Loading core/java/android/os/AppZygote.java +3 −2 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class AppZygote { pkgDataInfoMap, @Nullable Map<String, Pair<String, Long>> allowlistedDataInfoList, long startSeq, @Nullable String[] zygoteArgs) { try { return getProcess().start(processClass, Loading @@ -153,7 +154,7 @@ public class AppZygote { appDataDir, null, packageName, /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, false, false, false, false, false, false, startSeq, zygoteArgs); } catch (RuntimeException e) { final boolean zygote_dead = getProcess().isDead(); Loading @@ -170,7 +171,7 @@ public class AppZygote { appDataDir, null, packageName, /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, false, false, false, false, false, false, startSeq, zygoteArgs); } Loading core/java/android/os/Process.java +12 −2 Original line number Diff line number Diff line Loading @@ -670,6 +670,13 @@ public class Process { */ public static final int ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS = 1 << 2; /** * Flag used to indicate that the current launch event is for a native process. * * @hide */ public static final int ZYGOTE_POLICY_FLAG_NATIVE_PROCESS = 1 << 3; /** * State associated with the zygote process. * @hide Loading Loading @@ -752,13 +759,14 @@ public class Process { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindMountSystemOverrides, long startSeq, @Nullable String[] zygoteArgs) { return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids, runtimeFlags, mountExternal, targetSdkVersion, seInfo, abi, instructionSet, appDataDir, invokeWith, packageName, zygotePolicyFlags, isTopApp, disabledCompatChanges, pkgDataInfoMap, whitelistedDataInfoMap, bindMountAppsData, bindMountAppStorageDirs, bindMountSystemOverrides, zygoteArgs); bindMountAppStorageDirs, bindMountSystemOverrides, startSeq, zygoteArgs); } /** @hide */ Loading @@ -775,6 +783,7 @@ public class Process { @Nullable String invokeWith, @Nullable String packageName, @Nullable long[] disabledCompatChanges, long startSeq, @Nullable String[] zygoteArgs) { // Webview zygote can't access app private data files, so doesn't need to know its data // info. Loading @@ -784,7 +793,8 @@ public class Process { /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, /*isTopApp=*/ false, disabledCompatChanges, /* pkgDataInfoMap */ null, /* whitelistedDataInfoMap */ null, /* bindMountAppsData */ false, /* bindMountAppStorageDirs */ false, /* bindMountSyspropOverrides */ false, zygoteArgs); /* bindMountAppStorageDirs */ false, /* bindMountSyspropOverrides */ false, startSeq, zygoteArgs); } /** Loading core/java/android/os/ZygoteProcess.java +25 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.os; import static android.os.Process.ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE; import static android.os.Process.ZYGOTE_POLICY_FLAG_NATIVE_PROCESS; import static android.os.Process.ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS; import android.annotation.NonNull; Loading Loading @@ -359,6 +360,7 @@ public class ZygoteProcess { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindOverrideSysprops, long startSeq, @Nullable String[] zygoteArgs) { // TODO (chriswailes): Is there a better place to check this value? if (fetchUsapPoolEnabledPropWithMinInterval()) { Loading @@ -371,7 +373,7 @@ public class ZygoteProcess { abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false, packageName, zygotePolicyFlags, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, bindMountAppsData, bindMountAppStorageDirs, bindOverrideSysprops, zygoteArgs); bindMountAppStorageDirs, bindOverrideSysprops, startSeq, zygoteArgs); } catch (ZygoteStartFailedEx ex) { Log.e(LOG_TAG, "Starting VM process through Zygote failed"); Loading Loading @@ -591,6 +593,11 @@ public class ZygoteProcess { return true; } private static native int nativeStartNativeProcess( int uid, int gid, long startSeq, String packageName, String niceName, int targetSdkVersion, boolean startChildZygote, int runtimeFlags, String seInfo); /** * Starts a new process via the zygote mechanism. * Loading Loading @@ -645,8 +652,23 @@ public class ZygoteProcess { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindMountOverrideSysprops, long startSeq, @Nullable String[] extraArgs) throws ZygoteStartFailedEx { if (Flags.nativeFrameworkPrototype() && (zygotePolicyFlags & ZYGOTE_POLICY_FLAG_NATIVE_PROCESS) != 0) { Log.i(LOG_TAG, "about to request forking a native process to the native zygote!!!"); int pid = nativeStartNativeProcess(uid, gid, startSeq, packageName, niceName, targetSdkVersion, startChildZygote, runtimeFlags, seInfo); if (pid == -1) { throw new ZygoteStartFailedEx("Failed to fork a native process."); } Process.ProcessStartResult result = new Process.ProcessStartResult(); result.pid = pid; result.usingWrapper = false; return result; } ArrayList<String> argsForZygote = new ArrayList<>(); // --runtime-args, --setuid=, --setgid=, Loading @@ -655,6 +677,7 @@ public class ZygoteProcess { argsForZygote.add("--setuid=" + uid); argsForZygote.add("--setgid=" + gid); argsForZygote.add("--runtime-flags=" + runtimeFlags); if (mountExternal == Zygote.MOUNT_EXTERNAL_DEFAULT) { argsForZygote.add("--mount-external-default"); } else if (mountExternal == Zygote.MOUNT_EXTERNAL_INSTALLER) { Loading Loading @@ -1313,7 +1336,7 @@ public class ZygoteProcess { null /* disabledCompatChanges */, null /* pkgDataInfoMap */, null /* allowlistedDataInfoList */, true /* bindMountAppsData*/, /* bindMountAppStorageDirs */ false, /*bindMountOverrideSysprops */ false, extraArgs); /* startSeq */ 0, extraArgs); } catch (ZygoteStartFailedEx ex) { throw new RuntimeException("Starting child-zygote through Zygote failed", ex); Loading core/jni/Android.bp +25 −3 Original line number Diff line number Diff line Loading @@ -281,7 +281,19 @@ cc_library_shared_for_libandroid_runtime { "android_tracing_PerfettoDataSource.cpp", "android_tracing_PerfettoDataSourceInstance.cpp", "android_tracing_PerfettoProducer.cpp", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "android_os_ZygoteProcess.cpp", ], default: [], }), cppflags: select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "-DANDROID_NATIVE_FRAMEWORK_PROTOTYPE", ], default: [], }), static_libs: [ "android.os.flags-aconfig-cc", Loading @@ -297,7 +309,12 @@ cc_library_shared_for_libandroid_runtime { "libscrypt_static", "libstatssocket_lazy", "libskia", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "libflatbuffers-cpp", ], default: [], }), shared_libs: [ "libbase", Loading Loading @@ -404,7 +421,12 @@ cc_library_shared_for_libandroid_runtime { "dnsproxyd_protocol_headers", "flatbuffer_headers", "tensorflow_headers", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "libzygote_schema_headers", ], default: [], }), runtime_libs: [ "libidmap2", ], Loading core/jni/AndroidRuntime.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,9 @@ extern int register_android_os_UEventObserver(JNIEnv* env); extern int register_android_os_HidlMemory(JNIEnv* env); extern int register_android_os_MemoryFile(JNIEnv* env); extern int register_android_os_SharedMemory(JNIEnv* env); #ifdef ANDROID_NATIVE_FRAMEWORK_PROTOTYPE extern int register_android_os_ZygoteProcess(JNIEnv* env); #endif extern int register_android_service_DataLoaderService(JNIEnv* env); extern int register_android_os_incremental_IncrementalManager(JNIEnv* env); extern int register_android_net_LocalSocketImpl(JNIEnv* env); Loading Loading @@ -1631,6 +1634,9 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_net_LocalSocketImpl), REG_JNI(register_android_os_MemoryFile), REG_JNI(register_android_os_SharedMemory), #ifdef ANDROID_NATIVE_FRAMEWORK_PROTOTYPE REG_JNI(register_android_os_ZygoteProcess), #endif REG_JNI(register_android_os_incremental_IncrementalManager), REG_JNI(register_com_android_internal_content_om_OverlayConfig), REG_JNI(register_com_android_internal_content_om_OverlayManagerImpl), Loading Loading
core/java/android/os/AppZygote.java +3 −2 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class AppZygote { pkgDataInfoMap, @Nullable Map<String, Pair<String, Long>> allowlistedDataInfoList, long startSeq, @Nullable String[] zygoteArgs) { try { return getProcess().start(processClass, Loading @@ -153,7 +154,7 @@ public class AppZygote { appDataDir, null, packageName, /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, false, false, false, false, false, false, startSeq, zygoteArgs); } catch (RuntimeException e) { final boolean zygote_dead = getProcess().isDead(); Loading @@ -170,7 +171,7 @@ public class AppZygote { appDataDir, null, packageName, /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, false, false, false, false, false, false, startSeq, zygoteArgs); } Loading
core/java/android/os/Process.java +12 −2 Original line number Diff line number Diff line Loading @@ -670,6 +670,13 @@ public class Process { */ public static final int ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS = 1 << 2; /** * Flag used to indicate that the current launch event is for a native process. * * @hide */ public static final int ZYGOTE_POLICY_FLAG_NATIVE_PROCESS = 1 << 3; /** * State associated with the zygote process. * @hide Loading Loading @@ -752,13 +759,14 @@ public class Process { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindMountSystemOverrides, long startSeq, @Nullable String[] zygoteArgs) { return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids, runtimeFlags, mountExternal, targetSdkVersion, seInfo, abi, instructionSet, appDataDir, invokeWith, packageName, zygotePolicyFlags, isTopApp, disabledCompatChanges, pkgDataInfoMap, whitelistedDataInfoMap, bindMountAppsData, bindMountAppStorageDirs, bindMountSystemOverrides, zygoteArgs); bindMountAppStorageDirs, bindMountSystemOverrides, startSeq, zygoteArgs); } /** @hide */ Loading @@ -775,6 +783,7 @@ public class Process { @Nullable String invokeWith, @Nullable String packageName, @Nullable long[] disabledCompatChanges, long startSeq, @Nullable String[] zygoteArgs) { // Webview zygote can't access app private data files, so doesn't need to know its data // info. Loading @@ -784,7 +793,8 @@ public class Process { /*zygotePolicyFlags=*/ ZYGOTE_POLICY_FLAG_EMPTY, /*isTopApp=*/ false, disabledCompatChanges, /* pkgDataInfoMap */ null, /* whitelistedDataInfoMap */ null, /* bindMountAppsData */ false, /* bindMountAppStorageDirs */ false, /* bindMountSyspropOverrides */ false, zygoteArgs); /* bindMountAppStorageDirs */ false, /* bindMountSyspropOverrides */ false, startSeq, zygoteArgs); } /** Loading
core/java/android/os/ZygoteProcess.java +25 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.os; import static android.os.Process.ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE; import static android.os.Process.ZYGOTE_POLICY_FLAG_NATIVE_PROCESS; import static android.os.Process.ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS; import android.annotation.NonNull; Loading Loading @@ -359,6 +360,7 @@ public class ZygoteProcess { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindOverrideSysprops, long startSeq, @Nullable String[] zygoteArgs) { // TODO (chriswailes): Is there a better place to check this value? if (fetchUsapPoolEnabledPropWithMinInterval()) { Loading @@ -371,7 +373,7 @@ public class ZygoteProcess { abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false, packageName, zygotePolicyFlags, isTopApp, disabledCompatChanges, pkgDataInfoMap, allowlistedDataInfoList, bindMountAppsData, bindMountAppStorageDirs, bindOverrideSysprops, zygoteArgs); bindMountAppStorageDirs, bindOverrideSysprops, startSeq, zygoteArgs); } catch (ZygoteStartFailedEx ex) { Log.e(LOG_TAG, "Starting VM process through Zygote failed"); Loading Loading @@ -591,6 +593,11 @@ public class ZygoteProcess { return true; } private static native int nativeStartNativeProcess( int uid, int gid, long startSeq, String packageName, String niceName, int targetSdkVersion, boolean startChildZygote, int runtimeFlags, String seInfo); /** * Starts a new process via the zygote mechanism. * Loading Loading @@ -645,8 +652,23 @@ public class ZygoteProcess { boolean bindMountAppsData, boolean bindMountAppStorageDirs, boolean bindMountOverrideSysprops, long startSeq, @Nullable String[] extraArgs) throws ZygoteStartFailedEx { if (Flags.nativeFrameworkPrototype() && (zygotePolicyFlags & ZYGOTE_POLICY_FLAG_NATIVE_PROCESS) != 0) { Log.i(LOG_TAG, "about to request forking a native process to the native zygote!!!"); int pid = nativeStartNativeProcess(uid, gid, startSeq, packageName, niceName, targetSdkVersion, startChildZygote, runtimeFlags, seInfo); if (pid == -1) { throw new ZygoteStartFailedEx("Failed to fork a native process."); } Process.ProcessStartResult result = new Process.ProcessStartResult(); result.pid = pid; result.usingWrapper = false; return result; } ArrayList<String> argsForZygote = new ArrayList<>(); // --runtime-args, --setuid=, --setgid=, Loading @@ -655,6 +677,7 @@ public class ZygoteProcess { argsForZygote.add("--setuid=" + uid); argsForZygote.add("--setgid=" + gid); argsForZygote.add("--runtime-flags=" + runtimeFlags); if (mountExternal == Zygote.MOUNT_EXTERNAL_DEFAULT) { argsForZygote.add("--mount-external-default"); } else if (mountExternal == Zygote.MOUNT_EXTERNAL_INSTALLER) { Loading Loading @@ -1313,7 +1336,7 @@ public class ZygoteProcess { null /* disabledCompatChanges */, null /* pkgDataInfoMap */, null /* allowlistedDataInfoList */, true /* bindMountAppsData*/, /* bindMountAppStorageDirs */ false, /*bindMountOverrideSysprops */ false, extraArgs); /* startSeq */ 0, extraArgs); } catch (ZygoteStartFailedEx ex) { throw new RuntimeException("Starting child-zygote through Zygote failed", ex); Loading
core/jni/Android.bp +25 −3 Original line number Diff line number Diff line Loading @@ -281,7 +281,19 @@ cc_library_shared_for_libandroid_runtime { "android_tracing_PerfettoDataSource.cpp", "android_tracing_PerfettoDataSourceInstance.cpp", "android_tracing_PerfettoProducer.cpp", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "android_os_ZygoteProcess.cpp", ], default: [], }), cppflags: select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "-DANDROID_NATIVE_FRAMEWORK_PROTOTYPE", ], default: [], }), static_libs: [ "android.os.flags-aconfig-cc", Loading @@ -297,7 +309,12 @@ cc_library_shared_for_libandroid_runtime { "libscrypt_static", "libstatssocket_lazy", "libskia", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "libflatbuffers-cpp", ], default: [], }), shared_libs: [ "libbase", Loading Loading @@ -404,7 +421,12 @@ cc_library_shared_for_libandroid_runtime { "dnsproxyd_protocol_headers", "flatbuffer_headers", "tensorflow_headers", ] + select(release_flag("RELEASE_NATIVE_FRAMEWORK_PROTOTYPE"), { true: [ "libzygote_schema_headers", ], default: [], }), runtime_libs: [ "libidmap2", ], Loading
core/jni/AndroidRuntime.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,9 @@ extern int register_android_os_UEventObserver(JNIEnv* env); extern int register_android_os_HidlMemory(JNIEnv* env); extern int register_android_os_MemoryFile(JNIEnv* env); extern int register_android_os_SharedMemory(JNIEnv* env); #ifdef ANDROID_NATIVE_FRAMEWORK_PROTOTYPE extern int register_android_os_ZygoteProcess(JNIEnv* env); #endif extern int register_android_service_DataLoaderService(JNIEnv* env); extern int register_android_os_incremental_IncrementalManager(JNIEnv* env); extern int register_android_net_LocalSocketImpl(JNIEnv* env); Loading Loading @@ -1631,6 +1634,9 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_net_LocalSocketImpl), REG_JNI(register_android_os_MemoryFile), REG_JNI(register_android_os_SharedMemory), #ifdef ANDROID_NATIVE_FRAMEWORK_PROTOTYPE REG_JNI(register_android_os_ZygoteProcess), #endif REG_JNI(register_android_os_incremental_IncrementalManager), REG_JNI(register_com_android_internal_content_om_OverlayConfig), REG_JNI(register_com_android_internal_content_om_OverlayManagerImpl), Loading