Click left side of list in "previously connected devices" should connect to the device

* In "previously connected devices", to connect device
* In "Available media devices", to activate device

Bug: 77607104
Test: make -j50 RunSettingsRoboTests
Change-Id: If5005031bd3f5dc4950abf2c77575785cd6f67b1
Merged-In: If5005031bd3f5dc4950abf2c77575785cd6f67b1
This commit is contained in:
timhypeng
2018-04-24 21:45:23 +08:00
committed by tim peng
parent cbf68188ff
commit bafae44cb2
5 changed files with 47 additions and 18 deletions

View File

@@ -24,11 +24,15 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import android.support.v7.preference.Preference;
import android.util.Log;
/**
* Maintain and update saved bluetooth devices(bonded but not connected)
*/
public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater
implements Preference.OnPreferenceClickListener {
private static final String TAG = "SavedBluetoothDeviceUpdater";
public SavedBluetoothDeviceUpdater(Context context, DashboardFragment fragment,
DevicePreferenceCallback devicePreferenceCallback) {
@@ -57,4 +61,12 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
final BluetoothDevice device = cachedDevice.getDevice();
return device.getBondState() == BluetoothDevice.BOND_BONDED && !device.isConnected();
}
@Override
public boolean onPreferenceClick(Preference preference) {
final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference)
.getBluetoothDevice();
device.connect(true);
return true;
}
}