@@ -1474,6 +1474,21 @@ final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
14741474 return true ;
14751475 }
14761476
1477+ // If the most recent activity was noHistory but was only stopped rather
1478+ // than stopped+finished because the device went to sleep, we need to make
1479+ // sure to finish it as we're making a new activity topmost.
1480+ final ActivityRecord last = mLastPausedActivity ;
1481+ if (mService .mSleeping && last != null && !last .finishing ) {
1482+ if ((last .intent .getFlags ()&Intent .FLAG_ACTIVITY_NO_HISTORY ) != 0
1483+ || (last .info .flags &ActivityInfo .FLAG_NO_HISTORY ) != 0 ) {
1484+ if (DEBUG_STATES ) {
1485+ Slog .d (TAG , "no-history finish of " + last + " on new resume" );
1486+ }
1487+ requestFinishActivityLocked (last .appToken , Activity .RESULT_CANCELED , null ,
1488+ "no-history" );
1489+ }
1490+ }
1491+
14771492 if (prev != null && prev != next ) {
14781493 if (!prev .waitingVisible && next != null && !next .nowVisible ) {
14791494 prev .waitingVisible = true ;
@@ -3279,8 +3294,16 @@ private final void stopActivityLocked(ActivityRecord r) {
32793294 if ((r .intent .getFlags ()&Intent .FLAG_ACTIVITY_NO_HISTORY ) != 0
32803295 || (r .info .flags &ActivityInfo .FLAG_NO_HISTORY ) != 0 ) {
32813296 if (!r .finishing ) {
3282- requestFinishActivityLocked (r .appToken , Activity .RESULT_CANCELED , null ,
3283- "no-history" );
3297+ if (!mService .mSleeping ) {
3298+ if (DEBUG_STATES ) {
3299+ Slog .d (TAG , "no-history finish of " + r );
3300+ }
3301+ requestFinishActivityLocked (r .appToken , Activity .RESULT_CANCELED , null ,
3302+ "no-history" );
3303+ } else {
3304+ if (DEBUG_STATES ) Slog .d (TAG , "Not finishing noHistory " + r
3305+ + " on stop because we're just sleeping" );
3306+ }
32843307 }
32853308 }
32863309
@@ -3526,9 +3549,10 @@ final ActivityRecord activityIdleInternal(IBinder token, boolean fromTimeout,
35263549 final boolean requestFinishActivityLocked (IBinder token , int resultCode ,
35273550 Intent resultData , String reason ) {
35283551 int index = indexOfTokenLocked (token );
3529- if (DEBUG_RESULTS ) Slog .v (
3552+ if (DEBUG_RESULTS || DEBUG_STATES ) Slog .v (
35303553 TAG , "Finishing activity @" + index + ": token=" + token
3531- + ", result=" + resultCode + ", data=" + resultData );
3554+ + ", result=" + resultCode + ", data=" + resultData
3555+ + ", reason=" + reason );
35323556 if (index < 0 ) {
35333557 return false ;
35343558 }
0 commit comments