Several files associated with the setting default value in Frameworks
/frameworks/base/packages/settingsprovider/res/values/defaults.xml
/frameworks/base/packages/settingsprovider/src/com/android/providers/settings/databasehelper.java
The relevant values are defined in the Defaults.xml file, and Databasehelper.java will read the corresponding values to save to ContentProvider
Here's a look at what values are defined in Defaults.xml
<?xml version= "1.0" encoding= "Utf-8"?><!--/** * Copyright (c), the Android Open Source Project * * Licensed Under the Apache License, Version 2.0 (the "License"); * You are not a use this file except in compliance with the License. * Obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * unless required by applic Able law or agreed to in writing, software * Distributed under the License are distributed on a "as is" BASIS, * without W Arranties or CONDITIONS of any KIND, either express OR implied. * See the License for the specific language governing permissions and * limitations under the License. */--><resources> <bool name= "Def_dim_screen" >true</bool> <integer name= "def_screen_off_ Timeout ">60000</integer> <bool name=" def_airplane_mode_on ">false</bool> <!-- comma-separated List of Bluetooth, WiFi, and cell. --<string name= "Def_airplane_mode_radios" translatable= "FALSe ">cell,bluetooth,wifi,nfc,wimax</string> <string name=" Airplane_mode_toggleable_radios " Translatable= "false" >bluetooth,wifi,nfc</string> <bool name= "Def_auto_time" >true</bool> < BOOL Name= "Def_auto_time_zone" >true</bool> <bool name= "Def_accelerometer_rotation" >true</bool > <!--Default screen brightness, from 0 to 255. 102 is 40%. --<integer name= "def_screen_brightness" >102</integer> <bool name= "Def_screen_brightness_ Automatic_mode ">false</bool> <fraction name=" Def_window_animation_scale ">100%</fraction> <fraction name= "Def_window_transition_scale" >100%</fraction> <bool name= "Def_haptic_feedback" > true</bool> <bool name= "def_bluetooth_on" >false</bool> <bool name= "def_wifi_display_on" > false</bool> <bool name= "Def_install_non_market_apps" >false</bool> <bool name= "Def_package_ Verifier_eNable ">true</bool> <!--comma-separated List of location providers. Network location was off by default because it requires user opt-in via Setup Wizard or Settings. --<string name= "def_location_providers_allowed" translatable= "false" >gps</string> <bool name= "a Ssisted_gps_enabled ">true</bool> <bool name=" def_netstats_enabled ">true</bool> <bool name= "Def_usb_mass_storage_enabled" >true</bool> <bool name= "def_wifi_on" >false</bool> <!--0 = = N ever, 1 = = if plugged in, 2 = Always, <integer name= "Def_wifi_sleep_policy" >2</integer> &L T;bool name= "def_networks_available_notification_on" >true</bool> <bool name= "def_backup_enabled" > false</bool> <!--string Name= "Def_backup_transport" translatable= "false" >android/ com.android.internal.backup.localtransport</string--> <string name= "Def_backup_transport" traNslatable= "false" >com.google.android.backup/. backuptransportservice</string> <!--Default value for whether or not to pulse the notification LEDs when there is a pending notification--and <bool name= "Def_notification_pulse" >true</bool> <bool name= "Def_mount_play_notification_snd" >true</bool> <bool name= "Def_mount_ums_autostart" >false</bool > <bool name= "def_mount_ums_prompt" >true</bool> <bool name= "def_mount_ums_notify_enabled" > true</bool> <!--user interface sound Effects--<integer name= "def_power_sounds_enabled" >1</i nteger> <string name= "Def_low_battery_sound" translatable= "false" >/system/media/audio/ui/lowbattery.ogg </string> <integer name= "def_dock_sounds_enabled" >0</integer> <string name= "Def_desk_dock_ Sound "translatable=" false ">/system/media/audio/ui/Dock.ogg</string> <string name=" Def_desk_undock_ Sound "tRanslatable= "false" >/system/media/audio/ui/Undock.ogg</string> <string name= "Def_car_dock_sound" Translatable= "false" >/system/media/audio/ui/Dock.ogg</string> <string name= "Def_car_undock_sound" Translatable= "false" >/system/media/audio/ui/Undock.ogg</string> <integer name= "Def_lockscreen_sounds _enabled ">1</integer> <string name=" Def_lock_sound "translatable=" false ">/system/media/audio/ui/ lock.ogg</string> <string name= "Def_unlock_sound" translatable= "false" >/system/media/audio/ui/ unlock.ogg</string> <string name= "Def_wireless_charging_started_sound" translatable= "false" >/system/ media/audio/ui/wirelesschargingstarted.ogg</string> <bool name= "def_lockscreen_disabled" >false</ bool> <bool name= "def_device_provisioned" >false</bool> <integer name= "Def_dock_audio_media_ Enabled >1</integer> <!--notifications Use Ringer volume-<bool nAme= "Def_notifications_use_ring_volume" >true</bool> <!--Default for Settings.System.VIBRATE_IN_SILENT --<bool name= "Def_vibrate_in_silent" >true</bool> <!--Default for Settings.Secure.ACCESSIBILITY_ Script_injection--<bool name= "Def_accessibility_script_injection" >false</bool> <!--Default for Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD--<bool name= "Def_accessibility_speak_password" >false< /bool> <!--Default for Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS-<string name= "DEF_ACC Essibility_web_content_key_bindings "translatable=" false "> <!--dpad/trackball up-traverse Previous on Current axis and send an event. -0x13=0x01000100; <!--Dpad/trackball Down-traverse next on the current axis and the Send an event. -0x14=0x01010100; <!--Dpad/trackball Left-traverse Previous on the character Navigation axis and send event. -0x15=0x02000001; <!--Dpad/trackball Right-traverse next on the character navigation axis end send event. -0x16=0x02010001; <!--Alt+dpad/trackball Up-go to the top of the document. -0x200000013=0x02000601; <!--Alt+dpad/trackball Down-go to the bottom of the document. -0x200000014=0x02010601; <!--Alt+dpad/trackball Left-transition from a axis to another and sends an event.--> <!--axis tra Nsitions:2, 1; -0x200000015=0x03020101; <!--Alt+dpad/trackball Right-transition from a axis to another and sends an event. -<!--Axis Transitions:1-2; -0x200000016=0x03010201; <!--Alt+g-go to the previous heading and send an event. -0x200000023=0x02000301; <!--Alt+h-go to the next heading and SEnd an event. -0x200000024=0x02010301; <!--alt+comma-transition to sentence navigation axis and send an event. -<!--Axis Transitions:7-2; -0x200000037=0x03070201; <!--alt+period-transition to the Default Web view behavior axis and send an event. -<!--Axis transitions:0-7; 1-> 7; 2-7; -0x200000038=0x03000701:0x03010701:0x03020701; </string> <!--Default for Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION_URL--<string name= "def_a Ccessibility_screen_reader_url "translatable=" false "> https://ssl.gstatic.com/accessibility/javascript/ Android/androidvox_v1.js </string> <!--Default for Settings.Secure.TOUCH_EXPLORATION_ENABLED-< ; bool Name= "def_touch_exploration_enabled" >false</bool> <!--Default value for Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE-- <fraction name= "Def_accessibility_display_magnification_scale" >200%</fraction> <!--Default value fo R Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED--<bool name= "Def_accessibility_display_ Magnification_enabled ">false</bool> <!--Default value for Settings.Secure.ACCESSIBILITY_DISPLAY_ Magnification_auto_update--<bool name= "Def_accessibility_display_magnification_auto_update" >true</ Bool> <!--Default for Settings.System.USER_ROTATION-<integer name= "Def_user_rotation" >0</inte Ger> <!--Default for Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE. <=0 if no limit-to <integer name= "Def_download_manager_max_bytes_over_mobile" >-1</integer> <!- -Default for Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE. <=0 if no limit-to <integer name= "Def_download_manager_recommended_max_bytes_over_mobile" >-1</ Integer> <!--DefaUlt for Settings.Secure.LONG_PRESS_TIMEOUT_MILLIS-<integer name= "Def_long_press_timeout_millis" >500 </integer> <!--Default for Settings.System.POINTER_SPEED--<integer name= "Def_pointer_speed" >0& Lt;/integer> <!--Default for DTMF tones enabled--<bool name= "def_dtmf_tones_enabled" >true</boo L> <!--m:default for UI touch sounds disabled, Google Defaulit is enable--<bool name= "Def_sound_eff Ects_enabled ">false</bool> <!--Development Settings--<bool name=" def_stay_on_while_plugged_in " >false</bool> <!--number of retries for connecting to DHCP. Value here is the same as wifistatemachine.default_max_dhcp_retries--<integer name= "Def_max_dhcp_retries" >9 </integer> <!--Default for Settings.Secure.USER_SETUP_COMPLETE--<bool name= "Def_user_setup_comple TE ">false</bool> <!--Default for Settings.Global.LOW_Battery_sound_timeout. 0 means no timeout; Battery sounds'll always play >0 are milliseconds of screen-off time after which battery sounds would not play --<integer name= "Def_low_battery_sound_timeout" >0</integer></resources>
In the XML definition above, string has a property translatable= "false" means that there is no need to translate in multi-language, here is not the above definition one by one explanation, only to <string name= "def_location_providers _allowed "translatable=" false ">gps</string> for analysis
In Databasehelper.java, there is a function to load the fields in the. Xml.
private void Loadsecuresettings (Sqlitedatabase db) {sqlitestatement stmt = null; try {stmt = db.compilestatement ("INSERT OR IGNORE into secure (name,value)" + "VALUES (?,?) ;"); Loadsetting (stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, Mutils.getstringvalue (Settings.Secure.LOCATIO n_providers_allowed, r.string.def_location_providers_allowed)); String wifiwatchlist = Systemproperties.get ("Ro.com.android.wifi-watchlist"); if (! Textutils.isempty (wifiwatchlist)) {loadsetting (stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, Wifiwatchli ST); }//Don ' t do this. The Systemserver would initialize adb_enabled from A//persistent system property instead. Loadsetting (stmt, Settings.Secure.ADB_ENABLED, 1); Allow mocks locations default, based on Build loadsetting (stmt, Settings.Secure.ALLOW_MOCK_LOCATION, "1". Equals (Systemproperties.get ("Ro.allow.mock.location"))? 1:0); Loadsecure35settings (stmt); Loadbooleansetting (stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND, R.bool.def_mount_play_notificatio N_SND); Loadbooleansetting (stmt, Settings.Secure.MOUNT_UMS_AUTOSTART, R.bool.def_mount_ums_autostart); Loadbooleansetting (stmt, Settings.Secure.MOUNT_UMS_PROMPT, r.bool.def_mount_ums_prompt); Loadbooleansetting (stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED, r.bool.def_mount_ums_notify_enable D); Loadbooleansetting (stmt, Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, R.bool.def_accessibility_scrip T_injection); Loadstringsetting (stmt, Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, R.string.def_accessibil Ity_web_content_key_bindings); Loadintegersetting (stmt, Settings.Secure.LONG_PRESs_timeout, R.integer.def_long_press_timeout_millis); Loadbooleansetting (stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, r.bool.def_touch_exploration_enable D); Loadbooleansetting (stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, r.bool.def_accessibility_speak_p Assword); Loadstringsetting (stmt, Settings.Secure.ACCESSIBILITY_SCREEN_READER_URL, R.STRING.DEF_ACCESSIBILITY_SCR Een_reader_url); if (Systemproperties.getboolean ("Ro.lockscreen.disable.default", false) = = True) {loadsetting (stmt, Settin Gs. system.lockscreen_disabled, "1"); } else {loadbooleansetting (stmt, Settings.System.LOCKSCREEN_DISABLED, R.bool.def_lo ckscreen_disabled); } loadbooleansetting (stmt, Settings.Secure.SCREENSAVER_ENABLED, Com.android.internal.r.bool. Config_dreamsenabledbydefault); Loadbooleansetting (stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, com.android.internal.r.bool.co Nfig_dreamsactivatedondockbydefault); Loadbooleansetting (stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, Com.android.internal.r.bool.con Fig_dreamsactivatedonsleepbydefault); Loadstringsetting (stmt, Settings.Secure.SCREENSAVER_COMPONENTS, COM.ANDROID.INTERNAL.R.STRING.CONFIG_DR Eamsdefaultcomponent); Loadstringsetting (stmt, Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT, com.android.internal.r.string.co Nfig_dreamsdefaultcomponent); Loadbooleansetting (stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, r.bool.def_access ibility_display_magnification_enabled); Loadfractionsetting (stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, R.FRACTION.DEF_ACC Essibility_display_magnification_scale, 1); Loadbooleansetting (stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE, R.bool.def_accessibility_display_magnification_auto_update); Loadbooleansetting (stmt, Settings.Secure.USER_SETUP_COMPLETE, R.bool.def_user_setup_complete); Mutils.loadcustomsecuresettings (stmt); } finally {if (stmt! = null) stmt.close (); } }
In the code above, there is
Loadsetting (stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
Mutils.getstringvalue (Settings.Secure.LOCATION_PROVIDERS_ALLOWED, r.string.def_location_providers_allowed)); To load the string, save it to the database, and the database name is:
private static final String database_name = "SETTINGS.DB";
Static String dbnameforuser (final int userhandle) { //The owner gets the unadorned DB name; if (Userhandle = = Userhandle.user_owner) { return database_name; } else { //place the DATABASE in the USER-SP Ecific Data tree So it's //cleaned up automatically when the user is deleted. File Databasefile = new file ( environment.getusersystemdirectory (userhandle), database_name); return Databasefile.getpath (); } } Public Databasehelper (context context, int userhandle) { Super (context, Dbnameforuser (userhandle), NULL, DATABASE _version); Mcontext = context; Muserhandle = Userhandle; }
To see how to read the data in the ContentProvider, you can use Getcontentresolver () to query the corresponding field in setting
Of course not all default values are read Defaults.xml, or are set directly in Databasehelper.java
such as Loadsetting (stmt, Settings.Secure.ADB_ENABLED, 1); This adb debugging switch is written directly in the database file.
When parsing the code, find it directly in the Databasehelper.java file if you find that this item is not found in Defaults.xml.
Android modifies the default values in the setting in frameworks