├── .gitattributes ├── .gitignore ├── AudioModificationLibrary.sh ├── LICENSE ├── META-INF └── com │ └── google │ └── android │ ├── update-binary │ └── updater-script ├── README.md ├── changelog.md ├── customize.sh ├── install.zip ├── module.prop ├── post-fs-data.sh ├── service.sh ├── uninstall.sh └── update.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Declare files that will always have LF line endings on checkout. 2 | *.sh text eol=lf 3 | *.prop text eol=lf 4 | *.md text eol=lf 5 | META-INF/** text eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /AudioModificationLibrary.sh: -------------------------------------------------------------------------------- 1 | #libam3daudioenhancement.so~6723dd80-f0b7-11e0-98a2-0002a5d5c51b 2 | patch_cfgs am3daudioenhancement 6723dd80-f0b7-11e0-98a2-0002a5d5c51b am3daudioenhancement $libfile 3 | #libv4a_fx.so~41d3c987-e6cf-11e3-a88a-11aba5d5c51b 4 | patch_cfgs v4a_standard_fx 41d3c987-e6cf-11e3-a88a-11aba5d5c51b v4a_fx $libfile 5 | #libv4a_fx_ics.so~41d3c987-e6cf-11e3-a88a-11aba5d5c51b 6 | patch_cfgs v4a_standard_fx 41d3c987-e6cf-11e3-a88a-11aba5d5c51b v4a_fx $libfile 7 | #libv4a_xhifi_ics.so~d92c3a90-3e26-11e2-a25f-0800200c9a66 8 | patch_cfgs v4a_standard_xhifi d92c3a90-3e26-11e2-a25f-0800200c9a66 v4a_xhifi $libfile 9 | #libhwdax.so~9d4921da-8225-4f29-aefa-6e6f69726861 10 | patch_cfgs -pl dax 9d4921da-8225-4f29-aefa-6e6f69726861 dax_sw 6ab06da4-c516-4611-8166-6168726e6f69 $(dirname $libfile)/libswdax.so dax_hw a0c30891-8246-4aef-b8ad-696f6e726861 $libfile 11 | #libswdax.so~9d4921da-8225-4f29-aefa-6e6f69726861 12 | patch_cfgs dax 9d4921da-8225-4f29-aefa-6e6f69726861 dax $libfile 13 | #libswdap.so~9d4921da-8225-4f29-aefa-39537a04bcaa 14 | patch_cfgs dap 9d4921da-8225-4f29-aefa-39537a04bcaa dap $libfile 15 | #libhwdap.so~a0c30891-8246-4aef-b8ad-d53e26da0253 16 | patch_cfgs -pl dap 9d4921da-8225-4f29-aefa-6e6f69726861 dap_sw 6ab06da4-c516-4611-8166-452799218539 $(dirname $libfile)/libswdap.so dap_hw a0c30891-8246-4aef-b8ad-d53e26da0253 $libfile 17 | #libdseffect.so~9d4921da-8225-4f29-aefa-39537a04bcaa 18 | patch_cfgs dsplus 9d4921da-8225-4f29-aefa-39537a04bcaa ds $libfile 19 | #libswvlldp.so~3783c334-d3a0-4d13-874f-0032e5fb80e2 20 | patch_cfgs vlldp 3783c334-d3a0-4d13-874f-0032e5fb80e2 vlldp $libfile 21 | patch_cfgs -ole music atmos 9d4921da-8225-4f29-aefa-aacb40a73593 atmos $(dirname $libfile)/libatmos.so 22 | #libicepower.so~f1c02420-777f-11e3-981f-0800200c9a66 23 | patch_cfgs -l icepower $libfile 24 | patch_cfgs -e icepower_algo f1c02420-777f-11e3-981f-0800200c9a66 icepower 25 | patch_cfgs -e icepower_eq 50dbef80-4ad4-11e3-8f96-0800200c9a66 icepower 26 | patch_cfgs -e icepower_test e5456320-5391-11e3-8f96-0800200c9a66 icepower 27 | patch_cfgs -e icepower_load bf51a790-512b-11e3-8f96-0800200c9a66 icepower 28 | patch_cfgs -e icepower_null 63509430-52aa-11e3-8f96-0800200c9a66 icepower 29 | #libarkamys.so~17852d50-161e-11e2-892e-0800200c9a66 30 | patch_cfgs -ole music Arkamysfx 17852d50-161e-11e2-892e-0800200c9a66 arkamys $libfile 31 | #libdirac.so~4c6383e0-ff7d-11e0-b6d8-0002a5d5c51b 32 | patch_cfgs dirac 4c6383e0-ff7d-11e0-b6d8-0002a5d5c51b dirac $libfile 33 | patch_cfgs -e dirac_controller b437f4de-da28-449b-9673-667f8b9643fe dirac 34 | patch_cfgs -e dirac_music b437f4de-da28-449b-9673-667f8b964304 dirac 35 | #libdirac.so~e069d9e0-8329-11df-9168-0002a5d5c51b 36 | patch_cfgs -ole music dirac e069d9e0-8329-11df-9168-0002a5d5c51b dirac $libfile 37 | #libjamesdsp.so~f27317f4-c984-4de6-9a90-545759495bf2 38 | patch_cfgs jamesdsp f27317f4-c984-4de6-9a90-545759495bf2 jdsp $libfile 39 | #libmaxxeffect-cembedded.so~ae12da60-99ac-11df-b456-0002a5d5c51b 40 | patch_cfgs -ole music maxxaudio3 ae12da60-99ac-11df-b456-0002a5d5c51b maxxaudio3 $libfile 41 | #libbassboostMz.so~850b6319-bf66-4f93-bec0-dc6964367786 42 | patch_cfgs bassboostMz 850b6319-bf66-4f93-bec0-dc6964367786 bassboostMz $libfile 43 | patch_cfgs virtualizerMz 0e9779c9-4e8f-494d-b2b1-b4ad4e37c54c virtualizerMz $(dirname $libfile)/libvirtualizerMz.so 44 | patch_cfgs livemusicMz 0bbc89fe-52dc-4c40-8211-cae4da538b50 livemusicMz $(dirname $libfile)/liblivemusicMz.so 45 | patch_cfgs equalizerMz 9626da93-9c71-4bb2-8e23-9fc707fb9703 equalizerMz $(dirname $libfile)/ibequalizerMz.so 46 | #libsonysweffect.so~50786e95-da76-4557-976b-7981bdf6feb9 47 | patch_cfgs -qle mic,camcorder ZNR b8a031e0-6bbf-11e5-b9ef-0002a5d5c51b znrwrapper $(dirname $libfile)/libznrwrapper.so 48 | patch_cfgs -pl sonyeffect af8da7e0-2ca1-11e3-b71d-0002a5d5c51b sonyeffect_sw 50786e95-da76-4557-976b-7981bdf6feb9 $libfile sonyeffect_hw f9ed8ae0-1b9c-11e4-8900-0002a5d5c51b $(dirname $libfile)/libsonypostprocbundle.so 49 | #libatmos.so~74697567-7261-6564-6864-65726f206678 50 | patch_cfgs dolbyatmos 74697567-7261-6564-6864-65726f206678 dolbyatmos $libfile 51 | 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" 55 | #libdtsaudio.so~146edfc0-7ed2-11e4-80eb-0002a5d5c51b 56 | patch_cfgs -ole music dtsaudio 146edfc0-7ed2-11e4-80eb-0002a5d5c51b dtsaudio $libfile 57 | #libv4a_re.so~90380da3-8536-4744-a6a3-5731970e640f 58 | patch_cfgs v4a_re 90380da3-8536-4744-a6a3-5731970e640f v4a_re $libfile 59 | #end 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Zackptg5 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 -------------------------------------------------------------------------------- /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Audio Modification Library 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).
3 | To uninstall, REMOVE WITH MAGISK MANAGER 4 | 5 | ## Changelog 6 | * See [Changelog](changelog.md) 7 | 8 | ## Source Code 9 | * Module [GitHub](https://github.com/Zackptg5/Audio-Modification-Library) 10 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | ### v5.1 - 7.15.2023 2 | * Fix for magisk delta 3 | 4 | ### v5.0 - 7.10.2023 5 | * Big thanks to @reiryuki for this update 6 | * Update to current magisk module template - minimum magisk v20.4 7 | * Context fix 8 | * Add stage_policy.conf support 9 | * Add KSU support 10 | * Add support for other partitions - requires ksu or magisk delta 11 | * Rework/simplify some scripting 12 | * Fix for disabling aml in manager 13 | 14 | ### v4.2 - 1.6.2023 15 | * Add support for V4A RE 16 | 17 | ### v4.1 - 1.31.2022 18 | * Add support for magisk 24 module update method 19 | 20 | ### v4.0 - 9.15.2020 21 | * Reworked boot scripts - no more time limitation 22 | * Misc bug fixes 23 | * Removed prop processing 24 | * Allow use of "aml.sh" in addition to ".aml.sh" scripts 25 | * Added support for another dolby mod 26 | * Updated for Android 11 27 | * Only copy files to aml if needed by other mods 28 | 29 | ### v3.5 - 4.22.2020 30 | * Fixed bug with proxy effect patching 31 | 32 | ### v3.4 - 4.9.2020 33 | * Fix perms 34 | * Bug fixes 35 | 36 | ### v3.3 - 03.26.2020 37 | * Fixes for Magisk v20.4 38 | 39 | ### v3.2 - 03.17.2020 40 | * Restructured script for better efficiency/faster running time - may fix xposed issues 41 | * Fix prop issue where non-aml supported mods were affected 42 | * Favor module .aml.sh scripts over built-ins 43 | 44 | ### v3.1 - 03.14.2020 45 | * Enhanced osp_detect - needed for some mods 46 | * Added chcon fix for Q - may fix issues some users have with v4a/jdsp 47 | * Use proper contexts for aml files 48 | * Clean up script a little bit 49 | 50 | ### v3.0 - 03.13.2020 51 | * Complete overhaul - most everything happens in the boot script now, no need for redunduncies 52 | * Added Guitardedhero's Dolby Atmos Pie/Q 53 | * Added Ainur DTS 54 | * Removed IceWizard 55 | 56 | ### v2.5 - 12.30.2019 57 | * Update to new magisk module template - compatible with magisk 19+ only 58 | 59 | ### v2.4 - 5.20.2019 60 | * Fix for DTS mod osp effect 61 | 62 | ### v2.3 - 5.10.2019 63 | * More fixes for system as root devices 64 | 65 | ### v2.2 - 5.9.2019 66 | * Fix bootmode installation for system as root devices 67 | 68 | ### v2.1 - 4.3.2019 69 | * Fixed uninstall bug 70 | 71 | ### v2.0 - 3.28.2019 72 | * Updated to new magisk template - compatible with magisk 18+ only 73 | 74 | ### v1.9.4 - 2.28.2019 75 | * Bug fixes with mod detection and whatnot 76 | 77 | ### v1.9.3 - 2.21.2019 78 | * Small bug fix 79 | 80 | ### v1.9.2 - 12.19.2018 81 | * Rework usb policy patching so it's only for separate module - not applied to add devices by default now 82 | * Various bug fixes 83 | 84 | ### v1.9.1 - 12.17.2018 85 | * Fixed old bug with upgrades 86 | 87 | ### v1.9 - 12.16.2018 88 | * Updated for magisk v18 while maintaining backwards compatibility to 15.3 for those problem devices 89 | 90 | ### v1.8.5 - 12.6.2018 91 | * Added usb fix for v4a/xhifi (and likely other audio apps as well) 92 | 93 | ### v1.8.4 - 11.28.2018 94 | * Added support for audio_platform_info xml files 95 | 96 | ### v1.8.3 - 11.5.2018 97 | * Have AML remove patches for disabled mods/not patch disabled mods 98 | 99 | ### v1.8.2 - 10.22.2018 100 | * Bug fixes for pre_processing patches 101 | * Added capability for multiple pre/post processing patches (See documentation on support thread for usage) 102 | * Proxy entries must include it's own uuid now - allows for custom UUIDs (See documentation on support thread for usage) 103 | * Added Sony Xperia XZ2 104 | 105 | ### v1.8.1 - 9.2.2018 106 | * Updated to magisk 17 template while maintaining backwards compatibility for magisk 15.3+ 107 | 108 | ### v1.8 - 7.20.2018 109 | * Fix icewizard always showing error 110 | * Add capability to replace libraries and effects with patch_cfgs function (-r) 111 | * Change pre_processing patch_cfgs option to -q 112 | * Fix bug with proxy effects 113 | * Fix bugs with osp with xml files 114 | * Fix bug with squaresound 115 | 116 | ### v1.7.2 - 7.2.2018 117 | * Updated ice wizard patches 118 | * Delete osp rather than comment out 119 | 120 | ### v1.7.1 - 6.27.2018 121 | * Bug fix with osp_detect - should patch all cfgs now 122 | 123 | ### v1.7 - 6.19.2018 124 | * Added support for mixer_gains, audio_device, and sapa_feature xml files 125 | * Added RUNONCE option for custom AML scripts - allows them to only be run once instead of for each audio cfg file. Use this if your mod doesn't have cfg patches 126 | * Added COUNT variable. Can be used by custom AML scripts to determine how many times script has been run. Use this if your mod has cfg patches and other audio file patches 127 | * Fixed old bug with uninstall file restoration 128 | * Fixed bugs with boot script 129 | * Removed need to specify file with patch_cfgs function - make sure you update your aml.sh script for this 130 | * Added ainur squaresound 131 | 132 | ### v1.6.2 - 6.15.2018 133 | * Fixed mixed up libraries/effects 134 | * Fixed bug with acp 135 | 136 | ### v1.6.1 - 6.15.2018 137 | * Bug fixes for xml files 138 | 139 | ### v1.6 - 6.14.2018 140 | * Redid patching backend - huge thanks to Rezmir99 @xda-developers 141 | * Fully integrated aml.sh functionality - users can now user patch_cfgs function and LIBDIR variable like in AudioModificationLibrary.sh script - see support thread for instructions 142 | 143 | ### v1.5.7 - 4.26.2018 144 | * Add capability to import any audio mod with a ".aml.sh" file in the root of its magisk directory 145 | 146 | ### v1.5.6 - 4.12.2018 147 | * vendor file fix for devices with separate vendor partitions 148 | * misc fixes 149 | 150 | ### v1.5.5 - 4.12.2018 151 | * osp_detect fix 152 | 153 | ### v1.5.4 - 4.08.2018 154 | * dynamic effect removal fix 155 | 156 | ### v1.5.3 - 4.07.2018 157 | * V4A Fix 158 | 159 | ### v1.5.2 - 4.07.2018 160 | * Added materialized v4a 161 | * Use dynamic effect removal 162 | 163 | ### v1.5.1 - 3.30.2018 164 | * Fix effect removals 165 | 166 | ### v1.5 - 3.28.2018 167 | * Add soundalive and dha effect removal (needed for some samsung devices) 168 | * Pull ACP patch from ACP mod rather than static patch 169 | * Fine tuned osp patching 170 | 171 | ### v1.4.8 - 3.22.2018 172 | * Replaced ubdr with redone ACP 173 | 174 | ### v1.4.7 - 3.1.2018 175 | * Added new oreo Ice port 176 | 177 | ### v1.4.6 - 3.1.2018 178 | * Fixed lib directory issue with sauron 179 | 180 | ### v1.4.5 - 2.25.2018 181 | * Fixed vendor files in bootmode for devices with separate vendor partitions 182 | * Added detection of more policy files 183 | 184 | ### v1.4.4 - 2.16.2018 185 | * Fix prop logic for prop files that have empty lines in them 186 | * Fix xml file music_helper/sa3d patching 187 | 188 | ### v1.4.3 - 2.14.2018 189 | * Fix osp for htc and other weird devices 190 | * Get rid of vendor cfg creation - no need for it 191 | 192 | ### v1.4.2 - 2.12.2018 193 | * More osp fixes 194 | 195 | ### v1.4.1 - 2.9.2018 196 | * Attempt fix of osp 197 | * Added sa3d removal for samsung devices 198 | 199 | ### v1.4 - 2.9.2018 200 | * Fixed osp typo 201 | 202 | ### v1.3 - 2.8.2018 203 | * Fixed issues with output_session_processing patching 204 | 205 | ### v1.2 - 2.7.2018 206 | * Fixed janky bootmode stuff 207 | * Fix uninstall/upgrade when a supported audio mod has just been upgraded in bootmode 208 | 209 | ### v1.1 - 2.6.2018 210 | * Fixes for xml files 211 | * Various other fixes/improvements 212 | 213 | ### v1.0 - 2.5.2018 214 | * REBIRTH and initial release 215 | -------------------------------------------------------------------------------- /customize.sh: -------------------------------------------------------------------------------- 1 | ui_print " " 2 | ui_print " Mod detection and patching now happens at boot" 3 | ui_print " The boot script handles everything now" 4 | ui_print " " 5 | ui_print " Also note that disabled mods will be ignored!" 6 | ui_print " " 7 | 8 | # Escape each backslash and space since shell will expand it during echo 9 | sed -i -e 's/\\/\\\\/g' -e 's/\ /\\ /g' $MODPATH/AudioModificationLibrary.sh 10 | # Separate AML into individual files for each audio mod 11 | mkdir $MODPATH/.scripts 12 | while read line; do 13 | case $line in 14 | \#*) if [ "$uuid" ]; then 15 | echo " " >> $MODPATH/.scripts/$uuid.sh 16 | fi 17 | uuid=$(echo "$line" | sed "s/#//");; 18 | *) echo "$line" >> $MODPATH/.scripts/$uuid.sh;; 19 | esac 20 | done < $MODPATH/AudioModificationLibrary.sh 21 | rm -f $MODPATH/AudioModificationLibrary.sh 22 | # Generate libs var for faster script running 23 | for i in $MODPATH/.scripts/*; do 24 | libs="$libs-name \"$(basename $i | sed "s/~.*//")\" " 25 | done 26 | libs="$(echo $libs | sed "s/\" /\" -o /g")" 27 | sed -i -e "s||$libs|" $MODPATH/service.sh 28 | 29 | # Set vars in script 30 | [ -z $KSU ] && KSU=false 31 | [ -z $SERVICED ] && SERVICED=$NVBASE/service.d 32 | amldir=$NVBASE/aml 33 | for i in API amldir KSU MAGISK_VER; do 34 | for j in post-fs-data service uninstall; do 35 | sed -i "s|$i=|$i=$(eval echo \$$i)|" $MODPATH/$j.sh 36 | done 37 | done 38 | 39 | # Place fallback script in the event idiot user deletes aml module in file explorer 40 | mkdir $SERVICED 2>/dev/null 41 | cp -f $MODPATH/uninstall.sh $SERVICED/aml.sh 42 | chmod 0755 $SERVICED/aml.sh 43 | sed -i -e "3a[ -d \"\$moddir/$MODID\" -a ! -f \"\$moddir/$MODID/disable\" ] && exit 0" -e "s|^moddir=.*|moddir=$NVBASE/modules|" $SERVICED/aml.sh 44 | echo 'rm -f $0' >> $SERVICED/aml.sh 45 | 46 | rm -f $MODPATH/install.zip -------------------------------------------------------------------------------- /install.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zackptg5/Audio-Modification-Library/70330ae9ce4a98c4dfab7db8a646e920f0c65f7a/install.zip -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=aml 2 | name=Audio Modification Library 3 | version=v5.1 4 | versionCode=59 5 | author=zackptg5, ahrion 6 | description=AudModLib is a framework that allows the seamless integration of multiple audio mods in Magisk. 7 | support=https://forum.xda-developers.com/apps/magisk/module-audio-modification-library-t3579612 8 | updateJson=https://raw.githubusercontent.com/Zackptg5/Audio-Modification-Library/master/update.json 9 | -------------------------------------------------------------------------------- /post-fs-data.sh: -------------------------------------------------------------------------------- 1 | # Variables 2 | MODPATH="${0%/*}" 3 | amldir= 4 | API= 5 | KSU= 6 | MAGISK_VER= 7 | filenames="-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 -o -name *stage_policy*.conf" 8 | 9 | # Functions 10 | set_perm() { 11 | chown $2:$3 $1 || return 1 12 | chmod $4 $1 || return 1 13 | CON=$5 14 | [ -z $CON ] && CON=u:object_r:system_file:s0 15 | chcon $CON $1 || return 1 16 | } 17 | set_perm_recursive() { 18 | find $1 -type d 2>/dev/null | while read dir; do 19 | set_perm $dir $2 $3 $4 $6 20 | done 21 | find $1 -type f -o -type l 2>/dev/null | while read file; do 22 | set_perm $file $2 $3 $5 $6 23 | done 24 | } 25 | cp_mv() { 26 | mkdir -p "$(dirname "$3")" 27 | cp -af "$2" "$3" 28 | [ "$1" == "-m" ] && rm -f $2 || true 29 | } 30 | osp_detect() { 31 | local spaces effects type="$1" 32 | local files=$(find $MODPATH -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml") 33 | for file in $files; do 34 | for osp in $type; do 35 | case $file in 36 | *.conf) spaces=$(sed -n "/^output_session_processing {/,/^}/ {/^ *$osp {/p}" $file | sed -r "s/( *).*/\1/") 37 | effects=$(sed -n "/^output_session_processing {/,/^}/ {/^$spaces\$osp {/,/^$spaces}/p}" $file | grep -E "^$spaces +[A-Za-z]+" | sed -r "s/( *.*) .*/\1/g") 38 | for effect in ${effects}; do 39 | spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effect {/p}" $file | sed -r "s/( *).*/\1/") 40 | [ "$effect" != "atmos" -a "$effect" != "dtsaudio" ] && sed -i "/^effects {/,/^}/ {/^$spaces$effect {/,/^$spaces}/d}" $file 41 | done 42 | ;; 43 | *.xml) effects=$(sed -n "/^ *$/,/^ *<\/postprocess>$/ {/^ *$/,/^ *<\/stream>$/ {//d; /<\/stream>/d; s///g; s/ *//g; p}}" $file) 44 | for effect in ${effects}; do 45 | [ "$effect" != "atmos" -a "$effect" != "dtsaudio" ] && sed -i "/^\( *\)/d" $file 46 | done 47 | ;; 48 | esac 49 | done 50 | done 51 | return 0 52 | } 53 | 54 | # Debug 55 | exec 2>$MODPATH/debug-pfsd.log 56 | set -x 57 | 58 | # Restore and reset 59 | . $MODPATH/uninstall.sh 60 | moddir="$(dirname $MODPATH)" # Changed by uninstall script 61 | rm -rf $amldir $MODPATH/system $MODPATH/vendor $MODPATH/odm $MODPATH/my_product $MODPATH/errors.txt $MODPATH/system.prop 2>/dev/null 62 | [ -f "$moddir/acdb/post-fs-data.sh" ] && mv -f $moddir/acdb/post-fs-data.sh $moddir/acdb/post-fs-data.sh.bak 63 | mkdir $amldir 64 | # Don't follow symlinks 65 | if $KSU || [ "$(echo $MAGISK_VER | awk -F- '{ print $NF}')" == "delta" ]; then 66 | partitions="/system_root/system /system /vendor /odm /my_product" 67 | else 68 | partitions="/system_root/system /system /vendor" 69 | fi 70 | files="$(find $partitions -type f $filenames 2>/dev/null)" 71 | for file in $files; do 72 | $KSU && name=$(echo "$file" | sed "s|/system_root/|/|") || name=$(echo "$file" | sed -e "s|/system_root/|/|" -e "s|/system/|/|" | sed "s|^|/system|") 73 | cp_mv -c $file $MODPATH$name 74 | modfiles="$name $modfiles" 75 | done 76 | if $KSU; then 77 | partitions="$(echo $partitions | sed "s|/system_root/system /system ||")" 78 | for part in $partitions; do 79 | [ -d $MODPATH$part ] && ln -sf $part $MODPATH/system$part 80 | done 81 | fi 82 | osp_detect "music" 83 | 84 | # Detect/move audio mod files 85 | for mod in $(find $moddir/* -maxdepth 0 -type d ! -name aml -a ! -name 'lost+found'); do 86 | modname="$(basename $mod)" 87 | [ -f "$mod/disable" ] && continue 88 | $KSU && partitions="$mod/system $mod/vendor $mod/odm $mod/my_product" || partitions="$mod/system" 89 | # Move files 90 | files="$(find $partitions -type f $filenames 2>/dev/null)" 91 | [ "$files" ] && echo "$modname" >> $amldir/modlist || continue 92 | for file in $files; do 93 | cp_mv -m $file $amldir/$modname/$(echo "$file" | sed "s|$mod/||") 94 | done 95 | # Chcon fix for Android Q+ 96 | if [ $API -ge 29 ]; then 97 | if $KSU && [ -d $mod/vendor ] && [ ! -L $mod/vendor ]; then 98 | chcon -R u:object_r:vendor_file:s0 $mod/vendor/lib*/soundfx 2>/dev/null 99 | else 100 | chcon -R u:object_r:vendor_file:s0 $mod/system/vendor/lib*/soundfx 2>/dev/null 101 | fi 102 | fi 103 | done 104 | 105 | # Remove unneeded files from aml 106 | for file in $modfiles; do 107 | [ "$(find $amldir -type f -path "*$file")" ] || rm -f $MODPATH$file 108 | done 109 | 110 | # Set perms and such 111 | set_perm_recursive $MODPATH/system 0 0 0755 0644 112 | if [ $API -ge 26 ]; then 113 | set_perm_recursive $MODPATH/system/vendor 0 2000 0755 0644 u:object_r:vendor_file:s0 114 | set_perm_recursive $MODPATH/system/vendor/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0 115 | set_perm_recursive $MODPATH/system/vendor/odm/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0 116 | set_perm_recursive $MODPATH/system/odm/etc 0 0 0755 0644 u:object_r:vendor_configs_file:s0 117 | if $KSU; then 118 | set_perm_recursive $MODPATH/vendor 0 2000 0755 0644 u:object_r:vendor_file:s0 119 | set_perm_recursive $MODPATH/vendor/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0 120 | set_perm_recursive $MODPATH/vendor/odm/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0 121 | set_perm_recursive $MODPATH/odm/etc 0 2000 0755 0644 u:object_r:vendor_configs_file:s0 122 | fi 123 | fi 124 | exit 0 125 | -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | # Variables 2 | MODPATH="${0%/*}" 3 | moddir="$(dirname $MODPATH)" 4 | amldir= 5 | API= 6 | KSU= 7 | [ $API -ge 26 ] && libdir="/vendor" || libdir="/system" 8 | 9 | # Functions 10 | cp_mv() { 11 | mkdir -p "$(dirname "$3")" 12 | cp -af "$2" "$3" 13 | [ "$1" == "-m" ] && rm -f $2 || true 14 | } 15 | osp_detect() { 16 | local spaces effects type="$1" 17 | local files=$(find $MODPATH -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml") 18 | for file in $files; do 19 | for osp in $type; do 20 | case $file in 21 | *.conf) spaces=$(sed -n "/^output_session_processing {/,/^}/ {/^ *$osp {/p}" $file | sed -r "s/( *).*/\1/") 22 | effects=$(sed -n "/^output_session_processing {/,/^}/ {/^$spaces\$osp {/,/^$spaces}/p}" $file | grep -E "^$spaces +[A-Za-z]+" | sed -r "s/( *.*) .*/\1/g") 23 | for effect in ${effects}; do 24 | spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effect {/p}" $file | sed -r "s/( *).*/\1/") 25 | [ "$effect" != "atmos" -a "$effect" != "dtsaudio" ] && sed -i "/^effects {/,/^}/ {/^$spaces$effect {/,/^$spaces}/d}" $file 26 | done 27 | ;; 28 | *.xml) effects=$(sed -n "/^ *$/,/^ *<\/postprocess>$/ {/^ *$/,/^ *<\/stream>$/ {//d; /<\/stream>/d; s///g; s/ *//g; p}}" $file) 29 | for effect in ${effects}; do 30 | [ "$effect" != "atmos" -a "$effect" != "dtsaudio" ] && sed -i "/^\( *\)/d" $file 31 | done 32 | ;; 33 | esac 34 | done 35 | done 36 | return 0 37 | } 38 | patch_cfgs() { 39 | 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 40 | local opt=`getopt :fleoqpr "$@"` 41 | eval set -- "$opt" 42 | while true; do 43 | case "$1" in 44 | -f) files="placeholder"; shift;; 45 | -l) lib=true; first=false; shift;; 46 | -e) effect=true; first=false; shift;; 47 | -o) outsp=true; conf=output_session_processing; xml=postprocess; first=false; shift;; 48 | -q) outsp=true; conf=pre_processing; xml=preprocess; first=false; shift;; 49 | -p) proxy=true; effect=false; outsp=false; first=false; shift;; 50 | -r) replace=true; shift;; 51 | --) shift; break;; 52 | *) return 1;; 53 | esac 54 | done 55 | [ -z $files ] && files="$(find $MODPATH -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml")" || { files="$1"; shift; } 56 | $first && { lib=true; effect=true; } 57 | if $proxy; then 58 | effname=$1; uid=${2:?}; shift 2 59 | libname_sw=$1; uid_sw=${2:?}; shift 2 60 | $lib && { libpathsw=$1; shift; } 61 | libname_hw=$1; uid_hw=${2:?}; shift 2 62 | $lib && { libpathhw=${1:?}; shift; } 63 | else 64 | $outsp && { type=${1:?}; shift; } 65 | { $effect || $outsp; } && { effname=${1:?}; shift; } 66 | $effect && { uid=${1:?}; shift; } 67 | { $lib || $effect; } && { libname=${1:?}; shift; } 68 | $lib && { libpath=${1:?}; shift; } 69 | fi 70 | for file in $files; do 71 | case "$file" in 72 | *.conf) 73 | if $proxy; then 74 | if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ $effname {/,/^ }/p}" $file)" ]; then 75 | spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/") 76 | sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file 77 | fi 78 | [ ! "$(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 79 | if $lib; then 80 | patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so" 81 | if $replace; then 82 | patch_cfgs -frl "$file" "$libname_sw" "$libpathsw" 83 | patch_cfgs -frl "$file" "$libname_hw" "$libpathhw" 84 | else 85 | patch_cfgs -fl "$file" "$libname_sw" "$libpathsw" 86 | patch_cfgs -fl "$file" "$libname_hw" "$libpathhw" 87 | fi 88 | fi 89 | else 90 | if $lib; then 91 | if $replace && [ "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ]; then 92 | spaces=$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/p}" $file | sed -r "s/( *).*/\1/") 93 | sed -i "/^libraries {/,/^}/ {/^$spaces$libname {/,/^$spaces}/d}" $file 94 | fi 95 | [ ! "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ] && sed -i "s|^libraries {|libraries {\n $libname {\n path $libpath\n }|" $file 96 | fi 97 | if $effect; then 98 | if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ]; then 99 | spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/") 100 | sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file 101 | fi 102 | [ ! "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ] && sed -i "s|^effects {|effects {\n $effname {\n library $libname\n uuid $uid\n }|" $file 103 | fi 104 | if $outsp && [ "$API" -ge 26 ]; then 105 | local OIFS=$IFS; local IFS=',' 106 | for i in $type; do 107 | if [ ! "$(sed -n "/^$conf {/,/^}/p" $file)" ]; then 108 | echo -e "\n$conf {\n $i {\n $effname {\n }\n }\n}" >> $file 109 | elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/p}" $file)" ]; then 110 | sed -i "/^$conf {/,/^}/ s/$conf {/$conf {\n $i {\n $effname {\n }\n }/" $file 111 | elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/ {/$effname {/,/}/p}}" $file)" ]; then 112 | sed -i "/^$conf {/,/^}/ {/$i {/,/^ }/ s/$i {/$i {\n $effname {\n }/}" $file 113 | fi 114 | done 115 | local IFS=$OIFS 116 | fi 117 | fi 118 | ;; 119 | *.xml) 120 | if $proxy; then 121 | if $replace && [ "$(sed -n "//,/<\/effects>/ {/^ */,/^ *<\/effectProxy>/p}" $file)" -o "$(sed -n "//,/<\/effects>/ {/^ */p}" $file)" ]; then 122 | sed -i "//,/<\/effects>/ {/^ */,/^ *<\/effectProxy>/d}" $file 123 | sed -i "//,/<\/effects>/ {/^ */d}" $file 124 | fi 125 | [ ! "$(sed -n "//,/<\/effects>/ {/^ */,/^ *<\/effectProxy>/p}" $file)" -a ! "$(sed -n "//,/<\/effects>/ {/^ */,/^ *\/>/p}" $file)" ] && sed -i -e "// a\ \n \n \n <\/effectProxy>" $file 126 | if $lib; then 127 | patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so" 128 | if $replace; then 129 | patch_cfgs -frl "$file" "$libname_sw" "$libpathsw" 130 | patch_cfgs -frl "$file" "$libname_hw" "$libpathhw" 131 | else 132 | patch_cfgs -fl "$file" "$libname_sw" "$libpathsw" 133 | patch_cfgs -fl "$file" "$libname_hw" "$libpathhw" 134 | fi 135 | fi 136 | else 137 | if $lib; then 138 | if $replace && [ "$(sed -n "//,/<\/libraries>/ {/^ */p}" $file)" ]; then 139 | sed -i "//,/<\/libraries>/ {/^ */d}" $file 140 | fi 141 | [ ! "$(sed -n "//,/<\/libraries>/ {/^ */p}" $file)" ] && sed -i "// a\ " $file 142 | fi 143 | if $effect; then 144 | if $replace && [ "$(sed -n "//,/<\/effects>/ {/^ */p}" $file)" -o "$(sed -n "//,/<\/effects>/ {/^ */,/^ *<\/effectProxy>/p}" $file)" ]; then 145 | sed -i "//,/<\/effects>/ {/^ */d}" $file 146 | sed -i "//,/<\/effects>/ {/^ */,/^ *<\/effectProxy>/d}" $file 147 | fi 148 | [ ! "$(sed -n "//,/<\/effects>/ {/^ */p}" $file)" ] && sed -i "// a\ " $file 149 | fi 150 | if $outsp && [ "$API" -ge 26 ]; then 151 | local OIFS=$IFS; local IFS=',' 152 | for i in $type; do 153 | if [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/p" $file)" ]; then 154 | sed -i "/<\/audio_effects_conf>/i\ <$xml>\n \n \n <\/stream>\n <\/$xml>" $file 155 | elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {//,/<\/stream>/p}" $file)" ]; then 156 | sed -i "/^ *<$xml>/,/^ *<\/$xml>/ s/ <$xml>/ <$xml>\n \n \n <\/stream>/" $file 157 | elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {//,/<\/stream>/ {/^ */p}}" $file)" ]; then 158 | sed -i "/^ *<$xml>/,/^ *<\/$xml>/ {//,/<\/stream>/ s//\n /}" $file 159 | fi 160 | done 161 | local IFS=$OIFS 162 | fi 163 | fi 164 | ;; 165 | esac 166 | done 167 | return 0 168 | } 169 | legacy_script() { 170 | local RUNONCE=false COUNT=1 LIBDIR=$libdir/lib/soundfx MOD=$mod 171 | (. $mod/.aml.sh) || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt 172 | for file in $files; do 173 | local NAME=$(echo "$file" | sed "s|$mod|system|") 174 | $RUNONCE || { case $file in 175 | *audio_effects*) (. $mod/.aml.sh) || [ "$(grep -x "$modname" $MODPATH/errors.txt)" ] || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt; COUNT=$(($COUNT + 1));; 176 | esac; } 177 | done 178 | } 179 | 180 | ( 181 | # Debug 182 | exec 2>$MODPATH/debug.log 183 | set -x 184 | 185 | # Detect/install audio mods 186 | for mod in $(find $moddir/* -maxdepth 0 -type d ! -name aml); do 187 | modname="$(basename $mod)" 188 | [ -f "$mod/disable" ] && continue 189 | [ -f "$mod/aml.sh" ] && cp -f $mod/aml.sh $mod/.aml.sh 190 | # .aml.sh file should take precedence 191 | if [ -f "$mod/.aml.sh" ]; then 192 | grep -qx "$modname" $amldir/modlist || echo "$modname" >> $amldir/modlist 193 | if grep -qE '\$MODPATH/\$NAME|RUNONCE=|COUNT=' $mod/.aml.sh; then 194 | legacy_script 195 | else 196 | (. $mod/.aml.sh) || echo "Error in $modname aml.sh script" >> $MODPATH/errors.txt 197 | fi 198 | else 199 | # Favor vendor libs over system ones, no aml builtins are 64bit only - use 32bit lib dir 200 | if $KSU && [ ! -L $MODPATH/system/vendor ]; then 201 | libs="$(find $mod/vendor/lib/soundfx $mod/system/lib/soundfx -type f 2>/dev/null)" 202 | else 203 | libs="$(find $mod/system/vendor/lib/soundfx $mod/system/lib/soundfx -type f 2>/dev/null)" 204 | fi 205 | for lib in $libs; do 206 | for audmod in $MODPATH/.scripts/$(basename $lib)~*; do 207 | uuid=$(basename $audmod | sed -r "s/.*~(.*).sh/\1/") 208 | hexuuid="$(echo $uuid | sed -r -e "s/^(..)(..)(..)(..)-(..)(..)-(..)(..)-/\4\3\2\1\6\5\8\7-/" -e "s/-(..)(..)-(............)$/\2\1\3/")" 209 | xxd -p $lib | tr -d '\n' | grep -q "$hexuuid" || continue 210 | $(grep -xq "$modname" $amldir/modlist 2>/dev/null) || echo "$modname" >> $amldir/modlist 211 | libfile="$(echo $lib | sed -e "s|$mod||" -e "s|/system/vendor|/vendor|")" 212 | . $audmod 213 | done 214 | done 215 | fi 216 | done 217 | 218 | # Reload patched files 219 | if $KSU; then # KSU - reload overlay after modifications 220 | for i in /system /vendor /odm /my_product; do 221 | [ -d $MODPATH$i ] && mount -o remount $i 222 | done 223 | else # Magisk - Original mounted files are seemingly deleted and replaced by sed 224 | for i in $(find $MODPATH/system -type f); do 225 | j="$(echo $i | sed -e "s|$MODPATH||" -e 's|/system/odm|/odm|' -e 's|/system/my_product|/my_product|')" 226 | umount $j 227 | mount -o bind $i $j 228 | done 229 | fi 230 | [ $API -ge 24 ] && killall audioserver 2>/dev/null || killall mediaserver 2>/dev/null 231 | exit 0 232 | )& 233 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | moddir=$(dirname ${0%/*}) 3 | amldir= 4 | if [ -s $amldir/modlist ]; then 5 | while read mod; do 6 | [ -d "$moddir/$mod" ] || continue 7 | for file in $(find $amldir/$mod -type f 2>/dev/null | sed "s|$amldir/||"); do 8 | [ -f "$moddir/$file" ] || cp -af $amldir/$file $moddir/$file 9 | done 10 | done < $amldir/modlist 11 | fi 12 | rm -rf $amldir 13 | [ -f "$moddir/acdb/post-fs-data.sh.bak" ] && mv -f $moddir/acdb/post-fs-data.sh.bak $moddir/acdb/post-fs-data.sh 14 | -------------------------------------------------------------------------------- /update.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v5.1", 3 | "versionCode": 59, 4 | "zipUrl": "https://raw.githubusercontent.com/Zackptg5/Audio-Modification-Library/master/install.zip", 5 | "changelog": "https://raw.githubusercontent.com/Zackptg5/Audio-Modification-Library/master/changelog.md" 6 | } --------------------------------------------------------------------------------