Loading framework/java/android/bluetooth/BluetoothAdapter.java +16 −10 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,16 @@ public final class BluetoothAdapter { STATE_BLE_TURNING_OFF STATE_BLE_TURNING_OFF }) }) @Retention(RetentionPolicy.SOURCE) @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 {} public @interface AdapterState {} /** /** Loading Loading @@ -270,14 +280,14 @@ public final class BluetoothAdapter { public @interface RfcommListenerResult {} public @interface RfcommListenerResult {} /** /** * Human-readable string helper for AdapterState * Human-readable string helper for AdapterState and InternalAdapterState * * * @hide * @hide */ */ @SystemApi @SystemApi @RequiresNoPermission @RequiresNoPermission @NonNull @NonNull public static String nameForState(@AdapterState int state) { public static String nameForState(@InternalAdapterState int state) { switch (state) { switch (state) { case STATE_OFF: case STATE_OFF: return "OFF"; return "OFF"; Loading Loading @@ -1151,9 +1161,8 @@ public final class BluetoothAdapter { new IpcDataCache.QueryHandler<>() { new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState @Override @Override public Integer apply(Void query) { public @InternalAdapterState Integer apply(Void query) { int state = BluetoothAdapter.STATE_OFF; int state = BluetoothAdapter.STATE_OFF; mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { Loading Loading @@ -1189,8 +1198,7 @@ public final class BluetoothAdapter { * Fetch the current bluetooth state. If the service is down, return * Fetch the current bluetooth state. If the service is down, return * OFF. * OFF. */ */ @AdapterState private @InternalAdapterState int getStateInternal() { private int getStateInternal() { return mBluetoothGetStateCache.query(null); return mBluetoothGetStateCache.query(null); } } Loading @@ -1206,8 +1214,7 @@ public final class BluetoothAdapter { */ */ @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState public @AdapterState int getState() { public int getState() { int state = getStateInternal(); int state = getStateInternal(); // Consider all internal states as OFF // Consider all internal states as OFF Loading Loading @@ -1243,10 +1250,9 @@ public final class BluetoothAdapter { */ */ @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine " @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine " + "whether you can use BLE & BT classic.") + "whether you can use BLE & BT classic.") public int getLeState() { public @InternalAdapterState int getLeState() { int state = getStateInternal(); int state = getStateInternal(); if (VDBG) { if (VDBG) { Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +16 −10 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,16 @@ public final class BluetoothAdapter { STATE_BLE_TURNING_OFF STATE_BLE_TURNING_OFF }) }) @Retention(RetentionPolicy.SOURCE) @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 {} public @interface AdapterState {} /** /** Loading Loading @@ -270,14 +280,14 @@ public final class BluetoothAdapter { public @interface RfcommListenerResult {} public @interface RfcommListenerResult {} /** /** * Human-readable string helper for AdapterState * Human-readable string helper for AdapterState and InternalAdapterState * * * @hide * @hide */ */ @SystemApi @SystemApi @RequiresNoPermission @RequiresNoPermission @NonNull @NonNull public static String nameForState(@AdapterState int state) { public static String nameForState(@InternalAdapterState int state) { switch (state) { switch (state) { case STATE_OFF: case STATE_OFF: return "OFF"; return "OFF"; Loading Loading @@ -1151,9 +1161,8 @@ public final class BluetoothAdapter { new IpcDataCache.QueryHandler<>() { new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState @Override @Override public Integer apply(Void query) { public @InternalAdapterState Integer apply(Void query) { int state = BluetoothAdapter.STATE_OFF; int state = BluetoothAdapter.STATE_OFF; mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { Loading Loading @@ -1189,8 +1198,7 @@ public final class BluetoothAdapter { * Fetch the current bluetooth state. If the service is down, return * Fetch the current bluetooth state. If the service is down, return * OFF. * OFF. */ */ @AdapterState private @InternalAdapterState int getStateInternal() { private int getStateInternal() { return mBluetoothGetStateCache.query(null); return mBluetoothGetStateCache.query(null); } } Loading @@ -1206,8 +1214,7 @@ public final class BluetoothAdapter { */ */ @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState public @AdapterState int getState() { public int getState() { int state = getStateInternal(); int state = getStateInternal(); // Consider all internal states as OFF // Consider all internal states as OFF Loading Loading @@ -1243,10 +1250,9 @@ public final class BluetoothAdapter { */ */ @RequiresLegacyBluetoothPermission @RequiresLegacyBluetoothPermission @RequiresNoPermission @RequiresNoPermission @AdapterState @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine " @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine " + "whether you can use BLE & BT classic.") + "whether you can use BLE & BT classic.") public int getLeState() { public @InternalAdapterState int getLeState() { int state = getStateInternal(); int state = getStateInternal(); if (VDBG) { if (VDBG) { Loading