!84 保证多用户监听订阅成功。

Merge pull request !84 from demon/master
This commit is contained in:
openharmony_ci
2022-03-02 09:20:34 +00:00
committed by Gitee
2 changed files with 13 additions and 1 deletions
@@ -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();
+12 -1
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)