Skip to content

Commit bc0c9a0

Browse files
committed
v4.0
1 parent 0bf6208 commit bc0c9a0

File tree

11 files changed

+265
-210
lines changed

11 files changed

+265
-210
lines changed

.gitattributes

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

AudioModificationLibrary.sh

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ patch_cfgs -pl sonyeffect af8da7e0-2ca1-11e3-b71d-0002a5d5c51b sonyeffect_sw 507
4949
#libatmos.so~74697567-7261-6564-6864-65726f206678
5050
patch_cfgs dolbyatmos 74697567-7261-6564-6864-65726f206678 dolbyatmos $libfile
5151
osp_detect "alarm notification ring"
52+
#libswdap_ds1se.so~74697567-7261-6564-6864-65726f206678
53+
patch_cfgs dolbyatmos 74697567-7261-6564-6864-65726f206678 dolbyatmos $libfile
54+
osp_detect "alarm notification ring"
5255
#libdtsaudio.so~146edfc0-7ed2-11e4-80eb-0002a5d5c51b
5356
patch_cfgs -ole music dtsaudio 146edfc0-7ed2-11e4-80eb-0002a5d5c51b dtsaudio $libfile
5457
#end

META-INF/com/google/android/update-binary

100644100755
File mode changed.

META-INF/com/google/android/updater-script

100644100755
File mode changed.

README.md

100644100755
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Audio Modification Library
2-
AudModLib is a compatibility framework that allows the seamless integration of multiple audio mods for Magisk installs. [More details in support thread](https://forum.xda-developers.com/apps/magisk/mod-audio-modification-library-t3745466).<br/>
2+
AudModLib is a compatibility framework that allows the seamless integration of multiple audio mods for Magisk installs. Enables supported audio mods to share the same needed files sudo as audio_effects. [More details in support thread](https://forum.xda-developers.com/apps/magisk/mod-audio-modification-library-t3745466).<br/>
33
To uninstall, REMOVE WITH MAGISK MANAGER
44

55
## Change Log
6+
### v4.0 - x.xx.2020
7+
* Reworked boot scripts - no more time limitation
8+
* Misc bug fixes
9+
* Removed prop processing
10+
* Allow use of "aml.sh" in addition to ".aml.sh" scripts
11+
* Added support for another dolby mod
12+
* Updated for Android 11
13+
* Only copy files to aml if needed by other mods
14+
615
### v3.5 - 4.22.2020
716
* Fixed bug with proxy effect patching
817

customize.sh

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ for i in $MODPATH/.scripts/*; do
2424
libs="$libs-name \"$(basename $i | sed "s/~.*//")\" "
2525
done
2626
libs="$(echo $libs | sed "s/\" /\" -o /g")"
27+
sed -i -e "s|<libs>|$libs|" $MODPATH/service.sh
2728

2829
# Set vars in script
2930
amldir=$NVBASE/aml
30-
[ $API -ge 26 ] && libdir="/vendor" || libdir="/system"
31-
sed -i -e "s|moddir=|moddir=$NVBASE/modules|" -e "s|amldir=|amldir=$amldir|" $MODPATH/uninstall.sh
32-
sed -i -e "s|<libs>|$libs|" -e "s|MODPATH=|MODPATH=$(echo $MODPATH | sed 's/modules_update/modules/')|" $MODPATH/post-fs-data.sh
33-
for i in MAGISKTMP API IS64BIT libdir amldir; do
34-
sed -i "s|$i=|$i=$(eval echo \$$i)|" $MODPATH/post-fs-data.sh
31+
moddir=$NVBASE/modules
32+
for i in API amldir moddir; do
33+
for j in post-fs-data service uninstall; do
34+
sed -i "s|$i=|$i=$(eval echo \$$i)|" $MODPATH/$j.sh
35+
done
3536
done
3637

3738
# Place fallback script in the event idiot user deletes aml module in file explorer
3839
cp -f $MODPATH/uninstall.sh $SERVICED/aml.sh && chmod 0755 $SERVICED/aml.sh
39-
sed -i "1a[ -d \"$(echo $MODPATH | sed 's/modules_update/modules/')\" ] && exit 0" $SERVICED/aml.sh
40+
sed -i "3a[ -d \"\$moddir/$MODID\" ] && exit 0" $SERVICED/aml.sh
4041
echo 'rm -f $0' >> $SERVICED/aml.sh

module.prop

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=aml
22
name=Audio Modification Library
3-
version=v3.5
4-
versionCode=54
3+
version=v4.0
4+
versionCode=55
55
author=zackptg5, ahrion
66
description=AudModLib is a framework that allows the seamless integration of multiple audio mods in Magisk.
77
support=https://forum.xda-developers.com/apps/magisk/module-audio-modification-library-t3579612

post-fs-data.sh

100644100755
Lines changed: 20 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
#!/system/bin/sh
21
# Variables
3-
MODPATH=
4-
MAGISKTMP=
2+
# magisk --path isn't accessible during till part way through post-fs-data
3+
[ -d "/sbin/.magisk" ] && MAGISKTMP="/sbin/.magisk" || MAGISKTMP="$(find /dev -mindepth 2 -maxdepth 2 -type d -name ".magisk")"
4+
MODPATH=$MAGISKTMP/modules/aml
55
API=
6-
IS64BIT=
7-
libdir=
8-
exec 2>$MODPATH/debug.log
9-
set -x
10-
echo `date +%S`
11-
moddir=$(dirname $MODPATH)
12-
amldir=/data/adb/aml
6+
moddir=
7+
amldir=
138

149
# Functions
1510
set_perm() {
@@ -55,164 +50,10 @@ osp_detect() {
5550
done
5651
return 0
5752
}
58-
patch_cfgs() {
59-
local first=true files="" file lib=false effect=false outsp=false proxy=false replace=false libname libpath effname uid libname_sw uid_sw libname_hw uid_hw libpathsw libpathhw conf xml
60-
local opt=`getopt :fleoqpr "$@"`
61-
eval set -- "$opt"
62-
while true; do
63-
case "$1" in
64-
-f) files="placeholder"; shift;;
65-
-l) lib=true; first=false; shift;;
66-
-e) effect=true; first=false; shift;;
67-
-o) outsp=true; conf=output_session_processing; xml=postprocess; first=false; shift;;
68-
-q) outsp=true; conf=pre_processing; xml=preprocess; first=false; shift;;
69-
-p) proxy=true; effect=false; outsp=false; first=false; shift;;
70-
-r) replace=true; shift;;
71-
--) shift; break;;
72-
*) return 1;;
73-
esac
74-
done
75-
[ -z "$files" ] && files=$(find $MODPATH/system -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml") || { files="$1"; shift; }
76-
$first && { lib=true; effect=true; }
77-
if $proxy; then
78-
effname=$1; uid=${2:?}; shift 2
79-
libname_sw=$1; uid_sw=${2:?}; shift 2
80-
$lib && { libpathsw=$1; shift; }
81-
libname_hw=$1; uid_hw=${2:?}; shift 2
82-
$lib && { libpathhw=${1:?}; shift; }
83-
else
84-
$outsp && { type=${1:?}; shift; }
85-
{ $effect || $outsp; } && { effname=${1:?}; shift; }
86-
$effect && { uid=${1:?}; shift; }
87-
{ $lib || $effect; } && { libname=${1:?}; shift; }
88-
$lib && { libpath=${1:?}; shift; }
89-
fi
90-
for file in $files; do
91-
case "$file" in
92-
*.conf)
93-
if $proxy; then
94-
if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ $effname {/,/^ }/p}" $file)" ]; then
95-
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/")
96-
sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file
97-
fi
98-
[ ! "$(sed -n "/^effects {/,/^}/ {/^ $effname {/,/^ }/p}" $file)" ] && sed -i "s/^effects {/effects {\n $effname {\n library proxy\n uuid $uid\n\n libsw {\n library $libname_sw\n uuid $uid_sw\n }\n\n libhw {\n library $libname_hw\n uuid $uid_hw\n }\n }/g" $file
99-
if $lib; then
100-
patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
101-
if $replace; then
102-
patch_cfgs -frl "$file" "$libname_sw" "$libpathsw"
103-
patch_cfgs -frl "$file" "$libname_hw" "$libpathhw"
104-
else
105-
patch_cfgs -fl "$file" "$libname_sw" "$libpathsw"
106-
patch_cfgs -fl "$file" "$libname_hw" "$libpathhw"
107-
fi
108-
fi
109-
else
110-
if $lib; then
111-
if $replace && [ "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ]; then
112-
spaces=$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/p}" $file | sed -r "s/( *).*/\1/")
113-
sed -i "/^libraries {/,/^}/ {/^$spaces$libname {/,/^$spaces}/d}" $file
114-
fi
115-
[ ! "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ] && sed -i "s|^libraries {|libraries {\n $libname {\n path $libpath\n }|" $file
116-
fi
117-
if $effect; then
118-
if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ]; then
119-
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/")
120-
sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file
121-
fi
122-
[ ! "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ] && sed -i "s|^effects {|effects {\n $effname {\n library $libname\n uuid $uid\n }|" $file
123-
fi
124-
if $outsp && [ "$API" -ge 26 ]; then
125-
local OIFS=$IFS; local IFS=','
126-
for i in $type; do
127-
if [ ! "$(sed -n "/^$conf {/,/^}/p" $file)" ]; then
128-
echo -e "\n$conf {\n $i {\n $effname {\n }\n }\n}" >> $file
129-
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/p}" $file)" ]; then
130-
sed -i "/^$conf {/,/^}/ s/$conf {/$conf {\n $i {\n $effname {\n }\n }/" $file
131-
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/ {/$effname {/,/}/p}}" $file)" ]; then
132-
sed -i "/^$conf {/,/^}/ {/$i {/,/^ }/ s/$i {/$i {\n $effname {\n }/}" $file
133-
fi
134-
done
135-
local IFS=$OIFS
136-
fi
137-
fi
138-
;;
139-
*.xml)
140-
if $proxy; then
141-
if $replace && [ "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" -o "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" ]; then
142-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/d}" $file
143-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/d}" $file
144-
fi
145-
[ ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" -a ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*>/,/^ *\/>/p}" $file)" ] && sed -i -e "/<effects>/ a\ <effectProxy name=\"$effname\" library=\"proxy\" uuid=\"$uid\">\n <libsw library=\"$libname_sw\" uuid=\"$uid_sw\"\/>\n <libhw library=\"$libname_hw\" uuid=\"$uid_hw\"\/>\n <\/effectProxy>" $file
146-
if $lib; then
147-
patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
148-
if $replace; then
149-
patch_cfgs -frl "$file" "$libname_sw" "$libpathsw"
150-
patch_cfgs -frl "$file" "$libname_hw" "$libpathhw"
151-
else
152-
patch_cfgs -fl "$file" "$libname_sw" "$libpathsw"
153-
patch_cfgs -fl "$file" "$libname_hw" "$libpathhw"
154-
fi
155-
fi
156-
else
157-
if $lib; then
158-
if $replace && [ "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ]; then
159-
sed -i "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/d}" $file
160-
fi
161-
[ ! "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ] && sed -i "/<libraries>/ a\ <library name=\"$libname\" path=\"$(basename $libpath)\"\/>" $file
162-
fi
163-
if $effect; then
164-
if $replace && [ "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" -o "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" ]; then
165-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/d}" $file
166-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/d}" $file
167-
fi
168-
[ ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" ] && sed -i "/<effects>/ a\ <effect name=\"$effname\" library=\"$(basename $libname)\" uuid=\"$uid\"\/>" $file
169-
fi
170-
if $outsp && [ "$API" -ge 26 ]; then
171-
local OIFS=$IFS; local IFS=','
172-
for i in $type; do
173-
if [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/p" $file)" ]; then
174-
sed -i "/<\/audio_effects_conf>/i\ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>\n <\/$xml>" $file
175-
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/p}" $file)" ]; then
176-
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ s/ <$xml>/ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>/" $file
177-
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ {/^ *<apply effect=\"$effname\"\/>/p}}" $file)" ]; then
178-
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ s/<stream type=\"$type\">/<stream type=\"$type\">\n <apply effect=\"$effname\"\/>/}" $file
179-
fi
180-
done
181-
local IFS=$OIFS
182-
fi
183-
fi
184-
;;
185-
esac
186-
done
187-
return 0
188-
}
189-
prop_process() {
190-
local propfile=$1
191-
sed -i "/^$/d" $propfile
192-
[ "$(tail -1 $propfile)" ] && echo >> $propfile
193-
while read prop; do
194-
[ ! "$prop" ] && break
195-
local tprop=$(echo "$prop" | sed -r "s/(.*)=.*/\1/")
196-
if [ ! "$(grep "$tprop" $MODPATH/system.prop 2>/dev/null)" ]; then
197-
echo "$prop" >> $MODPATH/system.prop
198-
elif [ "$(grep "^$tprop" $MODPATH/system.prop 2>/dev/null)" ] && [ ! "$(grep "^$prop" $MODPATH/system.prop 2>/dev/null)" ]; then
199-
sed -i "s|^$tprop|^#$tprop|" $MODPATH/system.prop
200-
echo "#$prop" >> $MODPATH/system.prop
201-
echo "Conflicting props: $tprop and $prop" >> $MODPATH/errors.txt
202-
fi
203-
done < $propfile
204-
return 0
205-
}
206-
legacy_script() {
207-
local RUNONCE=false COUNT=1 LIBDIR=$libdir/lib/soundfx MOD=$mod
208-
(. $mod/.aml.sh) || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt
209-
for file in $files; do
210-
local NAME=$(echo "$file" | sed "s|$mod|system|")
211-
$RUNONCE || { case $file in
212-
*audio_effects*) (. $mod/.aml.sh) || [ "$(grep -x "$modname" $MODPATH/errors.txt)" ] || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt; COUNT=$(($COUNT + 1));;
213-
esac; }
214-
done
215-
}
53+
54+
# Debug
55+
exec 2>$MODPATH/debug-pfsd.log
56+
set -x
21657

