mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-20 23:45:31 -04:00
@@ -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;
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "input_method_ability.h"
|
||||
#include "input_method_core_proxy.h"
|
||||
#include "input_method_core_stub.h"
|
||||
@@ -32,18 +29,21 @@ namespace MiscServices {
|
||||
sptr<InputMethodAbility> InputMethodAbility::instance_;
|
||||
std::mutex InputMethodAbility::instanceLock_;
|
||||
|
||||
InputMethodAbility::InputMethodAbility() {
|
||||
InputMethodAbility::InputMethodAbility()
|
||||
{
|
||||
Initialize();
|
||||
OnConnect();
|
||||
}
|
||||
|
||||
InputMethodAbility::~InputMethodAbility() {
|
||||
InputMethodAbility::~InputMethodAbility()
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
delete msgHandler;
|
||||
}
|
||||
}
|
||||
|
||||
sptr<InputMethodAbility> InputMethodAbility::GetInstance() {
|
||||
sptr<InputMethodAbility> InputMethodAbility::GetInstance()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetInstance");
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::mutex> autoLock(instanceLock_);
|
||||
@@ -55,7 +55,8 @@ namespace MiscServices {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
sptr<InputMethodSystemAbilityProxy> InputMethodAbility::GetImsaProxy() {
|
||||
sptr<InputMethodSystemAbilityProxy> InputMethodAbility::GetImsaProxy()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetImsaProxy");
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
@@ -74,7 +75,8 @@ namespace MiscServices {
|
||||
return iface;
|
||||
}
|
||||
|
||||
sptr<IInputMethodCore> InputMethodAbility::OnConnect() {
|
||||
sptr<IInputMethodCore> InputMethodAbility::OnConnect()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::OnConnect");
|
||||
mImms = GetImsaProxy();
|
||||
sptr<InputMethodCoreStub> stub = new InputMethodCoreStub(0);
|
||||
@@ -87,7 +89,8 @@ namespace MiscServices {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void InputMethodAbility::Initialize() {
|
||||
void InputMethodAbility::Initialize()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::Initialize");
|
||||
InitialInputWindow();
|
||||
msgHandler = new MessageHandler();
|
||||
@@ -99,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);
|
||||
@@ -141,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<IRemoteObject> channelObject = data->ReadRemoteObject();
|
||||
if (channelObject == nullptr) {
|
||||
@@ -159,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<InputDataChannelProxy> channalProxy = new InputDataChannelProxy(data->ReadRemoteObject());
|
||||
inputDataChannel = channalProxy;
|
||||
if(inputDataChannel == nullptr) {
|
||||
@@ -180,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> 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");
|
||||
@@ -237,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");
|
||||
@@ -246,7 +262,8 @@ namespace MiscServices {
|
||||
inputDataChannel->DeleteBackward(length);
|
||||
}
|
||||
|
||||
void InputMethodAbility::HideKeyboardSelf() {
|
||||
void InputMethodAbility::HideKeyboardSelf()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::HideKeyboardSelf");
|
||||
inputControlChannel->hideKeyboardSelf(1);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,13 @@
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace ErrorCode;
|
||||
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IInputMethodAgent>(object) {
|
||||
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object)
|
||||
: IRemoteProxy<IInputMethodAgent>(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;
|
||||
|
||||
@@ -22,13 +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) {
|
||||
int32_t InputMethodAgentStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAgentStub::OnRemoteRequest code = %{public}d", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
@@ -54,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,16 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl) : IRemoteProxy<IInputMethodCore>(impl) {
|
||||
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl)
|
||||
: IRemoteProxy<IInputMethodCore>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
InputMethodCoreProxy::~InputMethodCoreProxy() = default;
|
||||
|
||||
int32_t InputMethodCoreProxy::initializeInput(sptr<IRemoteObject> &startInputToken, int32_t displayId, sptr<IInputControlChannel> &inputControlChannel) {
|
||||
int32_t InputMethodCoreProxy::initializeInput(sptr<IRemoteObject> &startInputToken, int32_t displayId,
|
||||
sptr<IInputControlChannel> &inputControlChannel)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreProxy::initializeInput");
|
||||
if (startInputToken == nullptr) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::initializeInput startInputToken is nullptr");
|
||||
@@ -58,7 +62,9 @@ namespace MiscServices {
|
||||
return code;
|
||||
}
|
||||
|
||||
bool InputMethodCoreProxy::startInput(const sptr<IInputDataChannel> &inputDataChannel, const InputAttribute& editorAttribute, bool supportPhysicalKbd) {
|
||||
bool InputMethodCoreProxy::startInput(const sptr<IInputDataChannel> &inputDataChannel,
|
||||
const InputAttribute& editorAttribute, bool supportPhysicalKbd)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreProxy::startInput");
|
||||
if (inputDataChannel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr");
|
||||
@@ -85,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());
|
||||
@@ -103,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){
|
||||
@@ -125,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) {
|
||||
@@ -146,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());
|
||||
@@ -160,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());
|
||||
@@ -173,7 +184,7 @@ namespace MiscServices {
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
*retHeight = reply.ReadInt32();
|
||||
retHeight = reply.ReadInt32();
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <stdint.h>
|
||||
#include "message_handler.h"
|
||||
@@ -32,14 +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) {
|
||||
int32_t InputMethodCoreStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
|
||||
MessageOption& option)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest");
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
@@ -66,7 +68,7 @@ namespace MiscServices {
|
||||
}
|
||||
case START_INPUT: {
|
||||
sptr<IInputDataChannel> inputDataChannel = iface_cast<IInputDataChannel>(data.ReadRemoteObject());
|
||||
InputAttribute* editorAttribute = data.ReadParcelable<InputAttribute>();
|
||||
InputAttribute *editorAttribute = data.ReadParcelable<InputAttribute>();
|
||||
bool supportPhysicalKbd = data.ReadBool();
|
||||
|
||||
if (inputDataChannel == nullptr) {
|
||||
@@ -94,13 +96,13 @@ namespace MiscServices {
|
||||
break;
|
||||
}
|
||||
case SET_KEYBOARD_TYPE: {
|
||||
KeyboardType* type = data.ReadParcelable<KeyboardType>();
|
||||
KeyboardType *type = data.ReadParcelable<KeyboardType>();
|
||||
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 +114,9 @@ namespace MiscServices {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t InputMethodCoreStub::initializeInput(sptr<IRemoteObject>& startInputToken, int32_t displayId, sptr<IInputControlChannel>& inputControlChannel) {
|
||||
int32_t InputMethodCoreStub::initializeInput(sptr<IRemoteObject>& startInputToken, int32_t displayId,
|
||||
sptr<IInputControlChannel>& inputControlChannel)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreStub::initializeInput");
|
||||
if (msgHandler_==nullptr) {
|
||||
return ErrorCode::ERROR_NULL_POINTER;
|
||||
@@ -122,99 +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<IInputDataChannel>& inputDataChannel, const InputAttribute& editorAttribute, bool supportPhysicalKbd) {
|
||||
bool InputMethodCoreStub::startInput(const sptr<IInputDataChannel>& inputDataChannel,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user