一、加载默认亮度
1、top_level_settings.xml

2、AndroidManifest.xml

3、DisplaySettings
①getPreferenceScreenResId

②buildPreferenceControllers

4、display_settings.xml

5、AutoBrightnessPreferenceController

6、BrightnessLevelPreferenceController
①getCurrentBrightness

②convertLinearToGammaFloat

7、 Z:\k630_64\vendor\tinno\k630_64\trunk\etc\settings-config.xml
<setting type="system" name="screen_brightness_float" value="0.35896719"/>

8、/data/system/users/0/settings_system.xml
<setting id="491" name="screen_brightness_float" value="0.3597016" package="android" defaultValue="0.35896719" defaultSysSet="true" />
二、字体调节
1、display_settings

2、FontSizePreferenceController

3、ToggleFontSizePreferenceFragment

4、values-zh-rCN/arrays.xml

5、arrays.xml

6、Z:\k630_64\vendor\tinno\k630_64\trunk\etc\settings-config.xml
<setting type="system" name="font_scale" value="1.0"/>
三、屏幕超时
1、TimeoutPreferenceController

2、arrays.xml

3、Z:\k630_64\vendor\tinno\k630_64\trunk\etc\settings-config.xml

四,显示实时电量
1、top_level_settings.xml

2、AndroidManifest.xml

