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

Commit d5e295f9 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Don't hold lock when calling externally

Wound up in a deadlock. We held mPackages lock and called the mount
service. This called into the AppOps service which tried to obtain
its lock. On another thread, we held the AppOps service lock which
called into PackageManager service and tried to take mPackages.

Ideally, we'd never hold an internal lock when calling externally.
In practice, that's not always fixable [for example, code change
would be too great to not hold the AppOps lock when calling into
the PackageManager service].

Bug: 28169075
Change-Id: If0a7f1361c7be9385b1f629f68ebc0556b08ab06
parent 34510eb2
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -2050,9 +2050,11 @@ public class PackageManagerService extends IPackageManager.Stub {
        final int immutableFlags = PackageManager.FLAG_PERMISSION_SYSTEM_FIXED
                | PackageManager.FLAG_PERMISSION_POLICY_FIXED;
        synchronized (mPackages) {
        for (String permission : pkg.requestedPermissions) {
                BasePermission bp = mSettings.mPermissions.get(permission);
            final BasePermission bp;
            synchronized (mPackages) {
                bp = mSettings.mPermissions.get(permission);
            }
            if (bp != null && (bp.isRuntime() || bp.isDevelopment())
                    && (grantedPermissions == null
                           || ArrayUtils.contains(grantedPermissions, permission))) {
@@ -2064,7 +2066,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            }
        }
    }
    }
    Bundle extrasForInstallResult(PackageInstalledInfo res) {
        Bundle extras = null;