├── .gitattributes ├── .gitignore ├── META-INF └── com │ └── google │ └── android │ ├── update-binary │ └── updater-script ├── README.md ├── addon.tar.xz ├── common ├── aml.sh ├── install.sh ├── post-fs-data.sh ├── sepolicy.sh ├── service.sh ├── system.prop ├── uninstall.sh └── unityfiles │ ├── addon.sh │ ├── modidsysover.sh │ ├── tools.tar.gz │ ├── util_functions.sh │ └── util_functions2.sh ├── config.sh ├── module.prop └── system └── placeholder /.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 | *.xml text eol=lf 6 | META-INF/** text eol=lf 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | ########################################################################################## 3 | # 4 | # Unity Installer 5 | # by ahrion & zackptg5 6 | # 7 | ########################################################################################## 8 | 9 | # Temp Installer Path 10 | export TMPDIR=/dev/tmp; export INSTALLER=$TMPDIR/install; export OUTFD=$2; export ZIPFILE=$3 11 | 12 | # Default Permissions 13 | umask 022 14 | 15 | # Preliminary detection of bootmode for ui_print function 16 | ps | grep zygote | grep -qv grep >/dev/null && BOOTMODE=true || BOOTMODE=false 17 | $BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -qv grep >/dev/null && BOOTMODE=true 18 | 19 | ui_print() { 20 | $BOOTMODE && echo "$1" || echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD 21 | } 22 | 23 | # Initial Cleanup 24 | rm -rf $TMPDIR 2>/dev/null 25 | mkdir -p $INSTALLER 26 | 27 | # Extract Unityfiles 28 | unzip -o "$ZIPFILE" 'common/unityfiles/tools.tar.gz' 'common/unityfiles/util_functions.sh' -d $INSTALLER >&2 29 | [ -f "$INSTALLER/common/unityfiles/tools.tar.gz" ] || { ui_print "! Unable to extract zip file !"; exit 1; } 30 | 31 | # Load Util_Functions, Add In-House Binaries to PATH, Start Bash Shell 32 | export ARCH32=`getprop ro.product.cpu.abi | cut -c-3` 33 | [ -z $ARCH32 ] && export ARCH32=`getprop ro.product.cpu.abi2 | cut -c-3` 34 | [ -z $ARCH32 ] && export ARCH32=arm 35 | (tar -xf $INSTALLER/common/unityfiles/tools.tar.gz -C $INSTALLER/common/unityfiles) || { ui_print "! Unable to extract unity tools !"; exit 1; } 36 | chmod -R 755 $INSTALLER/common/unityfiles/tools/$ARCH32 37 | echo $PATH | grep -q "$INSTALLER/common/unityfiles/tools/$ARCH32" || export PATH=$INSTALLER/common/unityfiles/tools/$ARCH32:$PATH 38 | bash $INSTALLER/common/unityfiles/util_functions.sh 39 | -------------------------------------------------------------------------------- /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This is the old repo for ACP. [The new one is here on the magisk modules repo](https://github.com/Magisk-Modules-Repo/acp) 2 | 3 | # Audio Compatibility Patch 4 | This fixes music and streaming apps (Spotify, Pandora, etc) that aren't processing audio effects for various equalizer applications through the modification of audio policy. [More details in support thread](https://forum.xda-developers.com/apps/magisk/module-universal-deepbuffer-remover-t3577067). 5 | 6 | ## Compatibility 7 | * Any Android device 8 | 9 | ## Change Log 10 | ### v1.5.8 - 1.15.2019 11 | * Unity v3.2 update 12 | 13 | ### v1.5.7 - 1.10.2019 14 | * Unity v3.1 update 15 | * Improve remove option 16 | 17 | ### v1.5.6 - 1.5.2019 18 | * Unity v3.0 update 19 | 20 | ### v1.5.5 - 12.26.2018 21 | * Fix zipname trigger 22 | 23 | ### v1.5.4 - 12.23.2018 24 | * Unity v2.2 update 25 | 26 | ### v1.5.3 -12.21.2018 27 | * Updated to unity v2.1 28 | 29 | ### v1.5.2 - 12.28.2018 30 | * Unity v2.0 update 31 | * Fixed limitation in zipname triggers - you can use spaces in the zipname now and trigger is case insensitive 32 | 33 | ### v1.5.1 - 10.23.2018 34 | * Unity v1.7.2 update 35 | 36 | ### v1.5 - 9.20.2018 37 | * Unity v1.7.1 update 38 | 39 | ### v1.4.9 - 9.2.2018 40 | * Unity v1.7 update 41 | 42 | ### v1.4.8 - 8.30.2018 43 | * Unity v1.6.1 update 44 | 45 | ### v1.4.7 - 8.24.2018 46 | * Unity v1.6 update 47 | 48 | ### v1.4.6 - 7.18.2018 49 | * Added patch support for samsungs with deep_buffer contained in primary-out/primary output 50 | * Fixed patching with busybox sed 51 | * Unity v1.5.5 update 52 | 53 | ### v1.4.5 - 6.17.2018 54 | * Updated for aml v1.7 55 | 56 | ### v1.4.4 - 6.15.2018 57 | * Bug fixes 58 | 59 | ### v1.4.3 - 5.7.2018 60 | * Unity v1.5.4 update 61 | 62 | ### v1.4.2 - 4.27.2018 63 | * Raw patching bug fixes 64 | 65 | ### v1.4.1 - 4.26.2018 66 | * Unity v1.5.3 update 67 | 68 | ### v1.4 - 4.23.2018 69 | * Brought back old deep_buffer remover logic (vol key option) for the few who need it 70 | * Minor bug fixes 71 | 72 | ### v1.1.3 - 4.16.2018 73 | * Unity v1.5.2 update 74 | * Add AML detection/notification 75 | 76 | ### v1.1.2 - 4.12.2018 77 | * Reworking/fixing of audio file patching 78 | 79 | ### v1.1.1 - 4.12.2018 80 | * Unity v1.5.1 update 81 | 82 | ### v1.1 - 3.27.2018 83 | * Added disabling of low_latency 84 | * Use flag of NONE for deep_buffer and low_latency, still FAST for raw 85 | 86 | ### v1.0 - 3.22.2018 87 | * Initial release 88 | 89 | ## Source Code 90 | * Module [GitHub](https://github.com/therealahrion/Audio-Compatibility-Patch) 91 | -------------------------------------------------------------------------------- /addon.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/therealahrion/Audio-Compatibility-Patch/88c0daa08993c5ed2ff9d0c8f9d2ce97c073b49e/addon.tar.xz -------------------------------------------------------------------------------- /common/aml.sh: -------------------------------------------------------------------------------- 1 | RUNONCE=true 2 | PATCH=true 3 | if $PATCH; then 4 | for FILE in ${FILES}; do 5 | NAME=$(echo "$FILE" | sed "s|$MOD|system|") 6 | case $NAME in 7 | *audio_*policy*.xml) sed -ri "/ *$/ s|flags=\"[^\"]*|flags=\"AUDIO_OUTPUT_FLAG_NONE|" $MODPATH/$NAME 8 | sed -i "/ *$/ s|flags=\"[^\"]*|flags=\"AUDIO_OUTPUT_FLAG_FAST|" $MODPATH/$NAME 9 | sed -i "/ *$/ s/|AUDIO_OUTPUT_FLAG_DEEP_BUFFER//; s/AUDIO_OUTPUT_FLAG_DEEP_BUFFER|//" $MODPATH/$NAME;; 10 | *audio_*policy*.conf) sed -ri "/^ *(deep_buffer)|(low_latency) \{/,/}/ s|flags .*|flags AUDIO_OUTPUT_FLAG_NONE|" $MODPATH/$NAME 11 | sed -i "/^ *raw {/,/}/ s|flags .*|flags AUDIO_OUTPUT_FLAG_PRIMARY|" $MODPATH/$NAME 12 | sed -i "/^ *primary {/,/}/ s/|AUDIO_OUTPUT_FLAG_DEEP_BUFFER//; s/AUDIO_OUTPUT_FLAG_DEEP_BUFFER|//" $MODPATH/$NAME;; 13 | esac 14 | done 15 | else 16 | for FLAG in "deep_buffer" "raw" "low_latency"; do 17 | if [ -f $MODPATH/system/vendor/etc/audio_output_policy.conf ] && [ -f $MODPATH/system/etc/audio_policy_configuration.xml ]; then 18 | for BUFFER in "Earpiece" "Speaker" "Wired Headset" "Wired Headphones" "Line" "HDMI" "Proxy" "FM" "BT SCO All" "USB Device Out" "Telephony Tx" "voice_rx" "primary input" "surround_sound" "record_24" "BT A2DP Out" "BT A2DP Headphones" "BT A2DP Speaker"; do 19 | sed -i "/$BUFFER/ s/$FLAG//g" $MODPATH/system/etc/audio_policy_configuration.xml 20 | done 21 | elif [ ! -f $MODPATH/system/vendor/etc/audio_output_policy.conf ] && [ -f $MODPATH/system/etc/audio_policy_configuration.xml ]; then 22 | sed -i "s/$FLAG,//g" $MODPATH/system/etc/audio_policy_configuration.xml 23 | sed -i "s/,$FLAG//g" $MODPATH/system/etc/audio_policy_configuration.xml 24 | elif [ -f $MODPATH/system/vendor/etc/audio/audio_policy_configuration.xml ]; then 25 | sed -i "s/$FLAG,//g" $MODPATH/system/vendor/etc/audio/audio_policy_configuration.xml 26 | sed -i "s/,$FLAG//g" $MODPATH/system/vendor/etc/audio/audio_policy_configuration.xml 27 | else 28 | for FILE in ${FILES}; do 29 | NAME=$(echo "$FILE" | sed "s|$MOD|system|") 30 | case $NAME in 31 | *audio_*policy*.conf) sed -i "/$FLAG {/,/}/d" $MODPATH/$NAME;; 32 | *audio_*policy*.xml) sed -i "/$FLAG {/,/}/d" $MODPATH/$NAME 33 | sed -i "s/$FLAG,//g" $MODPATH/$NAME 34 | sed -i "s/,$FLAG//g" $MODPATH/$NAME;; 35 | esac 36 | done 37 | fi 38 | done 39 | fi 40 | -------------------------------------------------------------------------------- /common/install.sh: -------------------------------------------------------------------------------- 1 | # Tell user aml is needed if applicable 2 | if $MAGISK && ! $SYSOVERRIDE; then 3 | if $BOOTMODE; then LOC="$MAGISKTMP/img/*/system $MOUNTPATH/*/system"; else LOC="$MOUNTPATH/*/system"; fi 4 | FILES=$(find $LOC -type f -name "*audio_*policy*.conf" -o -name "*audio_*policy*.xml" 2>/dev/null) 5 | if [ ! -z "$FILES" ] && [ ! "$(echo $FILES | grep '/aml/')" ]; then 6 | ui_print " " 7 | ui_print " ! Conflicting audio mod found!" 8 | ui_print " ! You will need to install !" 9 | ui_print " ! Audio Modification Library !" 10 | sleep 3 11 | fi 12 | fi 13 | 14 | # Check if FLAGS are even present. If not, do removal since there's nothing to patch 15 | PATCH=false 16 | for FILE in ${POLS}; do 17 | case $FILE in 18 | *.xml) [ "$(grep 'flags="AUDIO_OUTPUT_FLAG' $FILE)" ] && { PATCH=true; break; };; 19 | *.conf) [ "$(grep 'flags AUDIO_OUTPUT_FLAG' $FILE)" ] && { PATCH=true; break; };; 20 | esac 21 | done 22 | 23 | # Get Rem/Pat from zipname 24 | if $PATCH; then 25 | OIFS=$IFS; IFS=\| 26 | case $(echo $(basename $ZIPFILE) | tr '[:upper:]' '[:lower:]') in 27 | *nrem*) PATCH=true;; 28 | *rem*) PATCH=false;; 29 | *) PATCH="";; 30 | esac 31 | IFS=$OIFS 32 | else 33 | ui_print " " 34 | ui_print "! No flags detected in policy files!" 35 | ui_print "! Using removal logic!" 36 | fi 37 | 38 | ui_print " " 39 | if [ -z $PATCH ]; then 40 | ui_print "- Select Patch Method -" 41 | ui_print " Patch flags or remove sections?:" 42 | ui_print " Vol Up = Patch (new logic)" 43 | ui_print " Vol Down = Remove (old logic)" 44 | ui_print " Only select Remove if patch doesn't work for you" 45 | if $VKSEL; then 46 | PATCH=true 47 | else 48 | PATCH=false 49 | fi 50 | else 51 | ui_print " Patching method specified in zipname!" 52 | fi 53 | 54 | ui_print " Patching existing audio policy files..." 55 | if $PATCH; then 56 | ui_print " Using patch logic" 57 | for OFILE in ${POLS}; do 58 | FILE="$UNITY$(echo $OFILE | sed "s|^/vendor|/system/vendor|g")" 59 | cp_ch -i $ORIGDIR$OFILE $FILE 60 | case $FILE in 61 | *.xml) for MIX in "deep_buffer" "raw" "low_latency" "primary-out"; do 62 | sed -ri "/ *$/ {/flags=\"[^\"]*/p; s|( *)(.*flags=\"[^\"]*.*)|\1|; s|-->$MODID-->|$MODID-->|}" $FILE 63 | if [ "$MIX" == "deep_buffer" -o $MIX == "low_latency" ]; then 64 | sed -ri "/ *$/ {//}" $UNITY/system/etc/audio_policy_configuration.xml; } 95 | sed -i "/$BUFFER/{n;s/$FLAG,//;}" $UNITY/system/etc/audio_policy_configuration.xml 96 | fi 97 | done 98 | elif [ ! -f $VEN/etc/audio_output_policy.conf ] && [ -f /system/etc/audio_policy_configuration.xml ]; then 99 | $FIRST && { cp_ch -i $ORIGDIR/system/etc/audio_policy_configuration.xml $UNITY/system/etc/audio_policy_configuration.xml; 100 | sed -ri "/($FLAG,|,$FLAG)/p" $UNITY/system/etc/audio_policy_configuration.xml; 101 | sed -ri "/($FLAG,|,$FLAG)/{n;s/( *)(.*)$FLAG(.*)/\1/}" $UNITY/system/etc/audio_policy_configuration.xml; } 102 | sed -i "//}" $UNITY$VEN/etc/audio/audio_policy_configuration.xml; } 108 | sed -i "//g" $FILE 120 | fi 121 | $FIRST && { sed -ri "/($FLAG,|,$FLAG)/p" $FILE; 122 | sed -ri "/($FLAG,|,$FLAG)/{n;s/( *)(.*)$FLAG(.*)/\1/}" $FILE; } 123 | sed -i "/|\1\2|}" $FILE 8 | done;; 9 | *.conf) for MIX in "deep_buffer" "raw" "low_latency" "primary"; do 10 | sed -i "/^ *$MIX {/,/}/ {/^ *flags AUDIO_OUTPUT_FLAG_.*$/d; s|#$MODID||}" $FILE 11 | done;; 12 | esac 13 | done 14 | else 15 | for FLAG in "deep_buffer" "raw" "low_latency"; do 16 | if [ -f $UNITY$VEN/etc/audio_output_policy.conf ] && [ -f $UNITY$SYS/etc/audio_policy_configuration.xml ] && [ "$(grep "/\1/g}" $UNITY$SYS/etc/audio_policy_configuration.xml 22 | done 23 | elif [ ! -f $UNITY$VEN/etc/audio_output_policy.conf ] && [ -f $UNITY$SYS/etc/audio_policy_configuration.xml ] && [ "$(grep "/\1/g" $UNITY$SYS/etc/audio_policy_configuration.xml 26 | elif [ -f $VEN/etc/audio/audio_policy_configuration.xml ] && [ "$(grep "/\1/g" $UNITY$VEN/etc/audio/audio_policy_configuration.xml 29 | else 30 | for OFILE in ${POLS}; do 31 | FILE="$UNITY$(echo $OFILE | sed "s|^/vendor|/system/vendor|g")" 32 | case $FILE in 33 | *.conf) [ "$(grep "^#$MODID" $FILE)" ] && sed -i "/$FLAG {/,/}/ s/^#$MODID//" $FILE;; 34 | *.xml) [ "$(grep "/ s//}/g" $FILE;; 35 | esac 36 | done 37 | fi 38 | done 39 | fi 40 | fi 41 | -------------------------------------------------------------------------------- /common/unityfiles/addon.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | . /tmp/backuptool.functions 3 | list_files() { 4 | cat </dev/null 24 | cp -f $INSTALLER/common/unityfiles/tools/$ARCH32/busybox $BBBIN 2>/dev/null 25 | chmod 755 $BBBIN 26 | $BBBIN --install -s $TMPDIR/bin 27 | export PATH=$TMPDIR/bin:$PATH 28 | fi 29 | # Bootmode detection with proper busybox binaries 30 | ps -A | grep zygote | grep -qv grep && BOOTMODE=true || BOOTMODE=false 31 | # Get Outfd 32 | $BOOTMODE && return 33 | if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then 34 | # We will have to manually find out OUTFD 35 | for FD in `ls /proc/$$/fd`; do 36 | if readlink /proc/$$/fd/$FD | grep -q pipe; then 37 | if ps | grep -v grep | grep -q " 3 $FD "; then 38 | OUTFD=$FD 39 | break 40 | fi 41 | fi 42 | done 43 | fi 44 | } 45 | 46 | ui_print() { 47 | $BOOTMODE && echo "$1" || echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD 48 | } 49 | 50 | toupper() { 51 | echo "$@" | tr '[:lower:]' '[:upper:]' 52 | } 53 | 54 | find_block() { 55 | for BLOCK in "$@"; do 56 | DEVICE=`find /dev/block -type l -iname $BLOCK | head -n 1` 2>/dev/null 57 | if [ ! -z $DEVICE ]; then 58 | readlink -f $DEVICE 59 | return 0 60 | fi 61 | done 62 | # Fallback by parsing sysfs uevents 63 | for uevent in /sys/dev/block/*/uevent; do 64 | local DEVNAME=`grep_prop DEVNAME $uevent` 65 | local PARTNAME=`grep_prop PARTNAME $uevent` 66 | for p in "$@"; do 67 | if [ "`toupper $p`" = "`toupper $PARTNAME`" ]; then 68 | echo /dev/block/$DEVNAME 69 | return 0 70 | fi 71 | done 72 | done 73 | return 1 74 | } 75 | 76 | mount_partitions() { 77 | # Check A/B slot 78 | SLOT=`grep_cmdline androidboot.slot_suffix` 79 | if [ -z $SLOT ]; then 80 | SLOT=_`grep_cmdline androidboot.slot` 81 | [ $SLOT = "_" ] && SLOT= 82 | fi 83 | [ -z $SLOT ] || ui_print "- Current boot slot: $SLOT" 84 | ui_print "- Mounting /system, /vendor" 85 | [ -f /system/build.prop ] || is_mounted /system || mount -o rw /system 2>/dev/null 86 | if ! is_mounted /system && ! [ -f /system/build.prop ]; then 87 | SYSTEMBLOCK=`find_block system$SLOT` 88 | mount -t ext4 -o rw $SYSTEMBLOCK /system 89 | fi 90 | [ -f /system/build.prop ] || is_mounted /system || abort "! Cannot mount /system" 91 | grep -qE '/dev/root|/system_root' /proc/mounts && SYSTEM_ROOT=true || SYSTEM_ROOT=false 92 | if [ -f /system/init ]; then 93 | SYSTEM_ROOT=true 94 | mkdir /system_root 2>/dev/null 95 | mount --move /system /system_root 96 | mount -o bind /system_root/system /system 97 | fi 98 | $SYSTEM_ROOT && { ui_print "- Device using system_root_image"; ROOT=/system_root; } 99 | if [ -L /system/vendor ]; then 100 | # Seperate /vendor partition 101 | is_mounted /vendor || mount -o rw /vendor 2>/dev/null 102 | if ! is_mounted /vendor; then 103 | VENDORBLOCK=`find_block vendor$SLOT` 104 | mount -t ext4 -o rw $VENDORBLOCK /vendor 105 | fi 106 | is_mounted /vendor || abort "! Cannot mount /vendor" 107 | fi 108 | } 109 | 110 | grep_cmdline() { 111 | local REGEX="s/^$1=//p" 112 | cat /proc/cmdline | tr '[:space:]' '\n' | sed -n "$REGEX" 2>/dev/null 113 | } 114 | 115 | grep_prop() { 116 | local REGEX="s/^$1=//p" 117 | shift 118 | local FILES=$@ 119 | [ -z "$FILES" ] && FILES='/system/build.prop' 120 | sed -n "$REGEX" $FILES 2>/dev/null | head -n 1 121 | } 122 | 123 | is_mounted() { 124 | grep -q " `readlink -f $1` " /proc/mounts 2>/dev/null 125 | return $? 126 | } 127 | 128 | api_level_arch_detect() { 129 | API=`grep_prop ro.build.version.sdk` 130 | ABI=`grep_prop ro.product.cpu.abi | cut -c-3` 131 | ABI2=`grep_prop ro.product.cpu.abi2 | cut -c-3` 132 | ABILONG=`grep_prop ro.product.cpu.abi` 133 | ARCH=arm 134 | ARCH32=arm 135 | IS64BIT=false 136 | if [ "$ABI" = "x86" ]; then ARCH=x86; ARCH32=x86; fi; 137 | if [ "$ABI2" = "x86" ]; then ARCH=x86; ARCH32=x86; fi; 138 | if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; ARCH32=arm; IS64BIT=true; fi; 139 | if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; ARCH32=x86; IS64BIT=true; fi; 140 | } 141 | 142 | recovery_actions() { 143 | # TWRP bug fix 144 | mount -o bind /dev/urandom /dev/random 145 | # Temporarily block out all custom recovery binaries/libs 146 | mv /sbin /sbin_tmp 147 | # Unset library paths 148 | OLD_LD_LIB=$LD_LIBRARY_PATH 149 | OLD_LD_PRE=$LD_PRELOAD 150 | unset LD_LIBRARY_PATH 151 | unset LD_PRELOAD 152 | } 153 | 154 | recovery_cleanup() { 155 | mv /sbin_tmp /sbin 2>/dev/null 156 | [ -z $OLD_PATH ] || export PATH=$OLD_PATH 157 | [ -z $OLD_LD_LIB ] || export LD_LIBRARY_PATH=$OLD_LD_LIB 158 | [ -z $OLD_LD_PRE ] || export LD_PRELOAD=$OLD_LD_PRE 159 | ui_print "- Unmounting partitions" 160 | [ "$supersuimg" -o -d /su ] && umount /su 2>/dev/null 161 | umount -l /system_root 2>/dev/null 162 | umount -l /system 2>/dev/null 163 | umount -l /vendor 2>/dev/null 164 | umount -l /dev/random 2>/dev/null 165 | } 166 | 167 | abort() { 168 | ui_print "$1" 169 | $BOOTMODE || recovery_cleanup 170 | exit 1 171 | } 172 | 173 | set_perm() { 174 | chown $2:$3 $1 || return 1 175 | chmod $4 $1 || return 1 176 | [ -z $5 ] && chcon 'u:object_r:system_file:s0' $1 || chcon $5 $1 || return 1 177 | } 178 | 179 | set_perm_recursive() { 180 | find $1 -type d 2>/dev/null | while read dir; do 181 | set_perm $dir $2 $3 $4 $6 182 | done 183 | find $1 -type f -o -type l 2>/dev/null | while read file; do 184 | set_perm $file $2 $3 $5 $6 185 | done 186 | } 187 | 188 | mktouch() { 189 | mkdir -p ${1%/*} 2>/dev/null 190 | [ -z $2 ] && touch $1 || echo $2 > $1 191 | chmod 644 $1 192 | } 193 | 194 | supersuimg_mount() { 195 | supersuimg=$(ls /cache/su.img /data/su.img 2>/dev/null) 196 | if [ "$supersuimg" ]; then 197 | if ! is_mounted /su; then 198 | ui_print " Mounting /su..." 199 | [ -d /su ] || mkdir /su 2>/dev/null 200 | mount -t ext4 -o rw,noatime $supersuimg /su 2>/dev/null 201 | for i in 0 1 2 3 4 5 6 7; do 202 | is_mounted /su && break 203 | local loop=/dev/block/loop$i 204 | mknod $loop b 7 $i 205 | losetup $loop $supersuimg 206 | mount -t ext4 -o loop $loop /su 2>/dev/null 207 | done 208 | fi 209 | fi 210 | } 211 | 212 | cleanup() { 213 | [ -d "$RD" ] && repack_ramdisk 214 | if $MAGISK; then 215 | unmount_magisk_img 216 | # Please leave this message in your flashable zip for credits :) 217 | ui_print " " 218 | ui_print " *******************************************" 219 | ui_print " * Powered by Magisk (@topjohnwu) *" 220 | ui_print " *******************************************" 221 | fi 222 | $BOOTMODE || recovery_cleanup 223 | ui_print " " 224 | ui_print " *******************************************" 225 | ui_print " * Unity by ahrion & zackptg5 @ XDA *" 226 | ui_print " *******************************************" 227 | ui_print " " 228 | [ -d "$INSTALLER/addon/Aroma-Installer" ] && rm -rf $TMPDIR || { rm -rf $TMPDIR; exit 0; } 229 | } 230 | 231 | device_check() { 232 | local PROP=$(echo "$1" | tr '[:upper:]' '[:lower:]') 233 | for i in "ro.product.device" "ro.build.product"; do 234 | [ "$(sed -n "s/^$i=//p" /system/build.prop 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')" == "$PROP" -o "$(sed -n "s/^$i=//p" $VEN/build.prop 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')" == "$PROP" ] && return 0 235 | done 236 | return 1 237 | } 238 | 239 | cp_ch() { 240 | #UBAK: false for no backup file creation. REST: false for no file restore on uninstall 241 | local OPT=`getopt -o inr -- "$@"` BAK BAKFILE EXT UBAK=true REST=true FOL=false SAME=false 242 | eval set -- "$OPT" 243 | while true; do 244 | case "$1" in 245 | -i) UBAK=false; REST=false; shift;; 246 | -n) UBAK=false; shift;; 247 | -r) FOL=true; shift;; 248 | --) shift; break;; 249 | esac 250 | done 251 | OFILES="$1" FILE="$2" PERM=$3 252 | case "$2" in 253 | /system/*|/vendor/*) BAK=true; BAKFILE=$INFO; EXT=".bak";; 254 | $RD/*) BAK=true; BAKFILE=$INFORD; EXT="~";; 255 | $INSTALLER/*|$MOUNTPATH/*|$MAGISKTMP/img/*|$MAGISKBIN/*) BAK=false; BAKFILE=$INFO; EXT=".bak";; 256 | *) BAK=true; BAKFILE=$INFO; EXT=".bak";; 257 | esac 258 | [ -z $PERM ] && PERM=0644 259 | $FOL && { OFILES=$(find $1 -type f 2>/dev/null); [ "$(echo $1 | sed 's|.*/||')" == "$(echo $2 | sed 's|.*/||')" ] && SAME=true; } 260 | for OFILE in $OFILES; do 261 | if $FOL; then $SAME && FILE=$(echo $OFILE | sed "s|$1|$2|") || FILE=$(echo $OFILE | sed "s|$1|$2/$(basename $1)|"); fi 262 | if $BAK; then 263 | if $UBAK && $REST; then 264 | [ ! "$(grep "$FILE$" $BAKFILE 2>/dev/null)" ] && echo "$FILE" >> $BAKFILE 265 | [ -f "$FILE" -a ! -f "$FILE$EXT" ] && { cp -af $FILE $FILE$EXT; echo "$FILE$EXT" >> $BAKFILE; } 266 | elif ! $UBAK && $REST; then 267 | [ ! "$(grep "$FILE$" $BAKFILE 2>/dev/null)" ] && echo "$FILE" >> $BAKFILE 268 | elif ! $UBAK && ! $REST; then 269 | [ ! "$(grep "$FILE\NORESTORE$" $BAKFILE 2>/dev/null)" ] && echo "$FILE\NORESTORE" >> $BAKFILE 270 | fi 271 | fi 272 | install -D -m $PERM "$OFILE" "$FILE" 273 | case $FILE in 274 | */vendor/*.apk) chcon u:object_r:vendor_app_file:s0 $FILE;; 275 | */vendor/etc/*) chcon u:object_r:vendor_configs_file:s0 $FILE;; 276 | */vendor/*) chcon u:object_r:vendor_file:s0 $FILE;; 277 | */system/*) chcon u:object_r:system_file:s0 $FILE;; 278 | esac 279 | done 280 | } 281 | 282 | patch_script() { 283 | [ -L /system/vendor ] && local VEN=/vendor 284 | sed -i -e "1i $SHEBANG" -e '2i MODPATH=${0%/*}' -e "2i SYS=$ROOT/system" -e "2i VEN=$ROOT$VEN" $1 285 | for i in "ROOT" "MAGISK" "LIBDIR" "SYSOVERRIDE" "MODID"; do 286 | sed -i "3i $i=$(eval echo \$$i)" $1 287 | done 288 | if $MAGISK; then 289 | sed -i -e "s|\$MOUNTPATH|$MAGISKTMP/img|g" -e "s|\$UNITY|$MAGISKTMP/img/$MODID|g" -e "3i INFO=$(echo $INFO | sed "s|$MOUNTPATH|$MAGISKTMP/img|")" $1 290 | else 291 | sed -i -e "s|\$MOUNTPATH||g" -e "s|\$UNITY||g" -e "3i INFO=$INFO" $1 292 | fi 293 | } 294 | 295 | install_script() { 296 | if [ "$MAGISKTMP" == "/sbin/.magisk" ]; then 297 | local INPATH="$NVBASE" 298 | elif $BOOTMODE; then 299 | local INPATH="$MOUNTPATH/.core" 300 | else 301 | local INPATH="$NVBASE/img/.core" 302 | fi 303 | case "$1" in 304 | -l) shift; INPATH="$INPATH/service.d"; local EXT="-ls";; 305 | -p) shift; INPATH="$INPATH/post-fs-data.d"; local EXT="";; 306 | *) INPATH="$INPATH/post-fs-data.d"; local EXT="";; 307 | esac 308 | patch_script "$1" 309 | if $MAGISK; then 310 | case $(basename $1) in 311 | post-fs-data.sh|service.sh) cp_ch -n $1 $MODPATH/$(basename $1);; 312 | *) cp_ch -n $1 $INPATH/$(basename $1) 0755;; 313 | esac 314 | else 315 | cp_ch -n $1 $MODPATH/$MODID-$(basename $1 | sed 's/.sh$//')$EXT 0700 316 | fi 317 | } 318 | 319 | prop_process() { 320 | sed -i "/^#/d" $1 321 | if $MAGISK; then 322 | [ -f $PROP ] || mktouch $PROP 323 | else 324 | [ -f $PROP ] || mktouch $PROP "$SHEBANG" 325 | sed -ri "s|^(.*)=(.*)|setprop \1 \2|g" $1 326 | fi 327 | while read LINE; do 328 | echo "$LINE" >> $PROP 329 | done < $1 330 | $MAGISK || chmod 0700 $PROP 331 | } 332 | 333 | set_vars() { 334 | local ROOTTYPE="MagiskSu" 335 | if $BOOTMODE; then 336 | MOD_VER="$MAGISKTMP/img/$MODID/module.prop" 337 | $MAGISK && ORIGDIR="$MAGISKTMP/mirror" 338 | else 339 | MOD_VER="$MODPATH/module.prop" 340 | ORIGDIR="" 341 | fi 342 | SYS=/system; VEN=/system/vendor; ORIGVEN=$ORIGDIR/system/vendor; INITD=false 343 | RD=$INSTALLER/common/unityfiles/boot/ramdisk; INFORD="$RD/$MODID-files" 344 | SHEBANG="#!/system/bin/sh"; UNITY="$MODPATH"; INFO="$MODPATH/$MODID-files"; PROP=$MODPATH/system.prop 345 | if $DYNAMICOREO && [ $API -ge 26 ]; then LIBPATCH="\/vendor"; LIBDIR=$VEN; else LIBPATCH="\/system"; LIBDIR=/system; fi 346 | if ! $MAGISK || $SYSOVERRIDE; then 347 | UNITY="" 348 | [ -L /system/vendor ] && { VEN=/vendor; $BOOTMODE && ORIGVEN=$ORIGDIR/vendor; } 349 | [ -d /system/addon.d ] && INFO=/system/addon.d/$MODID-files || INFO=/system/etc/$MODID-files 350 | if ! $MAGISK; then 351 | # Determine system boot script type 352 | supersuimg_mount 353 | PROP=$MODPATH/$MODID-props.sh; MOD_VER="/system/etc/$MODID-module.prop"; MODPATH=/system/etc/init.d; ROOTTYPE="Rootless/other root" 354 | if [ "$supersuimg" ] || [ -d /su ]; then 355 | SHEBANG="#!/su/bin/sush"; ROOTTYPE="Systemless SuperSU"; MODPATH=/su/su.d 356 | elif [ -e "$(find /data /cache -name supersu_is_here | head -n1)" ]; then 357 | SHEBANG="#!/su/bin/sush"; ROOTTYPE="Systemless SuperSU" 358 | MODPATH=$(dirname `find /data /cache -name supersu_is_here | head -n1` 2>/dev/null)/su.d 359 | elif [ -d /system/su ] || [ -f /system/xbin/daemonsu ] || [ -f /system/xbin/sugote ] || [ -f /system/xbin/su ]; then 360 | MODPATH=/system/su.d; ROOTTYPE="System SuperSU" 361 | elif [ -f /system/xbin/su ]; then 362 | [ "$(grep "SuperSU" /system/xbin/su)" ] && { MODPATH=/system/su.d; ROOTTYPE="System SuperSU"; } || ROOTTYPE="LineageOS SU" 363 | fi 364 | fi 365 | fi 366 | ui_print "- $ROOTTYPE detected" 367 | ui_print " " 368 | } 369 | 370 | uninstall_files() { 371 | local FILE EXT 372 | if [ -z "$1" ] || [ "$1" == "$INFO" ]; then 373 | FILE=$INFO; EXT=".bak" 374 | $BOOTMODE && [ -f $MAGISKTMP/img/$MODID/$MODID-files ] && FILE=$MAGISKTMP/img/$MODID/$MODID-files 375 | $MAGISK || [ -f $FILE ] || abort " ! Mod not detected !" 376 | else 377 | FILE="$1" 378 | [ -z "$2" ] && EXT=.bak || EXT="$2" 379 | fi 380 | if [ -f $FILE ]; then 381 | while read LINE; do 382 | if [ "$(echo -n $LINE | tail -c 4)" == "$EXT" ] || [ "$(echo -n $LINE | tail -c 9)" == "NORESTORE" ]; then 383 | continue 384 | elif [ -f "$LINE$EXT" ]; then 385 | mv -f $LINE$EXT $LINE 386 | else 387 | rm -f $LINE 388 | while true; do 389 | LINE=$(dirname $LINE) 390 | [ "$(ls -A $LINE 2>/dev/null)" ] && break 1 || rm -rf $LINE 391 | done 392 | fi 393 | done < $FILE 394 | rm -f $FILE 395 | fi 396 | } 397 | 398 | unity_install() { 399 | ui_print " " 400 | ui_print "- Installing" 401 | 402 | # Run Aroma Installer Addon if present 403 | if [ -d "$INSTALLER/addon/Aroma-Installer" ]; then 404 | ui_print " " 405 | ui_print "- Running Aroma Installer Addon -" 406 | . $INSTALLER/addon/Aroma-Installer/install.sh 407 | ui_print " " 408 | ui_print "- Installing (cont) -" 409 | fi 410 | 411 | # Make info file 412 | rm -f $INFO 413 | mktouch $INFO 414 | 415 | # Run user install script 416 | [ -f "$INSTALLER/common/install.sh" ] && . $INSTALLER/common/install.sh 417 | 418 | # Addons 419 | if [ "$(ls -A $INSTALLER/addon/*/install.sh 2>/dev/null)" ]; then 420 | ui_print " " 421 | ui_print "- Running Addons -" 422 | for i in $INSTALLER/addon/*/install.sh; do 423 | [ "$i" == "$INSTALLER/addon/Aroma-Installer/install.sh" ] && continue 424 | ui_print " Running $(echo $i | sed -r "s|$INSTALLER/addon/(.*)/install.sh|\1|")..." 425 | . $i 426 | done 427 | ui_print " " 428 | ui_print "- Installing (cont) -" 429 | fi 430 | 431 | # Remove comments from files 432 | for i in $INSTALLER/common/sepolicy.sh $INSTALLER/common/system.prop $INSTALLER/common/service.sh $INSTALLER/common/post-fs-data.sh; do 433 | [ -f $i ] && sed -i -e "/^#/d" -e "/^ *$/d" $i 434 | done 435 | 436 | # Sepolicy 437 | if [ -s $INSTALLER/common/sepolicy.sh ]; then 438 | [ "$MODPATH" == "/system/etc/init.d" -o "$MODPATH" == "$MOUNTPATH/$MODID" ] && echo -n "magiskpolicy --live" >> $INSTALLER/common/service.sh || echo -n "supolicy --live" >> $INSTALLER/common/service.sh 439 | sed -i -e '/^#.*/d' -e '/^$/d' $INSTALLER/common/sepolicy.sh 440 | while read LINE; do 441 | case $LINE in 442 | \"*\") echo -n " $LINE" >> $INSTALLER/common/service.sh;; 443 | \"*) echo -n " $LINE\"" >> $INSTALLER/common/service.sh;; 444 | *\") echo -n " \"$LINE" >> $INSTALLER/common/service.sh;; 445 | *) echo -n " \"$LINE\"" >> $INSTALLER/common/service.sh;; 446 | esac 447 | done < $INSTALLER/common/sepolicy.sh 448 | fi 449 | 450 | ui_print " Installing scripts and files for $ARCH SDK $API device..." 451 | # Handle replace folders 452 | for TARGET in $REPLACE; do 453 | if $MAGISK; then mktouch $MODPATH$TARGET/.replace; else rm -rf $TARGET; fi 454 | done 455 | 456 | # Prop files 457 | [ -s $INSTALLER/common/system.prop ] && { prop_process $INSTALLER/common/system.prop; $MAGISK || echo $PROP >> $INFO; } 458 | 459 | # Module info 460 | cp_ch -n $INSTALLER/module.prop $MOD_VER 461 | 462 | #Install post-fs-data mode scripts 463 | [ -s $INSTALLER/common/post-fs-data.sh ] && install_script -p $INSTALLER/common/post-fs-data.sh 464 | 465 | # Service mode scripts 466 | [ -s $INSTALLER/common/service.sh ] && install_script -l $INSTALLER/common/service.sh 467 | 468 | # Install files 469 | $IS64BIT || rm -rf $INSTALLER/system/lib64 $INSTALLER/system/vendor/lib64 470 | [ -d "/system/priv-app" ] || mv -f $INSTALLER/system/priv-app $INSTALLER/system/app 471 | if $DYNAMICOREO && [ $API -ge 26 ]; then 472 | for FILE in $(find $INSTALLER/system/lib*/* -maxdepth 0 -type d 2>/dev/null | sed -e "s|$INSTALLER/system/lib.*/modules||" -e "s|$INSTALLER/system/||"); do 473 | mkdir -p $(dirname $INSTALLER/system/vendor/$FILE) 474 | mv -f $INSTALLER/system/$FILE $INSTALLER/system/vendor/$FILE 475 | done 476 | fi 477 | rm -f $INSTALLER/system/placeholder 478 | cp_ch -r $INSTALLER/system $UNITY 479 | 480 | # Install scripts 481 | if $MAGISK; then 482 | # Auto mount 483 | [ -d $MODPATH/system ] && ! $SYSOVERRIDE && mktouch $MODPATH/auto_mount 484 | # Update info for magisk manager 485 | $BOOTMODE && { mktouch $MAGISKTMP/img/$MODID/update; cp_ch -n $INSTALLER/module.prop $MODPATH/module.prop; } 486 | elif [ "$MODPATH" == "/system/etc/init.d" ]; then 487 | ui_print " " 488 | ui_print " ! This root method has no boot script support !" 489 | ui_print " ! You will need to add init.d support !" 490 | ui_print " " 491 | fi 492 | if $MAGISK && $SYSOVERRIDE; then 493 | cp -f $INSTALLER/common/unityfiles/modidsysover.sh $INSTALLER/common/unityfiles/$MODID-sysover.sh 494 | sed -i "34r $INSTALLER/common/uninstall.sh" $INSTALLER/common/unityfiles/$MODID-sysover.sh 495 | install_script -p $INSTALLER/common/unityfiles/$MODID-sysover.sh 496 | elif ! $MAGISK || $SYSOVERRIDE; then 497 | # Install rom backup script 498 | if [ -d /system/addon.d ]; then 499 | ui_print " Installing addon.d backup script..." 500 | sed -i "2i MODID=$MODID" $INSTALLER/common/unityfiles/addon.sh 501 | cp_ch -n $INSTALLER/common/unityfiles/addon.sh /system/addon.d/$MODID.sh 0755 502 | else 503 | ui_print " ! Addon.d not detected. Backup script not installed..." 504 | fi 505 | fi 506 | 507 | # Add blank line to end of all prop/script files if not already present 508 | for FILE in $MODPATH/*.sh $MODPATH/*.prop; do 509 | [ -f $FILE ] && { [ "$(tail -1 $FILE)" ] && echo "" >> $FILE; } 510 | done 511 | 512 | # Remove info file if not needed 513 | [ -s $INFO ] || rm -f $INFO 514 | 515 | # Set permissions 516 | ui_print " " 517 | ui_print "- Setting Permissions" 518 | $MAGISK && set_perm_recursive $MODPATH 0 0 0755 0644 519 | set_permissions 520 | } 521 | 522 | unity_uninstall() { 523 | ui_print " " 524 | ui_print "- Uninstalling" 525 | 526 | # Addons 527 | if [ "$(ls -A $INSTALLER/addon/*/uninstall.sh 2>/dev/null)" ]; then 528 | ui_print " " 529 | ui_print "- Running Addons -" 530 | for i in $INSTALLER/addon/*/uninstall.sh; do 531 | ui_print " Running $(echo $i | sed -r "s|$INSTALLER/addon/(.*)/uninstall.sh|\1|")..." 532 | . $i 533 | done 534 | ui_print " " 535 | ui_print "- Uninstalling (cont) -" 536 | fi 537 | 538 | # Remove files 539 | uninstall_files 540 | 541 | $MAGISK && { rm -rf $MODPATH $MAGISKTMP/img/$MODID; rm -f $NVBASE/post-fs-data.d/$MODID-sysover.sh; } 542 | 543 | # Run user install script 544 | [ -f "$INSTALLER/common/uninstall.sh" ] && . $INSTALLER/common/uninstall.sh 545 | 546 | ui_print " " 547 | ui_print "- Completing uninstall -" 548 | } 549 | 550 | ########################################################################################## 551 | # MAIN 552 | ########################################################################################## 553 | 554 | # Temp installer paths and vars 555 | MOUNTPATH=$TMPDIR/magisk_img; SYSOVERRIDE=false; DEBUG=false; DYNAMICOREO=false; DYNAMICAPP=false; SEPOLICY=false 556 | OIFS=$IFS; IFS=\|; 557 | case $(echo $(basename "$ZIPFILE") | tr '[:upper:]' '[:lower:]') in 558 | *debug*) DEBUG=true;; 559 | *sysover*) SYSOVERRIDE=true;; 560 | esac 561 | IFS=$OIFS 562 | 563 | # Setup busybox and stuff 564 | setup_flashable 565 | 566 | # Unzip files 567 | ui_print " " 568 | ui_print "Unzipping files..." 569 | unzip -oq "$ZIPFILE" -d $INSTALLER 2>/dev/null 570 | [ -f "$INSTALLER/config.sh" ] || abort "! Unable to extract zip file!" 571 | [ "$(grep_prop id $INSTALLER/module.prop)" == "UnityTemplate" ] && { ui_print "! Unity Template is not a separate module !"; abort "! This template is for devs only !"; } 572 | 573 | # Insert module info into config.sh and run it 574 | ( 575 | for i in version name author; do 576 | NEW=$(grep_prop $i $INSTALLER/module.prop) 577 | [ "$i" == "author" ] && NEW="by ${NEW}" 578 | CHARS=$((${#NEW}-$(echo "$NEW" | tr -cd "©®™" | wc -m))) 579 | SPACES="" 580 | if [ $CHARS -le 41 ]; then 581 | for j in $(seq $(((41-$CHARS) / 2))); do 582 | SPACES="${SPACES} " 583 | done 584 | fi 585 | if [ $(((41-$CHARS) % 2)) -eq 1 ]; then sed -i "s/<$i>/$SPACES$NEW${SPACES} /" $INSTALLER/config.sh; else sed -i "s/<$i>/$SPACES$NEW$SPACES/" $INSTALLER/config.sh; fi 586 | done 587 | ) 588 | . $INSTALLER/config.sh 589 | 590 | [ -z $MODID ] && MODID=`grep_prop id $INSTALLER/module.prop` 591 | MODPATH=$MOUNTPATH/$MODID 592 | MINMAGISK=$(grep_prop minMagisk $INSTALLER/module.prop) 593 | 594 | # Print modname 595 | print_modname 596 | 597 | # Mount data and cache 598 | ui_print "- Mounting /data, /cache" 599 | is_mounted /data || mount /data || is_mounted /cache || mount /cache || { ui_print "! Unable to mount partitions"; exit 1; } 600 | 601 | # Determine magisk path if applicable 602 | if [ -f /data/adb/magisk/util_functions.sh ]; then 603 | NVBASE=/data/adb 604 | elif [ -f /data/magisk/util_functions.sh ]; then 605 | NVBASE=/data 606 | fi 607 | [ -z $NVBASE ] || MAGISKBIN=$NVBASE/magisk 608 | 609 | # Determine install type 610 | if [ -z $MAGISKBIN ]; then 611 | MAGISK=false 612 | ui_print "- System install detected" 613 | else 614 | MAGISK=true 615 | ui_print "- Magisk install detected" 616 | cp -f $MAGISKBIN/util_functions.sh $INSTALLER/common/unityfiles/util_functions_mag.sh 617 | if $SYSOVERRIDE; then 618 | ui_print "- Overriding paths for system install" 619 | $BOOTMODE && { ui_print " ! Magisk manager isn't supported!"; abort " ! Install in recovery !"; } 620 | sed -i "s/-o ro/-o rw/g" $INSTALLER/common/unityfiles/util_functions_mag.sh 621 | fi 622 | . $INSTALLER/common/unityfiles/util_functions_mag.sh 623 | # Temporary workaround for cat: write error 624 | . $INSTALLER/common/unityfiles/util_functions2.sh 625 | [ -z $MAGISK_VER_CODE ] || [ $MAGISK_VER_CODE -ge $MINMAGISK ] || { ui_print "! Your install magisk of $(echo $MAGISK_VER_CODE | sed -r "s/(.{2})(.{1}).*/v\1.\2+\!/") is less than"; 626 | ui_print " the minimum magisk version of $(echo $MINMAGISK | sed -r "s/(.{2})(.{1}).*/v\1.\2+\!/")!"; abort "Please install Magisk $(echo $MINMAGISK | sed -r "s/(.{2})(.{1}).*/v\1.\2+\!/")!"; } 627 | [ $MAGISK_VER_CODE -ge 18000 ] && MAGISKTMP=/sbin/.magisk || MAGISKTMP=/sbin/.core 628 | fi 629 | 630 | # Mount partitions and detect version/architecture 631 | mount_partitions 632 | api_level_arch_detect 633 | 634 | # Check for min & max api version 635 | [ -z $MINAPI ] && MINAPI=21 || { [ $MINAPI -lt 21 ] && MINAPI=21; } 636 | [ $API -lt $MINAPI ] && { ui_print "! Your system API of $API is less than"; ui_print "! the minimum api of $MINAPI!"; abort "! Aborting!"; } 637 | [ -z $MAXAPI ] || { [ $API -gt $MAXAPI ] && { ui_print "! Your system API of $API is greater than"; ui_print "! the maximum api of $MINAPI!"; abort "! Aborting!"; }; } 638 | 639 | # Set variables 640 | set_vars 641 | 642 | if $MAGISK; then 643 | if $BOOTMODE; then 644 | IMG=$NVBASE/magisk_merge.img 645 | boot_actions 646 | else 647 | IMG=$NVBASE/magisk.img 648 | recovery_actions 649 | fi 650 | request_zip_size_check "$ZIPFILE" 651 | mount_magisk_img 652 | else 653 | recovery_actions 654 | fi 655 | 656 | # Add blank line to end of all files if needbe 657 | for i in $(find $INSTALLER -type f -name "*.sh" -o -name "*.prop"); do 658 | [ "$(tail -1 "$i")" ] && echo "" >> "$i" 659 | done 660 | 661 | # Import user tools and load ramdisk patching functions 662 | [ -f "$INSTALLER/addon.tar.xz" ] && tar -xf $INSTALLER/addon.tar.xz -C $INSTALLER 2>/dev/null 663 | for i in $INSTALLER/addon/*/main.sh; do 664 | . $i 665 | done 666 | 667 | #Debug 668 | if $DEBUG; then 669 | ui_print " " 670 | ui_print "- Debug mode" 671 | if $BOOTMODE; then 672 | ui_print " Debug log will be written to: /sdcard/$MODID-debug.log" 673 | exec > >(tee -a /sdcard/$MODID-debug.log ); exec 2>/sdcard/$MODID-debug.log 674 | else 675 | ui_print " Debug log will be written to: $(dirname "$ZIPFILE")/$MODID-debug.log" 676 | exec > >(tee -a $(dirname "$ZIPFILE")/$MODID-debug.log ); exec 2>$(dirname "$ZIPFILE")/$MODID-debug.log 677 | fi 678 | set -x 679 | fi 680 | 681 | # Load user vars/function 682 | unity_custom 683 | 684 | # Determine mod installation status 685 | ui_print " " 686 | if [ -d "$RD" ] && [ "$(grep "#$MODID-UnityIndicator" $RD/init.rc 2>/dev/null)" ] && [ ! -f "$MOD_VER" ]; then 687 | ui_print " ! Mod present in ramdisk but not in system!" 688 | ui_print " ! Ramdisk modifications will be uninstalled!" 689 | rm -f $INSTALLER/common/uninstall.sh 690 | unity_uninstall 691 | elif $MAGISK && ! $SYSOVERRIDE && [ -f "/system/addon.d/$MODID-files" -o -f "/system/etc/$MODID-files" ]; then 692 | ui_print " ! Previous system override install detected!" 693 | ui_print " ! Removing...!" 694 | $BOOTMODE && { ui_print " ! Magisk manager isn't supported!"; abort " ! Flash in TWRP !"; } 695 | mount -o rw,remount /system 696 | [ -L /system/vendor ] && mount -o rw,remount /vendor 697 | [ -d /system/addon.d ] && INFO=/system/addon.d/$MODID-files || INFO=/system/etc/$MODID-files 698 | unity_upgrade 699 | unity_uninstall 700 | INFO="$MODPATH/$MODID-files" 701 | unity_install 702 | elif [ -f "$MOD_VER" ]; then 703 | if [ -d "$RD" ] && [ ! "$(grep "#$MODID-UnityIndicator" $RD/init.rc 2>/dev/null)" ]; then 704 | ui_print " ! Mod present in system but not in ramdisk!" 705 | ui_print " ! Running upgrade..." 706 | unity_upgrade 707 | unity_uninstall 708 | unity_install 709 | elif [ $(grep_prop versionCode $MOD_VER) -ge $(grep_prop versionCode $INSTALLER/module.prop) ]; then 710 | ui_print " ! Current or newer version detected!" 711 | unity_uninstall 712 | else 713 | ui_print " ! Older version detected! Upgrading..." 714 | unity_upgrade 715 | unity_uninstall 716 | unity_install 717 | fi 718 | else 719 | unity_install 720 | fi 721 | 722 | # Complete (un)install 723 | cleanup 724 | -------------------------------------------------------------------------------- /common/unityfiles/util_functions2.sh: -------------------------------------------------------------------------------- 1 | is_mounted() { 2 | grep -q " `readlink -f $1` " /proc/mounts 2>/dev/null 3 | return $? 4 | } 5 | -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # 3 | # Unity Config Script 4 | # by topjohnwu, modified by Zackptg5 5 | # 6 | ########################################################################################## 7 | 8 | ########################################################################################## 9 | # Installation Message - Don't change this 10 | ########################################################################################## 11 | 12 | print_modname() { 13 | ui_print " " 14 | ui_print " *******************************************" 15 | ui_print " **" 16 | ui_print " *******************************************" 17 | ui_print " **" 18 | ui_print " **" 19 | ui_print " *******************************************" 20 | ui_print " " 21 | } 22 | 23 | ########################################################################################## 24 | # Defines 25 | ########################################################################################## 26 | 27 | # Uncomment and change 'MINAPI' and 'MAXAPI' to the minimum and maxium android version for your mod (note that unity's minapi is 21 (lollipop) due to bash) 28 | # Uncomment DYNAMICOREO if you want libs installed to vendor for oreo+ and system for anything older 29 | # Uncomment SYSOVERRIDE if you want the mod to always be installed to system (even on magisk) - note that this can still be set to true by the user by adding 'sysover' to the zipname 30 | # Uncomment DEBUG if you want full debug logs (saved to /sdcard in magisk manager and the zip directory in twrp) - note that this can still be set to true by the user by adding 'debug' to the zipname 31 | #MINAPI=21 32 | #MAXAPI=25 33 | #SYSOVERRIDE=true 34 | #DYNAMICOREO=true 35 | #DEBUG=true 36 | 37 | # Things that ONLY run during an upgrade (occurs after unity_custom) - you probably won't need this 38 | # A use for this would be to back up app data before it's wiped if your module includes an app 39 | # NOTE: the normal upgrade process is just an uninstall followed by an install 40 | unity_upgrade() { 41 | : # Remove this if adding to this function 42 | } 43 | 44 | # Custom Variables - Keep everything within this function 45 | unity_custom() { 46 | if $BOOTMODE; then 47 | POLS="$(find /system /vendor -type f -name "*audio_*policy*.conf" -o -name "*audio_*policy*.xml")" 48 | else 49 | POLS="$(find -L /system -type f -name "*audio_*policy*.conf" -o -name "*audio_*policy*.xml")" 50 | fi 51 | # Remove old udbr 52 | if [ -f "$(echo $MOD_VER | sed "s/$MODID/Udb_Remover/g")" ]; then 53 | ui_print " " 54 | ui_print "! Old Udbr detected! Removing..." 55 | INFO=$(echo $INFO | sed "s/$MODID/Udb_Remover/g") 56 | MODPATH=$(echo $MODPATH | sed "s/$MODID/Udb_Remover/g") 57 | MODID="Udb_Remover" 58 | unity_uninstall 59 | MODID=`grep_prop id $INSTALLER/module.prop` 60 | INFO=$(echo $INFO | sed "s/Udb_Remover/$MODID/g") 61 | MODPATH=$MOUNTPATH/$MODID 62 | fi 63 | } 64 | 65 | # Custom Functions for Install AND Uninstall - You can put them here 66 | 67 | 68 | ########################################################################################## 69 | # Replace list 70 | ########################################################################################## 71 | 72 | # List all directories you want to directly replace in the system 73 | # By default Magisk will merge your files with the original system 74 | # Directories listed here however, will be directly mounted to the correspond directory in the system 75 | 76 | # You don't need to remove the example below, these values will be overwritten by your own list 77 | # This is an example 78 | REPLACE=" 79 | /system/app/Youtube 80 | /system/priv-app/SystemUI 81 | /system/priv-app/Settings 82 | /system/framework 83 | " 84 | 85 | # Construct your own list here, it will overwrite the example 86 | # !DO NOT! remove this if you don't need to replace anything, leave it empty as it is now 87 | REPLACE=" 88 | " 89 | 90 | ########################################################################################## 91 | # Permissions 92 | ########################################################################################## 93 | 94 | set_permissions() { 95 | : # Remove this if adding to this function 96 | 97 | # Note that all files/folders have the $UNITY prefix - keep this prefix on all of your files/folders 98 | # Also note the lack of '/' between variables - preceding slashes are already included in the variables 99 | # Use $VEN for vendor (Do not use /system$VEN, the $VEN is set to proper vendor path already - could be /vendor, /system/vendor, etc.) 100 | 101 | # Some examples: 102 | 103 | # For directories (includes files in them): 104 | # set_perm_recursive (default: u:object_r:system_file:s0) 105 | 106 | # set_perm_recursive $UNITY/system/lib 0 0 0755 0644 107 | # set_perm_recursive $UNITY$VEN/lib/soundfx 0 0 0755 0644 108 | 109 | # For files (not in directories taken care of above) 110 | # set_perm (default: u:object_r:system_file:s0) 111 | 112 | # set_perm $UNITY/system/lib/libart.so 0 0 0644 113 | } 114 | -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=acp 2 | name=Audio Compatibility Patch 3 | version=v1.5.8 4 | versionCode=26 5 | author=zackptg5, ahrion 6 | description=Fixes music and streaming apps (Spotify, Pandora, etc) that aren't processing audio effects for various equalizer applications through the modification of audio policy 7 | support=https://forum.xda-developers.com/apps/magisk/module-universal-deepbuffer-remover-t3577067 8 | donate=https://github.com/therealahrion/Audio-Compatibility-Patch 9 | minMagisk=1530 10 | patch=true 11 | -------------------------------------------------------------------------------- /system/placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/therealahrion/Audio-Compatibility-Patch/88c0daa08993c5ed2ff9d0c8f9d2ce97c073b49e/system/placeholder --------------------------------------------------------------------------------