diff --git a/OAT.xml b/OAT.xml
index 2e3e8eb9..83f92a23 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -20,9 +20,9 @@ licensefile:
tasklist(only for batch mode):
1. task: Define oat check thread, each task will start a new thread.
-2. task name: Only an name, no practical effect.
-3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
-4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
+2. task name: Only a name, no practical effect.
+3. task policy: Default policy for projects under this task, this field is required and the specified policy must be defined in policylist.
+4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must be defined in filefilterlist.
5. task project: Projects to be checked, the path field define the source root dir of the project.
@@ -39,7 +39,7 @@ policyList:
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
-5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
+5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be excluded while process this policyitem.
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
7. policyitem filefilter: Used to bind filefilter which define filter rules.
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
diff --git a/README_zh.md b/README_zh.md
index de1489cb..f50bc53b 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -583,7 +583,7 @@ keyboardDelegate.off('textChange', (text) => {
hideKeyboard(): Promise<void>;
|
-隐藏输入法,使用peomise形式返回结果。参数个数为0,否则抛出异常。
+ | 隐藏输入法,使用promise形式返回结果。参数个数为0,否则抛出异常。
|
diff --git a/bundle.json b/bundle.json
index a0c2523d..0d10b290 100644
--- a/bundle.json
+++ b/bundle.json
@@ -84,9 +84,7 @@
}
],
"test": [
- "//base/inputmethod/imf/unitest:InputMethodControllerTest",
- "//base/inputmethod/imf/unitest:InputMethodAbilityTest",
- "//base/inputmethod/imf/unitest:InputMethodServiceTest",
+ "//base/inputmethod/imf/unitest:unittest",
"//base/inputmethod/imf/test/fuzztest:fuzztest",
"//base/inputmethod/imf/test/unitest/src:unittest"
]
diff --git a/etc/init/inputmethodservice.cfg b/etc/init/inputmethodservice.cfg
index ec97081c..61228b60 100644
--- a/etc/init/inputmethodservice.cfg
+++ b/etc/init/inputmethodservice.cfg
@@ -4,6 +4,7 @@
"path" : ["/system/bin/sa_main", "/system/profile/inputmethod_service.xml"],
"uid" : "inputmethod",
"gid" : ["inputmethod", "shell"],
+ "permission" : ["ohos.permission.INPUT_MONITORING"],
"caps" : [],
"secon" : "u:r:inputmethod_service:s0"
}
diff --git a/etc/para/include/para_handle.h b/etc/para/include/para_handle.h
index 5c10a451..6ecd2dd8 100644
--- a/etc/para/include/para_handle.h
+++ b/etc/para/include/para_handle.h
@@ -25,9 +25,10 @@ namespace OHOS {
static bool SetDefaultIme(int32_t userId, const std::string &imeName);
static std::string GetDefaultIme(int32_t userId);
+ static constexpr const char *DEFAULT_PACKAGE_NAME = "com.example.kikakeyboard";
+ static constexpr const char *DEFAULT_ABILITY_NAME = "ServiceExtAbility";
private:
static const char *DEFAULT_IME_KEY;
- static const char *DEFAULT_IME_NAME;
static constexpr int CONFIG_LEN = 128;
static const int32_t main_userId = 100;
};
diff --git a/etc/para/src/para_handle.cpp b/etc/para/src/para_handle.cpp
index 44922058..dcc26a92 100644
--- a/etc/para/src/para_handle.cpp
+++ b/etc/para/src/para_handle.cpp
@@ -19,7 +19,6 @@
namespace OHOS {
namespace MiscServices {
const char *ParaHandle::DEFAULT_IME_KEY = "persist.sys.default_ime";
- const char *ParaHandle::DEFAULT_IME_NAME = "com.example.kikakeyboard/ServiceExtAbility";
bool ParaHandle::SetDefaultIme(int32_t userId, const std::string &imeName)
{
if (userId != main_userId) {
@@ -41,9 +40,9 @@ namespace OHOS {
if (code > 0) {
return value;
}
-
- SetDefaultIme(userId, DEFAULT_IME_NAME);
- return DEFAULT_IME_NAME;
+ std::string defaultName = std::string(DEFAULT_PACKAGE_NAME) + "/" + std::string(DEFAULT_ABILITY_NAME);
+ SetDefaultIme(userId, defaultName);
+ return defaultName;
}
} // namespace MiscServices
} // namespace OHOS
diff --git a/frameworks/inputmethod_ability/include/input_method_ability.h b/frameworks/inputmethod_ability/include/input_method_ability.h
index 76dcbb02..0ddcf0d3 100644
--- a/frameworks/inputmethod_ability/include/input_method_ability.h
+++ b/frameworks/inputmethod_ability/include/input_method_ability.h
@@ -43,7 +43,6 @@ public:
InputMethodAbility();
~InputMethodAbility();
static sptr GetInstance();
- sptr OnConnect();
int32_t InsertText(const std::string text);
void setImeListener(std::shared_ptr imeListener);
void setKdListener(std::shared_ptr kdListener);
@@ -65,7 +64,7 @@ private:
MessageHandler *msgHandler;
bool mSupportPhysicalKbd = false;
InputAttribute editorAttribute;
- int32_t displyId = 0;
+ int32_t displayId = 0;
sptr startInputToken;
InputChannel *writeInputChannel;
bool stop_;
@@ -99,6 +98,7 @@ private:
void Initialize();
void WorkThread();
+ void QuitWorkThread();
void OnInitialInput(Message *msg);
void OnStartInput(Message *msg);
@@ -113,7 +113,7 @@ private:
void InitialInputWindow();
void ShowInputWindow(bool isShowKeyboard, const SubProperty &subProperty);
- void DissmissInputWindow();
+ void DismissInputWindow();
void BindServiceAndClient();
};
diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp
index d35afc1f..5dec26bd 100644
--- a/frameworks/inputmethod_ability/src/input_method_ability.cpp
+++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp
@@ -46,12 +46,11 @@ InputMethodAbility::InputMethodAbility() : stop_(false)
InputMethodAbility::~InputMethodAbility()
{
IMSA_HILOGI("InputMethodAbility::~InputMethodAbility");
- instance_ = nullptr;
+ QuitWorkThread();
if (msgHandler) {
delete msgHandler;
msgHandler = nullptr;
}
- stop_ = true;
}
sptr InputMethodAbility::GetInstance()
@@ -196,6 +195,7 @@ void InputMethodAbility::WorkThread()
break;
}
default: {
+ IMSA_HILOGD("the message is %{public}d.", msg->msgId_);
break;
}
}
@@ -208,7 +208,7 @@ void InputMethodAbility::OnInitialInput(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnInitialInput");
MessageParcel *data = msg->msgContent_;
- displyId = data->ReadInt32();
+ displayId = data->ReadInt32();
sptr channelObject = data->ReadRemoteObject();
if (channelObject == nullptr) {
IMSA_HILOGI("InputMethodAbility::OnInitialInput channelObject is nullptr");
@@ -268,7 +268,7 @@ void InputMethodAbility::OnShowKeyboard(Message *msg)
void InputMethodAbility::OnHideKeyboard(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnHideKeyboard");
- DissmissInputWindow();
+ DismissInputWindow();
}
void InputMethodAbility::OnStopInput(Message *msg)
@@ -376,17 +376,17 @@ void InputMethodAbility::ShowInputWindow(bool isShowKeyboard, const SubProperty
channel->SendKeyboardStatus(KEYBOARD_SHOW);
}
-void InputMethodAbility::DissmissInputWindow()
+void InputMethodAbility::DismissInputWindow()
{
- IMSA_HILOGI("InputMethodAbility::DissmissInputWindow");
+ IMSA_HILOGI("InputMethodAbility::DismissInputWindow");
if (!imeListener_) {
- IMSA_HILOGI("InputMethodAbility::DissmissInputWindow imeListener_ is nullptr");
+ IMSA_HILOGI("InputMethodAbility::DismissInputWindow imeListener_ is nullptr");
return;
}
imeListener_->OnKeyboardStatus(false);
std::shared_ptr channel = GetInputDataChannel();
if (channel == nullptr) {
- IMSA_HILOGI("InputMethodAbility::DissmissInputWindow channel is nullptr");
+ IMSA_HILOGI("InputMethodAbility::DismissInputWindow channel is nullptr");
return;
}
channel->SendKeyboardStatus(KEYBOARD_HIDE);
@@ -518,12 +518,12 @@ void InputMethodAbility::SetInputDataChannel(sptr &object)
{
IMSA_HILOGI("run in SetInputDataChannel");
std::lock_guard lock(dataChannelLock_);
- std::shared_ptr channalProxy = std::make_shared(object);
- if (channalProxy == nullptr) {
+ std::shared_ptr channelProxy = std::make_shared(object);
+ if (channelProxy == nullptr) {
IMSA_HILOGI("InputMethodAbility::SetInputDataChannel inputDataChannel is nullptr");
return;
}
- dataChannel_ = channalProxy;
+ dataChannel_ = channelProxy;
}
std::shared_ptr InputMethodAbility::GetInputDataChannel()
@@ -536,12 +536,12 @@ void InputMethodAbility::SetInputControlChannel(sptr &object)
{
IMSA_HILOGI("run in SetInputControlChannel");
std::lock_guard lock(controlChannelLock_);
- std::shared_ptr channalProxy = std::make_shared(object);
- if (channalProxy == nullptr) {
+ std::shared_ptr channelProxy = std::make_shared(object);
+ if (channelProxy == nullptr) {
IMSA_HILOGI("InputMethodAbility::SetInputControlChannel inputDataChannel is nullptr");
return;
}
- controlChannel_ = channalProxy;
+ controlChannel_ = channelProxy;
}
std::shared_ptr InputMethodAbility::GetInputControlChannel()
@@ -574,5 +574,15 @@ void InputMethodAbility::BindServiceAndClient()
sptr inputMethodAgent = sptr(new InputMethodAgentProxy(inputMethodAgentStub));
mImms->SetCoreAndAgent(stub, inputMethodAgent);
}
+
+void InputMethodAbility::QuitWorkThread()
+{
+ stop_ = true;
+ Message *msg = new Message(MessageID::MSG_ID_QUIT_WORKER_THREAD, nullptr);
+ msgHandler->SendMessage(msg);
+ if (workThreadHandler.joinable()) {
+ workThreadHandler.join();
+ }
+}
} // namespace MiscServices
} // namespace OHOS
diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp
index 419d8a01..7aa253a1 100644
--- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp
+++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp
@@ -34,7 +34,7 @@ InputMethodCoreProxy::~InputMethodCoreProxy() = default;
int32_t InputMethodCoreProxy::initializeInput(
sptr &startInputToken, int32_t displayId, sptr &inputControlChannel)
{
- IMSA_HILOGI("InputMethodCoreProxy::initializeInput");
+ IMSA_HILOGD("InputMethodCoreProxy::initializeInput");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -75,7 +75,7 @@ int32_t InputMethodCoreProxy::initializeInput(
int32_t InputMethodCoreProxy::InitInputControlChannel(sptr &inputControlChannel)
{
- IMSA_HILOGI("InputMethodCoreProxy::InitInputControlChannel");
+ IMSA_HILOGD("InputMethodCoreProxy::InitInputControlChannel");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -105,7 +105,7 @@ int32_t InputMethodCoreProxy::InitInputControlChannel(sptr
void InputMethodCoreProxy::SetClientState(bool state)
{
- IMSA_HILOGI("InputMethodCoreProxy::SetClientState");
+ IMSA_HILOGD("InputMethodCoreProxy::SetClientState");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -127,7 +127,7 @@ void InputMethodCoreProxy::SetClientState(bool state)
bool InputMethodCoreProxy::startInput(
const sptr &inputDataChannel, const InputAttribute &editorAttribute, bool supportPhysicalKbd)
{
- IMSA_HILOGI("InputMethodCoreProxy::startInput");
+ IMSA_HILOGD("InputMethodCoreProxy::startInput");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -159,7 +159,7 @@ bool InputMethodCoreProxy::startInput(
int32_t InputMethodCoreProxy::stopInput()
{
- IMSA_HILOGI("InputMethodCoreProxy::stopInput");
+ IMSA_HILOGD("InputMethodCoreProxy::stopInput");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -184,7 +184,7 @@ int32_t InputMethodCoreProxy::stopInput()
int32_t InputMethodCoreProxy::showKeyboard(
const sptr &inputDataChannel, bool isShowKeyboard, const SubProperty &subProperty)
{
- IMSA_HILOGI("InputMethodCoreProxy::showKeyboard");
+ IMSA_HILOGD("InputMethodCoreProxy::showKeyboard");
return SendRequest(SHOW_KEYBOARD, [&inputDataChannel, &isShowKeyboard, &subProperty](MessageParcel &data) {
return ITypesUtil::Marshal(data, inputDataChannel->AsObject(), isShowKeyboard, subProperty);
});
@@ -192,7 +192,7 @@ int32_t InputMethodCoreProxy::showKeyboard(
void InputMethodCoreProxy::StopInputService(std::string imeId)
{
- IMSA_HILOGI("InputMethodCoreProxy::StopInputService");
+ IMSA_HILOGD("InputMethodCoreProxy::StopInputService");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("InputMethodCoreProxy::StopInputService remote is nullptr");
@@ -213,7 +213,7 @@ void InputMethodCoreProxy::StopInputService(std::string imeId)
bool InputMethodCoreProxy::hideKeyboard(int32_t flags)
{
- IMSA_HILOGI("InputMethodCoreProxy::hideKeyboard");
+ IMSA_HILOGD("InputMethodCoreProxy::hideKeyboard");
auto remote = Remote();
if (!remote) {
return false;
@@ -235,7 +235,7 @@ bool InputMethodCoreProxy::hideKeyboard(int32_t flags)
int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType &type)
{
- IMSA_HILOGI("InputMethodCoreProxy::setKeyboardType");
+ IMSA_HILOGD("InputMethodCoreProxy::setKeyboardType");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -255,7 +255,7 @@ int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType &type)
int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t &retHeight)
{
- IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight");
+ IMSA_HILOGD("InputMethodCoreProxy::getKeyboardWindowHeight");
auto remote = Remote();
if (!remote) {
IMSA_HILOGI("remote is nullptr");
@@ -278,13 +278,13 @@ int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t &retHeight)
int32_t InputMethodCoreProxy::SetSubtype(const SubProperty &property)
{
- IMSA_HILOGI("InputMethodCoreProxy::SetSubtype");
+ IMSA_HILOGD("InputMethodCoreProxy::SetSubtype");
return SendRequest(SET_SUBTYPE, [&property](MessageParcel &data) { return ITypesUtil::Marshal(data, property); });
}
int32_t InputMethodCoreProxy::SendRequest(int code, ParcelHandler input, ParcelHandler output)
{
- IMSA_HILOGI("InputMethodCoreProxy::%{public}s in", __func__);
+ IMSA_HILOGD("InputMethodCoreProxy::%{public}s in", __func__);
MessageParcel data;
MessageParcel reply;
MessageOption option{ MessageOption::TF_SYNC };
diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp
index 3a668ad8..49c58adc 100644
--- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp
+++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp
@@ -46,7 +46,7 @@ InputMethodCoreStub::~InputMethodCoreStub()
int32_t InputMethodCoreStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
- IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest");
+ IMSA_HILOGD("InputMethodCoreStub::OnRemoteRequest");
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest descriptorToken is invalid");
@@ -146,7 +146,7 @@ int32_t InputMethodCoreStub::OnRemoteRequest(
int32_t InputMethodCoreStub::initializeInput(
sptr &startInputToken, int32_t displayId, sptr &inputControlChannel)
{
- IMSA_HILOGI("InputMethodCoreStub::initializeInput");
+ IMSA_HILOGD("InputMethodCoreStub::initializeInput");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -168,7 +168,7 @@ int32_t InputMethodCoreStub::initializeInput(
int32_t InputMethodCoreStub::InitInputControlChannel(sptr &inputControlChannel)
{
- IMSA_HILOGI("InputMethodCoreStub::initializeInput");
+ IMSA_HILOGD("InputMethodCoreStub::initializeInput");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -186,7 +186,7 @@ int32_t InputMethodCoreStub::InitInputControlChannel(sptr
bool InputMethodCoreStub::startInput(
const sptr &inputDataChannel, const InputAttribute &editorAttribute, bool supportPhysicalKbd)
{
- IMSA_HILOGI("InputMethodCoreStub::startInput");
+ IMSA_HILOGD("InputMethodCoreStub::startInput");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -204,7 +204,7 @@ bool InputMethodCoreStub::startInput(
int32_t InputMethodCoreStub::stopInput()
{
- IMSA_HILOGI("InputMethodCoreStub::stopInput");
+ IMSA_HILOGD("InputMethodCoreStub::stopInput");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -216,7 +216,7 @@ int32_t InputMethodCoreStub::stopInput()
void InputMethodCoreStub::SetClientState(bool state)
{
- IMSA_HILOGI("InputMethodCoreStub::SetClientState");
+ IMSA_HILOGD("InputMethodCoreStub::SetClientState");
if (!msgHandler_) {
return;
}
@@ -229,7 +229,7 @@ void InputMethodCoreStub::SetClientState(bool state)
bool InputMethodCoreStub::hideKeyboard(int32_t flags)
{
- IMSA_HILOGI("InputMethodCoreStub::hideKeyboard");
+ IMSA_HILOGD("InputMethodCoreStub::hideKeyboard");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -244,7 +244,7 @@ bool InputMethodCoreStub::hideKeyboard(int32_t flags)
int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType &type)
{
- IMSA_HILOGI("InputMethodCoreStub::setKeyboardType");
+ IMSA_HILOGD("InputMethodCoreStub::setKeyboardType");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -258,7 +258,7 @@ int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType &type)
void InputMethodCoreStub::StopInputService(std::string imeId)
{
- IMSA_HILOGI("InputMethodCoreStub::StopInputService");
+ IMSA_HILOGD("InputMethodCoreStub::StopInputService");
if (!msgHandler_) {
return;
}
@@ -271,7 +271,7 @@ void InputMethodCoreStub::StopInputService(std::string imeId)
int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t &retHeight)
{
- IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight");
+ IMSA_HILOGD("InputMethodCoreStub::getKeyboardWindowHeight");
if (!msgHandler_) {
return ErrorCode::ERROR_NULL_POINTER;
}
@@ -289,7 +289,7 @@ void InputMethodCoreStub::SetMessageHandler(MessageHandler *msgHandler)
void InputMethodCoreStub::ShowKeyboardOnRemote(MessageParcel &data, MessageParcel &reply)
{
- IMSA_HILOGI("InputMethodCoreStub::ShowKeyboardOnRemote");
+ IMSA_HILOGD("InputMethodCoreStub::ShowKeyboardOnRemote");
sptr channel;
bool isShowKeyboard = false;
SubProperty subProperty;
@@ -303,7 +303,7 @@ void InputMethodCoreStub::ShowKeyboardOnRemote(MessageParcel &data, MessageParce
void InputMethodCoreStub::SetSubtypeOnRemote(MessageParcel &data, MessageParcel &reply)
{
- IMSA_HILOGI("InputMethodCoreStub::SetSubtypeOnRemote");
+ IMSA_HILOGD("InputMethodCoreStub::SetSubtypeOnRemote");
SubProperty property;
int32_t ret = SendMessage(MessageID::MSG_ID_SET_SUBTYPE, [&data, &property](MessageParcel &parcel) {
return ITypesUtil::Unmarshal(data, property) && ITypesUtil::Marshal(parcel, property);
@@ -324,7 +324,7 @@ int32_t InputMethodCoreStub::SetSubtype(const SubProperty &property)
int32_t InputMethodCoreStub::SendMessage(int code, ParcelHandler input)
{
- IMSA_HILOGI("InputMethodCoreStub::SendMessage");
+ IMSA_HILOGD("InputMethodCoreStub::SendMessage");
if (msgHandler_ == nullptr) {
IMSA_HILOGE("InputMethodCoreStub::msgHandler_ is nullptr");
return ErrorCode::ERROR_EX_NULL_POINTER;
diff --git a/frameworks/inputmethod_controller/include/input_method_controller.h b/frameworks/inputmethod_controller/include/input_method_controller.h
index ee6200a7..33acdc48 100644
--- a/frameworks/inputmethod_controller/include/input_method_controller.h
+++ b/frameworks/inputmethod_controller/include/input_method_controller.h
@@ -105,6 +105,7 @@ private:
void OnSwitchInput(const Property &property, const SubProperty &subProperty);
std::shared_ptr GetInputMethodAgent();
void WorkThread();
+ void QuitWorkThread();
int32_t ListInputMethodCommon(InputMethodStatus status, std::vector &props);
sptr mInputDataChannel;
@@ -115,6 +116,7 @@ private:
sptr deathRecipient_;
std::mutex agentLock_;
std::shared_ptr mAgent = nullptr;
+ std::mutex textListenerLock_;
sptr textListener;
InputAttribute mAttribute;
std::u16string mTextString;
diff --git a/frameworks/inputmethod_controller/include/input_method_setting_listener.h b/frameworks/inputmethod_controller/include/input_method_setting_listener.h
index 308d5a11..1203fca7 100644
--- a/frameworks/inputmethod_controller/include/input_method_setting_listener.h
+++ b/frameworks/inputmethod_controller/include/input_method_setting_listener.h
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#ifndef INPUTMETHOD_IMF_INPUT_METHOD_ENGINE_LISTENER_H
-#define INPUTMETHOD_IMF_INPUT_METHOD_ENGINE_LISTENER_H
+#ifndef INPUTMETHOD_IMF_INPUT_METHOD_SETTING_LISTENER_H
+#define INPUTMETHOD_IMF_INPUT_METHOD_SETTING_LISTENER_H
#include "input_method_property.h"
@@ -28,4 +28,4 @@ public:
} // namespace MiscServices
} // namespace OHOS
-#endif // INPUTMETHOD_IMF_INPUT_METHOD_ENGINE_LISTENER_H
+#endif // INPUTMETHOD_IMF_INPUT_METHOD_SETTING_LISTENER_H
diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp
index 57f216a9..9f41c9c1 100644
--- a/frameworks/inputmethod_controller/src/input_method_controller.cpp
+++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp
@@ -43,14 +43,9 @@ using namespace MessageID;
InputMethodController::~InputMethodController()
{
- if (msgHandler) {
- delete msgHandler;
- msgHandler = nullptr;
- stop_ = false;
- }
- if (workThreadHandler.joinable()) {
- workThreadHandler.join();
- }
+ QuitWorkThread();
+ delete msgHandler;
+ msgHandler = nullptr;
}
sptr InputMethodController::GetInstance()
@@ -93,10 +88,12 @@ using namespace MessageID;
channel->SetHandler(msgHandler);
mInputDataChannel = channel;
- workThreadHandler = std::thread([this] {WorkThread();});
- mAttribute.inputPattern = InputAttribute::PATTERN_TEXT;
-
- textListener = nullptr;
+ workThreadHandler = std::thread([this] { WorkThread(); });
+ mAttribute.inputPattern = InputAttribute::PATTERN_TEXT;
+ {
+ std::lock_guard lock(textListenerLock_);
+ textListener = nullptr;
+ }
IMSA_HILOGI("InputMethodController::Initialize textListener is nullptr");
PrepareInput(0, mClient, mInputDataChannel, mAttribute);
return true;
@@ -139,6 +136,7 @@ using namespace MessageID;
{
while (!stop_) {
Message *msg = msgHandler->GetMessage();
+ std::lock_guard lock(textListenerLock_);
switch (msg->msgId_) {
case MSG_ID_INSERT_CHAR: {
MessageParcel *data = msg->msgContent_;
@@ -232,8 +230,10 @@ using namespace MessageID;
break;
}
OnSwitchInput(property, subProperty);
+ break;
}
default: {
+ IMSA_HILOGD("the message is %{public}d.", msg->msgId_);
break;
}
}
@@ -242,6 +242,16 @@ using namespace MessageID;
}
}
+ void InputMethodController::QuitWorkThread()
+ {
+ stop_ = true;
+ Message *msg = new Message(MessageID::MSG_ID_QUIT_WORKER_THREAD, nullptr);
+ msgHandler->SendMessage(msg);
+ if (workThreadHandler.joinable()) {
+ workThreadHandler.join();
+ }
+ }
+
void InputMethodController::OnSwitchInput(const Property &property, const SubProperty &subProperty)
{
IMSA_HILOGE("InputMethodController::OnSwitchInput");
@@ -259,6 +269,7 @@ using namespace MessageID;
void InputMethodController::Attach(sptr &listener, bool isShowKeyboard)
{
+ std::lock_guard lock(textListenerLock_);
textListener = listener;
IMSA_HILOGI("InputMethodController::Attach");
InputmethodTrace tracer("InputMethodController Attach trace.");
@@ -275,13 +286,13 @@ using namespace MessageID;
void InputMethodController::HideTextInput()
{
- IMSA_HILOGI("InputMethodController::HideTextInput");
+ IMSA_HILOGD("InputMethodController::HideTextInput");
StopInput(mClient);
}
int32_t InputMethodController::HideCurrentInput()
{
- IMSA_HILOGI("InputMethodController::HideCurrentInput");
+ IMSA_HILOGD("InputMethodController::HideCurrentInput");
auto proxy = GetSystemAbilityProxy();
if (proxy == nullptr) {
IMSA_HILOGE("proxy is nullptr");
@@ -305,8 +316,11 @@ using namespace MessageID;
{
ReleaseInput(mClient);
InputmethodTrace tracer("InputMethodController Close trace.");
- textListener = nullptr;
- IMSA_HILOGI("InputMethodController::Close");
+ {
+ std::lock_guard lock(textListenerLock_);
+ textListener = nullptr;
+ }
+ IMSA_HILOGD("InputMethodController::Close");
}
void InputMethodController::PrepareInput(int32_t displayId, sptr &client,
@@ -357,7 +371,7 @@ using namespace MessageID;
std::shared_ptr InputMethodController::GetCurrentInputMethod()
{
- IMSA_HILOGI("InputMethodController::GetCurrentInputMethod");
+ IMSA_HILOGD("InputMethodController::GetCurrentInputMethod");
auto proxy = GetSystemAbilityProxy();
if (proxy == nullptr) {
IMSA_HILOGE("proxy is nullptr");
@@ -373,7 +387,7 @@ using namespace MessageID;
std::shared_ptr InputMethodController::GetCurrentInputMethodSubtype()
{
- IMSA_HILOGI("InputMethodController::GetCurrentInputMethod");
+ IMSA_HILOGD("InputMethodController::GetCurrentInputMethod");
auto proxy = GetSystemAbilityProxy();
if (proxy == nullptr) {
IMSA_HILOGE("proxy is nullptr");
@@ -401,7 +415,7 @@ using namespace MessageID;
void InputMethodController::ReleaseInput(sptr &client)
{
- IMSA_HILOGI("InputMethodController::ReleaseInput");
+ IMSA_HILOGD("InputMethodController::ReleaseInput");
isStopInput = true;
auto proxy = GetSystemAbilityProxy();
if (proxy == nullptr) {
@@ -413,7 +427,7 @@ using namespace MessageID;
void InputMethodController::StopInput(sptr &client)
{
- IMSA_HILOGI("InputMethodController::StopInput");
+ IMSA_HILOGD("InputMethodController::StopInput");
isStopInput = true;
auto proxy = GetSystemAbilityProxy();
if (proxy == nullptr) {
@@ -502,7 +516,7 @@ using namespace MessageID;
int32_t InputMethodController::GetTextAfterCursor(int32_t number, std::u16string &text)
{
- IMSA_HILOGI("InputMethodController::GetTextBeforeCursor");
+ IMSA_HILOGI("InputMethodController::GetTextAfterCursor");
if (!mTextString.empty() && mTextString.size() <= INT_MAX) {
int32_t endPos = (mSelectNewEnd + number < static_cast(mTextString.size()))
? (mSelectNewEnd + number)
diff --git a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp
index 18c03325..58189c19 100644
--- a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp
+++ b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp
@@ -39,7 +39,7 @@ int32_t InputMethodSystemAbilityProxy::PrepareInput(int32_t displayId, sptr client, bool isShowKeyboard)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(START_INPUT, [isShowKeyboard, client](MessageParcel &data) {
return data.WriteRemoteObject(client->AsObject()) && data.WriteBool(isShowKeyboard);
});
@@ -47,25 +47,25 @@ int32_t InputMethodSystemAbilityProxy::StartInput(sptr client, boo
int32_t InputMethodSystemAbilityProxy::ShowCurrentInput()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(SHOW_CURRENT_INPUT);
}
int32_t InputMethodSystemAbilityProxy::HideCurrentInput()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(HIDE_CURRENT_INPUT);
}
int32_t InputMethodSystemAbilityProxy::StopInputSession()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(STOP_INPUT_SESSION);
}
int32_t InputMethodSystemAbilityProxy::StopInput(sptr client)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(STOP_INPUT,
[client](MessageParcel &data) { return data.WriteRemoteObject(client->AsObject()); });
}
@@ -84,7 +84,7 @@ int32_t InputMethodSystemAbilityProxy::DisplayOptionalInputMethod()
int32_t InputMethodSystemAbilityProxy::SetCoreAndAgent(sptr core, sptr agent)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(SET_CORE_AND_AGENT, [core, agent](MessageParcel &data) {
return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent->AsObject());
});
@@ -92,14 +92,14 @@ int32_t InputMethodSystemAbilityProxy::SetCoreAndAgent(sptr co
int32_t InputMethodSystemAbilityProxy::GetKeyboardWindowHeight(int32_t &retHeight)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, nullptr,
[&retHeight](MessageParcel &reply) { return reply.ReadInt32(retHeight); });
}
std::shared_ptr InputMethodSystemAbilityProxy::GetCurrentInputMethod()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
std::shared_ptr property = nullptr;
int32_t ret = SendRequest(GET_CURRENT_INPUT_METHOD, nullptr, [&property](MessageParcel &reply) {
property = std::make_shared();
@@ -118,7 +118,7 @@ std::shared_ptr InputMethodSystemAbilityProxy::GetCurrentInputMethod()
std::shared_ptr InputMethodSystemAbilityProxy::GetCurrentInputMethodSubtype()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
std::shared_ptr property = nullptr;
int32_t ret = SendRequest(GET_CURRENT_INPUT_METHOD_SUBTYPE, nullptr, [&property](MessageParcel &reply) {
property = std::make_shared();
@@ -137,7 +137,7 @@ std::shared_ptr InputMethodSystemAbilityProxy::GetCurrentInputMetho
int32_t InputMethodSystemAbilityProxy::ListInputMethod(InputMethodStatus status, std::vector &props)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
int32_t ret = SendRequest(
LIST_INPUT_METHOD, [status](MessageParcel &data) { return ITypesUtil::Marshal(data, uint32_t(status)); },
[&props](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, props); });
@@ -149,26 +149,26 @@ int32_t InputMethodSystemAbilityProxy::ListInputMethod(InputMethodStatus status,
int32_t InputMethodSystemAbilityProxy::ShowCurrentInputDeprecated()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(SHOW_CURRENT_INPUT_DEPRECATED);
}
int32_t InputMethodSystemAbilityProxy::HideCurrentInputDeprecated()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(HIDE_CURRENT_INPUT_DEPRECATED);
}
int32_t InputMethodSystemAbilityProxy::DisplayOptionalInputMethodDeprecated()
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(DISPLAY_OPTIONAL_INPUT_DEPRECATED);
}
int32_t InputMethodSystemAbilityProxy::SetCoreAndAgentDeprecated(sptr core,
sptr agent)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
return SendRequest(SET_CORE_AND_AGENT_DEPRECATED, [core, agent](MessageParcel &data) {
return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent->AsObject());
});
@@ -177,7 +177,7 @@ int32_t InputMethodSystemAbilityProxy::SetCoreAndAgentDeprecated(sptr &subProps)
{
- IMSA_HILOGI("InputMethodSystemAbilityProxy::ListInputMethodSubtype");
+ IMSA_HILOGD("InputMethodSystemAbilityProxy::ListInputMethodSubtype");
int32_t ret = SendRequest(
LIST_INPUT_METHOD_SUBTYPE, [&name](MessageParcel &data) { return ITypesUtil::Marshal(data, name); },
[&subProps](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, subProps); });
@@ -189,7 +189,7 @@ int32_t InputMethodSystemAbilityProxy::ListInputMethodSubtype(
int32_t InputMethodSystemAbilityProxy::ListCurrentInputMethodSubtype(std::vector &subProps)
{
- IMSA_HILOGI("InputMethodSystemAbilityProxy::ListCurrentInputMethodSubtype");
+ IMSA_HILOGD("InputMethodSystemAbilityProxy::ListCurrentInputMethodSubtype");
int32_t ret = SendRequest(LIST_CURRENT_INPUT_METHOD_SUBTYPE, nullptr,
[&subProps](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, subProps); });
if (ret != ErrorCode::NO_ERROR) {
@@ -200,14 +200,14 @@ int32_t InputMethodSystemAbilityProxy::ListCurrentInputMethodSubtype(std::vector
int32_t InputMethodSystemAbilityProxy::SwitchInputMethod(const std::string &name, const std::string &subName)
{
- IMSA_HILOGI("InputMethodSystemAbilityProxy::SwitchInputMethod");
+ IMSA_HILOGD("InputMethodSystemAbilityProxy::SwitchInputMethod");
return SendRequest(SWITCH_INPUT_METHOD,
[&name, &subName](MessageParcel &data) { return ITypesUtil::Marshal(data, name, subName); });
}
int32_t InputMethodSystemAbilityProxy::SendRequest(int code, ParcelHandler input, ParcelHandler output)
{
- IMSA_HILOGI("%{public}s in", __func__);
+ IMSA_HILOGD("%{public}s in", __func__);
MessageParcel data;
MessageParcel reply;
MessageOption option{ MessageOption::TF_SYNC };
diff --git a/frameworks/kits/extension/include/js_inputmethod_extension_context.h b/frameworks/kits/extension/include/js_inputmethod_extension_context.h
index be74c6da..eea4d3f5 100644
--- a/frameworks/kits/extension/include/js_inputmethod_extension_context.h
+++ b/frameworks/kits/extension/include/js_inputmethod_extension_context.h
@@ -47,19 +47,19 @@ private:
std::unique_ptr jsConnectionObject_ = nullptr;
};
-struct ConnecttionKey {
+struct ConnectionKey {
AAFwk::Want want;
int64_t id;
};
struct key_compare {
- bool operator()(const ConnecttionKey &key1, const ConnecttionKey &key2) const
+ bool operator()(const ConnectionKey &key1, const ConnectionKey &key2) const
{
return key1.id < key2.id;
}
};
-static std::map, key_compare> connects_;
+static std::map, key_compare> connects_;
static int64_t serialNumber_ = 0;
static std::shared_ptr handler_ = nullptr;
} // namespace AbilityRuntime
diff --git a/frameworks/kits/extension/src/js_inputmethod_extension_context.cpp b/frameworks/kits/extension/src/js_inputmethod_extension_context.cpp
index 717fccf2..57e09e24 100644
--- a/frameworks/kits/extension/src/js_inputmethod_extension_context.cpp
+++ b/frameworks/kits/extension/src/js_inputmethod_extension_context.cpp
@@ -260,7 +260,7 @@ private:
sptr connection = new JSInputMethodExtensionConnection(engine);
connection->SetJsConnectionObject(info.argv[1]);
int64_t connectId = serialNumber_;
- ConnecttionKey key;
+ ConnectionKey key;
key.id = serialNumber_;
key.want = want;
connects_.emplace(key, connection);
@@ -316,7 +316,7 @@ private:
sptr connection = new JSInputMethodExtensionConnection(engine);
connection->SetJsConnectionObject(info.argv[1]);
int64_t connectId = serialNumber_;
- ConnecttionKey key;
+ ConnectionKey key;
key.id = serialNumber_;
key.want = want;
connects_.emplace(key, connection);
@@ -363,7 +363,7 @@ private:
reinterpret_cast(&engine), reinterpret_cast(info.argv[INDEX_ZERO]), &connectId);
IMSA_HILOGI("OnDisconnectAbility connection:%{public}d", static_cast(connectId));
auto item = std::find_if(connects_.begin(), connects_.end(),
- [&connectId](const std::map>::value_type &obj) {
return connectId == obj.first.id;
});
@@ -596,7 +596,7 @@ void JSInputMethodExtensionConnection::HandleOnAbilityDisconnectDone(
std::string abilityName = element.GetAbilityName();
auto item = std::find_if(connects_.begin(), connects_.end(),
[bundleName, abilityName](
- const std::map>::value_type &obj) {
+ const std::map>::value_type &obj) {
return (bundleName == obj.first.want.GetBundle())
&& (abilityName == obj.first.want.GetElement().GetAbilityName());
});
diff --git a/interfaces/kits/js/napi/inputmethod_extension_ability/inputmethod_extension_ability_module.cpp b/interfaces/kits/js/napi/inputmethod_extension_ability/inputmethod_extension_ability_module.cpp
index 4234dc2a..f06ee45a 100644
--- a/interfaces/kits/js/napi/inputmethod_extension_ability/inputmethod_extension_ability_module.cpp
+++ b/interfaces/kits/js/napi/inputmethod_extension_ability/inputmethod_extension_ability_module.cpp
@@ -41,7 +41,7 @@ extern "C" __attribute__((visibility("default"))) void NAPI_inputmethodextension
}
}
-// inputmethod_extension_abiltiy JS register
+// inputmethod_extension_ability JS register
extern "C" __attribute__((visibility("default"))) void NAPI_inputmethodextensionability_GetABCCode(
const char **buf, int *buflen)
{
diff --git a/interfaces/kits/js/napi/inputmethod_extension_context/inputmethod_extension_context.js b/interfaces/kits/js/napi/inputmethod_extension_context/inputmethod_extension_context.js
index 1b27a1b7..e50ea058 100644
--- a/interfaces/kits/js/napi/inputmethod_extension_context/inputmethod_extension_context.js
+++ b/interfaces/kits/js/napi/inputmethod_extension_context/inputmethod_extension_context.js
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-var ExtensionContext = requireNapi("application.ExtensionContext")
+const ExtensionContext = requireNapi("application.ExtensionContext");
class InputMethodExtensionContext extends ExtensionContext {
constructor(obj) {
diff --git a/interfaces/kits/js/napi/inputmethodability/js_callback_object.h b/interfaces/kits/js/napi/inputmethodability/js_callback_object.h
index 197ff0f8..60f7309e 100644
--- a/interfaces/kits/js/napi/inputmethodability/js_callback_object.h
+++ b/interfaces/kits/js/napi/inputmethodability/js_callback_object.h
@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef CALLBAKC_OBJECT_H
-#define CALLBAKC_OBJECT_H
+#ifndef JS_CALLBACK_OBJECT_H
+#define JS_CALLBACK_OBJECT_H
#include
@@ -32,4 +32,4 @@ public:
};
} // namespace MiscServices
} // namespace OHOS
-#endif // CALLBAKC_OBJECT_H
\ No newline at end of file
+#endif // JS_CALLBACK_OBJECT_H
diff --git a/interfaces/kits/js/napi/inputmethodability/js_input_method_engine_setting.cpp b/interfaces/kits/js/napi/inputmethodability/js_input_method_engine_setting.cpp
index 3d7de195..9338920e 100644
--- a/interfaces/kits/js/napi/inputmethodability/js_input_method_engine_setting.cpp
+++ b/interfaces/kits/js/napi/inputmethodability/js_input_method_engine_setting.cpp
@@ -226,7 +226,7 @@ void JsInputMethodEngineSetting::RegisterListener(napi_value callback, std::stri
IMSA_HILOGI("RegisterListener %{public}s", type.c_str());
std::lock_guard lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
- IMSA_HILOGE("methodName: %{public}s not registertd!", type.c_str());
+ IMSA_HILOGE("methodName: %{public}s not registered!", type.c_str());
}
for (auto &item : jsCbMap_[type]) {
@@ -245,7 +245,7 @@ void JsInputMethodEngineSetting::UnRegisterListener(napi_value callback, std::st
IMSA_HILOGI("UnRegisterListener %{public}s", type.c_str());
std::lock_guard lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
- IMSA_HILOGE("methodName: %{public}s already unRegisterted!", type.c_str());
+ IMSA_HILOGE("methodName: %{public}s already unRegistered!", type.c_str());
return;
}
@@ -255,7 +255,7 @@ void JsInputMethodEngineSetting::UnRegisterListener(napi_value callback, std::st
return;
}
- for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end();) {
+ for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end(); item++) {
if (Equals((*item)->env_, callback, (*item)->callback_, (*item)->threadId_)) {
jsCbMap_[type].erase(item);
break;
@@ -734,7 +734,7 @@ void JsInputMethodEngineSetting::OnSetSubtype(const SubProperty &property)
for (auto item : entry->vecCopy) {
napi_value jsObject = GetResultOnSetSubtype(item->env_, entry->subProperty);
if (jsObject == nullptr) {
- IMSA_HILOGE("get GetResultOnSetSubtype failed: %{punlic}p", jsObject);
+ IMSA_HILOGE("get GetResultOnSetSubtype failed: jsObject is nullptr");
continue;
}
napi_value callback = nullptr;
diff --git a/interfaces/kits/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp b/interfaces/kits/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp
index c592ef3b..30d9ecb9 100644
--- a/interfaces/kits/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp
+++ b/interfaces/kits/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp
@@ -195,7 +195,7 @@ void JsKeyboardDelegateSetting::UnRegisterListener(napi_value callback, std::str
IMSA_HILOGI("UnRegisterListener %{public}s", type.c_str());
std::lock_guard lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
- IMSA_HILOGE("methodName %{public}s not unRegisterted!", type.c_str());
+ IMSA_HILOGE("methodName %{public}s not unRegistered!", type.c_str());
return;
}
@@ -205,7 +205,7 @@ void JsKeyboardDelegateSetting::UnRegisterListener(napi_value callback, std::str
return;
}
- for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end();) {
+ for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end(); item++) {
if ((callback != nullptr) && (Equals((*item)->env_, callback, (*item)->callback_, (*item)->threadId_))) {
jsCbMap_[type].erase(item);
break;
@@ -375,7 +375,7 @@ bool JsKeyboardDelegateSetting::OnKeyEvent(int32_t keyCode, int32_t keyStatus)
napi_value jsObject =
GetResultOnKeyEvent(item->env_, entry->keyEventPara.keyCode, entry->keyEventPara.keyStatus);
if (jsObject == nullptr) {
- IMSA_HILOGE("get GetResultOnKeyEvent failed: %{punlic}p", jsObject);
+ IMSA_HILOGE("get GetResultOnKeyEvent failed: jsObject is nullptr");
continue;
}
napi_value callback = nullptr;
@@ -643,4 +643,4 @@ void JsKeyboardDelegateSetting::OnTextChange(std::string text)
});
}
} // namespace MiscServices
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.cpp b/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.cpp
index d1b4366b..1bfd5139 100644
--- a/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.cpp
+++ b/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.cpp
@@ -76,7 +76,7 @@ napi_value JsTextInputClientEngine::MoveCursor(napi_env env, napi_callback_info
}
};
ctxt->SetAction(std::move(input));
- AsyncCall asyncCall(env, info, std::dynamic_pointer_cast(ctxt), 0);
+ AsyncCall asyncCall(env, info, std::dynamic_pointer_cast(ctxt));
return asyncCall.Call(env, exec);
}
diff --git a/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.h b/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.h
index 403d4cd0..2493b5cb 100644
--- a/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.h
+++ b/interfaces/kits/js/napi/inputmethodability/js_text_input_client_engine.h
@@ -45,7 +45,7 @@ struct SendKeyFunctionContext : public AsyncCall::Context {
};
struct MoveCursorContext : public AsyncCall::Context {
- bool num = false;
+ int32_t num = 0;
napi_status status = napi_generic_failure;
MoveCursorContext() : Context(nullptr, nullptr){};
MoveCursorContext(InputAction input, OutputAction output) : Context(std::move(input), std::move(output)){};
diff --git a/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_controller.h b/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_controller.h
index f916d9fc..1b9e9c5a 100644
--- a/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_controller.h
+++ b/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_controller.h
@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef INTERFACE_KITS_JS_GETINPUT_METHOD_CCONTROLLER_H
-#define INTERFACE_KITS_JS_GETINPUT_METHOD_CCONTROLLER_H
+#ifndef INTERFACE_KITS_JS_GET_INPUT_METHOD_CONTROLLER_H
+#define INTERFACE_KITS_JS_GET_INPUT_METHOD_CONTROLLER_H
#include "async_call.h"
#include "global.h"
@@ -63,4 +63,4 @@ private:
};
} // namespace MiscServices
} // namespace OHOS
-#endif // INTERFACE_KITS_JS_GETINPUT_METHOD_CCONTROLLER_H
+#endif // INTERFACE_KITS_JS_GET_INPUT_METHOD_CONTROLLER_H
diff --git a/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_setting.cpp b/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_setting.cpp
index e78c6902..33fce24e 100644
--- a/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_setting.cpp
+++ b/interfaces/kits/js/napi/inputmethodclient/js_get_input_method_setting.cpp
@@ -427,7 +427,7 @@ void JsGetInputMethodSetting::RegisterListener(
IMSA_HILOGI("RegisterListener %{public}s", type.c_str());
std::lock_guard lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
- IMSA_HILOGE("methodName: %{public}s not registertd!", type.c_str());
+ IMSA_HILOGE("methodName: %{public}s not registered!", type.c_str());
}
for (auto &item : jsCbMap_[type]) {
@@ -478,7 +478,7 @@ void JsGetInputMethodSetting::UnRegisterListener(napi_value callback, std::strin
IMSA_HILOGI("UnRegisterListener %{public}s", type.c_str());
std::lock_guard lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
- IMSA_HILOGE("methodName: %{public}s already unRegisterted!", type.c_str());
+ IMSA_HILOGE("methodName: %{public}s already unRegistered!", type.c_str());
return;
}
@@ -488,7 +488,7 @@ void JsGetInputMethodSetting::UnRegisterListener(napi_value callback, std::strin
return;
}
- for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end();) {
+ for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end(); item++) {
if (Equals((*item)->env_, callback, (*item)->callback_, (*item)->threadId_)) {
jsCbMap_[type].erase(item);
break;
diff --git a/interfaces/kits/js/napi/inputmethodclient/js_utils.cpp b/interfaces/kits/js/napi/inputmethodclient/js_utils.cpp
index 2a3b644e..afee9e40 100644
--- a/interfaces/kits/js/napi/inputmethodclient/js_utils.cpp
+++ b/interfaces/kits/js/napi/inputmethodclient/js_utils.cpp
@@ -20,9 +20,7 @@ namespace MiscServices {
const std::map JsUtils::ERROR_CODE_MAP = {
{ ErrorCode::ERROR_STATUS_PERMISSION_DENIED, EXCEPTION_PERMISSION },
{ ErrorCode::ERROR_REMOTE_IME_DIED, EXCEPTION_IMENGINE },
- { ErrorCode::ERROR_RESTART_IME_FAILED, EXCEPTION_IMENGINE },
{ ErrorCode::ERROR_REMOTE_CLIENT_DIED, EXCEPTION_IMCLIENT },
- { ErrorCode::ERROR_CLIENT_DUPLICATED, EXCEPTION_IMCLIENT },
{ ErrorCode::ERROR_CLIENT_NOT_FOUND, EXCEPTION_IMCLIENT },
{ ErrorCode::ERROR_CLIENT_NULL_POINTER, EXCEPTION_IMCLIENT },
{ ErrorCode::ERROR_NOT_IME_PACKAGE, EXCEPTION_SETTINGS },
@@ -42,19 +40,11 @@ const std::map JsUtils::ERROR_CODE_MAP = {
{ ErrorCode::ERROR_IME_BIND_FAILED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_IME_UNBIND_FAILED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_IME_START_FAILED, EXCEPTION_IMMS },
- { ErrorCode::ERROR_IME_STOP_FAILED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_KBD_SHOW_FAILED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_KBD_HIDE_FAILED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_IME_NOT_STARTED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_KBD_IS_OCCUPIED, EXCEPTION_IMMS },
{ ErrorCode::ERROR_KBD_IS_NOT_SHOWING, EXCEPTION_IMMS },
- { ErrorCode::ERROR_IME_ALREADY_STARTED, EXCEPTION_IMMS },
- { ErrorCode::ERROR_NO_NEXT_IME, EXCEPTION_IMMS },
- { ErrorCode::ERROR_CLIENTWINDOW_NOT_FOCUSED, EXCEPTION_IMMS },
- { ErrorCode::ERROR_CLIENT_NOT_WINDOW, EXCEPTION_IMMS },
- { ErrorCode::ERROR_IME_PROPERTY_MARSHALL, EXCEPTION_IMMS },
- { ErrorCode::ERROR_GETTING_CURRENT_IME, EXCEPTION_IMMS },
- { ErrorCode::ERROR_LIST_IME, EXCEPTION_IMMS },
{ ErrorCode::ERROR_EX_NULL_POINTER, EXCEPTION_IMMS },
{ ErrorCode::ERROR_PERSIST_CONFIG, EXCEPTION_CONFPERSIST },
{ ErrorCode::ERROR_PACKAGE_MANAGER, EXCEPTION_PACKAGEMANAGER },
@@ -83,86 +73,85 @@ const std::map JsUtils::ERROR_CODE_MAP = {
};
const std::map JsUtils::ERROR_CODE_CONVERT_MESSAGE_MAP = {
- { EXCEPTION_PERMISSION, "the permissions check fails." },
- { EXCEPTION_PARAMCHECK, "the parameters check fails." },
- { EXCEPTION_UNSUPPORTED, "call unsupported api." },
- { EXCEPTION_PACKAGEMANAGER, "package manager error." },
- { EXCEPTION_IMENGINE, "input method engine error." },
- { EXCEPTION_IMCLIENT, "input method client error." },
- { EXCEPTION_KEYEVENT, "key event processing error." },
- { EXCEPTION_CONFPERSIST, "configuration persisting error." },
- { EXCEPTION_CONTROLLER, "input method controller error." },
- { EXCEPTION_SETTINGS, "input method settings extension error." },
- { EXCEPTION_IMMS, "input method manager service error." },
- { EXCEPTION_OTHERS, "others error." },
- };
+ { EXCEPTION_PERMISSION, "the permissions check fails." },
+ { EXCEPTION_PARAMCHECK, "the parameters check fails." },
+ { EXCEPTION_UNSUPPORTED, "call unsupported api." },
+ { EXCEPTION_PACKAGEMANAGER, "package manager error." },
+ { EXCEPTION_IMENGINE, "input method engine error." },
+ { EXCEPTION_IMCLIENT, "input method client error." },
+ { EXCEPTION_KEYEVENT, "key event processing error." },
+ { EXCEPTION_CONFPERSIST, "configuration persisting error." },
+ { EXCEPTION_CONTROLLER, "input method controller error." },
+ { EXCEPTION_SETTINGS, "input method settings extension error." },
+ { EXCEPTION_IMMS, "input method manager service error." },
+ { EXCEPTION_OTHERS, "others error." },
+};
- const std::map JsUtils::PARAMETER_TYPE = {
- { TYPE_UNDEFINED, "napi_undefine." },
- { TYPE_NULL, "napi_null." },
- { TYPE_BOOLEAN, "napi_boolean." },
- { TYPE_NUMBER, "napi_number." },
- { TYPE_STRING, "napi_string." },
- { TYPE_SYMBOL, "napi_symbol." },
- { TYPE_OBJECT, "napi_object." },
- { TYPE_FUNCTION, "napi_function." },
- { TYPE_EXTERNAL, "napi_external." },
- { TYPE_BIGINT, "napi_bigint." },
- };
+const std::map JsUtils::PARAMETER_TYPE = {
+ { TYPE_UNDEFINED, "napi_undefine." },
+ { TYPE_NULL, "napi_null." },
+ { TYPE_BOOLEAN, "napi_boolean." },
+ { TYPE_NUMBER, "napi_number." },
+ { TYPE_STRING, "napi_string." },
+ { TYPE_SYMBOL, "napi_symbol." },
+ { TYPE_OBJECT, "napi_object." },
+ { TYPE_FUNCTION, "napi_function." },
+ { TYPE_EXTERNAL, "napi_external." },
+ { TYPE_BIGINT, "napi_bigint." },
+};
- void JsUtils::ThrowException(napi_env env, int32_t err, const std::string &msg, TypeCode type)
- {
- std::string errMsg = ToMessage(err);
- if (type == TypeCode::TYPE_NONE) {
- errMsg = errMsg + msg;
- IMSA_HILOGE("THROW_PARAMTER_ERROR message: %{public}s", errMsg.c_str());
- } else {
- auto iter = PARAMETER_TYPE.find(type);
- if (iter != PARAMETER_TYPE.end()) {
- errMsg = errMsg + "The type of " + msg + " must be " + iter->second;
- IMSA_HILOGE("THROW_PARAMTER_TYPE_ERROR message: %{public}s", errMsg.c_str());
- }
+void JsUtils::ThrowException(napi_env env, int32_t err, const std::string &msg, TypeCode type)
+{
+ std::string errMsg = ToMessage(err);
+ if (type == TypeCode::TYPE_NONE) {
+ errMsg = errMsg + msg;
+ IMSA_HILOGE("THROW_PARAMETER_ERROR message: %{public}s", errMsg.c_str());
+ } else {
+ auto iter = PARAMETER_TYPE.find(type);
+ if (iter != PARAMETER_TYPE.end()) {
+ errMsg = errMsg + "The type of " + msg + " must be " + iter->second;
+ IMSA_HILOGE("THROW_PARAMETER_TYPE_ERROR message: %{public}s", errMsg.c_str());
}
- napi_throw_error(env, std::to_string(err).c_str(), errMsg.c_str());
- }
-
- napi_value JsUtils::ToError(napi_env env, int32_t code)
- {
- IMSA_HILOGE("ToError start");
- napi_value errorObj;
- NAPI_CALL(env, napi_create_object(env, &errorObj));
- napi_value errorCode = nullptr;
- NAPI_CALL(
- env, napi_create_string_utf8(env, std::to_string(Convert(code)).c_str(), NAPI_AUTO_LENGTH, &errorCode));
- napi_value errorMessage = nullptr;
- NAPI_CALL(env, napi_create_string_utf8(env, ToMessage(Convert(code)).c_str(), NAPI_AUTO_LENGTH, &errorMessage));
- NAPI_CALL(env, napi_set_named_property(env, errorObj, "code", errorCode));
- NAPI_CALL(env, napi_set_named_property(env, errorObj, "message", errorMessage));
- IMSA_HILOGE("ToError end");
- return errorObj;
- }
-
- int32_t JsUtils::Convert(int32_t code)
- {
- IMSA_HILOGI("Convert start");
- auto iter = ERROR_CODE_MAP.find(code);
- if (iter != ERROR_CODE_MAP.end()) {
- IMSA_HILOGE("ErrorCode: %{public}d", iter->second);
- return iter->second;
- }
- IMSA_HILOGI("Convert end");
- return ERROR_CODE_QUERY_FAILED;
- }
-
- const std::string JsUtils::ToMessage(int32_t code)
- {
- IMSA_HILOGI("ToMessage start");
- auto iter = ERROR_CODE_CONVERT_MESSAGE_MAP.find(code);
- if (iter != ERROR_CODE_CONVERT_MESSAGE_MAP.end()) {
- IMSA_HILOGI("ErrorMessage: %{public}s", (iter->second).c_str());
- return iter->second;
- }
- return "error is out of definition.";
}
+ napi_throw_error(env, std::to_string(err).c_str(), errMsg.c_str());
}
-}
\ No newline at end of file
+
+napi_value JsUtils::ToError(napi_env env, int32_t code)
+{
+ IMSA_HILOGE("ToError start");
+ napi_value errorObj;
+ NAPI_CALL(env, napi_create_object(env, &errorObj));
+ napi_value errorCode = nullptr;
+ NAPI_CALL(env, napi_create_string_utf8(env, std::to_string(Convert(code)).c_str(), NAPI_AUTO_LENGTH, &errorCode));
+ napi_value errorMessage = nullptr;
+ NAPI_CALL(env, napi_create_string_utf8(env, ToMessage(Convert(code)).c_str(), NAPI_AUTO_LENGTH, &errorMessage));
+ NAPI_CALL(env, napi_set_named_property(env, errorObj, "code", errorCode));
+ NAPI_CALL(env, napi_set_named_property(env, errorObj, "message", errorMessage));
+ IMSA_HILOGE("ToError end");
+ return errorObj;
+}
+
+int32_t JsUtils::Convert(int32_t code)
+{
+ IMSA_HILOGI("Convert start");
+ auto iter = ERROR_CODE_MAP.find(code);
+ if (iter != ERROR_CODE_MAP.end()) {
+ IMSA_HILOGE("ErrorCode: %{public}d", iter->second);
+ return iter->second;
+ }
+ IMSA_HILOGI("Convert end");
+ return ERROR_CODE_QUERY_FAILED;
+}
+
+const std::string JsUtils::ToMessage(int32_t code)
+{
+ IMSA_HILOGI("ToMessage start");
+ auto iter = ERROR_CODE_CONVERT_MESSAGE_MAP.find(code);
+ if (iter != ERROR_CODE_CONVERT_MESSAGE_MAP.end()) {
+ IMSA_HILOGI("ErrorMessage: %{public}s", (iter->second).c_str());
+ return iter->second;
+ }
+ return "error is out of definition.";
+}
+} // namespace MiscServices
+} // namespace OHOS
\ No newline at end of file
diff --git a/services/BUILD.gn b/services/BUILD.gn
index b70afced..abdcb50a 100644
--- a/services/BUILD.gn
+++ b/services/BUILD.gn
@@ -23,6 +23,7 @@ config("inputmethod_services_native_config") {
"//base/notification/common_event_service/frameworks/core/include",
"//base/notification/common_event_service/interfaces/innerkits/native/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/event/include",
+ "${inputmethod_path}/services/adapter/keyboard/include",
"${inputmethod_path}/services/dfx/include",
]
@@ -57,7 +58,6 @@ ohos_shared_library("inputmethod_service") {
deps = [
"${ability_runtime_inner_api_path}/ability_manager:ability_manager",
- "${ability_runtime_services_path}/abilitymgr:abilityms",
"${inputmethod_path}/services/adapter/keyboard:keboard_event_static",
"${inputmethod_path}/services/dfx:inputmethod_dfx_static",
"//base/global/resource_management/frameworks/resmgr:global_resmgr",
diff --git a/services/adapter/keyboard/BUILD.gn b/services/adapter/keyboard/BUILD.gn
index d07b86ae..cac9aca9 100644
--- a/services/adapter/keyboard/BUILD.gn
+++ b/services/adapter/keyboard/BUILD.gn
@@ -23,7 +23,10 @@ config("inputmethod_adapter_native_config") {
}
ohos_static_library("keboard_event_static") {
- sources = [ "keyboard_event.cpp" ]
+ sources = [
+ "src/input_event_callback.cpp",
+ "src/keyboard_event.cpp",
+ ]
configs = [ ":inputmethod_adapter_native_config" ]
diff --git a/services/adapter/keyboard/include/input_event_callback.h b/services/adapter/keyboard/include/input_event_callback.h
new file mode 100644
index 00000000..1612fbe3
--- /dev/null
+++ b/services/adapter/keyboard/include/input_event_callback.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INPUTMETHOD_IMF_INPUT_EVENT_CALLBACK_H
+#define INPUTMETHOD_IMF_INPUT_EVENT_CALLBACK_H
+
+#include