Fix missing scan name on Android#252
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a resolvedDeviceName extension property on ScanResult to resolve the device name from the scan record, falling back to the device name if unavailable, and updates UniversalBlePlugin to use it. The review feedback correctly identifies a potential SecurityException crash on Android 12+ when accessing device.name without the BLUETOOTH_CONNECT permission, and suggests wrapping the call in a try-catch block.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR fixes an Android-only scanning regression where a device’s display name becomes missing (e.g., “N/A”) after a connect/disconnect cycle, by preferring the advertised local name from the scan record over the cached BluetoothDevice.name.
Changes:
- Add
ScanResult.resolvedDeviceNamethat resolves the scan name asscanRecord.deviceName(when non-blank) falling back todevice.name(guarded againstSecurityException). - Update Android scan callback to use the resolved name for both filtering and the emitted
UniversalBleScanResult.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt | Uses result.resolvedDeviceName in onScanResult to emit a stable scan name post-GATT. |
| android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt | Introduces ScanResult.resolvedDeviceName to prioritize advertised name and safely fall back to device.name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bc84768 to
b94a92c
Compare
Fixes #251