Skip to content

Commit

Permalink
Support /odm/etc/ & /my_product/etc/ (#6)
Browse files Browse the repository at this point in the history
* Support /odm/etc/ & /my_product/etc/

- Support /odm/etc/ & /my_product/etc/ audio files
- Support stage_policy.conf
- Remove duplicate
- Fix context

* Mount bind

- Mount bind of support /odm/etc/ & /my_product/etc/ audio files

* Fix permissions for Nougat and bellow

* Tidy up

* Added support for Magisk Delta Canary

- Magisk Delta Canary now supports $MAGISKTMP/.magisk/mirror/odm & $MAGISKTMP/.magisk/mirror/my_product
- Fixed permissions

* Fix Bug

Fix /odm/etc/ & /my_product/etc files umount & mount failures in Magisk Delta Canary
  • Loading branch information
reiryuki authored Jul 7, 2023
1 parent 84caa64 commit 58e2ecb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
24 changes: 19 additions & 5 deletions post-fs-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,25 @@ osp_detect() {
exec 2>$MODPATH/debug-pfsd.log
set -x

# Paths
MIRROR=$MAGISKTMP/mirror
SYSTEM=`realpath $MIRROR/system`
VENDOR=`realpath $MIRROR/vendor`
ODM=`realpath $MIRROR/odm`
MY_PRODUCT=`realpath $MIRROR/my_product`

# Restore and reset
. $MODPATH/uninstall.sh
rm -rf $amldir $MODPATH/system $MODPATH/errors.txt $MODPATH/system.prop
[ -f "$moddir/acdb/post-fs-data.sh" ] && mv -f $moddir/acdb/post-fs-data.sh $moddir/acdb/post-fs-data.sh.bak
mkdir $amldir
# Don't follow symlinks
files="$(find $MAGISKTMP/mirror/system_root/system $MAGISKTMP/mirror/system $MAGISKTMP/mirror/vendor -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml" -o -name "*audio_*policy*.conf" -o -name "*audio_*policy*.xml" -o -name "*mixer_paths*.xml" -o -name "*mixer_gains*.xml" -o -name "*audio_device*.xml" -o -name "*sapa_feature*.xml" -o -name "*audio_platform_info*.xml" -o -name "*audio_configs*.xml" -o -name "*audio_device*.xml")"
lists="*audio*effects*.conf -o -name *audio*effects*.xml\
-o -name *policy*.conf -o -name *policy*.xml\
-o -name *mixer*paths*.xml -o -name *mixer*gains*.xml\
-o -name *audio*device*.xml -o -name *sapa*feature*.xml\
-o -name *audio*platform*info*.xml -o -name *audio*configs*.xml"
files="$(find $SYSTEM $VENDOR $ODM $MY_PRODUCT -type f -name $lists)"
for file in $files; do
name=$(echo "$file" | sed -e "s|$MAGISKTMP/mirror||" -e "s|/system_root/|/|" -e "s|/system/|/|")
cp_mv -c $file $MODPATH/system$name
Expand All @@ -74,7 +86,7 @@ for mod in $(find $moddir/* -maxdepth 0 -type d ! -name aml); do
modname="$(basename $mod)"
[ -f "$mod/disable" ] && continue
# Move files
files="$(find $mod/system -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml" -o -name "*audio_*policy*.conf" -o -name "*audio_*policy*.xml" -o -name "*mixer_paths*.xml" -o -name "*mixer_gains*.xml" -o -name "*audio_device*.xml" -o -name "*sapa_feature*.xml" -o -name "*audio_platform_info*.xml" -o -name "*audio_configs*.xml" -o -name "*audio_device*.xml" 2>/dev/null)"
files="$(find $mod/system -type f -name $lists 2>/dev/null)"
[ "$files" ] && echo "$modname" >> $amldir/modlist || continue
for file in $files; do
cp_mv -m $file $amldir/$modname/$(echo "$file" | sed "s|$mod/||")
Expand All @@ -90,8 +102,10 @@ done

# Set perms and such
set_perm_recursive $MODPATH/system 0 0 0755 0644
if [ -d $MODPATH/system/vendor ]; then
set_perm_recursive $MODPATH/system/vendor 0 0 0755 0644 u:object_r:vendor_file:s0
[ -d $MODPATH/system/vendor/etc ] && set_perm_recursive $MODPATH/system/vendor/etc 0 0 0755 0644 u:object_r:vendor_configs_file:s0
if [ $API -ge 26 ]; then
set_perm_recursive $MODPATH/system/vendor 0 2000 0755 0644 u:object_r:vendor_file:s0
set_perm_recursive $MODPATH/system/vendor/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0
set_perm_recursive $MODPATH/system/vendor/odm/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0
set_perm_recursive $MODPATH/system/odm/etc 0 0 0755 0644 u:object_r:vendor_configs_file:s0
fi
exit 0
6 changes: 4 additions & 2 deletions service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ for mod in $(find $moddir/* -maxdepth 0 -type d ! -name aml); do
done

# Reload patched files - original mounted files are seemingly deleted and replaced by sed
for i in $(find $MODPATH/system -type f); do
j="$(echo $i | sed "s|$MODPATH||")"
dir=$MODPATH/system
files=$(find $dir -type f)
for i in $files; do
j="$(echo $i | sed "s|$dir||")"
umount $j
mount -o bind $i $j
done
Expand Down

0 comments on commit 58e2ecb

Please sign in to comment.