Some applications encounter a file access error in /storage/emulated/0/
like
[E] System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/Android/data/com.fgol.HungrySharkEvolution/files/test" is denied.
Michael pointed out the root cause is the init.rc of AOSP will set owner,
group and permissions of /config/sdcardfs before sdcardfs module is loaded.
Previously we don't always load sdcardfs module since it doesn't work in
some cases (e.g., /data is mounted on tmpfs). However, to fix the issue,
let sdcardfs always be loaded in early-init stage, and use the property
ro.sys.sdcardfs to decide whether to enable sdcardfs.
# enable sdcardfs if /data is not mounted on tmpfs or 9p
mount | grep /data\ | grep -qE 'tmpfs|9p'
- [ $? -ne 0 ] && modprobe sdcardfs
+ [ $? -eq 0 ] && set_prop_if_empty ro.sys.sdcardfs false
# remove wl if it's not used
local wifi
export EGL_LOG_LEVEL info
# export EGL_DRIVERS egl_dri2
+ exec u:r:init:s0 -- /sbin/modprobe sdcardfs
+
on init
on fs