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

Commit 4f768f68 authored by Marie Janssen's avatar Marie Janssen Committed by Andre Eisenbach
Browse files

Move state dumpsys (to BluetoothManagerService)

BluetoothManagerService will dump basic state about Bluetooth now for
standard dumpsys arguments. Move it from here and track which apps enable /
disable Bluetooth.

Test: enable/disable a few times, check that apps are recorded correctly
Bug: 33692282
Change-Id: I7505ba25a5cafda061fa23774cc31a6b83909d34
parent 6621044f
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -2552,28 +2552,6 @@ public class AdapterService extends Service {
        return getResources().getInteger(R.integer.config_bluetooth_operating_voltage_mv) / 1000.0;
    }

    private String getStateString() {
        int state = getState();
        switch (state) {
            case BluetoothAdapter.STATE_OFF:
                return "STATE_OFF";
            case BluetoothAdapter.STATE_TURNING_ON:
                return "STATE_TURNING_ON";
            case BluetoothAdapter.STATE_ON:
                return "STATE_ON";
            case BluetoothAdapter.STATE_TURNING_OFF:
                return "STATE_TURNING_OFF";
            case BluetoothAdapter.STATE_BLE_TURNING_ON:
                return "STATE_BLE_TURNING_ON";
            case BluetoothAdapter.STATE_BLE_ON:
                return "STATE_BLE_ON";
            case BluetoothAdapter.STATE_BLE_TURNING_OFF:
                return "STATE_BLE_TURNING_OFF";
            default:
                return "UNKNOWN STATE: " + state;
        }
    }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
@@ -2591,20 +2569,6 @@ public class AdapterService extends Service {
            }
        }

        long onDuration = System.currentTimeMillis() - mBluetoothStartTime;
        String onDurationString = String.format("%02d:%02d:%02d.%03d",
                                      (int)(onDuration / (1000 * 60 * 60)),
                                      (int)((onDuration / (1000 * 60)) % 60),
                                      (int)((onDuration / 1000) % 60),
                                      (int)(onDuration % 1000));

        writer.println("Bluetooth Status");
        writer.println("  enabled: " + isEnabled());
        writer.println("  state: " + getStateString());
        writer.println("  address: " + getAddress());
        writer.println("  name: " + getName());
        writer.println("  time since enabled: " + onDurationString + "\n");

        writer.println("Bonded devices:");
        for (BluetoothDevice device : getBondedDevices()) {
          writer.println("  " + device.getAddress()