Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66409025 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update process lru when switching focus between visible activities" into main

parents 411c2f4e 2570260e
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -362,6 +362,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
     */
    private boolean mTopResumedActivityWaitingForPrev;

    /** Whether a process state update of top resumed activity is deferred. */
    private boolean mHasPendingTopResumedProcessState;

    /** The target root task bounds for the picture-in-picture mode changed that we need to
     * report to the application */
    private Rect mPipModeChangedTargetRootTaskBounds;
@@ -2367,6 +2370,17 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        }
    }

    /** This is only used for switching between resumed activities without activity state change. */
    private void updateTopResumedProcessState() {
        if (mTopResumedActivity == null || mTopResumedActivity.app == null) {
            return;
        }
        mTopResumedActivity.app.updateProcessInfo(
                false /* updateServiceConnectionActivities */, true /* activityChange */,
                false /* updateOomAdj */, true /* addPendingTopUid */);
        mService.updateOomAdj();
    }

    /**
     * Updates the record of top resumed activity when it changes and handles reporting of the
     * state changes to previous and new top activities. It will immediately dispatch top resumed
@@ -2401,10 +2415,11 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        // If the previous top is null, there should be activity state change from it, Then the
        // process state should also have been updated so no need to update again.
        if (mTopResumedActivity != null && prevTopActivity != null) {
            if (mTopResumedActivity.app != null) {
                mTopResumedActivity.app.addToPendingTop();
            if (readyToResume()) {
                updateTopResumedProcessState();
            } else {
                mHasPendingTopResumedProcessState = true;
            }
            mService.updateOomAdj();
        }
        // Update the last resumed activity and focused app when the top resumed activity changed
        // because the new top resumed activity might be already resumed and thus won't have
@@ -2697,6 +2712,10 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
    void endDeferResume() {
        mDeferResumeCount--;
        if (readyToResume()) {
            if (mHasPendingTopResumedProcessState) {
                mHasPendingTopResumedProcessState = false;
                updateTopResumedProcessState();
            }
            if (mLastReportedTopResumedActivity != null
                    && mTopResumedActivity != mLastReportedTopResumedActivity) {
                scheduleTopResumedActivityStateLossIfNeeded();
+3 −0
Original line number Diff line number Diff line
@@ -403,8 +403,11 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase {
            return null;
        }).when(mAtm.mAmInternal).addPendingTopUid(anyInt(), anyInt(), any());
        clearInvocations(mAtm);
        spyOn(activity1.app);
        activity1.moveFocusableActivityToTop("test");
        assertEquals(activity1.getUid(), pendingTopUid[0]);
        verify(activity1.app).updateProcessInfo(false /* updateServiceConnectionActivities */,
                true /* activityChange */, false /* updateOomAdj */, true /* addPendingTopUid */);
        verify(mAtm).updateOomAdj();
        verify(mAtm).setLastResumedActivityUncheckLocked(any(), eq("test"));
    }