21758
# Restore and reset
21859
. $MODPATH/uninstall.sh
@@ -224,47 +65,27 @@ files="$(find $MAGISKTMP/mirror/system_root/system $MAGISKTMP/mirror/system $MAG
22465
for file in $files; do
22566
name=$(echo "$file" | sed -e "s|$MAGISKTMP/mirror||" -e "s|/system_root/|/|" -e "s|/system/|/|")
22667
cp_mv -c $file $MODPATH/system$name
68+
modfiles="/system$name $modfiles"
22769
done
22870
osp_detect "music"
22971

230-
# Detect/install audio mods
231-
for mod in $(find $moddir/* -maxdepth 0 -type d ! -name "aml"); do
72+
# Detect/move audio mod files
73+
for mod in $(find $moddir/* -maxdepth 0 -type d ! -name aml); do
23274
modname="$(basename $mod)"
23375
[ -f "$mod/disable" ] && continue
23476
# Move files
23577
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)"
236-
[ "$files" ] && echo "$modname" >> $amldir/modlist
78+
[ "$files" ] && echo "$modname" >> $amldir/modlist || continue
23779
for file in $files; do
23880
cp_mv -m $file $amldir/$modname/$(echo "$file" | sed "s|$mod/||")
23981
done
240-
# .aml.sh file should take precedence
241-
if [ -f "$mod/.aml.sh" ]; then
242-
grep -qx "$modname" $amldir/modlist || echo "$modname" >> $amldir/modlist
243-
if grep -qE '\$MODPATH/\$NAME|RUNONCE=|COUNT=' $mod/.aml.sh; then
244-
legacy_script
245-
else
246-
(. $mod/.aml.sh) || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt
247-
fi
248-
else
249-
# Favor vendor libs over system ones, no aml builtins are 64bit only - use 32bit lib dir
250-
libs="$(find $mod/system/vendor/lib/soundfx $mod/system/lib/soundfx -type f <libs> 2>/dev/null)"
251-
for lib in $libs; do
252-
for audmod in $MODPATH/.scripts/$(basename $lib)~*; do
253-
uuid=$(basename $audmod | sed -r "s/.*~(.*).sh/\1/")
254-
hexuuid="$(echo $uuid | sed -r -e "s/^(..)(..)(..)(..)-(..)(..)-(..)(..)-/\4\3\2\1\6\5\8\7-/" -e "s/-(..)(..)-(............)$/\2\1\3/")"
255-
xxd -p $lib | tr -d '\n' | grep -q "$hexuuid"
256-
[ $? -eq 0 ] || continue
257-
$(grep -xq "$modname" $amldir/modlist) || echo "$modname" >> $amldir/modlist
258-
libfile="$(echo $lib | sed -e "s|$mod||" -e "s|/system/vendor|/vendor|")"
259-
. $audmod
260-
done
261-
done
262-
fi
263-
if $(grep -x "$modname" $amldir/modlist); then
264-
[ -s "$mod/system.prop" ] && { prop_process $mod/system.prop; cp_mv -m $mod/system.prop $amldir/$modname/system.prop; }
265-
# Chcon fix for Android Q+
266-
[ $API -ge 29 ] && chcon -R u:object_r:vendor_file:s0 $mod/system/vendor/lib*/soundfx 2>/dev/null
267-
fi
82+
# Chcon fix for Android Q+
83+
[ $API -ge 29 ] && chcon -R u:object_r:vendor_file:s0 $mod/system/vendor/lib*/soundfx 2>/dev/null
84+
done
85+
86+
# Remove unneeded files from aml
87+
for file in $modfiles; do
88+
[ "$(find $amldir -type f -path "*$file")" ] || rm -f $MODPATH$file
26889
done
26990

27091
# Set perms and such
@@ -273,5 +94,4 @@ if [ -d $MODPATH/system/vendor ]; then
27394
set_perm_recursive $MODPATH/system/vendor 0 0 0755 0644 u:object_r:vendor_file:s0
27495
[ -d $MODPATH/system/vendor/etc ] && set_perm_recursive $MODPATH/system/vendor/etc 0 0 0755 0644 u:object_r:vendor_configs_file:s0
27596
fi
276-
echo `date +%S`
27797
exit 0

0 commit comments

Comments
 (0)