Search code examples
androidadb

Use ADB to check if Airplane mode is turned on?


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


Solution

  • adb shell settings get global airplane_mode_on returns 0 for airplane_mode off and 1 for airplane_mode on.