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

Commit ae6d1c9a authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Create sandboxes for newly installed apps."

parents 625a46df 8ff30b13
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -79,4 +79,18 @@ public abstract class StorageManagerInternal {
     * @return The mount mode.
     */
    public abstract int getExternalStorageMountMode(int uid, String packageName);

    /**
     * Mount external storage for the given package.
     *
     * <p> This will involve calling into vold to setup appropriate bind mounts.
     *
     * @param packageName The package for which external storage will be mounted.
     * @param appId The appId for the given package.
     * @param sharedUserId The sharedUserId for given package if it specified
     *      {@code android:sharedUserId} in the manifest, otherwise {@code null}
     * @param userId
     */
    public abstract void mountExternalStorageForApp(String packageName, int appId,
            String sharedUserId, int userId);
}
+24 −0
Original line number Diff line number Diff line
@@ -3867,5 +3867,29 @@ class StorageManagerService extends IStorageManager.Stub
            }
            return true;
        }

        @Override
        public void mountExternalStorageForApp(String packageName, int appId, String sharedUserId,
                int userId) {
            final String sandboxId;
            synchronized (mPackagesLock) {
                final ArraySet<String> userPackages = getPackagesForUserPL(userId);
                // If userPackages is empty, it means the user is not started yet, so no need to
                // do anything now.
                if (userPackages.isEmpty() || userPackages.contains(packageName)) {
                    return;
                }
                userPackages.add(packageName);
                mAppIds.put(packageName, appId);
                sandboxId = getSandboxId(packageName, sharedUserId);
                mSandboxIds.put(appId, sandboxId);
            }

            try {
                mVold.mountExternalStorageForApp(packageName, appId, sandboxId, userId);
            } catch (Exception e) {
                Slog.wtf(TAG, e);
            }
        }
    }
}
+8 −2
Original line number Diff line number Diff line
@@ -20026,9 +20026,9 @@ public class PackageManagerService extends IPackageManager.Stub
        mDexManager.systemReady();
        mPackageDexOptimizer.systemReady();
        StorageManagerInternal StorageManagerInternal = LocalServices.getService(
        StorageManagerInternal storageManagerInternal = LocalServices.getService(
                StorageManagerInternal.class);
        StorageManagerInternal.addExternalStoragePolicy(
        storageManagerInternal.addExternalStoragePolicy(
                new StorageManagerInternal.ExternalStorageMountPolicy() {
            @Override
            public int getMountMode(int uid, String packageName) {
@@ -21411,6 +21411,12 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        prepareAppDataContentsLeafLIF(pkg, userId, flags);
        final StorageManagerInternal storageManagerInternal
                = LocalServices.getService(StorageManagerInternal.class);
        if (storageManagerInternal != null) {
            storageManagerInternal.mountExternalStorageForApp(
                    pkg.packageName, appId, pkg.mSharedUserId, userId);
        }
    }
    private void prepareAppDataContentsLIF(PackageParser.Package pkg, int userId, int flags) {