Merge "Save activity state before stopping acitivity when device sleeps" into nyc-mr1-dev

This commit is contained in:
TreeHugger Robot
2016-09-22 19:27:25 +00:00
committed by Android (Google) Code Review

View File

@@ -3799,7 +3799,7 @@ public final class ActivityThread {
* than our client -- for the server, stop means to save state and give * than our client -- for the server, stop means to save state and give
* it the result when it is done, but the window may still be visible. * it the result when it is done, but the window may still be visible.
* For the client, we want to call onStop()/onStart() to indicate when * For the client, we want to call onStop()/onStart() to indicate when
* the activity's UI visibillity changes. * the activity's UI visibility changes.
*/ */
private void performStopActivityInner(ActivityClientRecord r, private void performStopActivityInner(ActivityClientRecord r,
StopInfo info, boolean keepShown, boolean saveState, String reason) { StopInfo info, boolean keepShown, boolean saveState, String reason) {
@@ -3973,6 +3973,9 @@ public final class ActivityThread {
mSomeActivitiesChanged = true; mSomeActivitiesChanged = true;
} }
// TODO: This method should be changed to use {@link #performStopActivityInner} to perform to
// stop operation on the activity to reduce code duplication and the chance of fixing a bug in
// one place and missing the other.
private void handleSleeping(IBinder token, boolean sleeping) { private void handleSleeping(IBinder token, boolean sleeping) {
ActivityClientRecord r = mActivities.get(token); ActivityClientRecord r = mActivities.get(token);
@@ -3983,6 +3986,10 @@ public final class ActivityThread {
if (sleeping) { if (sleeping) {
if (!r.stopped && !r.isPreHoneycomb()) { if (!r.stopped && !r.isPreHoneycomb()) {
if (!r.activity.mFinished && r.state == null) {
callCallActivityOnSaveInstanceState(r);
}
try { try {
// Now we are idle. // Now we are idle.
r.activity.performStop(false /*preserveWindow*/); r.activity.performStop(false /*preserveWindow*/);