forked from phhusson/device_phh_treble
-
Notifications
You must be signed in to change notification settings - Fork 43
/
phh-prop-handler.sh
283 lines (249 loc) · 8.51 KB
/
phh-prop-handler.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/system/bin/sh
set -o pipefail
display_usage() {
echo -e "\nUsage:\n ./phh-prop-handler.sh [prop]\n"
}
if [ "$#" -ne 1 ]; then
display_usage
exit 1
fi
prop_value=$(getprop "$1")
xiaomi_toggle_dt2w_proc_node() {
DT2W_PROC_NODES=("/proc/touchpanel/wakeup_gesture"
"/proc/tp_wakeup_gesture"
"/proc/tp_gesture")
for node in "${DT2W_PROC_NODES[@]}"; do
[ ! -f "${node}" ] && continue
echo "Trying to set dt2w mode with /proc node: ${node}"
echo "$1" >"${node}"
[[ "$(cat "${node}")" -eq "$1" ]] # Check result
return
done
return 1
}
xiaomi_toggle_dt2w_event_node() {
for ev in $(
cd /sys/class/input || return
echo event*
); do
isTouchscreen=false
if getevent -p /dev/input/$ev |grep -e 0035 -e 0036|wc -l |grep -q 2;then
isTouchscreen=true
fi
[ ! -f "/sys/class/input/${ev}/device/device/gesture_mask" ] &&
[ ! -f "/sys/class/input/${ev}/device/wake_gesture" ] &&
! $isTouchscreen && continue
echo "Trying to set dt2w mode with event node: /dev/input/${ev}"
if [ "$1" -eq 1 ]; then
# Enable
sendevent /dev/input/"${ev}" 0 1 5
return
else
# Disable
sendevent /dev/input/"${ev}" 0 1 4
return
fi
done
return 1
}
xiaomi_toggle_dt2w_ioctl() {
if [ -c "/dev/xiaomi-touch" ]; then
echo "Trying to set dt2w mode with ioctl on /dev/xiaomi-touch"
# 14 - Touch_Doubletap_Mode
xiaomi-touch 14 "$1"
return
fi
return 1
}
restartAudio() {
setprop ctl.restart audioserver
audioHal="$(getprop |sed -nE 's/.*init\.svc\.(.*audio-hal[^]]*).*/\1/p')"
setprop ctl.restart "$audioHal"
setprop ctl.restart vendor.audio-hal-2-0
setprop ctl.restart audio-hal-2-0
}
if [ "$1" == "persist.sys.phh.asus.dt2w" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
setprop persist.asus.dclick 1
else
setprop persist.asus.dclick 0
fi
exit
fi
if [ "$1" == "persist.sys.phh.asus.usb.port" ]; then
setprop persist.vendor.usb.controller.default "$prop_value"
exit
fi
if [ "$1" == "persist.sys.phh.xiaomi.dt2w" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
xiaomi_toggle_dt2w_proc_node "$prop_value"
# Fallback to event node method
xiaomi_toggle_dt2w_event_node "$prop_value"
# Fallback to ioctl method
xiaomi_toggle_dt2w_ioctl "$prop_value"
exit
fi
if [ "$1" == "persist.sys.phh.oppo.dt2w" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
echo "$prop_value" >/proc/touchpanel/double_tap_enable
exit
fi
if [ "$1" == "persist.sys.phh.oppo.gaming_mode" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
echo "$prop_value" >/proc/touchpanel/game_switch_enable
exit
fi
if [ "$1" == "persist.sys.phh.oppo.usbotg" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [ -e /sys/class/power_supply/usb/otg_switch ]; then
echo "$prop_value" >/sys/class/power_supply/usb/otg_switch
else
echo "$prop_value" >/sys/class/oplus_chg/usb/otg_switch
fi
exit
fi
if [ "$1" == "persist.sys.phh.transsion.usbotg" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
OTG_PATH=$(find /sys/ -path *tran_battery/OTG_CTL)
if [ -n "$OTG_PATH" ]; then
echo "$prop_value" >$OTG_PATH
fi
exit
fi
if [ "$1" == "persist.sys.phh.transsion.dt2w" ]; then
if [[ "$prop_value" != "1" && "$prop_value" != "2" ]]; then
exit 1
fi
echo cc${prop_value} > /proc/gesture_function
exit
fi
if [ "$1" == "persist.sys.phh.allow_binder_thread_on_incoming_calls" ]; then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
resetprop_phh ro.telephony.block_binder_thread_on_incoming_calls false
else
resetprop_phh --delete ro.telephony.block_binder_thread_on_incoming_calls
fi
exit
fi
if [ "$1" == "persist.sys.phh.disable_audio_effects" ];then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
resetprop_phh ro.audio.ignore_effects true
else
resetprop_phh --delete ro.audio.ignore_effects
fi
restartAudio
exit
fi
if [ "$1" == "persist.sys.phh.caf.audio_policy" ];then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
sku="$(getprop ro.boot.product.vendor.sku)"
if [[ "$prop_value" == 1 ]];then
umount /vendor/etc/audio
umount /vendor/etc/audio
if [ -f /vendor/etc/audio_policy_configuration_sec.xml ];then
mount /vendor/etc/audio_policy_configuration_sec.xml /vendor/etc/audio_policy_configuration.xml
elif [ -f /vendor/etc/audio/sku_${sku}_qssi/audio_policy_configuration.xml ] && [ -f /vendor/etc/audio/sku_$sku/audio_policy_configuration.xml ];then
umount /vendor/etc/audio
mount /vendor/etc/audio/sku_${sku}_qssi/audio_policy_configuration.xml /vendor/etc/audio/sku_$sku/audio_policy_configuration.xml
elif [ -f /vendor/etc/audio/audio_policy_configuration.xml ];then
mount /vendor/etc/audio/audio_policy_configuration.xml /vendor/etc/audio_policy_configuration.xml
elif [ -f /vendor/etc/audio_policy_configuration_base.xml ];then
mount /vendor/etc/audio_policy_configuration_base.xml /vendor/etc/audio_policy_configuration.xml
fi
else
umount /vendor/etc/audio_policy_configuration.xml
umount /vendor/etc/audio/sku_$sku/audio_policy_configuration.xml
if [ $(find /vendor/etc/audio -type f |wc -l) -le 3 ];then
mount /mnt/phh/empty_dir /vendor/etc/audio
fi
fi
restartAudio
exit
fi
if [ "$1" == "persist.sys.phh.vsmart.dt2w" ];then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
echo 0 > /sys/class/vsm/tp/gesture_control
else
echo > /sys/class/vsm/tp/gesture_control
fi
exit
fi
if [ "$1" == "persist.sys.phh.backlight.scale" ];then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
if [ -f /sys/class/leds/lcd-backlight/max_brightness ];then
setprop persist.sys.qcom-brightness "$(cat /sys/class/leds/lcd-backlight/max_brightness)"
elif [ -f /sys/class/backlight/panel0-backlight/max_brightness ];then
setprop persist.sys.qcom-brightness "$(cat /sys/class/backlight/panel0-backlight/max_brightness)"
elif [ -f /sys/class/backlight/sprd_backlight/max_brightness ];then
setprop persist.sys.qcom-brightness "$(cat /sys/class/backlight/sprd_backlight/max_brightness)"
fi
else
setprop persist.sys.qcom-brightness -1
fi
exit
fi
if [ "$1" == "persist.sys.phh.disable_soundvolume_effect" ];then
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
exit 1
fi
if [[ "$prop_value" == 1 ]];then
mount /system/phh/empty /vendor/lib/soundfx/libvolumelistener.so
mount /system/phh/empty /vendor/lib64/soundfx/libvolumelistener.so
else
umount /vendor/lib/soundfx/libvolumelistener.so
umount /vendor/lib64/soundfx/libvolumelistener.so
fi
restartAudio
exit
fi
if [ "$1" == "persist.bluetooth.system_audio_hal.enabled" ]; then
# Migrate from 0/1 to false/true first
if [[ "$prop_value" == "0" ]]; then
setprop persist.bluetooth.system_audio_hal.enabled false
exit 1
elif [[ "$prop_value" == "1" ]]; then
setprop persist.bluetooth.system_audio_hal.enabled true
exit 1
fi
if [[ "$prop_value" != "false" && "$prop_value" != "true" ]]; then
exit 1
fi
if [[ "$prop_value" == "true" ]]; then
setprop persist.bluetooth.bluetooth_audio_hal.disabled false
setprop persist.bluetooth.a2dp_offload.disabled true
resetprop_phh ro.bluetooth.a2dp_offload.supported false
else
resetprop_phh --delete persist.bluetooth.bluetooth_audio_hal.disabled
resetprop_phh --delete persist.bluetooth.a2dp_offload.disabled
resetprop_phh --delete ro.bluetooth.a2dp_offload.supported
fi
restartAudio
exit
fi