sdm660-common: create and symlink a dummy /metadata/apex

Google moved apex sessions directory from /data/apex/sessions to
/metadata/apex/sessions after commit:

"Move apex sessions directory to /metadata"
36cf4bbac6

Devices with a mounted metadata partition will have the needed
directories set up by system/core/rootdir/init.rc. Xiaomi devices
on sm6125 do not have a metadata partition out of the box, so things
like "Google Play system update" will fail to install the update.

Therefore, create a dummy directory under /data/vendor/metadata_apex
and symlink it to /metadata/apex.

The reason why the old /data/apex/sessions directory is not used
for the symlink is that apexd will call migrateSessionsDirIfNeeded()
to recursively copy things from the old directory to the new one.
Creating the symlink from /data/apex/sessions may result in
unintended behaviors.

Signed-off-by: OdSazib <odsazib@gmail.com>
This commit is contained in:
Chenyang Zhong 2021-02-09 11:04:23 +06:00 committed by OdSazib
parent 00956a4e88
commit 851d88070e
No known key found for this signature in database
GPG key ID: B678DBD07079B021
5 changed files with 20 additions and 2 deletions

View file

@ -130,6 +130,14 @@ $(EGL_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
ALL_DEFAULT_INSTALLED_MODULES += $(EGL_SYMLINKS)
METADATA_SYMLINK := $(TARGET_ROOT_OUT)/metadata
$(METADATA_SYMLINK): $(LOCAL_INSTALLED_MODULE)
@echo "Creating $@"
@mkdir -p $(TARGET_ROOT_OUT)/metadata
$(hide) ln -sf /data/vendor/metadata_apex $@/apex
ALL_DEFAULT_INSTALLED_MODULES += $(METADATA_SYMLINK)
subdir_makefiles=$(call first-makefiles-under,$(LOCAL_PATH))
$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
endif

View file

@ -232,6 +232,10 @@ on post-fs-data
# Create directory used by display clients
mkdir /data/vendor/display 0770 system graphics
# Create apex symlinked dirs
mkdir /data/vendor/metadata_apex 0755 root system
mkdir /data/vendor/metadata_apex/sessions 0700 root system
# Change lm related dirs
mkdir /data/vendor/lm 0700 root root

View file

@ -1,3 +1,7 @@
# Apex Metadata
/data/vendor/metadata_apex(/.*)? u:object_r:apex_metadata_file:s0
/data/vendor/metadata_apex/sessions(/.*)? u:object_r:apex_metadata_file:s0
# Executables
/system/bin/chargeonlymode u:object_r:charger_exec:s0

1
sepolicy/vendor/apexd.te vendored Normal file
View file

@ -0,0 +1 @@
allow apexd apex_metadata_file:lnk_file r_file_perms;

View file

@ -8,6 +8,7 @@ allow vendor_init {
camera_data_file
}:dir { create search getattr open read setattr ioctl write add_name remove_name rmdir relabelfrom };
allow vendor_init apex_metadata_file:dir create_dir_perms;
allow vendor_init fingerprint_data_file:dir {setattr create};
allow vendor_init media_rw_data_file:file { getattr relabelfrom };
allow vendor_init persist_debug_prop:file read;