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

Commit a71abc13 authored by Betty Chang's avatar Betty Chang Committed by Gerrit Code Review
Browse files

Merge "[LE Audio] Add feature flag to decouple Broadcast from Unicast"

parents 4cdefcca 3191c602
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -76,6 +76,16 @@ public class FeatureFlagUtils {
    public static final String SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME =
    public static final String SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME =
            "settings_app_allow_dark_theme_activation_at_bedtime";
            "settings_app_allow_dark_theme_activation_at_bedtime";


    /**
     * Flag to decouple bluetooth LE Audio Broadcast from Unicast
     * If the flag is true, the broadcast feature will be enabled when the phone
     * is connected to the BLE device.
     * If the flag is false, it is not necessary to connect the BLE device.
     * @hide
     */
    public static final String SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST =
            "settings_need_connected_ble_device_for_broadcast";

    /**
    /**
     * Hide back key in the Settings two pane design.
     * Hide back key in the Settings two pane design.
     * @hide
     * @hide
@@ -110,6 +120,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true");
        DEFAULT_FLAGS.put(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME, "true");
        DEFAULT_FLAGS.put(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME, "true");
        DEFAULT_FLAGS.put(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE, "true");
        DEFAULT_FLAGS.put(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE, "true");
        DEFAULT_FLAGS.put(SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, "true");
    }
    }


    private static final Set<String> PERSISTENT_FLAGS;
    private static final Set<String> PERSISTENT_FLAGS;
+11 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.media.dialog;


import android.content.Context;
import android.content.Context;
import android.os.Bundle;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
import android.view.View;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager;


@@ -99,10 +100,18 @@ public class MediaOutputDialog extends MediaOutputBaseDialog {
    @Override
    @Override
    public boolean isBroadcastSupported() {
    public boolean isBroadcastSupported() {
        boolean isBluetoothLeDevice = false;
        boolean isBluetoothLeDevice = false;
        if (FeatureFlagUtils.isEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)) {
            if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) {
            if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) {
                isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice(
                isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice(
                    mMediaOutputController.getCurrentConnectedMediaDevice());
                    mMediaOutputController.getCurrentConnectedMediaDevice());
            }
            }
        } else {
            // To decouple LE Audio Broadcast and Unicast, it always displays the button when there
            // is no LE Audio device connected to the phone
            isBluetoothLeDevice = true;
        }

        return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice;
        return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice;
    }
    }


+59 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.media.session.PlaybackState;
import android.os.PowerExemptionManager;
import android.os.PowerExemptionManager;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
import android.util.FeatureFlagUtils;
import android.view.View;
import android.view.View;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
@@ -169,6 +170,8 @@ public class MediaOutputDialogTest extends SysuiTestCase {
                mLocalBluetoothLeBroadcast);
                mLocalBluetoothLeBroadcast);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
        when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
        when(mMediaDevice.isBLEDevice()).thenReturn(false);
        when(mMediaDevice.isBLEDevice()).thenReturn(false);


        assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE);
        assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE);
@@ -181,6 +184,62 @@ public class MediaOutputDialogTest extends SysuiTestCase {
        assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE);
        assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE);
    }
    }


    @Test
    public void isBroadcastSupported_flagOnAndConnectBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
        when(mMediaDevice.isBLEDevice()).thenReturn(true);

        assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue();
    }

    @Test
    public void isBroadcastSupported_flagOnAndNoBleDevice_returnsFalse() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
        when(mMediaDevice.isBLEDevice()).thenReturn(false);

        assertThat(mMediaOutputDialog.isBroadcastSupported()).isFalse();
    }

    @Test
    public void isBroadcastSupported_notSupportBroadcastAndflagOn_returnsFalse() {
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);

        assertThat(mMediaOutputDialog.isBroadcastSupported()).isFalse();
    }

    @Test
    public void isBroadcastSupported_flagOffAndConnectToBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false);
        when(mMediaDevice.isBLEDevice()).thenReturn(true);

        assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue();
    }

    @Test
    public void isBroadcastSupported_flagOffAndNoBleDevice_returnsTrue() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
                mLocalBluetoothLeBroadcast);
        when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
        FeatureFlagUtils.setEnabled(mContext,
                FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false);
        when(mMediaDevice.isBLEDevice()).thenReturn(false);

        assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue();
    }

    @Test
    @Test
    public void getBroadcastIconVisibility_isBroadcasting_returnVisible() {
    public void getBroadcastIconVisibility_isBroadcasting_returnVisible() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(