Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cae6f7f authored by Alexandr Shabalin's avatar Alexandr Shabalin Committed by Android (Google) Code Review
Browse files

Merge "Allow the device list to be changed within 2 seconds after dialog opens." into main

parents be5f9f72 e1714cd8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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"
+21 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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,
@@ -204,6 +210,7 @@ public class MediaSwitchingController
            PowerExemptionManager powerExemptionManager,
            KeyguardManager keyGuardManager,
            FeatureFlags featureFlags,
            SystemClock clock,
            VolumePanelGlobalStateInteractor volumePanelGlobalStateInteractor,
            UserTracker userTracker) {
        mContext = context;
@@ -217,6 +224,7 @@ public class MediaSwitchingController
        mPowerExemptionManager = powerExemptionManager;
        mKeyGuardManager = keyGuardManager;
        mFeatureFlags = featureFlags;
        mClock = clock;
        mUserTracker = userTracker;
        mToken = token;
        mVolumePanelGlobalStateInteractor = volumePanelGlobalStateInteractor;
@@ -243,6 +251,7 @@ public class MediaSwitchingController
    }

    protected void start(@NonNull Callback cb) {
        mStartTime = mClock.elapsedRealtime();
        synchronized (mMediaDevicesLock) {
            mCachedMediaDevices.clear();
            mOutputMediaItemListProxy.clear();
@@ -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(),
@@ -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();
    }
@@ -949,6 +969,7 @@ public class MediaSwitchingController
                        mPowerExemptionManager,
                        mKeyGuardManager,
                        mFeatureFlags,
                        mClock,
                        mVolumePanelGlobalStateInteractor,
                        mUserTracker);
        MediaOutputBroadcastDialog dialog = new MediaOutputBroadcastDialog(mContext, true,
+2 −0
Original line number Diff line number Diff line
@@ -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;

@@ -167,6 +168,7 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
                        mPowerExemptionManager,
                        mKeyguardManager,
                        mFlags,
                        new FakeSystemClock(),
                        volumePanelGlobalStateInteractor,
                        mUserTracker);
    }
+2 −0
Original line number Diff line number Diff line
@@ -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;

@@ -158,6 +159,7 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase {
                        mPowerExemptionManager,
                        mKeyguardManager,
                        mFlags,
                        new FakeSystemClock(),
                        volumePanelGlobalStateInteractor,
                        mUserTracker);
        mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager;
+2 −0
Original line number Diff line number Diff line
@@ -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;

@@ -174,6 +175,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
                        mPowerExemptionManager,
                        mKeyguardManager,
                        mFlags,
                        new FakeSystemClock(),
                        volumePanelGlobalStateInteractor,
                        mUserTracker);
        mMediaSwitchingController.mLocalMediaManager = mLocalMediaManager;
Loading