Android lvl 17 airplane API switch

Since the airplane mode setting api lvl 17 has been moved from Settings.System to Settings.Global

The problem is that now I can no longer switch settings. The description of the API is that these settings are read-only. Has anyone managed to find a way to change it?

Pre API lvl 17 that worked:

Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1); 

The lvl 17 API, which I tried and does not work:

 Settings.Global.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, setMode); 

It throws an exception (the documentation says that it should cause a quiet log error):

 11-14 13:39:51.649: E/AndroidRuntime(3509): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS 

but I have this permission in the manifest:

 <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> 

If someone knows a way to solve this problem, it will be awesome!

+4
source share
1 answer

WRITE_SECURE_SETTINGS is a signature|system permission that can only be held by applications that are signed using the firmware signing key or are located on the system partition. Therefore, although you can ask for it, you cannot hold it.

+3
source

Source: https://habr.com/ru/post/1446009/


All Articles