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

Commit cc159e9a authored by Jerry Chang's avatar Jerry Chang Committed by Android (Google) Code Review
Browse files

Merge "Update top resumed activity and focused app while adding a task on top" into tm-qpr-dev

parents 3294ef42 affbd795
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3254,7 +3254,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
@@ -4624,7 +4624,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