Use correct contains method in PermissionManagerService.
Hashtable#contains(String) is actually pre-generics method that maps to
Hashtable#containsValue(V). In this case, PermissionManagerService
actually wants to know if it contains a given key as the values in the
map are not Strings at all.
Bug: 217923092
Test: errorprone build
Change-Id: I1f315d1051aaab3831eaca34e12fc9858ee9aeda
diff --git a/services/Android.bp b/services/Android.bp
index 378ad54..654e8d0 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -19,6 +19,7 @@
"-Xep:SelfEquals:ERROR",
"-Xep:NullTernary:ERROR",
"-Xep:TryFailThrowable:ERROR",
+ "-Xep:HashtableContains:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index edc0e3d..d0bbe3d 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -1318,7 +1318,7 @@
if (op < 0) {
// Bg location is one-off runtime modifier permission and has no app op
- if (sPlatformPermissions.contains(permission)
+ if (sPlatformPermissions.containsKey(permission)
&& !Manifest.permission.ACCESS_BACKGROUND_LOCATION.equals(permission)
&& !Manifest.permission.BODY_SENSORS_BACKGROUND.equals(permission)) {
Slog.wtf(LOG_TAG, "Platform runtime permission " + permission