Skip to content

Fix requestConnectionPriority implementation#2

Merged
aqeel-bmec-co merged 1 commit intomainfrom
main_pull-changes
Mar 30, 2026
Merged

Fix requestConnectionPriority implementation#2
aqeel-bmec-co merged 1 commit intomainfrom
main_pull-changes

Conversation

@aqeel-bmec-co
Copy link
Copy Markdown
Collaborator

🤖 Addresses review comments on Navideck#221

Features/Fixes

  • Remove redundant BleCapabilities.supportsConnectionPriorityApi guard in Dart layer — native implementations already return notSupported, consistent with readRssi pattern.
  • Add BleConnectionPriority Kotlin enum in UniversalBleHelper.kt mirroring the Dart enum, following the same pattern as BleInputProperty and BleOutputProperty.
  • Use explicit when mapping to Android SDK constants (BluetoothGatt.CONNECTION_PRIORITY_*) rather than relying on coincidental index equality.
  • Add firstOrNull with ILLEGAL_ARGUMENT early return for unknown priority values.
  • Add catch (e: Exception) block to handle SecurityException and other runtime exceptions, consistent with setNotifiable, readValue, and pair.
  • Fix enum doc comment — @throws belonged on the calling method, not the enum declaration.
  • Remove stale "Check BleCapabilities.supportsConnectionPriorityApi before calling" guidance from API doc and README.

- Remove redundant BleCapabilities guard in Dart layer (native handles it)
- Add BleConnectionPriority Kotlin enum mirroring Dart enum
- Map to explicit Android SDK constants via when expression
- Add firstOrNull with ILLEGAL_ARGUMENT for unknown priority values
- Add catch (e: Exception) block for broader error handling
- Fix enum doc comment (throws belongs on method, not enum)
- Remove stale capability check guidance from docs and README
@aqeel-bmec-co
Copy link
Copy Markdown
Collaborator Author

🤖 PR Review: #2 Fix requestConnectionPriority implementation

Risk: 4/9 — 🟠 Yellow

Dimension Score Justification
Impact 2 Non-breaking Android BLE API improvement — affects runtime error handling and enum mapping
Likelihood 2 6 files, moderate complexity in Kotlin logic, no new tests

Reviewer: @raphael-bmec-co — PR author of the original requestConnectionPriority implementation. ✅ Assigned.

Review Focus

File Review Reason
android/.../UniversalBlePlugin.kt 🔴 Verify firstOrNull + when mapping to Android SDK constants is correct, and catch (e: Exception) doesn't swallow unexpected errors
android/.../UniversalBleHelper.kt 🟠 Confirm BleConnectionPriority enum values (0/1/2) stay in sync with Dart enum indices
Changed Files
File Type Notes
android/.../UniversalBlePlugin.kt source Enum resolution via firstOrNull, explicit when mapping to SDK constants, added catch (e: Exception)
android/.../UniversalBleHelper.kt source New BleConnectionPriority Kotlin enum mirroring Dart enum
lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart source Removed redundant capability guard, converted to => syntax
lib/src/models/ble_connection_priority.dart source Fixed doc comment — removed @throws from enum
lib/src/universal_ble.dart source Removed stale capability check guidance from doc comment
README.md docs Removed stale "Check BleCapabilities.supportsConnectionPriorityApi" line

@aqeel-bmec-co
Copy link
Copy Markdown
Collaborator Author

aqeel-bmec-co commented Mar 27, 2026

@raphael-bmec-co These changes do affect how the Enum is handled as well as converted. Thus I think we should review/test them

@raphael-bmec-co
Copy link
Copy Markdown

Please update the test up to test as discussed.

@aqeel-bmec-co
Copy link
Copy Markdown
Collaborator Author

@raphael-bmec-co The test app connects and is able to set the priority. Merging

@aqeel-bmec-co aqeel-bmec-co merged commit b76b9d1 into main Mar 30, 2026
@aqeel-bmec-co aqeel-bmec-co deleted the main_pull-changes branch March 30, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants