Skip to content

Commit 81976fc

Browse files
authored
Add files via upload
* Fixed not to output an error message when the mount point isn't symbolically linked under "/system" * Changed the way how to get the actual audio policy file path in the service phase because some ROM's fail to execute "dumpsys" in the phase
1 parent 207a53c commit 81976fc

File tree

6 files changed

+96
-48
lines changed

6 files changed

+96
-48
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ This module behaves as follows:
2323

2424
## DISCLAIMER
2525

26-
* I am not responsible for any damage that may occur to your device, so it is your own choice to attempt this module.
27-
<br/>
26+
* I am not responsible for any damage that may occur to your device, so it is your own choice whether to attempt this module or not.
2827

2928
##

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Change logs
22

3-
#v1.2.3
3+
# v1.2.4
4+
* Fixed not to output an error message when the mount point isn't symbolically linked under "/system"
5+
* Changed the way how to get the actual audio policy file path in the service phase because some ROM's fail to execute "dumpsys" in the phase
6+
7+
# v1.2.3
48
* Added "compatible Magisk-mirroring" message for incompatible Magisk variants
59

610
# v1.2.2

customize.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ case "$configXML" in
2929
# Don't use "$MAGISKPATH/.magisk/mirror/system${configXML}" instead of "$MAGISKPATH/.magisk/mirror${configXML}".
3030
# In some cases, the former may link to overlaied "${configXML}" by Magisk itself (not original mirrored "${configXML}".
3131
mirrorConfigXML="$MAGISKPATH/.magisk/mirror${configXML}"
32+
3233
else
3334
original_policy_file_not_found
3435
abort " Abort installation!"
36+
3537
fi
3638

3739
# If DRC is enabled, modify audio policy configuration to stop DRC
@@ -52,9 +54,17 @@ case "$configXML" in
5254
chown root:root "$modConfigXML"
5355
chmod -R a+rX "${modConfigXML%/*}"
5456
REPLACE="/system${configXML}"
57+
58+
# If "${configXML}" isn't symbolically linked to "$/system/{configXML}",
59+
# disable Magisk's "magic mount" and mount "${configXML}" by this module itself in "service.sh"
60+
if [ ! -e "/system${configXML}" ]; then
61+
touch "$MODPATH/skip_mount"
62+
fi
63+
5564
else
5665
no_need_this_module
5766
abort " Abort installation!"
67+
5868
fi
5969
;;
6070
* )
@@ -63,4 +73,4 @@ case "$configXML" in
6373
;;
6474
esac
6575

66-
rm -f "$MODPATH/LICENSE" "$MODPATH/README.md" "$MODPATH/changelog.md"
76+
rm -f "$MODPATH/LICENSE" "$MODPATH/README.md" "$MODPATH/changelog.md" "$MODPATH/functions3.sh"

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id=drc-remover
22
name=DRC remover
3-
version=v1.2.3
4-
versionCode=1203
3+
version=v1.2.4
4+
versionCode=1204
55
author=zyhk
66
description=A remover of DRC (Dynamic Range Control, i.e., compression) sticking to all audio outputs on some major devices.

