Track current user without calling into AMS.
From a layering point-of-view, StorageManager is below ActivityManager and it shouldn't be calling upwards, since that risks locking inversions. Instead, track the current user through the existing SystemService callbacks. Bug: 28598527 Change-Id: I02d3277eb26288d3b4e1897f4c9318a6288c9551
This commit is contained in:
@@ -177,6 +177,11 @@ class MountService extends IMountService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchUser(int userHandle) {
|
||||
mMountService.mCurrentUserId = userHandle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnlockUser(int userHandle) {
|
||||
mMountService.onUnlockUser(userHandle);
|
||||
@@ -320,6 +325,8 @@ class MountService extends IMountService.Stub
|
||||
@GuardedBy("mLock")
|
||||
private String mMoveTargetUuid;
|
||||
|
||||
private volatile int mCurrentUserId = UserHandle.USER_SYSTEM;
|
||||
|
||||
private VolumeInfo findVolumeByIdOrThrow(String id) {
|
||||
synchronized (mLock) {
|
||||
final VolumeInfo vol = mVolumes.get(id);
|
||||
@@ -1285,7 +1292,7 @@ class MountService extends IMountService.Stub
|
||||
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
|
||||
}
|
||||
|
||||
vol.mountUserId = ActivityManager.getCurrentUser();
|
||||
vol.mountUserId = mCurrentUserId;
|
||||
mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
|
||||
|
||||
} else if (vol.type == VolumeInfo.TYPE_PRIVATE) {
|
||||
|
||||
Reference in New Issue
Block a user