Fix BTHS is still in pairing list after BTHS is connected
This CL uses onProfileConnectionStateChanged() to handle the case that bonded device is connected in pairing list. 1. Finish BluetoothPairingDetail page if the bonded device is connected and selected. 2. Remove the devices in BluetoothPairingDetail page if the device is connected. Bug: 142519901 Test: make -j42 RunSettingsRoboTests Change-Id: I51a9f2ebc0b491edb8ea026ff62ec20ae91eee1d
This commit is contained in:
@@ -29,9 +29,9 @@ import android.widget.Toast;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/**
|
||||
@@ -191,12 +191,19 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
|
||||
if (mSelectedDevice != null) {
|
||||
BluetoothDevice device = cachedDevice.getDevice();
|
||||
if (device != null && mSelectedDevice.equals(device)
|
||||
&& state == BluetoothAdapter.STATE_CONNECTED) {
|
||||
public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
|
||||
int bluetoothProfile) {
|
||||
// This callback is used to handle the case that bonded device is connected in pairing list.
|
||||
// 1. If user selected multiple bonded devices in pairing list, after connected
|
||||
// finish this page.
|
||||
// 2. If the bonded devices auto connected in paring list, after connected it will be
|
||||
// removed from paring list.
|
||||
if (cachedDevice != null && cachedDevice.isConnected()) {
|
||||
final BluetoothDevice device = cachedDevice.getDevice();
|
||||
if (device != null && mSelectedList.contains(device)) {
|
||||
finish();
|
||||
} else if (mDevicePreferenceMap.containsKey(cachedDevice)) {
|
||||
onDeviceDeleted(cachedDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user