Add preference group for saved devcies.

Currently it only contains bluetooth devices.

Bug: 3240835
Test: RunSettingsRoboTests
Change-Id: Ief102e7174a4c4610dbda6b728419b303ff928f9
This commit is contained in:
jackqdyulei
2017-11-21 10:44:21 -08:00
parent d5fff3645a
commit aec5543841
8 changed files with 299 additions and 16 deletions

View File

@@ -148,10 +148,23 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback {
mPrefContext = context;
}
/**
* Return {@code true} if {@code cachedBluetoothDevice} matches this
* {@link BluetoothDeviceUpdater} and should stay in the list, otherwise return {@code false}
*/
public abstract boolean isFilterMatched(CachedBluetoothDevice cachedBluetoothDevice);
/**
* Update whether to show {@cde cachedBluetoothDevice} in the list.
*/
abstract public void update(CachedBluetoothDevice cachedBluetoothDevice);
protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
if (isFilterMatched(cachedBluetoothDevice)) {
// Add the preference if it is new one
addPreference(cachedBluetoothDevice);
} else {
removePreference(cachedBluetoothDevice);
}
}
/**
* Add the {@link Preference} that represents the {@code cachedDevice}