Today while trying to figure out how to get my wife’s phone to keep WiFi on if she puts her phone into airplane mode, I learned that Android 9 and later disallow automation apps like Automate from controlling WiFi anymore during airplane mode. Android 10 appears to disable control of WiFi completely outside of the settings panel.
I came across an xda-developers post
of how to keep WiFi on entirely when entering airplane mode.
The key is to use adb
and set airplane_mode_radios
appropriately.
I have never looked into adb
before, but I found it surprisingly easy to install,
even for my Gentoo system. Once installed via portage,
and turning on my phone’s USB Debugging in Android’s Developer Options, I simply ran:
$ adb shell
# See the current settings
F5321:/ $ settings get global airplane_mode_radios
cell,wifi,bluetooth,nfc,wimax
# Only disable the cell and wimax radios when going into airplane mode
F5321:/ $ settings put global airplane_mode_radios cell,wimax
Voila, now turning airplane mode on kept WiFi on!
But I did notice that bluetooth kept turning off, even though
I had excluded it from the airplane_mode_radios
setting. This wasn’t a big
worry, since apps can still enable and disable Bluetooth, and I could
use an automation app to turn it back on, but I was still curious.
For some reason, I ended up rebooting my phone, and all of a sudden,
the bluetooth setting took effect and stayed on when entering airplane mode!
The airplane_mode_radios
setting was unchanged, but evidently
some of it only took effect if set during phone startup.