Comments (11)
I prefer not to ask my users for fine location on android 12 so as long as this is forced in 1.5.2, I forked and
changed AndroidManifest.xml to:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.boskokg.flutter_blue_plus">
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
</manifest>
and changed FlutterBluePlusPlugin.java in the scan code to omit the check of fine location for type "s" like this:
case "startScan":
{
ensurePermissionBeforeAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? Manifest.permission.BLUETOOTH_SCAN : Manifest.permission.ACCESS_FINE_LOCATION, (grantedScan, permissionScan) -> {
if (grantedScan) {
ensurePermissionBeforeAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? Manifest.permission.BLUETOOTH_CONNECT : null, (grantedConnect, permissionConnect) -> {
if (grantedConnect)
startScan(call, result);
else
result.error(
"no_permissions", String.format("flutter_blue plugin requires %s for scanning", permissionConnect), null);
});
}
else
result.error(
"no_permissions", String.format("flutter_blue plugin requires %s for scanning", permissionScan), null);
});
break;
}
The changelog for 1.5.0 states that the fine location requirement was added on purpose on Android12. I never encountered the need myself on an Android12 phone and the documentation clearly states that fine location isn't needed for scanning.
Can anyone share a phone model that needs fine location with Android 12?
from flutter_blue_plus.
I prefer not to ask my users for fine location on android 12 so as long as this is forced in 1.5.2, I forked and changed AndroidManifest.xml to:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.boskokg.flutter_blue_plus"> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" tools:targetApi="s" /> </manifest>
and changed FlutterBluePlusPlugin.java in the scan code to omit the check of fine location for type "s" like this:
case "startScan": { ensurePermissionBeforeAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? Manifest.permission.BLUETOOTH_SCAN : Manifest.permission.ACCESS_FINE_LOCATION, (grantedScan, permissionScan) -> { if (grantedScan) { ensurePermissionBeforeAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? Manifest.permission.BLUETOOTH_CONNECT : null, (grantedConnect, permissionConnect) -> { if (grantedConnect) startScan(call, result); else result.error( "no_permissions", String.format("flutter_blue plugin requires %s for scanning", permissionConnect), null); }); } else result.error( "no_permissions", String.format("flutter_blue plugin requires %s for scanning", permissionScan), null); }); break; }
The changelog for 1.5.0 states that the fine location requirement was added on purpose on Android12. I never encountered the need myself on an Android12 phone and the documentation clearly states that fine location isn't needed for scanning. Can anyone share a phone model that needs fine location with Android 12?
If phones are using Android 12, you'd expect them all to have the same permission requirements wouldn't you?
from flutter_blue_plus.
@virshe00 I would, yes, which is why I don't understand the decision made in 1.5.0 and why I feel ok with the fork I made. Still - the changelog hints that some people faced Android 12 phones that failed to work with the documented requirements, so maybe some manufacturer did something wrong? idk. Myself, I never encountered an Android 12 phone that needed fine location for BLE, but I didn't test more than a few manufacturers
from flutter_blue_plus.
@itamardo Yeah, that makes sense. I can't find any reference to anyone having issues and if some phone manufacturer isn't following the Android specification then idk what else they're doing and they sound like a bad brand.
Regardless, I think the core of the issue comes from requiring fine location permissions, but only if you don't specify neverForLocation
.
@chipweinberger Could you please make a decision as to what you think the course of action should be? I can understand why you might want to enforce precise location. If there's no way to detect whether the manifest specifies neverForLocation
, it might be safer to simply enforce fine location. However, I think reverting the commit and having a note/section in the README around the permissions section might be sufficient. If we were really pedantic, we could spit out a warning message if we don't have fine location.
from flutter_blue_plus.
Can anyone share a phone model that needs fine location with Android 12?
I would be interested too... This new location permission request is very annoying and against the Android specs (as long as BT is not used for location, obviously)
from flutter_blue_plus.
please open a PR.
This change was made because I pulled a fork. I'm not sure if the fork was for 11 or 12, but FBP should target the most recent version.
from flutter_blue_plus.
Thank you @itamardo !
I have spend 2 days to make ap works again...
Google is already annoying all the time to change and come up with new rules and mechanisms ...
from flutter_blue_plus.
I would like to contact flutter developers. I hope you read github.
You are creating a cross-platform framework that should behave the same on all platforms and have common interaction mechanisms. Now there are more than 10 options for plugins for working with bluetooth on pub.dev. I believe that you, as developers of a cross-platform framework, are obliged to develop and make part of the framework all the basic mechanisms for working with such things as bluetooth, cameras, wifi, and the like, as is done for example in QT.
from flutter_blue_plus.
My manifest above had a missing line (fine location for sdk <= 30) that was apparently needed for an Android 11 phone so I updated it like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.boskokg.flutter_blue_plus">
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
</manifest>
from flutter_blue_plus.
My manifest above had a missing line (fine location for sdk <= 30) that was apparently needed for an Android 11 phone so I updated it like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.boskokg.flutter_blue_plus"> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" tools:targetApi="s" /> </manifest>
I wondered about this, thanks for pointing it out.
I'll try and get this thing done over the weekend.
from flutter_blue_plus.
a lot of this changed in 1.7.0+
please try 1.7.6+, reopen a new issue if you still have problems.
from flutter_blue_plus.
Related Issues (20)
- [Issue]: discoverServices: GATT_ATTR_NOT_FOUND (10) HOT 2
- [Help]: device name doesnt update HOT 3
- [Help]: Slow data transmission with Phomemo thermal printer HOT 6
- [Feature]: AdaptionData.manufactorData not updated in a timely manner HOT 1
- [Help]: System device scan returns empty HOT 2
- [Bug]: FBP logs not getting turned off in Android HOT 2
- FlutterBluePlusException | connect | fbp-code: 1 HOT 3
- [Bug]: Frequent start/stop scan operations break the scan and return empty results HOT 4
- [Feature]: iBeacons are not supported on iOS. Apple requires you to use CoreLocation. HOT 1
- [Help]: How to disable auto connect after device is diconnected HOT 1
- [Help]: [iOS] OnConnectionStateChanged state does not change when using Settings app HOT 1
- [Help]: last value in MSD is always 0 after 1.32.5 HOT 5
- [Help]: Unstable connection HOT 5
- [Reature]:Bluetooth search problem[Help]: HOT 9
- [Help]: FlutterBluePlus.systemDevices isn't showing already paired devices to the BLE system HOT 2
- [Help]: The scan result service is returned as null. HOT 1
- [Help]: Ble auto connection issue when bluetooth turn on/off in Android HOT 2
- [Help]: Can't get sendData on iOS HOT 3
- [Help]: scanning returns no results HOT 5
- [Help]: Verify fix example for double pairing request on Android HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_blue_plus.