OSDN Git Service

Fix a bug: unable to start activity after starting activities during screen off.
authorleo_hsu <leo_hsu@htc.com>
Fri, 21 Mar 2014 04:27:16 +0000 (12:27 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 27 Aug 2014 10:19:19 +0000 (18:19 +0800)
Symptom: Unable to start any activity.
Root Cause: ActivityStack.mPausingActivity() points to a destroyed activity of a died process, so that ActivityStackSupervisor.allPausedActivitiesComplete() always returns false.
Solution: Set mPausingActivity to null in ActivityStack.cleanUpActivityLocked().
Reproduce steps:
    a. Turn screen off.
    b. A background service starts an activity X (in process X).
    c. A background service starts a no-history activity Y (in process Y), but the main thread of Y was blocked.
    d. A background service starts Y 3~4 times --> this causes am_failed_to_pause on X.
    e. Main thread of Y is freed finally --> this causes Y crash for android.view.WindowManager$BadTokenException.
    f. Turn screen on, X is shown on screen, but neither back key nor home key can work because mPausingActivity is Y.

Change-Id: I320b3db407e2d4cc745c8ca22a6e548742234242

services/java/com/android/server/am/ActivityStack.java

index abbb994..a02b4c4 100755 (executable)
@@ -2610,6 +2610,9 @@ final class ActivityStack {
         if (mResumedActivity == r) {
             mResumedActivity = null;
         }
+        if (mPausingActivity == r) {
+            mPausingActivity = null;
+        }
         if (mService.mFocusedActivity == r) {
             mService.mFocusedActivity = null;
         }