No feedback when attempting to transfer to an unpowered BT device
-Set title and subtitle when connecting state changes -Add test cases Bug: 152606143 Test: make -j42 RunSettingsRoboTests Change-Id: I1c482e8f45752d658d7898de760594fd3ec7164d
This commit is contained in:
@@ -197,6 +197,8 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
}
|
}
|
||||||
listBuilder.addInputRange(builder);
|
listBuilder.addInputRange(builder);
|
||||||
} else {
|
} else {
|
||||||
|
Log.d(TAG, "addRow device = " + device.getName() + " MaxVolume = "
|
||||||
|
+ device.getMaxVolume());
|
||||||
final ListBuilder.RowBuilder builder = getMediaDeviceRow(device);
|
final ListBuilder.RowBuilder builder = getMediaDeviceRow(device);
|
||||||
// Check end item visibility
|
// Check end item visibility
|
||||||
if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE
|
if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE
|
||||||
@@ -266,16 +268,24 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
|
|
||||||
if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE
|
if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE
|
||||||
&& !device.isConnected()) {
|
&& !device.isConnected()) {
|
||||||
// Append status to title only for the disconnected Bluetooth device.
|
if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
|
||||||
final SpannableString spannableTitle = new SpannableString(
|
rowBuilder.setTitle(deviceName);
|
||||||
mContext.getString(R.string.media_output_disconnected_status, deviceName));
|
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
||||||
spannableTitle.setSpan(new ForegroundColorSpan(
|
ListBuilder.ICON_IMAGE, deviceName));
|
||||||
Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary)),
|
rowBuilder.setSubtitle(mContext.getText(R.string.media_output_switching));
|
||||||
deviceName.length(),
|
} else {
|
||||||
spannableTitle.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
|
// Append status to title only for the disconnected Bluetooth device.
|
||||||
rowBuilder.setTitle(spannableTitle);
|
final SpannableString spannableTitle = new SpannableString(
|
||||||
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
mContext.getString(R.string.media_output_disconnected_status, deviceName));
|
||||||
ListBuilder.ICON_IMAGE, spannableTitle));
|
spannableTitle.setSpan(new ForegroundColorSpan(
|
||||||
|
Utils.getColorAttrDefaultColor(mContext,
|
||||||
|
android.R.attr.textColorSecondary)),
|
||||||
|
deviceName.length(),
|
||||||
|
spannableTitle.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
rowBuilder.setTitle(spannableTitle);
|
||||||
|
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
||||||
|
ListBuilder.ICON_IMAGE, spannableTitle));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rowBuilder.setTitle(deviceName);
|
rowBuilder.setTitle(deviceName);
|
||||||
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
||||||
|
@@ -473,6 +473,43 @@ public class MediaOutputSliceTest {
|
|||||||
R.string.bluetooth_pairing_pref_title))).isEqualTo(-1);
|
R.string.bluetooth_pairing_pref_title))).isEqualTo(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSlice_disconnectedBtOnTransferring_containTransferringSubtitle() {
|
||||||
|
final List<MediaDevice> mSelectedDevices = new ArrayList<>();
|
||||||
|
final List<MediaDevice> mSelectableDevices = new ArrayList<>();
|
||||||
|
mDevices.clear();
|
||||||
|
final MediaDevice device = mock(MediaDevice.class);
|
||||||
|
when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
|
||||||
|
when(device.getIcon()).thenReturn(mTestDrawable);
|
||||||
|
when(device.getMaxVolume()).thenReturn(100);
|
||||||
|
when(device.isConnected()).thenReturn(true);
|
||||||
|
when(device.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE);
|
||||||
|
when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
|
||||||
|
final MediaDevice device2 = mock(MediaDevice.class);
|
||||||
|
when(device2.getName()).thenReturn(TEST_DEVICE_2_NAME);
|
||||||
|
when(device2.getIcon()).thenReturn(mTestDrawable);
|
||||||
|
when(device2.getMaxVolume()).thenReturn(100);
|
||||||
|
when(device2.isConnected()).thenReturn(false);
|
||||||
|
when(device2.getState()).thenReturn(LocalMediaManager.MediaDeviceState.STATE_CONNECTING);
|
||||||
|
when(device2.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE);
|
||||||
|
when(device2.getId()).thenReturn(TEST_DEVICE_2_ID);
|
||||||
|
mSelectedDevices.add(device);
|
||||||
|
mSelectableDevices.add(device2);
|
||||||
|
when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
|
||||||
|
mDevices.add(device);
|
||||||
|
mDevices.add(device2);
|
||||||
|
when(mLocalMediaManager.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
|
||||||
|
when(mLocalMediaManager.getSelectableMediaDevice()).thenReturn(mSelectableDevices);
|
||||||
|
mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
|
||||||
|
|
||||||
|
final Slice mediaSlice = mMediaOutputSlice.getSlice();
|
||||||
|
final String sliceInfo = SliceQuery.findAll(mediaSlice, FORMAT_SLICE, HINT_LIST_ITEM,
|
||||||
|
null).toString();
|
||||||
|
|
||||||
|
assertThat(TextUtils.indexOf(sliceInfo, mContext.getText(R.string.media_output_switching)))
|
||||||
|
.isNotEqualTo(-1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onNotifyChange_foundMediaDevice_connect() {
|
public void onNotifyChange_foundMediaDevice_connect() {
|
||||||
mDevices.clear();
|
mDevices.clear();
|
||||||
|
Reference in New Issue
Block a user