Listed order on "previously connected" depend on recently connected devices

This CL use Bluetooth api "getMostRecentlyConnectedDevices()" to get
recently connected devices list. Let "previously connected" will list
most recently connected device on the top.

Bug: 130984590
Test: make -j42 RunSettingsRoboTests
Change-Id: I8d425b6da6cb9fe9fd1417937b4cb9a052cd1660
This commit is contained in:
hughchen
2020-02-03 13:59:06 +08:00
parent 07c1cdb77e
commit 043e43f059
3 changed files with 35 additions and 2 deletions

View File

@@ -232,12 +232,21 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
* Add the {@link Preference} that represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice) {
addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
}
/**
* Add the {@link Preference} with {@link BluetoothDevicePreference.SortType} that
* represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice,
@BluetoothDevicePreference.SortType int type) {
final BluetoothDevice device = cachedDevice.getDevice();
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
true /* showDeviceWithoutNames */,
BluetoothDevicePreference.SortType.TYPE_DEFAULT);
type);
btPreference.setKey(getPreferenceKey());
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {