From afc15834eb9f75863b34cf5370bad71c32b14a73 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Thu, 26 Jul 2018 16:34:28 +0900 Subject: Ensure not to kill process when there's non-killable activity The process should only get killed when all activities get onStop. Current UX ensures that since all activity will get onStop in recents system UI. The code here will cause no difference before we envolve other ways for user to kill a process. For multi-tasking and multi-display, this is needed to prevent from voilating the lifecycle related API design. This is a starter tasks to improve large display UX, and a re-do of fe0af5fb1be4ad253774a5d6472eed8c76bd0885. Test: go/wm-smoke Test: Manual. life cycle is correct when close an app on ARC++. Bug: 111840655 Change-Id: I6311c973eba8795251d60ef6b0d44655ef836c5e --- .../core/java/com/android/server/am/ActivityStackSupervisor.java | 2 +- .../core/java/com/android/server/am/WindowProcessController.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 4e39033d83d8..086fcb565cb8 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -3183,7 +3183,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (!proc.shouldKillProcessForRemovedTask(tr)) { // Don't kill process(es) that has an activity in a different task that is also - // in recents. + // in recents, or has an activity not stopped. return; } diff --git a/services/core/java/com/android/server/am/WindowProcessController.java b/services/core/java/com/android/server/am/WindowProcessController.java index 817905a5e3d4..6f3fb8eb9b72 100644 --- a/services/core/java/com/android/server/am/WindowProcessController.java +++ b/services/core/java/com/android/server/am/WindowProcessController.java @@ -334,7 +334,12 @@ public class WindowProcessController { boolean shouldKillProcessForRemovedTask(TaskRecord tr) { for (int k = 0; k < mActivities.size(); k++) { - final TaskRecord otherTask = mActivities.get(k).getTask(); + final ActivityRecord activity = mActivities.get(k); + if (!activity.stopped) { + // Don't kill process(es) that has an activity not stopped. + return false; + } + final TaskRecord otherTask = activity.getTask(); if (tr.taskId != otherTask.taskId && otherTask.inRecents) { // Don't kill process(es) that has an activity in a different task that is // also in recents. -- cgit v1.2.3-59-g8ed1b