Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +4 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements @Override public void stop() { if (isBroadcastSupported() && mIsLeBroadcastCallbackRegistered) { // unregister broadcast callback should only depend on profile and registered flag // rather than remote device or broadcast state // otherwise it might have risks of leaking registered callback handle if (mMediaOutputController.isBroadcastSupported() && mIsLeBroadcastCallbackRegistered) { mMediaOutputController.unregisterLeBroadcastServiceCallback(mBroadcastCallback); mIsLeBroadcastCallbackRegistered = false; } Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java +7 −1 Original line number Diff line number Diff line Loading @@ -104,11 +104,16 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { @Override public boolean isBroadcastSupported() { boolean isBluetoothLeDevice = false; boolean isBroadcastEnabled = false; if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)) { if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) { isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice( mMediaOutputController.getCurrentConnectedMediaDevice()); // if broadcast is active, broadcast should be considered as supported // there could be a valid case that broadcast is ongoing // without active LEA device connected isBroadcastEnabled = mMediaOutputController.isBluetoothLeBroadcastEnabled(); } } else { // To decouple LE Audio Broadcast and Unicast, it always displays the button when there Loading @@ -116,7 +121,8 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { isBluetoothLeDevice = true; } return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice; return mMediaOutputController.isBroadcastSupported() && (isBluetoothLeDevice || isBroadcastEnabled); } @Override Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,21 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase { verify(mLocalBluetoothLeBroadcast, never()).unregisterServiceCallBack(any()); } @Test public void whenNotBroadcasting_verifyLeBroadcastServiceCallBackIsUnregisteredIfProfileEnabled() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); mIsBroadcasting = true; mMediaOutputBaseDialogImpl.start(); verify(mLocalBluetoothLeBroadcast).registerServiceCallBack(any(), any()); mIsBroadcasting = false; mMediaOutputBaseDialogImpl.stop(); verify(mLocalBluetoothLeBroadcast).unregisterServiceCallBack(any()); } @Test public void refresh_checkStopText() { mStopText = "test_string"; Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,30 @@ public class MediaOutputDialogTest extends SysuiTestCase { assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue(); } @Test public void isBroadcastSupported_noBleDeviceAndEnabledBroadcast_returnsTrue() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(true); FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mMediaDevice.isBLEDevice()).thenReturn(false); assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue(); } @Test public void isBroadcastSupported_noBleDeviceAndDisabledBroadcast_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 getBroadcastIconVisibility_isBroadcasting_returnVisible() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( Loading Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +4 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements @Override public void stop() { if (isBroadcastSupported() && mIsLeBroadcastCallbackRegistered) { // unregister broadcast callback should only depend on profile and registered flag // rather than remote device or broadcast state // otherwise it might have risks of leaking registered callback handle if (mMediaOutputController.isBroadcastSupported() && mIsLeBroadcastCallbackRegistered) { mMediaOutputController.unregisterLeBroadcastServiceCallback(mBroadcastCallback); mIsLeBroadcastCallbackRegistered = false; } Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java +7 −1 Original line number Diff line number Diff line Loading @@ -104,11 +104,16 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { @Override public boolean isBroadcastSupported() { boolean isBluetoothLeDevice = false; boolean isBroadcastEnabled = false; if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST)) { if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) { isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice( mMediaOutputController.getCurrentConnectedMediaDevice()); // if broadcast is active, broadcast should be considered as supported // there could be a valid case that broadcast is ongoing // without active LEA device connected isBroadcastEnabled = mMediaOutputController.isBluetoothLeBroadcastEnabled(); } } else { // To decouple LE Audio Broadcast and Unicast, it always displays the button when there Loading @@ -116,7 +121,8 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { isBluetoothLeDevice = true; } return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice; return mMediaOutputController.isBroadcastSupported() && (isBluetoothLeDevice || isBroadcastEnabled); } @Override Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,21 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase { verify(mLocalBluetoothLeBroadcast, never()).unregisterServiceCallBack(any()); } @Test public void whenNotBroadcasting_verifyLeBroadcastServiceCallBackIsUnregisteredIfProfileEnabled() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); mIsBroadcasting = true; mMediaOutputBaseDialogImpl.start(); verify(mLocalBluetoothLeBroadcast).registerServiceCallBack(any(), any()); mIsBroadcasting = false; mMediaOutputBaseDialogImpl.stop(); verify(mLocalBluetoothLeBroadcast).unregisterServiceCallBack(any()); } @Test public void refresh_checkStopText() { mStopText = "test_string"; Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,30 @@ public class MediaOutputDialogTest extends SysuiTestCase { assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue(); } @Test public void isBroadcastSupported_noBleDeviceAndEnabledBroadcast_returnsTrue() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(true); FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mMediaDevice.isBLEDevice()).thenReturn(false); assertThat(mMediaOutputDialog.isBroadcastSupported()).isTrue(); } @Test public void isBroadcastSupported_noBleDeviceAndDisabledBroadcast_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 getBroadcastIconVisibility_isBroadcasting_returnVisible() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( Loading