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

Commit ce0965e2 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 262c89dc: am d19555d9: am 38cae6c8: Merge "Reconcile private volumes when mounted." into mnc-dev

* commit '262c89dc':
  Reconcile private volumes when mounted.
parents 5ee1eb82 262c89dc
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -4447,22 +4447,6 @@ public abstract class PackageManager {
     */
    public abstract @NonNull PackageInstaller getPackageInstaller();

    /**
     * Returns the data directory for a particular package and user.
     *
     * @hide
     */
    public static File getDataDirForUser(String volumeUuid, String packageName, int userId) {
        // TODO: This should be shared with Installer's knowledge of user directory
        final File base;
        if (TextUtils.isEmpty(volumeUuid)) {
            base = Environment.getDataDirectory();
        } else {
            base = new File("/mnt/expand/" + volumeUuid);
        }
        return new File(base, "user/" + userId + "/" + packageName);
    }

    /**
     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
     * user with id sourceUserId can also be be resolved by activities in the user with id
+3 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.FileUtils;
import android.os.PatternMatcher;
import android.os.UserHandle;
@@ -4785,7 +4786,7 @@ public class PackageParser {
        // Make shallow copy so we can store the metadata/libraries safely
        ApplicationInfo ai = new ApplicationInfo(p.applicationInfo);
        ai.uid = UserHandle.getUid(userId, ai.uid);
        ai.dataDir = PackageManager.getDataDirForUser(ai.volumeUuid, ai.packageName, userId)
        ai.dataDir = Environment.getDataUserPackageDirectory(ai.volumeUuid, userId, ai.packageName)
                .getAbsolutePath();
        if ((flags & PackageManager.GET_META_DATA) != 0) {
            ai.metaData = p.mAppMetaData;
@@ -4812,7 +4813,7 @@ public class PackageParser {
        // make a copy.
        ai = new ApplicationInfo(ai);
        ai.uid = UserHandle.getUid(userId, ai.uid);
        ai.dataDir = PackageManager.getDataDirForUser(ai.volumeUuid, ai.packageName, userId)
        ai.dataDir = Environment.getDataUserPackageDirectory(ai.volumeUuid, userId, ai.packageName)
                .getAbsolutePath();
        if (state.stopped) {
            ai.flags |= ApplicationInfo.FLAG_STOPPED;
+25 −3
Original line number Diff line number Diff line
@@ -244,12 +244,34 @@ public class Environment {
    }

    /** {@hide} */
    public static File getDataAppDirectory(String volumeUuid) {
    public static File getDataDirectory(String volumeUuid) {
        if (TextUtils.isEmpty(volumeUuid)) {
            return new File("/data/app");
            return new File("/data");
        } else {
            return new File("/mnt/expand/" + volumeUuid + "/app");
            return new File("/mnt/expand/" + volumeUuid);
        }
    }

    /** {@hide} */
    public static File getDataAppDirectory(String volumeUuid) {
        return new File(getDataDirectory(volumeUuid), "app");
    }

    /** {@hide} */
    public static File getDataUserDirectory(String volumeUuid) {
        return new File(getDataDirectory(volumeUuid), "user");
    }

    /** {@hide} */
    public static File getDataUserDirectory(String volumeUuid, int userId) {
        return new File(getDataUserDirectory(volumeUuid), String.valueOf(userId));
    }

    /** {@hide} */
    public static File getDataUserPackageDirectory(String volumeUuid, int userId,
            String packageName) {
        // TODO: keep consistent with installd
        return new File(getDataUserDirectory(volumeUuid, userId), packageName);
    }

    /**
+15 −0
Original line number Diff line number Diff line
@@ -585,6 +585,21 @@ public class StorageManager {
        }
    }

    /** {@hide} */
    public @NonNull List<VolumeInfo> getWritablePrivateVolumes() {
        try {
            final ArrayList<VolumeInfo> res = new ArrayList<>();
            for (VolumeInfo vol : mMountService.getVolumes(0)) {
                if (vol.getType() == VolumeInfo.TYPE_PRIVATE && vol.isMountedWritable()) {
                    res.add(vol);
                }
            }
            return res;
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /** {@hide} */
    public @NonNull List<VolumeRecord> getVolumeRecords() {
        try {
+2 −1
Original line number Diff line number Diff line
@@ -2831,7 +2831,8 @@ class MountService extends IMountService.Stub
                Slog.i(TAG, "Trying to bind to DefaultContainerService");

            Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
            if (mContext.bindService(service, mDefContainerConn, Context.BIND_AUTO_CREATE)) {
            if (mContext.bindServiceAsUser(service, mDefContainerConn, Context.BIND_AUTO_CREATE,
                    UserHandle.OWNER)) {
                mBound = true;
                return true;
            }
Loading