I know that we can do the following:
adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
adb shell input keyevent 19 ; adb shell input keyevent 23
to turn on/off airplane mode on android device.
However, is there anyway to check if currently the device has airplane mode turned on through ADB ?
I'm asking this because the two lines of code above will toggle airplane mode without knowing whether it is turning it on or off. But I need a way to make sure that airplane mode is indeed on/off through ADB.
Please help me out!
Thanks in advance
You can use the following commands after doing adb shell.
Turn on:
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
Turn off:
adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
This will make airplane mode ON/OFF
adb shell settings get global airplane_mode_on
returns0
for airplane_mode off and1
for airplane_mode on.