1. 本文使用的是展锐平台安卓10,自行酌情参考。
2. 本文内置的是百度输入法
一、 准备百度APK以及package包
# ///ADD START
# ///ADD END
# 设置当前工作路径
LOCAL_PATH:= $(call my-dir)
# 清除变量值
include $(CLEAR_VARS)
# 生成的模块名称
LOCAL_MODULE := baiduinput
# 生成的模块类型
LOCAL_MODULE_CLASS := APPS
# 生成的模块后缀名,此处为apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
# 设置模块tag,tags取值可以为:user debug eng tests optional
# optional表示全平台编译
LOCAL_MODULE_TAGS := optional
# LOCAL_PRIVILEGED_MODULE := true
#LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_PACKAGE_NAME := baiduinput
# 设置源文件
LOCAL_SRC_FILES := baiduinput_AndroidPhone_1000e.apk
# LOCAL_CERTIFICATE := platform
# 设置签名,此处表示保持apk原有签名
LOCAL_CERTIFICATE := PRESIGNED
JNI_LIBS := $(foreach FILE,$(shell find $(LOCAL_PATH)/lib/armeabi-v7a/ -name *.so), $(eval JNI_LIBS += $(FILE)))
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH),,$(JNI_LIBS))
LOCAL_MULTILIB := 32
# 此处表示预编译方式
include $(BUILD_PREBUILT)
-
制作package包目录 目录:packages/apps/baiduinput
- 加入编译系统(DeviceCommon.mk 文件)
diff --git a/device/sprd/sharkl3/common/DeviceCommon.mk b/device/sprd/sharkl3/common/DeviceCommon.mk
index 1b51f03..526eef5 100755
--- a/device/sprd/sharkl3/common/DeviceCommon.mk
+++ b/device/sprd/sharkl3/common/DeviceCommon.mk
@@ -227,6 +227,8 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
gwe_tty_loop_test
+PRODUCT_PACKAGES += \
+ baiduinput
# sensor
PRODUCT_PACKAGES += \
android.hardware.sensors@1.0-service \
二、设置为系统默认输入法
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index fb804c1..ffb4ce9 100644
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -26,6 +26,8 @@
<string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi,nfc,wimax</string>
<string name="airplane_mode_toggleable_radios" translatable="false">bluetooth,wifi,nfc</string>
<string name="def_bluetooth_disabled_profiles" translatable="false">0</string>
+ <string name="default_input_method" translatable="false">com.baidu.input/.ImeService</string>
+ <string name="enabled_input_method" translatable="false">com.baidu.input/.ImeService</string>
<bool name="def_auto_time">true</bool>
<bool name="def_auto_time_zone">true</bool>
<bool name="def_accelerometer_rotation">false</bool>
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/s
index 8d3c472..f443964 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
@@ -2434,6 +2434,12 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,
R.integer.def_sleep_timeout);
+ loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
+ R.string.default_input_method);
+
+ loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
+ R.string.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
三、 解决切换系统语言导致输入被切换成安卓默认的输入法
diff --git a/frameworks/base/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/frameworks/base/services/core/java/com/android/server/inputmethod/Inp
index 50c7666..8e58616 100644
--- a/frameworks/base/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1525,7 +1525,7 @@ public class InputMethodManagerService extends AbsInputMethodManager
if (DEBUG) {
Slog.i(TAG, "Default found, using " + defIm.getId());
}
- setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
+ //setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
}
@GuardedBy("mMethodMap")
|