diff options
| author | 2019-08-08 05:53:00 -0700 | |
|---|---|---|
| committer | 2019-08-08 05:53:00 -0700 | |
| commit | 6e1687440127d3903ce4e18ebee51a6d22c4893b (patch) | |
| tree | 174e04624dd38c0ed9b2f16e3051256aad659818 | |
| parent | f9a466503c90b5bce9f72fd4a463c7abd9af5d4f (diff) | |
| parent | 8f93d19459bc294f9d075a6e2efeab71effed175 (diff) | |
Merge "Notify the ART runtime when boot is complete." am: f83748ae28 am: 6b9ab57b2d am: ed22d5f05c
am: 8f93d19459
Change-Id: Iddebb915552b39cfb4cbe59bb67eb1c2aae0c8ea
4 files changed, 50 insertions, 1 deletions
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java index 09e09e9f8a13..e923336da454 100644 --- a/core/java/android/os/ZygoteProcess.java +++ b/core/java/android/os/ZygoteProcess.java @@ -742,6 +742,31 @@ public class ZygoteProcess { } /** + * Notify the Zygote processes that boot completed. + */ + public void bootCompleted() { + // Notify both the 32-bit and 64-bit zygote. + if (Build.SUPPORTED_32_BIT_ABIS.length > 0) { + bootCompleted(Build.SUPPORTED_32_BIT_ABIS[0]); + } + if (Build.SUPPORTED_64_BIT_ABIS.length > 0) { + bootCompleted(Build.SUPPORTED_64_BIT_ABIS[0]); + } + } + + private void bootCompleted(String abi) { + try { + synchronized (mLock) { + ZygoteState state = openZygoteSocketIfNeeded(abi); + state.mZygoteOutputWriter.write("1\n--boot-completed\n"); + state.mZygoteOutputWriter.flush(); + } + } catch (Exception ex) { + throw new RuntimeException("Failed to inform zygote of boot_completed", ex); + } + } + + /** * Push hidden API blacklisting exemptions into the zygote process(es). * * <p>The list of exemptions will take affect for all new processes forked from the zygote after diff --git a/core/java/com/android/internal/os/ZygoteArguments.java b/core/java/com/android/internal/os/ZygoteArguments.java index 2564f6b4d610..fc55ccf4d6b7 100644 --- a/core/java/com/android/internal/os/ZygoteArguments.java +++ b/core/java/com/android/internal/os/ZygoteArguments.java @@ -187,6 +187,11 @@ class ZygoteArguments { boolean mPidQuery; /** + * Whether the current arguments constitute a notification that boot completed. + */ + boolean mBootCompleted; + + /** * Exemptions from API blacklisting. These are sent to the pre-forked zygote at boot time, or * when they change, via --set-api-blacklist-exemptions. */ @@ -360,6 +365,8 @@ class ZygoteArguments { mAbiListQuery = true; } else if (arg.equals("--get-pid")) { mPidQuery = true; + } else if (arg.equals("--boot-completed")) { + mBootCompleted = true; } else if (arg.startsWith("--instruction-set=")) { mInstructionSet = arg.substring(arg.indexOf('=') + 1); } else if (arg.startsWith("--app-data-dir=")) { @@ -414,7 +421,11 @@ class ZygoteArguments { } } - if (mAbiListQuery || mPidQuery) { + if (mBootCompleted) { + if (args.length - curArg > 0) { + throw new IllegalArgumentException("Unexpected arguments after --boot-completed"); + } + } else if (mAbiListQuery || mPidQuery) { if (args.length - curArg > 0) { throw new IllegalArgumentException("Unexpected arguments after --query-abi-list."); } diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 78f82ea100a4..ad53eb9feeae 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -140,6 +140,11 @@ class ZygoteConnection { ZygoteArguments parsedArgs = new ZygoteArguments(args); + if (parsedArgs.mBootCompleted) { + handleBootCompleted(); + return null; + } + if (parsedArgs.mAbiListQuery) { handleAbiListQuery(); return null; @@ -299,6 +304,10 @@ class ZygoteConnection { } } + private void handleBootCompleted() { + VMRuntime.bootCompleted(); + } + /** * Preloads resources if the zygote is in lazily preload mode. Writes the result of the * preload operation; {@code 0} when a preload was initiated due to this request and {@code 1} diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index ed2ee25f4f9a..0a774f613670 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -5225,6 +5225,10 @@ public class ActivityManagerService extends IActivityManager.Stub } } + // Let the ART runtime in zygote and system_server know that the boot completed. + ZYGOTE_PROCESS.bootCompleted(); + VMRuntime.bootCompleted(); + IntentFilter pkgFilter = new IntentFilter(); pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART); pkgFilter.addDataScheme("package"); |