Loading media/java/android/media/flags/media_better_together.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,16 @@ flag { bug: "388296370" } flag { name: "allow_output_switcher_list_rearrangement_within_timeout" namespace: "media_better_together" description: "Allows Output Switcher device list to rearrange items within a short time after opening." bug: "422074183" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "enable_per_app_mirroring_in_media_router_2" namespace: "media_better_together" Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +21 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static android.media.RouteListingPreference.ACTION_TRANSFER_MEDIA; import static android.media.RouteListingPreference.EXTRA_ROUTE_ID; import static android.provider.Settings.ACTION_BLUETOOTH_SETTINGS; import static com.android.media.flags.Flags.allowOutputSwitcherListRearrangementWithinTimeout; import android.annotation.CallbackExecutor; import android.app.AlertDialog; import android.app.KeyguardManager; Loading Loading @@ -93,6 +95,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.util.time.SystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import dagger.assisted.Assisted; Loading Loading @@ -125,6 +128,7 @@ public class MediaSwitchingController private static final String PAGE_CONNECTED_DEVICES_KEY = "top_level_connected_devices"; private static final long ALLOWLIST_DURATION_MS = 20000; private static final long LIST_CHANGE_ALLOWED_TIMEOUT_MS = 2000; private static final String ALLOWLIST_REASON = "mediaoutput:remote_transfer"; private final String mPackageName; Loading Loading @@ -164,12 +168,14 @@ public class MediaSwitchingController MediaOutputMetricLogger mMetricLogger; private int mCurrentState; private final FeatureFlags mFeatureFlags; private final SystemClock mClock; private final UserTracker mUserTracker; private final VolumePanelGlobalStateInteractor mVolumePanelGlobalStateInteractor; @NonNull private MediaOutputColorScheme mMediaOutputColorScheme; @NonNull private MediaOutputColorSchemeLegacy mMediaOutputColorSchemeLegacy; private boolean mIsGroupListCollapsed = true; private boolean mHasAdjustVolumeUserRestriction = false; private long mStartTime; public enum BroadcastNotifyDialog { ACTION_FIRST_LAUNCH, Loading Loading @@ -204,6 +210,7 @@ public class MediaSwitchingController PowerExemptionManager powerExemptionManager, KeyguardManager keyGuardManager, FeatureFlags featureFlags, SystemClock clock, VolumePanelGlobalStateInteractor volumePanelGlobalStateInteractor, UserTracker userTracker) { mContext = context; Loading @@ -217,6 +224,7 @@ public class MediaSwitchingController mPowerExemptionManager = powerExemptionManager; mKeyGuardManager = keyGuardManager; mFeatureFlags = featureFlags; mClock = clock; mUserTracker = userTracker; mToken = token; mVolumePanelGlobalStateInteractor = volumePanelGlobalStateInteractor; Loading @@ -243,6 +251,7 @@ public class MediaSwitchingController } protected void start(@NonNull Callback cb) { mStartTime = mClock.elapsedRealtime(); synchronized (mMediaDevicesLock) { mCachedMediaDevices.clear(); mOutputMediaItemListProxy.clear(); Loading Loading @@ -617,6 +626,11 @@ public class MediaSwitchingController containsMutingExpectedDevice(devices) && !isCurrentConnectedDeviceRemote(); final MediaDevice connectedMediaDevice = needToHandleMutingExpectedDevice ? null : getCurrentConnectedMediaDevice(); if (isDeviceListRearrangementAllowed()) { // We erase all the items from the previous render so that the sorting and // categorization are run from a clean slate. mOutputMediaItemListProxy.clear(); } mOutputMediaItemListProxy.updateMediaDevices( devices, getSelectedMediaDevice(), Loading @@ -625,6 +639,12 @@ public class MediaSwitchingController } } /** Whether it's allowed to change device list order and categories. */ private boolean isDeviceListRearrangementAllowed() { return allowOutputSwitcherListRearrangementWithinTimeout() && mClock.elapsedRealtime() - mStartTime <= LIST_CHANGE_ALLOWED_TIMEOUT_MS; } private boolean enableInputRouting() { return Flags.enableAudioInputDeviceRoutingAndVolumeControl(); } Loading Loading @@ -949,6 +969,7 @@ public class MediaSwitchingController mPowerExemptionManager, mKeyGuardManager, mFeatureFlags, mClock, mVolumePanelGlobalStateInteractor, mUserTracker); MediaOutputBroadcastDialog dialog = new MediaOutputBroadcastDialog(mContext, true, Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -167,6 +168,7 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); } Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -158,6 +159,7 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager; Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -174,6 +175,7 @@ public class MediaOutputDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager; Loading Loading
media/java/android/media/flags/media_better_together.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,16 @@ flag { bug: "388296370" } flag { name: "allow_output_switcher_list_rearrangement_within_timeout" namespace: "media_better_together" description: "Allows Output Switcher device list to rearrange items within a short time after opening." bug: "422074183" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "enable_per_app_mirroring_in_media_router_2" namespace: "media_better_together" Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +21 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static android.media.RouteListingPreference.ACTION_TRANSFER_MEDIA; import static android.media.RouteListingPreference.EXTRA_ROUTE_ID; import static android.provider.Settings.ACTION_BLUETOOTH_SETTINGS; import static com.android.media.flags.Flags.allowOutputSwitcherListRearrangementWithinTimeout; import android.annotation.CallbackExecutor; import android.app.AlertDialog; import android.app.KeyguardManager; Loading Loading @@ -93,6 +95,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.util.time.SystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import dagger.assisted.Assisted; Loading Loading @@ -125,6 +128,7 @@ public class MediaSwitchingController private static final String PAGE_CONNECTED_DEVICES_KEY = "top_level_connected_devices"; private static final long ALLOWLIST_DURATION_MS = 20000; private static final long LIST_CHANGE_ALLOWED_TIMEOUT_MS = 2000; private static final String ALLOWLIST_REASON = "mediaoutput:remote_transfer"; private final String mPackageName; Loading Loading @@ -164,12 +168,14 @@ public class MediaSwitchingController MediaOutputMetricLogger mMetricLogger; private int mCurrentState; private final FeatureFlags mFeatureFlags; private final SystemClock mClock; private final UserTracker mUserTracker; private final VolumePanelGlobalStateInteractor mVolumePanelGlobalStateInteractor; @NonNull private MediaOutputColorScheme mMediaOutputColorScheme; @NonNull private MediaOutputColorSchemeLegacy mMediaOutputColorSchemeLegacy; private boolean mIsGroupListCollapsed = true; private boolean mHasAdjustVolumeUserRestriction = false; private long mStartTime; public enum BroadcastNotifyDialog { ACTION_FIRST_LAUNCH, Loading Loading @@ -204,6 +210,7 @@ public class MediaSwitchingController PowerExemptionManager powerExemptionManager, KeyguardManager keyGuardManager, FeatureFlags featureFlags, SystemClock clock, VolumePanelGlobalStateInteractor volumePanelGlobalStateInteractor, UserTracker userTracker) { mContext = context; Loading @@ -217,6 +224,7 @@ public class MediaSwitchingController mPowerExemptionManager = powerExemptionManager; mKeyGuardManager = keyGuardManager; mFeatureFlags = featureFlags; mClock = clock; mUserTracker = userTracker; mToken = token; mVolumePanelGlobalStateInteractor = volumePanelGlobalStateInteractor; Loading @@ -243,6 +251,7 @@ public class MediaSwitchingController } protected void start(@NonNull Callback cb) { mStartTime = mClock.elapsedRealtime(); synchronized (mMediaDevicesLock) { mCachedMediaDevices.clear(); mOutputMediaItemListProxy.clear(); Loading Loading @@ -617,6 +626,11 @@ public class MediaSwitchingController containsMutingExpectedDevice(devices) && !isCurrentConnectedDeviceRemote(); final MediaDevice connectedMediaDevice = needToHandleMutingExpectedDevice ? null : getCurrentConnectedMediaDevice(); if (isDeviceListRearrangementAllowed()) { // We erase all the items from the previous render so that the sorting and // categorization are run from a clean slate. mOutputMediaItemListProxy.clear(); } mOutputMediaItemListProxy.updateMediaDevices( devices, getSelectedMediaDevice(), Loading @@ -625,6 +639,12 @@ public class MediaSwitchingController } } /** Whether it's allowed to change device list order and categories. */ private boolean isDeviceListRearrangementAllowed() { return allowOutputSwitcherListRearrangementWithinTimeout() && mClock.elapsedRealtime() - mStartTime <= LIST_CHANGE_ALLOWED_TIMEOUT_MS; } private boolean enableInputRouting() { return Flags.enableAudioInputDeviceRoutingAndVolumeControl(); } Loading Loading @@ -949,6 +969,7 @@ public class MediaSwitchingController mPowerExemptionManager, mKeyGuardManager, mFeatureFlags, mClock, mVolumePanelGlobalStateInteractor, mUserTracker); MediaOutputBroadcastDialog dialog = new MediaOutputBroadcastDialog(mContext, true, Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -167,6 +168,7 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); } Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -158,6 +159,7 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager; Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractor; import com.android.systemui.volume.panel.domain.interactor.VolumePanelGlobalStateInteractorKosmosKt; Loading Loading @@ -174,6 +175,7 @@ public class MediaOutputDialogTest extends SysuiTestCase { mPowerExemptionManager, mKeyguardManager, mFlags, new FakeSystemClock(), volumePanelGlobalStateInteractor, mUserTracker); mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager; Loading