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

Commit d707002e authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "setShowWhenLocked/inherit in a Transition" into main

parents 3459cd0e 248336b7
Loading
Loading
Loading
Loading
+51 −2
Original line number Diff line number Diff line
@@ -1319,9 +1319,33 @@ class ActivityClientController extends IActivityClientController.Stub {
        try {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
                if (r != null) {
                if (r == null) return;
                final TransitionController controller = r.mTransitionController;
                if (!controller.isShellTransitionsEnabled()) {
                    r.setShowWhenLocked(showWhenLocked);
                    return;
                }
                if (controller.isCollecting()
                        && !mService.mKeyguardController.isKeyguardLocked(r.getDisplayId())) {
                    // Keyguard isn't locked, so this can be done as part of the collecting
                    // transition.
                    r.setShowWhenLocked(showWhenLocked);
                    return;
                }
                final Transition transition = new Transition(
                        showWhenLocked ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
                        0 /* flags */, controller, mService.mWindowManager.mSyncEngine);
                r.mTransitionController.startCollectOrQueue(transition, (deferred) -> {
                    transition.collect(r);
                    r.setShowWhenLocked(showWhenLocked);
                    if (transition.isNoOp()) {
                        transition.abort();
                        return;
                    }
                    controller.requestStartTransition(transition, null /* trigger */,
                            null /* remoteTransition */, null /* displayChange */);
                    transition.setReady(r, true);
                });
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
@@ -1334,9 +1358,34 @@ class ActivityClientController extends IActivityClientController.Stub {
        try {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
                if (r != null) {
                if (r == null) return;
                final TransitionController controller = r.mTransitionController;
                // If shell transitions is not enabled just set it directly.
                if (!controller.isShellTransitionsEnabled()) {
                    r.setInheritShowWhenLocked(inheritShowWhenLocked);
                    return;
                }
                if (controller.isCollecting()
                        && !mService.mKeyguardController.isKeyguardLocked(r.getDisplayId())) {
                    // Keyguard isn't locked, so this can be done as part of the collecting
                    // transition.
                    r.setInheritShowWhenLocked(inheritShowWhenLocked);
                    return;
                }
                final Transition transition = new Transition(
                        inheritShowWhenLocked ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
                        0 /* flags */, controller, mService.mWindowManager.mSyncEngine);
                r.mTransitionController.startCollectOrQueue(transition, (deferred) -> {
                    transition.collect(r);
                    r.setInheritShowWhenLocked(inheritShowWhenLocked);
                    if (transition.isNoOp()) {
                        transition.abort();
                        return;
                    }
                    controller.requestStartTransition(transition, null /* trigger */,
                            null /* remoteTransition */, null /* displayChange */);
                    transition.setReady(r, true);
                });
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
+20 −0
Original line number Diff line number Diff line
@@ -2917,6 +2917,26 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_WINDOW_MANAGER, TAG, cookie);
    }

    /**
     * Get whether the transition, in its current state, is a no-op. This should be avoided. It is
     * only here for legacy usages where we can't tell ahead-of-time whether something will
     * generate a change.
     */
    boolean isNoOp() {
        for (int i = mParticipants.size() - 1; i >= 0; --i) {
            // This is the same criteria as the rejection logic in calculateTargets
            final WindowContainer<?> wc = mParticipants.valueAt(i);
            if (!wc.isAttached()) continue;
            // The level of transition target should be at least window token.
            if (wc.asWindowState() != null) continue;
            final ChangeInfo changeInfo = mChanges.get(wc);
            // Reject no-ops
            if (!changeInfo.hasChanged()) continue;
            return false;
        }
        return true;
    }

    @VisibleForTesting
    static class ChangeInfo {
        private static final int FLAG_NONE = 0;