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

Commit 210ce8ae authored by Songchun Fan's avatar Songchun Fan Committed by Song Chun Fan
Browse files

[pm] fix NPE in assertPackageStorageValid

BUG: 324819312
BUG: 324689347
Test: atest com.android.tests.apex.host.ApkInApexTests

Change-Id: I8fcaa96746890a4da776d4ac1b4fd4eabdcb3070
parent a60c144b
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -503,21 +503,24 @@ public class AppDataHelper {
    private void assertPackageStorageValid(@NonNull Computer snapshot, String volumeUuid,
            String packageName, int userId) throws PackageManagerException {
        final PackageStateInternal packageState = snapshot.getPackageStateInternal(packageName);
        final PackageUserStateInternal userState = packageState.getUserStateOrDefault(userId);
        if (packageState == null) {
            throw PackageManagerException.ofInternalError("Package " + packageName + " is unknown",
                    PackageManagerException.INTERNAL_ERROR_STORAGE_INVALID_PACKAGE_UNKNOWN);
        } else if (!TextUtils.equals(volumeUuid, packageState.getVolumeUuid())) {
        }
        if (!TextUtils.equals(volumeUuid, packageState.getVolumeUuid())) {
            throw PackageManagerException.ofInternalError(
                    "Package " + packageName + " found on unknown volume " + volumeUuid
                            + "; expected volume " + packageState.getVolumeUuid(),
                    PackageManagerException.INTERNAL_ERROR_STORAGE_INVALID_VOLUME_UNKNOWN);
        } else if (!userState.isInstalled() && !userState.dataExists()) {
        }
        final PackageUserStateInternal userState = packageState.getUserStateOrDefault(userId);
        if (!userState.isInstalled() && !userState.dataExists()) {
            throw PackageManagerException.ofInternalError(
                    "Package " + packageName + " not installed for user " + userId
                            + " or was deleted without DELETE_KEEP_DATA",
                    PackageManagerException.INTERNAL_ERROR_STORAGE_INVALID_NOT_INSTALLED_FOR_USER);
        } else if (packageState.getPkg() != null
        }
        if (packageState.getPkg() != null
                && !shouldHaveAppStorage(packageState.getPkg())) {
            throw PackageManagerException.ofInternalError(
                    "Package " + packageName + " shouldn't have storage",