Execute the following command in the command prompt or terminal:
Then run the following command to prevent Airplane Mode from turning off WiFi:
settings put global airplane_mode_radios cell,bluetooth,nfc,wimax
Alternatively, you could do this command to prevent Airplane Mode from turning off WiFi and Bluetooth:
settings put global airplane_mode_radios cell,nfc,wimax
Each item we remove from the list tells Android to leave that radio on when Airplane Mode is toggled on. If you ever want to return things back to how they were, you can execute the following command in an ADB shell prompt:
settings delete global airplane_mode_radios
Normally, Airplane Mode will shut off cellular, WiFi, NFC, Bluetooth and WiMAX (if it exists) radios, but removing one or more of these from the list with the ADB command shown in makes it so that it’s ignored. In the example, both WiFi and Bluetooth stay on when I enable Airplane Mode.
This is why the command only includes cellular, NFC, and WiMAX options. Since we’re leaving those two radios out of the ADB command (WiFi and Bluetooth in this case), Android will leave those radios alone when you toggle Airplane Mode on. You can use any combination here by leaving out any of these options, and even make it so that cellular radios stay on when you turn Airplane Mode on.
So you may want to know that there’s also a way to stop a device from turning on one of these radios when Airplane Mode has been enabled. The preference is controlled by changing the values in the global preference “airplane_mode_toggleable_radios”. For example, you can make it so that you are unable to turn WiFi back on if you choose by entering this command:
settings put global airplane_mode_toggleable_radios bluetooth,nfc
By default, the options given to this command are WiFi, Bluetooth, and NFC. But if you leave one of them out when executing the command above then you stop the device from turning that radio back on. This can be a good idea for a child’s smartphone or tablet, or even used as a fail safe to make sure the radio isn’t turned back on when Airplane Mode is on. This feature will likely be less useful than the one detailed in the big guide above, but it’s something that you may want to be aware of.