Merge "Improve secondary volume mounts on user switch" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
58b0886913
@@ -248,9 +248,18 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserSwitching(@Nullable TargetUser from, @NonNull TargetUser to) {
|
public void onUserSwitching(@Nullable TargetUser from, @NonNull TargetUser to) {
|
||||||
mStorageManagerService.mCurrentUserId = to.getUserIdentifier();
|
int currentUserId = to.getUserIdentifier();
|
||||||
// To reset public volume mounts
|
mStorageManagerService.mCurrentUserId = currentUserId;
|
||||||
mStorageManagerService.onUserSwitching(mStorageManagerService.mCurrentUserId);
|
|
||||||
|
UserManagerInternal umInternal = LocalServices.getService(UserManagerInternal.class);
|
||||||
|
if (umInternal.isUserUnlocked(currentUserId)) {
|
||||||
|
Slog.d(TAG, "Attempt remount volumes for user: " + currentUserId);
|
||||||
|
mStorageManagerService.maybeRemountVolumes(currentUserId);
|
||||||
|
mStorageManagerService.mRemountCurrentUserVolumesOnUnlock = false;
|
||||||
|
} else {
|
||||||
|
Slog.d(TAG, "Attempt remount volumes for user: " + currentUserId + " on unlock");
|
||||||
|
mStorageManagerService.mRemountCurrentUserVolumesOnUnlock = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -425,6 +434,8 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
|
|
||||||
private volatile int mCurrentUserId = UserHandle.USER_SYSTEM;
|
private volatile int mCurrentUserId = UserHandle.USER_SYSTEM;
|
||||||
|
|
||||||
|
private volatile boolean mRemountCurrentUserVolumesOnUnlock = false;
|
||||||
|
|
||||||
private final Installer mInstaller;
|
private final Installer mInstaller;
|
||||||
|
|
||||||
/** Holding lock for AppFuse business */
|
/** Holding lock for AppFuse business */
|
||||||
@@ -1196,6 +1207,10 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
mHandler.obtainMessage(H_COMPLETE_UNLOCK_USER, userId).sendToTarget();
|
mHandler.obtainMessage(H_COMPLETE_UNLOCK_USER, userId).sendToTarget();
|
||||||
|
if (mRemountCurrentUserVolumesOnUnlock && userId == mCurrentUserId) {
|
||||||
|
maybeRemountVolumes(userId);
|
||||||
|
mRemountCurrentUserVolumesOnUnlock = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completeUnlockUser(int userId) {
|
private void completeUnlockUser(int userId) {
|
||||||
@@ -1255,7 +1270,7 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUserSwitching(int userId) {
|
private void maybeRemountVolumes(int userId) {
|
||||||
boolean reset = false;
|
boolean reset = false;
|
||||||
List<VolumeInfo> volumesToRemount = new ArrayList<>();
|
List<VolumeInfo> volumesToRemount = new ArrayList<>();
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@@ -1272,6 +1287,7 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (VolumeInfo vol : volumesToRemount) {
|
for (VolumeInfo vol : volumesToRemount) {
|
||||||
|
Slog.i(TAG, "Remounting volume for user: " + userId + ". Volume: " + vol);
|
||||||
mHandler.obtainMessage(H_VOLUME_UNMOUNT, vol).sendToTarget();
|
mHandler.obtainMessage(H_VOLUME_UNMOUNT, vol).sendToTarget();
|
||||||
mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
|
mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user