summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Filip Gruszczynski <gruszczy@google.com> 2015-12-04 14:52:25 -0800
committer Filip Gruszczynski <gruszczy@google.com> 2015-12-07 09:20:06 -0800
commitef2f72bb0e6fa6d286e571aea42751a9266151fa (patch)
tree9cc477e950ad7dc076e320475eb55417a431a0b7
parent5f986095bed776c119d2f5452e0afeac3a437ea2 (diff)
Refactoring: merge two snippets of adding activity to stopped.
Change-Id: I70777333ca9ff6c4f0736e036bd0946add4b041f
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java44
1 files changed, 20 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index bad71b23a553..60f26e224373 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -145,6 +145,9 @@ final class ActivityStack {
// convertToTranslucent().
static final long TRANSLUCENT_CONVERSION_TIMEOUT = 2000;
+ // How many activities have to be scheduled to stop to force a stop pass.
+ private static final int MAX_STOPPING_TO_FORCE = 3;
+
enum ActivityState {
INITIALIZING,
RESUMED,
@@ -1097,19 +1100,7 @@ final class ActivityStack {
} else if (!hasVisibleBehindActivity() || mService.isSleepingOrShuttingDown()) {
// If we were visible then resumeTopActivities will release resources before
// stopping.
-
- mStackSupervisor.mStoppingActivities.add(prev);
- if (mStackSupervisor.mStoppingActivities.size() > 3 ||
- prev.frontOfTask && mTaskHistory.size() <= 1) {
- // If we already have a few activities waiting to stop,
- // then give up on things going idle and start clearing
- // them out. Or if r is the last of activity of the last task the stack
- // will be empty and must be cleared immediately.
- if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "To many pending stops, forcing idle");
- mStackSupervisor.scheduleIdleLocked();
- } else {
- mStackSupervisor.checkReadyForSleepLocked();
- }
+ addToStopping(prev);
}
} else {
if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "App died during pause, not stopping: " + prev);
@@ -1166,6 +1157,21 @@ final class ActivityStack {
mService.notifyTaskStackChangedLocked();
}
+ private void addToStopping(ActivityRecord r) {
+ mStackSupervisor.mStoppingActivities.add(r);
+ if (mStackSupervisor.mStoppingActivities.size() > MAX_STOPPING_TO_FORCE ||
+ r.frontOfTask && mTaskHistory.size() <= 1) {
+ // If we already have a few activities waiting to stop,
+ // then give up on things going idle and start clearing
+ // them out. Or if r is the last of activity of the last task the stack
+ // will be empty and must be cleared immediately.
+ if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "To many pending stops, forcing idle");
+ mStackSupervisor.scheduleIdleLocked();
+ } else {
+ mStackSupervisor.checkReadyForSleepLocked();
+ }
+ }
+
/**
* Once we know that we have asked an application to put an activity in
* the resumed state (either by launching it or explicitly telling it),
@@ -3167,17 +3173,7 @@ final class ActivityStack {
// finishing until the resumed one becomes visible.
if (mode == FINISH_AFTER_VISIBLE && r.nowVisible) {
if (!mStackSupervisor.mStoppingActivities.contains(r)) {
- mStackSupervisor.mStoppingActivities.add(r);
- if (mStackSupervisor.mStoppingActivities.size() > 3
- || r.frontOfTask && mTaskHistory.size() <= 1) {
- // If we already have a few activities waiting to stop,
- // then give up on things going idle and start clearing
- // them out. Or if r is the last of activity of the last task the stack
- // will be empty and must be cleared immediately.
- mStackSupervisor.scheduleIdleLocked();
- } else {
- mStackSupervisor.checkReadyForSleepLocked();
- }
+ addToStopping(r);
}
if (DEBUG_STATES) Slog.v(TAG_STATES,
"Moving to STOPPING: "+ r + " (finish requested)");