I'm testing my app under Android 6 emulator and I found that it started crashing with following exception:
Caused by: java.lang.SecurityException: net.hubalek.android.xxx was not granted this permission: android.permission.WRITE_SETTINGS.
at android.os.Parcel.readException(Parcel.java:1599)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1322)
at android.provider.Settings$System.putStringForUser(Settings.java:1671)
at android.provider.Settings$System.putIntForUser(Settings.java:1776)
at android.provider.Settings$System.putInt(Settings.java:1770)
....
After further research I found that according javadoc at http://developer.android.com/reference/android/Manifest.permission.html#WRITE_SETTINGS it has protectionLevel="signature"
I guess that in previous versions of Android the protection was lower (normal
or dangerous
, I can't recall).
My question is: Is there any way how to overcome this change? At https://developer.android.com/reference/android/R.attr.html#protectionLevel there is written
A permission that the system is to grant only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.
but I don't understand how to fulfill this condition when it regards system permissions.