Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bd5cff7 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

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
parent 1fcb6d3a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -3431,6 +3431,11 @@ class MountService extends IMountService.Stub
        }
        }


        public boolean hasExternalStorage(int uid, String packageName) {
        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
            // No locking - CopyOnWriteArrayList
            for (ExternalStorageMountPolicy policy : mPolicies) {
            for (ExternalStorageMountPolicy policy : mPolicies) {
                final boolean policyHasStorage = policy.hasExternalStorage(uid, packageName);
                final boolean policyHasStorage = policy.hasExternalStorage(uid, packageName);