diff options
author | William Escande <wescande@google.com> | 2022-03-15 22:17:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-03-15 22:17:02 +0000 |
commit | 94924dd12bbb15754b6933bbfd62fef4bc042ffe (patch) | |
tree | e47937356888bf3c42f751d9e6f1f7be946b5713 /framework/java | |
parent | 60552deb66410d7a0796bc6bb4b928cac8e6ba82 (diff) | |
parent | 07d9ad0e4f25306f4371698314655d0ee6de2e14 (diff) |
Merge "[API REVIEW] Remove BLE state from AdapterState" into tm-dev
Diffstat (limited to 'framework/java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 01bc1bade2..de3f570d96 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -190,6 +190,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 {} /** @@ -270,14 +280,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,9 +1161,8 @@ public final class BluetoothAdapter { new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission - @AdapterState @Override - public Integer apply(Void query) { + public @InternalAdapterState Integer apply(Void query) { int state = BluetoothAdapter.STATE_OFF; mServiceLock.readLock().lock(); try { @@ -1189,8 +1198,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() { return mBluetoothGetStateCache.query(null); } @@ -1206,8 +1214,7 @@ public final class BluetoothAdapter { */ @RequiresLegacyBluetoothPermission @RequiresNoPermission - @AdapterState - public int getState() { + public @AdapterState int getState() { int state = getStateInternal(); // Consider all internal states as OFF @@ -1243,10 +1250,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) { |