Merge "Add a config to disable registering Shell Transitions in dagger" into tm-qpr-dev

This commit is contained in:
Evan Rosky
2022-10-27 01:10:09 +00:00
committed by Android (Google) Code Review
5 changed files with 32 additions and 10 deletions

View File

@@ -23,6 +23,10 @@
TODO(b/238217847): This config is temporary until we refactor the base WMComponent. --> TODO(b/238217847): This config is temporary until we refactor the base WMComponent. -->
<bool name="config_registerShellTaskOrganizerOnInit">true</bool> <bool name="config_registerShellTaskOrganizerOnInit">true</bool>
<!-- Determines whether to register the shell transitions on init.
TODO(b/238217847): This config is temporary until we refactor the base WMComponent. -->
<bool name="config_registerShellTransitionsOnInit">true</bool>
<!-- Animation duration for PIP when entering. --> <!-- Animation duration for PIP when entering. -->
<integer name="config_pipEnterAnimationDuration">425</integer> <integer name="config_pipEnterAnimationDuration">425</integer>

View File

@@ -41,7 +41,6 @@ import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction; import android.window.WindowContainerTransaction;
import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.transition.Transitions;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.concurrent.Executor; 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). */ /** Until all users are converted, we may have mixed-use (eg. Car). */
private boolean isUsingShellTransitions() { private boolean isUsingShellTransitions() {
return mTaskViewTransitions != null && Transitions.ENABLE_SHELL_TRANSITIONS; return mTaskViewTransitions != null && mTaskViewTransitions.isEnabled();
} }
/** /**

View File

@@ -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 // 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`. * Looks through the pending transitions for one matching `taskView`.
* @param taskView the pending transition should be for this. * @param taskView the pending transition should be for this.

View File

@@ -506,6 +506,10 @@ public abstract class WMShellBaseModule {
@ShellMainThread ShellExecutor mainExecutor, @ShellMainThread ShellExecutor mainExecutor,
@ShellMainThread Handler mainHandler, @ShellMainThread Handler mainHandler,
@ShellAnimationThread ShellExecutor animExecutor) { @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, return new Transitions(context, shellInit, shellController, organizer, pool,
displayController, mainExecutor, mainHandler, animExecutor); displayController, mainExecutor, mainHandler, animExecutor);
} }

View File

@@ -122,6 +122,8 @@ public class Transitions implements RemoteCallable<Transitions> {
private final ShellController mShellController; private final ShellController mShellController;
private final ShellTransitionImpl mImpl = new ShellTransitionImpl(); private final ShellTransitionImpl mImpl = new ShellTransitionImpl();
private boolean mIsRegistered = false;
/** List of possible handlers. Ordered by specificity (eg. tapped back to front). */ /** List of possible handlers. Ordered by specificity (eg. tapped back to front). */
private final ArrayList<TransitionHandler> mHandlers = new ArrayList<>(); private final ArrayList<TransitionHandler> mHandlers = new ArrayList<>();
@@ -163,19 +165,18 @@ public class Transitions implements RemoteCallable<Transitions> {
displayController, pool, mainExecutor, mainHandler, animExecutor); displayController, pool, mainExecutor, mainHandler, animExecutor);
mRemoteTransitionHandler = new RemoteTransitionHandler(mMainExecutor); mRemoteTransitionHandler = new RemoteTransitionHandler(mMainExecutor);
mShellController = shellController; 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. // The very last handler (0 in the list) should be the default one.
mHandlers.add(mDefaultTransitionHandler); mHandlers.add(mDefaultTransitionHandler);
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Default"); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Default");
// Next lowest priority is remote transitions. // Next lowest priority is remote transitions.
mHandlers.add(mRemoteTransitionHandler); mHandlers.add(mRemoteTransitionHandler);
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Remote"); 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(); ContentResolver resolver = mContext.getContentResolver();
mTransitionAnimationScaleSetting = getTransitionAnimationScaleSetting(); mTransitionAnimationScaleSetting = getTransitionAnimationScaleSetting();
@@ -186,13 +187,23 @@ public class Transitions implements RemoteCallable<Transitions> {
new SettingsObserver()); new SettingsObserver());
if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (Transitions.ENABLE_SHELL_TRANSITIONS) {
mIsRegistered = true;
// Register this transition handler with Core // Register this transition handler with Core
mOrganizer.registerTransitionPlayer(mPlayerImpl); try {
mOrganizer.registerTransitionPlayer(mPlayerImpl);
} catch (RuntimeException e) {
mIsRegistered = false;
throw e;
}
// Pre-load the instance. // Pre-load the instance.
TransitionMetrics.getInstance(); TransitionMetrics.getInstance();
} }
} }
public boolean isRegistered() {
return mIsRegistered;
}
private float getTransitionAnimationScaleSetting() { private float getTransitionAnimationScaleSetting() {
return fixScale(Settings.Global.getFloat(mContext.getContentResolver(), return fixScale(Settings.Global.getFloat(mContext.getContentResolver(),
Settings.Global.TRANSITION_ANIMATION_SCALE, mContext.getResources().getFloat( Settings.Global.TRANSITION_ANIMATION_SCALE, mContext.getResources().getFloat(