Use ADB to check if Airplane mode is turned on?

2019-03-16 12:02发布

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

标签: android adb
2条回答
beautiful°
2楼-- · 2019-03-16 12:43

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

查看更多
对你真心纯属浪费
3楼-- · 2019-03-16 12:46

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

查看更多
登录 后发表回答