Merge "Do not mount storage obb&data dirs in fuse daemon process" into rvc-dev

This commit is contained in:
Ricky Wai
2020-03-18 15:36:13 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 7 deletions

View File

@@ -144,4 +144,10 @@ public abstract class StorageManagerInternal {
* @param uid the uid of the package
*/
public abstract void prepareAppDataAfterInstall(@NonNull String packageName, int uid);
/**
* Return true if uid is external storage service.
*/
public abstract boolean isExternalStorageService(int uid);
}

View File

@@ -4076,7 +4076,7 @@ class StorageManagerService extends IStorageManager.Stub
return Zygote.MOUNT_EXTERNAL_NONE;
}
if (mIsFuseEnabled && mMediaStoreAuthorityAppId == UserHandle.getAppId(uid)) {
if (mIsFuseEnabled && mStorageManagerInternal.isExternalStorageService(uid)) {
// Determine if caller requires pass_through mount; note that we do this for
// all processes that share a UID with MediaProvider; but this is fine, since
// those processes anyway share the same rights as MediaProvider.
@@ -4422,14 +4422,16 @@ class StorageManagerService extends IStorageManager.Stub
String.format("/storage/emulated/%d/Android/data/%s/",
userId, pkg);
int appUid =
UserHandle.getUid(userId, mPmInternal.getPackage(pkg).getUid());
// Create package obb and data dir if it doesn't exist.
File file = new File(packageObbDir);
if (!file.exists()) {
vold.setupAppDir(packageObbDir, mPmInternal.getPackage(pkg).getUid());
vold.setupAppDir(packageObbDir, appUid);
}
file = new File(packageDataDir);
if (!file.exists()) {
vold.setupAppDir(packageDataDir, mPmInternal.getPackage(pkg).getUid());
vold.setupAppDir(packageDataDir, appUid);
}
}
} catch (ServiceManager.ServiceNotFoundException | RemoteException e) {
@@ -4524,6 +4526,11 @@ class StorageManagerService extends IStorageManager.Stub
}
}
@Override
public boolean isExternalStorageService(int uid) {
return mMediaStoreAuthorityAppId == UserHandle.getAppId(uid);
}
public boolean hasExternalStorage(int uid, String packageName) {
// No need to check for system uid. This avoids a deadlock between
// PackageManagerService and AppOpsService.

View File

@@ -2192,11 +2192,12 @@ public final class ProcessList {
app.setHasForegroundActivities(true);
}
StorageManagerInternal storageManagerInternal = LocalServices.getService(
StorageManagerInternal.class);
final Map<String, Pair<String, Long>> pkgDataInfoMap;
boolean bindMountAppStorageDirs = false;
if (shouldIsolateAppData(app)) {
bindMountAppStorageDirs = mVoldAppDataIsolationEnabled;
// Get all packages belongs to the same shared uid. sharedPackages is empty array
// if it doesn't have shared uid.
final PackageManagerInternal pmInt = mService.getPackageManagerInternalLocked();
@@ -2206,9 +2207,9 @@ public final class ProcessList {
? new String[]{app.info.packageName} : sharedPackages, uid);
int userId = UserHandle.getUserId(uid);
if (mVoldAppDataIsolationEnabled) {
StorageManagerInternal storageManagerInternal = LocalServices.getService(
StorageManagerInternal.class);
if (mVoldAppDataIsolationEnabled && UserHandle.isApp(app.uid) &&
!storageManagerInternal.isExternalStorageService(uid)) {
bindMountAppStorageDirs = true;
if (!storageManagerInternal.prepareStorageDirs(userId, pkgDataInfoMap.keySet(),
app.processName)) {
// Cannot prepare Android/app and Android/obb directory,