Loading android/pandora/server/src/com/android/pandora/Host.kt +10 −1 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ class Host( initiatedConnection.clear() waitedAclConnection.clear() waitedAclDisconnection.clear() bluetoothAdapter.clearBluetooth() Loading @@ -190,6 +191,8 @@ class Host( Log.i(TAG, "reset") initiatedConnection.clear() waitedAclConnection.clear() waitedAclDisconnection.clear() rebootBluetooth() Empty.getDefaultInstance() Loading Loading @@ -311,12 +314,18 @@ class Host( if (!bluetoothAdapter.isEnabled) { throw RuntimeException("Bluetooth is not enabled, cannot waitDisconnection") } if (bluetoothDevice.bondState != BluetoothDevice.BOND_NONE) { if ( bluetoothDevice.bondState != BluetoothDevice.BOND_NONE && !waitedAclDisconnection.contains(bluetoothDevice) ) { flow .filter { it.action == BluetoothDevice.ACTION_ACL_DISCONNECTED } .filter { it.getBluetoothDeviceExtra() == bluetoothDevice } .first() } waitedAclDisconnection.add(bluetoothDevice) Empty.getDefaultInstance() } } Loading android/pandora/server/src/com/android/pandora/Utils.kt +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ private val alphanumeric = ('A'..'Z') + ('a'..'z') + ('0'..'9') val initiatedConnection = HashSet<BluetoothDevice>() val waitedAclConnection = HashSet<BluetoothDevice>() val waitedAclDisconnection = HashSet<BluetoothDevice>() fun shell(cmd: String): String { val fd = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(cmd) Loading @@ -85,9 +86,13 @@ fun intentFlow(context: Context, intentFilter: IntentFilter) = callbackFlow { val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action == BluetoothDevice.ACTION_ACL_CONNECTED) { waitedAclDisconnection.remove(intent.getBluetoothDeviceExtra()) } if (intent.action == BluetoothDevice.ACTION_ACL_DISCONNECTED) { initiatedConnection.remove(intent.getBluetoothDeviceExtra()) waitedAclConnection.remove(intent.getBluetoothDeviceExtra()) waitedAclDisconnection.add(intent.getBluetoothDeviceExtra()) } trySendBlocking(intent) } Loading Loading
android/pandora/server/src/com/android/pandora/Host.kt +10 −1 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ class Host( initiatedConnection.clear() waitedAclConnection.clear() waitedAclDisconnection.clear() bluetoothAdapter.clearBluetooth() Loading @@ -190,6 +191,8 @@ class Host( Log.i(TAG, "reset") initiatedConnection.clear() waitedAclConnection.clear() waitedAclDisconnection.clear() rebootBluetooth() Empty.getDefaultInstance() Loading Loading @@ -311,12 +314,18 @@ class Host( if (!bluetoothAdapter.isEnabled) { throw RuntimeException("Bluetooth is not enabled, cannot waitDisconnection") } if (bluetoothDevice.bondState != BluetoothDevice.BOND_NONE) { if ( bluetoothDevice.bondState != BluetoothDevice.BOND_NONE && !waitedAclDisconnection.contains(bluetoothDevice) ) { flow .filter { it.action == BluetoothDevice.ACTION_ACL_DISCONNECTED } .filter { it.getBluetoothDeviceExtra() == bluetoothDevice } .first() } waitedAclDisconnection.add(bluetoothDevice) Empty.getDefaultInstance() } } Loading
android/pandora/server/src/com/android/pandora/Utils.kt +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ private val alphanumeric = ('A'..'Z') + ('a'..'z') + ('0'..'9') val initiatedConnection = HashSet<BluetoothDevice>() val waitedAclConnection = HashSet<BluetoothDevice>() val waitedAclDisconnection = HashSet<BluetoothDevice>() fun shell(cmd: String): String { val fd = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(cmd) Loading @@ -85,9 +86,13 @@ fun intentFlow(context: Context, intentFilter: IntentFilter) = callbackFlow { val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action == BluetoothDevice.ACTION_ACL_CONNECTED) { waitedAclDisconnection.remove(intent.getBluetoothDeviceExtra()) } if (intent.action == BluetoothDevice.ACTION_ACL_DISCONNECTED) { initiatedConnection.remove(intent.getBluetoothDeviceExtra()) waitedAclConnection.remove(intent.getBluetoothDeviceExtra()) waitedAclDisconnection.add(intent.getBluetoothDeviceExtra()) } trySendBlocking(intent) } Loading