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

Commit 67e0a033 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce unnecessary operations in the setFocusedTask" into udc-dev

parents 272ee645 9e9bc72f
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -2011,6 +2011,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            return;
        }

        if (r == mRootWindowContainer.getTopResumedActivity()) {
            setLastResumedActivityUncheckLocked(r, "setFocusedTask-alreadyTop");
            return;
        }
        final Transition transition = (getTransitionController().isCollecting()
                || !getTransitionController().isShellTransitionsEnabled()) ? null
                : getTransitionController().createTransition(TRANSIT_TO_FRONT);
@@ -4788,11 +4792,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        // until we've committed to the gesture. The focus will be transferred at the end of
        // the transition (if the transient launch is committed) or early if explicitly requested
        // via `setFocused*`.
        boolean focusedAppChanged = false;
        if (!getTransitionController().isTransientCollect(r)) {
            final Task prevFocusTask = r.mDisplayContent.mFocusedApp != null
                    ? r.mDisplayContent.mFocusedApp.getTask() : null;
            final boolean changed = r.mDisplayContent.setFocusedApp(r);
            if (changed) {
            focusedAppChanged = r.mDisplayContent.setFocusedApp(r);
            if (focusedAppChanged) {
                mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
                        true /*updateInputWindows*/);
            }
@@ -4801,13 +4804,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            mTaskSupervisor.mRecentTasks.add(task);
        }

        if (focusedAppChanged) {
            applyUpdateLockStateLocked(r);
        }
        if (mVrController.mVrService != null) {
            applyUpdateVrModeLocked(r);
        }

        EventLogTags.writeWmSetResumedActivity(
                r == null ? -1 : r.mUserId,
                r == null ? "NULL" : r.shortComponentName,
                reason);
        EventLogTags.writeWmSetResumedActivity(r.mUserId, r.shortComponentName, reason);
    }

    final class SleepTokenAcquirerImpl implements ActivityTaskManagerInternal.SleepTokenAcquirer {
+5 −1
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ final class VrController {
        }
    };

    /** If it is null after system ready, then VR mode is not supported. */
    VrManagerInternal mVrService;

    /**
     * Create new VrController instance.
     *
@@ -141,6 +144,7 @@ final class VrController {
    public void onSystemReady() {
        VrManagerInternal vrManagerInternal = LocalServices.getService(VrManagerInternal.class);
        if (vrManagerInternal != null) {
            mVrService = vrManagerInternal;
            vrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener);
        }
    }
@@ -181,7 +185,7 @@ final class VrController {
    public boolean onVrModeChanged(ActivityRecord record) {
        // This message means that the top focused activity enabled VR mode (or an activity
        // that previously set this has become focused).
        VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
        final VrManagerInternal vrService = mVrService;
        if (vrService == null) {
            // VR mode isn't supported on this device.
            return false;