Update output switch UI

This CL include following update:

1. Add onDeviceAttributesChanged() callback to update UI
   when device attributes are changed.
2. Fix the top device when user press device to transfer.
3. Update UI when device is on goning call state and receive
   STREAM_DEVICES_CHANGED_ACTION intent.

Bug: 144535188
Test: make -j42 RunSettingsRoboTests
Change-Id: Idd5fb95054db30f8184faf4f6ab75d0b550907a1
This commit is contained in:
hughchen
2020-01-08 19:38:40 +08:00
parent d0811849ec
commit c770c9133a
4 changed files with 71 additions and 11 deletions

View File

@@ -61,7 +61,7 @@ public class MediaOutputSlice implements CustomSliceable {
}
@VisibleForTesting
void init(String packageName, MediaDeviceUpdateWorker worker) {
void init(MediaDeviceUpdateWorker worker) {
mWorker = worker;
}
@@ -79,15 +79,20 @@ public class MediaOutputSlice implements CustomSliceable {
}
final List<MediaDevice> devices = getMediaDevices();
final MediaDeviceUpdateWorker worker = getWorker();
final MediaDevice connectedDevice = worker.getCurrentConnectedMediaDevice();
final boolean isTouched = worker.getIsTouched();
// Fix the last top device when user press device to transfer.
final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice;
final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
if (connectedDevice != null) {
listBuilder.addRow(getActiveDeviceHeaderRow(connectedDevice));
if (topDevice != null) {
listBuilder.addRow(getActiveDeviceHeaderRow(topDevice));
worker.setTopDevice(topDevice);
}
for (MediaDevice device : devices) {
if (connectedDevice == null
|| !TextUtils.equals(connectedDevice.getId(), device.getId())) {
if (topDevice == null
|| !TextUtils.equals(topDevice.getId(), device.getId())) {
listBuilder.addRow(getMediaDeviceRow(device));
}
}
@@ -173,6 +178,7 @@ public class MediaOutputSlice implements CustomSliceable {
final MediaDevice device = worker.getMediaDeviceById(id);
if (device != null) {
Log.d(TAG, "onNotifyChange() device name : " + device.getName());
worker.setIsTouched(true);
worker.connectDevice(device);
}
}