Avoid a deadlock between PMS and AppOpsService
Don't check for external storage access rights from MountService
for system server. Otherwise there's a case where AppOpsService
is locked and PackageManagerService calls into AppOps with its
own lock held and is unable to do an AppOps check via this path.
Bug: 22522725
Change-Id: Ib4cf914638905de391384aa5122e691c5a7140ec
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 92b98a7..ed136e9 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -3431,6 +3431,11 @@
}
public boolean hasExternalStorage(int uid, String packageName) {
+ // No need to check for system uid. This avoids a deadlock between
+ // PackageManagerService and AppOpsService.
+ if (uid == Process.SYSTEM_UID) {
+ return true;
+ }
// No locking - CopyOnWriteArrayList
for (ExternalStorageMountPolicy policy : mPolicies) {
final boolean policyHasStorage = policy.hasExternalStorage(uid, packageName);