2020-03-26 01:44:58 +00:00
|
|
|
#!/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
|
2020-04-28 14:48:57 +00:00
|
|
|
isTouchscreen=false
|
|
|
|
if getevent -p /dev/input/$ev |grep -e 0035 -e 0036|wc -l |grep -q 2;then
|
|
|
|
isTouchscreen=true
|
|
|
|
fi
|
2020-03-26 01:44:58 +00:00
|
|
|
[ ! -f "/sys/class/input/${ev}/device/device/gesture_mask" ] &&
|
2020-04-28 14:48:57 +00:00
|
|
|
[ ! -f "/sys/class/input/${ev}/device/wake_gesture" ] &&
|
|
|
|
! $isTouchscreen && continue
|
2020-03-26 01:44:58 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-05-03 16:05:30 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-03-26 01:44:58 +00:00
|
|
|
if [ "$1" == "persist.sys.phh.xiaomi.dt2w" ]; then
|
2020-03-26 15:30:57 +00:00
|
|
|
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
|
2020-03-26 01:44:58 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! xiaomi_toggle_dt2w_proc_node "$prop_value"; then
|
|
|
|
# Fallback to event node method
|
|
|
|
xiaomi_toggle_dt2w_event_node "$prop_value"
|
|
|
|
fi
|
|
|
|
exit $?
|
|
|
|
fi
|
2020-03-26 14:41:24 +00:00
|
|
|
|
|
|
|
if [ "$1" == "persist.sys.phh.oppo.dt2w" ]; then
|
2020-03-26 15:30:57 +00:00
|
|
|
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
|
2020-03-26 14:41:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$prop_value" >/proc/touchpanel/double_tap_enable
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "persist.sys.phh.oppo.gaming_mode" ]; then
|
2020-03-26 15:30:57 +00:00
|
|
|
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
|
2020-03-26 14:41:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$prop_value" >/proc/touchpanel/game_switch_enable
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "persist.sys.phh.oppo.usbotg" ]; then
|
2020-03-26 15:30:57 +00:00
|
|
|
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
|
2020-03-26 14:41:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$prop_value" >/sys/class/power_supply/usb/otg_switch
|
|
|
|
exit
|
|
|
|
fi
|
2020-05-03 16:05:30 +00:00
|
|
|
|
|
|
|
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
|
2021-02-22 09:04:19 +00:00
|
|
|
resetprop_phh ro.audio.ignore_effects true
|
2020-05-03 16:05:30 +00:00
|
|
|
else
|
2021-02-22 09:04:19 +00:00
|
|
|
resetprop_phh --delete ro.audio.ignore_effects
|
2020-05-03 16:05:30 +00:00
|
|
|
fi
|
|
|
|
restartAudio
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "persist.sys.phh.caf.audio_policy" ];then
|
|
|
|
if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-06-07 17:43:33 +00:00
|
|
|
sku="$(getprop ro.boot.product.vendor.sku)"
|
2020-05-03 16:05:30 +00:00
|
|
|
if [[ "$prop_value" == 1 ]];then
|
2020-10-13 15:19:48 +00:00
|
|
|
umount /vendor/etc/audio
|
2020-05-03 16:05:30 +00:00
|
|
|
umount /vendor/etc/audio
|
2021-06-07 17:41:21 +00:00
|
|
|
|
2021-06-07 17:43:33 +00:00
|
|
|
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
|
2021-06-07 17:41:21 +00:00
|
|
|
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
|
2021-03-28 16:56:14 +00:00
|
|
|
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
|
2021-07-05 18:39:10 +00:00
|
|
|
|
|
|
|
if [ -f /vendor/lib/hw/audio.bluetooth_qti.default.so ];then
|
|
|
|
cp /vendor/etc/a2dp_audio_policy_configuration.xml /mnt/phh
|
|
|
|
sed -i 's/bluetooth_qti/a2dp/' /mnt/phh/a2dp_audio_policy_configuration.xml
|
|
|
|
mount /mnt/phh/a2dp_audio_policy_configuration.xml /vendor/etc/a2dp_audio_policy_configuration.xml
|
|
|
|
chcon -h u:object_r:vendor_configs_file:s0 /vendor/etc/a2dp_audio_policy_configuration.xml
|
|
|
|
chmod 644 /vendor/etc/a2dp_audio_policy_configuration.xml
|
|
|
|
fi
|
2020-05-03 16:05:30 +00:00
|
|
|
else
|
|
|
|
umount /vendor/etc/audio_policy_configuration.xml
|
2021-06-07 17:43:33 +00:00
|
|
|
umount /vendor/etc/audio/sku_$sku/audio_policy_configuration.xml
|
2021-07-05 18:39:10 +00:00
|
|
|
umount /vendor/etc/a2dp_audio_policy_configuration.xml
|
|
|
|
rm /mnt/phh/a2dp_audio_policy_configuration.xml
|
2021-06-07 17:41:21 +00:00
|
|
|
if [ $(find /vendor/etc/audio -type f |wc -l) -le 3 ];then
|
|
|
|
mount /mnt/phh/empty_dir /vendor/etc/audio
|
|
|
|
fi
|
2020-05-03 16:05:30 +00:00
|
|
|
fi
|
|
|
|
restartAudio
|
|
|
|
exit
|
|
|
|
fi
|
2020-06-01 17:29:55 +00:00
|
|
|
|
|
|
|
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
|
2020-12-05 23:58:01 +00:00
|
|
|
|
|
|
|
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)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
setprop persist.sys.qcom-brightness -1
|
|
|
|
fi
|
|
|
|
exit
|
|
|
|
fi
|
2021-12-02 09:52:32 +00:00
|
|
|
|
|
|
|
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
|