summaryrefslogtreecommitdiff
path: root/libnativebridge/include/nativebridge/native_bridge.h
diff options
context:
space:
mode:
authorLev Rumyantsev <levarum@google.com>2019-12-13 15:49:37 -0800
committerLev Rumyantsev <levarum@google.com>2020-01-21 23:09:34 +0000
commitabafbe759a354dd6c6d81d4aba3f0aec9aca3d5b (patch)
treeabd0c540ee97708916450c07bc37d4cd5229a902 /libnativebridge/include/nativebridge/native_bridge.h
parent7ec3e60dd656509f4346fc94968f9de22cedcaaf (diff)
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
Diffstat (limited to 'libnativebridge/include/nativebridge/native_bridge.h')
-rw-r--r--libnativebridge/include/nativebridge/native_bridge.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/libnativebridge/include/nativebridge/native_bridge.h b/libnativebridge/include/nativebridge/native_bridge.h
index 22c128ba1f..e20b6270a1 100644
--- a/libnativebridge/include/nativebridge/native_bridge.h
+++ b/libnativebridge/include/nativebridge/native_bridge.h
@@ -50,6 +50,10 @@ bool NeedsNativeBridge(const char* instruction_set);
// high privileges.
bool PreInitializeNativeBridge(const char* app_data_dir, const char* instruction_set);
+// Prepare to fork from zygote. May be required to clean-up the enviroment, e.g.
+// close emulated file descriptors, after doPreload() in app-zygote.
+void PreZygoteForkNativeBridge();
+
// Initialize the native bridge, if any. Should be called by Runtime::DidForkFromZygote. The JNIEnv*
// will be used to modify the app environment for the bridge.
bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set);
@@ -374,6 +378,10 @@ struct NativeBridgeCallbacks {
// Returns:
// exported namespace or null if it was not set up for the device
struct native_bridge_namespace_t* (*getExportedNamespace)(const char* name);
+
+ // If native bridge is used in app-zygote (in doPreload()) this callback is
+ // required to clean-up the environment before the fork (see b/146904103).
+ void (*preZygoteFork)();
};
// Runtime interfaces to native bridge.