Handle API 29 split-permissions
* For apps targetting 28 or lower, fine/coarse location now implies background location. * Fine location now implies coarse location. References: * https://developer.android.com/about/versions/10/privacy/changes#access_granted_automatically_when_targeting_android_9_or_lower * https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-10.0.0_r1/data/etc/platform.xml#186
This commit is contained in:
parent
7c0cb2064e
commit
09835721f2
@ -500,9 +500,19 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
* Generate the set of requested permissions for the current Android version.
|
||||
* <p>
|
||||
* There are also a bunch of crazy rules where having one permission will imply
|
||||
* another permission, for example, {@link Manifest.permission#WRITE_EXTERNAL_STORAGE}
|
||||
* implies {@code Manifest.permission#READ_EXTERNAL_STORAGE}. Many of these rules
|
||||
* are for quite old Android versions, so they are not included here.
|
||||
* another permission, for example:
|
||||
* {@link Manifest.permission#WRITE_EXTERNAL_STORAGE} implies
|
||||
* {@link Manifest.permission#READ_EXTERNAL_STORAGE}.
|
||||
* Staring with API 29 / Android 10 / Q,
|
||||
* Apps targetting API 28 or lower automatically get
|
||||
* {@link Manifest.permission#ACCESS_BACKGROUND_LOCATION} when they ask for either of
|
||||
* {@link Manifest.permission#ACCESS_COARSE_LOCATION} or
|
||||
* {@link Manifest.permission#ACCESS_FINE_LOCATION}.
|
||||
* Also,
|
||||
* {@link Manifest.permission#ACCESS_FINE_LOCATION} implies
|
||||
* {@link Manifest.permission#ACCESS_COARSE_LOCATION}.
|
||||
* Many of these rules are for quite old Android versions,
|
||||
* so they are not included here.
|
||||
*
|
||||
* @see Manifest.permission#READ_EXTERNAL_STORAGE
|
||||
*/
|
||||
@ -523,6 +533,16 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
if (Build.VERSION.SDK_INT >= 16 && set.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
set.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
if (targetSdkVersion <= 28) {
|
||||
if (Build.VERSION.SDK_INT >= 29 && (set.contains(Manifest.permission.ACCESS_COARSE_LOCATION) ||
|
||||
set.contains(Manifest.permission.ACCESS_FINE_LOCATION))) {
|
||||
// TODO: Change the below to Manifest.permission once we target SDK 29.
|
||||
set.add("android.permission.ACCESS_BACKGROUND_LOCATION");
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 29 && set.contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
set.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
requestedPermissions = set.toArray(new String[set.size()]);
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,18 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
requestedPermissionsSet.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
requestedPermissionsSet.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
if (curapk.targetSdkVersion <= 28) {
|
||||
if (Build.VERSION.SDK_INT >= 29 &&
|
||||
(requestedPermissionsSet.contains(Manifest.permission.ACCESS_COARSE_LOCATION) ||
|
||||
requestedPermissionsSet.contains(Manifest.permission.ACCESS_FINE_LOCATION))) {
|
||||
// TODO: Change the below to Manifest.permission once we target SDK 29.
|
||||
requestedPermissionsSet.add("android.permission.ACCESS_BACKGROUND_LOCATION");
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 29 &&
|
||||
requestedPermissionsSet.contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
requestedPermissionsSet.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
int size = requestedPermissionsSet.size();
|
||||
curapk.requestedPermissions = requestedPermissionsSet.toArray(new String[size]);
|
||||
requestedPermissionsSet.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user