Modern Apps git

← Modern-Apps.git

findfamily: connect to the tracker with its random address type

Commit
f43f56fb56fc34cd3308ab057d5f6c2757da614d
Author
vayun-mathur <[email protected]>
When
2026-08-22 02:39 UTC (3 months ago)
Parents
bb0a5f6

Diff

findfamily/src/main/java/com/vayunmathur/findfamily/tracker/TrackerUwbGatt.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/tracker/TrackerUwbGatt.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/tracker/TrackerUwbGatt.ktindex 9161a75fda..24059e7933 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/tracker/TrackerUwbGatt.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/tracker/TrackerUwbGatt.kt@@ -120,10 +120,21 @@ object TrackerUwbGatt {         value: ByteArray,     ): Boolean = suspendCancellableCoroutine { cont ->         val manager = context.getSystemService(Context.BLUETOOTH_SERVICE) as? BluetoothManager+        val adapter = manager?.adapter         val device = try {-            manager?.adapter?.getRemoteDevice(bleAddress)+            /*+             * getRemoteLeDevice with an explicit RANDOM address type, not getRemoteDevice.+             *+             * The tracker advertises a Zephyr static random identity address, and+             * getRemoteDevice(String) assumes ADDRESS_TYPE_PUBLIC — connecting with the+             * wrong type never reaches the peer and fails with GATT status 147 after a+             * 30-second timeout. Binding is unaffected because TrackerProvisioner gets its+             * BluetoothDevice from a ScanResult, which already carries the right type; this+             * is the only path that rebuilds a device from a stored address string.+             */+            adapter?.getRemoteLeDevice(bleAddress, BluetoothDevice.ADDRESS_TYPE_RANDOM)         } catch (e: Exception) {-            Log.w(TAG, "getRemoteDevice($bleAddress) failed", e); null+            Log.w(TAG, "getRemoteLeDevice($bleAddress) failed", e); null         }         if (device == null) { cont.resume(false); return@suspendCancellableCoroutine }