-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.sh
executable file
·100 lines (88 loc) · 2.05 KB
/
convert.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
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
is_dryrun=n
do_mic1=n
do_mic2=n
while getopts "a:b:dtf" options
do
case "${options}" in
a)
re_isanum='^[0-9]+$'
if ! [[ ${OPTARG} =~ $re_isanum ]]
then
echo "Error: gain must be a positive, whole number."
exit 1
fi
mic1_gain=${OPTARG}
do_mic1=y
;;
b)
re_isanum='^[0-9]+$'
if ! [[ ${OPTARG} =~ $re_isanum ]]
then
echo "Error: gain must be a positive, whole number."
exit 1
fi
mic2_gain=${OPTARG}
do_mic2=y
;;
d)
do_diff=y
;;
f)
echo "Pulling file from phone"
adb pull /system/vendor/etc/mixer_paths_0.xml current.xml
exit 0
;;
t)
is_dryrun=y
;;
:)
echo "Error: -${OPTARG} requires an argument."
exit 1
;;
*)
exit 1
;;
esac
done
# python --version
# Python 3.8.0
params=""
if [ "${do_mic1} " == 'y ' ]
then
params="${params} --mic1_gain ${mic1_gain}"
fi
if [ "${do_mic2} " == 'y ' ]
then
params="${params} --mic2_gain ${mic2_gain}"
fi
python change_mixer.py ${params}
orig_file=mixer_paths_0.xml
py_file=mixer_paths_0_python.xml
proc_file=mixer_paths_0_latest.xml
if [ ! -s ${py_file} ]
then
echo "${py_file} does not exist or it is empty!"
exit 1
fi
# The following is because the output has "value"/> instead of "value" />
# XML-wise it is equivalent but it hampers the diffing of the files
cat ${py_file} | sed 's/"\/>$/" \/>/g' > ${proc_file}
rm ${py_file}
if [ "${do_diff} " == 'y ' ]
then
diff ${orig_file} ${proc_file} | more
fi
# adb --version
# Android Debug Bridge version 1.0.41
# Version 30.0.5-6877874
if [ "${is_dryrun} " != 'y ' ]
then
echo "Pushing file to phone"
adb root
adb remount
adb push ${proc_file} /system/vendor/etc/${orig_file}
adb reboot
else
echo "Not pushing file to phone"
fi