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

Commit 5666bae1 authored by Evan Rosky's avatar Evan Rosky
Browse files

Call legacy apptransition callbacks on shell transition events

This just adapts to the existing apptransitionlistener callbacks
for now (at least the relevant ones).

Bug: 189249177
Test: atest ActivityVisibilityTests
Change-Id: Ie202b9cdc3827841dc349577b30af71a3fb3d45b
parent ffac171d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1008,6 +1008,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        mAppTransition = new AppTransition(mWmService.mContext, mWmService, this);
        mAppTransition.registerListenerLocked(mWmService.mActivityManagerAppTransitionNotifier);
        mAtmService.getTransitionController().registerLegacyListener(
                mWmService.mActivityManagerAppTransitionNotifier);
        mAppTransition.registerListenerLocked(mFixedRotationTransitionListener);
        mAppTransitionController = new AppTransitionController(mWmService, this);
        mUnknownAppVisibilityController = new UnknownAppVisibilityController(mWmService, this);
+2 −0
Original line number Diff line number Diff line
@@ -613,6 +613,8 @@ public class DisplayPolicy {
            }
        };
        displayContent.mAppTransition.registerListenerLocked(mAppTransitionListener);
        mService.mAtmService.getTransitionController().registerLegacyListener(
                mAppTransitionListener);
        mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext, looper,
                mService.mVrModeEnabled);

+5 −0
Original line number Diff line number Diff line
@@ -304,6 +304,9 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
                        "  Commit activity becoming invisible: %s", ar);
                ar.commitVisibility(false /* visible */, false /* performLayout */);
            }
            if (ar != null) {
                mController.dispatchLegacyAppTransitionFinished(ar);
            }
            final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
            if (wt != null && !wt.isVisibleRequested()) {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
@@ -321,6 +324,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        if (mState != STATE_COLLECTING) {
            throw new IllegalStateException("Too late to abort.");
        }
        mController.dispatchLegacyAppTransitionCancelled();
        mState = STATE_ABORT;
        // Syncengine abort will call through to onTransactionReady()
        mSyncEngine.abort(mSyncId);
@@ -389,6 +393,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        mFinishTransaction = mController.mAtm.mWindowManager.mTransactionFactory.get();
        buildFinishTransaction(mFinishTransaction, info.getRootLeash());
        if (mController.getTransitionPlayer() != null) {
            mController.dispatchLegacyAppTransitionStarting(info);
            try {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                        "Calling onTransitionReady: %s", info);
+46 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ package com.android.server.wm;

import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OPEN;

import android.annotation.NonNull;
@@ -25,6 +30,7 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Slog;
import android.view.WindowManager;
import android.window.IRemoteTransition;
@@ -48,6 +54,9 @@ class TransitionController {
    private ITransitionPlayer mTransitionPlayer;
    final ActivityTaskManagerService mAtm;

    private final ArrayList<WindowManagerInternal.AppTransitionListener> mLegacyListeners =
            new ArrayList<>();

    /**
     * Currently playing transitions (in the order they were started). When finished, records are
     * removed from this list.
@@ -95,6 +104,7 @@ class TransitionController {
        mCollectingTransition = new Transition(type, flags, this, mAtm.mWindowManager.mSyncEngine);
        ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, "Creating Transition: %s",
                mCollectingTransition);
        dispatchLegacyAppTransitionPending();
        return mCollectingTransition;
    }

@@ -311,4 +321,40 @@ class TransitionController {
        }
        transition.legacyRestoreNavigationBarFromApp();
    }

    void registerLegacyListener(WindowManagerInternal.AppTransitionListener listener) {
        mLegacyListeners.add(listener);
    }

    void dispatchLegacyAppTransitionPending() {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionPendingLocked();
        }
    }

    void dispatchLegacyAppTransitionStarting(TransitionInfo info) {
        final boolean keyguardGoingAway = info.getType() == TRANSIT_KEYGUARD_GOING_AWAY
                || (info.getFlags() & (TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE
                        | TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION
                        | TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER
                        | TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION)) != 0;
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionStartingLocked(keyguardGoingAway,
                    0 /* durationHint */, SystemClock.uptimeMillis(),
                    AnimationAdapter.STATUS_BAR_TRANSITION_DURATION);
        }
    }

    void dispatchLegacyAppTransitionFinished(ActivityRecord ar) {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionFinishedLocked(ar.token);
        }
    }

    void dispatchLegacyAppTransitionCancelled() {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            mLegacyListeners.get(i).onAppTransitionCancelledLocked(
                    false /* keyguardGoingAway */);
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -7582,6 +7582,7 @@ public class WindowManagerService extends IWindowManager.Stub
        public void registerAppTransitionListener(AppTransitionListener listener) {
            synchronized (mGlobalLock) {
                getDefaultDisplayContentLocked().mAppTransition.registerListenerLocked(listener);
                mAtmService.getTransitionController().registerLegacyListener(listener);
            }
        }