简体   繁体   English

以编程方式更改 Android 中的模拟色彩空间和其他开发人员选项(已解决)

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

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 specific toggle I'm after, which is "Simulate color space".我希望能够在我的应用程序中修改开发人员选项设置,我尝试查看 Settings.Global、Settings.System 和 Settings.Secure,但没有涵盖我所追求的特定切换,即“模拟色彩空间” .

Would anyone be able to point me in the right direction in trying to locate this setting provider?任何人都可以指出我在尝试找到此设置提供程序时的正确方向吗?

Great news!, I have solved this now!好消息!,我现在已经解决了这个问题! (Requires ROOT or ADB ) (需要ROOTADB

Please note, to successfully modify secure settings you must grant your app permission to android.permission.WRITE_SECURE_SETTINGS otherwise it will crash;请注意,要成功修改安全设置,您必须向您的应用授予android.permission.WRITE_SECURE_SETTINGS权限,否则会崩溃; 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.您可以通过两种方式执行此操作,或者从 ADB Shell:“ pm grant your.package.name android.permission.WRITE_SECURE_SETTINGS ”或通过请求 root 权限并在您的应用程序中作为 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.我在 Settings.Secure 类中找到了这些字符串常量,您将能够找到其他开发人员设置并根据自己的喜好修改它们。

Below are the values for the other screen-space modes:以下是其他屏幕空间模式的值:

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

Enjoy!享受!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM