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

Commit 29fb980d authored by Marie Janssen's avatar Marie Janssen
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
(cherry picked from commit b5a03155)
parent 7f3f5e56
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -2417,28 +2417,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);
@@ -2456,20 +2434,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() +