!1540 fix:delete force hide

Merge pull request !1540 from 吴成文/master
This commit is contained in:
openharmony_ci 2024-10-26 08:21:57 +00:00 committed by Gitee
commit 11656567fb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 45 additions and 61 deletions

View File

@ -36,7 +36,6 @@ enum class OperateIMEInfoCode : int32_t {
IME_HIDE_NORMAL,
IME_HIDE_UNFOCUSED,
IME_HIDE_SELF,
IME_HIDE_FORCE,
};
enum class IMEBehaviour : int32_t {

View File

@ -37,8 +37,7 @@ const std::unordered_map<int32_t, std::string> InputMethodSysEvent::operateInfo_
"editable state." },
{ static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL), "HideSoftKeyboard, hide soft keyboard." },
{ static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_UNFOCUSED), "OnUnfocused: unfocused, hide soft keyboard." },
{ static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_SELF), "HideKeyboardSelf: hide soft keyboard self." },
{ static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_FORCE), "HidePanel: force hide soft keyboard." }
{ static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_SELF), "HideKeyboardSelf: hide soft keyboard self." }
};
std::map<int32_t, int32_t> InputMethodSysEvent::inputmethodBehaviour_ = {
@ -154,7 +153,6 @@ std::string InputMethodSysEvent::GetOperateAction(int32_t infoCode)
case static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL):
case static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_UNFOCUSED):
case static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_SELF):
case static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_FORCE):
return "hide";
default:
break;

View File

@ -56,7 +56,7 @@ public:
virtual int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) = 0;
virtual int32_t StopInput(const sptr<IRemoteObject> &channel) = 0;
virtual int32_t ShowKeyboard() = 0;
virtual int32_t HideKeyboard(bool isForce) = 0;
virtual int32_t HideKeyboard() = 0;
virtual int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) = 0;
virtual int32_t StopInputService(bool isTerminateIme) = 0;
virtual int32_t SetSubtype(const SubProperty &property) = 0;

View File

@ -99,7 +99,7 @@ public:
int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient);
int32_t StopInput(sptr<IRemoteObject> channelObj);
int32_t ShowKeyboard();
int32_t HideKeyboard(bool isForce);
int32_t HideKeyboard();
void OnInitInputControlChannel(sptr<IRemoteObject> channelObj);
void OnSetSubtype(SubProperty subProperty);
@ -145,17 +145,16 @@ private:
int32_t InvokeStartInputCallback(bool isNotifyInputStart);
int32_t InvokeStartInputCallback(const TextTotalConfig &textConfig, bool isNotifyInputStart);
int32_t HideKeyboard(Trigger trigger, bool isForce);
int32_t HideKeyboard(Trigger trigger);
std::shared_ptr<InputMethodPanel> GetSoftKeyboardPanel();
/* param flag: ShowPanel is async, show/hide softkeyboard in alphabet keyboard attached,
flag will be changed before finishing show/hide */
int32_t ShowPanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel, PanelFlag flag, Trigger trigger);
int32_t HidePanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel, PanelFlag flag, Trigger trigger,
bool isForce);
int32_t HidePanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel, PanelFlag flag, Trigger trigger);
void SetInputAttribute(const InputAttribute &inputAttribute);
void ClearInputAttribute();
void NotifyPanelStatusInfo(const PanelStatusInfo &info);
int32_t HideKeyboardImplWithoutLock(int32_t cmdId, bool isForce);
int32_t HideKeyboardImplWithoutLock(int32_t cmdId);
int32_t ShowKeyboardImplWithLock(int32_t cmdId);
int32_t ShowKeyboardImplWithoutLock(int32_t cmdId);
void NotifyPanelStatusInfo(const PanelStatusInfo &info, std::shared_ptr<InputDataChannelProxy> &channelProxy);

View File

