RK3566&RK3568 安卓11 设置默认系统时间为24小时制

需求:设置默认系统时间为24小时制

一.添加环境变量

在目录frameworks/base/packages/SettingsProvider/res/values/defaults.xml
添加代码如下:

    <!-- add by LQX -->
    <string name="time_12_24">24</string>
    <!-- end, add by LQX -->

二.添加默认系统变量

目录frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

    private void loadSystemSettings(SQLiteDatabase db) {
        SQLiteStatement stmt = null;
        try {
            stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
                    + " VALUES(?,?);");

     ....

            loadIntegerSetting(stmt, Settings.System.SCREENSHOT_BUTTON_SHOW,
                    R.integer.def_screenshot_button_show);
            //By-LQX
            loadStringSetting(stmt, Settings.System.TIME_12_24, R.string.time_12_24);
            //By-LQX
            /*
             * IMPORTANT: Do not add any more upgrade steps here as the global,
             * secure, and system settings are no longer stored in a database
             * but are kept in memory and persisted to XML.
             *
             * See: SettingsProvider.UpgradeController#onUpgradeLocked
             */
        } finally {
            if (stmt != null) stmt.close();
        }
    }

三.注释自动选择改为固定24小时

目录packages\apps\Settings\res\xml\date_time_prefs.xml

    <PreferenceCategory
        android:key="time_format_preference_category"
        android:title="@string/time_format_category_title"
        settings:keywords="@string/keywords_time_format">
        <!--<SwitchPreference
            android:key="auto_24hour"
            android:title="@string/date_time_24hour_auto"/>!-->

        <SwitchPreference
            android:key="24 hour"
            android:title="@string/date_time_24hour" />
    </PreferenceCategory>

教程结束

你可能感兴趣的:(android,java)