5

I found this question and I tried as follows :

settings put global airplane_mode_on 1
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true

It works really well on Android 4.4.1

but does not work in 4.0.1. (settings: not found / It supports version 4.2 or higher.)

So, i tried again as follows :

adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
adb shell input keyevent 19
adb shell input keyevent 23
adb shell input keyevent 4

Also, this work is strange

"AIRPLANE_MODE_SETTINGS" Window Popup -> Focus on Airplane Mode (no check) -> Volume up........

And it is turned off the screen, does not work

So I think that this way is not good.

Q : How to work like a 'settings put global airplane_mode_on 1' in 4.1 or earlier?

Community
  • 1
  • 1
RedPetals
  • 81
  • 1
  • 6

1 Answers1

4

AIRPLANE_MODE_ON used to belong to system namespace before they moved it to global. So the old settings command would have been settings put system airplane_mode_on 1. But since the settings command is not available in your build you can just modify the value directly in the database instead:

sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value='1' where name='airplane_mode_on';"
Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • Thank you for your answer. I've tried on Android 4.0.1 but I can not find the binary 'settings'. [New command-line binary 'settings' shipping with Android 4.2](http://forum.xda-developers.com/galaxy-nexus/general/tip-command-line-binary-settings-t2180945) – RedPetals Aug 05 '14 at 01:49
  • `settings` command is just a wrapper for the `content://settings` content provider. you can just modify the value directly in the database – Alex P. Aug 05 '14 at 03:20
  • Editing the value in 2.3.3 has no effect on having internet access or not. I still could access the internet with the value set to 1 or 0. – polym May 21 '15 at 17:33
  • @polym You have to broadcast the intent after the setting change as described in the OP's question. – David Ferenczy Rogožan Oct 21 '16 at 16:57