!87 同步修改到weekly分支

Merge pull request !87 from demon/weekly_20220301
This commit is contained in:
openharmony_ci 2022-03-03 13:21:18 +00:00 committed by Gitee
commit fa0218daf5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 14 additions and 1 deletions

View File

@ -193,6 +193,7 @@ using namespace MessageID;
void InputMethodController::Attach(sptr<OnTextChangedListener> &listener)
{
textListener = listener;
PrepareInput(0, mClient, mInputDataChannel, mAttribute);
StartInput(mClient);
}

View File

@ -87,6 +87,7 @@ namespace MiscServices {
void OnDisplayOptionalInputMethod(int32_t userId);
static sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleMgr();
void StartUserIdListener();
ServiceRunningState state_;
void InitServiceHandler();

View File

@ -183,10 +183,21 @@ namespace MiscServices {
userId_ = MAIN_USER_ID;
setting->Initialize();
StartUserIdListener();
}
void InputMethodSystemAbility::StartUserIdListener()
{
sptr<ImCommonEventManager> imCommonEventManager = ImCommonEventManager::GetInstance();
if (imCommonEventManager->SubscribeEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED)) {
bool isSuccess = imCommonEventManager->SubscribeEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
if (isSuccess) {
IMSA_HILOGI("InputMethodSystemAbility::Initialize subscribe service event success");
return;
}
IMSA_HILOGE("StartUserIdListener failed. Try again 10s later");
auto callback = [this]() { StartUserIdListener(); };
serviceHandler_->PostTask(callback, INIT_INTERVAL);
}
void InputMethodSystemAbility::StartInputService(std::string imeId)