Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipFlags.kt 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.shared.pip import android.app.AppGlobals import android.content.pm.PackageManager import android.window.DesktopExperienceFlags.ENABLE_DESKTOP_WINDOWING_PIP import com.android.wm.shell.Flags class PipFlags { companion object { /** * Returns true if PiP2 implementation should be used. Special note: if PiP on Desktop * Windowing is enabled, override the PiP2 gantry flag to be ON. */ @JvmStatic val isPip2ExperimentEnabled: Boolean by lazy { val isTv = AppGlobals.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK, 0) (Flags.enablePip2() || ENABLE_DESKTOP_WINDOWING_PIP.isTrue) && !isTv } @JvmStatic val isPipUmoExperienceEnabled: Boolean by lazy { Flags.enablePipUmoExperience() } } } libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUtils.kt +3 −37 Original line number Diff line number Diff line Loading @@ -16,12 +16,10 @@ package com.android.wm.shell.common.pip import android.app.ActivityTaskManager import android.app.AppGlobals import android.app.RemoteAction import android.app.WindowConfiguration import android.content.ComponentName import android.content.Context import android.content.pm.PackageManager import android.content.res.Configuration import android.content.res.Configuration.UI_MODE_NIGHT_MASK import android.graphics.PointF Loading @@ -35,6 +33,7 @@ import android.window.DesktopExperienceFlags.ENABLE_DESKTOP_WINDOWING_PIP import android.window.TaskSnapshot import android.window.TransitionInfo import com.android.internal.protolog.ProtoLog import com.android.wm.shell.shared.pip.PipFlags import com.android.wm.shell.Flags import com.android.wm.shell.protolog.ShellProtoLogGroup import java.io.PrintWriter Loading Loading @@ -308,39 +307,6 @@ object PipUtils { outCrop.bottom = roundOut(outCrop.top + startBounds.height() * hintToEndScaleY) } private var isPip2ExperimentEnabled: Boolean? = null /** * Returns true if PiP2 implementation should be used. Besides the trunk stable flag, * system property can be used to override this read only flag during development. * It's currently limited to phone form factor, i.e., not enabled on ARC / TV. * * Special note: if PiP on Desktop Windowing is enabled, override the PiP2 gantry flag to be ON. */ @JvmStatic fun isPip2ExperimentEnabled(): Boolean { if (isPip2ExperimentEnabled == null) { val isArc = AppGlobals.getPackageManager().hasSystemFeature( "org.chromium.arc", 0) val isTv = AppGlobals.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK, 0) val shouldOverridePip2Flag = ENABLE_DESKTOP_WINDOWING_PIP.isTrue isPip2ExperimentEnabled = (Flags.enablePip2() || shouldOverridePip2Flag) && !isArc && !isTv } 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 @@ -358,8 +324,8 @@ object PipUtils { pw.println("$prefix$TAG") val innerPrefix1 = "$prefix " val innerPrefix2 = "$innerPrefix1 " pw.println("${innerPrefix1}isPipUmoExperienceEnabled=${isPipUmoExperienceEnabled()}") pw.println("${innerPrefix1}isPip2ExperimentEnabled=${isPip2ExperimentEnabled()}") pw.println("${innerPrefix1}isPipUmoExperienceEnabled=${PipFlags.isPipUmoExperienceEnabled}") pw.println("${innerPrefix1}isPip2ExperimentEnabled=${PipFlags.isPip2ExperimentEnabled}") pw.println("${innerPrefix2}enablePip2=${Flags.enablePip2()}") pw.println("${innerPrefix2}enableDwPip=${ENABLE_DESKTOP_WINDOWING_PIP.isTrue}") } Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipPerfHintController; import com.android.wm.shell.common.pip.PipSnapAlgorithm; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.common.pip.SizeSpecSource; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; Loading @@ -64,6 +63,7 @@ import com.android.wm.shell.pip2.phone.PipUiStateChangeController; import com.android.wm.shell.recents.RecentsTransitionHandler; import com.android.wm.shell.shared.annotations.ShellMainThread; import com.android.wm.shell.shared.desktopmode.DesktopState; import com.android.wm.shell.shared.pip.PipFlags; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellCommandHandler; import com.android.wm.shell.sysui.ShellController; Loading Loading @@ -145,7 +145,7 @@ public abstract class Pip2Module { PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, @ShellMainThread ShellExecutor mainExecutor) { if (!PipUtils.isPip2ExperimentEnabled()) { if (!PipFlags.isPip2ExperimentEnabled()) { return Optional.empty(); } else { return Optional.ofNullable(PipController.create( Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java +3 −3 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.wm.shell.dagger.pip; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip2.phone.PipController; import com.android.wm.shell.pip2.phone.PipTransition; import com.android.wm.shell.shared.pip.PipFlags; import dagger.Module; import dagger.Provides; Loading @@ -42,7 +42,7 @@ public abstract class PipModule { static PipTransitionController providePipTransitionController( com.android.wm.shell.pip.PipTransition legacyPipTransition, PipTransition newPipTransition) { if (PipUtils.isPip2ExperimentEnabled()) { if (PipFlags.isPip2ExperimentEnabled()) { return newPipTransition; } else { return legacyPipTransition; Loading @@ -54,7 +54,7 @@ public abstract class PipModule { static Optional<Pip> providePip( Optional<com.android.wm.shell.pip.phone.PipController.PipImpl> pip1, Optional<PipController.PipImpl> pip2) { if (PipUtils.isPip2ExperimentEnabled()) { if (PipFlags.isPip2ExperimentEnabled()) { return Optional.ofNullable(pip2.orElse(null)); } else { Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.animation.Interpolators; import com.android.wm.shell.shared.annotations.ShellMainThread; import com.android.wm.shell.shared.pip.PipContentOverlay; import com.android.wm.shell.shared.pip.PipFlags; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.transition.Transitions; Loading Loading @@ -417,7 +418,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mTaskOrganizer = shellTaskOrganizer; mMainExecutor = mainExecutor; if (!PipUtils.isPip2ExperimentEnabled()) { if (!PipFlags.isPip2ExperimentEnabled()) { shellInit.addInitCallback(this::onInit, this); } } Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipFlags.kt 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.shared.pip import android.app.AppGlobals import android.content.pm.PackageManager import android.window.DesktopExperienceFlags.ENABLE_DESKTOP_WINDOWING_PIP import com.android.wm.shell.Flags class PipFlags { companion object { /** * Returns true if PiP2 implementation should be used. Special note: if PiP on Desktop * Windowing is enabled, override the PiP2 gantry flag to be ON. */ @JvmStatic val isPip2ExperimentEnabled: Boolean by lazy { val isTv = AppGlobals.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK, 0) (Flags.enablePip2() || ENABLE_DESKTOP_WINDOWING_PIP.isTrue) && !isTv } @JvmStatic val isPipUmoExperienceEnabled: Boolean by lazy { Flags.enablePipUmoExperience() } } }
libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipUtils.kt +3 −37 Original line number Diff line number Diff line Loading @@ -16,12 +16,10 @@ package com.android.wm.shell.common.pip import android.app.ActivityTaskManager import android.app.AppGlobals import android.app.RemoteAction import android.app.WindowConfiguration import android.content.ComponentName import android.content.Context import android.content.pm.PackageManager import android.content.res.Configuration import android.content.res.Configuration.UI_MODE_NIGHT_MASK import android.graphics.PointF Loading @@ -35,6 +33,7 @@ import android.window.DesktopExperienceFlags.ENABLE_DESKTOP_WINDOWING_PIP import android.window.TaskSnapshot import android.window.TransitionInfo import com.android.internal.protolog.ProtoLog import com.android.wm.shell.shared.pip.PipFlags import com.android.wm.shell.Flags import com.android.wm.shell.protolog.ShellProtoLogGroup import java.io.PrintWriter Loading Loading @@ -308,39 +307,6 @@ object PipUtils { outCrop.bottom = roundOut(outCrop.top + startBounds.height() * hintToEndScaleY) } private var isPip2ExperimentEnabled: Boolean? = null /** * Returns true if PiP2 implementation should be used. Besides the trunk stable flag, * system property can be used to override this read only flag during development. * It's currently limited to phone form factor, i.e., not enabled on ARC / TV. * * Special note: if PiP on Desktop Windowing is enabled, override the PiP2 gantry flag to be ON. */ @JvmStatic fun isPip2ExperimentEnabled(): Boolean { if (isPip2ExperimentEnabled == null) { val isArc = AppGlobals.getPackageManager().hasSystemFeature( "org.chromium.arc", 0) val isTv = AppGlobals.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK, 0) val shouldOverridePip2Flag = ENABLE_DESKTOP_WINDOWING_PIP.isTrue isPip2ExperimentEnabled = (Flags.enablePip2() || shouldOverridePip2Flag) && !isArc && !isTv } 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 @@ -358,8 +324,8 @@ object PipUtils { pw.println("$prefix$TAG") val innerPrefix1 = "$prefix " val innerPrefix2 = "$innerPrefix1 " pw.println("${innerPrefix1}isPipUmoExperienceEnabled=${isPipUmoExperienceEnabled()}") pw.println("${innerPrefix1}isPip2ExperimentEnabled=${isPip2ExperimentEnabled()}") pw.println("${innerPrefix1}isPipUmoExperienceEnabled=${PipFlags.isPipUmoExperienceEnabled}") pw.println("${innerPrefix1}isPip2ExperimentEnabled=${PipFlags.isPip2ExperimentEnabled}") pw.println("${innerPrefix2}enablePip2=${Flags.enablePip2()}") pw.println("${innerPrefix2}enableDwPip=${ENABLE_DESKTOP_WINDOWING_PIP.isTrue}") } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import com.android.wm.shell.common.pip.PipMediaController; import com.android.wm.shell.common.pip.PipPerfHintController; import com.android.wm.shell.common.pip.PipSnapAlgorithm; import com.android.wm.shell.common.pip.PipUiEventLogger; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.common.pip.SizeSpecSource; import com.android.wm.shell.dagger.WMShellBaseModule; import com.android.wm.shell.dagger.WMSingleton; Loading @@ -64,6 +63,7 @@ import com.android.wm.shell.pip2.phone.PipUiStateChangeController; import com.android.wm.shell.recents.RecentsTransitionHandler; import com.android.wm.shell.shared.annotations.ShellMainThread; import com.android.wm.shell.shared.desktopmode.DesktopState; import com.android.wm.shell.shared.pip.PipFlags; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellCommandHandler; import com.android.wm.shell.sysui.ShellController; Loading Loading @@ -145,7 +145,7 @@ public abstract class Pip2Module { PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, PipSurfaceTransactionHelper pipSurfaceTransactionHelper, @ShellMainThread ShellExecutor mainExecutor) { if (!PipUtils.isPip2ExperimentEnabled()) { if (!PipFlags.isPip2ExperimentEnabled()) { return Optional.empty(); } else { return Optional.ofNullable(PipController.create( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/PipModule.java +3 −3 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.wm.shell.dagger.pip; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.dagger.WMSingleton; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip2.phone.PipController; import com.android.wm.shell.pip2.phone.PipTransition; import com.android.wm.shell.shared.pip.PipFlags; import dagger.Module; import dagger.Provides; Loading @@ -42,7 +42,7 @@ public abstract class PipModule { static PipTransitionController providePipTransitionController( com.android.wm.shell.pip.PipTransition legacyPipTransition, PipTransition newPipTransition) { if (PipUtils.isPip2ExperimentEnabled()) { if (PipFlags.isPip2ExperimentEnabled()) { return newPipTransition; } else { return legacyPipTransition; Loading @@ -54,7 +54,7 @@ public abstract class PipModule { static Optional<Pip> providePip( Optional<com.android.wm.shell.pip.phone.PipController.PipImpl> pip1, Optional<PipController.PipImpl> pip2) { if (PipUtils.isPip2ExperimentEnabled()) { if (PipFlags.isPip2ExperimentEnabled()) { return Optional.ofNullable(pip2.orElse(null)); } else { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.animation.Interpolators; import com.android.wm.shell.shared.annotations.ShellMainThread; import com.android.wm.shell.shared.pip.PipContentOverlay; import com.android.wm.shell.shared.pip.PipFlags; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.transition.Transitions; Loading Loading @@ -417,7 +418,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mTaskOrganizer = shellTaskOrganizer; mMainExecutor = mainExecutor; if (!PipUtils.isPip2ExperimentEnabled()) { if (!PipFlags.isPip2ExperimentEnabled()) { shellInit.addInitCallback(this::onInit, this); } } Loading