Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ADB to check if Airplane mode is turned on?

Tags:

android

adb

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

like image 787
JJackJi Avatar asked Nov 21 '13 19:11

JJackJi


People also ask

How do I know if my Android phone is in Airplane Mode?

Android smartphone or tabletAccess the Settings utility. On the Settings screen, tap the Network & Internet option. On the Network & Internet screen, tap the toggle switch to the right of the Airplane Mode option to turn it on or off.

How do I check my Airplane Mode?

Open your phone's Settings app. Tap Network & internet. Turn Airplane mode on or off. When Airplane mode is on, Wi-Fi, mobile networks, and Bluetooth are all turned off.


2 Answers

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

like image 122
Anand Avatar answered Oct 04 '22 21:10

Anand


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

like image 26
Alex P. Avatar answered Oct 04 '22 22:10

Alex P.