Merge "New hearing device pairing page: check gatt status" into main
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static android.bluetooth.BluetoothGatt.GATT_SUCCESS;
|
||||||
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
@@ -461,24 +462,33 @@ public class HearingDevicePairingFragment extends RestrictedDashboardFragment im
|
|||||||
Log.d(TAG, "onConnectionStateChange, status: " + status + ", newState: "
|
Log.d(TAG, "onConnectionStateChange, status: " + status + ", newState: "
|
||||||
+ newState + ", device: " + cachedDevice);
|
+ newState + ", device: " + cachedDevice);
|
||||||
}
|
}
|
||||||
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
if (status == GATT_SUCCESS
|
||||||
|
&& newState == BluetoothProfile.STATE_CONNECTED) {
|
||||||
gatt.discoverServices();
|
gatt.discoverServices();
|
||||||
|
} else {
|
||||||
|
gatt.disconnect();
|
||||||
|
mConnectingGattList.remove(gatt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
||||||
super.onServicesDiscovered(gatt, status);
|
super.onServicesDiscovered(gatt, status);
|
||||||
boolean isCompatible = gatt.getService(BluetoothUuid.HEARING_AID.getUuid())
|
|
||||||
!= null
|
|
||||||
|| gatt.getService(BluetoothUuid.HAS.getUuid()) != null;
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG,
|
Log.d(TAG, "onServicesDiscovered, status: " + status + ", device: "
|
||||||
"onServicesDiscovered, compatible with Android: " + isCompatible
|
+ cachedDevice);
|
||||||
+ ", device: " + cachedDevice);
|
|
||||||
}
|
}
|
||||||
if (isCompatible) {
|
if (status == GATT_SUCCESS) {
|
||||||
addDevice(cachedDevice);
|
if (gatt.getService(BluetoothUuid.HEARING_AID.getUuid()) != null
|
||||||
|
|| gatt.getService(BluetoothUuid.HAS.getUuid()) != null) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "compatible with Android, device: " + cachedDevice);
|
||||||
|
}
|
||||||
|
addDevice(cachedDevice);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gatt.disconnect();
|
||||||
|
mConnectingGattList.remove(gatt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user