diff --git a/README.md b/README.md index 1f57d143..db873c26 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # miscservices_inputmethod -####Introduction +#### Introduction Input Method Framework, is used to connect the application and input method. the application can input text through the input method -####Warehouse path +#### Warehouse path /base/miscservices/inputmethod -####Introduction to framework code +#### Introduction to framework code The input method framework currently has four modules, as follows: @@ -36,12 +36,25 @@ Path: /base/miscservices/inputmethod/interfaces/kits/JS Function: the temporarily exposed JS interface is mainly reserved for calling input methods -####Main functions supported by the framework +#### Main functions supported by the framework 1. Click in the edit attribute control to invoke the default input method application through the input method framework 2. Typing can be carried out through the input method application, and characters can be input to the application client on the screen +#### Debugging method + +1. Compile command + +./build.sh --product-name (Fill in the specific product name, such as:Hi3516DV300) --build-target inputmethod_native + +2. push so file + +in $root\out\ohos-arm-release\miscservices\inputmethod_native, push libinputmethod_client.z.so libinputmethod_ability.z.so +libinputmethod_service.z.so to system/lib,and push libinputmethodability.z.so to system/lib/module, and make sure the four so files is readable at least. + +3. reboot + ####Participation contribution 1. Fork warehouse diff --git a/README_zh.md b/README_zh.md index 0406b4d9..39200d45 100644 --- a/README_zh.md +++ b/README_zh.md @@ -39,6 +39,19 @@ 2.通过输入法应用可以进行打字,并上屏输入字符到应用客户端 +#### 本框架编译调试方法 + +1. 编译命令 + +./build.sh --product-name (填写具体的产品名,如:Hi3516DV300) --build-target inputmethod_native + +2. 推送so文件 + +将工程目录下out\ohos-arm-release\miscservices\inputmethod_native下的libinputmethod_client.z.so libinputmethod_ability.z.so +libinputmethod_service.z.so三大so推送到system/lib,将libinputmethodability.z.so推送到system/lib/module下,并确保四个so至少为可读状态。 + +3. 重启设备 + #### 参与贡献 1. Fork 本仓库 diff --git a/frameworks/inputmethod_ability/include/event_target.h b/frameworks/inputmethod_ability/include/event_target.h index bce87b7c..766f6ada 100644 --- a/frameworks/inputmethod_ability/include/event_target.h +++ b/frameworks/inputmethod_ability/include/event_target.h @@ -22,29 +22,29 @@ namespace OHOS { namespace MiscServices { -struct EventListener; -class Event { -public: - virtual napi_value ToJsObject() = 0; -}; + struct EventListener; + class Event { + public: + virtual napi_value ToJsObject() = 0; + }; -class EventTarget : public RefBase { -public: - EventTarget(napi_env env, napi_value thisVar); - virtual ~EventTarget(); + class EventTarget : public RefBase { + public: + EventTarget(napi_env env, napi_value thisVar); + virtual ~EventTarget(); - virtual void On(const char* type, napi_value handler); - virtual void Once(const char* type, napi_value handler); - virtual void Off(const char* type, napi_value handler); - virtual void Off(const char* type); - virtual void Emit(const char* type, Event* event); + virtual void On(const char* type, napi_value handler); + virtual void Once(const char* type, napi_value handler); + virtual void Off(const char* type, napi_value handler); + virtual void Off(const char* type); + virtual void Emit(const char* type, Event* event); -protected: - napi_env env_; - napi_ref thisVarRef_; - EventListener* first_; - EventListener* last_; -}; + protected: + napi_env env_; + napi_ref thisVarRef_; + EventListener *first_; + EventListener *last_; + }; } } #endif // INPUT_METHOD_NAPI_EVENT_TARGET_H \ No newline at end of file diff --git a/frameworks/inputmethod_ability/include/i_input_method_core.h b/frameworks/inputmethod_ability/include/i_input_method_core.h index 50ecf881..eb73f9cc 100644 --- a/frameworks/inputmethod_ability/include/i_input_method_core.h +++ b/frameworks/inputmethod_ability/include/i_input_method_core.h @@ -53,7 +53,7 @@ namespace MiscServices { virtual bool showKeyboard(int32_t flags) = 0; virtual bool hideKeyboard(int32_t flags) = 0; virtual int32_t setKeyboardType(const KeyboardType& type) = 0; - virtual int32_t getKeyboardWindowHeight(int32_t* retHeight) = 0; + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0; }; } } diff --git a/frameworks/inputmethod_ability/include/input_method_ability.h b/frameworks/inputmethod_ability/include/input_method_ability.h index fbb770f1..00674e9f 100644 --- a/frameworks/inputmethod_ability/include/input_method_ability.h +++ b/frameworks/inputmethod_ability/include/input_method_ability.h @@ -47,12 +47,12 @@ namespace MiscServices { private: std::thread workThreadHandler; - MessageHandler* msgHandler; + MessageHandler *msgHandler; bool mSupportPhysicalKbd = false; - InputAttribute* editorAttribute; + InputAttribute *editorAttribute; int32_t displyId = 0; sptr startInputToken; - InputChannel* writeInputChannel; + InputChannel *writeInputChannel; // communicating with IMSA sptr inputControlChannel; @@ -71,15 +71,15 @@ namespace MiscServices { void CreateInputMethodAgent(bool supportPhysicalKbd); // the message from IMSA - void OnInitialInput(Message* msg); - void OnStartInput(Message* msg); - void OnStopInput(Message* msg); - void OnSetKeyboardType(Message* msg); - void OnShowKeyboard(Message* msg); - void OnHideKeyboard(Message* msg); + void OnInitialInput(Message *msg); + void OnStartInput(Message *msg); + void OnStopInput(Message *msg); + void OnSetKeyboardType(Message *msg); + void OnShowKeyboard(Message *msg); + void OnHideKeyboard(Message *msg); // the message from IMC - bool DispatchKey(Message* msg); + bool DispatchKey(Message *msg); // control inputwindow void InitialInputWindow(); diff --git a/frameworks/inputmethod_ability/include/input_method_agent_stub.h b/frameworks/inputmethod_ability/include/input_method_agent_stub.h index b477e82f..c26922a0 100644 --- a/frameworks/inputmethod_ability/include/input_method_agent_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_agent_stub.h @@ -33,9 +33,9 @@ namespace MiscServices { MessageParcel &reply, MessageOption &option) override; virtual int32_t DispatchKey(int32_t key, int32_t status) override; - void SetMessageHandler(MessageHandler* msgHandler); + void SetMessageHandler(MessageHandler *msgHandler); private: - MessageHandler* msgHandler_; + MessageHandler *msgHandler_; }; } } diff --git a/frameworks/inputmethod_ability/include/input_method_core_proxy.h b/frameworks/inputmethod_ability/include/input_method_core_proxy.h index 0b09b716..be50db28 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_proxy.h +++ b/frameworks/inputmethod_ability/include/input_method_core_proxy.h @@ -43,7 +43,7 @@ namespace MiscServices { virtual bool showKeyboard(int32_t flags) override; virtual bool hideKeyboard(int32_t flags) override; virtual int32_t setKeyboardType(const KeyboardType& type) override; - virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) override; + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; private: static inline BrokerDelegator delegator_; diff --git a/frameworks/inputmethod_ability/include/input_method_core_stub.h b/frameworks/inputmethod_ability/include/input_method_core_stub.h index bd2c229e..d7b8f977 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_core_stub.h @@ -52,12 +52,12 @@ namespace MiscServices { virtual bool showKeyboard(int32_t flags) override; virtual bool hideKeyboard(int32_t flags)override; virtual int32_t setKeyboardType(const KeyboardType& type) override; - virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) override; - void SetMessageHandler(MessageHandler* msgHandler); + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; + void SetMessageHandler(MessageHandler *msgHandler); private: int userId_; - MessageHandler* msgHandler_; + MessageHandler *msgHandler_; }; } } diff --git a/frameworks/inputmethod_ability/src/event_target.cpp b/frameworks/inputmethod_ability/src/event_target.cpp index e0f89960..87470aea 100644 --- a/frameworks/inputmethod_ability/src/event_target.cpp +++ b/frameworks/inputmethod_ability/src/event_target.cpp @@ -26,10 +26,11 @@ namespace MiscServices { char type[LISTENER_TYPTE_MAX_LENGTH] = { 0 }; bool isOnce = false; napi_ref handlerRef = nullptr; - EventListener* back = nullptr; - EventListener* next = nullptr; + EventListener *back = nullptr; + EventListener *next = nullptr; }; - EventTarget::EventTarget(napi_env env, napi_value thisVar) { + EventTarget::EventTarget(napi_env env, napi_value thisVar) + { IMSA_HILOGI("EventTarget::EventTarget"); env_ = env; first_ = last_ = nullptr; @@ -37,8 +38,9 @@ namespace MiscServices { napi_create_reference(env, thisVar, 1, &thisVarRef_); } - EventTarget::~EventTarget() { - EventListener* temp = nullptr; + EventTarget::~EventTarget() + { + EventListener *temp = nullptr; for (EventListener* i = first_; i != nullptr; i = temp) { temp = i->next; if (i == first_) { @@ -99,7 +101,7 @@ namespace MiscServices { napi_create_reference(env_, handler, 1, &last_->handlerRef); } - void EventTarget::Off(const char* type, napi_value handler) + void EventTarget::Off(const char *type, napi_value handler) { IMSA_HILOGI("EventTarget::Off"); napi_handle_scope scope = nullptr; @@ -109,8 +111,8 @@ namespace MiscServices { return; } - EventListener* temp = nullptr; - for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = temp) { + EventListener *temp = nullptr; + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) { temp = eventListener->next; bool isEquals = false; napi_value handlerTemp = nullptr; @@ -137,8 +139,8 @@ namespace MiscServices { void EventTarget::Off(const char* type) { IMSA_HILOGI("EventTarget::Off"); - EventListener* temp = nullptr; - for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = temp) { + EventListener *temp = nullptr; + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) { temp = eventListener->next; if (strcmp(eventListener->type, type) == 0) { if (eventListener == first_) { @@ -156,7 +158,7 @@ namespace MiscServices { } } - void EventTarget::Emit(const char* type, Event* event) + void EventTarget::Emit(const char* type, Event *event) { IMSA_HILOGI("EventTarget::Emit"); napi_handle_scope scope = nullptr; @@ -164,7 +166,7 @@ namespace MiscServices { napi_value thisVar = nullptr; napi_get_reference_value(env_, thisVarRef_, &thisVar); - for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = eventListener->next) { + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = eventListener->next) { if (strcmp(eventListener->type, type) == 0) { napi_value jsEvent = event ? event->ToJsObject() : nullptr; napi_value handler = nullptr; diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index 6b918451..a24f64c7 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -29,18 +29,21 @@ namespace MiscServices { sptr InputMethodAbility::instance_; std::mutex InputMethodAbility::instanceLock_; - InputMethodAbility::InputMethodAbility() { + InputMethodAbility::InputMethodAbility() + { Initialize(); OnConnect(); } - InputMethodAbility::~InputMethodAbility() { + InputMethodAbility::~InputMethodAbility() + { if (msgHandler != nullptr) { delete msgHandler; } } - sptr InputMethodAbility::GetInstance() { + sptr InputMethodAbility::GetInstance() + { IMSA_HILOGI("InputMethodAbility::GetInstance"); if (instance_ == nullptr) { std::lock_guard autoLock(instanceLock_); @@ -52,7 +55,8 @@ namespace MiscServices { return instance_; } - sptr InputMethodAbility::GetImsaProxy() { + sptr InputMethodAbility::GetImsaProxy() + { IMSA_HILOGI("InputMethodAbility::GetImsaProxy"); sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -71,7 +75,8 @@ namespace MiscServices { return iface; } - sptr InputMethodAbility::OnConnect() { + sptr InputMethodAbility::OnConnect() + { IMSA_HILOGI("InputMethodAbility::OnConnect"); mImms = GetImsaProxy(); sptr stub = new InputMethodCoreStub(0); @@ -84,7 +89,8 @@ namespace MiscServices { return nullptr; } - void InputMethodAbility::Initialize() { + void InputMethodAbility::Initialize() + { IMSA_HILOGI("InputMethodAbility::Initialize"); InitialInputWindow(); msgHandler = new MessageHandler(); @@ -96,9 +102,10 @@ namespace MiscServices { eventTarget_ = eventTarget; } - void InputMethodAbility::WorkThread() { + void InputMethodAbility::WorkThread() + { while(1){ - Message* msg = msgHandler->GetMessage(); + Message *msg = msgHandler->GetMessage(); switch(msg->msgId_) { case MSG_ID_INITIALIZE_INPUT: { OnInitialInput(msg); @@ -138,9 +145,10 @@ namespace MiscServices { } } - void InputMethodAbility::OnInitialInput(Message* msg) { + void InputMethodAbility::OnInitialInput(Message *msg) + { IMSA_HILOGI("InputMethodAbility::OnInitialInput"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; displyId = data->ReadInt32(); sptr channelObject = data->ReadRemoteObject(); if (channelObject == nullptr) { @@ -156,9 +164,10 @@ namespace MiscServices { InitialInputWindow(); } - void InputMethodAbility::OnStartInput(Message* msg) { + void InputMethodAbility::OnStartInput(Message *msg) + { IMSA_HILOGI("InputMethodAbility::OnStartInput"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; sptr channalProxy = new InputDataChannelProxy(data->ReadRemoteObject()); inputDataChannel = channalProxy; if(inputDataChannel == nullptr) { @@ -177,54 +186,63 @@ namespace MiscServices { } } - void InputMethodAbility::OnShowKeyboard(Message* msg) { + void InputMethodAbility::OnShowKeyboard(Message *msg) + { IMSA_HILOGI("InputMethodAbility::OnShowKeyboard"); ShowInputWindow(); } - void InputMethodAbility::OnHideKeyboard(Message* msg) { + void InputMethodAbility::OnHideKeyboard(Message *msg) + { IMSA_HILOGI("InputMethodAbility::OnHideKeyboard"); DissmissInputWindow(); } - void InputMethodAbility::OnStopInput(Message* msg) { + void InputMethodAbility::OnStopInput(Message *msg) + { IMSA_HILOGI("InputMethodAbility::OnStopInput"); if (writeInputChannel != nullptr) { delete writeInputChannel; } } - bool InputMethodAbility::DispatchKey(Message* msg) { + bool InputMethodAbility::DispatchKey(Message *msg) + { IMSA_HILOGI("InputMethodAbility::DispatchKey"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t key = data->ReadInt32(); int32_t status = data->ReadInt32(); IMSA_HILOGI("InputMethodAbility::DispatchKey: key = %{public}d, status = %{public}d", key, status); return true; } - void InputMethodAbility::CreateInputMethodAgent(bool supportPhysicalKbd) { + void InputMethodAbility::CreateInputMethodAgent(bool supportPhysicalKbd) + { IMSA_HILOGI("InputMethodAbility::CreateInputMethodAgent"); sptr inputMethodAgentStub(new InputMethodAgentStub()); inputMethodAgentStub->SetMessageHandler(msgHandler); inputMethodAgent = sptr(new InputMethodAgentProxy(inputMethodAgentStub)); } - void InputMethodAbility::InitialInputWindow() { + void InputMethodAbility::InitialInputWindow() + { IMSA_HILOGI("InputMethodAbility::InitialInputWindow"); } - void InputMethodAbility::ShowInputWindow() { + void InputMethodAbility::ShowInputWindow() + { IMSA_HILOGI("InputMethodAbility::ShowInputWindow"); eventTarget_->Emit("keyboardShow",nullptr); } - void InputMethodAbility::DissmissInputWindow() { + void InputMethodAbility::DissmissInputWindow() + { IMSA_HILOGI("InputMethodAbility::DissmissInputWindow"); eventTarget_->Emit("keyboardHide",nullptr); } - bool InputMethodAbility::InsertText(const std::string text) { + bool InputMethodAbility::InsertText(const std::string text) + { IMSA_HILOGI("InputMethodAbility::InsertText"); if (inputDataChannel == nullptr){ IMSA_HILOGI("InputMethodAbility::InsertText inputDataChanel is nullptr"); @@ -234,7 +252,8 @@ namespace MiscServices { return inputDataChannel->InsertText(Utils::to_utf16(text)); } - void InputMethodAbility::DeleteBackward(int32_t length) { + void InputMethodAbility::DeleteBackward(int32_t length) + { IMSA_HILOGI("InputMethodAbility::DeleteBackward"); if (inputDataChannel == nullptr){ IMSA_HILOGI("InputMethodAbility::DeleteBackward inputDataChanel is nullptr"); @@ -243,7 +262,8 @@ namespace MiscServices { inputDataChannel->DeleteBackward(length); } - void InputMethodAbility::HideKeyboardSelf() { + void InputMethodAbility::HideKeyboardSelf() + { IMSA_HILOGI("InputMethodAbility::HideKeyboardSelf"); inputControlChannel->hideKeyboardSelf(1); } diff --git a/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp index 02dd7c49..1e06f7e0 100644 --- a/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp @@ -19,10 +19,12 @@ namespace OHOS { namespace MiscServices { using namespace ErrorCode; InputMethodAgentProxy::InputMethodAgentProxy(const sptr &object) - : IRemoteProxy(object) { + : IRemoteProxy(object) + { } - int32_t InputMethodAgentProxy::DispatchKey(int32_t key, int32_t status) { + int32_t InputMethodAgentProxy::DispatchKey(int32_t key, int32_t status) + { IMSA_HILOGI("InputMethodAgentProxy::DispatchKey key = %{public}d, status = %{public}d", key, status); MessageParcel data, reply; MessageOption option; diff --git a/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp b/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp index c2504abb..f562d973 100644 --- a/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp @@ -22,14 +22,17 @@ namespace OHOS { namespace MiscServices { using namespace MessageID; - InputMethodAgentStub::InputMethodAgentStub() { + InputMethodAgentStub::InputMethodAgentStub() + { } - InputMethodAgentStub::~InputMethodAgentStub() { + InputMethodAgentStub::~InputMethodAgentStub() + { } int32_t InputMethodAgentStub::OnRemoteRequest(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) { + MessageParcel &reply, MessageOption &option) + { IMSA_HILOGI("InputMethodAgentStub::OnRemoteRequest code = %{public}d", code); auto descriptorToken = data.ReadInterfaceToken(); if (descriptorToken != GetDescriptor()) { @@ -55,20 +58,22 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - int32_t InputMethodAgentStub::DispatchKey(int32_t key, int32_t status) { + int32_t InputMethodAgentStub::DispatchKey(int32_t key, int32_t status) + { IMSA_HILOGI("InputMethodAgentStub::DispatchKey key = %{public}d, status = %{public}d", key, status); if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); data->WriteInt32(key); data->WriteInt32(status); - Message* message = new Message(MessageID::MSG_ID_DISPATCH_KEY, data); + Message *message = new Message(MessageID::MSG_ID_DISPATCH_KEY, data); msgHandler_->SendMessage(message); return ErrorCode::NO_ERROR; } - void InputMethodAgentStub::SetMessageHandler(MessageHandler* msgHandler) { + void InputMethodAgentStub::SetMessageHandler(MessageHandler *msgHandler) + { msgHandler_ = msgHandler; } } diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index 7d19a541..581df3be 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -21,13 +21,15 @@ namespace OHOS { namespace MiscServices { InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr &impl) - : IRemoteProxy(impl) { + : IRemoteProxy(impl) + { } InputMethodCoreProxy::~InputMethodCoreProxy() = default; int32_t InputMethodCoreProxy::initializeInput(sptr &startInputToken, int32_t displayId, - sptr &inputControlChannel) { + sptr &inputControlChannel) + { IMSA_HILOGI("InputMethodCoreProxy::initializeInput"); if (startInputToken == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput startInputToken is nullptr"); @@ -61,7 +63,8 @@ namespace MiscServices { } bool InputMethodCoreProxy::startInput(const sptr &inputDataChannel, - const InputAttribute& editorAttribute, bool supportPhysicalKbd) { + const InputAttribute& editorAttribute, bool supportPhysicalKbd) + { IMSA_HILOGI("InputMethodCoreProxy::startInput"); if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr"); @@ -88,7 +91,8 @@ namespace MiscServices { return code == ErrorCode::NO_ERROR; } - int32_t InputMethodCoreProxy::stopInput() { + int32_t InputMethodCoreProxy::stopInput() + { IMSA_HILOGI("InputMethodCoreProxy::stopInput"); MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); @@ -106,7 +110,8 @@ namespace MiscServices { return reply.ReadInt32(); } - bool InputMethodCoreProxy::showKeyboard(int32_t flags) { + bool InputMethodCoreProxy::showKeyboard(int32_t flags) + { IMSA_HILOGI("InputMethodCoreProxy::showKeyboard"); auto remote = Remote(); if (remote == nullptr){ @@ -128,7 +133,8 @@ namespace MiscServices { return true; } - bool InputMethodCoreProxy::hideKeyboard(int32_t flags) { + bool InputMethodCoreProxy::hideKeyboard(int32_t flags) + { IMSA_HILOGI("InputMethodCoreProxy::hideKeyboard"); auto remote = Remote(); if (remote == nullptr) { @@ -149,7 +155,8 @@ namespace MiscServices { return true; } - int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType& type) { + int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType& type) + { IMSA_HILOGI("InputMethodCoreProxy::setKeyboardType"); MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); @@ -163,7 +170,8 @@ namespace MiscServices { return code; } - int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t* retHeight) { + int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t retHeight) + { IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight"); MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); @@ -176,7 +184,7 @@ namespace MiscServices { if (code != 0) { return code; } - *retHeight = reply.ReadInt32(); + retHeight = reply.ReadInt32(); return ErrorCode::NO_ERROR; } } diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp index a7ecadab..3cf80ad0 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp @@ -30,15 +30,18 @@ namespace MiscServices { * param userId the id of the user to whom the object is linking * @param userId */ - InputMethodCoreStub::InputMethodCoreStub(int userId) { + InputMethodCoreStub::InputMethodCoreStub(int userId) + { userId_ = userId; } - InputMethodCoreStub::~InputMethodCoreStub() { + InputMethodCoreStub::~InputMethodCoreStub() + { } int32_t InputMethodCoreStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option) { + MessageOption& option) + { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest"); auto descriptorToken = data.ReadInterfaceToken(); if (descriptorToken != GetDescriptor()) { @@ -65,7 +68,7 @@ namespace MiscServices { } case START_INPUT: { sptr inputDataChannel = iface_cast(data.ReadRemoteObject()); - InputAttribute* editorAttribute = data.ReadParcelable(); + InputAttribute *editorAttribute = data.ReadParcelable(); bool supportPhysicalKbd = data.ReadBool(); if (inputDataChannel == nullptr) { @@ -93,13 +96,13 @@ namespace MiscServices { break; } case SET_KEYBOARD_TYPE: { - KeyboardType* type = data.ReadParcelable(); + KeyboardType *type = data.ReadParcelable(); setKeyboardType(*type); reply.WriteNoException(); break; } case GET_KEYBOARD_WINDOW_HEIGHT: { - int32_t* retHeight = nullptr; + int32_t retHeight = 0; getKeyboardWindowHeight(retHeight); reply.WriteNoException(); break; @@ -112,7 +115,8 @@ namespace MiscServices { } int32_t InputMethodCoreStub::initializeInput(sptr& startInputToken, int32_t displayId, - sptr& inputControlChannel) { + sptr& inputControlChannel) + { IMSA_HILOGI("InputMethodCoreStub::initializeInput"); if (msgHandler_==nullptr) { return ErrorCode::ERROR_NULL_POINTER; @@ -122,100 +126,107 @@ namespace MiscServices { IMSA_HILOGI("InputMethodCoreStub::initializeInput startInputToken is nullptr"); } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); data->WriteInt32(displayId); if (inputControlChannel != nullptr) { IMSA_HILOGI("InputMethodCoreStub::initializeInput. inputControlChannel is not nullptr"); data->WriteRemoteObject(inputControlChannel->AsObject()); } - Message* msg = new Message(MessageID::MSG_ID_INITIALIZE_INPUT, data); + Message *msg = new Message(MessageID::MSG_ID_INITIALIZE_INPUT, data); msgHandler_->SendMessage(msg); return ErrorCode::NO_ERROR; } bool InputMethodCoreStub::startInput(const sptr& inputDataChannel, - const InputAttribute& editorAttribute, bool supportPhysicalKbd) { + const InputAttribute& editorAttribute, bool supportPhysicalKbd) + { IMSA_HILOGI("InputMethodCoreStub::startInput"); if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); if (inputDataChannel !=nullptr) { IMSA_HILOGI("InputMethodCoreStub::startInput inputDataChannel is not nullptr"); data->WriteRemoteObject(inputDataChannel->AsObject()); } data->WriteParcelable(&editorAttribute); data->WriteBool(supportPhysicalKbd); - Message* msg = new Message(MessageID::MSG_ID_START_INPUT, data); + Message *msg = new Message(MessageID::MSG_ID_START_INPUT, data); msgHandler_->SendMessage(msg); return true; } - int32_t InputMethodCoreStub::stopInput() { + int32_t InputMethodCoreStub::stopInput() + { IMSA_HILOGI("InputMethodCoreStub::stopInput"); if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); - Message* msg = new Message(MessageID::MSG_ID_STOP_INPUT, data); + MessageParcel *data = new MessageParcel(); + Message *msg = new Message(MessageID::MSG_ID_STOP_INPUT, data); msgHandler_->SendMessage(msg); return ErrorCode::NO_ERROR; } - bool InputMethodCoreStub::showKeyboard(int32_t flags) { + bool InputMethodCoreStub::showKeyboard(int32_t flags) + { IMSA_HILOGI("InputMethodCoreStub::showKeyboard"); if (msgHandler_==nullptr) { return false; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); data->WriteInt32(userId_); data->WriteInt32(flags); - Message* msg = new Message(MessageID::MSG_ID_SHOW_KEYBOARD, data); + Message *msg = new Message(MessageID::MSG_ID_SHOW_KEYBOARD, data); msgHandler_->SendMessage(msg); return true; } - bool InputMethodCoreStub::hideKeyboard(int32_t flags) { + bool InputMethodCoreStub::hideKeyboard(int32_t flags) + { IMSA_HILOGI("InputMethodCoreStub::hideKeyboard"); if (msgHandler_==nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); data->WriteInt32(userId_); data->WriteInt32(flags); - Message* msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD, data); + Message *msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD, data); msgHandler_->SendMessage(msg); return true; } - int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type) { + int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type) + { IMSA_HILOGI("InputMethodCoreStub::setKeyboardType"); if (msgHandler_==nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); data->WriteParcelable(&type); - Message* msg = new Message(MessageID::MSG_ID_SET_KEYBOARD_TYPE, data); + Message *msg = new Message(MessageID::MSG_ID_SET_KEYBOARD_TYPE, data); msgHandler_->SendMessage(msg); return ErrorCode::NO_ERROR; } - int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t* retHeight) { + int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t retHeight) + { IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight"); if (msgHandler_==nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - MessageParcel* data = new MessageParcel(); + MessageParcel *data = new MessageParcel(); - Message* msg = new Message(MessageID::MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT, data); + Message *msg = new Message(MessageID::MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT, data); msgHandler_->SendMessage(msg); return ErrorCode::NO_ERROR; } - void InputMethodCoreStub::SetMessageHandler(MessageHandler* msgHandler) { + void InputMethodCoreStub::SetMessageHandler(MessageHandler *msgHandler) + { msgHandler_=msgHandler; } } diff --git a/frameworks/inputmethod_controller/include/i_input_client.h b/frameworks/inputmethod_controller/include/i_input_client.h index a55a5dca..0a984c41 100644 --- a/frameworks/inputmethod_controller/include/i_input_client.h +++ b/frameworks/inputmethod_controller/include/i_input_client.h @@ -38,7 +38,7 @@ namespace MiscServices { DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputClient"); virtual int32_t onInputReady(int32_t retValue, const sptr& agent, - const InputChannel* channel) = 0; + const InputChannel *channel) = 0; virtual int32_t onInputReleased(int32_t retValue) = 0; virtual int32_t setDisplayMode(int32_t mode) = 0; }; diff --git a/frameworks/inputmethod_controller/include/input_client_proxy.h b/frameworks/inputmethod_controller/include/input_client_proxy.h index c535f2f5..1cb1c5b4 100644 --- a/frameworks/inputmethod_controller/include/input_client_proxy.h +++ b/frameworks/inputmethod_controller/include/input_client_proxy.h @@ -28,7 +28,7 @@ public: ~InputClientProxy() = default; DISALLOW_COPY_AND_MOVE(InputClientProxy); - int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel* channel) override; + int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel *channel) override; int32_t onInputReleased(int32_t retValue) override; int32_t setDisplayMode(int32_t mode) override; diff --git a/frameworks/inputmethod_controller/include/input_client_stub.h b/frameworks/inputmethod_controller/include/input_client_stub.h index 8eddca28..15caf910 100644 --- a/frameworks/inputmethod_controller/include/input_client_stub.h +++ b/frameworks/inputmethod_controller/include/input_client_stub.h @@ -29,13 +29,13 @@ public: int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; InputClientStub(); ~InputClientStub(); - void SetHandler(MessageHandler* handler); + void SetHandler(MessageHandler *handler); - int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel* channel) override; + int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel *channel) override; int32_t onInputReleased(int32_t retValue) override; int32_t setDisplayMode(int32_t mode) override; private: - MessageHandler* msgHandler = nullptr; + MessageHandler *msgHandler = nullptr; }; } } diff --git a/frameworks/inputmethod_controller/include/input_data_channel_stub.h b/frameworks/inputmethod_controller/include/input_data_channel_stub.h index aaefdec2..46541ab6 100644 --- a/frameworks/inputmethod_controller/include/input_data_channel_stub.h +++ b/frameworks/inputmethod_controller/include/input_data_channel_stub.h @@ -29,13 +29,13 @@ public: int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; InputDataChannelStub(); ~InputDataChannelStub(); - void SetHandler(MessageHandler* handler); + void SetHandler(MessageHandler *handler); bool InsertText(const std::u16string& text) override; bool DeleteBackward(int32_t length) override; void Close() override; private: - MessageHandler* msgHandler; + MessageHandler *msgHandler; }; } } diff --git a/frameworks/inputmethod_controller/include/input_method_controller.h b/frameworks/inputmethod_controller/include/input_method_controller.h index 37a589ce..31a4e059 100644 --- a/frameworks/inputmethod_controller/include/input_method_controller.h +++ b/frameworks/inputmethod_controller/include/input_method_controller.h @@ -70,13 +70,13 @@ namespace MiscServices { sptr mImms; sptr deathRecipient_; sptr mAgent; - OnTextChangedListener* textListener; + OnTextChangedListener *textListener; InputAttribute mAttribute; static std::mutex instanceLock_; static sptr instance_; std::thread workThreadHandler; - MessageHandler* msgHandler; + MessageHandler *msgHandler; }; } } diff --git a/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h b/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h index 973ab694..741d25a6 100644 --- a/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h +++ b/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h @@ -48,8 +48,8 @@ class InputMethodSystemAbilityProxy : public IRemoteProxy &client); virtual int32_t getDisplayMode(int32_t *retMode) override; - virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) override; - virtual int32_t getCurrentKeyboardType(KeyboardType* retType) override; + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; + virtual int32_t getCurrentKeyboardType(KeyboardType *retType) override; virtual int32_t listInputMethodEnabled(std::vector *properties) override; virtual int32_t listInputMethod(std::vector *properties) override; virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector *types) override; diff --git a/frameworks/inputmethod_controller/src/input_client_proxy.cpp b/frameworks/inputmethod_controller/src/input_client_proxy.cpp index a34d424a..e36349f4 100644 --- a/frameworks/inputmethod_controller/src/input_client_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_client_proxy.cpp @@ -18,11 +18,13 @@ namespace OHOS { namespace MiscServices { using namespace ErrorCode; - InputClientProxy::InputClientProxy(const sptr &object) : IRemoteProxy(object) { + InputClientProxy::InputClientProxy(const sptr &object) : IRemoteProxy(object) + { } int32_t InputClientProxy::onInputReady(int32_t retValue, const sptr& agent, - const InputChannel* channel) { + const InputChannel *channel) + { IMSA_HILOGI("InputClientProxy::onInputReady"); MessageParcel data, reply; MessageOption option; diff --git a/frameworks/inputmethod_controller/src/input_client_stub.cpp b/frameworks/inputmethod_controller/src/input_client_stub.cpp index 19deaa18..b2764d5d 100644 --- a/frameworks/inputmethod_controller/src/input_client_stub.cpp +++ b/frameworks/inputmethod_controller/src/input_client_stub.cpp @@ -20,16 +20,14 @@ namespace OHOS { namespace MiscServices { InputClientStub::InputClientStub() { - } InputClientStub::~InputClientStub() { - } int32_t InputClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) + MessageOption &option) { IMSA_HILOGI("InputClientStub::OnRemoteRequest. code = %{public}u", code); auto descriptorToken = data.ReadInterfaceToken(); @@ -41,7 +39,7 @@ namespace MiscServices { if (msgHandler == nullptr) { break; } - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(data.ReadInt32()); if (data.ReadInt32() > 0) { parcel->WriteRemoteObject(data.ReadRemoteObject()); @@ -50,7 +48,7 @@ namespace MiscServices { parcel->WriteParcelable(data.ReadParcelable()); } - Message* msg = new Message(MessageID::MSG_ID_ON_INPUT_READY, parcel); + Message *msg = new Message(MessageID::MSG_ID_ON_INPUT_READY, parcel); msgHandler->SendMessage(msg); break; } @@ -58,9 +56,9 @@ namespace MiscServices { if (msgHandler == nullptr) { break; } - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(data.ReadInt32()); - Message* msg = new Message(MessageID::MSG_ID_EXIT_SERVICE, parcel); + Message *msg = new Message(MessageID::MSG_ID_EXIT_SERVICE, parcel); msgHandler->SendMessage(msg); break; } @@ -68,9 +66,9 @@ namespace MiscServices { if (msgHandler == nullptr) { break; } - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(data.ReadInt32()); - Message* msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel); + Message *msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel); msgHandler->SendMessage(msg); break; } @@ -81,7 +79,8 @@ namespace MiscServices { } int32_t InputClientStub::onInputReady(int32_t retValue, const sptr& agent, - const InputChannel* channel) { + const InputChannel *channel) + { return ErrorCode::NO_ERROR; } @@ -95,7 +94,7 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - void InputClientStub::SetHandler(MessageHandler* handler) + void InputClientStub::SetHandler(MessageHandler *handler) { msgHandler = handler; } diff --git a/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp b/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp index f3dda7be..e6065035 100644 --- a/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp @@ -20,7 +20,8 @@ namespace OHOS { namespace MiscServices { InputDataChannelProxy::InputDataChannelProxy(const sptr &object) - : IRemoteProxy(object) { + : IRemoteProxy(object) + { } bool InputDataChannelProxy::InsertText(const std::u16string& text) diff --git a/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp b/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp index 9f482a0e..8411cc05 100644 --- a/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp +++ b/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp @@ -19,7 +19,6 @@ namespace OHOS { namespace MiscServices { InputDataChannelStub::InputDataChannelStub() : msgHandler(nullptr) { - } InputDataChannelStub::~InputDataChannelStub() @@ -62,9 +61,9 @@ namespace MiscServices { { IMSA_HILOGI("InputDataChannelStub::InsertText"); if (msgHandler != nullptr) { - MessageParcel* parcel = new MessageParcel; + MessageParcel *parcel = new MessageParcel; parcel->WriteString16(text); - Message* msg = new Message(MessageID::MSG_ID_INSERT_CHAR, parcel); + Message *msg = new Message(MessageID::MSG_ID_INSERT_CHAR, parcel); msgHandler->SendMessage(msg); IMSA_HILOGI("InputDataChannelStub::InsertText return true"); return true; @@ -76,9 +75,9 @@ namespace MiscServices { { IMSA_HILOGI("InputDataChannelStub::DeleteBackward"); if (msgHandler != nullptr) { - MessageParcel* parcel = new MessageParcel; + MessageParcel *parcel = new MessageParcel; parcel->WriteInt32(length); - Message* msg = new Message(MessageID::MSG_ID_DELETE_BACKWARD, parcel); + Message *msg = new Message(MessageID::MSG_ID_DELETE_BACKWARD, parcel); msgHandler->SendMessage(msg); return true; } @@ -90,7 +89,7 @@ namespace MiscServices { } - void InputDataChannelStub::SetHandler(MessageHandler* handler) + void InputDataChannelStub::SetHandler(MessageHandler *handler) { msgHandler = handler; } diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index 11f01ad6..c2fd6ab7 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -95,10 +95,10 @@ using namespace MessageID; void InputMethodController::WorkThread() { while(1) { - Message* msg = msgHandler->GetMessage(); + Message *msg = msgHandler->GetMessage(); switch(msg->msgId_) { case MSG_ID_INSERT_CHAR:{ - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; std::u16string text = data->ReadString16(); if(textListener != nullptr){ textListener->InsertText(text); @@ -106,7 +106,7 @@ using namespace MessageID; break; } case MSG_ID_DELETE_BACKWARD:{ - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t length = data->ReadInt32(); if(textListener != nullptr){ textListener->DeleteBackward(length); @@ -114,13 +114,13 @@ using namespace MessageID; break; } case MSG_ID_SET_DISPLAY_MODE:{ - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t ret = data->ReadInt32(); IMSA_HILOGI("MSG_ID_SET_DISPLAY_MODE : %{public}d", ret); break; } case MSG_ID_ON_INPUT_READY:{ - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t ret = data->ReadInt32(); if(ret != ErrorCode::NO_ERROR) { if (textListener != nullptr){ @@ -137,7 +137,7 @@ using namespace MessageID; break; } case MSG_ID_EXIT_SERVICE:{ - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t ret = data->ReadInt32(); textListener = nullptr; IMSA_HILOGI("MSG_ID_EXIT_SERVICE : %{public}d", ret); @@ -234,13 +234,13 @@ using namespace MessageID; mImms->stopInput(data); } - void InputMethodController::OnRemoteSaDied(const wptr &remote) { + void InputMethodController::OnRemoteSaDied(const wptr &remote) + { mImms = GetImsaProxy(); } ImsaDeathRecipient::ImsaDeathRecipient() { - } void ImsaDeathRecipient::OnRemoteDied(const wptr &object) 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 046f1fc3..b596bd82 100644 --- a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp @@ -21,7 +21,6 @@ namespace MiscServices { InputMethodSystemAbilityProxy::InputMethodSystemAbilityProxy(const sptr &object) : IRemoteProxy(object) { - } void InputMethodSystemAbilityProxy::prepareInput(MessageParcel& data) @@ -98,27 +97,29 @@ namespace MiscServices { } } - int32_t InputMethodSystemAbilityProxy::setInputMethodCore(sptr &core) - { - IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore"); + int32_t InputMethodSystemAbilityProxy::setInputMethodCore(sptr &core) + { + IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore"); - if (core == nullptr) { - IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore inputDataChannel is nullptr"); - } - auto remote = Remote(); - if (remote == nullptr) - return -1; - MessageParcel data; - if (!(data.WriteInterfaceToken(GetDescriptor()) - && data.WriteRemoteObject(core->AsObject()))) - return -1; - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC }; - - int32_t status = Remote()->SendRequest(SET_INPUT_METHOD_CORE, data, reply, option); - - return status; + if (core == nullptr) { + IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore inputDataChannel is nullptr"); } + auto remote = Remote(); + if (remote == nullptr) { + return -1; + } + MessageParcel data; + if (!(data.WriteInterfaceToken(GetDescriptor()) + && data.WriteRemoteObject(core->AsObject()))) { + return -1; + } + MessageParcel reply; + MessageOption option { MessageOption::TF_SYNC }; + + int32_t status = Remote()->SendRequest(SET_INPUT_METHOD_CORE, data, reply, option); + + return status; + } int32_t InputMethodSystemAbilityProxy::Prepare(int32_t displayId, sptr &client, sptr &channel, InputAttribute &attribute) @@ -250,12 +251,8 @@ namespace MiscServices { return NO_ERROR; } - int32_t InputMethodSystemAbilityProxy::getKeyboardWindowHeight(int32_t *retHeight) + int32_t InputMethodSystemAbilityProxy::getKeyboardWindowHeight(int32_t retHeight) { - if (retHeight == nullptr) { - return ERROR_NULL_POINTER; - } - MessageParcel data, reply; MessageOption option; @@ -273,13 +270,13 @@ namespace MiscServices { return ret; } - if (!reply.ReadInt32(*retHeight)) { + if (!reply.ReadInt32(retHeight)) { return ERROR_STATUS_BAD_VALUE; } return NO_ERROR; } - int32_t InputMethodSystemAbilityProxy::getCurrentKeyboardType(KeyboardType* retType) + int32_t InputMethodSystemAbilityProxy::getCurrentKeyboardType(KeyboardType *retType) { if (retType == nullptr) { return ERROR_NULL_POINTER; @@ -302,7 +299,7 @@ namespace MiscServices { return ret; } - KeyboardType* keyType = reply.ReadParcelable(); + KeyboardType *keyType = reply.ReadParcelable(); *retType = *keyType; delete keyType; return NO_ERROR; @@ -333,7 +330,7 @@ namespace MiscServices { auto size = reply.ReadInt32(); while (size > 0) { - InputMethodProperty* imp = reply.ReadParcelable(); + InputMethodProperty *imp = reply.ReadParcelable(); properties->push_back(imp); size--; } @@ -367,7 +364,7 @@ namespace MiscServices { auto size = reply.ReadInt32(); while (size > 0) { - InputMethodProperty* imp = reply.ReadParcelable(); + InputMethodProperty *imp = reply.ReadParcelable(); properties->push_back(imp); size--; } @@ -401,7 +398,7 @@ namespace MiscServices { auto size = reply.ReadInt32(); while (size > 0) { - KeyboardType* kt = reply.ReadParcelable(); + KeyboardType *kt = reply.ReadParcelable(); types->push_back(kt); size--; } diff --git a/interfaces/kits/js/declaration/api/@ohos.inputmethodability.d.ts b/interfaces/kits/js/declaration/api/@ohos.inputmethodability.d.ts index 6ef576dc..56e6b4ad 100644 --- a/interfaces/kits/js/declaration/api/@ohos.inputmethodability.d.ts +++ b/interfaces/kits/js/declaration/api/@ohos.inputmethodability.d.ts @@ -18,8 +18,7 @@ import { AsyncCallback } from './basic'; /** * inputmethod * - * @since 6 - * @import inputmethod from '@ohos.inputmethod'; + * @since 7 * @devices phone, tablet, tv, wearable */ declare namespace inputMethodAbility { diff --git a/interfaces/kits/js/napi/js_input_method_ability.cpp b/interfaces/kits/js/napi/js_input_method_ability.cpp index ac52fe42..bb8ef017 100644 --- a/interfaces/kits/js/napi/js_input_method_ability.cpp +++ b/interfaces/kits/js/napi/js_input_method_ability.cpp @@ -27,14 +27,14 @@ napi_value JS_Constructor(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, nullptr, nullptr, &thisVar, &data); - OHOS::MiscServices::EventTarget* imeAbility = new OHOS::MiscServices::EventTarget(env,thisVar); - napi_wrap(env, thisVar, imeAbility, + OHOS::MiscServices::EventTarget *eventTarget = new OHOS::MiscServices::EventTarget(env,thisVar); + napi_wrap(env, thisVar, eventTarget, [](napi_env env, void* data, void* hint){ - EventTarget* imeAbility = (EventTarget*)data; - delete imeAbility; + EventTarget *eventTarget = (EventTarget*)data; + delete eventTarget; }, nullptr, nullptr); - OHOS::sptr eventTarget_=imeAbility; + OHOS::sptr eventTarget_ = eventTarget; InputMethodAbility::GetInstance()->setEventTarget(eventTarget_); return thisVar; } @@ -48,8 +48,8 @@ napi_value JS_InsertText(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data); - EventTarget* imeAbility = nullptr; - napi_unwrap(env, thisVar, (void **)&imeAbility); + EventTarget *eventTarget = nullptr; + napi_unwrap(env, thisVar, (void **)&eventTarget); char type[64] = { 0 }; size_t typeLen = 0; @@ -72,8 +72,8 @@ napi_value JS_DeleteBackward(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data); - EventTarget* imeAbility = nullptr; - napi_unwrap(env, thisVar, (void **)&imeAbility); + EventTarget *eventTarget = nullptr; + napi_unwrap(env, thisVar, (void **)&eventTarget); int32_t value32 = 0; napi_get_value_int32(env, argv[0], &value32); @@ -93,8 +93,8 @@ napi_value JS_HideKeyboardSelf(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data); - EventTarget* imeAbility = nullptr; - napi_unwrap(env, thisVar, (void **)&imeAbility); + EventTarget *eventTarget = nullptr; + napi_unwrap(env, thisVar, (void **)&eventTarget); InputMethodAbility::GetInstance()->HideKeyboardSelf(); @@ -113,8 +113,8 @@ napi_value JS_On(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data); - EventTarget* imeAbility = nullptr; - napi_unwrap(env, thisVar, (void **)&imeAbility); + EventTarget *eventTarget = nullptr; + napi_unwrap(env, thisVar, (void **)&eventTarget); NAPI_ASSERT(env, argc >= requireArgc, "requires 2 parameter"); @@ -131,7 +131,7 @@ napi_value JS_On(napi_env env, napi_callback_info cbInfo) napi_get_value_string_utf8(env, argv[0], type, sizeof(type), &typeLen); IMSA_HILOGI("call ima on function"); - imeAbility->On((const char*)type, argv[1]); + eventTarget->On((const char*)type, argv[1]); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -148,8 +148,8 @@ napi_value JS_Off(napi_env env, napi_callback_info cbInfo) void* data = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data); - EventTarget* imeAbility = nullptr; - napi_unwrap(env, thisVar, (void **)&imeAbility); + EventTarget *eventTarget = nullptr; + napi_unwrap(env, thisVar, (void **)&eventTarget); NAPI_ASSERT(env, argc >= requireArgc, "requires 2 parameter"); @@ -165,10 +165,9 @@ napi_value JS_Off(napi_env env, napi_callback_info cbInfo) if (argc > requireArgc) { NAPI_ASSERT(env, eventValueType == napi_function, "type mismatch for parameter 2"); - - imeAbility->Off(type, argv[1]); + eventTarget->Off(type, argv[1]); } else { - imeAbility->Off(type); + eventTarget->Off(type); } delete type; diff --git a/services/include/i_input_control_channel.h b/services/include/i_input_control_channel.h index e317b55e..6472bf2c 100644 --- a/services/include/i_input_control_channel.h +++ b/services/include/i_input_control_channel.h @@ -35,7 +35,7 @@ namespace OHOS { DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputControlChannel"); - virtual void onAgentCreated(sptr& agent, InputChannel* channel) = 0; + virtual void onAgentCreated(sptr& agent, InputChannel *channel) = 0; virtual void hideKeyboardSelf(int flags) = 0; virtual bool advanceToNext(bool isCurrentIme) = 0; virtual void setDisplayMode(int mode) = 0; diff --git a/services/include/i_input_method_system_ability.h b/services/include/i_input_method_system_ability.h index df36ff29..ad5657d1 100644 --- a/services/include/i_input_method_system_ability.h +++ b/services/include/i_input_method_system_ability.h @@ -55,8 +55,8 @@ namespace MiscServices { virtual int32_t setInputMethodCore(sptr &core)=0; virtual int32_t getDisplayMode(int32_t *retMode) = 0; - virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) = 0; - virtual int32_t getCurrentKeyboardType(KeyboardType* retType) = 0; + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0; + virtual int32_t getCurrentKeyboardType(KeyboardType *retType) = 0; virtual int32_t listInputMethodEnabled(std::vector *properties) = 0; virtual int32_t listInputMethod(std::vector *properties) = 0; virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector *types) = 0; diff --git a/services/include/input_control_channel_proxy.h b/services/include/input_control_channel_proxy.h index 2a3b215a..fcb05d08 100644 --- a/services/include/input_control_channel_proxy.h +++ b/services/include/input_control_channel_proxy.h @@ -33,7 +33,7 @@ namespace MiscServices { InputControlChannelProxy(const sptr &impl); ~InputControlChannelProxy(); - virtual void onAgentCreated(sptr& agent, InputChannel* channel) override; + virtual void onAgentCreated(sptr& agent, InputChannel *channel) override; virtual void hideKeyboardSelf(int flags) override; virtual bool advanceToNext(bool isCurrentIme) override; virtual void setDisplayMode(int mode) override; diff --git a/services/include/input_control_channel_stub.h b/services/include/input_control_channel_stub.h index 9b042954..2db382e4 100644 --- a/services/include/input_control_channel_stub.h +++ b/services/include/input_control_channel_stub.h @@ -35,7 +35,7 @@ namespace OHOS { MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - virtual void onAgentCreated(sptr& agent, InputChannel* channel) override; + virtual void onAgentCreated(sptr& agent, InputChannel *channel) override; virtual void hideKeyboardSelf(int flags) override; virtual bool advanceToNext(bool isCurrentIme) override; virtual void setDisplayMode(int mode) override; @@ -47,12 +47,13 @@ namespace OHOS { private: int userId_; sptr agent = nullptr; - InputChannel* channel = nullptr; + InputChannel *channel = nullptr; std::mutex mtx; std::condition_variable cv; bool agentReadyFlag = false; bool keyboardReadyFlag = false; + const int32_t sleepTime = 300; }; } } diff --git a/services/include/input_method_ability_connection_stub.h b/services/include/input_method_ability_connection_stub.h index 87fa1126..2f41782e 100644 --- a/services/include/input_method_ability_connection_stub.h +++ b/services/include/input_method_ability_connection_stub.h @@ -35,10 +35,10 @@ namespace OHOS { void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; - void SetHandler(MessageHandler* handler); + void SetHandler(MessageHandler *handler); private: - MessageHandler* messageHandler; + MessageHandler *messageHandler; int mIndex; }; } diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index 09fb192f..b4cca32f 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -46,8 +46,8 @@ namespace MiscServices { int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; virtual int32_t getDisplayMode(int32_t *retMode) override; - virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) override; - virtual int32_t getCurrentKeyboardType(KeyboardType* retType) override; + virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; + virtual int32_t getCurrentKeyboardType(KeyboardType *retType) override; virtual int32_t listInputMethodEnabled(std::vector *properties) override; virtual int32_t listInputMethod(std::vector *properties) override; virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector *types) override; @@ -68,20 +68,20 @@ namespace MiscServices { std::map msgHandlers; void WorkThread(); - PerUserSetting* GetUserSetting(int32_t userId); - PerUserSession* GetUserSession(int32_t userId); - int32_t OnUserStarted(const Message* msg); - int32_t OnUserStopped(const Message* msg); - int32_t OnUserUnlocked(const Message* msg); - int32_t OnUserLocked(const Message* msg); - int32_t OnPrepareInput(Message* msg); - int32_t OnHandleMessage(Message* msg); - int32_t OnRemotePeerDied(const Message* msg); - int32_t OnSettingChanged(const Message* msg); - int32_t OnPackageRemoved(const Message* msg); - int32_t OnPackageAdded(const Message* msg); - int32_t OnDisableIms(const Message* msg); - int32_t OnAdvanceToNext(const Message* msg); + PerUserSetting *GetUserSetting(int32_t userId); + PerUserSession *GetUserSession(int32_t userId); + int32_t OnUserStarted(const Message *msg); + int32_t OnUserStopped(const Message *msg); + int32_t OnUserUnlocked(const Message *msg); + int32_t OnUserLocked(const Message *msg); + int32_t OnPrepareInput(Message *msg); + int32_t OnHandleMessage(Message *msg); + int32_t OnRemotePeerDied(const Message *msg); + int32_t OnSettingChanged(const Message *msg); + int32_t OnPackageRemoved(const Message *msg); + int32_t OnPackageAdded(const Message *msg); + int32_t OnDisableIms(const Message *msg); + int32_t OnAdvanceToNext(const Message *msg); ServiceRunningState state_; sptr inputMethodAbility_; diff --git a/services/include/message.h b/services/include/message.h index 5116e9dd..be4330b0 100644 --- a/services/include/message.h +++ b/services/include/message.h @@ -25,7 +25,7 @@ namespace MiscServices { public: int32_t msgId_; // message id MessageParcel *msgContent_ = nullptr; // message content - Message(int32_t msgId, MessageParcel* msgContent); + Message(int32_t msgId, MessageParcel *msgContent); explicit Message(const Message& msg); Message& operator= (const Message& msg); ~Message(); diff --git a/services/include/message_handler.h b/services/include/message_handler.h index b47d1562..6295cd98 100644 --- a/services/include/message_handler.h +++ b/services/include/message_handler.h @@ -80,9 +80,9 @@ class MessageHandler { public: MessageHandler(); ~MessageHandler(); - void SendMessage(Message* msg); - Message* GetMessage(); - static MessageHandler* Instance(); + void SendMessage(Message *msg); + Message *GetMessage(); + static MessageHandler *Instance(); private: std::mutex mMutex; // a mutex to guard message queue diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index 69b27ff5..ea0b7997 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -100,15 +100,15 @@ namespace MiscServices { explicit PerUserSession(int userId); ~PerUserSession(); - void SetCurrentIme(InputMethodProperty* ime); - void SetSecurityIme(InputMethodProperty* ime); - void SetInputMethodSetting(InputMethodSetting* setting); - void ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme); + void SetCurrentIme(InputMethodProperty *ime); + void SetSecurityIme(InputMethodProperty *ime); + void SetInputMethodSetting(InputMethodSetting *setting); + void ResetIme(InputMethodProperty *defaultIme, InputMethodProperty *securityIme); void OnPackageRemoved(const std::u16string& packageName); int GetDisplayMode(); - int GetKeyboardWindowHeight(int *retHeight); - KeyboardType* GetCurrentKeyboardType(); + int GetKeyboardWindowHeight(int retHeight); + KeyboardType *GetCurrentKeyboardType(); int OnSettingChanged(const std::u16string& key, const std::u16string& value); void Dump(int fd); @@ -123,25 +123,25 @@ namespace MiscServices { int currentIndex; std::map, ClientInfo*> mapClients; - InputMethodProperty* currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime + InputMethodProperty *currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime - InputControlChannelStub* localControlChannel[MAX_IME]; + InputControlChannelStub *localControlChannel[MAX_IME]; sptr inputControlChannel[MAX_IME]; sptr imsCore[MAX_IME]; // the remote handlers of input method service sptr inputMethodToken[MAX_IME]; // the window token of keyboard int currentKbdIndex[MAX_IME]; // current keyboard index int lastImeIndex; // The last ime which showed keyboard - InputMethodSetting* inputMethodSetting; // The pointer referred to the object in PerUserSetting + InputMethodSetting *inputMethodSetting; // The pointer referred to the object in PerUserSetting int currentDisplayMode; // the display mode of the current keyboard sptr imsAgent; - InputChannel* imsChannel; // the write channel created by input method service + InputChannel *imsChannel; // the write channel created by input method service sptr currentClient; // the current input client sptr needReshowClient; // the input client for which keyboard need to re-show sptr clientDeathRecipient; // remote object death monitor for input client sptr imsDeathRecipient; - MessageHandler* msgHandler = nullptr; // message handler working with Work Thread + MessageHandler *msgHandler = nullptr; // message handler working with Work Thread std::thread workThreadHandler; // work thread handler std::mutex mtx; // mutex to lock the operations among multi work threads sptr connCallback; @@ -152,18 +152,18 @@ namespace MiscServices { PerUserSession(const PerUserSession&&); PerUserSession& operator= (const PerUserSession&&); int IncreaseOrResetImeError(bool resetFlag, int imeIndex); - KeyboardType* GetKeyboardType(int imeIndex, int typeIndex); + KeyboardType *GetKeyboardType(int imeIndex, int typeIndex); void ResetCurrentKeyboardType(int imeIndex); int OnCurrentKeyboardTypeChanged(int index, const std::u16string& value); void DumpClientInfo(int fd, const ClientInfo& clientInfo); void DumpCurrentSession(int fd); void CopyInputMethodService(int imeIndex); - ClientInfo* GetClientInfo(const sptr& inputClient); + ClientInfo *GetClientInfo(const sptr& inputClient); void WorkThread(); - void OnPrepareInput(Message* msg); - void OnReleaseInput(Message* msg); - void OnStartInput(Message* msg); - void OnStopInput(Message* msg); + void OnPrepareInput(Message *msg); + void OnReleaseInput(Message *msg); + void OnStartInput(Message *msg); + void OnStopInput(Message *msg); void OnClientDied(const wptr& who); void OnImsDied(const wptr& who); void OnHideKeyboardSelf(int flags); @@ -182,7 +182,7 @@ namespace MiscServices { void SetDisplayId(int displayId); int GetImeIndex(const sptr& inputClient); static sptr GetAbilityManagerService(); - void onSetInputMethodCore(Message* msg); + void onSetInputMethodCore(Message *msg); }; } } diff --git a/services/include/peruser_setting.h b/services/include/peruser_setting.h index 65ccda84..fe101358 100644 --- a/services/include/peruser_setting.h +++ b/services/include/peruser_setting.h @@ -33,14 +33,14 @@ namespace MiscServices { void Initialize(); int32_t GetUserState(); - InputMethodProperty* GetCurrentInputMethod(); - InputMethodProperty* GetSecurityInputMethod(); - InputMethodProperty* GetNextInputMethod(); - InputMethodSetting* GetInputMethodSetting(); - InputMethodProperty* GetInputMethodProperty(const std::u16string& imeId); + InputMethodProperty *GetCurrentInputMethod(); + InputMethodProperty *GetSecurityInputMethod(); + InputMethodProperty *GetNextInputMethod(); + InputMethodSetting *GetInputMethodSetting(); + InputMethodProperty *GetInputMethodProperty(const std::u16string& imeId); - int32_t OnPackageAdded(std::u16string& packageName, bool* isSecurityIme = nullptr); - int32_t OnPackageRemoved(std::u16string& packageName, bool* isSecurityIme = nullptr); + int32_t OnPackageAdded(std::u16string& packageName, bool isSecurityIme); + int32_t OnPackageRemoved(std::u16string& packageName, bool isSecurityIme); int32_t OnSettingChanged(const std::u16string& key, const std::u16string& value); void OnAdvanceToNext(); void OnUserLocked(); @@ -65,7 +65,7 @@ namespace MiscServices { PerUserSetting& operator= (const PerUserSetting&&); void InitInputMethodSetting(); void ResetCurrentInputMethod(); - std::u16string GetKeyboardTypeLanguage(const InputMethodProperty* property, int32_t hashCode); + std::u16string GetKeyboardTypeLanguage(const InputMethodProperty *property, int32_t hashCode); std::u16string GetImeId(const std::u16string& packageName); }; } diff --git a/services/include/platform.h b/services/include/platform.h index 2799fb86..8fef1efb 100644 --- a/services/include/platform.h +++ b/services/include/platform.h @@ -30,17 +30,17 @@ namespace OHOS { namespace MiscServices { class Platform { public: - static Platform* Instance(); + static Platform *Instance(); void SetPlatform(const sptr& platformApi); sptr BindInputMethodService(int userId, const std::u16string& packageName, const std::u16string& intention); int UnbindInputMethodService(int userId, const std::u16string& packageName); sptr CreateWindowToken(int userId, int displayId, const std::u16string& packageName); int DestroyWindowToken(int userId, const std::u16string& packageName); - int ListInputMethod(int userId, std::vector* properties); + int ListInputMethod(int userId, std::vector *properties); int GetInputMethodProperty(int userId, const std::u16string& packageName, - InputMethodProperty* inputMethodProperty); - int GetInputMethodSetting(int userId, InputMethodSetting* inputMethodSetting); + InputMethodProperty *inputMethodProperty); + int GetInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting); int SetInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting); bool CheckPhysicalKeyboard(); bool IsValidWindow(int uid, int pid, int displayId); diff --git a/services/src/global.cpp b/services/src/global.cpp index fa5ba8c7..41b8c237 100644 --- a/services/src/global.cpp +++ b/services/src/global.cpp @@ -29,7 +29,7 @@ namespace MiscServices { } namespace ErrorCode { - const char* ToString(int errorCode) + const char *ToString(int errorCode) { switch (errorCode) { case NO_ERROR: { diff --git a/services/src/input_attribute.cpp b/services/src/input_attribute.cpp index aee33ade..2a06b2bc 100644 --- a/services/src/input_attribute.cpp +++ b/services/src/input_attribute.cpp @@ -59,7 +59,8 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - bool InputAttribute::Marshalling(OHOS::Parcel &parcel) const { + bool InputAttribute::Marshalling(OHOS::Parcel &parcel) const + { if (!(parcel.WriteInt32(inputPattern) && parcel.WriteInt32(enterKeyType) && parcel.WriteInt32(inputOption))) @@ -72,7 +73,8 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - InputAttribute* InputAttribute::Unmarshalling(OHOS::Parcel &parcel) { + InputAttribute *InputAttribute::Unmarshalling(OHOS::Parcel &parcel) + { auto info = new InputAttribute(); info->inputPattern = parcel.ReadInt32(); info->enterKeyType = parcel.ReadInt32(); diff --git a/services/src/input_channel.cpp b/services/src/input_channel.cpp index 88823c81..d39ea3a4 100644 --- a/services/src/input_channel.cpp +++ b/services/src/input_channel.cpp @@ -36,7 +36,8 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - bool InputChannel::Marshalling(Parcel &parcel) const { + bool InputChannel::Marshalling(Parcel &parcel) const + { parcel.ParseFrom(inputChannelParcel.GetData(), inputChannelParcel.GetDataSize()); return NO_ERROR; } @@ -46,7 +47,8 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - InputChannel* InputChannel::Unmarshalling(Parcel &parcel) { + InputChannel *InputChannel::Unmarshalling(Parcel &parcel) + { auto inputChannel = new InputChannel(); inputChannel->inputChannelParcel.RewindRead(0); inputChannel->inputChannelParcel.ParseFrom(parcel.GetData(), parcel.GetDataSize()); diff --git a/services/src/input_control_channel_proxy.cpp b/services/src/input_control_channel_proxy.cpp index 22c83960..e31b82af 100644 --- a/services/src/input_control_channel_proxy.cpp +++ b/services/src/input_control_channel_proxy.cpp @@ -32,14 +32,15 @@ namespace OHOS { namespace MiscServices { InputControlChannelProxy::InputControlChannelProxy(const sptr &impl) - : IRemoteProxy(impl) { + : IRemoteProxy(impl) + { } InputControlChannelProxy::~InputControlChannelProxy() { } - void InputControlChannelProxy::onAgentCreated(sptr &agent, InputChannel* channel) + void InputControlChannelProxy::onAgentCreated(sptr &agent, InputChannel *channel) { IMSA_HILOGI("InputControlChannelProxy::onAgentCreated start."); MessageParcel data, reply; @@ -101,5 +102,3 @@ namespace MiscServices { } } } - - diff --git a/services/src/input_control_channel_stub.cpp b/services/src/input_control_channel_stub.cpp index 0c943558..4aa7fa90 100644 --- a/services/src/input_control_channel_stub.cpp +++ b/services/src/input_control_channel_stub.cpp @@ -23,234 +23,235 @@ #include "message_parcel.h" namespace OHOS { - namespace MiscServices { - /*! Constructor - \param userId the id of the user to whom the object is linking - */ - InputControlChannelStub::InputControlChannelStub(int userId) - { - userId_ = userId; +namespace MiscServices { + /*! Constructor + \param userId the id of the user to whom the object is linking + */ + InputControlChannelStub::InputControlChannelStub(int userId) + { + userId_ = userId; + } + + /*! Destructor + */ + InputControlChannelStub::~InputControlChannelStub() + { + } + + /*! Handle the transaction from the remote binder + \n Run in binder thread + \param code transaction code number + \param data the params from remote binder + \param[out] reply the result of the transaction replied to the remote binder + \param flags the flags of handling transaction + \return int32_t + */ + int32_t InputControlChannelStub::OnRemoteRequest(uint32_t code, MessageParcel& data, + MessageParcel& reply, MessageOption& option) + { + IMSA_HILOGI("InputControlChannelStub::OnRemoteRequest code = %{public}u", code); + auto descriptorToken = data.ReadInterfaceToken(); + if (descriptorToken != GetDescriptor()) { + return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION; } + switch (code) { + case ON_AGENT_CREATED: { + sptr proxy = new InputMethodAgentProxy(data.ReadRemoteObject()); + sptr agent = proxy; - /*! Destructor - */ - InputControlChannelStub::~InputControlChannelStub() { - } - - /*! Handle the transaction from the remote binder - \n Run in binder thread - \param code transaction code number - \param data the params from remote binder - \param[out] reply the result of the transaction replied to the remote binder - \param flags the flags of handling transaction - \return int32_t - */ - int32_t InputControlChannelStub::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) - { - IMSA_HILOGI("InputControlChannelStub::OnRemoteRequest code = %{public}u", code); - auto descriptorToken = data.ReadInterfaceToken(); - if (descriptorToken != GetDescriptor()) { - return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION; - } - switch (code) { - case ON_AGENT_CREATED: { - sptr proxy = new InputMethodAgentProxy(data.ReadRemoteObject()); - sptr agent = proxy; - - InputChannel* channel = nullptr; - if (data.ReadInt32() > 0) { - channel = data.ReadParcelable(); - } - onAgentCreated(agent, channel); - reply.WriteNoException(); - break; - } - case HIDE_KEYBOARD_SELF: { - int flag = data.ReadInt32(); - hideKeyboardSelf(flag); - reply.WriteNoException(); - break; - } - case ADVANCE_TO_NEXT: { - bool isCurrentIme = data.ReadInt32(); - bool ret = advanceToNext(isCurrentIme); - reply.WriteNoException(); - reply.WriteBool(ret); - break; - } - case SET_DISPLAY_MODE: { - int mode = data.ReadInt32(); - setDisplayMode(mode); - reply.WriteNoException(); - break; - } - case ON_KEYBOARD_SHOWED: { - onKeyboardShowed(); - reply.WriteNoException(); - break; - } - default: { - return IRemoteStub::OnRemoteRequest(code, data, reply, option); + InputChannel *channel = nullptr; + if (data.ReadInt32() > 0) { + channel = data.ReadParcelable(); } + onAgentCreated(agent, channel); + reply.WriteNoException(); + break; } - return NO_ERROR; - } - - - /*! Called when input method service creates InputMethodAgentProxy - \n This call is running in binder thread - \param agent the remote handler from input method service, with which input client can remotely callback to - input method service - \param channel channel for sending physical keyboard event from input client to input method service - */ - void InputControlChannelStub::onAgentCreated(sptr < IInputMethodAgent >& agent, InputChannel* channel) - { - IMSA_HILOGI("InputControlChannelStub::onAgentCreated"); - { - std::unique_lock < std::mutex > lck(mtx); - agentReadyFlag = true; + case HIDE_KEYBOARD_SELF: { + int flag = data.ReadInt32(); + hideKeyboardSelf(flag); + reply.WriteNoException(); + break; } - this->agent = agent; - this->channel = channel; - cv.notify_one(); - } - - /*! Called when input method service showed keyboard - \n This call is running in binder thread - */ - void InputControlChannelStub::onKeyboardShowed() - { - IMSA_HILOGI("InputControlChannelStub::onKeyboardShowed"); - { - std::unique_lock < std::mutex > lck(mtx); - keyboardReadyFlag = true; + case ADVANCE_TO_NEXT: { + bool isCurrentIme = data.ReadInt32(); + bool ret = advanceToNext(isCurrentIme); + reply.WriteNoException(); + reply.WriteBool(ret); + break; } - cv.notify_one(); - } - - /*! Send hideKeyboardSelf command to work thread. - \n This call is running in binder thread, - but the handling of hideKeyboardSelf is in the work thread of PerUserSession. - \see PerUserSession::OnHideKeyboardSelf - \param flags the flag value of hiding keyboard - */ - void InputControlChannelStub::hideKeyboardSelf(int flags) - { - IMSA_HILOGI("InputControlChannelStub::hideKeyboardSelf flags = %{public}d", flags); - MessageParcel* parcel = new MessageParcel(); - parcel->WriteInt32(userId_); - parcel->WriteInt32(flags); - - Message* msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, parcel); - MessageHandler::Instance()->SendMessage(msg); - } - - /*! Send advanceToNext command to work thread. - \n This call is running in binder thread, - but the handling of advanceToNext is in the work thread of InputMethodSystemAbility service - \n or in the work thread of PerUserSession - \see InputMethodSystemAbility::OnAdvanceToNext PerUserSession::OnAdvanceToNext - \see PerUserSetting::OnAdvanceToNext - \param isCurrentIme true - switch to next keyboard type within current input method engine - \n false - switch to next input method engine - \return true - */ - bool InputControlChannelStub::advanceToNext(bool isCurrentIme) - { - IMSA_HILOGI("InputControlChannelStub::advanceToNext"); - MessageParcel* parcel = new MessageParcel(); - parcel->WriteInt32(userId_); - parcel->WriteBool(isCurrentIme); - - Message* msg = new Message(MessageID::MSG_ID_ADVANCE_TO_NEXT, parcel); - MessageHandler::Instance()->SendMessage(msg); - return true; - } - - /*! Send setDisplayMode command to work thread. - \n This call is running in binder thread, - but the handling of setDisplayMode is in the work thread of PerUserSession. - \see PerUserSession::OnSetDisplayMode - \param mode 0 - part screen mode, 1 - full screen mode - */ - void InputControlChannelStub::setDisplayMode(int mode) - { - IMSA_HILOGI("InputControlChannelStub::setDisplayMode start"); - MessageParcel* parcel = new MessageParcel(); - parcel->WriteInt32(userId_); - parcel->WriteInt32(mode); - - Message* msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel); - MessageHandler::Instance()->SendMessage(msg); - } - - /*! Reset ready flag to be false - \n This should be called before imsCore->startInput() in work thread of PerUserSession - */ - void InputControlChannelStub::ResetFlag() - { - IMSA_HILOGI("InputControlChannelStub::ResetFlag"); - std::unique_lock < std::mutex > lck(mtx); - keyboardReadyFlag = false; - agentReadyFlag = false; - if (agent) { - agent = nullptr; + case SET_DISPLAY_MODE: { + int mode = data.ReadInt32(); + setDisplayMode(mode); + reply.WriteNoException(); + break; } - if (channel) { - delete channel; - channel = nullptr; + case ON_KEYBOARD_SHOWED: { + onKeyboardShowed(); + reply.WriteNoException(); + break; + } + default: { + return IRemoteStub::OnRemoteRequest(code, data, reply, option); } } - /*! Get input method agent and input write channel - \n This should be called in work thread of PerUserSession - \param[out] retAgent remote handler of InputMethodAgentProxy returned to the caller - \param[out] retChannel input write channel returned to caller - \return true - onAgentCreated is called by input method service in time - \n false - onAgentCreated is not called by input method service in time - */ - bool InputControlChannelStub::GetAgentAndChannel(sptr* retAgent, InputChannel** retChannel) - { - IMSA_HILOGI("InputControlChannelStub::GetAgentAndChannel"); - std::chrono::milliseconds millsec(300); - bool ret = false; - { - std::unique_lock < std::mutex > lck(mtx); - ret = cv.wait_for(lck, millsec, [this] { - return agentReadyFlag; - }); - } - if (ret) { - if (retAgent) { - *retAgent = agent; - agent = nullptr; - } - if (retChannel) { - *retChannel = channel; - channel = nullptr; - } - return true; - } - return false; - } + return NO_ERROR; + } - /*! Wait for keyboard to be ready - \n This should be called in work thread of PerUserSession - \return true - onKeyboardShowed is called by input method service in time - \n false - onKeyboardShowed is not called by input method service in time - */ - bool InputControlChannelStub::WaitKeyboardReady() + + /*! Called when input method service creates InputMethodAgentProxy + \n This call is running in binder thread + \param agent the remote handler from input method service, with which input client can remotely callback to + input method service + \param channel channel for sending physical keyboard event from input client to input method service + */ + void InputControlChannelStub::onAgentCreated(sptr < IInputMethodAgent >& agent, InputChannel *channel) +{ + IMSA_HILOGI("InputControlChannelStub::onAgentCreated"); { - IMSA_HILOGI("InputControlChannelStub::WaitKeyboardReady"); - std::chrono::milliseconds millsec(300); - bool ret = false; - { - std::unique_lock < std::mutex > lck(mtx); - ret = cv.wait_for(lck, millsec, [this] { - return keyboardReadyFlag; - }); - } - return ret; + std::unique_lock lck(mtx); + agentReadyFlag = true; + } + this->agent = agent; + this->channel = channel; + cv.notify_one(); + } + + /*! Called when input method service showed keyboard + \n This call is running in binder thread + */ + void InputControlChannelStub::onKeyboardShowed() + { + IMSA_HILOGI("InputControlChannelStub::onKeyboardShowed"); + { + std::unique_lock lck(mtx); + keyboardReadyFlag = true; + } + cv.notify_one(); + } + + /*! Send hideKeyboardSelf command to work thread. + \n This call is running in binder thread, + but the handling of hideKeyboardSelf is in the work thread of PerUserSession. + \see PerUserSession::OnHideKeyboardSelf + \param flags the flag value of hiding keyboard + */ + void InputControlChannelStub::hideKeyboardSelf(int flags) + { + IMSA_HILOGI("InputControlChannelStub::hideKeyboardSelf flags = %{public}d", flags); + MessageParcel *parcel = new MessageParcel(); + parcel->WriteInt32(userId_); + parcel->WriteInt32(flags); + + Message *msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, parcel); + MessageHandler::Instance()->SendMessage(msg); + } + + /*! Send advanceToNext command to work thread. + \n This call is running in binder thread, + but the handling of advanceToNext is in the work thread of InputMethodSystemAbility service + \n or in the work thread of PerUserSession + \see InputMethodSystemAbility::OnAdvanceToNext PerUserSession::OnAdvanceToNext + \see PerUserSetting::OnAdvanceToNext + \param isCurrentIme true - switch to next keyboard type within current input method engine + \n false - switch to next input method engine + \return true + */ + bool InputControlChannelStub::advanceToNext(bool isCurrentIme) + { + IMSA_HILOGI("InputControlChannelStub::advanceToNext"); + MessageParcel *parcel = new MessageParcel(); + parcel->WriteInt32(userId_); + parcel->WriteBool(isCurrentIme); + + Message *msg = new Message(MessageID::MSG_ID_ADVANCE_TO_NEXT, parcel); + MessageHandler::Instance()->SendMessage(msg); + return true; + } + + /*! Send setDisplayMode command to work thread. + \n This call is running in binder thread, + but the handling of setDisplayMode is in the work thread of PerUserSession. + \see PerUserSession::OnSetDisplayMode + \param mode 0 - part screen mode, 1 - full screen mode + */ + void InputControlChannelStub::setDisplayMode(int mode) + { + IMSA_HILOGI("InputControlChannelStub::setDisplayMode start"); + MessageParcel *parcel = new MessageParcel(); + parcel->WriteInt32(userId_); + parcel->WriteInt32(mode); + + Message *msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel); + MessageHandler::Instance()->SendMessage(msg); + } + + /*! Reset ready flag to be false + \n This should be called before imsCore->startInput() in work thread of PerUserSession + */ + void InputControlChannelStub::ResetFlag() + { + IMSA_HILOGI("InputControlChannelStub::ResetFlag"); + std::unique_lock lck(mtx); + keyboardReadyFlag = false; + agentReadyFlag = false; + if (agent) { + agent = nullptr; + } + if (channel) { + delete channel; + channel = nullptr; } } + /*! Get input method agent and input write channel + \n This should be called in work thread of PerUserSession + \param[out] retAgent remote handler of InputMethodAgentProxy returned to the caller + \param[out] retChannel input write channel returned to caller + \return true - onAgentCreated is called by input method service in time + \n false - onAgentCreated is not called by input method service in time + */ + bool InputControlChannelStub::GetAgentAndChannel(sptr *retAgent, InputChannel **retChannel) + { + IMSA_HILOGI("InputControlChannelStub::GetAgentAndChannel"); + std::chrono::milliseconds millsec(sleepTime); + bool ret = false; + { + std::unique_lock lck(mtx); + ret = cv.wait_for(lck, millsec, [this] { + return agentReadyFlag; + }); + } + if (ret) { + if (retAgent) { + *retAgent = agent; + agent = nullptr; + } + if (retChannel) { + *retChannel = channel; + channel = nullptr; + } + return true; + } + return false; + } + + /*! Wait for keyboard to be ready + \n This should be called in work thread of PerUserSession + \return true - onKeyboardShowed is called by input method service in time + \n false - onKeyboardShowed is not called by input method service in time + */ + bool InputControlChannelStub::WaitKeyboardReady() + { + IMSA_HILOGI("InputControlChannelStub::WaitKeyboardReady"); + std::chrono::milliseconds millsec(sleepTime); + bool ret = false; + { + std::unique_lock lck(mtx); + ret = cv.wait_for(lck, millsec, [this] { + return keyboardReadyFlag; + }); + } + return ret; + } +} } \ No newline at end of file diff --git a/services/src/input_method_ability_connection_stub.cpp b/services/src/input_method_ability_connection_stub.cpp index 4bc709f9..e466de58 100644 --- a/services/src/input_method_ability_connection_stub.cpp +++ b/services/src/input_method_ability_connection_stub.cpp @@ -18,43 +18,46 @@ #include "message.h" namespace OHOS { - namespace MiscServices { - InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index){ - mIndex = index; - } - - InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub(){ - - } - - void InputMethodAbilityConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName &element, - const sptr &remoteObject, int resultCode){ - IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone."); - if(messageHandler != nullptr){ - MessageParcel* data = new MessageParcel(); - data->WriteParcelable(&element); - data->WriteRemoteObject(remoteObject); - data->WriteInt32(mIndex); - Message* msg = new Message(MessageID::MSG_ID_ABILITY_CONNECT_DONE, data); - messageHandler->SendMessage(msg); - } - } - - void InputMethodAbilityConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, - int resultCode) { - IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone."); - if(messageHandler != nullptr){ - MessageParcel* data = new MessageParcel(); - data->WriteParcelable(&element); - data->WriteInt32(mIndex); - Message* msg = new Message(MessageID::MSG_ID_ABILITY_DISCONNECT_DONE, data); - messageHandler->SendMessage(msg); - } - } - - void InputMethodAbilityConnectionStub::SetHandler(MessageHandler* handler){ - messageHandler = handler; - } - +namespace MiscServices { + InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index) + { + mIndex = index; } + + InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub() + { + } + + void InputMethodAbilityConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName &element, + const sptr &remoteObject, int resultCode) + { + IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone."); + if(messageHandler != nullptr){ + MessageParcel *data = new MessageParcel(); + data->WriteParcelable(&element); + data->WriteRemoteObject(remoteObject); + data->WriteInt32(mIndex); + Message *msg = new Message(MessageID::MSG_ID_ABILITY_CONNECT_DONE, data); + messageHandler->SendMessage(msg); + } + } + + void InputMethodAbilityConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, + int resultCode) + { + IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone."); + if(messageHandler != nullptr){ + MessageParcel *data = new MessageParcel(); + data->WriteParcelable(&element); + data->WriteInt32(mIndex); + Message *msg = new Message(MessageID::MSG_ID_ABILITY_DISCONNECT_DONE, data); + messageHandler->SendMessage(msg); + } + } + + void InputMethodAbilityConnectionStub::SetHandler(MessageHandler *handler) + { + messageHandler = handler; + } +} } \ No newline at end of file diff --git a/services/src/input_method_agent_proxy.cpp b/services/src/input_method_agent_proxy.cpp index 80a35550..bd248348 100644 --- a/services/src/input_method_agent_proxy.cpp +++ b/services/src/input_method_agent_proxy.cpp @@ -24,25 +24,25 @@ This class should be implemented by input client */ namespace OHOS { - namespace MiscServices { - class InputMethodAgentProxy : public IRemoteProxy { - public: - InputMethodAgentProxy(const sptr& impl) - : IRemoteProxy(impl) - { - } +namespace MiscServices { + class InputMethodAgentProxy : public IRemoteProxy { + public: + InputMethodAgentProxy(const sptr& impl) + : IRemoteProxy(impl) + { + } - ~InputMethodAgentProxy() - { - } + ~InputMethodAgentProxy() + { + } - int32_t dispatchKey(int key, int status) - { - (void)key; - (void)status; - return NO_ERROR; - } - }; - } + int32_t dispatchKey(int key, int status) + { + (void)key; + (void)status; + return NO_ERROR; + } + }; +} } diff --git a/services/src/input_method_property.cpp b/services/src/input_method_property.cpp index 1c8bbb84..6c92c585 100644 --- a/services/src/input_method_property.cpp +++ b/services/src/input_method_property.cpp @@ -47,7 +47,7 @@ namespace MiscServices { mDefaultImeId = property.mDefaultImeId; for(int i = 0; i < (int)mTypes.size(); i++) { - KeyboardType* type = new KeyboardType(*property.mTypes[i]); + KeyboardType *type = new KeyboardType(*property.mTypes[i]); mTypes.push_back(type); } } @@ -69,7 +69,7 @@ namespace MiscServices { mDefaultImeId = property.mDefaultImeId; for(int i = 0; i < (int)mTypes.size(); i++) { - KeyboardType* type = new KeyboardType(*property.mTypes[i]); + KeyboardType *type = new KeyboardType(*property.mTypes[i]); mTypes.push_back(type); } return *this; @@ -104,7 +104,7 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - InputMethodProperty* InputMethodProperty::Unmarshalling(Parcel &parcel) + InputMethodProperty *InputMethodProperty::Unmarshalling(Parcel &parcel) { auto info = new InputMethodProperty(); info->mImeId = parcel.ReadString16(); diff --git a/services/src/input_method_setting.cpp b/services/src/input_method_setting.cpp index c80e6382..8e254a13 100644 --- a/services/src/input_method_setting.cpp +++ b/services/src/input_method_setting.cpp @@ -62,7 +62,8 @@ namespace MiscServices { \param[out] parcel the setting data is written to parcel returned to caller. \return ErrorCode::NO_ERROR */ - bool InputMethodSetting::Marshalling(OHOS::Parcel &parcel) const { + bool InputMethodSetting::Marshalling(OHOS::Parcel &parcel) const + { int32_t size = setting.size(); parcel.WriteInt32(size); std::map::const_iterator it; @@ -77,7 +78,8 @@ namespace MiscServices { \param parcel read the setting data from the given parcel \return ErrorCode::NO_ERROR */ - InputMethodSetting* InputMethodSetting::Unmarshalling(OHOS::Parcel &parcel) { + InputMethodSetting *InputMethodSetting::Unmarshalling(OHOS::Parcel &parcel) + { auto ims = new InputMethodSetting(); int32_t size = parcel.ReadInt32(); for(int i = 0; i < size; i++) { @@ -339,4 +341,4 @@ namespace MiscServices { return retValue; } } -} +} \ No newline at end of file diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 6125c198..e997b114 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -158,8 +158,8 @@ namespace MiscServices { workThreadHandler = std::thread([this] { WorkThread(); }); - PerUserSetting* setting=new PerUserSetting(0); - PerUserSession* session=new PerUserSession(0); + PerUserSetting *setting=new PerUserSetting(0); + PerUserSession *session=new PerUserSession(0); userSettings.insert(std::pair(0,setting)); userSessions.insert(std::pair(0,session)); @@ -204,7 +204,7 @@ namespace MiscServices { { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -219,11 +219,11 @@ namespace MiscServices { \return ErrorCode::NO_ERROR no error \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::getKeyboardWindowHeight(int32_t *retHeight) + int32_t InputMethodSystemAbility::getKeyboardWindowHeight(int32_t retHeight) { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -243,17 +243,17 @@ namespace MiscServices { \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked \return ErrorCode::ERROR_NULL_POINTER current keyboard type is null */ - int32_t InputMethodSystemAbility::getCurrentKeyboardType(KeyboardType* retType) + int32_t InputMethodSystemAbility::getCurrentKeyboardType(KeyboardType *retType) { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } - KeyboardType* type = GetUserSession(userId)->GetCurrentKeyboardType(); + KeyboardType *type = GetUserSession(userId)->GetCurrentKeyboardType(); if (type == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -267,10 +267,11 @@ namespace MiscServices { \return ErrorCode::NO_ERROR no error \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::listInputMethodEnabled(std::vector *properties) { + int32_t InputMethodSystemAbility::listInputMethodEnabled(std::vector *properties) + { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -298,7 +299,7 @@ namespace MiscServices { { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -326,7 +327,7 @@ namespace MiscServices { { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -352,7 +353,7 @@ namespace MiscServices { int32_t index = 0; dprintf(fd, "* User count = %d\n", userSettings.size()); for(it=userSettings.cbegin(); it!=userSettings.cend(); ++it) { - PerUserSetting* setting = it->second; + PerUserSetting *setting = it->second; int32_t userId = it->first; int32_t userState = setting->GetUserState(); if (userState == UserState::USER_STATE_STARTED) { @@ -360,7 +361,7 @@ namespace MiscServices { } else if (userState == UserState::USER_STATE_UNLOCKED) { dprintf(fd, "[%d] User information: UserId = %d, UserState = USER_STATE_UNLOCKED\n", index++, userId); setting->Dump(fd); - PerUserSession* session = GetUserSession(userId); + PerUserSession *session = GetUserSession(userId); session->Dump(fd); } dprintf(fd, "\n"); @@ -375,7 +376,7 @@ namespace MiscServices { \return a pointer of the instance if the user is found \return null if the user is not found */ - PerUserSetting* InputMethodSystemAbility::GetUserSetting(int32_t userId) + PerUserSetting *InputMethodSystemAbility::GetUserSetting(int32_t userId) { std::map::iterator it = userSettings.find(userId); if (it == userSettings.end()) { @@ -389,7 +390,7 @@ namespace MiscServices { \return a pointer of the instance if the user is found \return null if the user is not found */ - PerUserSession* InputMethodSystemAbility::GetUserSession(int32_t userId) + PerUserSession *InputMethodSystemAbility::GetUserSession(int32_t userId) { std::map::iterator it = userSessions.find(userId); if (it == userSessions.end()) { @@ -404,7 +405,7 @@ namespace MiscServices { void InputMethodSystemAbility::WorkThread() { while(1){ - Message* msg = MessageHandler::Instance()->GetMessage(); + Message *msg = MessageHandler::Instance()->GetMessage(); switch(msg->msgId_) { case MSG_ID_USER_START : { OnUserStarted(msg); @@ -462,7 +463,7 @@ namespace MiscServices { std::map::const_iterator it; for(it=msgHandlers.cbegin(); it!=msgHandlers.cend();) { MessageHandler *handler = it->second; - Message* destMsg = new Message(MSG_ID_EXIT_SERVICE, nullptr); + Message *destMsg = new Message(MSG_ID_EXIT_SERVICE, nullptr); handler->SendMessage(destMsg); GetUserSession(it->first)->JoinWorkThread(); it = msgHandlers.erase(it); @@ -483,7 +484,7 @@ namespace MiscServices { \param msg the parameters are saved in msg->msgContent_ \return ErrorCode */ - int32_t InputMethodSystemAbility::OnUserStarted(const Message* msg) + int32_t InputMethodSystemAbility::OnUserStarted(const Message *msg) { IMSA_HILOGI("Start...\n"); if (msg->msgContent_ == nullptr) { @@ -491,14 +492,14 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } int32_t userId = msg->msgContent_->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting != nullptr) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_ALREADY_STARTED), userId); return ErrorCode::ERROR_USER_ALREADY_STARTED; } setting = new PerUserSetting(userId); - PerUserSession* session = new PerUserSession(userId); + PerUserSession *session = new PerUserSession(userId); userSettings.insert(std::pair(userId, setting)); userSessions.insert(std::pair(userId, session)); @@ -511,7 +512,7 @@ namespace MiscServices { \param msg the parameters are saved in msg->msgContent_ \return ErrorCode */ - int32_t InputMethodSystemAbility::OnUserStopped(const Message* msg) + int32_t InputMethodSystemAbility::OnUserStopped(const Message *msg) { IMSA_HILOGI("Start...\n"); if (msg->msgContent_ == nullptr) { @@ -519,8 +520,8 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } int32_t userId = msg->msgContent_->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); - PerUserSession* session = GetUserSession(userId); + PerUserSetting *setting = GetUserSetting(userId); + PerUserSession *session = GetUserSession(userId); if (setting == nullptr || session == nullptr) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_STARTED), userId); return ErrorCode::ERROR_USER_NOT_STARTED; @@ -540,7 +541,8 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - int32_t InputMethodSystemAbility::setInputMethodCore(sptr &core){ + int32_t InputMethodSystemAbility::setInputMethodCore(sptr &core) + { return ErrorCode::NO_ERROR; } @@ -549,7 +551,7 @@ namespace MiscServices { \param msg the parameters are saved in msg->msgContent_ \return ErrorCode */ - int32_t InputMethodSystemAbility::OnUserUnlocked(const Message* msg) + int32_t InputMethodSystemAbility::OnUserUnlocked(const Message *msg) { IMSA_HILOGI("Start...\n"); if (msg->msgContent_ == nullptr) { @@ -557,8 +559,8 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } int32_t userId = msg->msgContent_->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); - PerUserSession* session = GetUserSession(userId); + PerUserSetting *setting = GetUserSetting(userId); + PerUserSession *session = GetUserSession(userId); if (setting == nullptr || session == nullptr) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_STARTED), userId); return ErrorCode::ERROR_USER_NOT_STARTED; @@ -570,7 +572,7 @@ namespace MiscServices { setting->Initialize(); - InputMethodProperty* ime = setting->GetSecurityInputMethod(); + InputMethodProperty *ime = setting->GetSecurityInputMethod(); session->SetSecurityIme(ime); ime = setting->GetCurrentInputMethod(); session->SetCurrentIme(ime); @@ -584,7 +586,7 @@ namespace MiscServices { \param msg the parameters are saved in msg->msgContent_ \return ErrorCode */ - int32_t InputMethodSystemAbility::OnUserLocked(const Message* msg) + int32_t InputMethodSystemAbility::OnUserLocked(const Message *msg) { IMSA_HILOGI("Start...\n"); if (msg->msgContent_ == nullptr) { @@ -592,15 +594,15 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } int32_t userId = msg->msgContent_->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } std::map::iterator it = msgHandlers.find(userId); if (it!=msgHandlers.end()) { - MessageHandler* handler = it->second; - Message* destMsg = new Message(MSG_ID_USER_LOCK , nullptr); + MessageHandler *handler = it->second; + Message *destMsg = new Message(MSG_ID_USER_LOCK , nullptr); handler->SendMessage(destMsg); GetUserSession(userId)->JoinWorkThread(); msgHandlers.erase(it); @@ -617,13 +619,13 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::OnPrepareInput(Message* msg) + int32_t InputMethodSystemAbility::OnPrepareInput(Message *msg) { IMSA_HILOGI("InputMethodSystemAbility::OnPrepareInput"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("InputMethodSystemAbility::OnPrepareInput errorCode = ErrorCode::ERROR_USER_NOT_UNLOCKED"); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -631,15 +633,15 @@ namespace MiscServices { std::map::const_iterator it = msgHandlers.find(userId); if(it==msgHandlers.end()) { - PerUserSession* session = GetUserSession(userId); - MessageHandler* handler = new MessageHandler(); + PerUserSession *session = GetUserSession(userId); + MessageHandler *handler = new MessageHandler(); session->CreateWorkThread(*handler); msgHandlers.insert(std::pair(userId, handler)); it = msgHandlers.find(userId); } if (it!=msgHandlers.end()) { - MessageHandler* handler = it->second; + MessageHandler *handler = it->second; handler->SendMessage(msg); } return 0; @@ -651,11 +653,11 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::OnHandleMessage(Message* msg) + int32_t InputMethodSystemAbility::OnHandleMessage(Message *msg) { - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -663,7 +665,7 @@ namespace MiscServices { std::map::const_iterator it = msgHandlers.find(userId); if (it!=msgHandlers.end()) { - MessageHandler* handler = it->second; + MessageHandler *handler = it->second; handler->SendMessage(msg); } return ErrorCode::NO_ERROR; @@ -676,10 +678,10 @@ namespace MiscServices { \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked \return ErrorCode::ERROR_BAD_PARAMETERS bad parameter */ - int32_t InputMethodSystemAbility::OnPackageAdded(const Message* msg) + int32_t InputMethodSystemAbility::OnPackageAdded(const Message *msg) { IMSA_HILOGI("Start...\n"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); int32_t size = data->ReadInt32(); @@ -688,20 +690,20 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } std::u16string packageName = data->ReadString16(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } bool securityImeFlag = false; - int32_t ret = setting->OnPackageAdded(packageName, &securityImeFlag); + int32_t ret = setting->OnPackageAdded(packageName, securityImeFlag); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGI("End...\n"); return ret; } if (securityImeFlag == true) { - InputMethodProperty* securityIme = setting->GetSecurityInputMethod(); - InputMethodProperty* defaultIme = setting->GetCurrentInputMethod(); + InputMethodProperty *securityIme = setting->GetSecurityInputMethod(); + InputMethodProperty *defaultIme = setting->GetCurrentInputMethod(); GetUserSession(userId)->ResetIme(defaultIme, securityIme); } IMSA_HILOGI("End...\n"); @@ -715,10 +717,10 @@ namespace MiscServices { \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked \return ErrorCode::ERROR_BAD_PARAMETERS bad parameter */ - int32_t InputMethodSystemAbility::OnPackageRemoved(const Message* msg) + int32_t InputMethodSystemAbility::OnPackageRemoved(const Message *msg) { IMSA_HILOGI("Start...\n"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); int32_t size = data->ReadInt32(); @@ -727,22 +729,22 @@ namespace MiscServices { return ErrorCode::ERROR_BAD_PARAMETERS; } std::u16string packageName = data->ReadString16(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } - PerUserSession* session = GetUserSession(userId); + PerUserSession *session = GetUserSession(userId); session->OnPackageRemoved(packageName); bool securityImeFlag = false; - int32_t ret = setting->OnPackageRemoved(packageName, &securityImeFlag); + int32_t ret = setting->OnPackageRemoved(packageName, securityImeFlag); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGI("End...\n"); return ret; } if (securityImeFlag == true) { - InputMethodProperty* securityIme = setting->GetSecurityInputMethod(); - InputMethodProperty* defaultIme = setting->GetCurrentInputMethod(); + InputMethodProperty *securityIme = setting->GetSecurityInputMethod(); + InputMethodProperty *defaultIme = setting->GetCurrentInputMethod(); GetUserSession(userId)->ResetIme(defaultIme, securityIme); } return 0; @@ -755,10 +757,10 @@ namespace MiscServices { \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked \return ErrorCode::ERROR_BAD_PARAMETERS bad parameter */ - int32_t InputMethodSystemAbility::OnSettingChanged(const Message* msg) + int32_t InputMethodSystemAbility::OnSettingChanged(const Message *msg) { IMSA_HILOGI("Start...\n"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); int32_t size = data->ReadInt32(); if (size < 2) { @@ -767,12 +769,12 @@ namespace MiscServices { } std::u16string updatedKey = data->ReadString16(); std::u16string updatedValue = data->ReadString16(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } - PerUserSession* session = GetUserSession(userId); + PerUserSession *session = GetUserSession(userId); int32_t ret = session->OnSettingChanged(updatedKey, updatedValue); if (ret == ErrorCode::ERROR_SETTING_SAME_VALUE) { IMSA_HILOGI("End...No need to update\n"); @@ -792,8 +794,8 @@ namespace MiscServices { return ret; } - InputMethodProperty* securityIme = setting->GetSecurityInputMethod(); - InputMethodProperty* defaultIme = setting->GetCurrentInputMethod(); + InputMethodProperty *securityIme = setting->GetSecurityInputMethod(); + InputMethodProperty *defaultIme = setting->GetCurrentInputMethod(); session->ResetIme(defaultIme, securityIme); IMSA_HILOGI("End...\n"); return ErrorCode::NO_ERROR; @@ -805,13 +807,13 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::OnDisableIms(const Message* msg) + int32_t InputMethodSystemAbility::OnDisableIms(const Message *msg) { IMSA_HILOGI("Start...\n"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); std::u16string imeId = data->ReadString16(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -831,13 +833,13 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::OnAdvanceToNext(const Message* msg) + int32_t InputMethodSystemAbility::OnAdvanceToNext(const Message *msg) { IMSA_HILOGI("Start...\n"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int32_t userId = data->ReadInt32(); bool isCurrentIme = data->ReadBool(); - PerUserSetting* setting = GetUserSetting(userId); + PerUserSetting *setting = GetUserSetting(userId); if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; @@ -845,7 +847,7 @@ namespace MiscServices { if (isCurrentIme) { std::map::const_iterator it = msgHandlers.find(userId); if (it!=msgHandlers.end()) { - Message* destMsg = new Message(msg->msgId_, nullptr); + Message *destMsg = new Message(msg->msgId_, nullptr); it->second->SendMessage(destMsg); } } else { diff --git a/services/src/input_method_system_ability_stub.cpp b/services/src/input_method_system_ability_stub.cpp index e812b613..8986504b 100644 --- a/services/src/input_method_system_ability_stub.cpp +++ b/services/src/input_method_system_ability_stub.cpp @@ -44,25 +44,25 @@ namespace MiscServices { break; } case RELEASE_INPUT: { - MessageParcel* msgParcel = (MessageParcel*) &data; + MessageParcel *msgParcel = (MessageParcel*) &data; releaseInput(*msgParcel); reply.WriteInt32(NO_ERROR); break; } case START_INPUT: { - MessageParcel* msgParcel = (MessageParcel*) &data; + MessageParcel *msgParcel = (MessageParcel*) &data; startInput(*msgParcel); reply.WriteInt32(NO_ERROR); break; } case STOP_INPUT: { - MessageParcel* msgParcel = (MessageParcel*) &data; + MessageParcel *msgParcel = (MessageParcel*) &data; stopInput(*msgParcel); reply.WriteInt32(NO_ERROR); break; } case SET_INPUT_METHOD_CORE:{ - MessageParcel* msgParcel = (MessageParcel*) &data; + MessageParcel *msgParcel = (MessageParcel*) &data; setInputMethodCoreFromHap(*msgParcel); reply.WriteInt32(NO_ERROR); break; @@ -81,7 +81,7 @@ namespace MiscServices { } case GET_KEYBOARD_WINDOW_HEIGHT: { int32_t height = 0; - int32_t status = getKeyboardWindowHeight(&height); + int32_t status = getKeyboardWindowHeight(height); if (status == ErrorCode::NO_ERROR) { reply.WriteInt32(NO_ERROR); reply.WriteInt32(height); @@ -177,7 +177,7 @@ namespace MiscServices { int32_t pid = IPCSkeleton::GetCallingPid(); int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId); parcel->WriteInt32(pid); parcel->WriteInt32(uid); @@ -186,7 +186,7 @@ namespace MiscServices { parcel->WriteRemoteObject(data.ReadRemoteObject()); parcel->WriteParcelable(data.ReadParcelable()); - Message* msg = new Message(MSG_ID_PREPARE_INPUT, parcel); + Message *msg = new Message(MSG_ID_PREPARE_INPUT, parcel); MessageHandler::Instance()->SendMessage(msg); } @@ -201,11 +201,11 @@ namespace MiscServices { IMSA_HILOGE("InputMethodSystemAbilityStub::releaseInput"); int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId); parcel->WriteRemoteObject(data.ReadRemoteObject()); - Message* msg = new Message(MSG_ID_RELEASE_INPUT, parcel); + Message *msg = new Message(MSG_ID_RELEASE_INPUT, parcel); MessageHandler::Instance()->SendMessage(msg); } @@ -220,11 +220,11 @@ namespace MiscServices { { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId); parcel->WriteRemoteObject(data.ReadRemoteObject()); - Message* msg = new Message(MSG_ID_START_INPUT, parcel); + Message *msg = new Message(MSG_ID_START_INPUT, parcel); MessageHandler::Instance()->SendMessage(msg); } @@ -238,11 +238,11 @@ namespace MiscServices { { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId); parcel->WriteRemoteObject(data.ReadRemoteObject()); - Message* msg = new Message(MSG_ID_STOP_INPUT, parcel); + Message *msg = new Message(MSG_ID_STOP_INPUT, parcel); MessageHandler::Instance()->SendMessage(msg); } @@ -252,18 +252,18 @@ namespace MiscServices { \see PerUserSession::OnPrepareInput \param data the parcel in which the parameters are saved */ - void InputMethodSystemAbilityStub::setInputMethodCoreFromHap(MessageParcel& data) - { - IMSA_HILOGI("InputMethodSystemAbilityStub::setInputMethodCoreFromHap"); - int32_t uid = IPCSkeleton::GetCallingUid(); - int32_t userId = getUserId(uid); - MessageParcel* parcel = new MessageParcel(); - parcel->WriteInt32(userId); - parcel->WriteRemoteObject(data.ReadRemoteObject()); + void InputMethodSystemAbilityStub::setInputMethodCoreFromHap(MessageParcel& data) + { + IMSA_HILOGI("InputMethodSystemAbilityStub::setInputMethodCoreFromHap"); + int32_t uid = IPCSkeleton::GetCallingUid(); + int32_t userId = getUserId(uid); + MessageParcel *parcel = new MessageParcel(); + parcel->WriteInt32(userId); + parcel->WriteRemoteObject(data.ReadRemoteObject()); - Message* msg = new Message(MSG_ID_SET_INPUT_METHOD_CORE, parcel); - MessageHandler::Instance()->SendMessage(msg); - } + Message *msg = new Message(MSG_ID_SET_INPUT_METHOD_CORE, parcel); + MessageHandler::Instance()->SendMessage(msg); + } /*! Get user id from uid \param uid the uid from which the remote call is diff --git a/services/src/keyboard_type.cpp b/services/src/keyboard_type.cpp index a3839c68..48e4b843 100644 --- a/services/src/keyboard_type.cpp +++ b/services/src/keyboard_type.cpp @@ -88,7 +88,7 @@ namespace MiscServices { \return ErrorCode::NO_ERROR \return ErrorCode::ERROR_NULL_POINTER parcel is null */ - KeyboardType* KeyboardType::Unmarshalling(Parcel &parcel) + KeyboardType *KeyboardType::Unmarshalling(Parcel &parcel) { auto info = new KeyboardType(); info->mId = parcel.ReadInt32(); diff --git a/services/src/message.cpp b/services/src/message.cpp index 3868f780..2b1b23fa 100644 --- a/services/src/message.cpp +++ b/services/src/message.cpp @@ -21,7 +21,7 @@ namespace MiscServices { \param msgId a message Id \param msgContent the content of a message */ - Message::Message(int32_t msgId, MessageParcel* msgContent) + Message::Message(int32_t msgId, MessageParcel *msgContent) { msgId_ = msgId; msgContent_ = msgContent; @@ -39,7 +39,7 @@ namespace MiscServices { if (msgContent_ != nullptr) { delete msgContent_; } - MessageParcel* src = msg.msgContent_; + MessageParcel *src = msg.msgContent_; if (src) { msgContent_ = new MessageParcel(); msgContent_->ParseFrom(src->GetData(), src->GetDataSize()); @@ -63,7 +63,8 @@ namespace MiscServices { return *this; } - Message::~Message( ) { + Message::~Message() + { if (msgContent_) { delete msgContent_; } diff --git a/services/src/message_handler.cpp b/services/src/message_handler.cpp index 60c52d10..2d136920 100644 --- a/services/src/message_handler.cpp +++ b/services/src/message_handler.cpp @@ -29,7 +29,7 @@ namespace MiscServices { { std::unique_lock lock(mMutex); while (! mQueue.empty()) { - Message* msg = mQueue.front(); + Message *msg = mQueue.front(); mQueue.pop(); delete msg; } @@ -39,7 +39,7 @@ namespace MiscServices { \param msg a message to be sent \note the msg pointer should not be freed by the caller */ - void MessageHandler::SendMessage(Message* msg) + void MessageHandler::SendMessage(Message *msg) { { std::unique_lock lock(mMutex); @@ -52,14 +52,14 @@ namespace MiscServices { \return a pointer referred to an object of message \note the returned pointer should be freed by the caller. */ - Message* MessageHandler::GetMessage() + Message *MessageHandler::GetMessage() { std::unique_lock lock(mMutex); mCV.wait(lock, [this]{ return !this->mQueue.empty(); }); - Message* msg = (Message*) mQueue.front(); + Message *msg = (Message*) mQueue.front(); mQueue.pop(); return msg; } @@ -67,7 +67,7 @@ namespace MiscServices { /*! The single instance of MessageHandler in the service \return the pointer referred to an object. */ - MessageHandler* MessageHandler::Instance() + MessageHandler *MessageHandler::Instance() { static MessageHandler *handler = nullptr; if (handler == nullptr) { diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 259f1d03..d1529ed8 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -36,82 +36,85 @@ namespace OHOS { namespace MiscServices { using namespace MessageID; - /*! Constructor - \param userId the id of the given user - \param msgId the msg id can be MessageID::MSG_ID_CLIENT_DIED (to monitor input client) - \n or MessageID::MSG_ID_IMS_DIED (to monitor input method service) - */ - RemoteObjectDeathRecipient::RemoteObjectDeathRecipient(int userId, int msgId) - { - userId_ = userId; - msgId_ = msgId; + /*! Constructor + \param userId the id of the given user + \param msgId the msg id can be MessageID::MSG_ID_CLIENT_DIED (to monitor input client) + \n or MessageID::MSG_ID_IMS_DIED (to monitor input method service) + */ + RemoteObjectDeathRecipient::RemoteObjectDeathRecipient(int userId, int msgId) + { + userId_ = userId; + msgId_ = msgId; + } + + RemoteObjectDeathRecipient::~RemoteObjectDeathRecipient() + { + } + + /*! Notify that a remote object died. + \n It's called when the linked remote object died. + \param who the IRemoteObject handler of the remote object died. + */ + void RemoteObjectDeathRecipient::OnRemoteDied(const wptr& who) + { + MessageParcel *parcel = new MessageParcel(); + parcel->WriteInt32(userId_); + parcel->WriteRemoteObject(who.promote()); + Message *msg = new Message(msgId_, parcel); + MessageHandler::Instance()->SendMessage(msg); + } + + /*! Constructor + \param userId the user id of this user whose session are managed by this instance of PerUserSession. + */ + PerUserSession::PerUserSession(int userId) + { + userState = UserState::USER_STATE_STARTED; + userId_ = userId; + currentIme[0] = nullptr; + currentIme[1] = nullptr; + + needReshowClient = nullptr; + + clientDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_CLIENT_DIED); + imsDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_IMS_DIED); + } + + /*! Destructor + */ + PerUserSession::~PerUserSession() + { + if (userState == UserState::USER_STATE_UNLOCKED) { + OnUserLocked(); } - - RemoteObjectDeathRecipient::~RemoteObjectDeathRecipient(){} - - /*! Notify that a remote object died. - \n It's called when the linked remote object died. - \param who the IRemoteObject handler of the remote object died. - */ - void RemoteObjectDeathRecipient::OnRemoteDied(const wptr& who) - { - MessageParcel* parcel = new MessageParcel(); - parcel->WriteInt32(userId_); - parcel->WriteRemoteObject(who.promote()); - Message* msg = new Message(msgId_, parcel); - MessageHandler::Instance()->SendMessage(msg); + clientDeathRecipient = nullptr; + imsDeathRecipient = nullptr; + if (workThreadHandler.joinable()) { + workThreadHandler.join(); } + } - /*! Constructor - \param userId the user id of this user whose session are managed by this instance of PerUserSession. - */ - PerUserSession::PerUserSession(int userId) - { - userState = UserState::USER_STATE_STARTED; - userId_ = userId; - currentIme[0] = nullptr; - currentIme[1] = nullptr; - needReshowClient = nullptr; + /*! Create work thread for this user + \param handle message handle to receive the message + */ + void PerUserSession::CreateWorkThread(MessageHandler& handler) + { + msgHandler = &handler; + workThreadHandler = std::thread([this]{WorkThread();}); + } - clientDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_CLIENT_DIED); - imsDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_IMS_DIED); + /*! Wait till work thread exits + */ + void PerUserSession::JoinWorkThread() + { + if (workThreadHandler.joinable()) { + workThreadHandler.join(); } + } - /*! Destructor - */ - PerUserSession::~PerUserSession() - { - if (userState == UserState::USER_STATE_UNLOCKED) { - OnUserLocked(); - } - clientDeathRecipient = nullptr; - imsDeathRecipient = nullptr; - if (workThreadHandler.joinable()) { - workThreadHandler.join(); - } - } - - - /*! Create work thread for this user - \param handle message handle to receive the message - */ - void PerUserSession::CreateWorkThread(MessageHandler& handler) - { - msgHandler = &handler; - workThreadHandler = std::thread([this]{WorkThread();}); - } - - /*! Wait till work thread exits - */ - void PerUserSession::JoinWorkThread() - { - if (workThreadHandler.joinable()) { - workThreadHandler.join(); - } - } - - void PerUserSession::SetInputMethodAbility(sptr &inputMethodAbility) { + void PerUserSession::SetInputMethodAbility(sptr &inputMethodAbility) + { inputMethodAbility_ = inputMethodAbility; } @@ -123,7 +126,7 @@ namespace MiscServices { return ; } while(1){ - Message* msg = msgHandler->GetMessage(); + Message *msg = msgHandler->GetMessage(); std::unique_lock lock(mtx); switch(msg->msgId_) { case MSG_ID_USER_LOCK: @@ -201,7 +204,7 @@ namespace MiscServices { /*! Set the current input method engine \param ime the current (default) IME pointer referred to the instance in PerUserSetting. */ - void PerUserSession::SetCurrentIme(InputMethodProperty* ime) + void PerUserSession::SetCurrentIme(InputMethodProperty *ime) { currentIme[DEFAULT_IME] = ime; userState = UserState::USER_STATE_UNLOCKED; @@ -210,7 +213,7 @@ namespace MiscServices { /*! Set the system security input method engine \param ime system security IME pointer referred to the instance in PerUserSetting. */ - void PerUserSession::SetSecurityIme(InputMethodProperty* ime) + void PerUserSession::SetSecurityIme(InputMethodProperty *ime) { currentIme[SECURITY_IME] = ime; } @@ -218,7 +221,7 @@ namespace MiscServices { /*! Set the input method setting data \param setting InputMethodSetting pointer referred to the instance in PerUserSetting. */ - void PerUserSession::SetInputMethodSetting(InputMethodSetting* setting) + void PerUserSession::SetInputMethodSetting(InputMethodSetting *setting) { inputMethodSetting = setting; } @@ -229,11 +232,11 @@ namespace MiscServices { \n Two input method engines can be running at the same time for one user. \n One is the default ime, another is security ime */ - void PerUserSession::ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme) + void PerUserSession::ResetIme(InputMethodProperty *defaultIme, InputMethodProperty *securityIme) { IMSA_HILOGI("PerUserSession::ResetIme"); std::unique_lock lock(mtx); - InputMethodProperty* ime[] = {defaultIme, securityIme}; + InputMethodProperty *ime[] = {defaultIme, securityIme}; for(int i=0; i<2; i++) { if (currentIme[i] == ime[i] && ime[i] != nullptr) { continue; @@ -320,7 +323,7 @@ namespace MiscServices { const InputAttribute& attribute) { IMSA_HILOGI("PerUserSession::AddClient"); - ClientInfo* clientInfo = GetClientInfo(inputClient); + ClientInfo *clientInfo = GetClientInfo(inputClient); if (clientInfo != nullptr) { IMSA_HILOGE("PerUserSession::AddClient clientInfo is not nullptr"); return ErrorCode::ERROR_CLIENT_DUPLICATED; @@ -357,15 +360,15 @@ namespace MiscServices { IMSA_HILOGE("PerUserSession::RemoveClient ErrorCode::ERROR_CLIENT_NOT_FOUND"); return ErrorCode::ERROR_CLIENT_NOT_FOUND; } - ClientInfo* clientInfo = it->second; + ClientInfo *clientInfo = it->second; bool flag = clientInfo->attribute.GetSecurityFlag(); int ret = b->RemoveDeathRecipient(clientDeathRecipient); if (ret != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::RemoveClient RemoveDeathRecipient return : %{public}s", ErrorCode::ToString(ret)); + IMSA_HILOGE("PerUserSession::RemoveClient RemoveDeathRecipient fail %{public}s", ErrorCode::ToString(ret)); } ret = clientInfo->client->onInputReleased(0); if (ret != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::RemoveClient onInputReleased return : %{public}s", ErrorCode::ToString(ret)); + IMSA_HILOGE("PerUserSession::RemoveClient onInputReleased fail %{public}s", ErrorCode::ToString(ret)); } delete clientInfo; mapClients.erase(it); @@ -405,7 +408,7 @@ namespace MiscServices { inputControlChannel[index] = localControlChannel[index]; int ret_init = imsCore[index]->initializeInput(inputMethodToken[index], displayId, inputControlChannel[index]); if (ret_init != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::StartInputMethod initializeInput return : %{public}s", ErrorCode::ToString(ret_init)); + IMSA_HILOGE("PerUserSession::StartInputMethod initializeInput fail %{public}s", ErrorCode::ToString(ret_init)); localControlChannel[index] = nullptr; inputControlChannel[index] = nullptr; return ret_init; @@ -472,10 +475,10 @@ namespace MiscServices { \return ErrorCode::ERROR_KBD_SHOW_FAILED failed to show keyboard \return other errors returned by binder driver */ - int PerUserSession::ShowKeyboard( const sptr& inputClient ) + int PerUserSession::ShowKeyboard(const sptr& inputClient) { IMSA_HILOGI("PerUserSession::ShowKeyboard"); - ClientInfo* clientInfo = GetClientInfo(inputClient); + ClientInfo *clientInfo = GetClientInfo(inputClient); int index = GetImeIndex(inputClient); if (index == -1 || clientInfo == nullptr) { IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! index = -1 or clientInfo is nullptr"); @@ -537,7 +540,7 @@ namespace MiscServices { IMSA_HILOGE("PerUserSession::HideKeyboard Aborted! ErrorCode::ERROR_CLIENT_NOT_FOUND"); return ErrorCode::ERROR_CLIENT_NOT_FOUND; } - ClientInfo* clientInfo = GetClientInfo(inputClient); + ClientInfo *clientInfo = GetClientInfo(inputClient); if(clientInfo == nullptr){ IMSA_HILOGE("PerUserSession::HideKeyboard GetClientInfo pointer nullptr"); } @@ -585,11 +588,8 @@ namespace MiscServices { \param[out] retHeight the height of keyboard window showing or showed returned to caller \return ErrorCode */ - int PerUserSession::GetKeyboardWindowHeight(int *retHeight) + int PerUserSession::GetKeyboardWindowHeight(int retHeight) { - if (retHeight == nullptr) { - return ErrorCode::ERROR_BAD_PARAMETERS; - } if (imsCore[lastImeIndex] != nullptr) { int ret = imsCore[lastImeIndex]->getKeyboardWindowHeight(retHeight); if (ret != ErrorCode::NO_ERROR) { @@ -606,7 +606,7 @@ namespace MiscServices { \n null if no keyboard type supported by the current ime. \note The returned pointer should NOT be freed by the caller. */ - KeyboardType* PerUserSession::GetCurrentKeyboardType() + KeyboardType *PerUserSession::GetCurrentKeyboardType() { if (inputMethodSetting == nullptr || currentIme[DEFAULT_IME] == nullptr) { IMSA_HILOGI("Ime has not started ! [%{public}d]\n", userId_); @@ -696,7 +696,7 @@ namespace MiscServices { MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId_); parcel->WriteString16(currentIme[index]->mImeId); - Message* msg = new Message(MSG_ID_DISABLE_IMS, parcel); + Message *msg = new Message(MSG_ID_DISABLE_IMS, parcel); MessageHandler::Instance()->SendMessage(msg); } else { // restart current input method. @@ -705,7 +705,7 @@ namespace MiscServices { parcel->WriteInt32(userId_); parcel->WriteInt32(index); parcel->WriteString16(currentIme[index]->mImeId); - Message* msg = new Message(MSG_ID_RESTART_IMS, parcel); + Message *msg = new Message(MSG_ID_RESTART_IMS, parcel); usleep(1600*1000); // wait that PACKAGE_REMOVED message is received if this ime has been removed MessageHandler::Instance()->SendMessage(msg); } @@ -809,7 +809,7 @@ namespace MiscServices { } } } - KeyboardType* type = GetKeyboardType(index, currentKbdIndex[index]); + KeyboardType *type = GetKeyboardType(index, currentKbdIndex[index]); if (type != nullptr) { if (currentClient != nullptr) { int ret = imsCore[index]->setKeyboardType(*type); @@ -842,7 +842,7 @@ namespace MiscServices { /*! Switch to next keyboard type */ - void PerUserSession::OnAdvanceToNext( ) + void PerUserSession::OnAdvanceToNext() { int index = GetImeIndex(currentClient); if (index == -1) { @@ -864,7 +864,7 @@ namespace MiscServices { int num = currentKbdIndex[index]+1; num %= size; - KeyboardType* type = GetKeyboardType(index, num); + KeyboardType *type = GetKeyboardType(index, num); if (type == nullptr) { IMSA_HILOGW("No next keyboard is available. [%{public}d]\n", userId_); return; @@ -889,7 +889,7 @@ namespace MiscServices { void PerUserSession::OnSetDisplayMode(int mode) { currentDisplayMode = mode; - ClientInfo* clientInfo = GetClientInfo(currentClient); + ClientInfo *clientInfo = GetClientInfo(currentClient); if (clientInfo == nullptr) { IMSA_HILOGE("%{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_); return ; @@ -945,7 +945,7 @@ namespace MiscServices { for(it=mapClients.begin(); it!=mapClients.end();) { sptr b = it->first; b->RemoveDeathRecipient(clientDeathRecipient); - ClientInfo* clientInfo = it->second; + ClientInfo *clientInfo = it->second; if (clientInfo != nullptr) { int ret = clientInfo->client->onInputReleased(0); if (ret != ErrorCode::NO_ERROR) { @@ -991,7 +991,7 @@ namespace MiscServices { for(int i=0; i<2; i++) { if (currentIme[i] != nullptr) { dprintf(fd, "\n * %s IME mImeId = %s\n", header[i].c_str(), Utils::to_utf8(currentIme[i]->mImeId).c_str()); - KeyboardType* type = currentIme[i]->mTypes.at(currentKbdIndex[i]); + KeyboardType *type = currentIme[i]->mTypes.at(currentKbdIndex[i]); dprintf(fd, " %s KeyboardType mHashCode = %d, mLanguage = %s\n", header[i].c_str(), type->getHashCode(), Utils::to_utf8(type->getLanguage()).c_str()); @@ -1045,7 +1045,7 @@ namespace MiscServices { dprintf(fd, " displayMode = %d [ full sceen ]\n", currentDisplayMode); } int height = 0; - GetKeyboardWindowHeight(&height); + GetKeyboardWindowHeight(height); dprintf(fd, " keyboard window height = %d\n", height); } @@ -1102,7 +1102,7 @@ namespace MiscServices { \return null when it's not found. \note The returned pointer should not be freed by caller. */ - KeyboardType* PerUserSession::GetKeyboardType(int imeIndex, int typeIndex) + KeyboardType *PerUserSession::GetKeyboardType(int imeIndex, int typeIndex) { if(typeIndex < 0) { return nullptr; @@ -1141,7 +1141,7 @@ namespace MiscServices { } else { hashCode = inputMethodSetting->GetCurrentSysKeyboardType(); } - KeyboardType* type = nullptr; + KeyboardType *type = nullptr; if (hashCode == -1) { type = GetKeyboardType(imeIndex, currentKbdIndex[imeIndex]); } else { @@ -1248,7 +1248,7 @@ namespace MiscServices { \n null if client is not found \note the clientInfo pointer should not be freed by caller */ - ClientInfo* PerUserSession::GetClientInfo(const sptr& inputClient) + ClientInfo *PerUserSession::GetClientInfo(const sptr& inputClient) { if (inputClient == nullptr) { IMSA_HILOGE("PerUserSession::GetClientInfo inputClient is nullptr"); @@ -1263,7 +1263,8 @@ namespace MiscServices { return (ClientInfo*) it->second; } - void PerUserSession::BindInputAbility(){ + void PerUserSession::BindInputAbility() + { IMSA_HILOGE("PerUserSession::BindInputAbility"); AAFwk::Want want; want.SetAction("action.system.inputmethod"); @@ -1290,10 +1291,10 @@ namespace MiscServices { \param msg the parameters from remote client are saved in msg->msgContent_ \return ErrorCode */ - void PerUserSession::OnPrepareInput(Message* msg) + void PerUserSession::OnPrepareInput(Message *msg) { IMSA_HILOGI("PerUserSession::OnPrepareInput Start...[%{public}d]\n", userId_); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; int pid = data->ReadInt32(); int uid = data->ReadInt32(); int displayId = data->ReadInt32(); @@ -1308,7 +1309,7 @@ namespace MiscServices { IMSA_HILOGI("PerUserSession::OnPrepareInput channelObject is null"); } sptr channel = new InputDataChannelProxy(channelObject); - InputAttribute* attribute = data->ReadParcelable(); + InputAttribute *attribute = data->ReadParcelable(); if (attribute ==nullptr) { IMSA_HILOGI("PerUserSession::OnPrepareInput attribute is nullptr"); } @@ -1332,10 +1333,10 @@ namespace MiscServices { \param msg the parameters from remote client are saved in msg->msgContent_ \return ErrorCode */ - void PerUserSession::OnReleaseInput(Message* msg) + void PerUserSession::OnReleaseInput(Message *msg) { IMSA_HILOGI("PerUserSession::OnReleaseInput Start...[%{public}d]\n", userId_); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; sptr clientObject = data->ReadRemoteObject(); sptr client = new InputClientProxy(clientObject); @@ -1356,10 +1357,10 @@ namespace MiscServices { \param msg the parameters from remote client are saved in msg->msgContent_ \return ErrorCode */ - void PerUserSession::OnStartInput(Message* msg) + void PerUserSession::OnStartInput(Message *msg) { IMSA_HILOGI("PerUserSession::OnStartInput"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; sptr clientObject = data->ReadRemoteObject(); sptr client = new InputClientProxy(clientObject); int ret = ShowKeyboard(client); @@ -1370,10 +1371,10 @@ namespace MiscServices { } } - void PerUserSession::onSetInputMethodCore(Message* msg) + void PerUserSession::onSetInputMethodCore(Message *msg) { IMSA_HILOGI("PerUserSession::onSetInputMethodCore Start...[%{public}d]\n", userId_); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; sptr coreObject = data->ReadRemoteObject(); sptr core = new InputMethodCoreProxy(coreObject); @@ -1401,10 +1402,10 @@ namespace MiscServices { \param msg the parameters from remote client are saved in msg->msgContent_ \return ErrorCode */ - void PerUserSession::OnStopInput(Message* msg) + void PerUserSession::OnStopInput(Message *msg) { IMSA_HILOGI("PerUserSession::OnStopInput"); - MessageParcel* data = msg->msgContent_; + MessageParcel *data = msg->msgContent_; sptr clientObject = data->ReadRemoteObject(); sptr client = new InputClientProxy(clientObject); diff --git a/services/src/peruser_setting.cpp b/services/src/peruser_setting.cpp index bafe6009..5e3a00b7 100644 --- a/services/src/peruser_setting.cpp +++ b/services/src/peruser_setting.cpp @@ -22,7 +22,8 @@ namespace MiscServices { /*! Constructor \param userId the id number of this user */ - PerUserSetting::PerUserSetting(int userId) { + PerUserSetting::PerUserSetting(int userId) + { userId_ = userId; currentImeId = Utils::to_utf16(""); userState = UserState::USER_STATE_STARTED; @@ -42,7 +43,8 @@ namespace MiscServices { * read all installed input method engine information from the system * read input method setting data from the system */ - void PerUserSetting::Initialize() { + void PerUserSetting::Initialize() + { userState = UserState::USER_STATE_UNLOCKED; inputMethodProperties.clear(); @@ -73,9 +75,10 @@ namespace MiscServices { \return ErrorCode::ERROR_NOT_IME_PACKAGE The installed package is not an IME package. \return ErrorCode::ERROR_IME_PACKAGE_DUPLICATED The installed package is duplicated. */ - int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool* isSecurityIme) { + int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool isSecurityIme) + { if (isSecurityIme) { - *isSecurityIme = false; + isSecurityIme = false; } std::u16string imeId = GetImeId(packageName); if (imeId.size() != 0) { @@ -93,7 +96,7 @@ namespace MiscServices { inputMethodProperties.push_back(property); if (CheckIfSecurityIme(*property)) { if (isSecurityIme) { - *isSecurityIme = true; + isSecurityIme = true; } return ErrorCode::NO_ERROR; } @@ -119,9 +122,10 @@ namespace MiscServices { \return ErrorCode::NO_ERROR The removed package is an IME package, and is removed from the input method management system \return ErrorCode::ERROR_NOT_IME_PACKAGE The removed package is not an IME package. */ - int PerUserSetting::OnPackageRemoved(std::u16string& packageName, bool* isSecurityIme) { + int PerUserSetting::OnPackageRemoved(std::u16string& packageName, bool isSecurityIme) + { if (isSecurityIme) { - *isSecurityIme = false; + isSecurityIme = false; } std::u16string imeId = GetImeId(packageName); if (imeId.size() == 0) { @@ -131,7 +135,7 @@ namespace MiscServices { bool securityFlag = false; std::vector::iterator it; for(it=inputMethodProperties.begin(); itmImeId == imeId) { if (CheckIfSecurityIme(*node)==true) { securityFlag = true; @@ -143,7 +147,7 @@ namespace MiscServices { } if (securityFlag) { if (isSecurityIme) { - *isSecurityIme = true; + isSecurityIme = true; } return ErrorCode::NO_ERROR; } @@ -170,7 +174,8 @@ namespace MiscServices { \return ErrorCode::NO_ERROR update the setting data to input method management system. \return ErrorCode::ERROR_SETTING_SAME_VALUE the current value is same as the one in the system. */ - int PerUserSetting::OnSettingChanged(const std::u16string& key, const std::u16string& value) { + int PerUserSetting::OnSettingChanged(const std::u16string& key, const std::u16string& value) + { std::u16string currentValue = inputMethodSetting.GetValue(key); if (currentValue == value) { @@ -197,12 +202,13 @@ namespace MiscServices { /*! Switch to the next input method service. */ - void PerUserSetting::OnAdvanceToNext() { + void PerUserSetting::OnAdvanceToNext() + { bool flag = false; std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); std::u16string imeId; std::u16string nextImeId = Utils::to_utf16(""); - InputMethodProperty* firstEnabledProperty = nullptr; + InputMethodProperty *firstEnabledProperty = nullptr; for(int i=0; i<(int)inputMethodProperties.size(); i++) { imeId = inputMethodProperties[i]->mImeId; if (imeId == currentImeId) { @@ -238,7 +244,8 @@ namespace MiscServices { * release input method engine information * release input method setting data */ - void PerUserSetting::OnUserLocked() { + void PerUserSetting::OnUserLocked() + { if (userState == UserState::USER_STATE_STARTED) { return; } @@ -248,7 +255,7 @@ namespace MiscServices { // release input method properties std::vector::iterator it; for(it=inputMethodProperties.begin(); itmImeId) { return inputMethodProperties[i]; @@ -317,8 +327,9 @@ namespace MiscServices { \return null when there is no security IME in the system. \note The returned pointer should NOT be freed by caller */ - InputMethodProperty* PerUserSetting::GetSecurityInputMethod() { - InputMethodProperty* ime = nullptr; + InputMethodProperty *PerUserSetting::GetSecurityInputMethod() + { + InputMethodProperty *ime = nullptr; std::u16string systemLocales = inputMethodSetting.GetValue(InputMethodSetting::SYSTEM_LOCALE_TAG); for(int i=0; i<(int)inputMethodProperties.size(); i++) { if (CheckIfSecurityIme(*inputMethodProperties[i])==false) { @@ -347,11 +358,12 @@ namespace MiscServices { \return null when the next enabled IME is not available. \note The returned pointer should NOT be freed by caller */ - InputMethodProperty* PerUserSetting::GetNextInputMethod() { + InputMethodProperty *PerUserSetting::GetNextInputMethod() + { bool flag = false; std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); std::u16string imeId; - InputMethodProperty* firstEnabledProperty = nullptr; + InputMethodProperty *firstEnabledProperty = nullptr; for(int i=0; i<(int)inputMethodProperties.size(); i++) { imeId = inputMethodProperties[i]->mImeId; if (imeId == currentImeId) { @@ -371,7 +383,8 @@ namespace MiscServices { \return a pointer of InputMethodSetting. \note The returned pointer should NOT be freed by caller */ - InputMethodSetting* PerUserSetting::GetInputMethodSetting() { + InputMethodSetting *PerUserSetting::GetInputMethodSetting() + { return &inputMethodSetting; } @@ -379,7 +392,8 @@ namespace MiscServices { \param[out] properties the details will be written to the param properties \return ErrorCode::NO_ERROR */ - int32_t PerUserSetting::ListInputMethodEnabled(std::vector *properties) { + int32_t PerUserSetting::ListInputMethodEnabled(std::vector *properties) + { std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); for(int i=0; i<(int)inputMethodProperties.size(); i++) { @@ -394,7 +408,8 @@ namespace MiscServices { \param[out] properties the details will be written to the param properties \return ErrorCode::NO_ERROR */ - int32_t PerUserSetting::ListInputMethod(std::vector *properties) { + int32_t PerUserSetting::ListInputMethod(std::vector *properties) + { for(int i=0; i<(int)inputMethodProperties.size(); i++) { properties->push_back(inputMethodProperties[i]); } @@ -406,7 +421,8 @@ namespace MiscServices { \param[out] types the data of type list of the given IME will be written to types \return ErrorCode::NO_ERROR */ - int32_t PerUserSetting::ListKeyboardType(const std::u16string& imeId, std::vector *types) { + int32_t PerUserSetting::ListKeyboardType(const std::u16string& imeId, std::vector *types) + { for(int i=0; i<(int)inputMethodProperties.size(); i++) { if (imeId == inputMethodProperties[i]->mImeId) { for(int j=0; j<(int)inputMethodProperties[i]->mTypes.size(); j++) { @@ -424,7 +440,8 @@ namespace MiscServices { \return null when the given IME is not available \note the returned pointer should not be freed by the caller. */ - InputMethodProperty* PerUserSetting::GetInputMethodProperty(const std::u16string& imeId) { + InputMethodProperty *PerUserSetting::GetInputMethodProperty(const std::u16string& imeId) + { for(int i=0; i<(int)inputMethodProperties.size(); i++) { if (inputMethodProperties[i]->mImeId == imeId) { return inputMethodProperties[i]; @@ -439,7 +456,8 @@ namespace MiscServices { \return language value when the given hashCode is found \return an empty string when the given hashCode is not found */ - std::u16string PerUserSetting::GetKeyboardTypeLanguage(const InputMethodProperty* property, int hashCode) { + std::u16string PerUserSetting::GetKeyboardTypeLanguage(const InputMethodProperty *property, int hashCode) + { for(int i=0; i<(int)property->mTypes.size(); i++) { if (property->mTypes[i]->getHashCode() == hashCode) { return property->mTypes[i]->getLanguage(); @@ -450,7 +468,8 @@ namespace MiscServices { /*! Init input method setting data */ - void PerUserSetting::InitInputMethodSetting() { + void PerUserSetting::InitInputMethodSetting() + { bool flag = inputMethodSetting.FindKey(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); if (flag == false) { for(int i=0; i<(int)inputMethodProperties.size(); i++) { @@ -486,11 +505,12 @@ namespace MiscServices { \li If no system ime is there, we use the first enabled ime as current ime. \li If no enabled ime, set current ime as null. */ - void PerUserSetting::ResetCurrentInputMethod() { + void PerUserSetting::ResetCurrentInputMethod() + { std::u16string systemLocales = inputMethodSetting.GetValue(InputMethodSetting::SYSTEM_LOCALE_TAG); std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); std::u16string imeId; - InputMethodProperty* firstEnabledIme = nullptr; + InputMethodProperty *firstEnabledIme = nullptr; bool flag = false; for(int i=0; i<(int)inputMethodProperties.size(); i++) { @@ -533,7 +553,8 @@ namespace MiscServices { \param packageName the packageName of the given IME \return the id of the given IME */ - std::u16string PerUserSetting::GetImeId(const std::u16string& packageName) { + std::u16string PerUserSetting::GetImeId(const std::u16string& packageName) + { for(int i=0; i<(int)inputMethodProperties.size(); i++) { if (inputMethodProperties[i]->mPackageName == packageName) { return inputMethodProperties[i]->mImeId; @@ -547,7 +568,8 @@ namespace MiscServices { \return true - It's a security Ime \n false - It's not a security Ime */ - bool PerUserSetting::CheckIfSecurityIme(const InputMethodProperty& property) { + bool PerUserSetting::CheckIfSecurityIme(const InputMethodProperty& property) + { return property.isSystemIme; } } diff --git a/services/src/platform.cpp b/services/src/platform.cpp index c9a3b1f8..046a6a57 100644 --- a/services/src/platform.cpp +++ b/services/src/platform.cpp @@ -19,7 +19,8 @@ namespace OHOS { namespace MiscServices { - void Platform::SetPlatform(const sptr < IPlatformApi >& platformApi) { + void Platform::SetPlatform(const sptr < IPlatformApi >& platformApi) + { this->platformApi = platformApi; sptr < IPlatformCallback > cb = new PlatformCallbackStub(); this->platformApi->registerCallback(cb); @@ -27,18 +28,21 @@ namespace MiscServices { /*! Constructor */ - Platform::Platform() { + Platform::Platform() + { } /*! Destructor */ - Platform::~Platform() { + Platform::~Platform() + { } /*! Single instance exists in the service */ - Platform* Platform::Instance() { - static Platform* platform = nullptr; + Platform *Platform::Instance() + { + static Platform *platform = nullptr; if (platform == nullptr) { platform = new Platform(); } @@ -51,8 +55,9 @@ namespace MiscServices { \param intention the intention to start the service \return the remote object handler of started input method service. */ - sptr < IInputMethodCore > Platform::BindInputMethodService(int userId, const std::u16string& packageName, - const std::u16string& intention) { + sptr Platform::BindInputMethodService(int userId, const std::u16string& packageName, + const std::u16string& intention) + { if (platformApi == nullptr) { return nullptr; } @@ -64,7 +69,8 @@ namespace MiscServices { \param packageName the packageName of the given input method engine which is going to stop \return ErrorCode */ - int Platform::UnbindInputMethodService(int userId, const std::u16string& packageName) { + int Platform::UnbindInputMethodService(int userId, const std::u16string& packageName) + { if (platformApi == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -77,7 +83,8 @@ namespace MiscServices { \param packageName the packageName of the given input method engine \return ErrorCode */ - sptr < IRemoteObject > Platform::CreateWindowToken(int userId, int displayId, const std::u16string& packageName) { + sptr < IRemoteObject > Platform::CreateWindowToken(int userId, int displayId, const std::u16string& packageName) + { if (platformApi == nullptr) { return nullptr; } @@ -89,7 +96,8 @@ namespace MiscServices { \param packageName the packageName of the given input method engine \return ErrorCode */ - int Platform::DestroyWindowToken(int userId, const std::u16string& packageName) { + int Platform::DestroyWindowToken(int userId, const std::u16string& packageName) + { if (platformApi == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -101,7 +109,8 @@ namespace MiscServices { \param[out] inputMethodProperties the input method engine list installed in the system for the given user \return ErrorCode */ - int Platform::ListInputMethod(int userId, std::vector < InputMethodProperty* > * inputMethodProperties) { + int Platform::ListInputMethod(int userId, std::vector *inputMethodProperties) + { return 0; } @@ -112,7 +121,8 @@ namespace MiscServices { \return ErrorCode */ int Platform::GetInputMethodProperty(int userId, const std::u16string& packageName, - InputMethodProperty* inputMethodProperty) { + InputMethodProperty *inputMethodProperty) + { if (platformApi == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -125,7 +135,8 @@ namespace MiscServices { \return ErrorCode */ - int Platform::GetInputMethodSetting(int userId, InputMethodSetting* inputMethodSetting) { + int Platform::GetInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting) + { return 0; } @@ -134,7 +145,8 @@ namespace MiscServices { \param inputMethodSetting the input method setting data for the given user \return ErrorCode */ - int Platform::SetInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting) { + int Platform::SetInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting) + { if (platformApi == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -145,7 +157,8 @@ namespace MiscServices { \return true - a physical keyboard is connected \n false - no physical keyboard */ - bool Platform::CheckPhysicalKeyboard() { + bool Platform::CheckPhysicalKeyboard() + { return true; } @@ -153,7 +166,8 @@ namespace MiscServices { \return true - the remote caller is from a valid window \n false - the remote caller is not from a valid window */ - bool Platform::IsValidWindow(int uid, int pid, int displayId) { + bool Platform::IsValidWindow(int uid, int pid, int displayId) + { (void)uid; (void)pid; (void)displayId; @@ -164,7 +178,8 @@ namespace MiscServices { \return true - the remote caller is from a focused window \n false - the remote caller is not from a focused window */ - bool Platform::IsWindowFocused(int uid, int pid, int displayId) { + bool Platform::IsWindowFocused(int uid, int pid, int displayId) + { (void)uid; (void)pid; (void)displayId; diff --git a/services/src/platform_api_proxy.cpp b/services/src/platform_api_proxy.cpp index 67b9db4c..2b40201f 100644 --- a/services/src/platform_api_proxy.cpp +++ b/services/src/platform_api_proxy.cpp @@ -32,13 +32,16 @@ namespace MiscServices { class PlatformApiProxy : public IRemoteProxy < IPlatformApi > { public: PlatformApiProxy(const sptr& impl) - : IRemoteProxy < IPlatformApi >(impl) { + : IRemoteProxy < IPlatformApi >(impl) + { } - ~PlatformApiProxy() { + ~PlatformApiProxy() + { } - int32_t registerCallback(const sptr < IPlatformCallback >& cb) { + int32_t registerCallback(const sptr < IPlatformCallback >& cb) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -54,12 +57,14 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - std::u16string getInterfaceDescriptor() { + std::u16string getInterfaceDescriptor() + { return Utils::to_utf16("20210814"); } sptr < IInputMethodCore > bindInputMethodService(const std::u16string& packageName, - const std::u16string& intention, int userId) { + const std::u16string& intention, int userId) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -81,7 +86,8 @@ namespace MiscServices { return ims; } - int32_t unbindInputMethodService(int userId, const std::u16string& packageName) { + int32_t unbindInputMethodService(int userId, const std::u16string& packageName) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -98,7 +104,8 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - sptr < IRemoteObject > createWindowToken(int userId, int displayId, const std::u16string& packageName) { + sptr < IRemoteObject > createWindowToken(int userId, int displayId, const std::u16string& packageName) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -118,7 +125,8 @@ namespace MiscServices { return token; } - int32_t destroyWindowToken(int userId, const std::u16string& packageName) { + int32_t destroyWindowToken(int userId, const std::u16string& packageName) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -136,7 +144,8 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - int32_t listInputMethod(int userId, std::vector < InputMethodProperty* >* inputMethodProperties) { + int32_t listInputMethod(int userId, std::vector *inputMethodProperties) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -152,7 +161,7 @@ namespace MiscServices { } int size = reply.ReadInt32(); for (int i = 0; i < size; i++) { - InputMethodProperty* property = new InputMethodProperty(); + InputMethodProperty *property = new InputMethodProperty(); property = reply.ReadParcelable(); inputMethodProperties->push_back(property); } @@ -161,7 +170,8 @@ namespace MiscServices { virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName, - InputMethodProperty* inputMethodProperty) { + InputMethodProperty *inputMethodProperty) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -180,7 +190,8 @@ namespace MiscServices { return status; } - int32_t getInputMethodSetting(int userId, InputMethodSetting* inputMethodSetting) { + int32_t getInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); @@ -198,7 +209,8 @@ namespace MiscServices { return status; } - int32_t setInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting) { + int32_t setInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting) + { MessageParcel data, reply; MessageOption option; data.WriteInterfaceToken(GetDescriptor()); diff --git a/services/src/platform_callback_proxy.cpp b/services/src/platform_callback_proxy.cpp index 4389700c..4bc3871e 100644 --- a/services/src/platform_callback_proxy.cpp +++ b/services/src/platform_callback_proxy.cpp @@ -24,16 +24,19 @@ */ namespace OHOS { namespace MiscServices { - class PlatformCallbackProxy : public IRemoteProxy < IPlatformCallback > { + class PlatformCallbackProxy : public IRemoteProxy { public: PlatformCallbackProxy(const sptr < IRemoteObject >& impl) - : IRemoteProxy < IPlatformCallback >(impl) { + : IRemoteProxy < IPlatformCallback >(impl) + { } - ~PlatformCallbackProxy() { + ~PlatformCallbackProxy() + { } - void notifyEvent(int eventId, int userId, const std::vector < std::u16string >& eventContent) { + void notifyEvent(int eventId, int userId, const std::vector < std::u16string >& eventContent) + { (void)eventId; (void)userId; (void)eventContent; diff --git a/services/src/platform_callback_stub.cpp b/services/src/platform_callback_stub.cpp index ecb66227..cce681e3 100644 --- a/services/src/platform_callback_stub.cpp +++ b/services/src/platform_callback_stub.cpp @@ -23,14 +23,17 @@ namespace OHOS { namespace MiscServices { using namespace MessageID; - PlatformCallbackStub::PlatformCallbackStub() { + PlatformCallbackStub::PlatformCallbackStub() + { } - PlatformCallbackStub::~PlatformCallbackStub() { + PlatformCallbackStub::~PlatformCallbackStub() + { } int PlatformCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option) { + MessageOption& option) + { switch (code) { case NOTIFY_EVENT: { int eventId = data.ReadInt32(); @@ -50,7 +53,8 @@ namespace MiscServices { return NO_ERROR; } - void PlatformCallbackStub::notifyEvent(int eventId, int userId, const std::vector& eventContent) { + void PlatformCallbackStub::notifyEvent(int eventId, int userId, const std::vector& eventContent) + { int msgId = 0; switch (eventId) { case CommonEvent::COMMON_EVENT_USER_STARTED: { @@ -86,14 +90,14 @@ namespace MiscServices { } } - MessageParcel* parcel = new MessageParcel(); + MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId); int size = eventContent.size(); parcel->WriteInt32(size); for (int i = 0; i < size; i++) { parcel->WriteString16(eventContent[i]); } - Message* msg = new Message(msgId, parcel); + Message *msg = new Message(msgId, parcel); MessageHandler::Instance()->SendMessage(msg); } } diff --git a/unitest/src/input_method_ability_test.cpp b/unitest/src/input_method_ability_test.cpp index f3ad35cf..8dc78bc9 100644 --- a/unitest/src/input_method_ability_test.cpp +++ b/unitest/src/input_method_ability_test.cpp @@ -44,18 +44,22 @@ public: void TearDown(); }; -void InputMethodAbilityTest::SetUpTestCase(void) { +void InputMethodAbilityTest::SetUpTestCase(void) +{ IMSA_HILOGI("InputMethodAbilityTest::SetUpTestCase"); } -void InputMethodAbilityTest::TearDownTestCase(void) { +void InputMethodAbilityTest::TearDownTestCase(void) +{ IMSA_HILOGI("InputMethodAbilityTest::TearDownTestCase"); } -void InputMethodAbilityTest::SetUp(void) { +void InputMethodAbilityTest::SetUp(void) +{ IMSA_HILOGI("InputMethodAbilityTest::SetUp"); } -void InputMethodAbilityTest::TearDown(void) { +void InputMethodAbilityTest::TearDown(void) +{ IMSA_HILOGI("InputMethodAbilityTest::TearDown"); } \ No newline at end of file diff --git a/unitest/src/input_method_controller_test.cpp b/unitest/src/input_method_controller_test.cpp index 22ca331f..9cf0bc82 100644 --- a/unitest/src/input_method_controller_test.cpp +++ b/unitest/src/input_method_controller_test.cpp @@ -38,15 +38,18 @@ class TextListener : public OnTextChangedListener { public: TextListener() {} ~TextListener() {} - void InsertText(const std::u16string& text) { + void InsertText(const std::u16string& text) + { IMSA_HILOGI("IMC TEST TextListener InsertText: %{public}s", MiscServices::Utils::to_utf8(text).c_str()); } - void DeleteBackward(int32_t length){ + void DeleteBackward(int32_t length) + { IMSA_HILOGI("IMC TEST TextListener DeleteBackward length: %{public}d", length); } - void SetKeyboardStatus(bool status) { + void SetKeyboardStatus(bool status) + { IMSA_HILOGI("IMC TEST TextListener SetKeyboardStatus %{public}d", status); } }; @@ -58,19 +61,23 @@ public: void TearDown(); }; -void InputMethodControllerTest::SetUpTestCase(void) { +void InputMethodControllerTest::SetUpTestCase(void) +{ IMSA_HILOGI("InputMethodControllerTest::SetUpTestCase"); } -void InputMethodControllerTest::TearDownTestCase(void) { +void InputMethodControllerTest::TearDownTestCase(void) +{ IMSA_HILOGI("InputMethodControllerTest::TearDownTestCase"); } -void InputMethodControllerTest::SetUp(void) { +void InputMethodControllerTest::SetUp(void) +{ IMSA_HILOGI("InputMethodControllerTest::SetUp"); } -void InputMethodControllerTest::TearDown(void) { +void InputMethodControllerTest::TearDown(void) +{ IMSA_HILOGI("InputMethodControllerTest::TearDown"); } @@ -79,7 +86,8 @@ void InputMethodControllerTest::TearDown(void) { * @tc.desc: Bind IMSA. * @tc.type: FUNC */ -HWTEST_F(InputMethodControllerTest, Imc001, TestSize.Level0) { +HWTEST_F(InputMethodControllerTest, Imc001, TestSize.Level0) +{ IMSA_HILOGI("IMC TEST START"); sptr imc = InputMethodController::GetInstance(); ASSERT_TRUE(imc!=nullptr);