-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize.sh
76 lines (63 loc) · 2.84 KB
/
customize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/system/bin/sh
[ -z "$(magisk --path)" ] && alias magisk='ksu-magisk'
. "$MODPATH/functions3.sh"
if ! isMagiskMountCompatible; then
abort ' ***
Aborted by no Magisk-mirrors:
try again either
a.) with official Magisk v27.0 (mounting mirrors), or
b.) after installing "Compatible Magisk-mirroring" Magisk module and rebooting
***'
fi
# Replace audio_policy_configuration*.xml
REPLACE="
"
# Set the active configuration file name retrieved from the audio policy server
configXML="`getActivePolicyFile`"
# configXML is usually placed under "/vendor/etc" (or "/vendor/etc/audio"), but
# "/my_product/etc" and "/odm/etc" are used on ColorOS (RealmeUI) and OxygenOS(?)
case "$configXML" in
/vendor/etc/* | /my_product/etc/* | /odm/etc/* | /system/etc/* | /product/etc/* )
MAGISKPATH="$(magisk --path)"
if [ -n "$MAGISKPATH" -a -r "$MAGISKPATH/.magisk/mirror${configXML}" ]; then
# Don't use "$MAGISKPATH/.magisk/mirror/system${configXML}" instead of "$MAGISKPATH/.magisk/mirror${configXML}".
# In some cases, the former may link to overlaied "${configXML}" by Magisk itself (not original mirrored "${configXML}".
mirrorConfigXML="$MAGISKPATH/.magisk/mirror${configXML}"
else
original_policy_file_not_found
abort " Abort installation!"
fi
# If DRC is enabled, modify audio policy configuration to stop DRC
grep -e "speaker_drc_enabled[[:space:]]*=[[:space:]]*\"true\"" "$mirrorConfigXML" >"/dev/null" 2>&1
if [ "$?" -eq 0 ]; then
case "${configXML}" in
/system/* )
configXML="${configXML#/system}"
;;
esac
modConfigXML="$MODPATH/system${configXML}"
mkdir -p "${modConfigXML%/*}"
touch "$modConfigXML"
mirrorConfigXML="`getActualConfigXML \"${mirrorConfigXML}\"`"
stopDRC "$mirrorConfigXML" "$modConfigXML"
chmod 644 "$modConfigXML"
chcon u:object_r:vendor_configs_file:s0 "$modConfigXML"
chown root:root "$modConfigXML"
chmod -R a+rX "${modConfigXML%/*}"
REPLACE="/system${configXML}"
# If "${configXML}" isn't symbolically linked to "$/system/{configXML}",
# disable Magisk's "magic mount" and mount "${configXML}" by this module itself in "service.sh"
if [ ! -e "/system${configXML}" ]; then
touch "$MODPATH/skip_mount"
fi
else
no_need_this_module
abort " Abort installation!"
fi
;;
* )
policy_file_not_found
abort " Abort installation!"
;;
esac
rm -f "$MODPATH/LICENSE" "$MODPATH/README.md" "$MODPATH/changelog.md" "$MODPATH/functions3.sh"