Skip to content

Instantly share code, notes, and snippets.

@ouija
Created July 29, 2019 00:08
Show Gist options
  • Save ouija/873a1d8ed697229865c7f5fa2baf5b4b to your computer and use it in GitHub Desktop.
Save ouija/873a1d8ed697229865c7f5fa2baf5b4b to your computer and use it in GitHub Desktop.
r8723bs wifi sleep fix
#!/system/bin/sh
while true
do
# check device wakefulness state
WAKE_STATE=$(dumpsys power | grep -m1 'mWakefulness' | cut -d = -f 2)
#echo "Wakefulness: $WAKE_STATE"
if [ "$WAKE_STATE" = "Asleep" ]; then
# disable wifi
WIFI=$(lsmod | grep -m1 r8723bs)
if [ ! -z "$WIFI" ]; then
svc wifi disable && rmmod r8723bs
fi
elif [ "$WAKE_STATE" = "Awake" ]; then
# enable wifi if not loaded
WIFI=$(lsmod | grep -m1 r8723bs)
if [ -z "$WIFI" ]; then
modprobe r8723bs && svc wifi enable
fi
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment