diff options
| author | Riddle Hsu <riddlehsu@google.com> | 2019-05-17 23:10:16 -0600 |
|---|---|---|
| committer | Riddle Hsu <riddlehsu@google.com> | 2019-06-11 15:28:01 +0800 |
| commit | 32dbdca4f5e3c4306f9b61e97625f8b9b9009cdd (patch) | |
| tree | 316e7bb37ae8b8c2ddc8829457d3ad3133866169 /core/java/android/os/Process.java | |
| parent | 33562e9a36b5a5902f36329f08d462119645108f (diff) | |
Start process of next activity with top priority in advance
In common cases, to resume the next activity we need to wait for the
current one to be paused. Since starting a process for activity is
asynchronous, if we already know the process of next activity has not
started yet, we can start the process earlier so the time waiting for
the pause to complete can be saved.
Also if the launching activity is going to be the top app, we can set
the top schedule group right after its process is started so the start
time before actually launching the activity can be improved.
Although before the current activity is paused, the next top activity
may still change and results some empty processes. That should not be
a common case and the process is still useful when going back the stack,
and the empty background processes are easier to be reclaimed.
Bug: 123043091
Test: AppLaunchTest
Test: Launch calculator from launcher, the event log am_proc_start will
show "pre-top-activity".
Test: Cold launch a top activity, the system log should not show
"not expected top priority".
Test: Use startActivities to start serveral activities in a sequence.
Check "adb shell cat /proc/$pid/task/$pid/cgroup" for each process.
Only the last one has top-app, others are background.
Change-Id: I9601b66e7cc0855fd7c2b573ded31fcf8d0711ae
Diffstat (limited to 'core/java/android/os/Process.java')
| -rw-r--r-- | core/java/android/os/Process.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 74c89d6898e5..b535e8d0601c 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -511,6 +511,7 @@ public class Process { * @param appDataDir null-ok the data directory of the app. * @param invokeWith null-ok the command to invoke with. * @param packageName null-ok the name of the package this process belongs to. + * @param isTopApp whether the process starts for high priority application. * * @param zygoteArgs Additional arguments to supply to the zygote process. * @return An object that describes the result of the attempt to start the process. @@ -530,11 +531,12 @@ public class Process { @Nullable String appDataDir, @Nullable String invokeWith, @Nullable String packageName, + boolean isTopApp, @Nullable String[] zygoteArgs) { return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids, runtimeFlags, mountExternal, targetSdkVersion, seInfo, abi, instructionSet, appDataDir, invokeWith, packageName, - /*useUsapPool=*/ true, zygoteArgs); + /*useUsapPool=*/ true, isTopApp, zygoteArgs); } /** @hide */ @@ -554,7 +556,7 @@ public class Process { return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids, runtimeFlags, mountExternal, targetSdkVersion, seInfo, abi, instructionSet, appDataDir, invokeWith, packageName, - /*useUsapPool=*/ false, zygoteArgs); + /*useUsapPool=*/ false, /*isTopApp=*/ false, zygoteArgs); } /** |
