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

Commit bbba07ef authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Notify transition listener only for its interested display

In legacy transition, the listeners are managed by AppTransition
per display (DisplayContent.mAppTransition.registerListenerLocked).
So listeners won't be notified by unrelated display.

While in shell transition, all listeners are managed by
TransitionController. So all listeners will be notified once any
display has a transition.

This change allows the listener to specify the display it wants
to monitor. If no display is specified, it will receive from all
displays, e.g. WMS#mActivityManagerAppTransitionNotifier. The
behavior is only enabled in TransitionController (shell transition).

Bug: 326610743
Flag: EXEMPT bugfix
Test: TransitionTests
Change-Id: Ia297b2e7a1204dc501a9ae288580b74638a78e2e
parent ce8e50cf
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2402,7 +2402,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
        }

        mWindowManagerInternal.registerAppTransitionListener(new AppTransitionListener() {
        final var transitionListener = new AppTransitionListener(DEFAULT_DISPLAY) {
            @Override
            public int onAppTransitionStartingLocked(long statusBarAnimationStartTime,
                    long statusBarAnimationDuration) {
@@ -2436,7 +2436,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mLockAfterDreamingTransitionFinished = false;
                }
            }
        });
        };
        mWindowManagerInternal.registerAppTransitionListener(transitionListener);

        mKeyguardDrawnTimeout = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_keyguardDrawnTimeout);
+4 −0
Original line number Diff line number Diff line
@@ -6911,6 +6911,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        /** Whether {@link #mAnimatingRecents} is going to be the top activity. */
        private boolean mRecentsWillBeTop;

        FixedRotationTransitionListener() {
            super(DisplayContent.this.mDisplayId);
        }

        /**
         * If the recents activity has a fixed orientation which is different from the current top
         * activity, it will be rotated before being shown so we avoid a screen rotation animation
+1 −1
Original line number Diff line number Diff line
@@ -588,7 +588,7 @@ public class DisplayPolicy {
                    gesturesPointerEventCallbacks);
            displayContent.registerPointerEventListener(mSystemGestures);
        }
        mAppTransitionListener = new WindowManagerInternal.AppTransitionListener() {
        mAppTransitionListener = new WindowManagerInternal.AppTransitionListener(displayId) {

            private Runnable mAppTransitionPending = () -> {
                StatusBarManagerInternal statusBar = getStatusBarManagerInternal();
+2 −1
Original line number Diff line number Diff line
@@ -744,6 +744,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        if (mController.isAnimating()) {
            dc.enableHighPerfTransition(true);
        }
        mController.dispatchLegacyAppTransitionPending(dc.mDisplayId);
    }

    /**
@@ -1617,7 +1618,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        mController.mTransitionTracer.logAbortedTransition(this);
        // Syncengine abort will call through to onTransactionReady()
        mSyncEngine.abort(mSyncId);
        mController.dispatchLegacyAppTransitionCancelled();
        mController.dispatchLegacyAppTransitionCancelled(mTargetDisplays);
        invokeTransitionEndedListeners();
    }

+35 −12
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.util.Slog;
import android.util.SparseArray;
import android.util.TimeUtils;
import android.util.proto.ProtoOutputStream;
import android.view.Display;
import android.view.WindowManager;
import android.window.ITransitionMetricsReporter;
import android.window.ITransitionPlayer;
@@ -326,7 +327,6 @@ class TransitionController {
        mCollectingTransition.startCollecting(timeoutMs);
        ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, "Start collecting in Transition: %s",
                mCollectingTransition);
        dispatchLegacyAppTransitionPending();
    }

    void registerTransitionPlayer(@Nullable ITransitionPlayer player,
@@ -1347,31 +1347,54 @@ class TransitionController {
        mLegacyListeners.remove(listener);
    }

    void dispatchLegacyAppTransitionPending() {
    private static boolean shouldDispatchLegacyListener(
            WindowManagerInternal.AppTransitionListener listener, int displayId) {
        // INVALID_DISPLAY means that it is a global listener.
        return listener.mDisplayId == Display.INVALID_DISPLAY || listener.mDisplayId == displayId;
    }

    void dispatchLegacyAppTransitionPending(int displayId) {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionPendingLocked();
            final WindowManagerInternal.AppTransitionListener listener = mLegacyListeners.get(i);
            if (shouldDispatchLegacyListener(listener, displayId)) {
                listener.onAppTransitionPendingLocked();
            }
        }
    }

    void dispatchLegacyAppTransitionStarting(TransitionInfo info, long statusBarTransitionDelay) {
        final long now = SystemClock.uptimeMillis();
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            // TODO(shell-transitions): handle (un)occlude transition.
            mLegacyListeners.get(i).onAppTransitionStartingLocked(
                    SystemClock.uptimeMillis() + statusBarTransitionDelay,
            final WindowManagerInternal.AppTransitionListener listener = mLegacyListeners.get(i);
            for (int j = 0; j < info.getRootCount(); ++j) {
                final int displayId = info.getRoot(j).getDisplayId();
                if (shouldDispatchLegacyListener(listener, displayId)) {
                    listener.onAppTransitionStartingLocked(
                            now + statusBarTransitionDelay,
                            AnimationAdapter.STATUS_BAR_TRANSITION_DURATION);
                }
            }
        }
    }

    void dispatchLegacyAppTransitionFinished(ActivityRecord ar) {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionFinishedLocked(ar.token);
            final WindowManagerInternal.AppTransitionListener listener = mLegacyListeners.get(i);
            if (shouldDispatchLegacyListener(listener, ar.getDisplayId())) {
                listener.onAppTransitionFinishedLocked(ar.token);
            }
        }
    }

    void dispatchLegacyAppTransitionCancelled() {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionCancelledLocked(
                    false /* keyguardGoingAwayCancelled */);
    void dispatchLegacyAppTransitionCancelled(ArrayList<DisplayContent> targetDisplays) {
        for (int i = 0; i < targetDisplays.size(); ++i) {
            final int displayId = targetDisplays.get(i).mDisplayId;
            for (int j = 0; j < mLegacyListeners.size(); ++j) {
                final var listener = mLegacyListeners.get(j);
                if (shouldDispatchLegacyListener(listener, displayId)) {
                    listener.onAppTransitionCancelledLocked(false /* keyguardGoingAwayCancelled */);
                }
            }
        }
    }

Loading