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

Commit 94d450d2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix incorrect locking order"

parents 47f43001 68babfc7
Loading
Loading
Loading
Loading
+41 −36
Original line number Diff line number Diff line
@@ -12836,7 +12836,6 @@ public class PackageManagerService extends IPackageManager.Stub
        final List<String> unactionedPackages = new ArrayList<>(packageNames.length);
        final long callingId = Binder.clearCallingIdentity();
        try {
            synchronized (mPackages) {
            for (int i = 0; i < packageNames.length; i++) {
                final String packageName = packageNames[i];
                if (callingPackage.equals(packageName)) {
@@ -12845,7 +12844,9 @@ public class PackageManagerService extends IPackageManager.Stub
                    unactionedPackages.add(packageName);
                    continue;
                }
                    final PackageSetting pkgSetting = mSettings.mPackages.get(packageName);
                PackageSetting pkgSetting;
                synchronized (mPackages) {
                    pkgSetting = mSettings.mPackages.get(packageName);
                    if (pkgSetting == null
                            || filterAppAccessLPr(pkgSetting, callingUid, userId)) {
                        Slog.w(TAG, "Could not find package setting for package: " + packageName
@@ -12853,16 +12854,21 @@ public class PackageManagerService extends IPackageManager.Stub
                        unactionedPackages.add(packageName);
                        continue;
                    }
                    if (suspended && !canSuspendPackageForUserLocked(packageName, userId)) {
                }
                if (suspended && !canSuspendPackageForUserInternal(packageName, userId)) {
                    unactionedPackages.add(packageName);
                    continue;
                }
                synchronized (mPackages) {
                    pkgSetting = mSettings.mPackages.get(packageName);
                    if (pkgSetting != null) {
                        pkgSetting.setSuspended(suspended, callingPackage, dialogInfo, appExtras,
                                launcherExtras, userId);
                    }
                }
                changedPackagesList.add(packageName);
                changedUids.add(UserHandle.getUid(userId, pkgSetting.appId));
            }
            }
        } finally {
            Binder.restoreCallingIdentity(callingId);
        }
@@ -13018,16 +13024,13 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        final long identity = Binder.clearCallingIdentity();
        try {
            synchronized (mPackages) {
                return canSuspendPackageForUserLocked(packageName, userId);
            }
            return canSuspendPackageForUserInternal(packageName, userId);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
    @GuardedBy("mPackages")
    private boolean canSuspendPackageForUserLocked(String packageName, int userId) {
    private boolean canSuspendPackageForUserInternal(String packageName, int userId) {
        if (isPackageDeviceAdmin(packageName, userId)) {
            Slog.w(TAG, "Cannot suspend package \"" + packageName
                    + "\": has an active device admin");
@@ -13071,6 +13074,7 @@ public class PackageManagerService extends IPackageManager.Stub
            return false;
        }
        synchronized (mPackages) {
            if (mProtectedPackages.isPackageStateProtected(userId, packageName)) {
                Slog.w(TAG, "Cannot suspend package \"" + packageName
                        + "\": protected package");
@@ -13087,6 +13091,7 @@ public class PackageManagerService extends IPackageManager.Stub
                        + pkg.staticSharedLibName);
                return false;
            }
        }
        if (PLATFORM_PACKAGE_NAME.equals(packageName)) {
            Slog.w(TAG, "Cannot suspend the platform package: " + packageName);