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

Commit e49fbffd authored by Sal Savage's avatar Sal Savage
Browse files

Log class of device more robustly

This change adds the current class of device to the bonded devices
section of dumpsys. It also adds a "device=" field to several existing
log lines so associating class of device changes with a particular
device is easier.

Bug: 311456944
Flag: EXEMPT, logging only change
Test: m com.android.btservices
Change-Id: Ib4baf3d5f8f756d4e664bde4b278d3c19aca8fff
parent 4e15c37c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -219,7 +219,8 @@ static void remote_device_properties_callback(bt_status_t status,
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;

  log::verbose("Status is: {}, Properties: {}", bt_status_text(status),
  log::verbose("Device: {}, Status: {}, Properties: {}",
               ADDRESS_TO_LOGGABLE_STR(*bd_addr), bt_status_text(status),
               num_properties);

  if (status != BT_STATUS_SUCCESS) {
+14 −4
Original line number Diff line number Diff line
@@ -1254,13 +1254,21 @@ class AdapterProperties {
        StringBuilder sb = new StringBuilder();
        for (BluetoothDevice device : mBondedDevices) {
            String address = device.getAddress();
            BluetoothClass cod = device.getBluetoothClass();
            int codInt = cod != null ? cod.getClassOfDevice() : 0;
            String brEdrAddress =
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device)
                            : mService.getIdentityAddress(address);
            if (brEdrAddress.equals(address)) {
                writer.println("    " + address
                            + " [" + dumpDeviceType(device.getType()) + "] "
                writer.println(
                        "    "
                                + address
                                + " ["
                                + dumpDeviceType(device.getType())
                                + "][ 0x"
                                + String.format("%06X", codInt)
                                + " ] "
                                + Utils.getName(device));
            } else {
                sb.append(
@@ -1270,6 +1278,8 @@ class AdapterProperties {
                                + brEdrAddress
                                + " ["
                                + dumpDeviceType(device.getType())
                                + "][ 0x"
                                + String.format("%06X", codInt)
                                + " ] "
                                + Utils.getName(device)
                                + "\n");
+12 −4
Original line number Diff line number Diff line
@@ -861,7 +861,7 @@ public class RemoteDevices {
        BluetoothDevice bdDevice = getDevice(address);
        DeviceProperties deviceProperties;
        if (bdDevice == null) {
            debugLog("Added new device property");
            debugLog("Added new device property, device=" + bdDevice);
            deviceProperties = addDeviceProperties(address);
            bdDevice = getDevice(address);
        } else {
@@ -878,7 +878,7 @@ public class RemoteDevices {
            val = values[j];
            if (val.length > 0) {
                synchronized (mObject) {
                    debugLog("Property type: " + type);
                    debugLog("Update property, device=" + bdDevice + ", type: " + type);
                    switch (type) {
                        case AbstractionLayer.BT_PROPERTY_BDNAME:
                            final String newName = new String(val);
@@ -910,7 +910,11 @@ public class RemoteDevices {
                        case AbstractionLayer.BT_PROPERTY_CLASS_OF_DEVICE:
                            final int newBluetoothClass = Utils.byteArrayToInt(val);
                            if (newBluetoothClass == deviceProperties.getBluetoothClass()) {
                                debugLog("Skip class update for " + bdDevice);
                                debugLog(
                                        "Skip class update, device="
                                                + bdDevice
                                                + ", cod=0x"
                                                + Integer.toHexString(newBluetoothClass));
                                break;
                            }
                            deviceProperties.setBluetoothClass(newBluetoothClass);
@@ -923,7 +927,11 @@ public class RemoteDevices {
                                    intent,
                                    BLUETOOTH_CONNECT,
                                    Utils.getTempBroadcastOptions().toBundle());
                            debugLog("Remote class is:" + newBluetoothClass);
                            debugLog(
                                    "Remote class update, device="
                                            + bdDevice
                                            + ", cod=0x"
                                            + Integer.toHexString(newBluetoothClass));
                            break;
                        case AbstractionLayer.BT_PROPERTY_UUIDS:
                            final ParcelUuid[] newUuids = Utils.byteArrayToUuid(val);