summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wale Ogunwale <ogunwale@google.com> 2016-09-22 20:36:32 +0000
committer android-build-merger <android-build-merger@google.com> 2016-09-22 20:36:32 +0000
commit3adb9d93184efa6ec790e8a72abdf9dbc10970ad (patch)
tree94d3075c3262bc2ae2537eed730715137befbe35
parentc2226d8db60b7827a2fe5a2593788e4c4963be3c (diff)
parentb5066fe30790e3e5741ac2e6ef180c79ff8cf048 (diff)
Save activity state before stopping acitivity when device sleeps
am: b5066fe307 Change-Id: I95e897de48a9f5b10728110b5b3c9d379f86f695
-rw-r--r--core/java/android/app/ActivityThread.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 18677dda3b88..d9492cbd2911 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3799,7 +3799,7 @@ public final class ActivityThread {
* 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.
* 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,
StopInfo info, boolean keepShown, boolean saveState, String reason) {
@@ -3973,6 +3973,9 @@ public final class ActivityThread {
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) {
ActivityClientRecord r = mActivities.get(token);
@@ -3983,6 +3986,10 @@ public final class ActivityThread {
if (sleeping) {
if (!r.stopped && !r.isPreHoneycomb()) {
+ if (!r.activity.mFinished && r.state == null) {
+ callCallActivityOnSaveInstanceState(r);
+ }
+
try {
// Now we are idle.
r.activity.performStop(false /*preserveWindow*/);