Merge "Fix issue #17740687: Device does not boot after flashing LMP dev TOT(1478825) build." into lmp-dev
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index e9f0558..bbfb62a 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -2243,9 +2243,13 @@
             r.idle = true;
 
             //Slog.i(TAG, "IDLE: mBooted=" + mBooted + ", fromTimeout=" + fromTimeout);
-            if (!mService.mBooted && isFrontStack(r.task.stack)) {
-                mService.mBooted = true;
-                enableScreen = true;
+            if (isFrontStack(r.task.stack) || fromTimeout) {
+                booting = mService.mBooting;
+                mService.mBooting = false;
+                if (!mService.mBooted) {
+                    mService.mBooted = true;
+                    enableScreen = true;
+                }
             }
         }
 
@@ -2273,9 +2277,6 @@
             mFinishingActivities.clear();
         }
 
-        booting = mService.mBooting;
-        mService.mBooting = false;
-
         if (mStartingUsers.size() > 0) {
             startingUsers = new ArrayList<UserStartedState>(mStartingUsers);
             mStartingUsers.clear();