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

Commit 33f65534 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Null check while removing suspensions

Packages passed to package manager may not exist as
DevicePolicyManager#setUninstallBlocked can be called on non-existent packages.

Test: Builds, existing tests pass.

Bug: 150161010
Bug: 155933497

Change-Id: Ie4ec6c429fde8567b25e9ac06d54a7354d780661
parent 829ac140
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -13451,7 +13451,7 @@ public class PackageManagerService extends IPackageManager.Stub
        synchronized (mLock) {
            for (String packageName : packagesToChange) {
                final PackageSetting ps = mSettings.mPackages.get(packageName);
                if (ps.getSuspended(userId)) {
                if (ps != null && ps.getSuspended(userId)) {
                    ps.removeSuspension(suspendingPackagePredicate, userId);
                    if (!ps.getSuspended(userId)) {
                        unsuspendedPackages.add(ps.name);
@@ -13492,7 +13492,7 @@ public class PackageManagerService extends IPackageManager.Stub
        synchronized (mLock) {
            for (String packageName : packagesToChange) {
                final PackageSetting ps = mSettings.mPackages.get(packageName);
                if (ps.getDistractionFlags(userId) != 0) {
                if (ps != null && ps.getDistractionFlags(userId) != 0) {
                    ps.setDistractionFlags(0, userId);
                    changedPackages.add(ps.name);
                    changedUids.add(UserHandle.getUid(userId, ps.getAppId()));
@@ -18884,6 +18884,7 @@ public class PackageManagerService extends IPackageManager.Stub
            int userId) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.DELETE_PACKAGES, null);
        // TODO (b/157774108): This should fail on non-existent packages.
        synchronized (mLock) {
            // Cannot block uninstall of static shared libs as they are
            // considered a part of the using app (emulating static linking).