测试平台
Platform: RK3399
OS: Android 7.1.1
需求
始终弹出软键盘
设置默认输入法
解决方案
- 始终弹出软键盘 : 系统默认当连接物理键盘时,虚拟键盘不会弹出.
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index 08570fe…141825a 100644
— a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -159,7 +159,7 @@ 300
-
true
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 20b95b9…25225ab 100644
— a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2454,6 +2454,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
private void loadSecureSettings(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement(“INSERT OR IGNORE INTO secure(name,value)”
+ " VALUES(?,?);");
-
loadBooleanSetting(stmt, Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD,
-
R.bool.def_show_ime_with_hard_keyboard);
-
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, R.string.def_location_providers_allowed);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2. 设置默认输入法
设置默认输入法首先在机器上安装相应的输入法并设置成默认,然后连接adb输入以下命令
$ adb shell settings get secure enabled_input_methods
com.android.inputmethod.latin/.LatinIME:com.iflytek.inputmethod.google/com.iflytek.inputmethod.FlyIME:com.google.android.inputmethod.pinyin/.PinyinIME
$ adb shell settings get secure default_input_method
com.iflytek.inputmethod.google/com.iflytek.inputmethod.FlyIME
1
2
3
4
获取启用的输入法和默认输入法,然后在SettingProvider里面添加如下代码
diff --git a/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
index a2e0012…88d7fba 100644
— a/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
@@ -7,4 +7,8 @@
<!--if true while show rotation in SystenUI and Settings-DisplaySettings -->
<bool name="def_enable_rotation_by_user">true</bool>
- com.android.inputmethod.latin/.LatinIME:com.iflytek.inputmethod.google/com.iflytek.inputmethod.FlyIME:com.google.android.inputmethod.pinyin/.PinyinIME
- com.iflytek.inputmethod.google/com.iflytek.inputmethod.FlyIME
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 20b95b9…25225ab 100644
— a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2454,6 +2454,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
private void loadSecureSettings(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement(“INSERT OR IGNORE INTO secure(name,value)”
+ " VALUES(?,?);");
-
loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
-
R.string.enabled_input_methods);
-
loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
-
R.string.def_input_method); loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, R.string.def_location_providers_allowed);