Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d11b047 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by The Android Automerger
Browse files

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
parent 67a150a9
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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) {