设置默认输入法及输入法相关设置

测试平台
Platform: RK3399
OS: Android 7.1.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);
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

android framework

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值