Fix onStop not called when activity is under translucent
Activity was not stopped when device went to sleep if it was covered by
another translucent activity. The issue appeared after ag/864253 which
disabled stopping for visible activities.
Bug: 28191555
Change-Id: I39f0c5579ee3e5a16db888c72ace5dc43aa307bd
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 009c9a8..442a40e9 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1008,13 +1008,14 @@
void goToSleep() {
ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
- // Make sure any stopped but visible activities are now sleeping.
+ // Make sure any paused or stopped but visible activities are now sleeping.
// This ensures that the activity's onStop() is called.
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = activities.get(activityNdx);
- if (r.state == ActivityState.STOPPING || r.state == ActivityState.STOPPED) {
+ if (r.state == ActivityState.STOPPING || r.state == ActivityState.STOPPED
+ || r.state == ActivityState.PAUSED || r.state == ActivityState.PAUSING) {
r.setSleeping(true);
}
}