Add requestConnectionPriority support#221
Conversation
raphael-bmec-co
commented
Mar 20, 2026
- Closes Connection Priority support on Android #220
- Add BleConnectionPriority enum (balanced, highPerformance, lowPower) - Add BleCapabilities.supportsConnectionPriorityApi flag - Implement on Android via BluetoothGatt.requestConnectionPriority() - Throw notSupported on iOS, macOS, Windows, Linux, and Web - Update pigeon definition and regenerate platform channel files - Bump version 1.2.0 -> 1.3.0
…upport Add requestConnectionPriority support
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Universal BLE plugin by adding support for requesting connection priority, a feature primarily beneficial for Android devices. This allows developers to optimize BLE connection intervals for scenarios requiring higher data throughput, such as data-intensive transfers. The change includes a new API, an enum for priority levels, and platform-specific implementations to ensure correct behavior and error handling across different operating systems. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for requestConnectionPriority on Android, enabling developers to adjust BLE connection intervals for performance or power efficiency. The changes are well-implemented across the board, including the native Android code, the Dart API, and stubs for other platforms to ensure consistent behavior. Documentation has also been updated accordingly. I have one suggestion to enhance consistency in how errors are handled for unsupported platforms.
There was a problem hiding this comment.
Pull request overview
Adds a new requestConnectionPriority API to the universal_ble Flutter plugin to let Android apps request BLE connection parameter updates (balanced / highPerformance / lowPower), while providing consistent “not supported” behavior on non-Android platforms and updating docs/versioning.
Changes:
- Introduce
BleConnectionPriorityand exposeUniversalBle.requestConnectionPriority(...)(queued command, capability-gated). - Add platform-channel/Pigeon plumbing and stub implementations returning
notSupportedon non-Android platforms. - Implement Android-side
BluetoothGatt.requestConnectionPriority(...), plus documentation and version/changelog updates.
Reviewed changes
Copilot reviewed 21 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt |
Implements requestConnectionPriority via BluetoothGatt.requestConnectionPriority. |
android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt |
Generated Pigeon interface + message handler wiring for the new method. |
darwin/Classes/UniversalBlePlugin.swift |
Adds Apple-platform stub returning notSupported. |
darwin/Classes/UniversalBle.g.swift |
Generated Pigeon protocol + channel setup for the new method. |
windows/src/universal_ble_plugin.h |
Adds Windows plugin method declaration. |
windows/src/universal_ble_plugin.cpp |
Adds Windows stub returning kNotSupported. |
windows/src/generated/universal_ble.g.h |
Generated interface includes RequestConnectionPriority. |
windows/src/generated/universal_ble.g.cpp |
Generated message handler for requestConnectionPriority. |
lib/src/models/ble_connection_priority.dart |
New Dart enum representing connection priority. |
lib/src/models/model_exports.dart |
Exports ble_connection_priority.dart. |
lib/src/models/ble_capabilities.dart |
Adds supportsConnectionPriorityApi capability flag (Android-only). |
lib/src/universal_ble_platform_interface.dart |
Adds requestConnectionPriority to the platform interface. |
lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart |
Adds Dart-side platform call + capability guard. |
lib/src/universal_ble_pigeon/universal_ble.g.dart |
Generated Dart Pigeon channel method. |
lib/src/universal_ble_linux/universal_ble_linux.dart |
Adds Linux stub throwing notSupported. |
lib/src/universal_ble_web/universal_ble_web.dart |
Adds Web stub throwing notSupported. |
lib/src/universal_ble.dart |
Adds the public UniversalBle.requestConnectionPriority API (queued). |
pigeon/universal_ble.dart |
Adds Pigeon API definition for requestConnectionPriority. |
test/universal_ble_test_mock.dart |
Updates test mock interface to include the new method. |
example/lib/data/mock_universal_ble.dart |
Updates example mock to include the new method. |
README.md |
Documents API support + adds usage section for connection priority. |
CHANGELOG.md |
Adds 1.3.0 entry for the new API. |
pubspec.yaml |
Bumps package version to 1.3.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt
Show resolved
Hide resolved
android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt
Show resolved
Hide resolved
|
@raphael-bmec-co thank you for the PR. Could you please have a look into the AI comments? |
|
@fotiDim , yes sure. Would you mind having a quick look over the AI comments and sanity checking that they are valid and not hallucinations? |
|
@raphael-bmec-co added my comments |
|
Thanks @fotiDim. Our team is working on this as we speak - we'll revert ASAP. |
- 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
Fix requestConnectionPriority implementation
|
@fotiDim The comments above have been addressed. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 24 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.