@ -36,7 +36,7 @@ public:
int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override;
int32_t StopInput(const sptr<IRemoteObject> &channel) override;
int32_t ShowKeyboard() override;
int32_t HideKeyboard(bool isForce) override;
int32_t HideKeyboard() override;
int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) override;
int32_t StopInputService(bool isTerminateIme) override;
int32_t SetSubtype(const SubProperty &property) override;

View File

@ -37,7 +37,7 @@ public:
int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override;
int32_t StopInput(const sptr<IRemoteObject> &channel) override;
int32_t ShowKeyboard() override;
int32_t HideKeyboard(bool isForce) override;
int32_t HideKeyboard() override;
int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) override;
int32_t StopInputService(bool isTerminateIme) override;
int32_t SetSubtype(const SubProperty &property) override;

View File

@ -87,7 +87,7 @@ public:
PanelType GetPanelType();
PanelFlag GetPanelFlag();
int32_t ShowPanel();
int32_t HidePanel(bool isForce);
int32_t HidePanel();
int32_t SizeChange(const WindowSize &size);
WindowSize GetKeyboardSize();
bool SetPanelStatusListener(std::shared_ptr<PanelStatusListener> statusListener, const std::string &type);

View File

@ -65,10 +65,10 @@ public:
class TaskImsaHideKeyboard : public Task {
public:
explicit TaskImsaHideKeyboard(bool force) : Task(TASK_TYPE_IMSA_HIDE_KEYBOARD)
explicit TaskImsaHideKeyboard() : Task(TASK_TYPE_IMSA_HIDE_KEYBOARD)
{
auto func = [=]() {
InputMethodAbility::GetInstance()->HideKeyboard(force);
InputMethodAbility::GetInstance()->HideKeyboard();
};
actions_.emplace_back(std::make_unique<Action>(func));
}

View File

@ -213,7 +213,7 @@ int32_t InputMethodAbility::StartInput(const InputClientInfo &clientInfo, bool i
IMSA_HILOGD("pwd or normal input pattern changed, need hide panel first.");
auto panel = GetSoftKeyboardPanel();
if (panel != nullptr) {
panel->HidePanel(false);
panel->HidePanel();
}
}
int32_t ret = isBindFromClient ? InvokeStartInputCallback(clientInfo.config, clientInfo.isNotifyInputStart)
@ -282,7 +282,7 @@ int32_t InputMethodAbility::StopInput(sptr<IRemoteObject> channelObject)
std::lock_guard<std::recursive_mutex> lock(keyboardCmdLock_);
int32_t cmdCount = ++cmdId_;
IMSA_HILOGI("IMA");
HideKeyboardImplWithoutLock(cmdCount, false);
HideKeyboardImplWithoutLock(cmdCount);
ClearDataChannel(channelObject);
ClearInputAttribute();
ClearInputType();
@ -381,20 +381,20 @@ int32_t InputMethodAbility::OnStopInputService(bool isTerminateIme)
return ErrorCode::NO_ERROR;
}
int32_t InputMethodAbility::HideKeyboard(bool isForce)
int32_t InputMethodAbility::HideKeyboard()
{
std::lock_guard<std::recursive_mutex> lock(keyboardCmdLock_);
int32_t cmdCount = ++cmdId_;
return HideKeyboardImplWithoutLock(cmdCount, isForce);
return HideKeyboardImplWithoutLock(cmdCount);
}
int32_t InputMethodAbility::HideKeyboardImplWithoutLock(int32_t cmdId, bool isForce)
int32_t InputMethodAbility::HideKeyboardImplWithoutLock(int32_t cmdId)
{
if (cmdId != cmdId_) {
IMSA_HILOGE("current is not last cmd cur: %{public}d, cmdId_: %{public}d!", cmdId, cmdId_);
return ErrorCode::NO_ERROR;
}
return HideKeyboard(Trigger::IMF, isForce);
return HideKeyboard(Trigger::IMF);
}
int32_t InputMethodAbility::ShowKeyboard()
@ -569,7 +569,7 @@ int32_t InputMethodAbility::HideKeyboardSelf()
return ErrorCode::NO_ERROR;
}
InputMethodSyncTrace tracer("IMA_HideKeyboardSelf start.");
auto ret = HideKeyboard(Trigger::IME_APP, false);
auto ret = HideKeyboard(Trigger::IME_APP);
if (ret == ErrorCode::NO_ERROR) {
InputMethodSysEvent::GetInstance().OperateSoftkeyboardBehaviour(OperateIMEInfoCode::IME_HIDE_SELF);
}
@ -867,7 +867,7 @@ int32_t InputMethodAbility::HidePanel(const std::shared_ptr<InputMethodPanel> &i
}
std::lock_guard<std::recursive_mutex> lock(keyboardCmdLock_);
return HidePanel(inputMethodPanel, inputMethodPanel->GetPanelFlag(), Trigger::IME_APP, false);
return HidePanel(inputMethodPanel, inputMethodPanel->GetPanelFlag(), Trigger::IME_APP);
}
int32_t InputMethodAbility::ShowPanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel, PanelFlag flag,
@ -897,12 +897,12 @@ int32_t InputMethodAbility::ShowPanel(const std::shared_ptr<InputMethodPanel> &i
}
int32_t InputMethodAbility::HidePanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel, PanelFlag flag,
Trigger trigger, bool isForce)
Trigger trigger)
{
if (inputMethodPanel == nullptr) {
return ErrorCode::ERROR_BAD_PARAMETERS;
}
auto ret = inputMethodPanel->HidePanel(isForce);
auto ret = inputMethodPanel->HidePanel();
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGD("failed, ret: %{public}d", ret);
return ret;
@ -949,7 +949,7 @@ InputAttribute InputMethodAbility::GetInputAttribute()
return inputAttribute_;
}
int32_t InputMethodAbility::HideKeyboard(Trigger trigger, bool isForce)
int32_t InputMethodAbility::HideKeyboard(Trigger trigger)
{
InputMethodSyncTrace tracer("IMA_HideKeyboard");
if (imeListener_ == nullptr) {
@ -969,7 +969,7 @@ int32_t InputMethodAbility::HideKeyboard(Trigger trigger, bool isForce)
IMSA_HILOGI("panel flag is candidate, no need to hide.");
return ErrorCode::NO_ERROR;
}
return HidePanel(panel, flag, trigger, isForce);
return HidePanel(panel, flag, trigger);
}
IMSA_HILOGI("panel is not created.");
imeListener_->OnKeyboardStatus(false);
@ -1114,7 +1114,7 @@ void InputMethodAbility::OnClientInactive(const sptr<IRemoteObject> &channel)
}
panels_.ForEach([this, &channelProxy](const PanelType &panelType, const std::shared_ptr<InputMethodPanel> &panel) {
if (panelType != PanelType::SOFT_KEYBOARD || panel->GetPanelFlag() != PanelFlag::FLG_FIXED) {
auto ret = panel->HidePanel(false);
auto ret = panel->HidePanel();
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed, ret: %{public}d", ret);
return false;

View File

@ -77,9 +77,9 @@ int32_t InputMethodCoreProxy::ShowKeyboard()
return SendRequest(SHOW_KEYBOARD);
}
int32_t InputMethodCoreProxy::HideKeyboard(bool isForce)
int32_t InputMethodCoreProxy::HideKeyboard()
{
return SendRequest(HIDE_KEYBOARD, [isForce](MessageParcel &data) { return ITypesUtil::Marshal(data, isForce); });
return SendRequest(HIDE_KEYBOARD);
}
int32_t InputMethodCoreProxy::SetSubtype(const SubProperty &property)

View File

@ -70,9 +70,9 @@ int32_t InputMethodCoreStub::ShowKeyboard()
return ErrorCode::NO_ERROR;
}
int32_t InputMethodCoreStub::HideKeyboard(bool isForce)
int32_t InputMethodCoreStub::HideKeyboard()
{
auto task = std::make_shared<TaskImsaHideKeyboard>(isForce);
auto task = std::make_shared<TaskImsaHideKeyboard>();
TaskManager::GetInstance().PostTask(task);
return ErrorCode::NO_ERROR;
}
@ -196,12 +196,7 @@ int32_t InputMethodCoreStub::ShowKeyboardOnRemote(MessageParcel &data, MessagePa
int32_t InputMethodCoreStub::HideKeyboardOnRemote(MessageParcel &data, MessageParcel &reply)
{
bool isForce = false;
if (!ITypesUtil::Unmarshal(data, isForce)) {
IMSA_HILOGE("unmarshal failed!");
return ErrorCode::ERROR_EX_PARCELABLE;
}
auto ret = HideKeyboard(isForce);
auto ret = HideKeyboard();
return ITypesUtil::Marshal(reply, ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}

View File

@ -26,7 +26,6 @@
#include "scene_board_judgement.h"
#include "sys_cfg_parser.h"
#include "ui/rs_surface_node.h"
#include "inputmethod_sysevent.h"
namespace OHOS {
namespace MiscServices {
@ -144,7 +143,7 @@ int32_t InputMethodPanel::SetPanelProperties()
int32_t InputMethodPanel::DestroyPanel()
{
auto ret = HidePanel(false);
auto ret = HidePanel();
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("InputMethodPanel, hide panel failed, ret: %{public}d!", ret);
}
@ -651,9 +650,9 @@ int32_t InputMethodPanel::SetTextFieldAvoidInfo(double positionY, double height)
return ErrorCode::NO_ERROR;
}
int32_t InputMethodPanel::HidePanel(bool isForce)
int32_t InputMethodPanel::HidePanel()
{
IMSA_HILOGD("InputMethodPanel start. isForce=%{public}d", isForce);
IMSA_HILOGD("InputMethodPanel start");
if (window_ == nullptr) {
IMSA_HILOGE("window_ is nullptr!");
return ErrorCode::ERROR_NULL_POINTER;
@ -662,10 +661,6 @@ int32_t InputMethodPanel::HidePanel(bool isForce)
IMSA_HILOGI("panel already hidden.");
return ErrorCode::NO_ERROR;
}
if (isForce) {
IMSA_HILOGI("force hide");
InputMethodSysEvent::GetInstance().OperateSoftkeyboardBehaviour(OperateIMEInfoCode::IME_HIDE_FORCE);
}
auto ret = WMError::WM_OK;
{
InputMethodSyncTrace tracer("InputMethodPanel_HidePanel");

View File

@ -192,7 +192,7 @@ int32_t PerUserSession::HideKeyboard(const sptr<IInputClient> &currentClient)
IMSA_HILOGE("ime: %{public}d is not exist!", clientInfo->bindImeType);
return ErrorCode::ERROR_IME_NOT_STARTED;
}
auto ret = RequestIme(data, RequestType::NORMAL, [&data] { return data->core->HideKeyboard(false); });
auto ret = RequestIme(data, RequestType::NORMAL, [&data] { return data->core->HideKeyboard(); });
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed to hide keyboard, ret: %{public}d!", ret);
return ErrorCode::ERROR_KBD_HIDE_FAILED;
@ -408,13 +408,7 @@ int32_t PerUserSession::OnRequestHideInput()
return ErrorCode::ERROR_IME_NOT_STARTED;
}
bool isForce = false;
if (!data->freezeMgr->IsIpcNeeded(RequestType::REQUEST_HIDE)) {
IMSA_HILOGD("need to force hide");
isForce = true;
}
auto ret = RequestIme(data, RequestType::REQUEST_HIDE,
[&data, isForce] { return data->core->HideKeyboard(isForce); });
auto ret = RequestIme(data, RequestType::REQUEST_HIDE, [&data] { return data->core->HideKeyboard(); });
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed to hide keyboard, ret: %{public}d!", ret);
return ErrorCode::ERROR_KBD_HIDE_FAILED;
@ -1288,6 +1282,10 @@ int32_t PerUserSession::RequestIme(const std::shared_ptr<ImeData> &data, Request
IMSA_HILOGE("data is nullptr!");
return ErrorCode::NO_ERROR;
}
if (!data->freezeMgr->IsIpcNeeded(type)) {
IMSA_HILOGD("no need to request, type: %{public}d.", type);
return ErrorCode::NO_ERROR;
}
data->freezeMgr->BeforeIpc(type);
auto ret = exec();
data->freezeMgr->AfterIpc(type, ret == ErrorCode::NO_ERROR);

View File

@ -299,7 +299,7 @@ HWTEST_F(InputMethodAbilityExceptionTest, testHideKeyboard_001, TestSize.Level0)
{
IMSA_HILOGI("InputMethodAbilityExceptionTest testHideKeyboard_001 START");
// imeListener_ == nullptr
auto ret = inputMethodAbility_->HideKeyboard(false);
auto ret = inputMethodAbility_->HideKeyboard();
EXPECT_EQ(ret, ErrorCode::ERROR_IME);
// panel exist, PanelFlag == FLG_CANDIDATE_COLUMN
@ -311,14 +311,14 @@ HWTEST_F(InputMethodAbilityExceptionTest, testHideKeyboard_001, TestSize.Level0)
panel->panelFlag_ = FLG_CANDIDATE_COLUMN;
panel->windowId_ = 2;
inputMethodAbility_->panels_.Insert(SOFT_KEYBOARD, panel);
ret = inputMethodAbility_->HideKeyboard(false);
ret = inputMethodAbility_->HideKeyboard();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
// ShowPanel failed
inputMethodAbility_->panels_.Clear();
panel->panelFlag_ = FLG_FIXED;
inputMethodAbility_->panels_.Insert(SOFT_KEYBOARD, panel);
ret = inputMethodAbility_->HideKeyboard(false);
ret = inputMethodAbility_->HideKeyboard();
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
ResetMemberVar();

View File

@ -311,7 +311,7 @@ HWTEST_F(InputMethodAbilityTest, testShowKeyboardWithoutImeListener, TestSize.Le
HWTEST_F(InputMethodAbilityTest, testHideKeyboardWithoutImeListener, TestSize.Level0)
{
IMSA_HILOGI("InputMethodAbilityTest testHideKeyboardWithoutImeListener start.");
auto ret = inputMethodAbility_->HideKeyboard(false);
auto ret = inputMethodAbility_->HideKeyboard();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
}
@ -826,7 +826,7 @@ HWTEST_F(InputMethodAbilityTest, testNotifyPanelStatusInfo_001, TestSize.Level0)
EXPECT_TRUE(TextListener::WaitNotifyPanelStatusInfoCallback({ info1, true, Trigger::IMF }));
TextListener::ResetParam();
ret = inputMethodAbility_->HideKeyboard(false);
ret = inputMethodAbility_->HideKeyboard();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
EXPECT_TRUE(TextListener::WaitSendKeyboardStatusCallback(KeyboardStatus::HIDE));
EXPECT_TRUE(TextListener::WaitNotifyPanelStatusInfoCallback({ info1, false, Trigger::IMF }));

View File

@ -392,7 +392,7 @@ void InputMethodPanelTest::TestHidePanel(const std::shared_ptr<InputMethodPanel>
ASSERT_NE(panel, nullptr);
// set tokenId and uid as current ime
AccessScope scope(currentImeTokenId_, currentImeUid_);
auto ret = panel->HidePanel(false);
auto ret = panel->HidePanel();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
}
@ -612,7 +612,7 @@ HWTEST_F(InputMethodPanelTest, testShowPanel, TestSize.Level0)
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
ret = inputMethodPanel->ShowPanel();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
ret = inputMethodPanel->HidePanel(false);
ret = inputMethodPanel->HidePanel();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
ret = inputMethodPanel->DestroyPanel();
EXPECT_EQ(ret, ErrorCode::NO_ERROR);