From 2a31fd75a0090c0a7a7eb0df27664f2d9758a3e8 Mon Sep 17 00:00:00 2001 From: Hai Zhang Date: Tue, 10 Dec 2019 15:48:22 -0800 Subject: [PATCH] Add Slog.wtf for calling setMode() with OP_COARSE_LOCATION. This happened in Q and seems not in R, but we want to make sure. Bug: 145744192 Bug: 146014123 Test: presubmit Change-Id: I25d41833f17cf38d8987c6f472acdd4430fbb154 --- .../core/java/com/android/server/appop/AppOpsService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 366766e2e47bc..14f96540bc6a7 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -20,6 +20,7 @@ import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION import static android.app.AppOpsManager.MAX_PRIORITY_UID_STATE; import static android.app.AppOpsManager.MIN_PRIORITY_UID_STATE; import static android.app.AppOpsManager.OP_CAMERA; +import static android.app.AppOpsManager.OP_COARSE_LOCATION; import static android.app.AppOpsManager.OP_FLAGS_ALL; import static android.app.AppOpsManager.OP_NONE; import static android.app.AppOpsManager.OP_PLAY_AUDIO; @@ -1642,6 +1643,13 @@ public class AppOpsService extends IAppOpsService.Stub { return; } + // STOPSHIP: Remove this check once we are sure no one is doing it. + if (code == OP_COARSE_LOCATION && mode != AppOpsManager.opToDefaultMode(code)) { + Slog.wtf(TAG, "Trying to setMode() instead of setUidMode(), " + "code=" + code + + ", uid=" + uid + ", packageName=" + packageName + ", mode=" + mode + + ", callingUid=" + Binder.getCallingUid(), new RuntimeException()); + } + synchronized (this) { UidState uidState = getUidStateLocked(uid, false); Op op = getOpLocked(code, uid, packageName, isPrivileged, true);