mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 22:59:45 +00:00
commit
f4c219d1f4
@ -263,8 +263,9 @@ napi_value JsTextInputClientEngine::SendPrivateCommand(napi_env env, napi_callba
|
||||
napi_status status = JsUtils::GetValue(env, argv[0], ctxt->privateCommand);
|
||||
CHECK_RETURN(status == napi_ok, "GetValue privateCommand error", status);
|
||||
if (!TextConfig::IsPrivateCommandValid(ctxt->privateCommand)) {
|
||||
PARAM_CHECK_RETURN(
|
||||
env, false, "privateCommand size limit 32KB, count limit 5.", TYPE_NONE, napi_generic_failure);
|
||||
JsUtils::ThrowException(
|
||||
env, IMFErrorCode::EXCEPTION_PARAMCHECK, "privateCommand size limit 32KB, count limit 5.", TYPE_NONE);
|
||||
return napi_generic_failure;
|
||||
}
|
||||
ctxt->info = { std::chrono::system_clock::now(), ctxt->privateCommand };
|
||||
privateCommandQueue_.Push(ctxt->info);
|
||||
|
@ -146,7 +146,7 @@ private:
|
||||
int32_t GenerateClientInfo(InputClientInfo &clientInfo);
|
||||
void RegisterEnableImeObserver();
|
||||
void RegisterSecurityModeObserver();
|
||||
void CheckSecurityMode(InputClientInfo &inputClientInfo);
|
||||
void CheckInputTypeOption(InputClientInfo &inputClientInfo);
|
||||
int32_t IsDefaultImeFromTokenId(uint32_t tokenId);
|
||||
void DealSwitchRequest();
|
||||
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
bool IsSupported(InputType type);
|
||||
bool IsInputType(const ImeIdentification &ime);
|
||||
bool IsStarted();
|
||||
bool IsSecurityImeStarted();
|
||||
bool IsCameraImeStarted();
|
||||
void Set(bool isStarted, const ImeIdentification ¤tIme = {});
|
||||
ImeIdentification GetCurrentIme();
|
||||
|
@ -306,7 +306,7 @@ int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, s
|
||||
}
|
||||
|
||||
if (!userSession_->IsProxyImeEnable()) {
|
||||
CheckSecurityMode(inputClientInfo);
|
||||
CheckInputTypeOption(inputClientInfo);
|
||||
}
|
||||
int32_t ret = PrepareInput(inputClientInfo);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
@ -316,23 +316,36 @@ int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, s
|
||||
return userSession_->OnStartInput(inputClientInfo, agent);
|
||||
};
|
||||
|
||||
void InputMethodSystemAbility::CheckSecurityMode(InputClientInfo &inputClientInfo)
|
||||
void InputMethodSystemAbility::CheckInputTypeOption(InputClientInfo &inputClientInfo)
|
||||
{
|
||||
IMSA_HILOGI("SecurityFlag: %{public}d, IsSameTextInput: %{public}d, IsStarted: %{public}d, "
|
||||
"IsSecurityImeStarted: %{public}d.",
|
||||
inputClientInfo.config.inputAttribute.GetSecurityFlag(), !inputClientInfo.isNotifyInputStart,
|
||||
InputTypeManager::GetInstance().IsStarted(), InputTypeManager::GetInstance().IsSecurityImeStarted());
|
||||
if (inputClientInfo.config.inputAttribute.GetSecurityFlag()) {
|
||||
if (InputTypeManager::GetInstance().IsStarted()) {
|
||||
IMSA_HILOGD("security ime has started.");
|
||||
if (!InputTypeManager::GetInstance().IsStarted()) {
|
||||
StartInputType(InputType::SECURITY_INPUT);
|
||||
IMSA_HILOGI("SecurityFlag, input type is not started.");
|
||||
return;
|
||||
}
|
||||
auto ret = StartInputType(InputType::SECURITY_INPUT);
|
||||
IMSA_HILOGD("switch to security ime ret = %{public}d.", ret);
|
||||
if (!inputClientInfo.isNotifyInputStart) {
|
||||
IMSA_HILOGI("SecurityFlag, same textinput.");
|
||||
return;
|
||||
}
|
||||
if (!InputTypeManager::GetInstance().IsSecurityImeStarted()) {
|
||||
StartInputType(InputType::SECURITY_INPUT);
|
||||
IMSA_HILOGI("SecurityFlag, input type is started, but not security.");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("SecurityFlag others.");
|
||||
return;
|
||||
}
|
||||
if (!InputTypeManager::GetInstance().IsStarted() || InputTypeManager::GetInstance().IsCameraImeStarted()) {
|
||||
IMSA_HILOGD("security ime is not start or camera ime started, keep current.");
|
||||
if (inputClientInfo.isNotifyInputStart && InputTypeManager::GetInstance().IsStarted()) {
|
||||
IMSA_HILOGI("NormalFlag diff textinput, input type started.");
|
||||
StartInputType(InputType::NONE);
|
||||
return;
|
||||
}
|
||||
auto ret = StartInputType(InputType::NONE);
|
||||
IMSA_HILOGD("Exit security ime ret = %{public}d.", ret);
|
||||
IMSA_HILOGI("NormalFlag others.");
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbility::ShowInput(sptr<IInputClient> client)
|
||||
@ -506,7 +519,7 @@ int32_t InputMethodSystemAbility::ExitCurrentInputType()
|
||||
if (userSession_->CheckSecurityMode()) {
|
||||
return StartInputType(InputType::SECURITY_INPUT);
|
||||
}
|
||||
return userSession_->ExitCurrentInputType();
|
||||
return StartInputType(InputType::NONE);
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbility::IsDefaultIme()
|
||||
|
@ -91,6 +91,13 @@ bool InputTypeManager::IsStarted()
|
||||
return isStarted_;
|
||||
}
|
||||
|
||||
bool InputTypeManager::IsSecurityImeStarted()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(stateLock_);
|
||||
return isStarted_ && inputTypes_.find(InputType::SECURITY_INPUT) != inputTypes_.end()
|
||||
&& inputTypes_[InputType::SECURITY_INPUT] == currentTypeIme_;
|
||||
}
|
||||
|
||||
bool InputTypeManager::IsCameraImeStarted()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(stateLock_);
|
||||
|
@ -28,6 +28,7 @@ void ImeSettingListenerTestImpl::ResetParam()
|
||||
{
|
||||
status_ = InputWindowStatus::NONE;
|
||||
subProperty_ = {};
|
||||
property_ = {};
|
||||
isImeChange_ = false;
|
||||
}
|
||||
bool ImeSettingListenerTestImpl::WaitPanelHide()
|
||||
@ -53,9 +54,11 @@ bool ImeSettingListenerTestImpl::WaitImeChange()
|
||||
bool ImeSettingListenerTestImpl::WaitTargetImeChange(const std::string &bundleName)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(imeSettingListenerLock_);
|
||||
// 3 means 3 seconds.
|
||||
imeSettingListenerCv_.wait_for(
|
||||
lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME), [&bundleName]() { return bundleName == property_.name; });
|
||||
do {
|
||||
// 3 means 3 seconds.
|
||||
imeSettingListenerCv_.wait_for(lock, std::chrono::seconds(SWITCH_IME_WAIT_TIME),
|
||||
[&bundleName]() { return bundleName == property_.name; });
|
||||
} while (bundleName != property_.name);
|
||||
return isImeChange_ && bundleName == property_.name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user