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

Commit d0d241e7 authored by Eric Biggers's avatar Eric Biggers
Browse files

Use isCeStorageUnlocked() in package manager

isUserKeyUnlocked() is being renamed to isCeStorageUnlocked() to make it
clear what it does (considering that there are many types of user keys).
Temporarily, the method exists under both names.  Change the package
manager to use the new name.  No change in behavior.

Bug: 306204742
Flag: exempt, mechanical refactoring
Test: presubmit
Change-Id: I66db78ce40618f1c5b263c826eb5984bfe92eab1
parent 912e35b6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public class AppDataHelper {
                StorageManagerInternal.class);
        for (UserInfo user : umInternal.getUsers(false /*excludeDying*/)) {
            final int flags;
            if (StorageManager.isUserKeyUnlocked(user.id)
            if (StorageManager.isCeStorageUnlocked(user.id)
                    && smInternal.isCeStoragePrepared(user.id)) {
                flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
            } else if (umInternal.isUserRunning(user.id)) {
@@ -404,7 +404,7 @@ public class AppDataHelper {
        // First look for stale data that doesn't belong, and check if things
        // have changed since we did our last restorecon
        if ((flags & StorageManager.FLAG_STORAGE_CE) != 0) {
            if (StorageManager.isFileEncrypted() && !StorageManager.isUserKeyUnlocked(userId)) {
            if (StorageManager.isFileEncrypted() && !StorageManager.isCeStorageUnlocked(userId)) {
                throw new RuntimeException(
                        "Yikes, someone asked us to reconcile CE storage while " + userId
                                + " was still locked; this would have caused massive data loss!");
+2 −2
Original line number Diff line number Diff line
@@ -3538,7 +3538,7 @@ public class ComputerEngine implements Computer {
    @Override
    public int getPackageStartability(boolean safeMode, @NonNull String packageName, int callingUid,
            @UserIdInt int userId) {
        final boolean userKeyUnlocked = StorageManager.isUserKeyUnlocked(userId);
        final boolean ceStorageUnlocked = StorageManager.isCeStorageUnlocked(userId);
        final PackageStateInternal ps = getPackageStateInternal(packageName);
        if (ps == null || shouldFilterApplication(ps, callingUid, userId)
                || !ps.getUserStateOrDefault(userId).isInstalled()) {
@@ -3553,7 +3553,7 @@ public class ComputerEngine implements Computer {
            return PackageManagerService.PACKAGE_STARTABILITY_FROZEN;
        }

        if (!userKeyUnlocked && !AndroidPackageUtils.isEncryptionAware(ps.getPkg())) {
        if (!ceStorageUnlocked && !AndroidPackageUtils.isEncryptionAware(ps.getPkg())) {
            return PackageManagerService.PACKAGE_STARTABILITY_DIRECT_BOOT_UNSUPPORTED;
        }
        return PackageManagerService.PACKAGE_STARTABILITY_OK;
+2 −1
Original line number Diff line number Diff line
@@ -198,7 +198,8 @@ public final class MovePackageHelper {
        // If we're moving app data around, we need all the users unlocked
        if (moveCompleteApp) {
            for (int userId : installedUserIds) {
                if (StorageManager.isFileEncrypted() && !StorageManager.isUserKeyUnlocked(userId)) {
                if (StorageManager.isFileEncrypted()
                        && !StorageManager.isCeStorageUnlocked(userId)) {
                    freezer.close();
                    throw new PackageManagerException(MOVE_FAILED_LOCKED_USER,
                            "User " + userId + " must be unlocked");
+1 −1
Original line number Diff line number Diff line
@@ -3460,7 +3460,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        UserManagerInternal umInternal = mInjector.getUserManagerInternal();
        StorageManagerInternal smInternal = mInjector.getLocalService(StorageManagerInternal.class);
        final int flags;
        if (StorageManager.isUserKeyUnlocked(userId) && smInternal.isCeStoragePrepared(userId)) {
        if (StorageManager.isCeStorageUnlocked(userId) && smInternal.isCeStoragePrepared(userId)) {
            flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
        } else if (umInternal.isUserRunning(userId)) {
            flags = StorageManager.FLAG_STORAGE_DE;
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ public final class StorageEventHelper extends StorageEventListener {
                StorageManagerInternal.class);
        for (UserInfo user : mPm.mUserManager.getUsers(false /* includeDying */)) {
            final int flags;
            if (StorageManager.isUserKeyUnlocked(user.id)
            if (StorageManager.isCeStorageUnlocked(user.id)
                    && smInternal.isCeStoragePrepared(user.id)) {
                flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
            } else if (umInternal.isUserRunning(user.id)) {
Loading