diff options
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 61ed1a7..b719b16 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3119,7 +3119,13 @@ public class PackageManagerService extends IPackageManager.Stub { final PackageParser.Package p = mPackages.get(pkgName); if (p != null && p.mExtras != null) { final PackageSetting ps = (PackageSetting) p.mExtras; - if (ps.getPermissionsState().hasPermission(permName, userId)) { + final PermissionsState permissionsState = ps.getPermissionsState(); + if (permissionsState.hasPermission(permName, userId)) { + return PackageManager.PERMISSION_GRANTED; + } + // Special case: ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION + if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permName) && permissionsState + .hasPermission(Manifest.permission.ACCESS_FINE_LOCATION, userId)) { return PackageManager.PERMISSION_GRANTED; } } @@ -3140,13 +3146,25 @@ public class PackageManagerService extends IPackageManager.Stub { Object obj = mSettings.getUserIdLPr(UserHandle.getAppId(uid)); if (obj != null) { final SettingBase ps = (SettingBase) obj; - if (ps.getPermissionsState().hasPermission(permName, userId)) { + final PermissionsState permissionsState = ps.getPermissionsState(); + if (permissionsState.hasPermission(permName, userId)) { + return PackageManager.PERMISSION_GRANTED; + } + // Special case: ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION + if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permName) && permissionsState + .hasPermission(Manifest.permission.ACCESS_FINE_LOCATION, userId)) { return PackageManager.PERMISSION_GRANTED; } } else { ArraySet<String> perms = mSystemPermissions.get(uid); - if (perms != null && perms.contains(permName)) { - return PackageManager.PERMISSION_GRANTED; + if (perms != null) { + if (perms.contains(permName)) { + return PackageManager.PERMISSION_GRANTED; + } + if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permName) && perms + .contains(Manifest.permission.ACCESS_FINE_LOCATION)) { + return PackageManager.PERMISSION_GRANTED; + } } } } |