diff --git a/post_sleep.sh b/post_sleep.sh index b78827fc..1471b451 100644 --- a/post_sleep.sh +++ b/post_sleep.sh @@ -26,21 +26,16 @@ function reprobe_module_if_loaded() MODULE_RELOAD_LIST="" # set RESTART_WIFI to true if a wifi module is going to be reloaded, note that users will have to manually turn on wifi again after a wificond restart RESTART_WIFI=false -# set RESET_BT to true if a bluetooth module is going to be reloaded, note that user might have to manually turn on bluetooth again after bthal restart -RESTART_BT=false ### EXAMPLE: ### if [ "$BOARD" == "xxx" ] ### then -### MODULE_RELOAD_LIST="$MODULE_RELOAD_LIST iwlwifi btusb" +### MODULE_RELOAD_LIST="$MODULE_RELOAD_LIST iwlwifi" ### RESTART_WIFI=true -### RESTART_BT=true ### fi -# usually bluetooth breaks when waking from s3 resets the device, then bthal continues to communicate to it with existing sockets as if the reset had never happened -# while disabling bthal before suspend then starting it after is enough on the steamdeck, reprobing the module should make it work better in a more general sense -RESTART_BT=true -MODULE_RELOAD_LIST="$MODULE_RELOAD_LIST btusb" +# note that btusb is unloaded in pre_sleep.sh, since it takes more than 10+ seconds to unload btusb right after wake +# ie. do not put btusb into the reload list # users can use this to flag wificond restart USER_RESTART_WIFI_FLAG=/data/etc/wake_reload_wifi @@ -49,33 +44,11 @@ then RESTART_WIFI=true fi -# users can use this to flag bluetooth restart -USER_RESTART_BT_FLAG=/data/etc/wake_reload_bt -if [ -e $USER_RESTART_BT_FLAG ] -then - RESTART_BT=true -fi - -# stop services if requested -if $RESTART_BT -then - pm disable com.android.bluetooth - sleep 0.5 - setprop ctl.stop btlinux-1.1 - setprop ctl.stop vendor.bluetooth-1-1 -fi - if $RESTART_WIFI then setprop ctl.stop wificond fi -# setprop ctl.stop should be instant, but just in case -if $RESTART_WIFI || $RESTART_BT -then - sleep 0.2 -fi - # perform module reprobe MODULE_RELOAD_LOG=/data/wake_module_reload_log rm -f $MODULE_RELOAD_LOG @@ -103,20 +76,20 @@ then setprop ctl.start wificond fi -if $RESTART_BT -then - bthal=$(getprop ro.bliss.bthal) - case $bthal in - "btlinux") - setprop ctl.start btlinux-1.1 - ;; - "celadon") - setprop ctl.start vendor.bluetooth-1-1 - ;; - esac - sleep 0.5 - pm enable com.android.bluetooth -fi +# probe btusb since it was unloaded in pre_sleep.sh +modprobe btusb + +# bthal and com.android.bluetooth were disabled in pre_sleep.sh +bthal=$(getprop ro.bliss.bthal) +case $bthal in + "btlinux") + setprop ctl.start btlinux-1.1 + ;; + "celadon") + setprop ctl.start vendor.bluetooth-1-1 + ;; +esac +pm enable com.android.bluetooth # allow user defined actions USER_SCRIPT=/data/etc/post_sleep.sh diff --git a/pre_sleep.sh b/pre_sleep.sh index 98be46d8..c2018695 100644 --- a/pre_sleep.sh +++ b/pre_sleep.sh @@ -9,6 +9,21 @@ export UEVENT=$(cat $DMIPATH/uevent) # put prebaked actions here +# stop com.android.bluetooth +pm disable com.android.bluetooth +bt_pid=$(pidof com.android.bluetooth) +if [ -n "$bt_pid" ] +then + kill -KILL $bt_pid +fi + +# stop bluetooth hal +setprop ctl.stop vendor.bluetooth-1-1 +setprop ctl.stop btlinux-1.1 + +# unload btusb here, because unloading could take 10+ seconds right after wake +modprobe -r btusb + # allow user defined actions USER_SCRIPT=/data/etc/pre_sleep.sh if [ -e $USER_SCRIPT ]