Merge "When only one device is selected in dynamic group, the device should be disabled" into rvc-dev am: 8d2c8f1f33
Change-Id: I4403bc7f8b208a62751c37edd081c3230c225d3a
This commit is contained in:
@@ -174,6 +174,15 @@ public class MediaDeviceUpdateWorker extends SliceBackgroundWorker
|
||||
return mLocalMediaManager.getSelectedMediaDevice();
|
||||
}
|
||||
|
||||
boolean isSelectedMediaDevice(MediaDevice device) {
|
||||
for (MediaDevice selectedMediaDevice : getSelectedMediaDevice()) {
|
||||
if (TextUtils.equals(selectedMediaDevice.getId(), device.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void adjustSessionVolume(String sessionId, int volume) {
|
||||
mLocalMediaManager.adjustSessionVolume(sessionId, volume);
|
||||
}
|
||||
|
@@ -236,7 +236,7 @@ public class MediaOutputGroupSlice implements CustomSliceable {
|
||||
+ ") is unavailable");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.equals(device.getClientPackageName(), getWorker().getPackageName())) {
|
||||
if (getWorker().isSelectedMediaDevice(device)) {
|
||||
getWorker().removeDeviceFromPlayMedia(device);
|
||||
} else {
|
||||
getWorker().addDeviceToPlayMedia(device);
|
||||
|
@@ -212,11 +212,9 @@ public class MediaOutputGroupSliceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNotifyChange_sessionOperation_differentClient_verifyAddSession() {
|
||||
mSelectableDevices.add(mDevice1);
|
||||
public void onNotifyChange_sendSelectableDevice_verifyAddSession() {
|
||||
mSelectableDevices.add(mDevice2);
|
||||
mSelectedDevices.add(mDevice1);
|
||||
when(mDevice2.getClientPackageName()).thenReturn(TEST_PACKAGE_NAME2);
|
||||
when(mLocalMediaManager.getMediaDeviceById(mSelectableDevices, TEST_DEVICE_2_ID))
|
||||
.thenReturn(mDevice2);
|
||||
sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectableDevices);
|
||||
@@ -229,16 +227,13 @@ public class MediaOutputGroupSliceTest {
|
||||
|
||||
verify(sMediaDeviceUpdateWorker).addDeviceToPlayMedia(mDevice2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNotifyChange_sessionOperation_sameClient_verifyRemoveSession() {
|
||||
mSelectableDevices.add(mDevice1);
|
||||
mSelectableDevices.add(mDevice2);
|
||||
public void onNotifyChange_sendSelectedDevice_verifyRemoveSession() {
|
||||
mSelectedDevices.add(mDevice1);
|
||||
when(mDevice2.getClientPackageName()).thenReturn(TEST_PACKAGE_NAME);
|
||||
when(mLocalMediaManager.getMediaDeviceById(mSelectableDevices, TEST_DEVICE_2_ID))
|
||||
mSelectedDevices.add(mDevice2);
|
||||
when(mLocalMediaManager.getMediaDeviceById(mSelectedDevices, TEST_DEVICE_2_ID))
|
||||
.thenReturn(mDevice2);
|
||||
sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectableDevices);
|
||||
sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectedDevices);
|
||||
when(sMediaDeviceUpdateWorker.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(MEDIA_DEVICE_ID, TEST_DEVICE_2_ID);
|
||||
|
Reference in New Issue
Block a user