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

Commit a747a967 authored by Alex Shabalin's avatar Alex Shabalin
Browse files

Clean up avoid_binder_calls_for_muting_expected_device

Test: atest MediaSwitchingControllerTest, InfoMediaManagerTest, BluetoothMediaDeviceTest
Flag: EXEMPT flag cleanup
Fix: 426672631
Change-Id: I92287dcdcc7fe68fcc2d58575db9c1ecab34c867
parent 230d4501
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -260,16 +260,6 @@ flag {
    bug: "293743975"
}

flag {
    name: "avoid_binder_calls_for_muting_expected_device"
    namespace: "media_better_together"
    description: "Sets isMutingExpectedDevice attribute during construction of MediaDevice."
    bug: "414668703"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_output_switcher_personal_audio_sharing"
    namespace: "cross_device_experiences"
+1 −6
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.settingslib.media;

import static com.android.media.flags.Flags.avoidBinderCallsForMutingExpectedDevice;
import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_TRANSFER;

import android.annotation.NonNull;
@@ -154,12 +153,8 @@ public class BluetoothMediaDevice extends MediaDevice {

    @Override
    public boolean isMutingExpectedDevice() {
        if (avoidBinderCallsForMutingExpectedDevice()) {
        return mIsMutingExpectedDevice;
    }
        return mAudioManager.getMutingExpectedDevice() != null && mCachedDevice.getAddress().equals(
                mAudioManager.getMutingExpectedDevice().getAddress());
    }

    @Override
    public boolean isConnected() {
+0 −3
Original line number Diff line number Diff line
@@ -26,10 +26,8 @@ import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaRoute2Info;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;

import com.android.media.flags.Flags;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;

import org.junit.Before;
@@ -153,7 +151,6 @@ public class BluetoothMediaDeviceTest {
        assertThat(bluetoothMediaDevice.getName()).isEqualTo(TEST_CACHED_DEVICE_NAME);
    }

    @EnableFlags(Flags.FLAG_AVOID_BINDER_CALLS_FOR_MUTING_EXPECTED_DEVICE)
    @Test
    public void getIsMutingExpectedDevice_dependsOnConstructorArgument() {
        MediaDevice bluetoothMediaDevice = new BluetoothMediaDevice(mContext, mDevice,
+6 −15
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ 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.avoidBinderCallsForMutingExpectedDevice;

import android.annotation.CallbackExecutor;
import android.app.AlertDialog;
import android.app.KeyguardManager;
@@ -165,9 +163,9 @@ public class MediaSwitchingController
    @VisibleForTesting
    MediaOutputMetricLogger mMetricLogger;
    private int mCurrentState;
    private FeatureFlags mFeatureFlags;
    private UserTracker mUserTracker;
    private VolumePanelGlobalStateInteractor mVolumePanelGlobalStateInteractor;
    private final FeatureFlags mFeatureFlags;
    private final UserTracker mUserTracker;
    private final VolumePanelGlobalStateInteractor mVolumePanelGlobalStateInteractor;
    @NonNull private MediaOutputColorScheme mMediaOutputColorScheme;
    @NonNull private MediaOutputColorSchemeLegacy mMediaOutputColorSchemeLegacy;
    private boolean mIsGroupListCollapsed = true;
@@ -374,12 +372,9 @@ public class MediaSwitchingController
     * Checks if there's any muting expected devices in the current MediaItem list.
     */
    public boolean hasMutingExpectedDevice() {
        if (avoidBinderCallsForMutingExpectedDevice()) {
        return mOutputMediaItemListProxy.getOutputMediaItemList().stream().anyMatch(
                MediaItem::isMutingExpectedDevice);
    }
        return mAudioManager.getMutingExpectedDevice() != null;
    }

    /**
     * Checks if there's any muting expected device in the provided device list.
@@ -622,12 +617,8 @@ public class MediaSwitchingController

            // For the first time building list, to make sure the top device is the connected
            // device.
            boolean hasMutingExpectedDevice =
                    avoidBinderCallsForMutingExpectedDevice()
                            ? containsMutingExpectedDevice(devices)
                            : hasMutingExpectedDevice();
            boolean needToHandleMutingExpectedDevice =
                    hasMutingExpectedDevice && !isCurrentConnectedDeviceRemote();
                    containsMutingExpectedDevice(devices) && !isCurrentConnectedDeviceRemote();
            final MediaDevice connectedMediaDevice =
                    needToHandleMutingExpectedDevice ? null : getCurrentConnectedMediaDevice();
            mOutputMediaItemListProxy.updateMediaDevices(
+0 −2
Original line number Diff line number Diff line
@@ -706,7 +706,6 @@ public class MediaSwitchingControllerTest extends SysuiTestCase {
        verify(mCb).onDeviceListChanged();
    }

    @EnableFlags(Flags.FLAG_AVOID_BINDER_CALLS_FOR_MUTING_EXPECTED_DEVICE)
    @Test
    public void onDeviceListUpdate_withMutingExpectedDevice_putItOnTop() {
        when(mMediaDevice1.isSuggestedDevice()).thenReturn(false);
@@ -723,7 +722,6 @@ public class MediaSwitchingControllerTest extends SysuiTestCase {
        assertThat(mMediaSwitchingController.hasMutingExpectedDevice()).isTrue();
    }

    @EnableFlags(Flags.FLAG_AVOID_BINDER_CALLS_FOR_MUTING_EXPECTED_DEVICE)
    @Test
    public void onDeviceListUpdate_noMutingExpectedDevice_processListNormally() {
        when(mMediaDevice1.isSuggestedDevice()).thenReturn(false);