Platform: RK3288
OS: Android 7.1.2
Kernel: v4.4.143
需求:
设置第三方输入法为默认输入法
前提:
预装第三方输入法,参考
方法:
路径:/packages/SettingsProvider/res/values/defaults.xml
config_default_input_method代表默认输入法
config_enabled_input_method代表内置的输入法,内置可以设置多个,用:隔开
<string name="config_enabled_input_method" translatable="false">com.sohu.inputmethod.sogou/.SogouIME:com.android.inputmethod.latin/.LatinIME</string>
代码形式为 “包名/类名,
“com.baidu.input_baidutv” 是百度输入法的包名“.ImeService”是百度输入法类名,这里是简略写法,类名名也可以写成全称“com.baidu.input_baidutv/com.baidu.input_baidutv.ImeService”
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 6325b9b..9b09785 100755
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -44,7 +44,9 @@Network location is off by default because it requiresuser opt-in via Setup Wizard or Settings.-->
- <string name="def_input_method" translatable="false">com.google.android.inputmethod.pinyin/.PinyinIME</string>
+
+ <string name="config_default_input_method" translatable="false">com.baidu.input_baidutv/.ImeService</string>
+ <string name="config_enabled_input_method" translatable="false">com.baidu.input_baidutv/.ImeService</string><string name="def_location_providers_allowed" translatable="false">gps</string><bool name="assisted_gps_enabled">true</bool><bool name="def_netstats_enabled">true</bool>
路径:packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
注意要放在loadSecureSettings方法里,不能放在loadSystemSettings方法里面;
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 6be960a..98d8607 100755
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2543,9 +2543,9 @@ class DatabaseHelper extends SQLiteOpenHelper {loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,R.integer.def_sleep_timeout);
- loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
- R.string.def_input_method );
-
+
+ loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,R.string.config_default_input_method);
+ loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,R.string.config_enabled_input_method);/** IMPORTANT: Do not add any more upgrade steps here as the global,* secure, and system settings are no longer stored in a database
其他知识点
1. 确定APK的包名和主类名
将APK直接拖动到Androidstudio,查看Androidmanifest
包名: package="com.baidu.input_baidutv">
类名:<service
android:name="com.baidu.input_baidutv.ImeService"
2. 调试步骤:
#显示系统安装的输入法列表
adb shell ime list -s
#获取系统默认输入法
adb shell settings get secure default_input_method
#设置系统默认输入法
adb shell settings put secure default_input_method com.baidu.input_baidutv/com.baidu.input_baidutv.ImeService
#获取系统内置输入法
adb shell settings get secure enabled_input_method
#设置系统内置输入法
adb shell settings put secure enabled_input_method com.baidu.input_baidutv/com.baidu.input_baidutv.ImeService