platform_system_vold/model
Arnab Sen f96d81f5cd SM: Change volume mountUserId for new user
When a volume is ejected from a user but not removed from the device
and mounted again by calling StorageManager#mount, the volume is
mounted for the user from which it was last ejected. This causes the
path of the mounted volume to be inaccessible to the current user.

Whenever StorageManager#mount is called, check if the
VolumeInfo#mountUserId is same as the current userId maintained by
StorageManagerService, if it is not, change the mountUserId for the
Volume to the current userId known to StorageManagerService if it
is not the primary volume and the volume is visible.
This change also fixes a bug where the volumes are unmounted for the
wrong user which causes StorageSessionController go out of sync
which would cause errors during mounting the volumes again as it
maintains sessions per user. The bug also caused volume event
broadcasts to be sent to wrong user handles. To solve the issue
add an extra paramter in IVoldListener#onVolumeStateChanged for userId
which will update the copy which is used for informing
StorageSessionController and also for sending broadcasts.

Test: Perform the following steps:
1. Format SD Card as portable storage in system user.
2. Eject the SD Card from Storage Settings.
3. Switch to a non-system user
4. Mount the SD Card again.
5. Check that the Storage Summary is shown correctly instead
   of 0B out of 0B.
Also, checked from the logs the volume state broadcasts are sent to
the correct user handles.

Change-Id: I60b8954cdaee4a54ea6a6299fe5ddda2006faf1c
2023-07-14 09:55:37 +00:00
..
Disk.cpp Expand virtio_block check to other virtual devices 2020-05-16 00:02:21 +00:00
Disk.h Remove StubVolume disks upon vold reset events 2021-12-08 09:37:53 +09:00
EmulatedVolume.cpp Add persist.sys.fuse.bpf.override 2022-12-14 15:00:20 -08:00
EmulatedVolume.h Add persist.sys.fuse.bpf.override 2022-12-14 15:00:20 -08:00
ObbVolume.cpp Remove broken code for mounting encrypted OBB files 2022-03-01 21:19:18 +00:00
ObbVolume.h Remove broken code for mounting encrypted OBB files 2022-03-01 21:19:18 +00:00
PrivateVolume.cpp Remove write permission from file mode of top-level user dirs 2023-06-08 22:16:25 +00:00
PrivateVolume.h Introduce postMount() VolumeBase helper. 2020-05-04 15:09:32 +02:00
PublicVolume.cpp Merge "[vold] Add mount lazy if forcemount fail." 2023-04-25 10:32:16 +00:00
PublicVolume.h Conditionally use sdcardfs. 2020-01-07 09:03:35 +01:00
StubVolume.cpp Add disk for StubVolume 2020-02-12 07:42:40 +00:00
StubVolume.h Add disk for StubVolume 2020-02-12 07:42:40 +00:00
VolumeBase.cpp SM: Change volume mountUserId for new user 2023-07-14 09:55:37 +00:00
VolumeBase.h Split MOUNT_FLAG_VISIBLE into MOUNT_FLAG_VISIBLE_FOR_{READ, WRITE} 2021-11-25 13:04:45 +09:00
VolumeEncryption.cpp vold: use __ANDROID_API_Q__ instead of pre_gki_level 2020-08-10 11:45:08 -07:00
VolumeEncryption.h On newer devices, use dm-default-key to encrypt SD cards 2020-02-18 13:01:00 -08:00