Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3ef4fc0 authored by Matthew Xie's avatar Matthew Xie
Browse files

Donot bind to GATT service when BLE is not supported

bug 8664724

Change-Id: I9b9222cd5877babcded73798a5d1ff13fd10e791
parent c4ae982d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1472,9 +1472,13 @@ public final class BluetoothAdapter {

            try {
                IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
                if (iGatt == null) {
                    // BLE is not supported
                    return false;
                }

                UUID uuid = UUID.randomUUID();
                GattCallbackWrapper wrapper = new GattCallbackWrapper(this, callback, serviceUuids);

                iGatt.registerClient(new ParcelUuid(uuid), wrapper);
                if (wrapper.scanStarted()) {
                    mLeScanClients.put(callback, wrapper);
+4 −0
Original line number Diff line number Diff line
@@ -1187,6 +1187,10 @@ public final class BluetoothDevice implements Parcelable {
        IBluetoothManager managerService = adapter.getBluetoothManager();
        try {
            IBluetoothGatt iGatt = managerService.getBluetoothGatt();
            if (iGatt == null) {
                // BLE is not supported
                return null;
            }
            BluetoothGatt gatt = new BluetoothGatt(context, iGatt, this);
            gatt.connect(autoConnect, callback);
            return gatt;