Android定制出厂默认输入法

方法一:
\frameworks\base\packages\SettingsProvider\res\values\defaults.xml
\frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java

设置默认输入法为google拼音
\frameworks\base\packages\SettingsProvider\res\values\defaults.xml
    <string name="config_default_input_method" translatable="false">com.android.inputmethod.pinyin/.PinyinIME</string>
 
\frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java
loadSecureSettings()中增加一条语句,制定默认使能的输入法 
loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
                R.string.config_default_input_method );

方法二:
frameworks\base\core\res\res\values\config.xml
frameworks\base\services\java\com\android\server \InputMethodManagerService.java

在 frameworks\base\core\res\res\values\config.xml 添加一个属性:
    <string name="config_default_input_method">com.android.inputmethod.pinyin/.PinyinIME</string>

frameworks\base\services\java\com\android\server\InputMethodManagerService.java的方法buildInputMethodListLocked()里添加:   
   String defaultIme = Settings.Secure.getString(mContext
                .getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);

        if ( defaultIme == null )
        {
            final Resources res = mContext.getResources();
            try
            {
                //frameworks\base\core\res\res\values\config.xml
                String myIME = res.getString( com.android.internal.R.string.config_default_input_method );
                if ( myIME != null && myIME.length() > 0 )
                {
                    Settings.Secure.putString( mContext.getContentResolver(),
                            Settings.Secure.DEFAULT_INPUT_METHOD,
                            myIME );
                }
            }
            catch ( Exception e )
            {
            }
        }

方法三:
frameworks/base/package/settingsproviders/res/values/defaults.xml
在文件frameworks/base/package/settingsproviders/src/com/android/providers/settings/DatabaseHelper.java

一些系统定制信息是通过
frameworks/base/package/settingsproviders/res/values/defaults.xml来预设的,在系统首次启动时加载此文件,并应用文件中的设置。文件如下:
<string name="def_enabled_input_methods">com.sohu.inputmethod.sogou/.SogouIME:com.android.inputmethod.pinyin/.PinyinIME</string>

在文件frameworks/base/package/settingsproviders/src/com/android/providers/settings/DatabaseHelper.java的函数
loadSecureSettings()中增加一条语句,制定默认使能的输入法 
loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
                R.string.def_enabled_input_methods);

你可能感兴趣的:(android)