-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions3.sh
89 lines (77 loc) · 2.93 KB
/
functions3.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
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/system/bin/sh
# This script functions will be used in customize.sh and service.sh
#
# Check whether Magisk magic mount compatible or not
function isMagiskMountCompatible()
{
local tmp="$(magisk --path)"
if [ -z "$tmp" ]; then
return 1
elif [ -d "${tmp}/.magisk/mirror/vendor" ]; then
return 0
else
return 1
fi
}
function no_need_this_module()
{
ui_print "*********************************************************************************"
ui_print " This module isn't needed! (because DRC hasn't been enabled on this device)"
ui_print "*********************************************************************************"
}
function policy_file_not_found()
{
ui_print "*********************************************************************************"
ui_print " This module cannot find any audio policy file! "
ui_print "*********************************************************************************"
}
function original_policy_file_not_found()
{
ui_print "*********************************************************************************"
ui_print " This module cannot find any original (unmodified) audio policy file! "
ui_print "*********************************************************************************"
}
# Get the active audio policy configuration fille from the audioserever
function getActivePolicyFile()
{
dumpsys media.audio_policy | awk '
/^ Config source: / {
print $3
}'
}
# stopDRC has two args specifying a main audio policy configuration XML file (eg. audio_policy_configuration.xml) and its dummy to overide
function stopDRC()
{
if [ $# -eq 2 -a -r "$1" -a -w "$2" ]; then
# Copy an original audio_policy_configuration.xml
cp -f "$1" "$2"
# Change audio_policy_configuration.xml file to remove DRC
sed -i 's/speaker_drc_enabled[:space:]*=[:space:]*"true"/speaker_drc_enabled="false"/' "$2"
fi
}
# Get the actual audio configuration XML file name, even for Xiaomi, OnePlus, etc. stock devices
# that may overlay another file on the dummy mount point file
function getActualConfigXML()
{
if [ $# -eq 1 ]; then
local dir=${1%/*}
local fname=${1##*/}
local sname=${fname%.*}
if [ -r "${dir}/${sname}_sec.xml" ]; then
echo "${dir}/${sname}_sec.xml"
elif [ -e "${dir}_qssi" -a -r "${dir}_qssi/${fname}" ]; then
# OnePlus stock pattern
echo "${dir}_qssi/${fname}"
elif [ "${dir##*/}" = "sku_`getprop ro.board.platform`" -a -r "${dir%/*}/${fname}" ]; then
# OnePlus stock pattern2
echo "${dir%/*}/${fname}"
elif [ -r "${dir}/audio/${fname}" ]; then
# Xiaomi stock pattern
echo "${dir}/audio/${fname}"
elif [ -r "${dir}/${sname}_base.xml" ]; then
echo "${dir}/${sname}_base.xml"
else
echo "$1"
fi
fi
}