From b8ba68ae2bc48410b389c0d611605dbeb91507eb Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sun, 3 May 2020 18:05:30 +0200 Subject: [PATCH] Add properties to use vendor audio policy, and to disable audio effects --- phh-prop-handler.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/phh-prop-handler.sh b/phh-prop-handler.sh index ba0e0b7..e1eea4a 100644 --- a/phh-prop-handler.sh +++ b/phh-prop-handler.sh @@ -52,6 +52,15 @@ xiaomi_toggle_dt2w_event_node() { 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.xiaomi.dt2w" ]; then if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then exit 1 @@ -90,3 +99,33 @@ if [ "$1" == "persist.sys.phh.oppo.usbotg" ]; then echo "$prop_value" >/sys/class/power_supply/usb/otg_switch 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 ro.audio.ignore_effects true + else + resetprop --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 + + if [[ "$prop_value" == 1 ]];then + umount /vendor/etc/audio + mount /audio_policy_configuration.xml /vendor/etc/audio_policy_configuration.xml + else + umount /vendor/etc/audio_policy_configuration.xml + mount /mnt/phh/empty_dir /vendor/etc/audio + fi + restartAudio + exit +fi