Some cleanup/rearrangement of shell transitions things

Some stuff changed underneath, so we can do a little bit
of housekeeping

Bug: 169035082
Test: nothing changed
Change-Id: I70c668d5760cd6fb9ddfd56720e0b712bd7520fc
This commit is contained in:
Evan Rosky
2020-12-02 16:06:57 -08:00
parent 1b44485e2b
commit c5b5c7611f
13 changed files with 116 additions and 89 deletions

View File

@@ -343,23 +343,48 @@ public interface WindowManager extends ViewManager {
/** @hide */
int TRANSIT_NONE = 0;
/** @hide */
/**
* A window that didn't exist before has been created and made visible.
* @hide
*/
int TRANSIT_OPEN = 1;
/** @hide */
/**
* A window that was visible no-longer exists (was finished or destroyed).
* @hide
*/
int TRANSIT_CLOSE = 2;
/** @hide */
/**
* A window that already existed but was not visible is made visible.
* @hide
*/
int TRANSIT_TO_FRONT = 3;
/** @hide */
/**
* A window that was visible is made invisible but still exists.
* @hide
*/
int TRANSIT_TO_BACK = 4;
/** @hide */
int TRANSIT_RELAUNCH = 5;
/** @hide */
int TRANSIT_CHANGE_WINDOWING_MODE = 6;
/** @hide */
/**
* A window is visible before and after but changes in some way (eg. it resizes or changes
* windowing-mode).
* @hide
*/
int TRANSIT_CHANGE = 6;
/**
* The keyguard was visible and has been dismissed.
* @hide
*/
int TRANSIT_KEYGUARD_GOING_AWAY = 7;
/** @hide */
/**
* A window is appearing above a locked keyguard.
* @hide
*/
int TRANSIT_KEYGUARD_OCCLUDE = 8;
/** @hide */
/**
* A window is made invisible revealing a locked keyguard.
* @hide
*/
int TRANSIT_KEYGUARD_UNOCCLUDE = 9;
/**
@@ -372,7 +397,7 @@ public interface WindowManager extends ViewManager {
TRANSIT_TO_FRONT,
TRANSIT_TO_BACK,
TRANSIT_RELAUNCH,
TRANSIT_CHANGE_WINDOWING_MODE,
TRANSIT_CHANGE,
TRANSIT_KEYGUARD_GOING_AWAY,
TRANSIT_KEYGUARD_OCCLUDE,
TRANSIT_KEYGUARD_UNOCCLUDE,

View File

@@ -16,6 +16,13 @@
package android.window;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -35,31 +42,17 @@ import java.util.List;
*/
public final class TransitionInfo implements Parcelable {
/** No transition mode. This is a placeholder, don't use this as an actual mode. */
public static final int TRANSIT_NONE = 0;
/** The container didn't exist before but will exist and be visible after. */
public static final int TRANSIT_OPEN = 1;
/** The container existed and was visible before but won't exist after. */
public static final int TRANSIT_CLOSE = 2;
/** The container existed before but was invisible and will be visible after. */
public static final int TRANSIT_SHOW = 3;
/** The container is going from visible to invisible but it will still exist after. */
public static final int TRANSIT_HIDE = 4;
/** The container exists and is visible before and after but it changes. */
public static final int TRANSIT_CHANGE = 5;
/** @hide */
/**
* Modes are only a sub-set of all the transit-types since they are per-container
* @hide
*/
@IntDef(prefix = { "TRANSIT_" }, value = {
TRANSIT_NONE,
TRANSIT_OPEN,
TRANSIT_CLOSE,
TRANSIT_SHOW,
TRANSIT_HIDE,
// Note: to_front/to_back really mean show/hide respectively at the container level.
TRANSIT_TO_FRONT,
TRANSIT_TO_BACK,
TRANSIT_CHANGE
})
public @interface TransitionMode {}
@@ -188,8 +181,8 @@ public final class TransitionInfo implements Parcelable {
case TRANSIT_NONE: return "NONE";
case TRANSIT_OPEN: return "OPEN";
case TRANSIT_CLOSE: return "CLOSE";
case TRANSIT_SHOW: return "SHOW";
case TRANSIT_HIDE: return "HIDE";
case TRANSIT_TO_FRONT: return "SHOW";
case TRANSIT_TO_BACK: return "HIDE";
case TRANSIT_CHANGE: return "CHANGE";
default: return "<unknown:" + mode + ">";
}
@@ -200,7 +193,7 @@ public final class TransitionInfo implements Parcelable {
private final WindowContainerToken mContainer;
private WindowContainerToken mParent;
private final SurfaceControl mLeash;
private int mMode = TRANSIT_NONE;
private @TransitionMode int mMode = TRANSIT_NONE;
private final Rect mStartAbsBounds = new Rect();
private final Rect mEndAbsBounds = new Rect();
private final Point mEndRelOffset = new Point();

View File

@@ -40,6 +40,7 @@ public class ShellInit {
private final Optional<AppPairs> mAppPairsOptional;
private final LetterboxTaskListener mLetterboxTaskListener;
private final FullscreenTaskListener mFullscreenTaskListener;
private final Transitions mTransitions;
public ShellInit(DisplayImeController displayImeController,
DragAndDropController dragAndDropController,
@@ -47,7 +48,8 @@ public class ShellInit {
Optional<SplitScreen> splitScreenOptional,
Optional<AppPairs> appPairsOptional,
LetterboxTaskListener letterboxTaskListener,
FullscreenTaskListener fullscreenTaskListener) {
FullscreenTaskListener fullscreenTaskListener,
Transitions transitions) {
mDisplayImeController = displayImeController;
mDragAndDropController = dragAndDropController;
mShellTaskOrganizer = shellTaskOrganizer;
@@ -55,6 +57,7 @@ public class ShellInit {
mAppPairsOptional = appPairsOptional;
mLetterboxTaskListener = letterboxTaskListener;
mFullscreenTaskListener = fullscreenTaskListener;
mTransitions = transitions;
}
@ExternalThread
@@ -72,5 +75,9 @@ public class ShellInit {
mAppPairsOptional.ifPresent(AppPairs::onOrganizerRegistered);
// Bind the splitscreen impl to the drag drop controller
mDragAndDropController.setSplitScreenController(mSplitScreenOptional);
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
mTransitions.register(mShellTaskOrganizer);
}
}
}

View File

@@ -43,8 +43,6 @@ import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.startingsurface.StartingSurfaceDrawer;
import java.io.PrintWriter;
@@ -102,24 +100,17 @@ public class ShellTaskOrganizer extends TaskOrganizer {
/** @see #setPendingLaunchCookieListener */
private final ArrayMap<IBinder, TaskListener> mLaunchCookieToListener = new ArrayMap<>();
// TODO(shell-transitions): move to a more "global" Shell location as this isn't only for Tasks
private final Transitions mTransitions;
private final Object mLock = new Object();
private final StartingSurfaceDrawer mStartingSurfaceDrawer;
public ShellTaskOrganizer(SyncTransactionQueue syncQueue, TransactionPool transactionPool,
ShellExecutor mainExecutor, ShellExecutor animExecutor, Context context) {
this(null, syncQueue, transactionPool, mainExecutor, animExecutor, context);
public ShellTaskOrganizer(ShellExecutor mainExecutor, Context context) {
this(null, mainExecutor, context);
}
@VisibleForTesting
ShellTaskOrganizer(ITaskOrganizerController taskOrganizerController,
SyncTransactionQueue syncQueue, TransactionPool transactionPool,
ShellExecutor mainExecutor, ShellExecutor animExecutor, Context context) {
ShellTaskOrganizer(ITaskOrganizerController taskOrganizerController, ShellExecutor mainExecutor,
Context context) {
super(taskOrganizerController, mainExecutor);
mTransitions = new Transitions(this, transactionPool, mainExecutor, animExecutor);
if (Transitions.ENABLE_SHELL_TRANSITIONS) mTransitions.register(this);
// TODO(b/131727939) temporarily live here, the starting surface drawer should be controlled
// by a controller, that class should be create while porting
// ActivityRecord#addStartingWindow to WMShell.

View File

@@ -16,10 +16,10 @@
package com.android.wm.shell;
import static android.window.TransitionInfo.TRANSIT_CLOSE;
import static android.window.TransitionInfo.TRANSIT_HIDE;
import static android.window.TransitionInfo.TRANSIT_OPEN;
import static android.window.TransitionInfo.TRANSIT_SHOW;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import android.animation.Animator;
import android.animation.ValueAnimator;
@@ -40,7 +40,6 @@ import androidx.annotation.BinderThread;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import java.util.ArrayList;
@@ -62,7 +61,7 @@ public class Transitions {
/** Keeps track of currently tracked transitions and all the animations associated with each */
private final ArrayMap<IBinder, ArrayList<Animator>> mActiveTransitions = new ArrayMap<>();
Transitions(@NonNull WindowOrganizer organizer, @NonNull TransactionPool pool,
public Transitions(@NonNull WindowOrganizer organizer, @NonNull TransactionPool pool,
@NonNull ShellExecutor mainExecutor, @NonNull ShellExecutor animExecutor) {
mOrganizer = organizer;
mTransactionPool = pool;
@@ -119,8 +118,8 @@ public class Transitions {
}
private static boolean isOpeningType(@WindowManager.TransitionType int type) {
return type == WindowManager.TRANSIT_OPEN
|| type == WindowManager.TRANSIT_TO_FRONT
return type == TRANSIT_OPEN
|| type == TRANSIT_TO_FRONT
|| type == WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
}
@@ -150,7 +149,7 @@ public class Transitions {
// Don't animate anything with an animating parent
if (change.getParent() != null) {
if (mode == TRANSIT_OPEN || mode == TRANSIT_SHOW) {
if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
t.show(leash);
t.setMatrix(leash, 1, 0, 0, 1);
}
@@ -161,7 +160,7 @@ public class Transitions {
t.setPosition(leash, change.getEndAbsBounds().left - info.getRootOffset().x,
change.getEndAbsBounds().top - info.getRootOffset().y);
// Put all the OPEN/SHOW on top
if (mode == TRANSIT_OPEN || mode == TRANSIT_SHOW) {
if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
t.show(leash);
t.setMatrix(leash, 1, 0, 0, 1);
if (isOpening) {
@@ -174,7 +173,7 @@ public class Transitions {
t.setLayer(leash, -i);
t.setAlpha(leash, 1.f);
}
} else if (mode == TRANSIT_CLOSE || mode == TRANSIT_HIDE) {
} else if (mode == TRANSIT_CLOSE || mode == TRANSIT_TO_BACK) {
if (isOpening) {
// put on bottom and leave visible without fade
t.setLayer(leash, -i);

View File

@@ -108,8 +108,7 @@ public class ShellTaskOrganizerTests {
doReturn(ParceledListSlice.<TaskAppearedInfo>emptyList())
.when(mTaskOrganizerController).registerTaskOrganizer(any());
} catch (RemoteException e) {}
mOrganizer = spy(new ShellTaskOrganizer(mTaskOrganizerController, mSyncTransactionQueue,
mTransactionPool, mTestExecutor, mTestExecutor, mContext));
mOrganizer = spy(new ShellTaskOrganizer(mTaskOrganizerController, mTestExecutor, mContext));
}
@Test

View File

@@ -37,6 +37,7 @@ import com.android.wm.shell.FullscreenTaskListener;
import com.android.wm.shell.ShellCommandHandler;
import com.android.wm.shell.ShellInit;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.Transitions;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.apppairs.AppPairs;
import com.android.wm.shell.bubbles.BubbleController;
@@ -173,14 +174,16 @@ public abstract class WMShellBaseModule {
Optional<SplitScreen> splitScreenOptional,
Optional<AppPairs> appPairsOptional,
LetterboxTaskListener letterboxTaskListener,
FullscreenTaskListener fullscreenTaskListener) {
FullscreenTaskListener fullscreenTaskListener,
Transitions transitions) {
return new ShellInit(displayImeController,
dragAndDropController,
shellTaskOrganizer,
splitScreenOptional,
appPairsOptional,
letterboxTaskListener,
fullscreenTaskListener);
fullscreenTaskListener,
transitions);
}
/**
@@ -278,12 +281,9 @@ public abstract class WMShellBaseModule {
@WMSingleton
@Provides
static ShellTaskOrganizer provideShellTaskOrganizer(SyncTransactionQueue syncQueue,
@ShellMainThread ShellExecutor shellMainExecutor,
@ShellAnimationThread ShellExecutor shellAnimationExecutor,
TransactionPool transactionPool, Context context) {
return new ShellTaskOrganizer(syncQueue, transactionPool, shellMainExecutor,
shellAnimationExecutor, context);
static ShellTaskOrganizer provideShellTaskOrganizer(@ShellMainThread ShellExecutor mainExecutor,
Context context) {
return new ShellTaskOrganizer(mainExecutor, context);
}
@WMSingleton
@@ -350,4 +350,12 @@ public abstract class WMShellBaseModule {
static LetterboxConfigController provideLetterboxConfigController(Context context) {
return new LetterboxConfigController(context);
}
@WMSingleton
@Provides
static Transitions provideTransitions(ShellTaskOrganizer organizer, TransactionPool pool,
@ShellMainThread ShellExecutor mainExecutor,
@ShellAnimationThread ShellExecutor animExecutor) {
return new Transitions(organizer, pool, mainExecutor, animExecutor);
}
}

View File

@@ -17,7 +17,7 @@
package com.android.server.wm;
import static android.view.WindowManager.LayoutParams;
import static android.view.WindowManager.TRANSIT_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
@@ -2092,8 +2092,8 @@ public class AppTransition implements Dump {
case TRANSIT_RELAUNCH: {
return "TRANSIT_RELAUNCH";
}
case TRANSIT_CHANGE_WINDOWING_MODE: {
return "TRANSIT_CHANGE_WINDOWING_MODE";
case TRANSIT_CHANGE: {
return "TRANSIT_CHANGE";
}
case TRANSIT_KEYGUARD_GOING_AWAY: {
return "TRANSIT_KEYGUARD_GOING_AWAY";

View File

@@ -17,7 +17,7 @@
package com.android.server.wm;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.TRANSIT_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
@@ -303,7 +303,7 @@ public class AppTransitionController {
// Special transitions
// TODO(new-app-transitions): Revisit if those can be rewritten by using flags.
if (appTransition.containsTransitRequest(TRANSIT_CHANGE_WINDOWING_MODE)) {
if (appTransition.containsTransitRequest(TRANSIT_CHANGE)) {
return TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
}
if ((flags & TRANSIT_FLAG_APP_CRASHED) != 0) {

View File

@@ -59,7 +59,7 @@ import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.SurfaceControl.METADATA_TASK_ID;
import static android.view.WindowManager.TRANSIT_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
@@ -2356,7 +2356,7 @@ class Task extends WindowContainer<WindowContainer> {
* Initializes a change transition. See {@link SurfaceFreezer} for more information.
*/
private void initializeChangeTransition(Rect startBounds) {
mDisplayContent.prepareAppTransition(TRANSIT_CHANGE_WINDOWING_MODE);
mDisplayContent.prepareAppTransition(TRANSIT_CHANGE);
mDisplayContent.mChangingContainers.add(this);
mSurfaceFreezer.freeze(getPendingTransaction(), startBounds);
@@ -2440,8 +2440,7 @@ class Task extends WindowContainer<WindowContainer> {
@Override
public SurfaceControl getFreezeSnapshotTarget() {
if (!mDisplayContent.mAppTransition.containsTransitRequest(
TRANSIT_CHANGE_WINDOWING_MODE)) {
if (!mDisplayContent.mAppTransition.containsTransitRequest(TRANSIT_CHANGE)) {
return null;
}
// Skip creating snapshot if this transition is controlled by a remote animator which

View File

@@ -18,11 +18,17 @@ package com.android.server.wm;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
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_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -389,7 +395,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
parent == null ? "no parent" : ("parent can't be target " + parent));
return false;
}
@TransitionInfo.TransitionMode int mode = TransitionInfo.TRANSIT_NONE;
@TransitionInfo.TransitionMode int mode = TRANSIT_NONE;
// Go through all siblings of this target to see if any of them would prevent
// the target from promoting.
siblingLoop:
@@ -403,11 +409,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
if (depth < 0) continue;
if (depth == 0) {
final int siblingMode = sibling.isVisibleRequested()
? TransitionInfo.TRANSIT_OPEN : TransitionInfo.TRANSIT_CLOSE;
? TRANSIT_OPEN : TRANSIT_CLOSE;
ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
" sibling is a top target with mode %s",
TransitionInfo.modeToString(siblingMode));
if (mode == TransitionInfo.TRANSIT_NONE) {
if (mode == TRANSIT_NONE) {
ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
" no common mode yet, so set it");
mode = siblingMode;
@@ -693,12 +699,12 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
int getTransitMode(@NonNull WindowContainer wc) {
final boolean nowVisible = wc.isVisibleRequested();
if (nowVisible == mVisible) {
return TransitionInfo.TRANSIT_CHANGE;
return TRANSIT_CHANGE;
}
if (mExistenceChanged) {
return nowVisible ? TransitionInfo.TRANSIT_OPEN : TransitionInfo.TRANSIT_CLOSE;
return nowVisible ? TRANSIT_OPEN : TRANSIT_CLOSE;
} else {
return nowVisible ? TransitionInfo.TRANSIT_SHOW : TransitionInfo.TRANSIT_HIDE;
return nowVisible ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK;
}
}

View File

@@ -20,7 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
@@ -111,7 +111,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
translucentOpening.setOccludesParent(false);
translucentOpening.setVisible(false);
mDisplayContent.prepareAppTransition(TRANSIT_CHANGE_WINDOWING_MODE);
mDisplayContent.prepareAppTransition(TRANSIT_CHANGE);
mDisplayContent.mOpeningApps.add(behind);
mDisplayContent.mOpeningApps.add(translucentOpening);
assertEquals(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE,

View File

@@ -20,8 +20,8 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import static android.window.TransitionInfo.TRANSIT_HIDE;
import static android.window.TransitionInfo.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -237,7 +237,7 @@ public class TransitionTests extends WindowTestsBase {
assertEquals(TRANSIT_OPEN,
info.getChange(openTask.mRemoteToken.toWindowContainerToken()).getMode());
// No exestence change on closing, so HIDE rather than CLOSE
assertEquals(TRANSIT_HIDE,
assertEquals(TRANSIT_TO_BACK,
info.getChange(closeTask.mRemoteToken.toWindowContainerToken()).getMode());
}