frameworksbasepackagesSettingsProvider中android6.0之后用不在用settings.db这个数据了,会存储在/data/system/users/0这个目录三个xml文件下: 在SettingsProvidersrccomandroidproviderssettingsDatabaseHelper.java中 由于公司是定制产品需要ota强制默认打开wifi开关 不执行的会获取SettingsProvidersrccomandroidproviderssettingsDatabaseHelper.java中的版本号DATABASE_VERSION导致相应的bugSettingsProvider 修改默认值数据及更新数值
SettingsProvider数据存储
在SettingsProvidersrccomandroidproviderssettingsSettingsProvider.java中创建 final class SettingsRegistry { private static final String DROPBOX_TAG_USERLOG = "restricted_profile_ssaid"; private static final String SETTINGS_FILE_GLOBAL = "settings_global.xml"; private static final String SETTINGS_FILE_SYSTEM = "settings_system.xml"; private static final String SETTINGS_FILE_SECURE = "settings_secure.xml"; private final SparseArray<SettingsState> mSettingsStates = new SparseArray<>(); private GenerationRegistry mGenerationRegistry;
private File getSettingsFile(int key) { if (isGlobalSettingsKey(key)) { final int userId = getUserIdFromKey(key); return new File(Environment.getUserSystemDirectory(userId), SETTINGS_FILE_GLOBAL); } else if (isSystemSettingsKey(key)) { final int userId = getUserIdFromKey(key); return new File(Environment.getUserSystemDirectory(userId), SETTINGS_FILE_SYSTEM); } else if (isSecureSettingsKey(key)) { final int userId = getUserIdFromKey(key); return new File(Environment.getUserSystemDirectory(userId), SETTINGS_FILE_SECURE); } else { throw new IllegalArgumentException("Invalid settings key:" + key); } } ``` ## 调试的时候获取或者设置相关的默认值 通过三种类型system, secure, global 可以分别获取和这种值 设置: - adb shell settings put system [key] [value] - adb shell settings put global [key] [value] - adb shell settings put secure default_input_method com.sohu.inputmethod.sogouoem/.SogouIME 获取: - adb shell settings get secure default_input_method - adb shell settings get global device_provisioned - adb shell settings get system [key] 也可以进入/data/system/users/0输入如下命令获取 - cat settings_global.xml | grep device_provisioned ## 修改系统默认的一些设置配置值 当我们要修改一些默认值时一般修改SettingsProvider/res/values/defaults.xml可以修改通用属性 ```java <resources> <bool name="def_dim_screen">true</bool>自动关屏 开 <integer name="def_screen_off_timeout">30000</integer> Android睡眠时间为1分钟 //假设默认打开wifi可以将下面自动设置为true <bool name="def_wifi_on">false</bool> //wifi 关 ...
private void loadGlobalSettings(SQLiteDatabase db) { SQLiteStatement stmt = null; try { stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" + " VALUES(?,?);"); // --- Previously in 'system' loadBooleanSetting(stmt, Settings.Global.AIRPLANE_MODE_ON, R.bool.def_airplane_mode_on); loadBooleanSetting(stmt, Settings.Global.THEATER_MODE_ON, R.bool.def_theater_mode_on); //获取wifi默认值并设置 loadBooleanSetting(stmt, Settings.Global.WIFI_ON, R.bool.def_wifi_on);
强制更新数据
private final class UpgradeController { //ota升级强制更改默认值需要该字段自增一如 private static final int SETTINGS_VERSION = 132; private final int mUserId;
if (currentVersion == 131) { // Initialize new multi-press timeout to default value // final SettingsState systemSecureSettings = getSecureSettingsLocked(userId); // final String oldValue = systemSecureSettings.getSettingLocked( // Settings.Secure.MULTI_PRESS_TIMEOUT).getValue(); // if (TextUtils.equals(null, oldValue)) { // systemSecureSettings.insertSettingLocked( // Settings.Secure.MULTI_PRESS_TIMEOUT, // String.valueOf(getContext().getResources().getInteger( // R.integer.def_multi_press_timeout_millis)), // SettingsState.SYSTEM_PACKAGE_NAME); } currentVersion = 132; }
参考文献:
https://www.jianshu.com/p/3922f68b3560
https://www.jianshu.com/p/7815d573b12f
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算