https://www.cnblogs.com/mythou/p/3425570.html
https://blog.csdn.net/myfriend0/article/details/59107989
Platform: RK3288
OS: Android 5.1
Kernel: 3.10.0
一.android provision apk 分析
1.packages\apps\Provision\AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.provision"> <original-package android:name="com.android.provision" /> <!-- For miscellaneous settings --> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <application> <activity android:name="DefaultActivity" android:excludeFromRecents="true"> <intent-filter android:priority="1"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest>
a.priority n. 優先;優先權;[數] 優先次序;優先考慮的事
<intent-filter android:priority="1">
優先級比原生的Launcher優先級還要高,它會在Launcher啟動前就運行起來
b.Launcher屬性
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
2.packages\apps\Provision\src\com\android\provision\DefaultActivity.java
package com.android.provision; import android.app.Activity; import android.content.ComponentName; import android.content.pm.PackageManager; import android.os.Bundle; import android.provider.Settings; /** * Application that sets the provisioned bit, like SetupWizard does. */ public class DefaultActivity extends Activity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Add a persistent setting to allow other apps to know the device has been provisioned. //添加永久性設置,以允許其他應用知道設備已配置 Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1); Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 0); // remove this activity from the package manager. PackageManager pm = getPackageManager(); ComponentName name = new ComponentName(this, DefaultActivity.class); pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); // terminate the activity. finish(); } }
3.Provision.apk 優先於Launcher,so……
二.SettingsProvider
2.1.數據分類
SettingsProvider對數據進行了分類,分別是Global、System、Secure三種類型,它們的區別如下:
Global:所有的偏好設置對系統的所有用戶公開,第三方有讀沒有寫的權限
System:包含各種各樣的用戶偏好系統設置
Secure:安全性的用戶偏好系統設置,第三方APP有讀沒有寫的權
2.2.數據庫中的默認數據在frameworks\base\packages\SettingsProvider\res\values\defaults.xml中定義
<bool name="def_bluetooth_on">false</bool>//藍牙 關
2.3.通過frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java對數據庫結構及初始值進行初始化
loadSecureSettings(SQLiteDatabase db)方法中加入新字段的添加代碼
loadVolumeLevels()和loadSettings()的作用就是在手機第一次啟動時,把手機編好設置的默認值寫入到數據庫settings.db
loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON,R.bool.def_bluetooth_on);
2.4.adb 設置
cat /sys/class/backlight/backlight/brightness adb shell settings get system screen_brightness adb shell settings get secure default_input_method adb shell settings put secure default_input_method com.android.inputmethod.pinyin/.PinyinIME //默認PinyinIME鍵盤輸入法 Settings.Secure.putString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD, "com.sohu.inputmethod.sogou/.SogouIME"); adb shell settings put global def_package_verifier_include_adb 0 //通過USB驗證應用 Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 0); Settings.Secure.putString(getContentResolver(), Settings.Secure.TTS_DEFAULT_SYNTH, "com.iflytek.speechcloud");//默認訊飛tts
2.5.使用24小時格式
private static final String HOURS_12 = "12"; Settings.System.putString(getContentResolver(),Settings.System.TIME_12_24,HOURS_12);
2.6.位置信息 默認精度設置為“節電”/"僅限設備"/"高精度"
< string name="def_location_providers_allowed" translatable="false">network,gps</string>//默認設置為高精度 a. gps 則模式為”僅限設備” b. gps,network則模式為”高精確度” c. network 則模式為”節電”
2.7.android 7.1 系統設置選項默認值數據庫位置
cd /data/system/users/0
2.8. android 5.1 系統設置選項默認值數據庫位置
Settings參數保存在 /data/data/com.android.providers.settings/databases/settings.db里,里面有三個表global, system, secure.
通常這樣查看數據
adb shell sqlite3 data/data/com.android.providers.settings/databases/settings.db "select * from secure"
2.10.frameworks\base\core\java\android\provider\Settings.java 添加新變量
/** * Run package verificaiton on apps installed through ADB/ADT/USB * 1 = perform package verification on ADB installs (default) * 0 = bypass package verification on ADB installs * @hide */ public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";
2.11.設置 顯示 休眠
settings get system screen_off_timeout
2.6. Android 5.1 frameworks默認設置 frameworks\base\packages\SettingsProvider\res\values\defaults.xml
<bool name="def_dim_screen">true</bool>//自動關屏 開 <integer name="def_screen_off_timeout"></integer>//自動關閉屏幕時間 15秒 <integer name="def_sleep_timeout">-</integer>//表示休眠時間,默認如果沒有修改的是6000,即6000ms的意思,6s進行休眠,在這里將其改為-1就是讓其永遠不休眠 <bool name="def_airplane_mode_on">false</bool>//飛行模式 關 <bool name="def_theater_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">false</bool> //自動旋轉 關 <!-- Default screen brightness, from to . is %. <integer name="def_screen_brightness"></integer>//默認屏幕亮度 <bool name="def_screen_brightness_automatic_mode">false</bool>//屏幕亮度自適應 關 <fraction name="def_window_animation_scale">%</fraction> //常規窗口動畫的百分比值,為0時禁止窗口動畫 <fraction name="def_window_transition_scale">%</fraction>//activity過度窗口動畫的百分比值,為0時禁止窗口動畫 <bool name="def_haptic_feedback">false</bool> //觸動反饋 關 <bool name="def_bluetooth_on">false</bool>//藍牙 關 <bool name="def_wifi_display_on">false</bool>//Wifi是否開啟顯示 關 <bool name="def_install_non_market_apps">true</bool> //安裝非市場APK 開 <bool name="def_package_verifier_enable">true</bool> //驗證應用 開 <!-- Comma-separated list of location providers. Network location is off by default because it requires user opt-in via Setup Wizard or Settings. <string name="def_location_providers_allowed" translatable="false"></string> //位置信息訪問權限 關 <bool name="assisted_gps_enabled">false</bool> //GPS定位 關 <bool name="def_netstats_enabled">true</bool> //默認是否開啟數據流量 開 <bool name="def_usb_mass_storage_enabled">true</bool> //是否使用USB大容量存儲 開 <bool name="def_wifi_on">false</bool> //wifi 關 <!-- == never, == only when plugged in, == always <integer name="def_wifi_sleep_policy"></integer> //wifi休眠策略,2-永不修改 <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 LED when there is a pending notification <bool name="def_notification_pulse">true</bool>//當有通知時LED燈是否一直閃爍 <bool name="def_mount_play_notification_snd">true</bool>//當有MountService事件時是否播放通知音 <bool name="def_mount_ums_autostart">false</bool>//ums自動重啟 關 <bool name="def_mount_ums_prompt">true</bool>// ums啟用時是否在通知欄提示 <bool name="def_mount_ums_notify_enabled">true</bool> //ums主機監控時顯示在通知欄 <!-- user interface sound effects <integer name="def_power_sounds_enabled"></integer> //是否播放低電量聲音 1--是 <string name="def_low_battery_sound" translatable="false">/system/media/audio/ui/LowBattery.ogg</string>//低電量聲音文件 <integer name="def_dock_sounds_enabled"></integer>//插上充電座是否播放聲音 0-否 <string name="def_desk_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string>//插入家用底座時的音頻文件的URI <string name="def_desk_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string>//拔出家用底座時的音頻文件的URI <string name="def_car_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string>//插入車載底座時音頻文件的URI <string name="def_car_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string>//拔出車載底座時音頻文件的URI <integer name="def_lockscreen_sounds_enabled"></integer>//鎖屏是否播放聲音 0--否 <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_trusted_sound" translatable="false">/system/media/audio/ui/Trusted.ogg</string> <string name="def_wireless_charging_started_sound" translatable="false">/system/media/audio/ui/WirelessChargingStarted.ogg</string> //開始無線充電音頻文件的URI <bool name="def_lockscreen_disabled">true</bool> //是否禁用鎖屏 <bool name="def_device_provisioned">false</bool> //設備是否已提供 <integer name="def_dock_audio_media_enabled"></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> //是否啟用javascript注入來增強閱讀 <!-- 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_accessibility_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 current axis and 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 an axis to another and sends an event. <!-- Axis transitions: -> ; 0x200000015=0x03020101; <!-- Alt+DPAD/Trackball RIGHT - transition from an axis to another and sends an event. <!-- Axis transitions: -> ; 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: -> ; 0x200000037=0x03070201; <!-- Alt+PERIOD - transition to default web view behavior axis and send an event. <!-- Axis transitions: -> ; - > ; -> ; 0x200000038=0x03000701:0x03010701:0x03020701; </string> <!-- Default for Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION_URL <string name="def_accessibility_screen_reader_url" translatable="false"> https://ssl.gstatic.com/accessibility/javascript/android/AndroidVox_v1.js </string> //WebView用來展示基本閱讀的JavaScript的URL <!-- 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">%</fraction> //設置顯示放大的百分比 <!-- Default value for 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"></integer>//屏幕旋轉策略,默認啟用旋轉 0--否 <!-- Default for Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE. <= if no limit <integer name="def_download_manager_max_bytes_over_mobile">-</integer> //下載時的最大速度,以字節為單位 -1-不限制 <!-- Default for Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE. <= if no limit <integer name="def_download_manager_recommended_max_bytes_over_mobile">-</integer> //下載時推薦的最大速度,以字節為單位 -1-不限制 <!-- Default for Settings.Secure.LONG_PRESS_TIMEOUT_MILLIS <integer name="def_long_press_timeout_millis"></integer>//設置長按失效時長 500毫秒 <!-- Default for Settings.System.POINTER_SPEED <integer name="def_pointer_speed"></integer> //屏幕是否可以旋轉 否 <!-- Default for DTMF tones enabled <bool name="def_dtmf_tones_enabled">true</bool> //在撥號時撥號器是否啟用DTMF音調 是 <!-- M: Default for UI touch sounds disabled ,google defaulit is enable <bool name="def_sound_effects_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"></integer> //最大重連次數 <!-- Default for Settings.Secure.USER_SETUP_COMPLETE <bool name="def_user_setup_complete">false</bool> 當前用戶是否已經通過安裝向導設置 否 <!-- Default for Settings.Global.LOW_BATTERY_SOUND_TIMEOUT. means no timeout; battery sounds will always play > is milliseconds of screen-off time after which battery sounds will not play <integer name="def_low_battery_sound_timeout"></integer>//低電量聲音在屏幕關閉后是否超時播放 0-代表超時毫秒 <!-- Initial value for the Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS setting, which is a comma separated list of packages that no longer need confirmation for immersive mode. Override to disable immersive mode confirmation for certain packages. <string name="def_immersive_mode_confirmations" translatable="false"></string>是否需要沉浸式模式 <!-- Default for Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE <integer name="def_wifi_scan_always_available"></integer>//Wifi 是否一致掃描 <!-- Default for Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, ==on <integer name="def_lock_screen_show_notifications"></integer>//鎖屏界面上展示通知 <!-- Default for Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS <bool name="def_lock_screen_allow_private_notifications">true</bool> //鎖屏界面是否一直展示通知 <!-- Default for Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, ==on <integer name="def_heads_up_enabled"></integer> <!-- Default for Settings.Global.DEVICE_NAME $=MANUFACTURER $=MODEL <string name="def_device_name">%$s %$s</string>//設置多個設備名稱 <!-- Default for Settings.Global.DEVICE_NAME $=MODEL <string name="def_device_name_simple">%$s</string>//設置單個設備名稱 <!-- Default for Settings.Secure.WAKE_GESTURE_ENABLED <bool name="def_wake_gesture_enabled">true</bool>//手勢喚醒是否可用 <!-- Default for Settings.Global.GUEST_USER_ENABLED <bool name="def_guest_user_enabled">true</bool>//手勢是否可以使用