!734 【bugfix】修复快捷键切换子类型

Merge pull request !734 from 赵凌岚/master
This commit is contained in:
openharmony_ci 2023-05-26 10:41:49 +00:00 committed by Gitee
commit 11004ffec6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 7 deletions

View File

@ -102,7 +102,7 @@ private:
static sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
void StartUserIdListener();
bool IsNeedSwitch(const std::string &bundleName, const std::string &subName);
int32_t OnSwitchInputMethod(const SwitchInfo &switchInfo);
int32_t OnSwitchInputMethod(const SwitchInfo &switchInfo, bool isCheckPermission);
int32_t Switch(const std::string &bundleName, const ImeInfo &info);
int32_t SwitchExtension(const ImeInfo &info);
int32_t SwitchSubType(const ImeInfo &info);

View File

@ -370,10 +370,10 @@ int32_t InputMethodSystemAbility::SwitchInputMethod(const std::string &bundleNam
{
SwitchInfo switchInfo = { std::chrono::system_clock::now(), bundleName, subName };
PushToSwitchQueue(switchInfo);
return OnSwitchInputMethod(switchInfo);
return OnSwitchInputMethod(switchInfo, true);
}
int32_t InputMethodSystemAbility::OnSwitchInputMethod(const SwitchInfo &switchInfo)
int32_t InputMethodSystemAbility::OnSwitchInputMethod(const SwitchInfo &switchInfo, bool isCheckPermission)
{
IMSA_HILOGD("run in, switchInfo: %{public}s|%{public}s", switchInfo.bundleName.c_str(), switchInfo.subName.c_str());
if (!CheckReadyToSwitch(switchInfo)) {
@ -385,7 +385,8 @@ int32_t InputMethodSystemAbility::OnSwitchInputMethod(const SwitchInfo &switchIn
IMSA_HILOGD("start switch %{public}s", (switchInfo.bundleName + '/' + switchInfo.subName).c_str());
// if currentIme is switching subtype, permission verification is not performed.
auto currentIme = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_)->bundleName;
if (!BundleChecker::CheckPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)
if (isCheckPermission
&& !BundleChecker::CheckPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)
&& !(switchInfo.bundleName == currentIme
&& BundleChecker::IsCurrentIme(IPCSkeleton::GetCallingTokenID(), currentIme))) {
PopSwitchQueue();
@ -696,7 +697,7 @@ int32_t InputMethodSystemAbility::SwitchMode()
}
SwitchInfo switchInfo = { std::chrono::system_clock::now(), target->name, target->id };
PushToSwitchQueue(switchInfo);
return OnSwitchInputMethod(switchInfo);
return OnSwitchInputMethod(switchInfo, false);
}
int32_t InputMethodSystemAbility::SwitchLanguage()
@ -720,7 +721,7 @@ int32_t InputMethodSystemAbility::SwitchLanguage()
}
SwitchInfo switchInfo = { std::chrono::system_clock::now(), target->name, target->id };
PushToSwitchQueue(switchInfo);
return OnSwitchInputMethod(switchInfo);
return OnSwitchInputMethod(switchInfo, false);
}
int32_t InputMethodSystemAbility::SwitchType()
@ -737,7 +738,7 @@ int32_t InputMethodSystemAbility::SwitchType()
if (iter != props.end()) {
SwitchInfo switchInfo = { std::chrono::system_clock::now(), iter->name, "" };
PushToSwitchQueue(switchInfo);
return OnSwitchInputMethod(switchInfo);
return OnSwitchInputMethod(switchInfo, false);
}
return ErrorCode::NO_ERROR;
}