Android13 新增Settings.Global参数相关的文件
frameworks/base/core/api/current.txt
frameworks/base/core/java/android/provider/Settings.java
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
Android13 新增Settings.Global参数的步骤如下
1、定义:frameworks/base/core/java/android/provider/Settings.java
MOVED_TO_GLOBAL.add(Settings.Global.SOURCE_NAME_0);
@Deprecated
public static final String SOURCE_NAME_0 = Global.SOURCE_NAME_0;
@SuppressLint("NoSettingsProvider")
public static final String SOURCE_NAME_0 = "source_name_0";
注:一定要加上@SuppressLint(“NoSettingsProvider”)否则不会生效
2、初始化:frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<string name="source_name_0" translatable="false">VGA</string>
3、frameworks/base/core/api/current.txt
field public static final String SOURCE_NAME_0 = "source_name_0";
field @Deprecated public static final String SOURCE_NAME_0 = "source_name_0";
4、设置默认值:frameworks/base/packages/SettingsProvider/src/com/android/providers/
settings/DatabaseHelper.java
loadStringSetting(stmt, Settings.Global.SOURCE_NAME_0,R.string.source_name_0);
5、使用:
Settings.Global.getString(getActivity().getContentResolver(),Settings.Global.source_name_0,”VGA”);
Settings.Global.putString(getActivity().getContentResolver(),Settings.Global.source_name_0,”HDMI”);