6

I come across a weird problem, I got an application allowing to freely change the font size on Android Device (Font Size Setter). It uses introspection to call some internal Android apis. To do this call, it needs the following permission : android.permission.CHANGE_CONFIGURATION. It worked like a charm under Android 4.0 and up to 4.2 where it does not work anymore. Digging into logs I found out that I can't update font size because it misses this permission. Debbuging to check effective permissions, I got these when inspecting the PackageInfo corresponding to my app

requestedPermissions = {java.lang.String[2]@830038778728}
    [0] = {java.lang.String@830038778760}"android.permission.CHANGE_CONFIGURATION"
    [1] = {java.lang.String@830038778896}"android.permission.WRITE_SETTINGS"
requestedPermissionsFlags = {int[2]@830038779016}
    [0] = 1
    [1] = 3

Does somebody got any clue about what's going on, or any workaround idea ? Thanks a lot for reading me.

Per request, the AndroidManifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="fr.gatay.android.fss"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-sdk android:minSdkVersion="14"/>
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
    <application android:label="@string/app_name" android:icon="@drawable/app_icon">
        <activity android:name=".MainActivity"
        android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
Cedric Gatay
  • 1,553
  • 3
  • 12
  • 17

3 Answers3

5

Check this post http://blog.sightidea.com/?p=44

You can ask your user to grant permission to the app with adb tool:

>adb shell
>pm grant com.yourapp.packagename android.permission.CHANGE_CONFIGURATION
dangVarmit
  • 5,641
  • 2
  • 22
  • 24
situee
  • 2,710
  • 2
  • 22
  • 27
4

The protection level of CHANGE_CONFIGURATION permission has been changed to "system|signature|development" (v4.2) from "dangerous" (v4.1 and below) since Android v4.2

It looks like that no way for 3rd part apps to get CHANGE_CONFIGURATION permission on Android 4.2+ devices. :-(

Sam Lu
  • 3,448
  • 1
  • 27
  • 39
3

At least at present, CHANGE_CONFIGURATION requires for your app either to be signed by the firmware signing key or be installed on a system partition. You can see this by examining the framework manifest, where these permissions are defined.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks, so I guess it is the dead of my application if I can't do this. Is there any known workaround ? – Cedric Gatay Nov 18 '12 at 15:33
  • @CedricGatay: Well, you are using "introspection to call some internal Android apis" -- expecting that to work across releases is not very sensible. That being said, I have no idea what specifically you were using `CHANGE_CONFIGURATION` for. – CommonsWare Nov 18 '12 at 15:36
  • basically I use `IActivityManager#updatePersistentConfiguration` to update the font size Android should use. I didn't find other ways to do so. I'd prefer using a public API though. – Cedric Gatay Nov 18 '12 at 15:45
  • How would one go about procuring a firmware signing key? My org depends on this for an internal tool that sets a bogus locale for testing localization, and this is throwing a wrench in Jellybean QA. – Cheezmeister Feb 21 '13 at 18:46
  • @Cheezmeister: "How would one go about procuring a firmware signing key?" -- you have to build your own firmware. For example, CyanogenMod has some signing key for use in their ROM mod. – CommonsWare Feb 21 '13 at 18:49
  • @CommonsWare Sir is there a workaround to this ? I have faced the same problem on 4.2 and 4.3 too. – Rat-a-tat-a-tat Ratatouille Nov 29 '13 at 14:27