@@ -725,7 +725,7 @@ final boolean realStartActivityLocked(ActivityRecord r,
725725 + ", giving up" , e );
726726 mService .appDiedLocked (app , app .pid , app .thread );
727727 requestFinishActivityLocked (r .appToken , Activity .RESULT_CANCELED , null ,
728- "2nd-crash" );
728+ "2nd-crash" , false );
729729 return false ;
730730 }
731731
@@ -1092,7 +1092,7 @@ private final void completePauseLocked() {
10921092 if (prev != null ) {
10931093 if (prev .finishing ) {
10941094 if (DEBUG_PAUSE ) Slog .v (TAG , "Executing finish of activity: " + prev );
1095- prev = finishCurrentActivityLocked (prev , FINISH_AFTER_VISIBLE );
1095+ prev = finishCurrentActivityLocked (prev , FINISH_AFTER_VISIBLE , false );
10961096 } else if (prev .app != null ) {
10971097 if (DEBUG_PAUSE ) Slog .v (TAG , "Enqueueing pending stop: " + prev );
10981098 if (prev .waitingVisible ) {
@@ -1504,7 +1504,7 @@ final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
15041504 Slog .d (TAG , "no-history finish of " + last + " on new resume" );
15051505 }
15061506 requestFinishActivityLocked (last .appToken , Activity .RESULT_CANCELED , null ,
1507- "no-history" );
1507+ "no-history" , false );
15081508 }
15091509 }
15101510
@@ -1726,7 +1726,7 @@ final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
17261726 // activity and try the next one.
17271727 Slog .w (TAG , "Exception thrown during resume of " + next , e );
17281728 requestFinishActivityLocked (next .appToken , Activity .RESULT_CANCELED , null ,
1729- "resume-exception" );
1729+ "resume-exception" , true );
17301730 return true ;
17311731 }
17321732
@@ -2080,7 +2080,7 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
20802080 continue ;
20812081 }
20822082 if (finishActivityLocked (p , srcPos ,
2083- Activity .RESULT_CANCELED , null , "reset" )) {
2083+ Activity .RESULT_CANCELED , null , "reset" , false )) {
20842084 replyChainEnd --;
20852085 srcPos --;
20862086 }
@@ -2143,7 +2143,7 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
21432143 continue ;
21442144 }
21452145 if (finishActivityLocked (p , srcPos ,
2146- Activity .RESULT_CANCELED , null , "reset" )) {
2146+ Activity .RESULT_CANCELED , null , "reset" , false )) {
21472147 taskTopI --;
21482148 lastReparentPos --;
21492149 replyChainEnd --;
@@ -2200,7 +2200,7 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
22002200 }
22012201 if (p .intent .getComponent ().equals (target .intent .getComponent ())) {
22022202 if (finishActivityLocked (p , j ,
2203- Activity .RESULT_CANCELED , null , "replace" )) {
2203+ Activity .RESULT_CANCELED , null , "replace" , false )) {
22042204 taskTopI --;
22052205 lastReparentPos --;
22062206 }
@@ -2270,7 +2270,7 @@ private final ActivityRecord performClearTaskLocked(int taskId,
22702270 continue ;
22712271 }
22722272 if (finishActivityLocked (r , i , Activity .RESULT_CANCELED ,
2273- null , "clear" )) {
2273+ null , "clear" , false )) {
22742274 i --;
22752275 }
22762276 }
@@ -2284,7 +2284,7 @@ private final ActivityRecord performClearTaskLocked(int taskId,
22842284 int index = indexOfTokenLocked (ret .appToken );
22852285 if (index >= 0 ) {
22862286 finishActivityLocked (ret , index , Activity .RESULT_CANCELED ,
2287- null , "clear" );
2287+ null , "clear" , false );
22882288 }
22892289 return null ;
22902290 }
@@ -2313,7 +2313,7 @@ private final void performClearTaskAtIndexLocked(int taskId, int i) {
23132313 continue ;
23142314 }
23152315 if (!finishActivityLocked (r , i , Activity .RESULT_CANCELED ,
2316- null , "clear" )) {
2316+ null , "clear" , false )) {
23172317 i ++;
23182318 }
23192319 }
@@ -2579,6 +2579,7 @@ final int startActivityLocked(IApplicationThread caller,
25792579 mDismissKeyguardOnNextActivity = false ;
25802580 mService .mWindowManager .dismissKeyguard ();
25812581 }
2582+ Slog .i (TAG , "DONE STARTING!" );
25822583 return err ;
25832584 }
25842585
@@ -3319,7 +3320,7 @@ private final void stopActivityLocked(ActivityRecord r) {
33193320 Slog .d (TAG , "no-history finish of " + r );
33203321 }
33213322 requestFinishActivityLocked (r .appToken , Activity .RESULT_CANCELED , null ,
3322- "no-history" );
3323+ "no-history" , false );
33233324 } else {
33243325 if (DEBUG_STATES ) Slog .d (TAG , "Not finishing noHistory " + r
33253326 + " on stop because we're just sleeping" );
@@ -3531,7 +3532,7 @@ final ActivityRecord activityIdleInternal(IBinder token, boolean fromTimeout,
35313532 ActivityRecord r = (ActivityRecord )stops .get (i );
35323533 synchronized (mService ) {
35333534 if (r .finishing ) {
3534- finishCurrentActivityLocked (r , FINISH_IMMEDIATELY );
3535+ finishCurrentActivityLocked (r , FINISH_IMMEDIATELY , false );
35353536 } else {
35363537 stopActivityLocked (r );
35373538 }
@@ -3585,7 +3586,7 @@ final void addStartingUserLocked(UserStartedState uss) {
35853586 * some reason it is being left as-is.
35863587 */
35873588 final boolean requestFinishActivityLocked (IBinder token , int resultCode ,
3588- Intent resultData , String reason ) {
3589+ Intent resultData , String reason , boolean oomAdj ) {
35893590 int index = indexOfTokenLocked (token );
35903591 if (DEBUG_RESULTS || DEBUG_STATES ) Slog .v (
35913592 TAG , "Finishing activity @" + index + ": token=" + token
@@ -3596,7 +3597,7 @@ final boolean requestFinishActivityLocked(IBinder token, int resultCode,
35963597 }
35973598 ActivityRecord r = mHistory .get (index );
35983599
3599- finishActivityLocked (r , index , resultCode , resultData , reason );
3600+ finishActivityLocked (r , index , resultCode , resultData , reason , oomAdj );
36003601 return true ;
36013602 }
36023603
@@ -3613,10 +3614,11 @@ final void finishSubActivityLocked(IBinder token, String resultWho, int requestC
36133614 if ((r .resultWho == null && resultWho == null ) ||
36143615 (r .resultWho != null && r .resultWho .equals (resultWho ))) {
36153616 finishActivityLocked (r , i ,
3616- Activity .RESULT_CANCELED , null , "request-sub" );
3617+ Activity .RESULT_CANCELED , null , "request-sub" , false );
36173618 }
36183619 }
36193620 }
3621+ mService .updateOomAdjLocked ();
36203622 }
36213623
36223624 final boolean finishActivityAffinityLocked (IBinder token ) {
@@ -3639,7 +3641,8 @@ final boolean finishActivityAffinityLocked(IBinder token) {
36393641 if (cur .taskAffinity != null && !cur .taskAffinity .equals (r .taskAffinity )) {
36403642 break ;
36413643 }
3642- finishActivityLocked (cur , index , Activity .RESULT_CANCELED , null , "request-affinity" );
3644+ finishActivityLocked (cur , index , Activity .RESULT_CANCELED , null ,
3645+ "request-affinity" , true );
36433646 index --;
36443647 }
36453648 return true ;
@@ -3677,16 +3680,16 @@ final void finishActivityResultsLocked(ActivityRecord r, int resultCode, Intent
36773680 * list, or false if it is still in the list and will be removed later.
36783681 */
36793682 final boolean finishActivityLocked (ActivityRecord r , int index ,
3680- int resultCode , Intent resultData , String reason ) {
3681- return finishActivityLocked (r , index , resultCode , resultData , reason , false );
3683+ int resultCode , Intent resultData , String reason , boolean oomAdj ) {
3684+ return finishActivityLocked (r , index , resultCode , resultData , reason , false , oomAdj );
36823685 }
36833686
36843687 /**
36853688 * @return Returns true if this activity has been removed from the history
36863689 * list, or false if it is still in the list and will be removed later.
36873690 */
3688- final boolean finishActivityLocked (ActivityRecord r , int index ,
3689- int resultCode , Intent resultData , String reason , boolean immediate ) {
3691+ final boolean finishActivityLocked (ActivityRecord r , int index , int resultCode ,
3692+ Intent resultData , String reason , boolean immediate , boolean oomAdj ) {
36903693 if (r .finishing ) {
36913694 Slog .w (TAG , "Duplicate finish request for " + r );
36923695 return false ;
@@ -3730,7 +3733,7 @@ final boolean finishActivityLocked(ActivityRecord r, int index,
37303733
37313734 if (immediate ) {
37323735 return finishCurrentActivityLocked (r , index ,
3733- FINISH_IMMEDIATELY ) == null ;
3736+ FINISH_IMMEDIATELY , oomAdj ) == null ;
37343737 } else if (mResumedActivity == r ) {
37353738 boolean endTask = index <= 0
37363739 || (mHistory .get (index -1 )).task != r .task ;
@@ -3754,7 +3757,7 @@ final boolean finishActivityLocked(ActivityRecord r, int index,
37543757 // it is done pausing; else we can just directly finish it here.
37553758 if (DEBUG_PAUSE ) Slog .v (TAG , "Finish not pausing: " + r );
37563759 return finishCurrentActivityLocked (r , index ,
3757- FINISH_AFTER_PAUSE ) == null ;
3760+ FINISH_AFTER_PAUSE , oomAdj ) == null ;
37583761 } else {
37593762 if (DEBUG_PAUSE ) Slog .v (TAG , "Finish waiting for pause of: " + r );
37603763 }
@@ -3767,17 +3770,17 @@ final boolean finishActivityLocked(ActivityRecord r, int index,
37673770 private static final int FINISH_AFTER_VISIBLE = 2 ;
37683771
37693772 private final ActivityRecord finishCurrentActivityLocked (ActivityRecord r ,
3770- int mode ) {
3773+ int mode , boolean oomAdj ) {
37713774 final int index = indexOfActivityLocked (r );
37723775 if (index < 0 ) {
37733776 return null ;
37743777 }
37753778
3776- return finishCurrentActivityLocked (r , index , mode );
3779+ return finishCurrentActivityLocked (r , index , mode , oomAdj );
37773780 }
37783781
37793782 private final ActivityRecord finishCurrentActivityLocked (ActivityRecord r ,
3780- int index , int mode ) {
3783+ int index , int mode , boolean oomAdj ) {
37813784 // First things first: if this activity is currently visible,
37823785 // and the resumed activity is not yet visible, then hold off on
37833786 // finishing until the resumed one becomes visible.
@@ -3796,7 +3799,9 @@ private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r,
37963799 if (DEBUG_STATES ) Slog .v (TAG , "Moving to STOPPING: " + r
37973800 + " (finish requested)" );
37983801 r .state = ActivityState .STOPPING ;
3799- mService .updateOomAdjLocked ();
3802+ if (oomAdj ) {
3803+ mService .updateOomAdjLocked ();
3804+ }
38003805 return r ;
38013806 }
38023807
@@ -3816,7 +3821,8 @@ private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r,
38163821 || prevState == ActivityState .INITIALIZING ) {
38173822 // If this activity is already stopped, we can just finish
38183823 // it right now.
3819- boolean activityRemoved = destroyActivityLocked (r , true , true , "finish-imm" );
3824+ boolean activityRemoved = destroyActivityLocked (r , true ,
3825+ oomAdj , "finish-imm" );
38203826 if (activityRemoved ) {
38213827 resumeTopActivityLocked (null );
38223828 }
@@ -4008,9 +4014,8 @@ final boolean destroyActivityLocked(ActivityRecord r,
40084014 ActivityManagerService .CANCEL_HEAVY_NOTIFICATION_MSG );
40094015 }
40104016 if (r .app .activities .size () == 0 ) {
4011- // No longer have activities, so update location in
4012- // LRU list.
4013- mService .updateLruProcessLocked (r .app , oomAdj , false );
4017+ // No longer have activities, so update oom adj.
4018+ mService .updateOomAdjLocked ();
40144019 }
40154020 }
40164021
0 commit comments