Merge "Fix warning of activity LRU list removal"

This commit is contained in:
TreeHugger Robot
2019-11-13 15:07:18 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 22 deletions

View File

@@ -2659,14 +2659,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
EventLog.writeEvent(EventLogTags.AM_DESTROY_ACTIVITY, mUserId,
System.identityHashCode(this), task.mTaskId, shortComponentName, reason);
final ActivityStack stack = getActivityStack();
if (hasProcess() && !stack.inLruList(this)) {
Slog.w(TAG, "Activity " + this + " being finished, but not in LRU list");
}
boolean removedFromHistory = false;
cleanUp(false /* cleanServices */, false /* setState */);
final ActivityStack stack = getActivityStack();
final boolean hadApp = hasProcess();
if (hadApp) {
if (hasProcess()) {
if (removeFromApp) {
app.removeActivity(this);
if (!app.hasActivities()) {
@@ -2731,10 +2733,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
configChangeFlags = 0;
if (!stack.removeActivityFromLRUList(this) && hadApp) {
Slog.w(TAG, "Activity " + this + " being finished, but not in LRU list");
}
return removedFromHistory;
}

View File

@@ -297,7 +297,7 @@ class ActivityStack extends TaskStack {
* The first entry in the list is the least recently used.
* It contains HistoryRecord objects.
*/
private final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<>();
private final ArrayList<ActivityRecord> mLruActivities = new ArrayList<>();
/**
* When we are in the process of pausing an activity, before starting the
@@ -1060,14 +1060,15 @@ class ActivityStack extends TaskStack {
}
/** @return {@code true} if LRU list contained the specified activity. */
final boolean removeActivityFromLRUList(ActivityRecord activity) {
return mLRUActivities.remove(activity);
final boolean inLruList(ActivityRecord activity) {
return mLruActivities.contains(activity);
}
final boolean updateLRUListLocked(ActivityRecord r) {
final boolean hadit = mLRUActivities.remove(r);
mLRUActivities.add(r);
return hadit;
/** @return {@code true} if the given activity was contained in LRU list. */
final boolean updateLruList(ActivityRecord r) {
final boolean contained = mLruActivities.remove(r);
mLruActivities.add(r);
return contained;
}
final boolean isHomeOrRecentsStack() {
@@ -2655,7 +2656,7 @@ class ActivityStack extends TaskStack {
next.app.updateProcessInfo(false /* updateServiceConnectionActivities */,
true /* activityChange */, true /* updateOomAdj */);
updateLRUListLocked(next);
updateLruList(next);
// Have the window manager re-evaluate the orientation of
// the screen based on the new activity order.
@@ -3645,10 +3646,10 @@ class ActivityStack extends TaskStack {
* an activity moves away from the stack.
*/
void onActivityRemovedFromStack(ActivityRecord r) {
removeActivityFromLRUList(r);
removeTimeoutsForActivity(r);
mExitingActivities.remove(r);
mLruActivities.remove(r);
if (mResumedActivity != null && mResumedActivity == r) {
setResumedActivity(null, "onActivityRemovedFromStack");
@@ -3659,9 +3660,12 @@ class ActivityStack extends TaskStack {
}
void onActivityAddedToStack(ActivityRecord r) {
if(r.getState() == RESUMED) {
if (r.isState(RESUMED)) {
setResumedActivity(r, "onActivityAddedToStack");
}
if (r.hasProcess()) {
updateLruList(r);
}
}
/// HANDLER INTERFACE BEGIN
@@ -3819,7 +3823,7 @@ class ActivityStack extends TaskStack {
}
private boolean removeHistoryRecordsForAppLocked(WindowProcessController app) {
removeHistoryRecordsForAppLocked(mLRUActivities, app, "mLRUActivities");
removeHistoryRecordsForAppLocked(mLruActivities, app, "mLruActivities");
removeHistoryRecordsForAppLocked(mStackSupervisor.mStoppingActivities, app,
"mStoppingActivities");
removeHistoryRecordsForAppLocked(mStackSupervisor.mGoingToSleepActivities, app,
@@ -4383,7 +4387,7 @@ class ActivityStack extends TaskStack {
boolean printed = dumpActivitiesLocked(fd, pw, dumpAll, dumpClient, dumpPackage,
needSep);
printed |= dumpHistoryList(fd, pw, mLRUActivities, " ", "Run", false,
printed |= dumpHistoryList(fd, pw, mLruActivities, " ", "Run", false,
!dumpAll, false, dumpPackage, true,
" Running activities (most recent first):", null);
@@ -4660,7 +4664,7 @@ class ActivityStack extends TaskStack {
// Apps may depend on onResume()/onPause() being called in pairs.
if (setResume) {
r.setState(RESUMED, "moveToFrontAndResumeStateIfNeeded");
updateLRUListLocked(r);
updateLruList(r);
}
// If the activity was previously pausing, then ensure we transfer that as well
if (setPause) {

View File

@@ -912,7 +912,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
}
r.launchFailed = false;
if (stack.updateLRUListLocked(r)) {
if (stack.updateLruList(r)) {
Slog.w(TAG, "Activity " + r + " being launched, but already in LRU list");
}