Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java

Issue 2682863002: [Android] Explicitly request all needed runtime permissions. (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/permissions/permission_update_infobar_delegate_android.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
index 8c4073b7db206a4c8b832524693e7697f2f8999a..0afd70b83082086ca5c2a9a72d3869c352a609d4 100644
--- a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
@@ -24,6 +24,7 @@ import android.view.View;
import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
+import org.chromium.base.BuildInfo;
import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
import org.chromium.ui.UiUtils;
@@ -178,22 +179,27 @@ public class ActivityWindowAndroid
private String getHasRequestedPermissionKey(String permission) {
String permissionQueriedKey = permission;
- try {
- // Runtime permissions are controlled at the group level. So when determining whether
- // we have requested a particular permission before, we should check whether we
- // have requested any permission in that group as that mimics the logic in the Android
- // framework.
- //
- // e.g. Requesting first the permission ACCESS_FINE_LOCATION will result in Chrome
- // treating ACCESS_COARSE_LOCATION as if it had already been requested as well.
- PermissionInfo permissionInfo = getApplicationContext().getPackageManager()
- .getPermissionInfo(permission, PackageManager.GET_META_DATA);
-
- if (!TextUtils.isEmpty(permissionInfo.group)) {
- permissionQueriedKey = permissionInfo.group;
+ // Prior to O, permissions were granted at the group level. Post O, each permission is
+ // granted individually.
+ if (!BuildInfo.isAtLeastO()) {
+ try {
+ // Runtime permissions are controlled at the group level. So when determining
+ // whether we have requested a particular permission before, we should check whether
+ // we have requested any permission in that group as that mimics the logic in the
+ // Android framework.
+ //
+ // e.g. Requesting first the permission ACCESS_FINE_LOCATION will result in Chrome
+ // treating ACCESS_COARSE_LOCATION as if it had already been requested as well.
+ PermissionInfo permissionInfo =
+ getApplicationContext().getPackageManager().getPermissionInfo(
+ permission, PackageManager.GET_META_DATA);
+
+ if (!TextUtils.isEmpty(permissionInfo.group)) {
+ permissionQueriedKey = permissionInfo.group;
+ }
+ } catch (NameNotFoundException e) {
+ // Unknown permission. Default back to the permission name instead of the group.
}
- } catch (NameNotFoundException e) {
- // Unknown permission. Default back to the permission name instead of the group.
}
return PERMISSION_QUERIED_KEY_PREFIX + permissionQueriedKey;
« no previous file with comments | « chrome/browser/permissions/permission_update_infobar_delegate_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698