RK:Provision.apk、SettingsProvider的分析、使用

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>//手势是否可以使用

  

 

posted @ 2020-07-31 10:23  CrushGirl  阅读(1297)  评论(0编辑  收藏  举报