3、TopLevelBatteryPreferenceController
配置项中配置了TopLevelBatteryPreferenceController控制器,它继承自AbstractPreferenceController,这个抽象类用于对所有菜单项进行统一管理(例如展示或隐藏,监听点击事件等)。
public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop {
// 电量改变广播
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
// 当前配置项
private Preference mPreference;
// 电量信息
private BatteryInfo mBatteryInfo;
//初始化电量改变广播
public TopLevelBatteryPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext);
mBatteryBroadcastReceiver.setBatteryChangedListener(type -> {
BatteryInfo.getBatteryInfo(mContext, info -> {
mBatteryInfo = info;
updateState(mPreference);
}, true /* shortString */);
});
}
// 控制该项是否可用
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
// 获取当前的配置项
mPreference = screen.findPreference(getPreferenceKey());
}
@Override
public void onStart() {
// 注册广播
mBatteryBroadcastReceiver.register();
}
@Override
public void onStop() {
// 取消注册广播
mBatteryBroadcastReceiver.unRegister();
}
@Override
public CharSequence getSummary() {
// 返回电量概览
return getDashboardLabel(mContext, mBatteryInfo);
}
// 获取电量信息
static CharSequence getDashboardLabel(Context context, BatteryInfo info) {
if (info == null || context == null) {
return null;
}
CharSequence label;
if (!info.discharging && info.chargeLabel != null) {
label = info.chargeLabel;
} else if (info.remainingLabel == null) {
label = info.batteryPercentString;
} else {
label = context.getString(R.string.power_remaining_settings_home_page,
info.batteryPercentString,
info.remainingLabel);
}
return label;
}
}
4、总结
- 在构造方法中初始化电量改变广播
- 在onStart()和onStop()中注册和取消注册广播
- 一旦收到电量改变广播,则把电量信息保存在mBatteryInfo中
- 然后执行updateState(),该方法会调用getSummary()把信息设置给当前配置项
- getSummary()中将mBatteryInfo保存的电量信息解析出来
五、系统提供者
Android的系统设置数据存放在/data/data/com.android.providers.settings/databases/settings.db 中
是否有默认值
在寻找一个开关的默认值时,首先要明白一点,该开关是否存在默认值,以及该开关状态是否有状态保存(一般状态存储在settings的db中)。 判断条件: 在reboot(重启)之后开关状态仍旧保存或者是在reset(恢复出厂设置)之后开关状态恢复到默认的,才能找到默认值。
在reboot之后开关状态仍旧保存的,表示状态存储在了db中。 在reset之后开关状态恢复默认的,表示状态有一个默认值。
比如像wiif开关,蓝牙开关,gps开关等,都有默认值,并且状态值都在db中保存。
至于像WiFi热点开关这种在reboot之后,状态没有保存,那么你就别白费力气来找他的默认值或者状态存储值了
修改默认值
大部分的开关状态都存储在了SettingProvider的db中,与状态值相关的有三个文件
- /frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java:该文件中对状态值进行存储
- /frameworks/base/packages/SettingsProvider/res/values/defaults.xml:定义了开关状态的默认值
- /frameworks/base/core/java/android/provider/Settings.java:定义了各开关状态默认值存储时对应的key
- Z:\k630_64\vendor\tinno\k630_64\trunk\etc\settings-config.xml 亮度、字体大小、锁屏等设置的默认值在这里设置
以屏幕超时为例
1、TimeoutPreferenceController
@Override
public void updateState(Preference preference) {
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
//系统没有提供SCREEN_OFF_TIMEOUT才使用FALLBACK_SCREEN_TIMEOUT_VALUE
final long currentTimeout = Settings.System.getLong(mContext.getContentResolver(),
SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
}
2、DatabaseHelper
并不是所有的默认值都是通过读取defaults.xml的,也有的是在DatabaseHelper.java中直接设置
如loadSetting(stmt, Settings.Secure.ADB_ENABLED, 1); 这个ADB Debugging开关就是直接在数据库文件中写入的。
关于USB Debugging 开关也可以在systemui的systemui/usb/StorageNotification.java文件中去设置,可以判断是否有IMEI号
分析代码时如果发现在defaults.xml找不到这一项就直接在DatabaseHelper.java文件中查找。
private void loadSystemSettings(SQLiteDatabase db) {
//数据库名
private static final String DATABASE_NAME = "settings.db";
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
//SCREEN_OFF_TIMEOUT设置def_screen_off_timeout
//def_screen_off_timeout在defaults.xml中
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
.....
private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) {
//
loadSetting(stmt, key,
Integer.toString(mContext.getResources().getInteger(resid)));
}
}
private void loadSetting(SQLiteStatement stmt, String key, Object value) {
//
stmt.bindString(1, key);
stmt.bindString(2, value.toString());
stmt.execute();
}
.....
static final String PARTNER_SETTINGS_PATH ="etc/settings-config.xml";
private void updateSystemSecureSettings(SQLiteDatabase db) {
FileReader settingsReader;
final File settingsFile = new File(Environment.getRootDirectory(), PARTNER_SETTINGS_PATH);
try {
settingsReader = new FileReader(settingsFile);
} catch (FileNotFoundException e) {
Log.w(TAG, "Can't open " + Environment.getRootDirectory() + "/" + PARTNER_SETTINGS_PATH);
return;
}
3、defaults.xml
<resources>
<bool name="def_dim_screen">true</bool>
//对应SCREEN_OFF_TIMEOUT
<integer name="def_screen_off_timeout">15000</integer>
<integer name="def_sleep_timeout">-1</integer>
<bool name="def_airplane_mode_on">false</bool>
......
4、Settings.java
/**
* The amount of time in milliseconds before the device goes to sleep or begins
* to dream after a period of inactivity. This value is also known as the
* user activity timeout period since the screen isn't necessarily turned off
* when it expires.
*
* <p>
* This value is bounded by maximum timeout set by
* {@link android.app.admin.DevicePolicyManager#setMaximumTimeToLock(ComponentName, long)}.
*/
//使用adb命令获取得到,区分大小写:screen_off_timeout
public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
5、settings-config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
<setting type="global" name="auto_time" value="1"/>
<setting type="global" name="auto_time_zone" value="1"/>
<setting type="system" name="time_12_24" value="24"/>
<setting type="system" name="date_format" value="dd/MM/yyyy"/>
<setting type="system" name="accelerometer_rotation" value="0"/>
//屏幕锁定时间
<setting type="system" name="screen_off_timeout" value="120000"/>
<setting type="system" name="sound_effects_enabled" value="0"/>
<setting type="system" name="haptic_feedback_enabled" value="0"/>
<setting type="system" name="dtmf_tone" value="0"/>
<setting type="system" name="lockscreen_sounds_enabled" value="0"/>
<setting type="system" name="screen_brightness" value="56"/>
<setting type="system" name="screen_brightness_mode" value="1"/>
//字体大小
<setting type="system" name="font_scale" value="1.0"/>
<setting type="system" name="status_bar_show_battery_percent" value="1"/>
<setting type="global" name="install_non_market_apps" value="0"/>
<setting type="secure" name="backup_enabled" value="0"/>
<setting type="secure" name="charging_sounds_enabled" value="0"/>
//屏幕亮度
<setting type="system" name="screen_brightness_float" value="0.35896719"/>
<setting type="secure" name="backup_transport" value="com.google.android.backup/.BackupTransportService"/>
<setting type="secure" name="default_input_method" value="com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME"/>
<setting type="secure" name="enabled_input_methods" value="com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME:com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService:com.google.android.inputmethod.pinyin/.PinyinIME"/>
<setting type="system" name="ipo_setting" value="0"/>
<setting type="global" name="device_name" value="K630"/>
<!--
<setting type="system" name="lowrawapp_optimize_white_packages" value="com.tencent.mm,com.tencent.mobileqq,com.facebook.katana,com.whatsapp,com.skype.rover,com.snapchat.android,com.tnmb.bootclean,com.ape.cubes,com.ape.folio,com.ape.retailmode,com.tinno.autotesttool,com.tinno.fieldtester,com.antutu.ABenchMark,com.antutu.benchmark.full,it.telecomitalia.cubovision,it.telecomitalia.selectedbytim,com.telecomitalia.cubomusica"/>
<setting type="system" name="lowrawapp_optimize_limit_num" value="4"/>
<setting type="system" name="lowrawapp_optimize_limit_sum" value="6"/>
<setting type="system" name="lowrawapp_optimize_Custom_packages" value="com.kugou.android"/>
<setting type="system" name="lowrawapp_optimize_cpuload_normal" value="12.5"/>
<setting type="system" name="lowrawapp_optimize_cpuload_high" value="13.5"/>
<setting type="system" name="lowrawapp_optimize_cpuload_ultrahigh" value="16.5"/>
<setting type="system" name="lowrawapp_optimize_topPss_large" value="260000"/>
<setting type="system" name="lowrawapp_optimize_topPss_resume" value="150000"/>
<setting type="system" name="lowrawapp_optimize_topPss_ultralarge" value="340000"/>
-->
<!-- FEATURE_SINGLE_HAND hsg 20190904-->
<setting type="global" name="enable_single_hand" value="1" />
<!-- TINNO END -->
</resources>
6、默认值
| value | 含义 | key |
| def_dim_screen | 0=no 1=yes:是否让屏幕亮度渐渐变暗 | Settings.System.DIM_SCREEN |
| def_screen_off_timeout | 无操作多少秒后灭屏 | Settings.System.SCREEN_OFF_TIMEOUT |
| def_sleep_timeout | 无操作多少秒后休眠(该值要比灭屏时间长,因为在休眠之前会先灭屏) | Settings.Secure.SLEEP_TIMEOUT |
| def_airplane_mode_on | 飞行模式是否默认开启 | Settings.Global.AIRPLANE_MODE_ON |
| def_theater_mode_on | 剧场模式是否默认开启 | Settings.Global.THEATER_MODE_ON |
| def_airplane_mode_radios | 开启飞行模式时会关掉的开关列表(通常会包括蓝牙,wifi,nfc等) | Settings.Global.AIRPLANE_MODE_RADIOS |
| airplane_mode_toggleable_radios | 飞行模式下用户可以手动开启的开关列表 | Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS |
| def_auto_time | 1=yes, 0=no是否从网络自动同步日期、时间、时区 | Settings.Global.AUTO_TIME |
| def_auto_time_zone | 1=yes, 0=no是否从网络自动同步时区 | Settings.Global.AUTO_TIME_ZONE |
| def_accelerometer_rotation | 1=yes, 0=no是否开启自动旋转(即是否根据加速度传感器旋转屏幕方向) | Settings.System.ACCELEROMETER_ROTATION |
| def_screen_brightness | 屏幕默认亮度(取值区间为0–255) | Settings.System.SCREEN_BRIGHTNESS |
| def_screen_brightness_automatic_mode | 是否开启屏幕亮度的自动调节 | Settings.System.SCREEN_BRIGHTNESS_MODE |
| def_window_animation_scale | 1=yes, 0=no窗口动画缩放 | Settings.System.WINDOW_ANIMATION_SCALE |
| def_window_transition_scale | 1=yes, 0=no窗口透明度 | Settings.System.TRANSITION_ANIMATION_SCALE |
| def_haptic_feedback | 是否开启触摸反馈,不清楚什么含义 | Settings.System.HAPTIC_FEEDBACK_ENABLED |
| def_bluetooth_on | 0=disabled. 1=enabled.默认是否开启蓝牙 | Settings.Global.BLUETOOTH_ON |
| def_wifi_display_on | 0=disabled. 1=enabled.是否开启wifi显示 | Settings.Global.WIFI_DISPLAY_ON |
| def_install_non_market_apps | 是否允许安装不是在应用市场下载的app:1 = 允许通过安装包安装,0 = 不允许通过安装包安装 | Settings.Secure.INSTALL_NON_MARKET_APPS |
| def_package_verifier_enable | 在安装app之前进行证书检查,1审查,0不审查 | Settings.Global.PACKAGE_VERIFIER_ENABLE |
| def_location_providers_allowed | 是否开启gps,若字符串为null则默认不开启gps,还需借助LOCATION_MODE进行判断 | Settings.Secure.LOCATION_PROVIDERS_ALLOWED |
| assisted_gps_enabled | 是否开启辅助的gps应用 | Settings.Global.ASSISTED_GPS_ENABLED |
| def_netstats_enabled | 是否开启流量统计 | Settings.Global.NETSTATS_ENABLED |
| def_usb_mass_storage_enabled | 是否开启usb海量存储 | Settings.Global.USB_MASS_STORAGE_ENABLED |
| def_wifi_on | wifi默认是否开启 | Settings.Global.WIFI_ON |
| def_wifi_sleep_policy | wifi是否休眠(会和移动网络来回切换)取值为0-never, 1-only when plugged in, 2-always | Settings.Global.WIFI_SLEEP_POLICY |
| def_networks_available_notification_on | 是否通知用户打开网络 | Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON |
| def_backup_enabled | 0-disabled, 1-enabled是否开启设置备份 | Settings.Secure.BACKUP_ENABLED |
| def_backup_transport | 用于备份或者恢复的传输文件 | Settings.Secure.BACKUP_TRANSPORT |
| def_notification_pulse | 当有通知来时,led灯是否要重复闪烁 | Settings.System.NOTIFICATION_LIGHT_PULSE |
| def_mount_play_notification_snd | 当有事件来临时是否播放通知铃声 | Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND |
| def_mount_ums_autostart | 是否自动启动主机检测系统 | Settings.Secure.MOUNT_UMS_AUTOSTART |
| def_mount_ums_prompt | 是否在主机检测时显示通知 | Settings.Secure.MOUNT_UMS_PROMPT |
| def_mount_ums_notify_enabled | Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED | 当开启ums时是否显示通知 |
| def_power_sounds_enabled | 电量过低时是否铃声通知 | Settings.Global.POWER_SOUNDS_ENABLED |
| def_low_battery_sound | 低电量时播放的铃声文件来源 | Settings.Global.LOW_BATTERY_SOUND |
| def_dock_sounds_enabled | 当插拔电源时是否播放声音 | Settings.Global.DOCK_SOUNDS_ENABLED |
| def_desk_dock_sound | 插上电源时播放的音频文件 | Settings.Global.DESK_DOCK_SOUND |
| def_desk_undock_sound | 拔下电源时播放的音频文件 | Settings.Global.DESK_UNDOCK_SOUND |
| def_car_dock_sound | 使用车载电源充电时播放的音频文件 | Settings.Global.CAR_DOCK_SOUND |
| def_car_undock_sound | 当从车载电源拔下时播放的音频文件 | Settings.Global.CAR_UNDOCK_SOUND |
| def_lockscreen_sounds_enabled | 当解锁或是锁屏时是否播放声音 | Settings.System.LOCKSCREEN_SOUNDS_ENABLED |
| def_lock_sound | 锁屏时播放的音频文件 | Settings.Global.LOCK_SOUND |
| def_unlock_sound | 解锁时播放的音频文件 | Settings.Global.UNLOCK_SOUND |
| def_trusted_sound | 在未解锁的情况下设备进入到可信任状态时播放的音频文件 | Settings.Global.TRUSTED_SOUND |
| def_wireless_charging_started_sound | 开启无线充电时播放声音 | Settings.Global.WIRELESS_CHARGING_STARTED_SOUND |
| def_lockscreen_disabled | 第一次开机时默认不锁屏(若要彻底去掉锁屏页面还需要在别的方法中设置) | Settings.System.LOCKSCREEN_DISABLED |
| def_device_provisioned | 设备是否已经被配置(该参数考虑的时多用户不同时刻使用同一个设备的情况) | Settings.Global.DEVICE_PROVISIONED |
| def_dock_audio_media_enabled | 使用dock音频输出媒体 | Settings.Global.DOCK_AUDIO_MEDIA_ENABLED |
| def_vibrate_in_silent | 静音模式下是否允许震动 | Settings.System.VIBRATE_IN_SILENT |
| def_accessibility_script_injection | 是否增强js的屏幕阅读性 | Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION |
| def_accessibility_speak_password | 访问模式下是否语音播报密码 | Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD |
| def_low_battery_sound_timeout | 当经过一定时间后,如果低电量提醒为播放声音,则灭屏 | Settings.Global.LOW_BATTERY_SOUND_TIMEOUT |
| def_lock_screen_show_notifications | 是否在锁屏界面显示通知 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS |
| def_lock_screen_allow_private_notifications | 允许在锁屏界面上显示私有通知,就像是解锁状态下一样 | Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS |
| def_wifi_scan_always_available | 设置-wlan-高级-随时扫描开关 | Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE |
7、adb命令获取/修改/设置值
C:\Users\jiabao.guan>adb shell settings get system screen_off_timeout 60000 C:\Users\jiabao.guan>adb shell settings put system guan 66 C:\Users\jiabao.guan>adb shell settings get system guan 66 C:\Users\jiabao.guan>adb shell settings put system screen_off_timeout 120000 C:\Users\jiabao.guan>adb shell settings get system screen_off_timeout 120000
六:添加辅助菜单
测试目标:
为系统设置最底部增加一项菜单项(title:辅助功能),进入辅助功能菜单项,设置一个<SwitchPreference>项(高对比度字体),和两个<Preference>项(颜色调整和多彩屏幕)。
1、top_level_settings.xml
在res/xml/top_level_settings.xml配置文件中增加一个<Preference>标签,并为<Preference>标签设置相关属性(fragment属性和controller属性需要配置该类的全限定类名)。
<Preference
android:key="assistant_function"
android:title="@string/assistant_function"
android:summary="@string/assistant_summary"
android:icon="@drawable/ic_homepage_support"
android:order="30"
android:fragment="com.android.settings.assistant.AssistantFunctionDashboardFragment"
settings:controller="com.android.settings.assistant.AssistantFunctionPreferenceController"/>
2、assistant
配置好后创建com.android.settings.assistant包,在该包下创建这两个类。(AssistantFunctionDashboardFragment类和AssistantFunctionPreferenceController类)
3、AssistantFunctionDashboardFragment
package com.android.settings.assistant;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.wiosfeature.firebase.ServiceUtils;
import android.content.Context;
import android.os.Bundle;
import androidx.preference.Preference;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import android.provider.SearchIndexableResource;
import java.util.ArrayList;
import java.util.List;
import android.util.Log;
/**
* @Author : 柒
* @Time : 2022/8/24 14:17
*/
public class AssistantFunctionDashboardFragment extends SettingsPreferenceFragment {
private static final Object TAG = "AssistantFunctionDashboardFragment";
private Context mContext;
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_SYSTEM_CATEGORY;
}
//创建二级菜单
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.assistant_function);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
mContext = context;
}
// 为每个二级菜单项设置点击事件
@Override
public boolean onPreferenceTreeClick(Preference preference) {
String key = preference.getKey();
android.util.Log.i("AssistantFunctionDashboardFragment", "guan+onPreferenceTreeClick: " + key);
switch (key){
case "color_adjustment":
android.util.Log.i("AssistantFunctionDashboardFragment", "guan+color_adjustment: " + key);
break;
case "colorful_screen":
android.util.Log.i("AssistantFunctionDashboardFragment", "guan+colorful_screen: " + key);
break;
}
return true;
}
/**
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.assistant_function) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return super.isPageSearchEnabled(context);
}
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled) {
return super.getXmlResourcesToIndex(context, enabled);
}
};
}
4、AssistantFunctionPreferenceController
package com.android.settings.assistant;
import com.android.settings.core.BasePreferenceController;
import android.content.Context;
/**
* @Author : 柒
* @Time : 2022/8/24 14:17
*/
public class AssistantFunctionPreferenceController extends BasePreferenceController {
//调用父类的构造方法
public AssistantFunctionPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
//实现该菜单项的显示
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
}
5、AssistantFunctionDashboardActivity
在Settings目录下创建
package com.android.settings;
/**
* @Author : 柒
* @Time : 2022/8/24 15:11
*/
public class AssistantFunctionDashboardActivity extends SettingsActivity{
}
6、assistant_function.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/assistant_function"
android:key="assistant_function_key">
<SwitchPreference
android:key="high_contrast_font"
android:title="@string/high_contrast_font"
android:summary="@string/high_contrast_font_summary"
/>
<Preference
android:key="color_adjustment"
android:title="@string/color_adjustment"
android:summary="@string/color_adjustment_summary"/>
<Preference
android:key="colorful_screen"
android:title="@string/colorful_screen"
android:summary="@string/colorful_screen_summary"/>
</PreferenceScreen>
7、AndroidManifest.xml
<!--辅助功能-->
<activity
android:name="Settings$AssistantFunctionDashboardActivity"
android:label="@string/assistant_function">
<intent-filter android:priority="12">
<action android:name="com.android.settings.action.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.assistant.AssistantFunctionDashboardFragment" />
</activity>
8、Settings
public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
9、SettingsGateway
在SettingsGateway类的ENTRY_FRAGMENTS数组中加入AssistantFunctionDashboardFragment类名,在SETTINGS_FOR_RESTRICTED数组中加入AssistantFunctionPreferenceController类名
public static final String[] SETTINGS_FOR_RESTRICTED = {
// Home page
AssistantFunctionPreferenceController.class.getName(),
.....
}
public static final String[] ENTRY_FRAGMENTS = {
AssistantFunctionDashboardFragment.class.getName(),
....
}
10、strings
<string name="assistant_function">assistant & function</string>
<string name="assistant_summary">assistant & summary</string>
<string name="high_contrast_font">high_contrast & contrast_font</string>
<string name="high_contrast_font_summary">high_contrast_font & summary</string>
<string name="color_adjustment">color & adjustment</string>
<string name="color_adjustment_summary">color_adjustment & summary</string>
<string name="colorful_screen">colorful & screen</string>
<string name="colorful_screen_summary">colorful_screen & summary</string>
<string name="assistant_function" msgid="3235725053332345774">"辅助功能"</string>
<string name="assistant_summary" msgid="3235725053332345775">"高对比度字体、颜色调整、多彩屏幕"</string>
<string name="high_contrast_font" msgid="3235725053332345776">"高对比度字体"</string>
<string name="high_contrast_font_summary" msgid="3235725053332345777">"高对比度字体"</string>
<string name="color_adjustment" msgid="3235725053332345778">"颜色调整"</string>
<string name="color_adjustment_summary" msgid="3235725053332345779">"颜色调整"</string>
<string name="colorful_screen" msgid="3235725053332345710">"多彩屏幕"</string>
<string name="colorful_screen_summary" msgid="3235725053332345711">"多彩屏幕"</string>



















