我是靠谱客的博主 文艺书本,最近开发中收集的这篇文章主要介绍[RK3288][Android6.0] 调试笔记 --- 设置中文为默认输入法,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Platform: RK3288
OS: Android 6.0
Kernel: 3.10.92

添加方法:

1. 添加第三方apk
路径: rk3288/device/rockchip/rk3288/Sougou:
Android.mk    //标准预置第三方apk方法
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sougoushurufa
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
#LOCAL_PRIVILEGED_MODULE :=
#LOCAL_OVERRIDES_PACKAGES :=
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#LOCAL_REQUIRED_MODULES :=
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

路径: rk3288/device/rockchip/rk3288
device.mk
diff --git a/device.mk b/device.mk
index c9f1ec4..e058a2c 100644
--- a/device.mk
+++ b/device.mk
@@ -47,6 +47,10 @@ endif
PRODUCT_COPY_FILES +=
    device/rockchip/rk3288/rk3288_box/init.rc:root/init.rc
    device/rockchip/rk3288/fstab.rk30board.bootmode.unknown:root/fstab.rk30board.bootmode.unknown
    device/rockchip/rk3288/rk3288_box/fstab.rk30board.bootmode.emmc:root/fstab.rk30board.bootmode.emmc
else
  PRODUCT_COPY_FILES +=
    device/rockchip/rk3288/fstab.rk30board.bootmode.unknown:root/fstab.rk30board.bootmode.unknown
    device/rockchip/rk3288/fstab.rk30board.bootmode.emmc:root/fstab.rk30board.bootmode.emmc
endif
 
+#170401, add sougou input method.
+PRODUCT_PACKAGES +=
+    sougoushurufa

+

2. 设置默认属性以及加载到database中
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index d75b742..cc8e961 100755
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -217,4 +217,7 @@
     <!-- should show the screenshot button default -->
     <bool name="def_screenshot_button_show">false</bool>
 
    //此属性默认没有设置,需要自己添加.
+    <!-- Kris, 170401, Add sougou input method. -->
+    <string name="def_input_method" translatable="false">com.sohu.inputmethod.sogou/.SogouIME</string>
+
 </resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 0b122a4..657af87 100755
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2535,6 +2535,10 @@ class DatabaseHelper extends SQLiteOpenHelper {
             loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,
                     R.integer.def_sleep_timeout);
 
+            /*Kris, 170401, Add default input method to database. */
+            loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
+                    R.string.def_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

3. 使能所有输入法

默认情况下只有一种输入法是被使能的,如果要使能全部, 可做如下修改

[kris@ecovacs:~/rk3288/frameworks/base]$ g df
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
index 742173b..1c26d51 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
@@ -926,12 +926,12 @@ public class InputMethodUtils {
         // At the initial boot, the settings for input methods are not set,
         // so we need to enable IME in that case.
         public void enableAllIMEsIfThereIsNoEnabledIME() {
-            if (TextUtils.isEmpty(getEnabledInputMethodsStr())) {
+            if (!TextUtils.isEmpty(getEnabledInputMethodsStr())) {
                 StringBuilder sb = new StringBuilder();
                 final int N = mMethodList.size();
                 for (int i = 0; i < N; i++) {
                     InputMethodInfo imi = mMethodList.get(i);
-                    Slog.i(TAG, "Adding: " + imi.getId());
+                    Slog.i(TAG, "Adding: " +sb.toString()+ imi.getId());
                     if (i > 0) sb.append(':');
                     sb.append(imi.getId());
                 }

相关知识点:

资源文件路径:
rk3288/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
系统自带输入法路径:
rk3288/packages/inputmethods
由于要新建git,所以上面例子中将输入法直接放在rk3288/device/rockchip/rk3288下面了.

数据库位置:
/data/system/users/0/

获取默认输入法:
adb shell settings get secure default_input_method

ref:
database:
http://blog.csdn.net/qq_27062249/article/details/54929344
http://blog.csdn.net/kv110/article/details/51520207
http://blog.sina.com.cn/s/blog_a28e3dd90102wcbw.html

修改:

http://blog.csdn.net/yuxiangyunei/article/details/44546041

http://blog.csdn.net/andylau6789/article/details/23958467

settings命令

https://testerhome.com/topics/1993



最后

以上就是文艺书本为你收集整理的[RK3288][Android6.0] 调试笔记 --- 设置中文为默认输入法的全部内容,希望文章能够帮你解决[RK3288][Android6.0] 调试笔记 --- 设置中文为默认输入法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部