Programmatically change Simulate Color Space and other developer options in Android (Solved)

后端 未结 1 652
无人及你
无人及你 2021-01-17 05:00

I am looking to be able to modify developer option settings in my app, I have tried looking in the Settings.Global, Settings.System and Settings.Secure but none cover the sp

相关标签:
1条回答
  • 2021-01-17 05:36

    Great news!, I have solved this now! (Requires ROOT or ADB)

    Please note, to successfully modify secure settings you must grant your app permission to android.permission.WRITE_SECURE_SETTINGS otherwise it will crash; you can do this in two ways, either from the ADB Shell: "pm grant your.package.name android.permission.WRITE_SECURE_SETTINGS" or by requesting root privileges and executing it within your app as SU.

    Use the following lines to enable the Monochrome setting:

    Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "1");
    Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "0");
    

    and to disable:

    Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "0");
    Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "-1");
    

    I located these string constants in the Settings.Secure class and you will be able to find other developer settings and modify them to your fancy.

    Below are the values for the other screen-space modes:

    DISABLED = -1
    MONOCHROMACY = 0
    PROTANOMALY = 11
    CORRECT_DEUTERANOMALY = 12
    TRITANOMALY= 13
    

    Enjoy!

    0 讨论(0)
提交回复
热议问题