Loading core/java/android/view/IWindowManager.aidl +3 −4 Original line number Diff line number Diff line Loading @@ -153,11 +153,10 @@ interface IWindowManager * WindowlessWindowManager). * * @param client an IWindow used for window-level communication (ime, finish draw, etc.). * @param windowType used by WM to determine the z-order. This is the same as the window type * used in {@link WindowManager.LayoutParams}. * @param shellRootLayer The container's layer. See WindowManager#ShellRootLayer. * @return a SurfaceControl to add things to. */ SurfaceControl addShellRoot(int displayId, IWindow client, int windowType); SurfaceControl addShellRoot(int displayId, IWindow client, int shellRootLayer); /** * Sets the window token sent to accessibility for a particular shell root. The Loading @@ -165,7 +164,7 @@ interface IWindowManager * * @param target The IWindow that accessibility service interfaces with. */ void setShellRootAccessibilityWindow(int displayId, int windowType, IWindow target); void setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target); /** * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is Loading core/java/android/view/SyncRtSurfaceTransactionApplier.java +23 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class SyncRtSurfaceTransactionApplier { public static final int FLAG_CORNER_RADIUS = 1 << 4; public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5; public static final int FLAG_VISIBILITY = 1 << 6; public static final int FLAG_TRANSACTION = 1 << 7; private SurfaceControl mTargetSc; private final ViewRootImpl mTargetViewRootImpl; Loading Loading @@ -93,6 +94,10 @@ public class SyncRtSurfaceTransactionApplier { } public static void applyParams(Transaction t, SurfaceParams params, float[] tmpFloat9) { if ((params.flags & FLAG_TRANSACTION) != 0) { t.merge(params.mergeTransaction); } if ((params.flags & FLAG_MATRIX) != 0) { t.setMatrix(params.surface, params.matrix, tmpFloat9); } Loading Loading @@ -161,6 +166,7 @@ public class SyncRtSurfaceTransactionApplier { Rect windowCrop; int layer; boolean visible; Transaction mergeTransaction; /** * @param surface The surface to modify. Loading Loading @@ -239,18 +245,29 @@ public class SyncRtSurfaceTransactionApplier { return this; } /** * @param mergeTransaction The transaction to apply to the surface. Note this is applied * first before all the other properties. * @return this Builder */ public Builder withMergeTransaction(Transaction mergeTransaction) { this.mergeTransaction = mergeTransaction; flags |= FLAG_TRANSACTION; return this; } /** * @return a new SurfaceParams instance */ public SurfaceParams build() { return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer, cornerRadius, backgroundBlurRadius, visible); cornerRadius, backgroundBlurRadius, visible, mergeTransaction); } } private SurfaceParams(SurfaceControl surface, int params, float alpha, Matrix matrix, Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius, boolean visible) { Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius, boolean visible, Transaction mergeTransaction) { this.flags = params; this.surface = surface; this.alpha = alpha; Loading @@ -260,6 +277,7 @@ public class SyncRtSurfaceTransactionApplier { this.cornerRadius = cornerRadius; this.backgroundBlurRadius = backgroundBlurRadius; this.visible = visible; this.mergeTransaction = mergeTransaction; } private final int flags; Loading @@ -286,5 +304,7 @@ public class SyncRtSurfaceTransactionApplier { public final int layer; public final boolean visible; public final Transaction mergeTransaction; } } core/java/android/view/WindowManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,22 @@ public interface WindowManager extends ViewManager { /** @hide */ String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer"; /** @hide */ int SHELL_ROOT_LAYER_DIVIDER = 0; /** @hide */ int SHELL_ROOT_LAYER_PIP = 1; /** * Declares the layer the shell root will belong to. This is for z-ordering. * @hide */ @IntDef(prefix = { "SHELL_ROOT_LAYER_" }, value = { SHELL_ROOT_LAYER_DIVIDER, SHELL_ROOT_LAYER_PIP }) @Retention(RetentionPolicy.SOURCE) @interface ShellRootLayer {} /** * Not set up for a transition. * @hide Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +11 −23 Original line number Diff line number Diff line Loading @@ -101,13 +101,13 @@ public class SystemWindows { * Adds a view to system-ui window management. */ public void addView(View view, WindowManager.LayoutParams attrs, int displayId, int windowType) { @WindowManager.ShellRootLayer int shellRootLayer) { PerDisplay pd = mPerDisplay.get(displayId); if (pd == null) { pd = new PerDisplay(displayId); mPerDisplay.put(displayId, pd); } pd.addView(view, attrs, windowType); pd.addView(view, attrs, shellRootLayer); } /** Loading Loading @@ -148,18 +148,6 @@ public class SystemWindows { ((SysUiWindowManager) wwm).setTouchableRegionForWindow(view, region); } /** * Adds a root for system-ui window management with no views. Only useful for IME. */ public void addRoot(int displayId, int windowType) { PerDisplay pd = mPerDisplay.get(displayId); if (pd == null) { pd = new PerDisplay(displayId); mPerDisplay.put(displayId, pd); } pd.addRoot(windowType); } /** * Get the IWindow token for a specific root. * Loading Loading @@ -198,8 +186,9 @@ public class SystemWindows { mDisplayId = displayId; } public void addView(View view, WindowManager.LayoutParams attrs, int windowType) { SysUiWindowManager wwm = addRoot(windowType); public void addView(View view, WindowManager.LayoutParams attrs, @WindowManager.ShellRootLayer int shellRootLayer) { SysUiWindowManager wwm = addRoot(shellRootLayer); if (wwm == null) { Slog.e(TAG, "Unable to create systemui root"); return; Loading @@ -213,23 +202,22 @@ public class SystemWindows { mViewRoots.put(view, viewRoot); try { mWmService.setShellRootAccessibilityWindow(mDisplayId, windowType, mWmService.setShellRootAccessibilityWindow(mDisplayId, shellRootLayer, viewRoot.getWindowToken()); } catch (RemoteException e) { Slog.e(TAG, "Error setting accessibility window for " + mDisplayId + ":" + windowType, e); + shellRootLayer, e); } } SysUiWindowManager addRoot(int windowType) { SysUiWindowManager wwm = mWwms.get(windowType); SysUiWindowManager addRoot(@WindowManager.ShellRootLayer int shellRootLayer) { SysUiWindowManager wwm = mWwms.get(shellRootLayer); if (wwm != null) { return wwm; } SurfaceControl rootSurface = null; ContainerWindow win = new ContainerWindow(); try { rootSurface = mWmService.addShellRoot(mDisplayId, win, windowType); rootSurface = mWmService.addShellRoot(mDisplayId, win, shellRootLayer); } catch (RemoteException e) { } if (rootSurface == null) { Loading @@ -238,7 +226,7 @@ public class SystemWindows { } Context displayContext = mDisplayController.getDisplayContext(mDisplayId); wwm = new SysUiWindowManager(mDisplayId, displayContext, rootSurface, win); mWwms.put(windowType, wwm); mWwms.put(shellRootLayer, wwm); return wwm; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +29 −66 Original line number Diff line number Diff line Loading @@ -52,9 +52,6 @@ import android.util.Log; import android.util.Rational; import android.util.Size; import android.view.SurfaceControl; import android.view.SurfaceControlViewHost; import android.view.View; import android.view.WindowManager; import android.window.TaskOrganizer; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; Loading @@ -66,6 +63,7 @@ import com.android.internal.os.SomeArgs; import com.android.wm.shell.R; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.pip.phone.PipMenuActivityController; import com.android.wm.shell.pip.phone.PipMotionHelper; import com.android.wm.shell.pip.phone.PipUpdateThread; Loading Loading @@ -138,6 +136,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, private final Handler mUpdateHandler; private final PipBoundsState mPipBoundsState; private final PipBoundsHandler mPipBoundsHandler; private final PipMenuActivityController mMenuActivityController; private final SystemWindows mSystemWindows; private final PipAnimationController mPipAnimationController; private final PipUiEventLogger mPipUiEventLoggerLogger; private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>(); Loading @@ -146,8 +146,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, private final Map<IBinder, Configuration> mInitialState = new HashMap<>(); private final Optional<SplitScreen> mSplitScreenOptional; protected final ShellTaskOrganizer mTaskOrganizer; private SurfaceControlViewHost mPipViewHost; private SurfaceControl mPipMenuSurface; // These callbacks are called on the update thread private final PipAnimationController.PipAnimationCallback mPipAnimationCallback = Loading Loading @@ -267,15 +265,19 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, public PipTaskOrganizer(Context context, @NonNull PipBoundsState pipBoundsState, @NonNull PipBoundsHandler boundsHandler, PipMenuActivityController menuActivityController, @NonNull PipSurfaceTransactionHelper surfaceTransactionHelper, Optional<SplitScreen> splitScreenOptional, @NonNull DisplayController displayController, @NonNull PipUiEventLogger pipUiEventLogger, @NonNull ShellTaskOrganizer shellTaskOrganizer) { @NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull SystemWindows systemWindows) { mMainHandler = new Handler(Looper.getMainLooper()); mUpdateHandler = new Handler(PipUpdateThread.get().getLooper(), mUpdateCallbacks); mPipBoundsState = pipBoundsState; mPipBoundsHandler = boundsHandler; mMenuActivityController = menuActivityController; mSystemWindows = systemWindows; mEnterExitAnimationDuration = context.getResources() .getInteger(R.integer.config_pipResizeAnimationDuration); mSurfaceTransactionHelper = surfaceTransactionHelper; Loading Loading @@ -639,60 +641,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } } /** * Setup the ViewHost and attach the provided menu view to the ViewHost. * @return The input token belonging to the PipMenuView. */ public IBinder attachPipMenuViewHost(View menuView, WindowManager.LayoutParams lp) { if (mPipMenuSurface != null) { Log.e(TAG, "PIP Menu View already created and attached."); return null; } if (mLeash == null) { Log.e(TAG, "PiP Leash is not yet ready."); return null; } if (Looper.getMainLooper() != Looper.myLooper()) { throw new RuntimeException("PipMenuView needs to be attached on the main thread."); } final Context context = menuView.getContext(); mPipViewHost = new SurfaceControlViewHost(context, context.getDisplay(), (android.os.Binder) null); mPipMenuSurface = mPipViewHost.getSurfacePackage().getSurfaceControl(); SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); transaction.reparent(mPipMenuSurface, mLeash); transaction.show(mPipMenuSurface); transaction.setRelativeLayer(mPipMenuSurface, mLeash, 1); transaction.apply(); mPipViewHost.setView(menuView, lp); return mPipViewHost.getSurfacePackage().getInputToken(); } /** * Releases the PIP Menu's View host, remove it from PIP task surface. */ public void detachPipMenuViewHost() { if (mPipMenuSurface != null) { SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); transaction.remove(mPipMenuSurface); transaction.apply(); mPipMenuSurface = null; mPipViewHost = null; } } /** * Return whether the PiP Menu has been attached to the leash yet. */ public boolean isPipMenuViewHostAttached() { return mPipViewHost != null; } /** * Note that dismissing PiP is now originated from SystemUI, see {@link #exitPip(int)}. * Meanwhile this callback is invoked whenever the task is removed. For instance: Loading Loading @@ -998,8 +946,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mSurfaceTransactionHelper .crop(tx, mLeash, destinationBounds) .round(tx, mLeash, mState.isInPip()); if (mMenuActivityController.isMenuVisible()) { runOnMainHandler(() -> { mMenuActivityController.resizePipMenu(mLeash, tx, destinationBounds); }); } else { tx.apply(); } } private void userResizePip(Rect startBounds, Rect destinationBounds) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { Loading @@ -1019,8 +973,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); mSurfaceTransactionHelper.scale(tx, mLeash, startBounds, destinationBounds); if (mMenuActivityController.isMenuVisible()) { runOnMainHandler(() -> { mMenuActivityController.movePipMenu(mLeash, tx, destinationBounds); }); } else { tx.apply(); } } private void finishResize(SurfaceControl.Transaction tx, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, Loading @@ -1034,6 +994,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, removePipImmediately(); return; } else if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) { // TODO: Synchronize this correctly in #applyEnterPipSyncTransaction runOnMainHandler(() -> { mMenuActivityController.movePipMenu(null, null, destinationBounds); mMenuActivityController.updateMenuBounds(destinationBounds); }); return; } Loading @@ -1041,10 +1006,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, prepareFinishResizeTransaction(destinationBounds, direction, tx, wct); applyFinishBoundsResize(wct, direction); runOnMainHandler(() -> { if (mPipViewHost != null) { mPipViewHost.relayout(PipMenuActivityController.getPipMenuLayoutParams( destinationBounds.width(), destinationBounds.height())); } mMenuActivityController.movePipMenu(null, null, destinationBounds); mMenuActivityController.updateMenuBounds(destinationBounds); }); } Loading Loading
core/java/android/view/IWindowManager.aidl +3 −4 Original line number Diff line number Diff line Loading @@ -153,11 +153,10 @@ interface IWindowManager * WindowlessWindowManager). * * @param client an IWindow used for window-level communication (ime, finish draw, etc.). * @param windowType used by WM to determine the z-order. This is the same as the window type * used in {@link WindowManager.LayoutParams}. * @param shellRootLayer The container's layer. See WindowManager#ShellRootLayer. * @return a SurfaceControl to add things to. */ SurfaceControl addShellRoot(int displayId, IWindow client, int windowType); SurfaceControl addShellRoot(int displayId, IWindow client, int shellRootLayer); /** * Sets the window token sent to accessibility for a particular shell root. The Loading @@ -165,7 +164,7 @@ interface IWindowManager * * @param target The IWindow that accessibility service interfaces with. */ void setShellRootAccessibilityWindow(int displayId, int windowType, IWindow target); void setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target); /** * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is Loading
core/java/android/view/SyncRtSurfaceTransactionApplier.java +23 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class SyncRtSurfaceTransactionApplier { public static final int FLAG_CORNER_RADIUS = 1 << 4; public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5; public static final int FLAG_VISIBILITY = 1 << 6; public static final int FLAG_TRANSACTION = 1 << 7; private SurfaceControl mTargetSc; private final ViewRootImpl mTargetViewRootImpl; Loading Loading @@ -93,6 +94,10 @@ public class SyncRtSurfaceTransactionApplier { } public static void applyParams(Transaction t, SurfaceParams params, float[] tmpFloat9) { if ((params.flags & FLAG_TRANSACTION) != 0) { t.merge(params.mergeTransaction); } if ((params.flags & FLAG_MATRIX) != 0) { t.setMatrix(params.surface, params.matrix, tmpFloat9); } Loading Loading @@ -161,6 +166,7 @@ public class SyncRtSurfaceTransactionApplier { Rect windowCrop; int layer; boolean visible; Transaction mergeTransaction; /** * @param surface The surface to modify. Loading Loading @@ -239,18 +245,29 @@ public class SyncRtSurfaceTransactionApplier { return this; } /** * @param mergeTransaction The transaction to apply to the surface. Note this is applied * first before all the other properties. * @return this Builder */ public Builder withMergeTransaction(Transaction mergeTransaction) { this.mergeTransaction = mergeTransaction; flags |= FLAG_TRANSACTION; return this; } /** * @return a new SurfaceParams instance */ public SurfaceParams build() { return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer, cornerRadius, backgroundBlurRadius, visible); cornerRadius, backgroundBlurRadius, visible, mergeTransaction); } } private SurfaceParams(SurfaceControl surface, int params, float alpha, Matrix matrix, Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius, boolean visible) { Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius, boolean visible, Transaction mergeTransaction) { this.flags = params; this.surface = surface; this.alpha = alpha; Loading @@ -260,6 +277,7 @@ public class SyncRtSurfaceTransactionApplier { this.cornerRadius = cornerRadius; this.backgroundBlurRadius = backgroundBlurRadius; this.visible = visible; this.mergeTransaction = mergeTransaction; } private final int flags; Loading @@ -286,5 +304,7 @@ public class SyncRtSurfaceTransactionApplier { public final int layer; public final boolean visible; public final Transaction mergeTransaction; } }
core/java/android/view/WindowManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,22 @@ public interface WindowManager extends ViewManager { /** @hide */ String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer"; /** @hide */ int SHELL_ROOT_LAYER_DIVIDER = 0; /** @hide */ int SHELL_ROOT_LAYER_PIP = 1; /** * Declares the layer the shell root will belong to. This is for z-ordering. * @hide */ @IntDef(prefix = { "SHELL_ROOT_LAYER_" }, value = { SHELL_ROOT_LAYER_DIVIDER, SHELL_ROOT_LAYER_PIP }) @Retention(RetentionPolicy.SOURCE) @interface ShellRootLayer {} /** * Not set up for a transition. * @hide Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +11 −23 Original line number Diff line number Diff line Loading @@ -101,13 +101,13 @@ public class SystemWindows { * Adds a view to system-ui window management. */ public void addView(View view, WindowManager.LayoutParams attrs, int displayId, int windowType) { @WindowManager.ShellRootLayer int shellRootLayer) { PerDisplay pd = mPerDisplay.get(displayId); if (pd == null) { pd = new PerDisplay(displayId); mPerDisplay.put(displayId, pd); } pd.addView(view, attrs, windowType); pd.addView(view, attrs, shellRootLayer); } /** Loading Loading @@ -148,18 +148,6 @@ public class SystemWindows { ((SysUiWindowManager) wwm).setTouchableRegionForWindow(view, region); } /** * Adds a root for system-ui window management with no views. Only useful for IME. */ public void addRoot(int displayId, int windowType) { PerDisplay pd = mPerDisplay.get(displayId); if (pd == null) { pd = new PerDisplay(displayId); mPerDisplay.put(displayId, pd); } pd.addRoot(windowType); } /** * Get the IWindow token for a specific root. * Loading Loading @@ -198,8 +186,9 @@ public class SystemWindows { mDisplayId = displayId; } public void addView(View view, WindowManager.LayoutParams attrs, int windowType) { SysUiWindowManager wwm = addRoot(windowType); public void addView(View view, WindowManager.LayoutParams attrs, @WindowManager.ShellRootLayer int shellRootLayer) { SysUiWindowManager wwm = addRoot(shellRootLayer); if (wwm == null) { Slog.e(TAG, "Unable to create systemui root"); return; Loading @@ -213,23 +202,22 @@ public class SystemWindows { mViewRoots.put(view, viewRoot); try { mWmService.setShellRootAccessibilityWindow(mDisplayId, windowType, mWmService.setShellRootAccessibilityWindow(mDisplayId, shellRootLayer, viewRoot.getWindowToken()); } catch (RemoteException e) { Slog.e(TAG, "Error setting accessibility window for " + mDisplayId + ":" + windowType, e); + shellRootLayer, e); } } SysUiWindowManager addRoot(int windowType) { SysUiWindowManager wwm = mWwms.get(windowType); SysUiWindowManager addRoot(@WindowManager.ShellRootLayer int shellRootLayer) { SysUiWindowManager wwm = mWwms.get(shellRootLayer); if (wwm != null) { return wwm; } SurfaceControl rootSurface = null; ContainerWindow win = new ContainerWindow(); try { rootSurface = mWmService.addShellRoot(mDisplayId, win, windowType); rootSurface = mWmService.addShellRoot(mDisplayId, win, shellRootLayer); } catch (RemoteException e) { } if (rootSurface == null) { Loading @@ -238,7 +226,7 @@ public class SystemWindows { } Context displayContext = mDisplayController.getDisplayContext(mDisplayId); wwm = new SysUiWindowManager(mDisplayId, displayContext, rootSurface, win); mWwms.put(windowType, wwm); mWwms.put(shellRootLayer, wwm); return wwm; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +29 −66 Original line number Diff line number Diff line Loading @@ -52,9 +52,6 @@ import android.util.Log; import android.util.Rational; import android.util.Size; import android.view.SurfaceControl; import android.view.SurfaceControlViewHost; import android.view.View; import android.view.WindowManager; import android.window.TaskOrganizer; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; Loading @@ -66,6 +63,7 @@ import com.android.internal.os.SomeArgs; import com.android.wm.shell.R; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.pip.phone.PipMenuActivityController; import com.android.wm.shell.pip.phone.PipMotionHelper; import com.android.wm.shell.pip.phone.PipUpdateThread; Loading Loading @@ -138,6 +136,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, private final Handler mUpdateHandler; private final PipBoundsState mPipBoundsState; private final PipBoundsHandler mPipBoundsHandler; private final PipMenuActivityController mMenuActivityController; private final SystemWindows mSystemWindows; private final PipAnimationController mPipAnimationController; private final PipUiEventLogger mPipUiEventLoggerLogger; private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>(); Loading @@ -146,8 +146,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, private final Map<IBinder, Configuration> mInitialState = new HashMap<>(); private final Optional<SplitScreen> mSplitScreenOptional; protected final ShellTaskOrganizer mTaskOrganizer; private SurfaceControlViewHost mPipViewHost; private SurfaceControl mPipMenuSurface; // These callbacks are called on the update thread private final PipAnimationController.PipAnimationCallback mPipAnimationCallback = Loading Loading @@ -267,15 +265,19 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, public PipTaskOrganizer(Context context, @NonNull PipBoundsState pipBoundsState, @NonNull PipBoundsHandler boundsHandler, PipMenuActivityController menuActivityController, @NonNull PipSurfaceTransactionHelper surfaceTransactionHelper, Optional<SplitScreen> splitScreenOptional, @NonNull DisplayController displayController, @NonNull PipUiEventLogger pipUiEventLogger, @NonNull ShellTaskOrganizer shellTaskOrganizer) { @NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull SystemWindows systemWindows) { mMainHandler = new Handler(Looper.getMainLooper()); mUpdateHandler = new Handler(PipUpdateThread.get().getLooper(), mUpdateCallbacks); mPipBoundsState = pipBoundsState; mPipBoundsHandler = boundsHandler; mMenuActivityController = menuActivityController; mSystemWindows = systemWindows; mEnterExitAnimationDuration = context.getResources() .getInteger(R.integer.config_pipResizeAnimationDuration); mSurfaceTransactionHelper = surfaceTransactionHelper; Loading Loading @@ -639,60 +641,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } } /** * Setup the ViewHost and attach the provided menu view to the ViewHost. * @return The input token belonging to the PipMenuView. */ public IBinder attachPipMenuViewHost(View menuView, WindowManager.LayoutParams lp) { if (mPipMenuSurface != null) { Log.e(TAG, "PIP Menu View already created and attached."); return null; } if (mLeash == null) { Log.e(TAG, "PiP Leash is not yet ready."); return null; } if (Looper.getMainLooper() != Looper.myLooper()) { throw new RuntimeException("PipMenuView needs to be attached on the main thread."); } final Context context = menuView.getContext(); mPipViewHost = new SurfaceControlViewHost(context, context.getDisplay(), (android.os.Binder) null); mPipMenuSurface = mPipViewHost.getSurfacePackage().getSurfaceControl(); SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); transaction.reparent(mPipMenuSurface, mLeash); transaction.show(mPipMenuSurface); transaction.setRelativeLayer(mPipMenuSurface, mLeash, 1); transaction.apply(); mPipViewHost.setView(menuView, lp); return mPipViewHost.getSurfacePackage().getInputToken(); } /** * Releases the PIP Menu's View host, remove it from PIP task surface. */ public void detachPipMenuViewHost() { if (mPipMenuSurface != null) { SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); transaction.remove(mPipMenuSurface); transaction.apply(); mPipMenuSurface = null; mPipViewHost = null; } } /** * Return whether the PiP Menu has been attached to the leash yet. */ public boolean isPipMenuViewHostAttached() { return mPipViewHost != null; } /** * Note that dismissing PiP is now originated from SystemUI, see {@link #exitPip(int)}. * Meanwhile this callback is invoked whenever the task is removed. For instance: Loading Loading @@ -998,8 +946,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mSurfaceTransactionHelper .crop(tx, mLeash, destinationBounds) .round(tx, mLeash, mState.isInPip()); if (mMenuActivityController.isMenuVisible()) { runOnMainHandler(() -> { mMenuActivityController.resizePipMenu(mLeash, tx, destinationBounds); }); } else { tx.apply(); } } private void userResizePip(Rect startBounds, Rect destinationBounds) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { Loading @@ -1019,8 +973,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); mSurfaceTransactionHelper.scale(tx, mLeash, startBounds, destinationBounds); if (mMenuActivityController.isMenuVisible()) { runOnMainHandler(() -> { mMenuActivityController.movePipMenu(mLeash, tx, destinationBounds); }); } else { tx.apply(); } } private void finishResize(SurfaceControl.Transaction tx, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, Loading @@ -1034,6 +994,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, removePipImmediately(); return; } else if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) { // TODO: Synchronize this correctly in #applyEnterPipSyncTransaction runOnMainHandler(() -> { mMenuActivityController.movePipMenu(null, null, destinationBounds); mMenuActivityController.updateMenuBounds(destinationBounds); }); return; } Loading @@ -1041,10 +1006,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, prepareFinishResizeTransaction(destinationBounds, direction, tx, wct); applyFinishBoundsResize(wct, direction); runOnMainHandler(() -> { if (mPipViewHost != null) { mPipViewHost.relayout(PipMenuActivityController.getPipMenuLayoutParams( destinationBounds.width(), destinationBounds.height())); } mMenuActivityController.movePipMenu(null, null, destinationBounds); mMenuActivityController.updateMenuBounds(destinationBounds); }); } Loading