Stop activity onVisibleBehindCanceled()

Once an activity is no longer visible behind and has released
its background resources, it is added to the list of activities
that can be stopped, but not actually stopped until the next
major event (like another activity starting). We now schedule
the idle processing once the background resources have been
released so the activity can be stopped as soon as possible.

Bug: 18191707
Change-Id: I472eee949c1a78b4d944454463f03c90e7d2618b
This commit is contained in:
Wale Ogunwale
2014-11-13 14:22:32 -08:00
parent 04b6a6d3a1
commit 1f4c02bb18
2 changed files with 4 additions and 3 deletions

View File

@@ -6260,7 +6260,7 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized (this) {
ActivityStack stack = ActivityRecord.getStackLocked(token);
if (stack != null) {
stack.backgroundResourcesReleased(token);
stack.backgroundResourcesReleased();
}
}
} finally {

View File

@@ -3317,17 +3317,18 @@ final class ActivityStack {
mHandler.sendEmptyMessageDelayed(RELEASE_BACKGROUND_RESOURCES_TIMEOUT_MSG, 500);
} else {
Slog.e(TAG, "releaseBackgroundResources: activity " + r + " no longer running");
backgroundResourcesReleased(r.appToken);
backgroundResourcesReleased();
}
}
}
final void backgroundResourcesReleased(IBinder token) {
final void backgroundResourcesReleased() {
mHandler.removeMessages(RELEASE_BACKGROUND_RESOURCES_TIMEOUT_MSG);
final ActivityRecord r = getVisibleBehindActivity();
if (r != null) {
mStackSupervisor.mStoppingActivities.add(r);
setVisibleBehindActivity(null);
mStackSupervisor.scheduleIdleTimeoutLocked(null);
}
mStackSupervisor.resumeTopActivitiesLocked();
}