Reputation: 4205
I want to modify something in Settings.secure database, just as the android Settings app do:
Settings.Secure.putString(
getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE,
setting);
I have added following permission in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
Unfortunately, the app aborts saying:
E/DatabaseUtils( 147): Writing exception to parcel E/DatabaseUtils( 147): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS E/DatabaseUtils( 147): at com.android.providers.settings.SettingsProvider.checkWritePermissions(SettingsProvider.java:211) E/DatabaseUtils( 147): at com.android.providers.settings.SettingsProvider.insert(SettingsProvider.java:552) E/DatabaseUtils( 147): at android.content.ContentProvider$Transport.insert(ContentProvider.java:198) E/DatabaseUtils( 147): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146) E/DatabaseUtils( 147): at android.os.Binder.execTransact(Binder.java:320) E/DatabaseUtils( 147): at dalvik.system.NativeStart.run(Native Method)
If I sign this app with the platform key it would be OK, but for different systems, the platform key seems different. It can't be run on other devices.
How can I accomplish this?
Upvotes: 1
Views: 3257
Reputation: 4205
Answer my own question:
In frameworks/base/core/res/AndroidManifest.xml, WRITE_SECURE_SETTINGS is declared with protectionLevel signatureOrSystem. So it's impossible for a normal app to obtain this permission, unless it's put in system image, or signed with the same key used by framework res apk.
Upvotes: 1