mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Penble 2: Fix crash (regression)
This commit is contained in:
+10
-4
@@ -25,6 +25,7 @@ import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCallback;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattDescriptor;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -249,10 +250,15 @@ class PebbleGATTClient extends BluetoothGattCallback {
|
||||
}
|
||||
|
||||
public void readBatteryCharacteristic() {
|
||||
BluetoothGattCharacteristic characteristic = mBluetoothGatt.getService(GattService.UUID_SERVICE_BATTERY_SERVICE).getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL);
|
||||
if (characteristic != null) {
|
||||
mBluetoothGatt.readCharacteristic(characteristic);
|
||||
}
|
||||
BluetoothGattService serivce = mBluetoothGatt.getService(GattService.UUID_SERVICE_BATTERY_SERVICE);
|
||||
if (serivce == null)
|
||||
return;
|
||||
|
||||
BluetoothGattCharacteristic characteristic = serivce.getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL);
|
||||
if (characteristic == null)
|
||||
return;
|
||||
|
||||
mBluetoothGatt.readCharacteristic(characteristic);
|
||||
}
|
||||
|
||||
private void connectToPebble(BluetoothDevice btDevice) {
|
||||
|
||||
Reference in New Issue
Block a user