From 82753280133ab1811bc89d00de295da65ca7378e Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Wed, 26 Oct 2022 18:50:00 +0000 Subject: Add a config to disable registering Shell Transitions in dagger This is needed for android-auto where shell is actually in launcher vs systemui. Also have TaskViewTransitions use this information instead of checking the flag so that it doesn't do anything in the process where it isn't registered. Bug: 255631687 Test: everything still works as expected Change-Id: I61ad21575850f15fd821cc5c8239bf7246549936 --- libs/WindowManager/Shell/res/values/config.xml | 4 ++++ .../Shell/src/com/android/wm/shell/TaskView.java | 3 +-- .../com/android/wm/shell/TaskViewTransitions.java | 4 ++++ .../android/wm/shell/dagger/WMShellBaseModule.java | 4 ++++ .../android/wm/shell/transition/Transitions.java | 27 +++++++++++++++------- 5 files changed, 32 insertions(+), 10 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index 30c3d50ed8ad..df5f921f3a62 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -23,6 +23,10 @@ TODO(b/238217847): This config is temporary until we refactor the base WMComponent. --> true + + true + 425 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java index d76ad3d27c70..477bc955212b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java @@ -41,7 +41,6 @@ import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; import com.android.wm.shell.common.SyncTransactionQueue; -import com.android.wm.shell.transition.Transitions; import java.io.PrintWriter; import java.util.concurrent.Executor; @@ -123,7 +122,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, /** Until all users are converted, we may have mixed-use (eg. Car). */ private boolean isUsingShellTransitions() { - return mTaskViewTransitions != null && Transitions.ENABLE_SHELL_TRANSITIONS; + return mTaskViewTransitions != null && mTaskViewTransitions.isEnabled(); } /** diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java index 83335ac24799..07d501201105 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java @@ -87,6 +87,10 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { // Note: Don't unregister handler since this is a singleton with lifetime bound to Shell } + boolean isEnabled() { + return mTransitions.isRegistered(); + } + /** * Looks through the pending transitions for one matching `taskView`. * @param taskView the pending transition should be for this. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java index 28a19597bd37..625d8a83736d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java @@ -506,6 +506,10 @@ public abstract class WMShellBaseModule { @ShellMainThread ShellExecutor mainExecutor, @ShellMainThread Handler mainHandler, @ShellAnimationThread ShellExecutor animExecutor) { + if (!context.getResources().getBoolean(R.bool.config_registerShellTransitionsOnInit)) { + // TODO(b/238217847): Force override shell init if registration is disabled + shellInit = new ShellInit(mainExecutor); + } return new Transitions(context, shellInit, shellController, organizer, pool, displayController, mainExecutor, mainHandler, animExecutor); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index db1f19aa87b6..3de091139345 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -122,6 +122,8 @@ public class Transitions implements RemoteCallable { private final ShellController mShellController; private final ShellTransitionImpl mImpl = new ShellTransitionImpl(); + private boolean mIsRegistered = false; + /** List of possible handlers. Ordered by specificity (eg. tapped back to front). */ private final ArrayList mHandlers = new ArrayList<>(); @@ -163,19 +165,18 @@ public class Transitions implements RemoteCallable { displayController, pool, mainExecutor, mainHandler, animExecutor); mRemoteTransitionHandler = new RemoteTransitionHandler(mMainExecutor); mShellController = shellController; - shellInit.addInitCallback(this::onInit, this); - } - - private void onInit() { - mShellController.addExternalInterface(KEY_EXTRA_SHELL_SHELL_TRANSITIONS, - this::createExternalInterface, this); - // The very last handler (0 in the list) should be the default one. mHandlers.add(mDefaultTransitionHandler); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Default"); // Next lowest priority is remote transitions. mHandlers.add(mRemoteTransitionHandler); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Remote"); + shellInit.addInitCallback(this::onInit, this); + } + + private void onInit() { + mShellController.addExternalInterface(KEY_EXTRA_SHELL_SHELL_TRANSITIONS, + this::createExternalInterface, this); ContentResolver resolver = mContext.getContentResolver(); mTransitionAnimationScaleSetting = getTransitionAnimationScaleSetting(); @@ -186,13 +187,23 @@ public class Transitions implements RemoteCallable { new SettingsObserver()); if (Transitions.ENABLE_SHELL_TRANSITIONS) { + mIsRegistered = true; // Register this transition handler with Core - mOrganizer.registerTransitionPlayer(mPlayerImpl); + try { + mOrganizer.registerTransitionPlayer(mPlayerImpl); + } catch (RuntimeException e) { + mIsRegistered = false; + throw e; + } // Pre-load the instance. TransitionMetrics.getInstance(); } } + public boolean isRegistered() { + return mIsRegistered; + } + private float getTransitionAnimationScaleSetting() { return fixScale(Settings.Global.getFloat(mContext.getContentResolver(), Settings.Global.TRANSITION_ANIMATION_SCALE, mContext.getResources().getFloat( -- cgit v1.2.3-59-g8ed1b