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

Commit 2163e39e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[API REVIEW] Remove BLE state from AdapterState" am: 6b001aa0

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2025783

Change-Id: Ibfa847f9aba1639fea2af455d218b90269757596
parents be5cf021 6b001aa0
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -188,6 +188,16 @@ public final class BluetoothAdapter {
            STATE_BLE_TURNING_OFF
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface InternalAdapterState {}

    /** @hide */
    @IntDef(prefix = { "STATE_" }, value = {
            STATE_OFF,
            STATE_TURNING_ON,
            STATE_ON,
            STATE_TURNING_OFF,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AdapterState {}

    /**
@@ -268,14 +278,14 @@ public final class BluetoothAdapter {
    public @interface RfcommListenerResult {}

    /**
     * Human-readable string helper for AdapterState
     * Human-readable string helper for AdapterState and InternalAdapterState
     *
     * @hide
     */
    @SystemApi
    @RequiresNoPermission
    @NonNull
    public static String nameForState(@AdapterState int state) {
    public static String nameForState(@InternalAdapterState int state) {
        switch (state) {
            case STATE_OFF:
                return "OFF";
@@ -1151,8 +1161,7 @@ public final class BluetoothAdapter {
     * Fetch the current bluetooth state.  If the service is down, return
     * OFF.
     */
    @AdapterState
    private int getStateInternal() {
    private @InternalAdapterState int getStateInternal() {
        int state = BluetoothAdapter.STATE_OFF;
        try {
            mServiceLock.readLock().lock();
@@ -1183,8 +1192,7 @@ public final class BluetoothAdapter {
     */
    @RequiresLegacyBluetoothPermission
    @RequiresNoPermission
    @AdapterState
    public int getState() {
    public @AdapterState int getState() {
        int state = getStateInternal();

        // Consider all internal states as OFF
@@ -1220,10 +1228,9 @@ public final class BluetoothAdapter {
     */
    @RequiresLegacyBluetoothPermission
    @RequiresNoPermission
    @AdapterState
    @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine "
            + "whether you can use BLE & BT classic.")
    public int getLeState() {
    public @InternalAdapterState int getLeState() {
        int state = getStateInternal();

        if (VDBG) {