Merge "Create a new MOUNT_EXTERNAL_LEGACY storage mode."
This commit is contained in:
committed by
Android (Google) Code Review
commit
7461df211d
@@ -402,6 +402,8 @@ public class ZygoteProcess {
|
||||
argsForZygote.add("--mount-external-full");
|
||||
} else if (mountExternal == Zygote.MOUNT_EXTERNAL_INSTALLER) {
|
||||
argsForZygote.add("--mount-external-installer");
|
||||
} else if (mountExternal == Zygote.MOUNT_EXTERNAL_LEGACY) {
|
||||
argsForZygote.add("--mount-external-legacy");
|
||||
}
|
||||
|
||||
argsForZygote.add("--target-sdk-version=" + targetSdkVersion);
|
||||
|
||||
@@ -81,6 +81,11 @@ public final class Zygote {
|
||||
public static final int MOUNT_EXTERNAL_READ = IVold.REMOUNT_MODE_READ;
|
||||
/** Read-write external storage should be mounted. */
|
||||
public static final int MOUNT_EXTERNAL_WRITE = IVold.REMOUNT_MODE_WRITE;
|
||||
/**
|
||||
* Mount mode for apps that are already installed on the device before the isolated_storage
|
||||
* feature is enabled.
|
||||
*/
|
||||
public static final int MOUNT_EXTERNAL_LEGACY = IVold.REMOUNT_MODE_LEGACY;
|
||||
/**
|
||||
* Mount mode for package installers which should give them access to
|
||||
* all obb dirs in addition to their package sandboxes
|
||||
|
||||
@@ -688,8 +688,10 @@ class ZygoteConnection {
|
||||
mountExternal = Zygote.MOUNT_EXTERNAL_WRITE;
|
||||
} else if (arg.equals("--mount-external-full")) {
|
||||
mountExternal = Zygote.MOUNT_EXTERNAL_FULL;
|
||||
} else if (arg.equals("--mount-external-installer")) {
|
||||
} else if (arg.equals("--mount-external-installer")) {
|
||||
mountExternal = Zygote.MOUNT_EXTERNAL_INSTALLER;
|
||||
} else if (arg.equals("--mount-external-legacy")) {
|
||||
mountExternal = Zygote.MOUNT_EXTERNAL_LEGACY;
|
||||
} else if (arg.equals("--query-abi-list")) {
|
||||
abiListQuery = true;
|
||||
} else if (arg.equals("--get-pid")) {
|
||||
|
||||
@@ -109,8 +109,9 @@ enum MountExternalKind {
|
||||
MOUNT_EXTERNAL_DEFAULT = 1,
|
||||
MOUNT_EXTERNAL_READ = 2,
|
||||
MOUNT_EXTERNAL_WRITE = 3,
|
||||
MOUNT_EXTERNAL_INSTALLER = 4,
|
||||
MOUNT_EXTERNAL_FULL = 5,
|
||||
MOUNT_EXTERNAL_LEGACY = 4,
|
||||
MOUNT_EXTERNAL_INSTALLER = 5,
|
||||
MOUNT_EXTERNAL_FULL = 6,
|
||||
};
|
||||
|
||||
// Must match values in com.android.internal.os.Zygote.
|
||||
@@ -548,8 +549,9 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode,
|
||||
}
|
||||
|
||||
if (GetBoolProperty(kIsolatedStorageSnapshot, GetBoolProperty(kIsolatedStorage, false))) {
|
||||
if (mount_mode == MOUNT_EXTERNAL_FULL) {
|
||||
storageSource = "/mnt/runtime/write";
|
||||
if (mount_mode == MOUNT_EXTERNAL_FULL || mount_mode == MOUNT_EXTERNAL_LEGACY) {
|
||||
storageSource = (mount_mode == MOUNT_EXTERNAL_FULL)
|
||||
? "/mnt/runtime/full" : "/mnt/runtime/write";
|
||||
if (TEMP_FAILURE_RETRY(mount(storageSource.string(), "/storage",
|
||||
NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) {
|
||||
*error_msg = CREATE_ERROR("Failed to mount %s to /storage: %s",
|
||||
|
||||
@@ -3288,7 +3288,8 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
}
|
||||
|
||||
final int mountMode = mAmInternal.getStorageMountMode(pid, uid);
|
||||
if (mountMode == Zygote.MOUNT_EXTERNAL_FULL) {
|
||||
if (mountMode == Zygote.MOUNT_EXTERNAL_FULL
|
||||
|| mountMode == Zygote.MOUNT_EXTERNAL_LEGACY) {
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -3663,8 +3664,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
return Zygote.MOUNT_EXTERNAL_FULL;
|
||||
} else if (mIAppOpsService.checkOperation(OP_LEGACY_STORAGE, uid,
|
||||
packageName) == MODE_ALLOWED) {
|
||||
// TODO: define a specific "legacy" mount mode
|
||||
return Zygote.MOUNT_EXTERNAL_FULL;
|
||||
return Zygote.MOUNT_EXTERNAL_LEGACY;
|
||||
} else if (mIPackageManager.checkUidPermission(INSTALL_PACKAGES, uid)
|
||||
== PERMISSION_GRANTED || mIAppOpsService.checkOperation(
|
||||
OP_REQUEST_INSTALL_PACKAGES, uid, packageName) == MODE_ALLOWED) {
|
||||
|
||||
@@ -226,6 +226,22 @@ public class StorageManagerServiceTest {
|
||||
PID_RED, UID_COLORS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageInLegacyMode() throws Exception {
|
||||
setStorageMountMode(PID_RED, UID_COLORS, Zygote.MOUNT_EXTERNAL_LEGACY);
|
||||
|
||||
// Both app and system have the same view
|
||||
assertTranslation(
|
||||
"/storage/emulated/0/Android/data/com.red/foo.jpg",
|
||||
"/storage/emulated/0/Android/data/com.red/foo.jpg",
|
||||
PID_RED, UID_COLORS);
|
||||
|
||||
assertTranslation(
|
||||
"/storage/emulated/0/Android/sandbox/com.grey/bar.jpg",
|
||||
"/storage/emulated/0/Android/sandbox/com.grey/bar.jpg",
|
||||
PID_RED, UID_COLORS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstallerPackage() throws Exception {
|
||||
setStorageMountMode(PID_GREY, UID_GREY, Zygote.MOUNT_EXTERNAL_INSTALLER);
|
||||
|
||||
Reference in New Issue
Block a user