Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipMediaController.kt +7 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,13 @@ class PipMediaController(private val mContext: Context, private val mMainHandler setActiveMediaController(null) } /** * Returns {@code true} if the pinned Activity has an active associated MediaSession. */ fun hasActiveMediaSession(): Boolean { return mMediaController != null } /** * Sets the active media controller for the top PiP activity. */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUtils.kt +10 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,16 @@ object PipUtils { return isPip2ExperimentEnabled as Boolean } private var isPipUmoExperienceEnabled: Boolean? = null @JvmStatic fun isPipUmoExperienceEnabled(): Boolean { if (isPipUmoExperienceEnabled == null) { isPipUmoExperienceEnabled = Flags.enablePipUmoExperience() } return isPipUmoExperienceEnabled as Boolean } /** * Returns true if the system theme is the dark theme. */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −1 Original line number Diff line number Diff line Loading @@ -135,6 +135,7 @@ public abstract class Pip2Module { PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, @ShellMainThread ShellExecutor mainExecutor) { if (!PipUtils.isPip2ExperimentEnabled()) { Loading @@ -145,7 +146,8 @@ public abstract class Pip2Module { displayInsetsController, pipBoundsState, pipBoundsAlgorithm, pipDisplayLayoutState, pipScheduler, taskStackListener, shellTaskOrganizer, pipTransitionState, pipTouchHandler, pipAppOpsListener, pipMenuController, pipUiEventLogger, pipSurfaceTransactionHelper, mainExecutor)); pipUiEventLogger, pipMediaController, pipSurfaceTransactionHelper, mainExecutor)); } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PhonePipMenuController.java +7 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipMediaController.ActionListener; import com.android.wm.shell.common.pip.PipMenuController; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.io.PrintWriter; Loading Loading @@ -486,6 +487,12 @@ public class PhonePipMenuController implements PipMenuController, * @return the best set of actions to show in the PiP menu. */ private List<RemoteAction> resolveMenuActions() { // If UMO Experience is enabled, default to MediaSession actions if present. // Note that mMediaActions can be pulled asynchronously, we use the active media session // check here instead. if (PipUtils.isPipUmoExperienceEnabled() && mMediaController.hasActiveMediaSession()) { return mMediaActions; } if (isValidActions(mAppActions)) { return mAppActions; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipController.java +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import com.android.wm.shell.common.pip.PipAppOpsListener; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.pip.Pip; Loading Loading @@ -109,6 +110,7 @@ public class PipController implements ConfigurationChangeListener, private final ShellExecutor mMainExecutor; private final PipImpl mImpl; private final List<Consumer<Boolean>> mOnIsInPipStateChangedListeners = new ArrayList<>(); private final PipMediaController mMediaController; // Wrapper for making Binder calls into PiP animation listener hosted in launcher's Recents. @Nullable private PipAnimationListener mPipRecentsAnimationListener; Loading Loading @@ -156,6 +158,7 @@ public class PipController implements ConfigurationChangeListener, PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, ShellExecutor mainExecutor) { mContext = context; Loading @@ -175,6 +178,7 @@ public class PipController implements ConfigurationChangeListener, mPipAppOpsListener = pipAppOpsListener; mPipMenuController = pipMenuController; mPipUiEventLogger = pipUiEventLogger; mMediaController = pipMediaController; mPipSurfaceTransactionHelper = pipSurfaceTransactionHelper; mMainExecutor = mainExecutor; mImpl = new PipImpl(); Loading Loading @@ -204,6 +208,7 @@ public class PipController implements ConfigurationChangeListener, PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, ShellExecutor mainExecutor) { if (!context.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)) { Loading @@ -215,7 +220,8 @@ public class PipController implements ConfigurationChangeListener, displayController, displayInsetsController, pipBoundsState, pipBoundsAlgorithm, pipDisplayLayoutState, pipScheduler, taskStackListener, shellTaskOrganizer, pipTransitionState, pipTouchHandler, pipAppOpsListener, pipMenuController, pipUiEventLogger, pipSurfaceTransactionHelper, mainExecutor); pipUiEventLogger, pipMediaController, pipSurfaceTransactionHelper, mainExecutor); } public PipImpl getPipImpl() { Loading Loading @@ -515,6 +521,7 @@ public class PipController implements ConfigurationChangeListener, if (taskInfo != null && taskInfo.topActivity != null) { mPipAppOpsListener.onActivityPinned(taskInfo.topActivity.getPackageName()); mPipUiEventLogger.setTaskInfo(taskInfo); mMediaController.onActivityPinned(); } if (mPipTransitionState.isInSwipePipToHomeTransition()) { mPipUiEventLogger.log( Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipMediaController.kt +7 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,13 @@ class PipMediaController(private val mContext: Context, private val mMainHandler setActiveMediaController(null) } /** * Returns {@code true} if the pinned Activity has an active associated MediaSession. */ fun hasActiveMediaSession(): Boolean { return mMediaController != null } /** * Sets the active media controller for the top PiP activity. */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUtils.kt +10 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,16 @@ object PipUtils { return isPip2ExperimentEnabled as Boolean } private var isPipUmoExperienceEnabled: Boolean? = null @JvmStatic fun isPipUmoExperienceEnabled(): Boolean { if (isPipUmoExperienceEnabled == null) { isPipUmoExperienceEnabled = Flags.enablePipUmoExperience() } return isPipUmoExperienceEnabled as Boolean } /** * Returns true if the system theme is the dark theme. */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −1 Original line number Diff line number Diff line Loading @@ -135,6 +135,7 @@ public abstract class Pip2Module { PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, @ShellMainThread ShellExecutor mainExecutor) { if (!PipUtils.isPip2ExperimentEnabled()) { Loading @@ -145,7 +146,8 @@ public abstract class Pip2Module { displayInsetsController, pipBoundsState, pipBoundsAlgorithm, pipDisplayLayoutState, pipScheduler, taskStackListener, shellTaskOrganizer, pipTransitionState, pipTouchHandler, pipAppOpsListener, pipMenuController, pipUiEventLogger, pipSurfaceTransactionHelper, mainExecutor)); pipUiEventLogger, pipMediaController, pipSurfaceTransactionHelper, mainExecutor)); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PhonePipMenuController.java +7 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipMediaController.ActionListener; import com.android.wm.shell.common.pip.PipMenuController; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.io.PrintWriter; Loading Loading @@ -486,6 +487,12 @@ public class PhonePipMenuController implements PipMenuController, * @return the best set of actions to show in the PiP menu. */ private List<RemoteAction> resolveMenuActions() { // If UMO Experience is enabled, default to MediaSession actions if present. // Note that mMediaActions can be pulled asynchronously, we use the active media session // check here instead. if (PipUtils.isPipUmoExperienceEnabled() && mMediaController.hasActiveMediaSession()) { return mMediaActions; } if (isValidActions(mAppActions)) { return mAppActions; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipController.java +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import com.android.wm.shell.common.pip.PipAppOpsListener; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.pip.Pip; Loading Loading @@ -109,6 +110,7 @@ public class PipController implements ConfigurationChangeListener, private final ShellExecutor mMainExecutor; private final PipImpl mImpl; private final List<Consumer<Boolean>> mOnIsInPipStateChangedListeners = new ArrayList<>(); private final PipMediaController mMediaController; // Wrapper for making Binder calls into PiP animation listener hosted in launcher's Recents. @Nullable private PipAnimationListener mPipRecentsAnimationListener; Loading Loading @@ -156,6 +158,7 @@ public class PipController implements ConfigurationChangeListener, PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, ShellExecutor mainExecutor) { mContext = context; Loading @@ -175,6 +178,7 @@ public class PipController implements ConfigurationChangeListener, mPipAppOpsListener = pipAppOpsListener; mPipMenuController = pipMenuController; mPipUiEventLogger = pipUiEventLogger; mMediaController = pipMediaController; mPipSurfaceTransactionHelper = pipSurfaceTransactionHelper; mMainExecutor = mainExecutor; mImpl = new PipImpl(); Loading Loading @@ -204,6 +208,7 @@ public class PipController implements ConfigurationChangeListener, PipAppOpsListener pipAppOpsListener, PhonePipMenuController pipMenuController, PipUiEventLogger pipUiEventLogger, PipMediaController pipMediaController, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, ShellExecutor mainExecutor) { if (!context.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)) { Loading @@ -215,7 +220,8 @@ public class PipController implements ConfigurationChangeListener, displayController, displayInsetsController, pipBoundsState, pipBoundsAlgorithm, pipDisplayLayoutState, pipScheduler, taskStackListener, shellTaskOrganizer, pipTransitionState, pipTouchHandler, pipAppOpsListener, pipMenuController, pipUiEventLogger, pipSurfaceTransactionHelper, mainExecutor); pipUiEventLogger, pipMediaController, pipSurfaceTransactionHelper, mainExecutor); } public PipImpl getPipImpl() { Loading Loading @@ -515,6 +521,7 @@ public class PipController implements ConfigurationChangeListener, if (taskInfo != null && taskInfo.topActivity != null) { mPipAppOpsListener.onActivityPinned(taskInfo.topActivity.getPackageName()); mPipUiEventLogger.setTaskInfo(taskInfo); mMediaController.onActivityPinned(); } if (mPipTransitionState.isInSwipePipToHomeTransition()) { mPipUiEventLogger.log( Loading