Implement audio switch UI

* Implement available media devices group
* Add AvailableMediaDeviceGroupController to realize UI, the user can see the all device that can be activated in this group.
* ConnectedDeviceGroupController change to show the device that cannot be activated but is connected.
* Refactoring the below class, implement the controller in connected_devices.xml.
  ConnectedDeviceGroupController.java
  SavedDeviceGroupController.java
  ConnectedDeviceDashboardFragment.java
  connected_devices.xml
* Add AvailableMediaBluetoothDeviceUpdaterTest to verify the add/remove preference behavior when connectedStateChanged or profileAudioStateChanged
* Add test that used to verify device is connected or not in BluetoothDeviceUpdaterTest.
* Add test that used to verify the add/remove preference behavior when connectedStateChanged or profileAudioStateChanged in ConnectedBluetoothDeviceUpdaterTest.
* Add AvailableMediaDeviceGroupControllerTest to verify bluetooth feature is supported or not and test register callback.
* Add test that used to verify bluetooth feature is supported or not and test register callback in ConnectedDeviceGroupControllerTest.
* Add test that used to verify bluetooth feature is supported or not and test register callback in SavedDeviceGroupControllerTest

Bug: 74134939
Test: make -j40 RunSettingsRoboTests
Change-Id: I54d03c2ddadc6a4be7519dd74cdbcb5055d44083
This commit is contained in:
hughchen
2018-03-23 16:14:13 +08:00
committed by Hugh Chen
parent 28041fb8cd
commit bd3e5de207
18 changed files with 949 additions and 85 deletions

View File

@@ -48,19 +48,8 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
private ConnectedUsbDeviceUpdater mConnectedUsbDeviceUpdater;
public ConnectedDeviceGroupController(Context context, DashboardFragment fragment,
Lifecycle lifecycle) {
public ConnectedDeviceGroupController(Context context) {
super(context, KEY);
init(lifecycle, new ConnectedBluetoothDeviceUpdater(context, fragment, this),
new ConnectedUsbDeviceUpdater(context, fragment, this));
}
@VisibleForTesting
ConnectedDeviceGroupController(DashboardFragment fragment, Lifecycle lifecycle,
BluetoothDeviceUpdater bluetoothDeviceUpdater,
ConnectedUsbDeviceUpdater connectedUsbDeviceUpdater) {
super(fragment.getContext(), KEY);
init(lifecycle, bluetoothDeviceUpdater, connectedUsbDeviceUpdater);
}
@Override
@@ -116,12 +105,15 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
}
}
private void init(Lifecycle lifecycle, BluetoothDeviceUpdater bluetoothDeviceUpdater,
@VisibleForTesting
public void init(BluetoothDeviceUpdater bluetoothDeviceUpdater,
ConnectedUsbDeviceUpdater connectedUsbDeviceUpdater) {
if (lifecycle != null && isAvailable()) {
lifecycle.addObserver(this);
}
mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
mConnectedUsbDeviceUpdater = connectedUsbDeviceUpdater;
}
public void init(DashboardFragment fragment) {
init(new ConnectedBluetoothDeviceUpdater(fragment.getContext(), fragment, this),
new ConnectedUsbDeviceUpdater(fragment.getContext(), fragment, this));
}
}