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

Commit affbd795 authored by Jerry Chang's avatar Jerry Chang
Browse files

Update top resumed activity and focused app while adding a task on top

Drag to dismiss a split pair reparents the task on non-dismissing side
to the top of its TaskDisplayArea. The focused app should be updated if
the task on dismissing side was top focused.

This makes sure to update top resumed activity when adding a task on top
of a TaskDisplayArea. Also makes sure to update focsued app and last
resumsed activity in AMS while updating top resumed activity.

Fix: 242141128
Test: check mFocusedApp in dumpsys with repro steps of the bug
Test: atest ActivityTaskSupervisorTests
Test: atest ActivityRecordTests TaskDisplayAreaTests
Change-Id: I2dd0ca73df9c46ffce42cfc52280be35aeb9e2ec
parent bc18e296
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3247,7 +3247,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        rootTask.moveToFront(reason, task);
        // Report top activity change to tracking services and WM
        if (mRootWindowContainer.getTopResumedActivity() == this) {
            mAtmService.setResumedActivityUncheckLocked(this, reason);
            mAtmService.setLastResumedActivityUncheckLocked(this, reason);
        }
        return true;
    }
+1 −1
Original line number Diff line number Diff line
@@ -4623,7 +4623,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

    /** Update AMS states when an activity is resumed. */
    void setResumedActivityUncheckLocked(ActivityRecord r, String reason) {
    void setLastResumedActivityUncheckLocked(ActivityRecord r, String reason) {
        final Task task = r.getTask();
        if (task.isActivityTypeStandard()) {
            if (mCurAppTimeTracker != r.appTimeTracker) {
+7 −1
Original line number Diff line number Diff line
@@ -2083,7 +2083,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
     * activity releases the top state and reports back, message about acquiring top state will be
     * sent to the new top resumed activity.
     */
    void updateTopResumedActivityIfNeeded() {
    void updateTopResumedActivityIfNeeded(String reason) {
        final ActivityRecord prevTopActivity = mTopResumedActivity;
        final Task topRootTask = mRootWindowContainer.getTopDisplayFocusedRootTask();
        if (topRootTask == null || topRootTask.getTopResumedActivity() == prevTopActivity) {
@@ -2119,6 +2119,12 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            }
            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
        // activity state change to update the records to AMS.
        if (mTopResumedActivity != null) {
            mService.setLastResumedActivityUncheckLocked(mTopResumedActivity, reason);
        }
        scheduleTopResumedActivityStateIfNeeded();

        mService.updateTopApp(mTopResumedActivity);
+1 −1
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    void onChildPositionChanged(WindowContainer child) {
        mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
                !mWmService.mPerDisplayFocusEnabled /* updateInputWindows */);
        mTaskSupervisor.updateTopResumedActivityIfNeeded();
        mTaskSupervisor.updateTopResumedActivityIfNeeded("onChildPositionChanged");
    }

    @Override
+2 −6
Original line number Diff line number Diff line
@@ -920,7 +920,7 @@ class Task extends TaskFragment {
                // If the original state is resumed, there is no state change to update focused app.
                // So here makes sure the activity focus is set if it is the top.
                if (r.isState(RESUMED) && r == mRootWindowContainer.getTopResumedActivity()) {
                    mAtmService.setResumedActivityUncheckLocked(r, reason);
                    mAtmService.setLastResumedActivityUncheckLocked(r, reason);
                }
            }
            if (!animate) {
@@ -2439,11 +2439,7 @@ class Task extends TaskFragment {
        focusableTask.moveToFront(myReason);
        // Top display focused root task is changed, update top resumed activity if needed.
        if (rootTask.getTopResumedActivity() != null) {
            mTaskSupervisor.updateTopResumedActivityIfNeeded();
            // Set focused app directly because if the next focused activity is already resumed
            // (e.g. the next top activity is on a different display), there won't have activity
            // state change to update it.
            mAtmService.setResumedActivityUncheckLocked(rootTask.getTopResumedActivity(), reason);
            mTaskSupervisor.updateTopResumedActivityIfNeeded(reason);
        }
        return rootTask;
    }
Loading