nativebridge: Add PreZygoteFork callback
It's required to clean-up the emulated enviroment (e.g. close file
descriptors) after emulated execution in doPreload() in app-zygote.
Test: NativeBridge6PreZygoteFork_test
Test: CtsSeccompHostTestCases
android.seccomp.cts.SeccompHostJUnit4DeviceTest
testAppZygoteSyscalls
both for Q.sdk_gphone_x86_arm.armeabi-v7a
Bug: 146904103
Change-Id: Id192a1647c2f405570bf196daf65b3f2a9faca42
diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc
index 9287536..0651f0c 100644
--- a/runtime/native_bridge_art_interface.cc
+++ b/runtime/native_bridge_art_interface.cc
@@ -110,6 +110,10 @@
#endif
}
+void PreZygoteForkNativeBridge() {
+ android::PreZygoteForkNativeBridge();
+}
+
void InitializeNativeBridge(JNIEnv* env, const char* instruction_set) {
if (android::NativeBridgeInitialized()) {
// This happens in apps forked from app-zygote, since native bridge
diff --git a/runtime/native_bridge_art_interface.h b/runtime/native_bridge_art_interface.h
index c86e5da..873cd1f 100644
--- a/runtime/native_bridge_art_interface.h
+++ b/runtime/native_bridge_art_interface.h
@@ -31,6 +31,8 @@
// This is mostly for testing purposes, as in a full system this is called by Zygote code.
void PreInitializeNativeBridge(const std::string& dir);
+void PreZygoteForkNativeBridge();
+
void InitializeNativeBridge(JNIEnv* env, const char* instruction_set);
void UnloadNativeBridge();
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 0dc93c3..fa1916a 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -688,6 +688,7 @@
GetJit()->PreZygoteFork();
}
heap_->PreZygoteFork();
+ PreZygoteForkNativeBridge();
}
void Runtime::PostZygoteFork() {