Make HearingAid code more generic

-handle UI updating when sub device connection state changes
-add test case

Bug: 112735753
Test: make -j42 RunSettingsRoboTests
Change-Id: Ie2643657c47a0956aac3f8cac4bfdbdea0399ce8
This commit is contained in:
timhypeng
2018-10-09 11:19:23 +08:00
committed by Hugh Chen
parent 2f5200ea5a
commit c95056d7b5
5 changed files with 36 additions and 7 deletions

View File

@@ -230,9 +230,19 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
*/
protected void removePreference(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
final CachedBluetoothDevice subCachedDevice = cachedDevice.getSubDevice();
if (mPreferenceMap.containsKey(device)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(device));
mPreferenceMap.remove(device);
} else if (subCachedDevice != null) {
// When doing remove, to check if preference maps to sub device.
// This would happen when connection state is changed in detail page that there is no
// callback from SettingsLib.
final BluetoothDevice subDevice = subCachedDevice.getDevice();
if (mPreferenceMap.containsKey(subDevice)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(subDevice));
mPreferenceMap.remove(subDevice);
}
}
}