Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to toggle Airplane Mode on Android 4.2 and above using root?

As is known, on Android 4.2 only system applications can toggle Airplane Mode. But I think it must be available for rooted devices. And I want to impliment it in my application for rooted devices with Build.VERSION.SDK_INT>=17. How to toggle Airplane Mode on rooted devices with Android 4.2?

like image 641
BArtWell Avatar asked Apr 07 '13 09:04

BArtWell


People also ask

How do I turn off airplane mode on Android permanently?

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.

Why is my android stuck airplane mode?

Update Android If the airplane mode problem is intermittent, select the "Settings" app from the All Apps screen then choose "About Phone" and "System Updates." Tap "Check Now" to make sure you're running the most recent version of Android.


1 Answers

There is a new "settings" binary in Android 4.2 You can also use it without su, then your app needs the permission required to change this setting declared in your app's manifest (which would be WRITE_SECURE_SETTINGS for flight mode in 4.2 - which is only granted to apps installed on system partition).

Activate

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

Deactivate

su
settings put global airplane_mode_on 0
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

For other android versions and other settings (flight mode can be activated without root before 4.2) you can use sql injects in settings.db

su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
insert into global values(null, 'airplane_mode_on', 1);

Replace "global" with "system" or "secure" and 'airplane_mode_on' with the key of your desired table entry. For some settings you need to send certain broadcasts afterwards, see example above for flight mode.

To explore your settings.db run this in a terminal app:

su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
.tables
select * from global
select * from secure
select * from system
like image 124
joe1806772 Avatar answered Oct 26 '22 07:10

joe1806772