Background

Certain applications can only function properly in specific compatibility modes during runtime. Therefore, there is a need to design a universal compatibility settings framework. This framework should be capable of reading user configuration values and determining whether to enable compatibility configuration features. This document serves as a guide for developers on how to develop their own compatibility framework and incorporate new compatibility configuration options.

Steps

1. Adding Configuration

First, add the following configuration to the file "comp_config.xml" located in the directory "openfde/boringdroidsystemui/tree/fde_w/app/main/res/raw/":

1<compatible> 2 <keycode>isAllowHideDecorCaption</keycode> 3 <keydesc>{ 4 "en":"Allow to hide the title bar", 5 "ch":"允许隐藏标题栏" 6 }</keydesc> 7 <defaultvalue>false</defaultvalue> 8 <inputtype>switch</inputtype> 9 <notes> 10 { 11 "en":"test text", 12 "ch":"测试文本" 13 } 14 </notes> 15 <optionjson>[]</optionjson> 16</compatible>

Field Descriptions:

  • keycode: Compatibility Configuration Key

  • keydesc: Compatibility Description used for display purposes. Requires configuration in both Chinese and English.

  • defaultvalue: Default value

  • inputtype: Currently supports three types: switch, input, and select.

  • notes: Notes to guide users on how to use the configuration. Requires configuration in both Chinese and English.

  • optionjson: If the inputtype is select, the optionjson option needs to be configured.

2. Framework Interface Invocation

Asynchronous Method:

1CompatibleConfig.queryTrainingData(Context context, String packageName, String keycode)

Synchronous Method:

1CompatibleConfig.queryValueData(Context context, String packageName, String keycode)

Parameter Descriptions:

  • context: Context object

  • packageName: Package name

  • keycode: Compatibility Configuration Key