service-functions.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/system/bin/sh
2+
3+
function reloadAudioServer()
4+
{
5+
if [ -n "`getprop init.svc.audioserver`" ]; then
6+
setprop ctl.restart audioserver
7+
sleep 1.2
8+
if [ "`getprop init.svc.audioserver`" != "running" ]; then
9+
# workaround for Android 12 old devices hanging up the audioserver after "setprop ctl.restart audioserver" is executed
10+
local pid="`getprop init.svc_debug_pid.audioserver`"
11+
if [ -n "$pid" ]; then
12+
kill -HUP $pid 1>"/dev/null" 2>&1
13+
fi
14+
fi
15+
fi
16+
}
17+
18+
# Sleep some secs needed for Audioserver's preparation
19+
function waitAudioServer()
20+
{
21+
# wait for system boot completion and audiosever boot up
22+
sleep 11
23+
local i
24+
for i in `seq 1 10` ; do
25+
if [ "`getprop sys.boot_completed`" = "1" -a -n "`getprop init.svc.audioserver`" ]; then
26+
break
27+
fi
28+
sleep $i
29+
done
30+
}
31+
32+
# A rewritten version because some ROM's fail to execute "dumpsys media.audio_policy" on the service phase
33+
# arg1 : Magisk's module folder path, typically "/data/adb/modules/<module name>"
34+
function remountFiles()
35+
{
36+
local modPath flist x deletePat forceReload=0
37+
38+
if [ $# -eq 1 -a -e "$1" ]; then
39+
modPath="$1"
40+
else
41+
return
42+
fi
43+
44+
deletePat=$(echo "${modPath}/system" | sed -e 's/\//\\\//g')
45+
46+
# Get absolute paths for Magisk's magic mount, then remount by itself
47+
flist="`find \"${modPath}/system\" -type f | sed -e \"s/$deletePat//\"`"
48+
49+
# Check if the audio policy XML file and others mounted by Magisk is still unmounted.
50+
# Some Qcomm devices from Xiaomi, OnePlus, etc. overlays another on it in a boot process
51+
# and phh GSI's on Qcomm devices unmount it for the phh settings of the GSI's.
52+
53+
for x in $flist; do
54+
if [ -e "${modPath}/skip_mount" -a "${x##*/}" = ".replace" ]; then
55+
# Mount a directory instead of ".replace" file if skipping Magisk's magic mount
56+
mount -o bind "${modPath}/system${x%/.replace}" "${x%/.replace}"
57+
forceReload=1
58+
elif [ -r "$x" -a -r "${modPath}/system${x}" ]; then
59+
cmp "$x" "${modPath}/system${x}" >"/dev/null" 2>&1
60+
if [ "$?" -ne 0 ]; then
61+
umount "$x" >"/dev/null" 2>&1
62+
umount "$x" >"/dev/null" 2>&1
63+
mount -o bind "${modPath}/system${x}" "$x"
64+
forceReload=1
65+
fi
66+
fi
67+
done
68+
69+
if [ "$forceReload" -gt 0 ]; then
70+
# Since this library file may be shared multiple modules, it is needed to disperse the timing of each module not to collide
71+
sleep $(expr $RANDOM % 20)
72+
reloadAudioServer
73+
fi
74+
}

service.sh

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,8 @@
11
#!/system/bin/sh
22

33
# if Magisk change its mount point in the future
4-
MODDIR=${0%/*}
4+
MODDIR=${0%/*}
55

6-
. "$MODDIR/functions3.sh"
6+
. "${MODDIR}/service-functions.sh"
77

8-
function reloadAudioServer()
9-
{
10-
if [ -n "`getprop init.svc.audioserver`" ]; then
11-
setprop ctl.restart audioserver
12-
sleep 1.2
13-
if [ "`getprop init.svc.audioserver`" != "running" ]; then
14-
# workaround for Android 12 old devices hanging up the audioserver after "setprop ctl.restart audioserver" is executed
15-
local pid="`getprop init.svc_debug_pid.audioserver`"
16-
if [ -n "$pid" ]; then
17-
kill -HUP $pid 1>"/dev/null" 2>&1
18-
fi
19-
fi
20-
fi
21-
}
22-
23-
# sleep some secs needed for Audioserver's preparation
24-
25-
function remountFile()
26-
{
27-
local configXML
28-
29-
# Set the active configuration file name retrieved from the audio policy server
30-
configXML="`getActivePolicyFile`"
31-
32-
# Check if the audio policy XML file mounted by Magisk is still unmounted.
33-
# Some Qcomm devices from Xiaomi, OnePlus, etc. overlays another on it in a boot process
34-
# and phh GSI on Qcomm devices unmount it
35-
36-
if [ -r "$configXML" -a -r "${MODDIR}/system${configXML}" ]; then
37-
cmp "$configXML" "${MODDIR}/system${configXML}" >"/dev/null" 2>&1
38-
if [ "$?" -ne 0 ]; then
39-
umount "$configXML" >"/dev/null" 2>&1
40-
umount "$configXML" >"/dev/null" 2>&1
41-
mount -o bind "${MODDIR}/system${configXML}" "$configXML"
42-
reloadAudioServer
43-
fi
44-
fi
45-
}
46-
47-
(((sleep 32; remountFile) 0<&- &>"/dev/null" &) &)
8+
(((waitAudioServer; remountFiles "$MODDIR") 0<&- &>"/dev/null" &) &)

0 commit comments

Comments
 (0)