diff options
| author | 2018-07-03 16:33:24 -0700 | |
|---|---|---|
| committer | 2018-07-09 16:35:33 -0700 | |
| commit | b86334faa48114daa6ff795958eaef687fe923c8 (patch) | |
| tree | ad8c33ed21630e84623b25695db3875c0c8c23e1 | |
| parent | 50621368c8d16a8f02982e8335c7a8d170809722 (diff) | |
Use app ops string string when checking ops.
Permission string is used instead of app ops string. This would
cause RemoteExceptions when getting last location.
Bug: 111104930
Test: Manual, with test app
Change-Id: Ia284b1103f667bd29cf2bc0877dd8f605723b0ff
| -rw-r--r-- | services/core/java/com/android/server/LocationManagerService.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index de02e81a00c4..776cf47a1e56 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -1549,6 +1549,22 @@ public class LocationManagerService extends ILocationManager.Stub { return -1; } + private static String resolutionLevelToOpStr(int allowedResolutionLevel) { + switch(allowedResolutionLevel) { + case RESOLUTION_LEVEL_COARSE: + return AppOpsManager.OPSTR_COARSE_LOCATION; + case RESOLUTION_LEVEL_FINE: + return AppOpsManager.OPSTR_FINE_LOCATION; + case RESOLUTION_LEVEL_NONE: + // The client is not allowed to get any location, so both FINE and COARSE ops will + // be denied. Pick the most restrictive one to be safe. + return AppOpsManager.OPSTR_FINE_LOCATION; + default: + // Use the most restrictive ops if not sure. + return AppOpsManager.OPSTR_FINE_LOCATION; + } + } + boolean reportLocationAccessNoThrow( int pid, int uid, String packageName, int allowedResolutionLevel) { int op = resolutionLevelToOp(allowedResolutionLevel); @@ -2295,7 +2311,7 @@ public class LocationManagerService extends ILocationManager.Stub { } // Don't return stale location to apps with foreground-only location permission. - String op = getResolutionPermission(allowedResolutionLevel); + String op = resolutionLevelToOpStr(allowedResolutionLevel); long locationAgeMs = SystemClock.elapsedRealtime() - location.getElapsedRealtimeNanos() / NANOS_PER_MILLI; if ((locationAgeMs > mLastLocationMaxAgeMs) |