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

Commit 5252b97d authored by Jack He's avatar Jack He
Browse files

Bluetooth: Add convenience method to convert connection state to string

* Add method to convert the following state values to string
  - BluetoothHeadset.STATE_DISCONNECTED
  - BluetoothHeadset.STATE_CONNECTING
  - BluetoothHeadset.STATE_CONNECTED
  - BluetoothHeadset.STATE_DISCONNECTING

Test: make
Change-Id: Iaa5b6e35d3214ded8edbe29d626e0869651417d1
parent 403c8f72
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -254,4 +254,28 @@ public interface BluetoothProfile {
         */
        public void onServiceDisconnected(int profile);
    }

    /**
     * Convert an integer value of connection state into human readable string
     *
     * @param connectionState - One of {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
     * {@link #STATE_CONNECTED}, or {@link #STATE_DISCONNECTED}
     * @return a string representation of the connection state, STATE_UNKNOWN if the state
     * is not defined
     * @hide
     */
    static String getConnectionStateName(int connectionState) {
        switch (connectionState) {
            case STATE_DISCONNECTED:
                return "STATE_DISCONNECTED";
            case STATE_CONNECTING:
                return "STATE_CONNECTING";
            case STATE_CONNECTED:
                return "STATE_CONNECTED";
            case STATE_DISCONNECTING:
                return "STATE_DISCONNECTING";
            default:
                return "STATE_UNKNOWN";
        }
    }
}