Skip to content
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

Fix locationAlways does not work on Android 10 #921

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions permission_handler_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.0.1

* Fix locationAlways does not work on Android 10.

## 10.0.0

* __BREAKING CHANGE__: Updated Android `compileSdkVersion` to `33` to handle the new `POST_NOTIFICATIONS` permission.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ static List<String> getManifestNames(Context context, @PermissionConstants.Permi
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (hasPermissionInManifest(context, permissionNames, Manifest.permission.ACCESS_BACKGROUND_LOCATION))
permissionNames.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
break;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
break;
Comment on lines +120 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading through the documentation, I think we should always fall through to the location case and add the ACCESS_COARSE_LOCATION and/ or ACCESS_FINE_LOCATION as well. Meaning we need to remove the break; statement al together.

We should also improve the comment above to reflect this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mvanbeusekom
Thank you for your review.

If remove the break;, #794 doesn't work.
Android R (11) and above cannot request background and foreground permissions at the same time.
Therefore, for Android R (11) and above, it is ideal to break if Manifest.permission.ACCESS_BACKGROUND_LOCATION is included and acquire permissions only in the background.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mvanbeusekom
Could you confirm my comments?
Please feel free to contact us if you have any questions.

}
case PermissionConstants.PERMISSION_GROUP_LOCATION_WHEN_IN_USE:
case PermissionConstants.PERMISSION_GROUP_LOCATION:
Expand Down
2 changes: 1 addition & 1 deletion permission_handler_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: permission_handler_android
description: Permission plugin for Flutter. This plugin provides the Android API to request and check permissions.
version: 10.0.0
version: 10.0.1
homepage: https://github.com/baseflow/flutter-permission-handler

environment:
Expand Down