diff options
author | 2019-12-13 15:49:37 -0800 | |
---|---|---|
committer | 2020-01-21 23:09:34 +0000 | |
commit | abafbe759a354dd6c6d81d4aba3f0aec9aca3d5b (patch) | |
tree | abd0c540ee97708916450c07bc37d4cd5229a902 /libnativebridge/native_bridge.cc | |
parent | 7ec3e60dd656509f4346fc94968f9de22cedcaaf (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/native_bridge.cc')
-rw-r--r-- | libnativebridge/native_bridge.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc index 1a54ace2e0..b24d14ade2 100644 --- a/libnativebridge/native_bridge.cc +++ b/libnativebridge/native_bridge.cc @@ -103,6 +103,8 @@ enum NativeBridgeImplementationVersion { VENDOR_NAMESPACE_VERSION = 4, // The version with runtime namespaces RUNTIME_NAMESPACE_VERSION = 5, + // The version with pre-zygote-fork hook to support app-zygotes. + PRE_ZYGOTE_FORK_VERSION = 6, }; // Whether we had an error at some point. @@ -328,6 +330,17 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct return true; } +void PreZygoteForkNativeBridge() { + if (NativeBridgeInitialized()) { + if (isCompatibleWith(PRE_ZYGOTE_FORK_VERSION)) { + return callbacks->preZygoteFork(); + } else { + ALOGE("not compatible with version %d, preZygoteFork() isn't invoked", + PRE_ZYGOTE_FORK_VERSION); + } + } +} + static void SetCpuAbi(JNIEnv* env, jclass build_class, const char* field, const char* value) { if (value != nullptr) { jfieldID field_id = env->GetStaticFieldID(build_class, field, "Ljava/lang/String;"); |