!1426 fix RemoveDeathRecipient

Merge pull request !1426 from ht/master
This commit is contained in:
openharmony_ci 2024-08-29 14:52:34 +00:00 committed by Gitee
commit d1c333a063
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 19 additions and 4 deletions

View File

@ -171,11 +171,11 @@ sptr<IInputMethodSystemAbility> InputMethodController::GetSystemAbilityProxy()
void InputMethodController::RemoveDeathRecipient()
{
std::lock_guard<std::mutex> lock(abilityLock_);
if (abilityManager_ == nullptr || deathRecipient_ == nullptr) {
return;
}
if (abilityManager_ != nullptr && abilityManager_->AsObject() != nullptr && deathRecipient_ != nullptr) {
abilityManager_->AsObject()->RemoveDeathRecipient(deathRecipient_);
}
deathRecipient_ = nullptr;
abilityManager_ = nullptr;
}
void InputMethodController::DeactivateClient()
@ -356,6 +356,12 @@ int32_t InputMethodController::Close()
return ReleaseInput(clientInfo_.client);
}
void InputMethodController::Reset()
{
Close();
RemoveDeathRecipient();
}
int32_t InputMethodController::RequestShowInput()
{
auto proxy = GetSystemAbilityProxy();
@ -498,7 +504,6 @@ int32_t InputMethodController::ReleaseInput(sptr<IInputClient> &client)
if (ret == ErrorCode::NO_ERROR) {
OnInputStop();
}
RemoveDeathRecipient();
SetTextListener(nullptr);
return ret;
}

View File

@ -778,6 +778,16 @@ public:
*/
IMF_API bool IsCurrentImeByPid(int32_t pid);
/**
* @brief Reset controller.
*
* This function is used to reset controller.
* Do not call this interface unless you know what you are doing
*
* @since 12
*/
IMF_API void Reset();
private:
InputMethodController();
~InputMethodController();