Conversation
Summary of ChangesHello @fotiDim, 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 significantly enhances the Android implementation by introducing robust support for Bluetooth Low Energy (BLE) scanning within background services. The core change involves refactoring the 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the Android permission handling to support background services by making the PermissionHandler activity-aware. The changes are well-structured and correctly delegate activity lifecycle events. However, I've identified a couple of edge cases where pending operations (permission requests, Bluetooth enable/disable) are not correctly cancelled when the activity is detached, which could lead to timeouts. I've provided suggestions to make the implementation more robust against activity lifecycle changes.
android/src/main/kotlin/com/navideck/universal_ble/PermissionHandler.kt
Outdated
Show resolved
Hide resolved
android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt
Show resolved
Hide resolved
- Enhanced `PermissionHandler` to be activity-aware, allowing silent success for already granted permissions when no activity is available. - Updated README with best practices for requesting permissions in foreground before background operations.
8704568 to
506f087
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for BLE scanning from background services (such as flutter_foreground_task) on Android by making the PermissionHandler activity-aware. Previously, the PermissionHandler required an Activity to function, which prevented BLE operations in background contexts.
Changes:
- Refactored
PermissionHandlerto support optional activity attachment, enabling it to work in background service contexts - Updated permission request logic to succeed silently when permissions are already granted and no activity is available
- Added comprehensive documentation for background scanning use cases and best practices
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart | Updated comment to document the new Android permission behavior for background contexts |
| android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt | Moved PermissionHandler initialization to onAttachedToEngine and added activity attachment/detachment lifecycle management |
| android/src/main/kotlin/com/navideck/universal_ble/PermissionHandler.kt | Refactored to accept activity as an attachable/detachable reference rather than constructor parameter, with fallback logic for background contexts |
| README.md | Added comprehensive documentation section explaining background scanning support, limitations, and best practices |
| CHANGELOG.md | Added entry describing the new background service support feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.