Skip to content
Snippets Groups Projects
Commit 9c5fc5e9 authored by Andreas Schildbach's avatar Andreas Schildbach
Browse files

ScannerFragment: Always show paired card10s, no matter if it's caught in the scan.

That way, we can unpair even if the card10 isn't available any more.
parent 3fd6494c
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,12 @@ class ScannerFragment : Fragment() {
val callback = object : ScanCallback() {
override fun onScanResult(callbackType: Int, result: ScanResult) {
val device = result.device
if (device.address.startsWith(CARD10_BLUETOOTH_MAC_PREFIX, true)) {
if (device.address.startsWith(CARD10_BLUETOOTH_MAC_PREFIX, true))
putToListAdapter(device)
}
}
private fun putToListAdapter(device: BluetoothDevice) {
listAdapter.put(
Device(
btMac = device.address,
......@@ -57,8 +62,6 @@ class ScannerFragment : Fragment() {
)
)
}
}
}
val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
......@@ -71,6 +74,14 @@ class ScannerFragment : Fragment() {
super.onCreate(savedInstanceState)
activity?.registerReceiver(receiver, IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED))
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
for (device in bluetoothAdapter.bondedDevices.filter {
it.address.startsWith(
CARD10_BLUETOOTH_MAC_PREFIX,
true
)
}) {
putToListAdapter(device)
}
bluetoothAdapter.bluetoothLeScanner.startScan(callback)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment