diff options
| author | 2023-02-09 16:11:31 +0000 | |
|---|---|---|
| committer | 2023-02-09 16:11:31 +0000 | |
| commit | 1dee1633f3f64c4de1d200356d2440cd6cd69022 (patch) | |
| tree | c5d59dcfd4c5c2db1d68c0db3c55fc4e279d50f7 | |
| parent | 4e40afb186c0b944ca808fae1b5b5e66e43fc615 (diff) | |
| parent | 9b4f3067f2a4d7b0e933be1dbb18e451d8473706 (diff) | |
Merge "[LE Audio] Add feature flag to decouple Broadcast from Unicast" am: a71abc1388 am: 9b4f3067f2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2419060
Change-Id: Ic8f708c59fb13e45e7e1e8c42774cdeef65cc7ff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
3 files changed, 81 insertions, 2 deletions
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index c218a0ba2f49..754178abeeaf 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -77,6 +77,16 @@ public class FeatureFlagUtils { "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 */ @@ -110,6 +120,7 @@ public class FeatureFlagUtils { 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_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; diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java index fbd0079f8dc0..a174b459272f 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java @@ -18,6 +18,7 @@ package com.android.systemui.media.dialog; import android.content.Context; import android.os.Bundle; +import android.util.FeatureFlagUtils; import android.view.View; import android.view.WindowManager; @@ -99,10 +100,18 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { @Override public boolean isBroadcastSupported() { boolean isBluetoothLeDevice = false; - if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) { - isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice( + if (FeatureFlagUtils.isEnabled(mContext, + FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)) { + if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) { + isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice( 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; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java index 31866a8df7e5..9ecc63ca9232 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java @@ -36,6 +36,7 @@ import android.media.session.PlaybackState; import android.os.PowerExemptionManager; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; +import android.util.FeatureFlagUtils; import android.view.View; import androidx.test.filters.SmallTest; @@ -171,6 +172,8 @@ public class MediaOutputDialogTest extends SysuiTestCase { mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false); when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING); + FeatureFlagUtils.setEnabled(mContext, + FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mMediaDevice.isBLEDevice()).thenReturn(false); assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE); @@ -184,6 +187,62 @@ public class MediaOutputDialogTest extends SysuiTestCase { } @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 public void getBroadcastIconVisibility_isBroadcasting_returnVisible() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); |