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

Commit 1477584e authored by Yiyi Shen's avatar Yiyi Shen
Browse files

[Audiosharing] Gates legacy le audio sharing UI.

Bug: 322295262
Flag: ACONFIG com.android.systemui.legacy_le_audio_sharing DEVELOPMENT
Test: compile
Change-Id: I27edbff752d46e8e6353f29a865a3bb1672b9969
parent 9e73f1db
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.media.controls.ui;

import static android.provider.Settings.ACTION_MEDIA_CONTROLS_SETTINGS;

import static com.android.systemui.Flags.legacyLeAudioSharing;
import static com.android.systemui.media.controls.models.recommendation.SmartspaceMediaDataKt.NUM_REQUIRED_RECOMMENDATIONS;

import android.animation.Animator;
@@ -597,7 +598,9 @@ public class MediaControlPanel {

        // Show the broadcast dialog button only when the le audio is enabled.
        mShowBroadcastDialogButton =
                data.getDevice() != null && data.getDevice().getShowBroadcastButton();
                legacyLeAudioSharing()
                        && data.getDevice() != null
                        && data.getDevice().getShowBroadcastButton();
        bindOutputSwitcherAndBroadcastButton(mShowBroadcastDialogButton, data);
        bindGutsMenuForPlayer(data);
        bindPlayerContentDescription(data);
@@ -1930,3 +1933,4 @@ public class MediaControlPanel {
                interactedSubcardCardinality);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.media.dialog;

import static com.android.systemui.Flags.legacyLeAudioSharing;

import android.content.Context;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
@@ -108,6 +110,7 @@ public class MediaOutputDialog extends MediaOutputBaseDialog {

    @Override
    public boolean isBroadcastSupported() {
        if (!legacyLeAudioSharing()) return false;
        boolean isBluetoothLeDevice = false;
        boolean isBroadcastEnabled = false;
        if (FeatureFlagUtils.isEnabled(mContext,
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.media.session.MediaSession
import android.media.session.PlaybackState
import android.os.Bundle
import android.platform.test.annotations.EnableFlags
import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import android.provider.Settings
import android.provider.Settings.ACTION_MEDIA_CONTROLS_SETTINGS
import android.testing.AndroidTestingRunner
@@ -140,6 +142,7 @@ private const val APP_NAME = "APP_NAME"
@RunWith(AndroidTestingRunner::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class MediaControlPanelTest : SysuiTestCase() {
    @get:Rule val checkFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()

    private lateinit var player: MediaControlPanel

@@ -1244,6 +1247,7 @@ public class MediaControlPanelTest : SysuiTestCase() {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    fun bindBroadcastButton() {
        initMediaViewHolderMocks()
        initDeviceMediaData(true, APP_NAME)
+20 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.PowerExemptionManager;
import android.os.UserHandle;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.FeatureFlagUtils;
@@ -61,6 +64,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -76,6 +80,9 @@ public class MediaOutputDialogTest extends SysuiTestCase {

    private static final String TEST_PACKAGE = "test_package";

    @Rule
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();

    // Mock
    private final MediaSessionManager mMediaSessionManager = mock(MediaSessionManager.class);
    private MediaController mMediaController = mock(MediaController.class);
@@ -170,6 +177,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getStopButtonVisibility_remoteBLEDevice_returnVisible() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -181,6 +189,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getStopButtonVisibility_remoteNonBLEDevice_returnGone() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -201,6 +210,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_flagOnAndConnectBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -213,6 +223,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_flagOnAndNoBleDevice_returnsFalse() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -225,6 +236,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_notSupportBroadcastAndflagOn_returnsFalse() {
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
@@ -233,6 +245,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_flagOffAndConnectToBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -245,6 +258,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_flagOffAndNoBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -257,6 +271,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_noBleDeviceAndEnabledBroadcast_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -269,6 +284,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void isBroadcastSupported_noBleDeviceAndDisabledBroadcast_returnsFalse() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -281,6 +297,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getBroadcastIconVisibility_isBroadcasting_returnVisible() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -292,6 +309,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getBroadcastIconVisibility_noBroadcasting_returnGone() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -303,6 +321,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getBroadcastIconVisibility_remoteNonLeDevice_returnGone() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
@@ -355,6 +374,7 @@ public class MediaOutputDialogTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsEnabled(com.android.systemui.Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    public void getStopButtonText_supportsBroadcast_returnsBroadcastText() {
        String stopText = mContext.getText(R.string.media_output_broadcast).toString();
        MediaDevice mMediaDevice = mock(MediaDevice.class);