BleNamesResolver: add BluetoothProfile#STATE_... lookup

This commit is contained in:
Thomas Kuehne
2025-05-13 20:39:40 +02:00
parent 616e8977c6
commit e1de7efa55
2 changed files with 19 additions and 1 deletions
@@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.btle;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothProfile;
import android.util.SparseArray;
import java.util.HashMap;
@@ -74,6 +75,23 @@ public class BleNamesResolver {
return mCharacteristics.containsKey(uuid);
}
/// lookup description for numeric BluetoothProfile.STATE_...
static public String getStateString(int state) {
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return "STATE_DISCONNECTED";
case BluetoothProfile.STATE_CONNECTING:
return "STATE_CONNECTING";
case BluetoothProfile.STATE_CONNECTED:
return "STATE_CONNECTED";
case BluetoothProfile.STATE_DISCONNECTING:
return "STATE_DISCONNECTING";
default:
return "state_" + state;
}
}
/// lookup description for numeric BluetoothDevice.BOND_...
static public String getBondStateString(int state) {
switch (state) {
case BluetoothDevice.BOND_NONE:
@@ -514,7 +514,7 @@ public final class BtLEQueue {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
LOG.debug("connection state change, newState: {} {}", newState, BleNamesResolver.getStatusString(status));
LOG.debug("connection state change, newState: {} {}", BleNamesResolver.getStateString(newState), BleNamesResolver.getStatusString(status));
synchronized (mGattMonitor) {
if (mBluetoothGatt == null) {