android 输入法如何启动流程_[RK3288][Android6.0] 输入法框架开机初始化部分小结

Platform: ROCKCHIP

OS: Android 6.0

Kernel: 3.10.92

之前遇到默认输入法修改有问题,这里对输入法服务开机初始化部分做个小结.

startOtherServices ->    SystemServer.java

new InputMethodManagerService ->

IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));    //和windowsmanagerservice建立关系.

new InputMethodSettings InputMethodUtils.java

mSettings.getSelectedInputMethod ->    //获取系统默认输入法, SettingsProvider会提前解析默认配置,然后写入数据库,如果没有设置,那么就会返回空.

getSelectedInputMethod ->    InputMethodUtils.java

Settings.Secure.getStringForUser(...,Settings.Secure.DEFAULT_INPUT_METHOD, ...);

buildInputMethodListLocked ->

new ComponentName    //循环读取系统中所有可用的输入法

new InputMethodInfo //输入法各自用此结构保存信息.

InputMethodUtils.getDefaultEnabledImes ->     InputMethodUtils.java //当没有设置输入法时候会自动选择一个, 6.0默认选择了Latin输入法,谷歌拼音输入法已经被移除掉.

getMinimumKeyboardSetWithSystemLocale

//默认选择规则如下:

// Once the system becomes ready, we pick up at least one keyboard in the following order.

// Secondary users fall into this category in general.

// 1. checkDefaultAttribute: true, locale: systemLocale, checkCountry: true

// 2. checkDefaultAttribute: true, locale: systemLocale, checkCountry: false

// 3. checkDefaultAttribute: true, locale: fallbackLocale, checkCountry: true

// 4. checkDefaultAttribute: true, locale: fallbackLocale, checkCountry: false

// 5. checkDefaultAttribute: false, locale: fallbackLocale, checkCountry: true

// 6. checkDefaultAttribute: false, locale: fallbackLocale, checkCountry: false

// TODO: We should check isAsciiCapable instead of relying on fallbackLocale.

setInputMethodEnabledLocked ->  //存为默认enabled input method.

mSettings.appendAndPutEnabledInputMethodLocked ->

putEnabledInputMethodsStr ->

Settings.Secure.putStringForUser(..., Settings.Secure.ENABLED_INPUT_METHODS, str, mCurrentUserId);

mSettings.enableAllIMEsIfThereIsNoEnabledIME ->    //如果上面依然为空,那么会加载所有的输入法.

enableAllIMEsIfThereIsNoEnabledIME ->

putEnabledInputMethodsStr    //从mMethodList中读取所有输入法

resetDefaultImeLocked ->    //当系统已经有默认输入法并且是第三方的输入法的话不会被reset,这种情况主要用于处理系统语言切换的情况.也就是说,如果是第三方输入法,那么在系统语言切换的时候不做变化.

InputMethodUtils.getMostApplicableDefaultIME ->    //根据Locale选择一个最合适的.

mSettings.getEnabledInputMethodListLocked ->    //获取系统当前支持的所有输入法

createEnabledInputMethodListLocked ->

getEnabledInputMethodsAndSubtypeListLocked ->

buildInputMethodsAndSubtypeList ->

getEnabledInputMethodsStr ->    //前面有设置过了,所以能得到数据了.

Settings.Secure.getStringForUser(..., Settings.Secure.ENABLED_INPUT_METHODS, ...);    //从数据库中获取当前支持的ims

简单来说就是:

SettingsProvider读取并更新配置到数据库, InputMethodService读取配置,

如果没有读取到默认输入法,那么按照一定规则从现有系统输入法中选择其中

一个最合适的作为默认输入法.

参考:

http://blog.csdn.net/tfslovexizi/article/details/39400181

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值