diff --git a/frameworks/inputmethod_ability/include/i_input_method_core.h b/frameworks/inputmethod_ability/include/i_input_method_core.h index 22bdda39680377a47242d59f646617c1df3d5219..8018dd8a18301b9e2fe133e7334a5b23b43acbcb 100644 --- a/frameworks/inputmethod_ability/include/i_input_method_core.h +++ b/frameworks/inputmethod_ability/include/i_input_method_core.h @@ -38,6 +38,7 @@ namespace MiscServices { START_INPUT, STOP_INPUT, SHOW_KEYBOARD, + STOP_INPUT_SERVICE, HIDE_KEYBOARD, SET_KEYBOARD_TYPE, GET_KEYBOARD_WINDOW_HEIGHT, @@ -58,6 +59,7 @@ namespace MiscServices { virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) = 0; virtual void SetClientState(bool state) = 0; + virtual void StopInputService(std::string imeId) = 0; }; } } diff --git a/frameworks/inputmethod_ability/include/input_method_core_proxy.h b/frameworks/inputmethod_ability/include/input_method_core_proxy.h index 91923f1be7f2e57681233c2131e45ddd4b1b68f7..e4e157c86fb55ae6d8ee64985afc690e3b3037e3 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_proxy.h +++ b/frameworks/inputmethod_ability/include/input_method_core_proxy.h @@ -46,6 +46,7 @@ namespace MiscServices { virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) override; virtual void SetClientState(bool state) override; + virtual void StopInputService(std::string imeId) 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 b314264357b0a9b778ea5395fed82feaa322a183..ae6a3c661d3e36586a259bc2c1da7d483ce5e8b0 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_core_stub.h @@ -55,6 +55,7 @@ namespace MiscServices { virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) override; virtual void SetClientState(bool state) override; + virtual void StopInputService(std::string imeId) override; void SetMessageHandler(MessageHandler *msgHandler); private: diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index 03ead7f7f9a9fac562bb1d217d820b21944969a1..7b4c1ee5347852e4a133435c544c23c41ed60d7d 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -167,6 +167,12 @@ namespace MiscServices { OnSelectionChange(msg); break; } + case MSG_ID_STOP_INPUT_SERVICE:{ + MessageParcel *data = msg->msgContent_; + std::string imeId = Str16ToStr8(data->ReadString16()); + imeListener_->OnInputStop(imeId); + break; + } default: { break; } diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index 2155aa3f0fa0ec9e8e683deaec828ffc49fd82b0..355637049db392dad73aa4860bdc38a68003d87a 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -17,6 +17,7 @@ #include "message_parcel.h" #include "message_option.h" #include "input_attribute.h" +#include namespace OHOS { namespace MiscServices { @@ -187,6 +188,31 @@ namespace MiscServices { return true; } + void InputMethodCoreProxy::StopInputService(std::string imeId) + { + IMSA_HILOGI("InputMethodCoreProxy::StopInputService"); + + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("InputMethodCoreProxy::StopInputService remote is nullptr"); + return; + } + MessageParcel data; + if (!(data.WriteInterfaceToken(GetDescriptor()) + && data.WriteString16(Str8ToStr16(imeId)))) { + return; + } + MessageParcel reply; + MessageOption option { + MessageOption::TF_SYNC + }; + + int32_t res = remote->SendRequest(STOP_INPUT_SERVICE, data, reply, option); + if (res != ErrorCode::NO_ERROR) { + return; + } + } + bool InputMethodCoreProxy::hideKeyboard(int32_t flags) { IMSA_HILOGI("InputMethodCoreProxy::hideKeyboard"); diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp index f8717704d0bafe2792fa140c7c4bc5ea476f62eb..e71e02ab5b9eced3ac58ae101b73883ed22b6361 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp @@ -23,6 +23,7 @@ #include "message_parcel.h" #include "input_control_channel_proxy.h" #include "input_method_ability.h" +#include namespace OHOS { namespace MiscServices { @@ -128,6 +129,12 @@ namespace MiscServices { reply.WriteNoException(); break; } + case STOP_INPUT_SERVICE: { + std::string imeId = Str16ToStr8(data.ReadString16()); + StopInputService(imeId); + reply.WriteNoException(); + break; + } default: { return IRemoteStub::OnRemoteRequest(code, data, reply, option); } @@ -264,6 +271,19 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } + void InputMethodCoreStub::StopInputService(std::string imeId) + { + IMSA_HILOGI("InputMethodCoreStub::StopInputService"); + if (msgHandler_ == nullptr) { + return; + } + MessageParcel *data = new MessageParcel(); + data->WriteString16(Str8ToStr16(imeId)); + + Message *msg = new Message(MessageID::MSG_ID_STOP_INPUT_SERVICE, data); + msgHandler_->SendMessage(msg); + } + int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t retHeight) { IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight"); diff --git a/interfaces/kits/js/napi/include/js_input_method_engine_listener.h b/interfaces/kits/js/napi/include/js_input_method_engine_listener.h index d7bff0088fd5ffb04756889fe4d1b1b04ec164c7..e55f980cfd30a0f7f0fbb62b23e788622e2617bc 100644 --- a/interfaces/kits/js/napi/include/js_input_method_engine_listener.h +++ b/interfaces/kits/js/napi/include/js_input_method_engine_listener.h @@ -36,6 +36,7 @@ namespace MiscServices { void OnCursorUpdate(int32_t positionX, int32_t positionY, int height); void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd); void OnTextChange(std::string text); + void OnInputStop(std::string imeId); private: void AddCallback(std::string type, NativeValue* jsListenerObject); void CallJsMethod(std::string methodName, NativeValue* const* argv = nullptr, size_t argc = 0); diff --git a/interfaces/kits/js/napi/src/js_input_method_engine_listener.cpp b/interfaces/kits/js/napi/src/js_input_method_engine_listener.cpp index 70bd8c68ed3aff7ded21c30651fdd5ec774c7d00..93cdffcd12674355c41a1cf8ea8005a61926488d 100644 --- a/interfaces/kits/js/napi/src/js_input_method_engine_listener.cpp +++ b/interfaces/kits/js/napi/src/js_input_method_engine_listener.cpp @@ -264,5 +264,23 @@ namespace MiscServices { std::string methodName = "textChange"; CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); } + + void JsInputMethodEngineListener::OnInputStop(std::string imeId) + { + std::lock_guard lock(mMutex); + IMSA_HILOGI("JsInputMethodEngineListener::OnInputStop"); + + NativeValue* nativeValue = engine_->CreateObject(); + NativeObject* object = AbilityRuntime::ConvertNativeValueTo(nativeValue); + if (object == nullptr) { + IMSA_HILOGI("Failed to convert rect to jsObject"); + return; + } + object->SetProperty("imeId", AbilityRuntime::CreateJsValue(*engine_, imeId)); + + NativeValue* argv[] = {nativeValue}; + std::string methodName = "inputStop"; + CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + } } } \ No newline at end of file diff --git a/services/dialog/js/pages/index/index.css b/services/dialog/js/pages/index/index.css index d9cd6c1b35fd7b0333c35147ad4a26a5116e0c03..86ac12b78fbdb0315af6bc5120476a556eb470d6 100644 --- a/services/dialog/js/pages/index/index.css +++ b/services/dialog/js/pages/index/index.css @@ -7,6 +7,7 @@ top: 0fp; width: 100%; height: 100%; + background: #ffffff; } .title { @@ -17,7 +18,7 @@ margin-top: 12fp; margin-left: 23fp; margin-right: 25fp; - color:#000000; + color: #000000; } .btn { @@ -32,6 +33,11 @@ margin-top: 22fp; } +.normal { + width: 100%; + height: 100%; +} + .listItem { width: 100%; height: 42fp; @@ -43,17 +49,17 @@ width: 100%; height: 22fp; font-size: 16fp; - weight:medium; - color:#000000; + weight: medium; + color: #000000; } .imeDecription { width: 100%; height: 22fp; font-size: 13fp; - weight:medium; + weight: medium; margin-top: 2fp; - color:#66000000; + color: #66000000; } .imeMessage { diff --git a/services/dialog/js/pages/index/index.hml b/services/dialog/js/pages/index/index.hml index 64d98e5acd8fde7a8fcabee0df3fa81366cdf0e9..797f5c2d5bb160e5f8f5d9ab5869142620e12337 100644 --- a/services/dialog/js/pages/index/index.hml +++ b/services/dialog/js/pages/index/index.hml @@ -5,9 +5,9 @@ -
+
- {{ $item.name }} + {{ $item.label }} {{ $item.discription }}
{ + mgr.getString(labelId).then(value => { + this.updateLabelData(bundle, value, ''); + }).catch(error => { + console.info("ImsaKit-dialog initString resource getString error:" + error); + }) + mgr.getString(discriptionId).then(value => { + this.updateLabelData(bundle, '', value); + }).catch(error => { + console.info("ImsaKit-dialog initString resource getString error:" + error); + }) + }).catch(error => { + console.info("ImsaKit-dialog initString getResourceManager error:" + error); + }); + } + }, + updateLabelData(bundle, label, discription) { + for (var i = 0; i < this.imeList.length; i++) { + if (this.imeList[i].ime == bundle) { + if (label != '') { + this.imeList[i].label = label; + } + if (discription != '') { + this.imeList[i].discription = discription; + } + } + } } } diff --git a/services/include/input_method_property.h b/services/include/input_method_property.h index 04f5f1d166dc5a61a3a50e6d92c3f30fc66bfa5d..ab02eb4669326598bf7a2c70d1348014526b2749 100644 --- a/services/include/input_method_property.h +++ b/services/include/input_method_property.h @@ -31,8 +31,8 @@ namespace MiscServices { bool isSystemIme; int32_t mDefaultImeId; std::vector mTypes; - std::u16string moduleName; - std::u16string description; + int32_t labelId; + int32_t descriptionId; InputMethodProperty(); ~InputMethodProperty(); diff --git a/services/include/message_handler.h b/services/include/message_handler.h index 3a12967ceff23666d1db462e1ac89b5b1a925fcc..b7e37f9f1e5170df15b054f5fd5df06b6480f9ec 100644 --- a/services/include/message_handler.h +++ b/services/include/message_handler.h @@ -75,6 +75,7 @@ namespace MessageID { MSG_ID_INITIALIZE_INPUT, MSG_ID_HIDE_KEYBOARD, MSG_ID_SET_KEYBOARD_TYPE, + MSG_ID_STOP_INPUT_SERVICE, MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT, MSG_ID_INIT_INPUT_CONTROL_CHANNEL, diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index 65eecf0b20a1dcb04462410a57d8ba7cf0166733..c9e470c0d75a7f88daa6367c3936d9d276967769 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -112,6 +112,7 @@ namespace MiscServices { int OnSettingChanged(const std::u16string& key, const std::u16string& value); void CreateWorkThread(MessageHandler& handler); void JoinWorkThread(); + void StopInputService(std::string imeId); static bool StartInputService(); private: int userId_; // the id of the user to whom the object is linking diff --git a/services/src/input_method_property.cpp b/services/src/input_method_property.cpp index 803fabf7c3d58bb3993bdd5752a00867b618f9fa..a5581a193fc34ef3493713f375e7bb9cc7e2b5e2 100644 --- a/services/src/input_method_property.cpp +++ b/services/src/input_method_property.cpp @@ -45,8 +45,8 @@ namespace MiscServices { mConfigurationPage = property.mConfigurationPage; isSystemIme = property.isSystemIme; mDefaultImeId = property.mDefaultImeId; - moduleName = property.moduleName; - description = property.description; + labelId = property.labelId; + descriptionId = property.descriptionId; for (int i = 0; i < (int)mTypes.size(); i++) { KeyboardType *type = new KeyboardType(*property.mTypes[i]); @@ -69,8 +69,8 @@ namespace MiscServices { mConfigurationPage = property.mConfigurationPage; isSystemIme = property.isSystemIme; mDefaultImeId = property.mDefaultImeId; - moduleName = property.moduleName; - description = property.description; + labelId = property.labelId; + descriptionId = property.descriptionId; for (int i = 0; i < (int)mTypes.size(); i++) { KeyboardType *type = new KeyboardType(*property.mTypes[i]); @@ -92,8 +92,8 @@ namespace MiscServices { && parcel.WriteString16(mConfigurationPage) && parcel.WriteBool(isSystemIme) && parcel.WriteInt32(mDefaultImeId) - && parcel.WriteString16(moduleName) - && parcel.WriteString16(description))) + && parcel.WriteInt32(labelId) + && parcel.WriteInt32(descriptionId))) return false; int32_t size = (int32_t)mTypes.size(); parcel.WriteInt32(size); @@ -120,8 +120,8 @@ namespace MiscServices { info->mConfigurationPage = parcel.ReadString16(); info->isSystemIme = parcel.ReadBool(); info->mDefaultImeId = parcel.ReadInt32(); - info->moduleName = parcel.ReadString16(); - info->description = parcel.ReadString16(); + info->labelId = parcel.ReadInt32(); + info->descriptionId = parcel.ReadInt32(); int32_t size = parcel.ReadInt32(); if (size == 0) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 3ec80bd9b62ec58fef4a2681f70b23aafd72d65f..c7d71e517040d4264e8f7ed98979e875050097c2 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -180,7 +180,8 @@ namespace MiscServices { setting->Initialize(); } - void InputMethodSystemAbility::StartInputService(std::string imeId) { + void InputMethodSystemAbility::StartInputService(std::string imeId) + { IMSA_HILOGE("InputMethodSystemAbility::StartInputService() ime:%{public}s", imeId.c_str()); PerUserSession *session = GetUserSession(MAIN_USER_ID); @@ -218,8 +219,15 @@ namespace MiscServices { } } - void InputMethodSystemAbility::StopInputService(std::string imeId) { + void InputMethodSystemAbility::StopInputService(std::string imeId) + { IMSA_HILOGE("InputMethodSystemAbility::StopInputService(%{public}s)", imeId.c_str()); + PerUserSession *session = GetUserSession(MAIN_USER_ID); + if (session == nullptr){ + IMSA_HILOGE("InputMethodSystemAbility::StopInputService abort session is nullptr"); + } + + session->StopInputService(imeId); } /*! Get the state of user @@ -366,15 +374,16 @@ namespace MiscServices { std::vector extensionInfos; bool ret = GetBundleMgr()->QueryExtensionAbilityInfos(AppExecFwk::ExtensionAbilityType::SERVICE, userId, extensionInfos); if (!ret) { - IMSA_HILOGI("InputMethodSystemAbility::ListInputMethod QueryExtensionAbilityInfos error"); + IMSA_HILOGI("InputMethodSystemAbility::listInputMethodByUserId QueryExtensionAbilityInfos error"); return ErrorCode::ERROR_STATUS_UNKNOWN_ERROR; } for (auto extension : extensionInfos) { + AppExecFwk::ApplicationInfo applicationInfo = extension.applicationInfo; InputMethodProperty *property = new InputMethodProperty(); property->mPackageName = Str8ToStr16(extension.bundleName); property->mAbilityName = Str8ToStr16(extension.name); - property->moduleName = Str8ToStr16(extension.moduleName); - property->description = Str8ToStr16(extension.description); + property->labelId = applicationInfo.labelId; + property->descriptionId = applicationInfo.descriptionId; properties->push_back(property); } return ErrorCode::NO_ERROR; @@ -828,21 +837,24 @@ namespace MiscServices { std::string params = ""; std::vector::iterator it; for (it = properties.begin(); it < properties.end(); ++it) { - if(it == properties.begin()) { + if (it == properties.begin()) { params += "{\"imeList\":["; - }else { + } else { params += "},"; } InputMethodProperty *property = (InputMethodProperty*)*it; std::string imeId = Str16ToStr8(property->mPackageName) + "/" + Str16ToStr8(property->mAbilityName); params += "{\"ime\": \"" + imeId + "\","; - params += "\"name\": \"" + Str16ToStr8(property->moduleName) + "\","; - params += "\"discription\": \"" + Str16ToStr8(property->description) + "\","; + params += "\"labelId\": \"" + std::to_string(property->labelId) + "\","; + params += "\"discriptionId\": \"" + std::to_string(property->descriptionId) + "\","; std::string isDefaultIme = defaultIme == imeId ? "true" : "false"; - params += "\"isDefaultIme\": \"" + isDefaultIme + "\""; + params += "\"isDefaultIme\": \"" + isDefaultIme + "\","; + params += "\"label\": \"\","; + params += "\"discription\": \"\""; } params += "}]}"; + IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod param : %{public}s", params.c_str()); const int TITLE_HEIGHT = 62; const int SINGLE_IME_HEIGHT = 66; const int POSTION_X = 0; diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index aacb8c8fe9481765bde553f429b6860880153a7d..1146e25e6053d1bd088b7b34669b842ca63cda69 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -1304,5 +1304,13 @@ namespace MiscServices { sptr client = new InputClientProxy(clientObject); HideKeyboard(client); } + + void PerUserSession::StopInputService(std::string imeId) + { + IMSA_HILOGI("PerUserSession::StopInputService"); + if (imsCore[0] != nullptr) { + imsCore[0]->StopInputService(imeId); + } + } } }