Loading
Fix external storage access with system user locked
Make adaptations that allow secondary users to access (their own)
external storage even if the system user is locked, so that when the
system is configured to allow this, it works properly.
* Do not require the system user to be unlocked in order to initialize
external storage; allow any full user (i.e. non-profile) to do so.
Under typical circumstances, the system user will be unlocked first.
AOSP appeared to rely on that idea - along with the idea that
the system user would only be unlocked once - as a way to assure
that system-wide access to external storage was initialized just once
and at an appropriate time. However, if settings allow switching
users when the system user is locked, then a different full user may
unlock first, and that's a fine enough time to make external storage
available, considering that such users need external storage, too.
And we ensure it only (successfully) happens once by checking that
the component name assigned during initialization has yet to be set.
* Don't falsely report that volumes are unmounted just because the
system user (user 0) is locked. Instead, check the calling user
itself, or rather its parent if it is a profile.
This AOSP behavior that we're altering was added as part of a legacy
obb data migration, as a way to prevent listing volumes when that
migration is still in progress. The volumes would be reported as
unmounted during that time. That migration is specific to user 0
and has no effect on other users; so, if user 0 is locked, it's
of no consequence to users outside of its profile group, since they
cannot access its data by design.
Test: Manual: Create a new user. `adb shell settings put global \
allow_user_switching_when_system_user_locked 1`. Ensure your
main user has a PIN/password/pattern. Reboot. Switch to the
new user without unlocking the main user. Open Files. With this
change, you'll see folders. Without it, you'll see an error.
Change-Id: Ie832a65758d763a12f61ccbb46331a3d98de7268