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

Commit 6eb7c58f authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[pm] Add null check and return first

If the package doesn't exist, don't need to proceed to
setPackageStoppedState in notifyComponentUsed. Return it first.

Bug: 299565095
Test: atest DevicePolicyManagerServiceMigrationTest
Test: atest SuspendPackageHelperTest
Test: atest PackageManagerSettingsTests
Test: atest AppCloningMediaProviderHostTest --iterations 100
Change-Id: I7aff7887e54d023d25ea62d2aad928e45d0fc448
parent 6a853abc
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -4681,9 +4681,12 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            @UserIdInt int userId, @NonNull String recentCallingPackage,
            @NonNull String debugInfo) {
        synchronized (mLock) {
            final PackageUserStateInternal userState = mSettings.getPackageLPr(
                    packageName).getUserStateOrDefault(userId);
            if (userState.isQuarantined()) {
            final PackageSetting pkgSetting = mSettings.getPackageLPr(packageName);
            // If the package doesn't exist, don't need to proceed to setPackageStoppedState.
            if (pkgSetting == null) {
                return;
            }
            if (pkgSetting.getUserStateOrDefault(userId).isQuarantined()) {
                Slog.i(TAG,
                        "Component is quarantined+suspended but being used: "
                                + packageName + " by " + recentCallingPackage + ", debugInfo: "