diff options
author | 2025-03-20 15:26:51 -0700 | |
---|---|---|
committer | 2025-03-20 15:26:51 -0700 | |
commit | 0d8713dff209c7f9ba76b160c928569b0c4fcb6f (patch) | |
tree | 3ba7f9e875e0e880561d153c03105114f8cebeb8 | |
parent | dd912b0c93ec9108fac98952ba6f2d3d770a68c8 (diff) | |
parent | 51af1f1d0252f12cefe360037861a75859d667ca (diff) |
Merge "BlockingAdapter: remove STATE_UNKNOWN" into main
-rw-r--r-- | framework/tests/util/src/BlockingBluetoothAdapter.kt | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/framework/tests/util/src/BlockingBluetoothAdapter.kt b/framework/tests/util/src/BlockingBluetoothAdapter.kt index 13ea7aee9b..5d55b80c51 100644 --- a/framework/tests/util/src/BlockingBluetoothAdapter.kt +++ b/framework/tests/util/src/BlockingBluetoothAdapter.kt @@ -145,22 +145,14 @@ object BlockingBluetoothAdapter { Log.e(TAG, "disable: Failed") return false } - // Notify that disable was call. - state.wasDisabled = true return state.waitForStateWithTimeout(stateChangeTimeout, STATE_OFF) } } private class AdapterStateListener(context: Context, private val adapter: BluetoothAdapter) { - private val STATE_UNKNOWN = -42 private val STATE_BLE_TURNING_ON = 14 // BluetoothAdapter.STATE_BLE_TURNING_ON private val STATE_BLE_TURNING_OFF = 16 // BluetoothAdapter.STATE_BLE_TURNING_OFF - // Set to true once a call to disable is made, in order to force the differentiation between the - // various state hidden within STATE_OFF (OFF, BLE_TURNING_ON, BLE_TURNING_OFF) - // Once true, getter will return STATE_OFF when there has not been any callback sent to it - var wasDisabled = false - val adapterStateFlow = callbackFlow<Intent> { val broadcastReceiver = @@ -184,10 +176,8 @@ private class AdapterStateListener(context: Context, private val adapter: Blueto state } else if (adapter.isLeEnabled()) { STATE_BLE_ON - } else if (wasDisabled) { - STATE_OFF } else { - STATE_UNKNOWN + STATE_OFF } } @@ -200,7 +190,6 @@ private class AdapterStateListener(context: Context, private val adapter: Blueto // Cts cannot use BluetoothAdapter.nameForState prior to T, some module test on R private fun nameForState(state: Int): String { return when (state) { - STATE_UNKNOWN -> "UNKNOWN: State is oneOf(OFF, BLE_TURNING_ON, BLE_TURNING_OFF)" STATE_OFF -> "OFF" STATE_TURNING_ON -> "TURNING_ON" STATE_ON -> "ON" |