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

Commit e8d2fdf1 authored by Eric Biggers's avatar Eric Biggers Committed by Android (Google) Code Review
Browse files

Merge "Move {prepare,destroy}UserStorage() to StorageManagerInternal" into main

parents 70b22390 0a092dcc
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -136,10 +136,6 @@ interface IStorageManager {
    @EnforcePermission("STORAGE_INTERNAL")
    void lockCeStorage(int userId) = 64;
    boolean isCeStorageUnlocked(int userId) = 65;
    @EnforcePermission("STORAGE_INTERNAL")
    void prepareUserStorage(in String volumeUuid, int userId, int flags) = 66;
    @EnforcePermission("STORAGE_INTERNAL")
    void destroyUserStorage(in String volumeUuid, int userId, int flags) = 67;
    @EnforcePermission("MOUNT_FORMAT_FILESYSTEMS")
    void fstrim(int flags, IVoldTaskListener listener) = 72;
    AppFuseMount mountProxyFileDescriptorBridge() = 73;
+0 −18
Original line number Diff line number Diff line
@@ -1648,24 +1648,6 @@ public class StorageManager {
        }
    }

    /** {@hide} */
    public void prepareUserStorage(String volumeUuid, int userId, int flags) {
        try {
            mStorageManager.prepareUserStorage(volumeUuid, userId, flags);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** {@hide} */
    public void destroyUserStorage(String volumeUuid, int userId, int flags) {
        try {
            mStorageManager.destroyUserStorage(volumeUuid, userId, flags);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns true if the user's credential-encrypted (CE) storage is unlocked.
     *
+22 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.pm.UserInfo;
import android.os.IInstalld;
import android.os.IVold;
import android.os.ParcelFileDescriptor;
import android.os.storage.StorageManager.StorageFlags;

import java.io.IOException;
import java.util.List;
@@ -171,6 +172,27 @@ public abstract class StorageManagerInternal {
     */
    public abstract void destroyUserStorageKeys(int userId);

    /**
     * Prepares a user's CE and/or DE storage on a volume.
     *
     * @param volumeUuid UUID of the volume, or null for the private internal volume
     * @param userId ID of the user to prepare storage for
     * @param flags Flags that specify the type(s) of storage to prepare
     * @throws RuntimeException on failure
     */
    public abstract void prepareUserStorage(
            @Nullable String volumeUuid, @UserIdInt int userId, @StorageFlags int flags);

    /**
     * Destroys a user's CE and/or DE storage on a volume.
     *
     * @param volumeUuid UUID of the volume, or null for the private internal volume
     * @param userId ID of the user to destroy storage for
     * @param flags Flags that specify the type(s) of storage to destroy
     */
    public abstract void destroyUserStorage(
            @Nullable String volumeUuid, @UserIdInt int userId, @StorageFlags int flags);

    /**
     * Tells StorageManager that CE storage for this user has been prepared.
     *
+21 −26
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ import android.os.storage.IStorageManager;
import android.os.storage.IStorageShutdownObserver;
import android.os.storage.OnObbStateChangeListener;
import android.os.storage.StorageManager;
import android.os.storage.StorageManager.StorageFlags;
import android.os.storage.StorageVolume;
import android.os.storage.VolumeInfo;
import android.os.storage.VolumeRecord;
@@ -3387,19 +3388,6 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @android.annotation.EnforcePermission(android.Manifest.permission.STORAGE_INTERNAL)
    @Override
    public void prepareUserStorage(String volumeUuid, int userId, int flags) {

        super.prepareUserStorage_enforcePermission();

        try {
            prepareUserStorageInternal(volumeUuid, userId, flags);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private void prepareUserStorageInternal(String volumeUuid, int userId, int flags)
            throws Exception {
        try {
@@ -3432,19 +3420,6 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @android.annotation.EnforcePermission(android.Manifest.permission.STORAGE_INTERNAL)
    @Override
    public void destroyUserStorage(String volumeUuid, int userId, int flags) {

        super.destroyUserStorage_enforcePermission();

        try {
            mVold.destroyUserStorage(volumeUuid, userId, flags);
        } catch (Exception e) {
            Slog.wtf(TAG, e);
        }
    }

    @Override
    public void fixupAppDir(String path) {
        final Matcher matcher = KNOWN_APP_DIR_PATHS.matcher(path);
@@ -5084,6 +5059,26 @@ class StorageManagerService extends IStorageManager.Stub
            }
        }

        @Override
        public void prepareUserStorage(
                @Nullable String volumeUuid, @UserIdInt int userId, @StorageFlags int flags) {
            try {
                prepareUserStorageInternal(volumeUuid, userId, flags);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void destroyUserStorage(
                @Nullable String volumeUuid, @UserIdInt int userId, @StorageFlags int flags) {
            try {
                mVold.destroyUserStorage(volumeUuid, userId, flags);
            } catch (Exception e) {
                Slog.wtf(TAG, e);
            }
        }

        @Override
        public void markCeStoragePrepared(int userId) {
            synchronized (mLock) {
+1 −1
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ public final class StorageEventHelper extends StorageEventListener {
            }

            try {
                sm.prepareUserStorage(volumeUuid, user.id, flags);
                smInternal.prepareUserStorage(volumeUuid, user.id, flags);
                try (PackageManagerTracedLock installLock = mPm.mInstallLock.acquireLock()) {
                    appDataHelper.reconcileAppsDataLI(volumeUuid, user.id, flags,
                            true /* migrateAppData */);
Loading