Write_Secure_Settings Permission Error Even When Added in Manifest

WRITE_SECURE_SETTINGS permission error even when added in Manifest

Firstly, as you have read before, WRITE_SECURE_SETTINGS is NOT available to applications! So you cannot use this permission regardless whether you are on rooted or production builds.

So, if you wish to enable this setting, create your own firmware that does what you need and load that firmware on whatever devices you wish. Or, contribute your changes to existing firmware mods (e.g., Cyanogen).

Some other applications use techniques like Reflection using Java to gain access to functions not exposed via API, you can probably try the same.

Secondly, adb remount does not work as is with production builds unless the phone is rooted or firmware enables it by default.

How to set the Permission WRITE_SECURE_SETTINGS in android?

WRITE_SECURE_SETTINGS is not available to applications. No app outside of the system/firmware can get that permisssion.

Please check this answer

android.permission.WRITE_SECURE_SETTINGS error

WRITE_SECURE_SETTINGS is a signatureOrSystem permission, meaning that ordinary SDK applications cannot hold it. Only apps that are related to the firmware can hold this permission.

Can't get WRITE_SETTINGS permission

To use WRITE_SETTINGS, based on the docs:

  1. Have the <uses-permission> element in the manifest as normal.

  2. Call Settings.System.canWrite() to see if you are eligible to write out settings.

  3. If canWrite() returns false, start up the ACTION_MANAGE_WRITE_SETTINGS activity so the user can agree there to allow your app to actually write to settings.

In other words, writing to settings is now a double-opt-in (agree to install, agree separately in Settings to allow), akin to device admin APIs, accessibility services, etc.

Also note that I have not tried using these yet — this is based on research that I did yesterday on Android 6.0 changes.

Permission is only granted to system app

In Eclipse:

Window -> Preferences -> Android -> Lint Error Checking.

In the list find an entry with ID = ProtectedPermission. Set the Severity to something lower than Error. This way you can still compile the project using Eclipse.

In Android Studio:

File -> Settings -> Editor -> Inspections

Under Android Lint, locate Using system app permission. Either uncheck the checkbox or choose a Severity lower than Error.

Android app unable to modify system settings

My resolution needed to incorporate a few different things. The solution I ended up taking was to run the app as a superuser and it seems to properly set the system settings now. Note that I am running this application on a rooted device.

First, in the Manifest, I needed to remove this line from the application tag:

android:permission="android.permission.WRITE_SECURE_SETTINGS"

Not sure of the reasoning. It looks like you can't call secure permissions within the application tag.

In my MainActivity, I added the following su call to my try statement, and added in the settings commands beneath:

Process p = Runtime.getRuntime().exec("su");

Thanks to @The-Metal-Beard for his direction!



Related Topics



Leave a reply



Submit