-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Add permission check if android bluetooth is on ( kids-1278 ) #1136
Bugfix: Add permission check if android bluetooth is on ( kids-1278 ) #1136
Conversation
WalkthroughThe changes in this pull request primarily focus on enhancing the Changes
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
lib/features/give/pages/bt_scan_page.dart (1)
Line range hint
27-28
: Swap variable names for clarity.The variables
adapterStateStream
andscanResultsStream
appear to be misnamed.adapterStateStream
is subscribing toscanResults
, andscanResultsStream
is subscribing toadapterState
. Swapping the variable names would improve code readability and reduce confusion.Apply this diff to correct the variable names:
-StreamSubscription<List<ScanResult>>? adapterStateStream; -StreamSubscription<BluetoothAdapterState>? scanResultsStream; +StreamSubscription<List<ScanResult>>? scanResultsStream; +StreamSubscription<BluetoothAdapterState>? adapterStateStream; ... -// Set listen method for scan results -adapterStateStream = FlutterBluePlus.scanResults.listen( +// Set listen method for scan results +scanResultsStream = FlutterBluePlus.scanResults.listen( ... -// Listen to scan mode changes -scanResultsStream = FlutterBluePlus.adapterState +// Listen to adapter state changes +adapterStateStream = FlutterBluePlus.adapterState
Core issue is that if the android device has bluetooth turned on but permissions declined the BluetoothAdapterState returns .on instead of the expected .unauthorized like on iOS. So it would attempt to startBluetoothScan -> FlutterBluePlus.startScan but get stuck in a loop failing and restarting the attempt.
Solution: Check for permissions if it is an Android device before attempting to start scanning.
Summary by CodeRabbit
New Features
Bug Fixes