From c9be3f364ef0f3c61878dec71d0c049f9eadeb0a Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Fri, 14 Jul 2023 12:45:03 -0700 Subject: [PATCH] Add separated Pip1 and Pip2 dagger module - Moved all legacy PiP related to its own Pip1Module and Pip1SharedModule (shared with TvPipModule) - Added a placeholder Pip2Module - Hold all PiP related dependencies to dagger.pip package - Abstract the experiment flag based selection of class to dedicated PipModule and expose that only to WMShellModule Changed also constructors to not register for wm/ shell callbacks by default. This is to prevent implementations from both legacy and pip2 listening for same events, which can cause undefined behavior. TODO - Move shared classes between the legacy and new PiP implementation to a separated package - Refactor PipTransitionController as an interface can be shared in between legacy and new implementations, this should be the only external dependency for PiP Bug: 291996784 Test: m -j SystemUIGoogle Change-Id: I0d15ce2aa77e0452d12a6e8e1fd9568261ec11e0 --- .../wm/shell/dagger/TvWMShellModule.java | 1 + .../wm/shell/dagger/WMShellBaseModule.java | 45 +-- .../wm/shell/dagger/WMShellModule.java | 225 +-------------- .../wm/shell/dagger/pip/Pip1Module.java | 271 ++++++++++++++++++ .../wm/shell/dagger/pip/Pip1SharedModule.java | 66 +++++ .../wm/shell/dagger/pip/Pip2Module.java | 39 +++ .../wm/shell/dagger/pip/PipModule.java | 45 +++ .../shell/dagger/{ => pip}/TvPipModule.java | 10 +- .../src/com/android/wm/shell/pip/Pip.java | 7 + .../wm/shell/pip/PipMediaController.java | 16 +- .../wm/shell/pip/PipTaskOrganizer.java | 16 +- .../wm/shell/pip/PipTransitionController.java | 6 +- .../com/android/wm/shell/pip/PipUtils.java | 8 + .../wm/shell/pip/phone/PipController.java | 11 +- .../wm/shell/pip/phone/PipTouchHandler.java | 5 +- .../android/wm/shell/pip2/PipTransition.java | 43 +++ .../src/com/android/wm/shell/pip2/README.md | 3 + .../shell/transition/DefaultMixedHandler.java | 8 +- 18 files changed, 540 insertions(+), 285 deletions(-) create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java rename libs/WindowManager/Shell/src/com/android/wm/shell/dagger/{ => pip}/TvPipModule.java (97%) create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/pip2/PipTransition.java create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/pip2/README.md diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java index 47d58afb6aba8..9facbd542e6c7 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java @@ -31,6 +31,7 @@ import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.dagger.pip.TvPipModule; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.recents.RecentTasksController; import com.android.wm.shell.splitscreen.SplitScreenController; 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 34a6e0ae406cd..422e3b0216c86 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 @@ -20,7 +20,6 @@ import static com.android.wm.shell.onehanded.OneHandedController.SUPPORT_ONE_HAN import android.app.ActivityTaskManager; import android.content.Context; -import android.content.pm.PackageManager; import android.os.Handler; import android.os.SystemProperties; import android.view.IWindowManager; @@ -45,7 +44,6 @@ import com.android.wm.shell.common.DisplayImeController; import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.DockStateReader; -import com.android.wm.shell.common.FloatingContentCoordinator; import com.android.wm.shell.common.LaunchAdjacentController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.SyncTransactionQueue; @@ -76,10 +74,6 @@ import com.android.wm.shell.keyguard.KeyguardTransitions; import com.android.wm.shell.onehanded.OneHanded; import com.android.wm.shell.onehanded.OneHandedController; import com.android.wm.shell.pip.Pip; -import com.android.wm.shell.pip.PipMediaController; -import com.android.wm.shell.pip.PipSurfaceTransactionHelper; -import com.android.wm.shell.pip.PipUiEventLogger; -import com.android.wm.shell.pip.phone.PipTouchHandler; import com.android.wm.shell.recents.RecentTasks; import com.android.wm.shell.recents.RecentTasksController; import com.android.wm.shell.recents.RecentsTransitionHandler; @@ -103,13 +97,13 @@ import com.android.wm.shell.unfold.UnfoldAnimationController; import com.android.wm.shell.unfold.UnfoldTransitionHandler; import com.android.wm.shell.windowdecor.WindowDecorViewModel; -import java.util.Optional; - import dagger.BindsOptionalOf; import dagger.Lazy; import dagger.Module; import dagger.Provides; +import java.util.Optional; + /** * Provides basic dependencies from {@link com.android.wm.shell}, these dependencies are only * accessible from components within the WM subcomponent (can be explicitly exposed to the @@ -469,40 +463,6 @@ public abstract class WMShellBaseModule { return Optional.empty(); } - // - // Pip (optional feature) - // - - @WMSingleton - @Provides - static FloatingContentCoordinator provideFloatingContentCoordinator() { - return new FloatingContentCoordinator(); - } - - // Needs handler for registering broadcast receivers - @WMSingleton - @Provides - static PipMediaController providePipMediaController(Context context, - @ShellMainThread Handler mainHandler) { - return new PipMediaController(context, mainHandler); - } - - @WMSingleton - @Provides - static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper(Context context) { - return new PipSurfaceTransactionHelper(context); - } - - @WMSingleton - @Provides - static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, - PackageManager packageManager) { - return new PipUiEventLogger(uiEventLogger, packageManager); - } - - @BindsOptionalOf - abstract PipTouchHandler optionalPipTouchHandler(); - // // Recent tasks // @@ -838,7 +798,6 @@ public abstract class WMShellBaseModule { Optional bubblesOptional, Optional splitScreenOptional, Optional pipOptional, - Optional pipTouchHandlerOptional, FullscreenTaskListener fullscreenTaskListener, Optional unfoldAnimationController, Optional unfoldTransitionHandler, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index f5c6a03336ed6..881c8f5552b67 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -16,6 +16,7 @@ package com.android.wm.shell.dagger; +import android.annotation.Nullable; import android.content.Context; import android.content.pm.LauncherApps; import android.os.Handler; @@ -46,13 +47,12 @@ import com.android.wm.shell.common.FloatingContentCoordinator; import com.android.wm.shell.common.LaunchAdjacentController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.SyncTransactionQueue; -import com.android.wm.shell.common.SystemWindows; -import com.android.wm.shell.common.TabletopModeController; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.annotations.ShellAnimationThread; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.dagger.pip.PipModule; import com.android.wm.shell.desktopmode.DesktopModeController; import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.desktopmode.DesktopModeTaskRepository; @@ -67,27 +67,7 @@ import com.android.wm.shell.freeform.FreeformTaskTransitionHandler; import com.android.wm.shell.freeform.FreeformTaskTransitionObserver; import com.android.wm.shell.keyguard.KeyguardTransitionHandler; import com.android.wm.shell.onehanded.OneHandedController; -import com.android.wm.shell.pip.Pip; -import com.android.wm.shell.pip.PipAnimationController; -import com.android.wm.shell.pip.PipAppOpsListener; -import com.android.wm.shell.pip.PipBoundsAlgorithm; -import com.android.wm.shell.pip.PipBoundsState; -import com.android.wm.shell.pip.PipDisplayLayoutState; -import com.android.wm.shell.pip.PipMediaController; -import com.android.wm.shell.pip.PipParamsChangedForwarder; -import com.android.wm.shell.pip.PipSnapAlgorithm; -import com.android.wm.shell.pip.PipSurfaceTransactionHelper; -import com.android.wm.shell.pip.PipTaskOrganizer; -import com.android.wm.shell.pip.PipTransition; import com.android.wm.shell.pip.PipTransitionController; -import com.android.wm.shell.pip.PipTransitionState; -import com.android.wm.shell.pip.PipUiEventLogger; -import com.android.wm.shell.pip.phone.PhonePipKeepClearAlgorithm; -import com.android.wm.shell.pip.phone.PhonePipMenuController; -import com.android.wm.shell.pip.phone.PipController; -import com.android.wm.shell.pip.phone.PipMotionHelper; -import com.android.wm.shell.pip.phone.PipSizeSpecHandler; -import com.android.wm.shell.pip.phone.PipTouchHandler; import com.android.wm.shell.recents.RecentTasksController; import com.android.wm.shell.recents.RecentsTransitionHandler; import com.android.wm.shell.splitscreen.SplitScreenController; @@ -127,7 +107,10 @@ import java.util.Optional; * This module only defines Shell dependencies for handheld SystemUI implementation. Common * dependencies should go into {@link WMShellBaseModule}. */ -@Module(includes = WMShellBaseModule.class) +@Module(includes = { + WMShellBaseModule.class, + PipModule.class +}) public abstract class WMShellModule { // @@ -350,195 +333,6 @@ public abstract class WMShellModule { windowDecorViewModel, mainExecutor); } - // - // Pip - // - - @WMSingleton - @Provides - static Optional providePip(Context context, - ShellInit shellInit, - ShellCommandHandler shellCommandHandler, - ShellController shellController, - DisplayController displayController, - PipAnimationController pipAnimationController, - PipAppOpsListener pipAppOpsListener, - PipBoundsAlgorithm pipBoundsAlgorithm, - PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, - PipBoundsState pipBoundsState, - PipSizeSpecHandler pipSizeSpecHandler, - PipDisplayLayoutState pipDisplayLayoutState, - PipMotionHelper pipMotionHelper, - PipMediaController pipMediaController, - PhonePipMenuController phonePipMenuController, - PipTaskOrganizer pipTaskOrganizer, - PipTransitionState pipTransitionState, - PipTouchHandler pipTouchHandler, - PipTransitionController pipTransitionController, - WindowManagerShellWrapper windowManagerShellWrapper, - TaskStackListenerImpl taskStackListener, - PipParamsChangedForwarder pipParamsChangedForwarder, - DisplayInsetsController displayInsetsController, - TabletopModeController pipTabletopController, - Optional oneHandedController, - @ShellMainThread ShellExecutor mainExecutor) { - return Optional.ofNullable(PipController.create( - context, shellInit, shellCommandHandler, shellController, - displayController, pipAnimationController, pipAppOpsListener, pipBoundsAlgorithm, - pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler, pipDisplayLayoutState, - pipMotionHelper, pipMediaController, phonePipMenuController, pipTaskOrganizer, - pipTransitionState, pipTouchHandler, pipTransitionController, - windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder, - displayInsetsController, pipTabletopController, oneHandedController, mainExecutor)); - } - - @WMSingleton - @Provides - static PipBoundsState providePipBoundsState(Context context, - PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState) { - return new PipBoundsState(context, pipSizeSpecHandler, pipDisplayLayoutState); - } - - @WMSingleton - @Provides - static PipSnapAlgorithm providePipSnapAlgorithm() { - return new PipSnapAlgorithm(); - } - - @WMSingleton - @Provides - static PhonePipKeepClearAlgorithm providePhonePipKeepClearAlgorithm(Context context) { - return new PhonePipKeepClearAlgorithm(context); - } - - @WMSingleton - @Provides - static PipSizeSpecHandler providePipSizeSpecHelper(Context context, - PipDisplayLayoutState pipDisplayLayoutState) { - return new PipSizeSpecHandler(context, pipDisplayLayoutState); - } - - @WMSingleton - @Provides - static PipBoundsAlgorithm providesPipBoundsAlgorithm(Context context, - PipBoundsState pipBoundsState, PipSnapAlgorithm pipSnapAlgorithm, - PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, - PipSizeSpecHandler pipSizeSpecHandler) { - return new PipBoundsAlgorithm(context, pipBoundsState, pipSnapAlgorithm, - pipKeepClearAlgorithm, pipSizeSpecHandler); - } - - // Handler is used by Icon.loadDrawableAsync - @WMSingleton - @Provides - static PhonePipMenuController providesPipPhoneMenuController(Context context, - PipBoundsState pipBoundsState, PipMediaController pipMediaController, - SystemWindows systemWindows, - Optional splitScreenOptional, - PipUiEventLogger pipUiEventLogger, - @ShellMainThread ShellExecutor mainExecutor, - @ShellMainThread Handler mainHandler) { - return new PhonePipMenuController(context, pipBoundsState, pipMediaController, - systemWindows, splitScreenOptional, pipUiEventLogger, mainExecutor, mainHandler); - } - - @WMSingleton - @Provides - static PipTouchHandler providePipTouchHandler(Context context, - ShellInit shellInit, - PhonePipMenuController menuPhoneController, - PipBoundsAlgorithm pipBoundsAlgorithm, - PipBoundsState pipBoundsState, - PipSizeSpecHandler pipSizeSpecHandler, - PipTaskOrganizer pipTaskOrganizer, - PipMotionHelper pipMotionHelper, - FloatingContentCoordinator floatingContentCoordinator, - PipUiEventLogger pipUiEventLogger, - @ShellMainThread ShellExecutor mainExecutor) { - return new PipTouchHandler(context, shellInit, menuPhoneController, pipBoundsAlgorithm, - pipBoundsState, pipSizeSpecHandler, pipTaskOrganizer, pipMotionHelper, - floatingContentCoordinator, pipUiEventLogger, mainExecutor); - } - - @WMSingleton - @Provides - static PipTransitionState providePipTransitionState() { - return new PipTransitionState(); - } - - @WMSingleton - @Provides - static PipTaskOrganizer providePipTaskOrganizer(Context context, - SyncTransactionQueue syncTransactionQueue, - PipTransitionState pipTransitionState, - PipBoundsState pipBoundsState, - PipDisplayLayoutState pipDisplayLayoutState, - PipBoundsAlgorithm pipBoundsAlgorithm, - PhonePipMenuController menuPhoneController, - PipAnimationController pipAnimationController, - PipSurfaceTransactionHelper pipSurfaceTransactionHelper, - PipTransitionController pipTransitionController, - PipParamsChangedForwarder pipParamsChangedForwarder, - Optional splitScreenControllerOptional, - DisplayController displayController, - PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer, - @ShellMainThread ShellExecutor mainExecutor) { - return new PipTaskOrganizer(context, - syncTransactionQueue, pipTransitionState, pipBoundsState, pipDisplayLayoutState, - pipBoundsAlgorithm, menuPhoneController, pipAnimationController, - pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder, - splitScreenControllerOptional, displayController, pipUiEventLogger, - shellTaskOrganizer, mainExecutor); - } - - @WMSingleton - @Provides - static PipAnimationController providePipAnimationController(PipSurfaceTransactionHelper - pipSurfaceTransactionHelper) { - return new PipAnimationController(pipSurfaceTransactionHelper); - } - - @WMSingleton - @Provides - static PipTransitionController providePipTransitionController(Context context, - ShellInit shellInit, ShellTaskOrganizer shellTaskOrganizer, Transitions transitions, - PipAnimationController pipAnimationController, PipBoundsAlgorithm pipBoundsAlgorithm, - PipBoundsState pipBoundsState, PipDisplayLayoutState pipDisplayLayoutState, - PipTransitionState pipTransitionState, PhonePipMenuController pipMenuController, - PipSurfaceTransactionHelper pipSurfaceTransactionHelper, - Optional splitScreenOptional) { - return new PipTransition(context, shellInit, shellTaskOrganizer, transitions, - pipBoundsState, pipDisplayLayoutState, pipTransitionState, pipMenuController, - pipBoundsAlgorithm, pipAnimationController, pipSurfaceTransactionHelper, - splitScreenOptional); - } - - @WMSingleton - @Provides - static PipAppOpsListener providePipAppOpsListener(Context context, - PipTouchHandler pipTouchHandler, - @ShellMainThread ShellExecutor mainExecutor) { - return new PipAppOpsListener(context, pipTouchHandler.getMotionHelper(), mainExecutor); - } - - @WMSingleton - @Provides - static PipMotionHelper providePipMotionHelper(Context context, - PipBoundsState pipBoundsState, PipTaskOrganizer pipTaskOrganizer, - PhonePipMenuController menuController, PipSnapAlgorithm pipSnapAlgorithm, - PipTransitionController pipTransitionController, - FloatingContentCoordinator floatingContentCoordinator) { - return new PipMotionHelper(context, pipBoundsState, pipTaskOrganizer, - menuController, pipSnapAlgorithm, pipTransitionController, - floatingContentCoordinator); - } - - @WMSingleton - @Provides - static PipParamsChangedForwarder providePipParamsChangedForwarder() { - return new PipParamsChangedForwarder(); - } - // // Transitions // @@ -548,7 +342,7 @@ public abstract class WMShellModule { static DefaultMixedHandler provideDefaultMixedHandler( ShellInit shellInit, Optional splitScreenOptional, - Optional pipTouchHandlerOptional, + @Nullable PipTransitionController pipTransitionController, Optional recentsTransitionHandler, KeyguardTransitionHandler keyguardTransitionHandler, Optional desktopModeController, @@ -556,8 +350,9 @@ public abstract class WMShellModule { Optional unfoldHandler, Transitions transitions) { return new DefaultMixedHandler(shellInit, transitions, splitScreenOptional, - pipTouchHandlerOptional, recentsTransitionHandler, keyguardTransitionHandler, - desktopModeController, desktopTasksController, unfoldHandler); + pipTransitionController, recentsTransitionHandler, + keyguardTransitionHandler, desktopModeController, desktopTasksController, + unfoldHandler); } @WMSingleton diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java new file mode 100644 index 0000000000000..d972f48b92fd4 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1Module.java @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.dagger.pip; + +import android.annotation.Nullable; +import android.content.Context; +import android.os.Handler; + +import com.android.wm.shell.ShellTaskOrganizer; +import com.android.wm.shell.WindowManagerShellWrapper; +import com.android.wm.shell.common.DisplayController; +import com.android.wm.shell.common.DisplayInsetsController; +import com.android.wm.shell.common.FloatingContentCoordinator; +import com.android.wm.shell.common.ShellExecutor; +import com.android.wm.shell.common.SyncTransactionQueue; +import com.android.wm.shell.common.SystemWindows; +import com.android.wm.shell.common.TabletopModeController; +import com.android.wm.shell.common.TaskStackListenerImpl; +import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.dagger.WMShellBaseModule; +import com.android.wm.shell.dagger.WMSingleton; +import com.android.wm.shell.onehanded.OneHandedController; +import com.android.wm.shell.pip.Pip; +import com.android.wm.shell.pip.PipAnimationController; +import com.android.wm.shell.pip.PipAppOpsListener; +import com.android.wm.shell.pip.PipBoundsAlgorithm; +import com.android.wm.shell.pip.PipBoundsState; +import com.android.wm.shell.pip.PipDisplayLayoutState; +import com.android.wm.shell.pip.PipMediaController; +import com.android.wm.shell.pip.PipParamsChangedForwarder; +import com.android.wm.shell.pip.PipSnapAlgorithm; +import com.android.wm.shell.pip.PipSurfaceTransactionHelper; +import com.android.wm.shell.pip.PipTaskOrganizer; +import com.android.wm.shell.pip.PipTransition; +import com.android.wm.shell.pip.PipTransitionController; +import com.android.wm.shell.pip.PipTransitionState; +import com.android.wm.shell.pip.PipUiEventLogger; +import com.android.wm.shell.pip.PipUtils; +import com.android.wm.shell.pip.phone.PhonePipKeepClearAlgorithm; +import com.android.wm.shell.pip.phone.PhonePipMenuController; +import com.android.wm.shell.pip.phone.PipController; +import com.android.wm.shell.pip.phone.PipMotionHelper; +import com.android.wm.shell.pip.phone.PipSizeSpecHandler; +import com.android.wm.shell.pip.phone.PipTouchHandler; +import com.android.wm.shell.splitscreen.SplitScreenController; +import com.android.wm.shell.sysui.ShellCommandHandler; +import com.android.wm.shell.sysui.ShellController; +import com.android.wm.shell.sysui.ShellInit; +import com.android.wm.shell.transition.Transitions; + +import dagger.Module; +import dagger.Provides; + +import java.util.Optional; + +/** + * Provides dependencies from {@link com.android.wm.shell.pip}, this implementation is meant to be + * replaced by the sibling {@link Pip2Module}. + */ +@Module(includes = { + Pip1SharedModule.class, + WMShellBaseModule.class +}) +public abstract class Pip1Module { + @WMSingleton + @Provides + static Optional providePip1(Context context, + ShellInit shellInit, + ShellCommandHandler shellCommandHandler, + ShellController shellController, + DisplayController displayController, + PipAnimationController pipAnimationController, + PipAppOpsListener pipAppOpsListener, + PipBoundsAlgorithm pipBoundsAlgorithm, + PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, + PipBoundsState pipBoundsState, + PipSizeSpecHandler pipSizeSpecHandler, + PipDisplayLayoutState pipDisplayLayoutState, + PipMotionHelper pipMotionHelper, + PipMediaController pipMediaController, + PhonePipMenuController phonePipMenuController, + PipTaskOrganizer pipTaskOrganizer, + PipTransitionState pipTransitionState, + PipTouchHandler pipTouchHandler, + PipTransitionController pipTransitionController, + WindowManagerShellWrapper windowManagerShellWrapper, + TaskStackListenerImpl taskStackListener, + PipParamsChangedForwarder pipParamsChangedForwarder, + DisplayInsetsController displayInsetsController, + TabletopModeController pipTabletopController, + Optional oneHandedController, + @ShellMainThread ShellExecutor mainExecutor) { + if (PipUtils.isPip2ExperimentEnabled()) { + return Optional.empty(); + } else { + return Optional.ofNullable(PipController.create( + context, shellInit, shellCommandHandler, shellController, + displayController, pipAnimationController, pipAppOpsListener, + pipBoundsAlgorithm, + pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler, + pipDisplayLayoutState, + pipMotionHelper, pipMediaController, phonePipMenuController, pipTaskOrganizer, + pipTransitionState, pipTouchHandler, pipTransitionController, + windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder, + displayInsetsController, pipTabletopController, oneHandedController, + mainExecutor)); + } + } + + @WMSingleton + @Provides + static PipBoundsState providePipBoundsState(Context context, + PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState) { + return new PipBoundsState(context, pipSizeSpecHandler, pipDisplayLayoutState); + } + + @WMSingleton + @Provides + static PipSnapAlgorithm providePipSnapAlgorithm() { + return new PipSnapAlgorithm(); + } + + @WMSingleton + @Provides + static PhonePipKeepClearAlgorithm providePhonePipKeepClearAlgorithm(Context context) { + return new PhonePipKeepClearAlgorithm(context); + } + + @WMSingleton + @Provides + static PipSizeSpecHandler providePipSizeSpecHelper(Context context, + PipDisplayLayoutState pipDisplayLayoutState) { + return new PipSizeSpecHandler(context, pipDisplayLayoutState); + } + + @WMSingleton + @Provides + static PipBoundsAlgorithm providesPipBoundsAlgorithm(Context context, + PipBoundsState pipBoundsState, PipSnapAlgorithm pipSnapAlgorithm, + PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, + PipSizeSpecHandler pipSizeSpecHandler) { + return new PipBoundsAlgorithm(context, pipBoundsState, pipSnapAlgorithm, + pipKeepClearAlgorithm, pipSizeSpecHandler); + } + + // Handler is used by Icon.loadDrawableAsync + @WMSingleton + @Provides + static PhonePipMenuController providesPipPhoneMenuController(Context context, + PipBoundsState pipBoundsState, PipMediaController pipMediaController, + SystemWindows systemWindows, + Optional splitScreenOptional, + PipUiEventLogger pipUiEventLogger, + @ShellMainThread ShellExecutor mainExecutor, + @ShellMainThread Handler mainHandler) { + return new PhonePipMenuController(context, pipBoundsState, pipMediaController, + systemWindows, splitScreenOptional, pipUiEventLogger, mainExecutor, mainHandler); + } + + @WMSingleton + @Provides + static PipTouchHandler providePipTouchHandler(Context context, + ShellInit shellInit, + PhonePipMenuController menuPhoneController, + PipBoundsAlgorithm pipBoundsAlgorithm, + PipBoundsState pipBoundsState, + PipSizeSpecHandler pipSizeSpecHandler, + PipTaskOrganizer pipTaskOrganizer, + PipMotionHelper pipMotionHelper, + FloatingContentCoordinator floatingContentCoordinator, + PipUiEventLogger pipUiEventLogger, + @ShellMainThread ShellExecutor mainExecutor) { + return new PipTouchHandler(context, shellInit, menuPhoneController, pipBoundsAlgorithm, + pipBoundsState, pipSizeSpecHandler, pipTaskOrganizer, pipMotionHelper, + floatingContentCoordinator, pipUiEventLogger, mainExecutor); + } + + @WMSingleton + @Provides + static PipTransitionState providePipTransitionState() { + return new PipTransitionState(); + } + + @WMSingleton + @Provides + static PipTaskOrganizer providePipTaskOrganizer(Context context, + SyncTransactionQueue syncTransactionQueue, + PipTransitionState pipTransitionState, + PipBoundsState pipBoundsState, + PipDisplayLayoutState pipDisplayLayoutState, + PipBoundsAlgorithm pipBoundsAlgorithm, + PhonePipMenuController menuPhoneController, + PipAnimationController pipAnimationController, + PipSurfaceTransactionHelper pipSurfaceTransactionHelper, + PipTransitionController pipTransitionController, + PipParamsChangedForwarder pipParamsChangedForwarder, + Optional splitScreenControllerOptional, + DisplayController displayController, + PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer, + @ShellMainThread ShellExecutor mainExecutor) { + return new PipTaskOrganizer(context, + syncTransactionQueue, pipTransitionState, pipBoundsState, pipDisplayLayoutState, + pipBoundsAlgorithm, menuPhoneController, pipAnimationController, + pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder, + splitScreenControllerOptional, displayController, pipUiEventLogger, + shellTaskOrganizer, mainExecutor); + } + + @WMSingleton + @Provides + static PipAnimationController providePipAnimationController(PipSurfaceTransactionHelper + pipSurfaceTransactionHelper) { + return new PipAnimationController(pipSurfaceTransactionHelper); + } + + @WMSingleton + @Provides + @Nullable + static PipTransition providePipTransition(Context context, + ShellInit shellInit, ShellTaskOrganizer shellTaskOrganizer, Transitions transitions, + PipAnimationController pipAnimationController, PipBoundsAlgorithm pipBoundsAlgorithm, + PipBoundsState pipBoundsState, PipDisplayLayoutState pipDisplayLayoutState, + PipTransitionState pipTransitionState, PhonePipMenuController pipMenuController, + PipSurfaceTransactionHelper pipSurfaceTransactionHelper, + Optional splitScreenOptional) { + return new PipTransition(context, shellInit, shellTaskOrganizer, transitions, + pipBoundsState, pipDisplayLayoutState, pipTransitionState, pipMenuController, + pipBoundsAlgorithm, pipAnimationController, pipSurfaceTransactionHelper, + splitScreenOptional); + } + + @WMSingleton + @Provides + static PipAppOpsListener providePipAppOpsListener(Context context, + PipTouchHandler pipTouchHandler, + @ShellMainThread ShellExecutor mainExecutor) { + return new PipAppOpsListener(context, pipTouchHandler.getMotionHelper(), mainExecutor); + } + + @WMSingleton + @Provides + static PipMotionHelper providePipMotionHelper(Context context, + PipBoundsState pipBoundsState, PipTaskOrganizer pipTaskOrganizer, + PhonePipMenuController menuController, PipSnapAlgorithm pipSnapAlgorithm, + PipTransitionController pipTransitionController, + FloatingContentCoordinator floatingContentCoordinator) { + return new PipMotionHelper(context, pipBoundsState, pipTaskOrganizer, + menuController, pipSnapAlgorithm, pipTransitionController, + floatingContentCoordinator); + } + + @WMSingleton + @Provides + static PipParamsChangedForwarder providePipParamsChangedForwarder() { + return new PipParamsChangedForwarder(); + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java new file mode 100644 index 0000000000000..f29b3a35128d2 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip1SharedModule.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.dagger.pip; + +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Handler; + +import com.android.internal.logging.UiEventLogger; +import com.android.wm.shell.common.FloatingContentCoordinator; +import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.dagger.WMSingleton; +import com.android.wm.shell.pip.PipMediaController; +import com.android.wm.shell.pip.PipSurfaceTransactionHelper; +import com.android.wm.shell.pip.PipUiEventLogger; + +import dagger.Module; +import dagger.Provides; + +/** + * Provides shared dependencies from {@link com.android.wm.shell.pip}, this implementation is + * shared with {@link TvPipModule} and possibly other form factors. + */ +@Module +public abstract class Pip1SharedModule { + @WMSingleton + @Provides + static FloatingContentCoordinator provideFloatingContentCoordinator() { + return new FloatingContentCoordinator(); + } + + // Needs handler for registering broadcast receivers + @WMSingleton + @Provides + static PipMediaController providePipMediaController(Context context, + @ShellMainThread Handler mainHandler) { + return new PipMediaController(context, mainHandler); + } + + @WMSingleton + @Provides + static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper(Context context) { + return new PipSurfaceTransactionHelper(context); + } + + @WMSingleton + @Provides + static PipUiEventLogger providePipUiEventLogger(UiEventLogger uiEventLogger, + PackageManager packageManager) { + return new PipUiEventLogger(uiEventLogger, packageManager); + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java new file mode 100644 index 0000000000000..c7c6e8a14278f --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.dagger.pip; + +import android.annotation.Nullable; + +import com.android.wm.shell.dagger.WMSingleton; +import com.android.wm.shell.pip2.PipTransition; + +import dagger.Module; +import dagger.Provides; + +/** + * Provides dependencies from {@link com.android.wm.shell.pip2}, this implementation is meant to be + * the successor of its sibling {@link Pip1SharedModule}. + */ +@Module +public abstract class Pip2Module { + @WMSingleton + @Provides + @Nullable + static PipTransition providePipTransition() { + return null; + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java new file mode 100644 index 0000000000000..2ded4a32a9f32 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.dagger.pip; + +import android.annotation.Nullable; + +import com.android.wm.shell.dagger.WMSingleton; +import com.android.wm.shell.pip.PipTransitionController; +import com.android.wm.shell.pip.PipUtils; + +import dagger.Module; +import dagger.Provides; + +/** + * Provides dependencies for external components / modules reference PiP and extracts away the + * selection of legacy and new PiP implementation. + */ +@Module(includes = { + Pip1Module.class, + Pip2Module.class +}) +public abstract class PipModule { + @WMSingleton + @Provides + @Nullable + static PipTransitionController providePipTransitionController( + com.android.wm.shell.pip.PipTransition legacyPipTransition, + com.android.wm.shell.pip2.PipTransition newPipTransition) { + return PipUtils.isPip2ExperimentEnabled() ? newPipTransition : legacyPipTransition; + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvPipModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/TvPipModule.java similarity index 97% rename from libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvPipModule.java rename to libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/TvPipModule.java index 14daae03e6b51..360bf8b70fca6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvPipModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/TvPipModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 The Android Open Source Project + * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.wm.shell.dagger; +package com.android.wm.shell.dagger.pip; import android.content.Context; import android.os.Handler; @@ -28,6 +28,8 @@ import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.dagger.WMShellBaseModule; +import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipAppOpsListener; @@ -62,7 +64,9 @@ import java.util.Optional; /** * Provides TV specific dependencies for Pip. */ -@Module(includes = {WMShellBaseModule.class}) +@Module(includes = { + WMShellBaseModule.class, + Pip1SharedModule.class}) public abstract class TvPipModule { @WMSingleton @Provides diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java index f34d2a827e69c..a9aa6badcfe2b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java @@ -67,4 +67,11 @@ public interface Pip { * view hierarchy or destroyed. */ default void removePipExclusionBoundsChangeListener(Consumer listener) { } + + /** + * @return {@link PipTransitionController} instance. + */ + default PipTransitionController getPipTransitionController() { + return null; + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java index 2590cab9ff2ef..ddffb5bdacded 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java @@ -150,13 +150,15 @@ public class PipMediaController { mContext = context; mMainHandler = mainHandler; mHandlerExecutor = new HandlerExecutor(mMainHandler); - IntentFilter mediaControlFilter = new IntentFilter(); - mediaControlFilter.addAction(ACTION_PLAY); - mediaControlFilter.addAction(ACTION_PAUSE); - mediaControlFilter.addAction(ACTION_NEXT); - mediaControlFilter.addAction(ACTION_PREV); - mContext.registerReceiverForAllUsers(mMediaActionReceiver, mediaControlFilter, - SYSTEMUI_PERMISSION, mainHandler, Context.RECEIVER_EXPORTED); + if (!PipUtils.isPip2ExperimentEnabled()) { + IntentFilter mediaControlFilter = new IntentFilter(); + mediaControlFilter.addAction(ACTION_PLAY); + mediaControlFilter.addAction(ACTION_PAUSE); + mediaControlFilter.addAction(ACTION_NEXT); + mediaControlFilter.addAction(ACTION_PREV); + mContext.registerReceiverForAllUsers(mMediaActionReceiver, mediaControlFilter, + SYSTEMUI_PERMISSION, mainHandler, Context.RECEIVER_EXPORTED); + } // Creates the standard media buttons that we may show. mPauseAction = getDefaultRemoteAction(R.string.pip_pause, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 08da4857a0b0a..208f9b7432bf0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -364,13 +364,15 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mMainExecutor = mainExecutor; // TODO: Can be removed once wm components are created on the shell-main thread - mMainExecutor.execute(() -> { - mTaskOrganizer.addListenerForType(this, TASK_LISTENER_TYPE_PIP); - }); - mTaskOrganizer.addFocusListener(this); - mPipTransitionController.setPipOrganizer(this); - displayController.addDisplayWindowListener(this); - pipTransitionController.registerPipTransitionCallback(mPipTransitionCallback); + if (!PipUtils.isPip2ExperimentEnabled()) { + mMainExecutor.execute(() -> { + mTaskOrganizer.addListenerForType(this, TASK_LISTENER_TYPE_PIP); + }); + mTaskOrganizer.addFocusListener(this); + mPipTransitionController.setPipOrganizer(this); + displayController.addDisplayWindowListener(this); + pipTransitionController.registerPipTransitionCallback(mPipTransitionCallback); + } } public PipTransitionController getTransitionController() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java index 63627938ec875..0f74f9e323a53 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java @@ -142,8 +142,10 @@ public abstract class PipTransitionController implements Transitions.TransitionH mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipAnimationController = pipAnimationController; mTransitions = transitions; - if (Transitions.ENABLE_SHELL_TRANSITIONS) { - shellInit.addInitCallback(this::onInit, this); + if (!PipUtils.isPip2ExperimentEnabled()) { + if (Transitions.ENABLE_SHELL_TRANSITIONS) { + shellInit.addInitCallback(this::onInit, this); + } } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUtils.java index 8b98790d34990..3cd9848d56869 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUtils.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUtils.java @@ -27,6 +27,7 @@ import android.app.RemoteAction; import android.content.ComponentName; import android.content.Context; import android.os.RemoteException; +import android.os.SystemProperties; import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; @@ -46,6 +47,9 @@ public class PipUtils { // Minimum difference between two floats (e.g. aspect ratios) to consider them not equal. private static final double EPSILON = 1e-7; + private static final String ENABLE_PIP2_IMPLEMENTATION = + "persist.wm.debug.enable_pip2_implementation"; + /** * @return the ComponentName and user id of the top non-SystemUI activity in the pinned stack. * The component name may be null if no such activity exists. @@ -134,4 +138,8 @@ public class PipUtils { return null; } } + + public static boolean isPip2ExperimentEnabled() { + return SystemProperties.getBoolean(ENABLE_PIP2_IMPLEMENTATION, false); + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 51e7be0f8a244..5b9e47fb51884 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -461,8 +461,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb Optional oneHandedController, ShellExecutor mainExecutor ) { - - mContext = context; mShellCommandHandler = shellCommandHandler; mShellController = shellController; @@ -493,7 +491,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb mDisplayInsetsController = displayInsetsController; mTabletopModeController = tabletopModeController; - shellInit.addInitCallback(this::onInit, this); + if (!PipUtils.isPip2ExperimentEnabled()) { + shellInit.addInitCallback(this::onInit, this); + } } private void onInit() { @@ -1258,6 +1258,11 @@ public class PipController implements PipTransitionController.PipTransitionCallb PipController.this.showPictureInPictureMenu(); }); } + + @Override + public PipTransitionController getPipTransitionController() { + return mPipTransitionController; + } } /** diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java index 2c4f76b1f34b1..415f398765c1c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java @@ -57,6 +57,7 @@ import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip.PipUiEventLogger; +import com.android.wm.shell.pip.PipUtils; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.sysui.ShellInit; @@ -228,7 +229,9 @@ public class PipTouchHandler { // TODO(b/181599115): This should really be initializes as part of the pip controller, but // until all PIP implementations derive from the controller, just initialize the touch handler // if it is needed - shellInit.addInitCallback(this::onInit, this); + if (!PipUtils.isPip2ExperimentEnabled()) { + shellInit.addInitCallback(this::onInit, this); + } } /** diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/PipTransition.java new file mode 100644 index 0000000000000..8ab85d0829dfe --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/PipTransition.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.pip2; + +import android.annotation.NonNull; + +import com.android.wm.shell.ShellTaskOrganizer; +import com.android.wm.shell.pip.PipAnimationController; +import com.android.wm.shell.pip.PipBoundsAlgorithm; +import com.android.wm.shell.pip.PipBoundsState; +import com.android.wm.shell.pip.PipMenuController; +import com.android.wm.shell.pip.PipTransitionController; +import com.android.wm.shell.sysui.ShellInit; +import com.android.wm.shell.transition.Transitions; + +/** Placeholder, for demonstrate purpose only. */ +public abstract class PipTransition extends PipTransitionController { + public PipTransition( + @NonNull ShellInit shellInit, + @NonNull ShellTaskOrganizer shellTaskOrganizer, + @NonNull Transitions transitions, + PipBoundsState pipBoundsState, + PipMenuController pipMenuController, + PipBoundsAlgorithm pipBoundsAlgorithm, + PipAnimationController pipAnimationController) { + super(shellInit, shellTaskOrganizer, transitions, pipBoundsState, pipMenuController, + pipBoundsAlgorithm, pipAnimationController); + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/README.md b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/README.md new file mode 100644 index 0000000000000..415ea8f959cc5 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/README.md @@ -0,0 +1,3 @@ +# PLACEHOLDER + +This is meant to be the doc for the pip2 package. \ No newline at end of file diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java index c5c22ded8b71b..052af3af98cc6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java @@ -49,7 +49,6 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.desktopmode.DesktopTasksController; import com.android.wm.shell.keyguard.KeyguardTransitionHandler; import com.android.wm.shell.pip.PipTransitionController; -import com.android.wm.shell.pip.phone.PipTouchHandler; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.recents.RecentsTransitionHandler; import com.android.wm.shell.splitscreen.SplitScreenController; @@ -147,7 +146,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, public DefaultMixedHandler(@NonNull ShellInit shellInit, @NonNull Transitions player, Optional splitScreenControllerOptional, - Optional pipTouchHandlerOptional, + @Nullable PipTransitionController pipTransitionController, Optional recentsHandlerOptional, KeyguardTransitionHandler keyguardHandler, Optional desktopModeControllerOptional, @@ -155,11 +154,12 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, Optional unfoldHandler) { mPlayer = player; mKeyguardHandler = keyguardHandler; - if (Transitions.ENABLE_SHELL_TRANSITIONS && pipTouchHandlerOptional.isPresent() + if (Transitions.ENABLE_SHELL_TRANSITIONS + && pipTransitionController != null && splitScreenControllerOptional.isPresent()) { // Add after dependencies because it is higher priority shellInit.addInitCallback(() -> { - mPipHandler = pipTouchHandlerOptional.get().getTransitionHandler(); + mPipHandler = pipTransitionController; mSplitHandler = splitScreenControllerOptional.get().getTransitionHandler(); mPlayer.addHandler(this); if (mSplitHandler != null) {