Loading src/com/android/settings/media/MediaOutputIndicatorWorker.java +7 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,13 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements return mPackageName; } /** Check if this device supports LE Audio Broadcast feature */ public boolean isBroadcastSupported() { LocalBluetoothLeBroadcast broadcast = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); return broadcast != null ? true : false; } public boolean isDeviceBroadcasting() { LocalBluetoothLeBroadcast broadcast = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); Loading src/com/android/settings/notification/MediaVolumePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont @VisibleForTesting boolean isSupportEndItem() { return isConnectedBLEDevice(); return getWorker() != null && getWorker().isBroadcastSupported() && isConnectedBLEDevice(); } private boolean isConnectedBLEDevice() { Loading tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java +31 −2 Original line number Diff line number Diff line Loading @@ -38,11 +38,14 @@ import android.media.session.MediaSessionManager; import android.media.session.PlaybackState; import android.net.Uri; import com.android.settings.bluetooth.Utils; import com.android.settings.slices.ShadowSliceBackgroundWorker; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settings.testutils.shadow.ShadowBluetoothUtils; import com.android.settingslib.bluetooth.BluetoothEventManager; import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.media.LocalMediaManager; import org.junit.Before; Loading @@ -69,13 +72,17 @@ public class MediaOutputIndicatorWorkerTest { @Mock private BluetoothEventManager mBluetoothEventManager; @Mock private LocalBluetoothManager mLocalBluetoothManager; private LocalBluetoothManager mLocalBtManager; @Mock private LocalBluetoothProfileManager mLocalBluetoothProfileManager; @Mock private MediaSessionManager mMediaSessionManager; @Mock private MediaController mMediaController; @Mock private LocalMediaManager mLocalMediaManager; @Mock private LocalBluetoothLeBroadcast mLeAudioBroadcastProfile; private Context mContext; private MediaOutputIndicatorWorker mMediaOutputIndicatorWorker; Loading @@ -84,14 +91,18 @@ public class MediaOutputIndicatorWorkerTest { private List<MediaController> mMediaControllers = new ArrayList<>(); private PlaybackState mPlaybackState; private MediaController.PlaybackInfo mPlaybackInfo; private LocalBluetoothManager mLocalBluetoothManager; @Before public void setUp() { MockitoAnnotations.initMocks(this); mShadowApplication = ShadowApplication.getInstance(); mContext = spy(RuntimeEnvironment.application); ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager; ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager; mLocalBluetoothManager = Utils.getLocalBtManager(mContext); when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager); when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager); when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(null); mMediaOutputIndicatorWorker = new MediaOutputIndicatorWorker(mContext, URI); doReturn(mMediaSessionManager).when(mContext).getSystemService(MediaSessionManager.class); mMediaControllers.add(mMediaController); Loading Loading @@ -284,4 +295,22 @@ public class MediaOutputIndicatorWorkerTest { assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isNull(); } @Test public void isBroadcastSupported_leAudioBroadcastProfileIsNull_returnFalse() { mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; mMediaOutputIndicatorWorker.onSlicePinned(); assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isFalse(); } @Test public void isBroadcastSupported_leAudioBroadcastProfileNotNull_returnTrue() { mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; mMediaOutputIndicatorWorker.onSlicePinned(); when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()) .thenReturn(mLeAudioBroadcastProfile); assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isTrue(); } } tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -113,13 +113,23 @@ public class MediaVolumePreferenceControllerTest { @Test public void isSupportEndItem_withBleDevice_returnsTrue() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isTrue(); } @Test public void isSupportEndItem_notSupportedBroadcast_returnsFalse() { doReturn(false).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isFalse(); } @Test public void isSupportEndItem_withNonBleDevice_returnsFalse() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isFalse(); Loading @@ -127,6 +137,7 @@ public class MediaVolumePreferenceControllerTest { @Test public void getSliceEndItem_NotSupportEndItem_getsNullSliceAction() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); final SliceAction sliceAction = mController.getSliceEndItem(mContext); Loading @@ -136,6 +147,7 @@ public class MediaVolumePreferenceControllerTest { @Test public void getSliceEndItem_deviceIsBroadcasting_getsBroadcastIntent() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting(); doReturn(mMediaController).when(sMediaOutputIndicatorWorker) Loading @@ -155,6 +167,7 @@ public class MediaVolumePreferenceControllerTest { final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class); when(((BluetoothMediaDevice) device).getCachedDevice()).thenReturn(cachedDevice); when(device.isBLEDevice()).thenReturn(true); doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(device).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting(); doReturn(mMediaController).when(sMediaOutputIndicatorWorker) Loading Loading
src/com/android/settings/media/MediaOutputIndicatorWorker.java +7 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,13 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements return mPackageName; } /** Check if this device supports LE Audio Broadcast feature */ public boolean isBroadcastSupported() { LocalBluetoothLeBroadcast broadcast = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); return broadcast != null ? true : false; } public boolean isDeviceBroadcasting() { LocalBluetoothLeBroadcast broadcast = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); Loading
src/com/android/settings/notification/MediaVolumePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont @VisibleForTesting boolean isSupportEndItem() { return isConnectedBLEDevice(); return getWorker() != null && getWorker().isBroadcastSupported() && isConnectedBLEDevice(); } private boolean isConnectedBLEDevice() { Loading
tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java +31 −2 Original line number Diff line number Diff line Loading @@ -38,11 +38,14 @@ import android.media.session.MediaSessionManager; import android.media.session.PlaybackState; import android.net.Uri; import com.android.settings.bluetooth.Utils; import com.android.settings.slices.ShadowSliceBackgroundWorker; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settings.testutils.shadow.ShadowBluetoothUtils; import com.android.settingslib.bluetooth.BluetoothEventManager; import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.media.LocalMediaManager; import org.junit.Before; Loading @@ -69,13 +72,17 @@ public class MediaOutputIndicatorWorkerTest { @Mock private BluetoothEventManager mBluetoothEventManager; @Mock private LocalBluetoothManager mLocalBluetoothManager; private LocalBluetoothManager mLocalBtManager; @Mock private LocalBluetoothProfileManager mLocalBluetoothProfileManager; @Mock private MediaSessionManager mMediaSessionManager; @Mock private MediaController mMediaController; @Mock private LocalMediaManager mLocalMediaManager; @Mock private LocalBluetoothLeBroadcast mLeAudioBroadcastProfile; private Context mContext; private MediaOutputIndicatorWorker mMediaOutputIndicatorWorker; Loading @@ -84,14 +91,18 @@ public class MediaOutputIndicatorWorkerTest { private List<MediaController> mMediaControllers = new ArrayList<>(); private PlaybackState mPlaybackState; private MediaController.PlaybackInfo mPlaybackInfo; private LocalBluetoothManager mLocalBluetoothManager; @Before public void setUp() { MockitoAnnotations.initMocks(this); mShadowApplication = ShadowApplication.getInstance(); mContext = spy(RuntimeEnvironment.application); ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager; ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager; mLocalBluetoothManager = Utils.getLocalBtManager(mContext); when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager); when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager); when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(null); mMediaOutputIndicatorWorker = new MediaOutputIndicatorWorker(mContext, URI); doReturn(mMediaSessionManager).when(mContext).getSystemService(MediaSessionManager.class); mMediaControllers.add(mMediaController); Loading Loading @@ -284,4 +295,22 @@ public class MediaOutputIndicatorWorkerTest { assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isNull(); } @Test public void isBroadcastSupported_leAudioBroadcastProfileIsNull_returnFalse() { mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; mMediaOutputIndicatorWorker.onSlicePinned(); assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isFalse(); } @Test public void isBroadcastSupported_leAudioBroadcastProfileNotNull_returnTrue() { mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; mMediaOutputIndicatorWorker.onSlicePinned(); when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()) .thenReturn(mLeAudioBroadcastProfile); assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isTrue(); } }
tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -113,13 +113,23 @@ public class MediaVolumePreferenceControllerTest { @Test public void isSupportEndItem_withBleDevice_returnsTrue() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isTrue(); } @Test public void isSupportEndItem_notSupportedBroadcast_returnsFalse() { doReturn(false).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isFalse(); } @Test public void isSupportEndItem_withNonBleDevice_returnsFalse() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); assertThat(mController.isSupportEndItem()).isFalse(); Loading @@ -127,6 +137,7 @@ public class MediaVolumePreferenceControllerTest { @Test public void getSliceEndItem_NotSupportEndItem_getsNullSliceAction() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); final SliceAction sliceAction = mController.getSliceEndItem(mContext); Loading @@ -136,6 +147,7 @@ public class MediaVolumePreferenceControllerTest { @Test public void getSliceEndItem_deviceIsBroadcasting_getsBroadcastIntent() { doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting(); doReturn(mMediaController).when(sMediaOutputIndicatorWorker) Loading @@ -155,6 +167,7 @@ public class MediaVolumePreferenceControllerTest { final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class); when(((BluetoothMediaDevice) device).getCachedDevice()).thenReturn(cachedDevice); when(device.isBLEDevice()).thenReturn(true); doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported(); doReturn(device).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice(); doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting(); doReturn(mMediaController).when(sMediaOutputIndicatorWorker) Loading