summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martijn Coenen <maco@google.com> 2023-07-17 09:18:29 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-07-17 09:18:29 +0000
commitca7ee461617b324800e34f23d96ab51c691e49fb (patch)
treeb36f7cdfeb483340442acd7f3b216d54318a110a
parent295290e1e3746e14cb987ce123ed34f81747bd06 (diff)
parent88d2b411f774da9267fcdf5f8ce0c84ec4201b65 (diff)
Merge "SM: Change volume mountUserId for new user" into main am: cc299356d6 am: 88d2b411f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2616670 Change-Id: Ib4fafdbb5285c5a3a8a2df62c04d429c5d156e31 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/StorageManagerService.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 73dbb86ae7cc..e467dd65b371 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1269,6 +1269,21 @@ class StorageManagerService extends IStorageManager.Stub
}
}
+ /**
+ * This method checks if the volume is public and the volume is visible and the volume it is
+ * trying to mount doesn't have the same mount user id as the current user being maintained by
+ * StorageManagerService and change the mount Id. The checks are same as
+ * {@link StorageManagerService#maybeRemountVolumes(int)}
+ * @param VolumeInfo object to consider for changing the mountId
+ */
+ private void updateVolumeMountIdIfRequired(VolumeInfo vol) {
+ synchronized (mLock) {
+ if (!vol.isPrimary() && vol.isVisible() && vol.getMountUserId() != mCurrentUserId) {
+ vol.mountUserId = mCurrentUserId;
+ }
+ }
+ }
+
private boolean supportsBlockCheckpoint() throws RemoteException {
enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
return mVold.supportsBlockCheckpoint();
@@ -1382,13 +1397,14 @@ class StorageManagerService extends IStorageManager.Stub
}
@Override
- public void onVolumeStateChanged(String volId, final int newState) {
+ public void onVolumeStateChanged(String volId, final int newState, final int userId) {
synchronized (mLock) {
final VolumeInfo vol = mVolumes.get(volId);
if (vol != null) {
final int oldState = vol.state;
vol.state = newState;
final VolumeInfo vInfo = new VolumeInfo(vol);
+ vInfo.mountUserId = userId;
final SomeArgs args = SomeArgs.obtain();
args.arg1 = vInfo;
args.argi1 = oldState;
@@ -2232,7 +2248,7 @@ class StorageManagerService extends IStorageManager.Stub
if (isMountDisallowed(vol)) {
throw new SecurityException("Mounting " + volId + " restricted by policy");
}
-
+ updateVolumeMountIdIfRequired(vol);
mount(vol);
}