Signed-off-by: htt1997 <hutao105@huawei.com>
This commit is contained in:
htt1997 2024-08-01 16:07:16 +08:00
parent 2812ae6cde
commit 55d122a1db
10 changed files with 35 additions and 28 deletions

View File

@ -17,24 +17,23 @@
namespace OHOS {
namespace MiscServices {
const std::unordered_set<std::string> EventChecker::EVENT_TYPES[static_cast<uint32_t>(EventSubscribeModule::MODULE_END)] = {
{ { "insertText", "deleteLeft", "deleteRight", "sendKeyboardStatus", "sendFunctionKey", "moveCursor",
"handleExtendAction", "selectByRange", "selectByMovement", "getLeftTextOfCursor", "getRightTextOfCursor",
"getTextIndexAtCursor" } },
{ { "imeChange", "imeShow", "imeHide" } },
{ { "inputStart", "inputStop", "keyboardShow", "keyboardHide", "setCallingWindow", "setSubtype",
"securityModeChange", "privateCommand" } },
{ { "editorAttributeChanged", "keyDown", "keyUp", "keyEvent", "cursorContextChange", "selectionChange",
"textChange" } },
{ { "show", "hide", "sizeChange" } }, { { "panelPrivateCommand", "isPanelShow" } }
const std::unordered_set<std::string> EVENT_TYPES[static_cast<uint32_t>(EventSubscribeModule::MODULE_END)] = {
{ "insertText", "deleteLeft", "deleteRight", "sendKeyboardStatus", "sendFunctionKey", "moveCursor",
"handleExtendAction", "selectByRange", "selectByMovement", "getLeftTextOfCursor", "getRightTextOfCursor",
"getTextIndexAtCursor" },
{ "imeChange", "imeShow", "imeHide" },
{ "inputStart", "inputStop", "keyboardShow", "keyboardHide", "setCallingWindow", "setSubtype",
"securityModeChange", "privateCommand" },
{ "editorAttributeChanged", "keyDown", "keyUp", "keyEvent", "cursorContextChange", "selectionChange", "textChange" },
{ "show", "hide", "sizeChange" }, { "panelPrivateCommand", "isPanelShow" }
};
bool EventChecker::IsValidEventType(EventSubscribeModule module, const std::string &type)
{
if (module < EventSubscribeModule::MODULE_BEGIN || module >= EventSubscribeModule::MODULE_END) {
return false;
}
return EVENT_TYPES[static_cast<uint32_t>(module)].find(type) != EVENT_TYPES[static_cast<uint32_t>(module)].end();
if (module < EventSubscribeModule::MODULE_BEGIN || module >= EventSubscribeModule::MODULE_END) {
return false;
}
return EVENT_TYPES[static_cast<uint32_t>(module)].find(type) != EVENT_TYPES[static_cast<uint32_t>(module)].end();
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -34,9 +34,6 @@ enum class EventSubscribeModule : uint32_t {
class EventChecker {
public:
static bool IsValidEventType(EventSubscribeModule module, const std::string &type);
private:
static const std::unordered_set<std::string> EVENT_TYPES[static_cast<uint32_t>(EventSubscribeModule::MODULE_END)];
};
} // namespace MiscServices
} // namespace OHOS

View File

@ -37,6 +37,9 @@ public:
{
InputMethodSyncTrace tracer("Traverse callback");
for (const auto &object : objects) {
if (object == nullptr) {
continue;
}
JsUtil::ScopeGuard scopeGuard(object->env_);
napi_value jsOutput = nullptr;
Execute(object, argContainer, jsOutput);

View File

@ -35,17 +35,18 @@ std::shared_ptr<PanelListenerImpl> PanelListenerImpl::GetInstance()
PanelListenerImpl::~PanelListenerImpl() {}
void PanelListenerImpl::Subscribe(uint32_t windowId, const std::string &type, std::shared_ptr<JSCallbackObject> cbObject)
void PanelListenerImpl::Subscribe(uint32_t windowId, const std::string &type,
std::shared_ptr<JSCallbackObject> cbObject)
{
callbacks_.Compute(windowId,
[cbObject, &type](auto windowId, std::map<std::string, std::shared_ptr<JSCallbackObject>> &cbs) {
auto [it, insert] = cbs.try_emplace(type, cbObject);
if (insert) {
IMSA_HILOGD("type: %{public}s of windowId: %{public}u already subscribed.", type.c_str(), windowId);
} else {
IMSA_HILOGI("start to subscribe type: %{public}s of windowId: %{public}u.", type.c_str(), windowId);
} else {
IMSA_HILOGD("type: %{public}s of windowId: %{public}u already subscribed.", type.c_str(), windowId);
}
return cbs.empty();
return !cbs.empty();
});
}
@ -76,6 +77,10 @@ void PanelListenerImpl::OnPanelStatus(uint32_t windowId, bool isShow)
callBack = it->second;
return !callbacks.empty();
});
if (callBack == nullptr) {
IMSA_HILOGE("callBack is nullptr!");
return;
}
auto entry = std::make_shared<UvEntry>(callBack);
IMSA_HILOGI("windowId = %{public}u, type = %{public}s", windowId, type.c_str());
auto task = [entry]() {

View File

@ -32,7 +32,8 @@ public:
enum {
KEY_EVENT_CONSUMER_BEGIN,
KEY_EVENT_RESULT = KEY_EVENT_CONSUMER_BEGIN,
KEY_EVENT_CONSUMER_CMD_END };
KEY_EVENT_CONSUMER_CMD_END
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IKeyEventConsumer");
virtual int32_t OnKeyEventResult(bool isConsumed) = 0;
};

View File

@ -19,7 +19,7 @@
#include <fstream>
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
#include <climits>
#include "global.h"
namespace OHOS {

View File

@ -104,8 +104,10 @@ private:
&InputMethodSystemAbilityStub::ShowCurrentInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_CURRENT_INPUT)] =
&InputMethodSystemAbilityStub::HideCurrentInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_INPUT)] = &InputMethodSystemAbilityStub::ShowInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_INPUT)] = &InputMethodSystemAbilityStub::HideInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::SHOW_INPUT)] =
&InputMethodSystemAbilityStub::ShowInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::HIDE_INPUT)] =
&InputMethodSystemAbilityStub::HideInputOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::STOP_INPUT_SESSION)] =
&InputMethodSystemAbilityStub::StopInputSessionOnRemote,
[static_cast<uint32_t>(InputMethodInterfaceCode::RELEASE_INPUT)] =

View File

@ -39,7 +39,7 @@
#include "input_method_property.h"
#include "iremote_broker.h"
#include "message_parcel.h"
#include "unRegistered_type.h"
#include "input_method_types.h"
using namespace OHOS::MiscServices;
namespace OHOS {

View File

@ -25,6 +25,6 @@ namespace OHOS {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::IMS_CMD_LAST);
ImfSaStubFuzzUtil::FuzzInputMethodSystemAbility(data, size, InputMethodInterfaceCode::IMS_CMD_END);
return 0;
}

View File

@ -29,7 +29,7 @@
#include "keyboard_listener_test_impl.h"
#include "tdd_util.h"
#include "text_listener.h"
#include "unRegistered_type.h"
#include "input_method_types.h"
using namespace testing::ext;
namespace OHOS {
namespace MiscServices {