mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 22:59:45 +00:00
commit
e09554c05f
@ -36,10 +36,9 @@ namespace MiscServices {
|
||||
INITIALIZE_INPUT = FIRST_CALL_TRANSACTION,
|
||||
START_INPUT,
|
||||
STOP_INPUT,
|
||||
DISPATCH_KEY,
|
||||
SHOW_KEYBOARD,
|
||||
HIDE_KEYBOARD,
|
||||
ON_CURSOR_UPDATE,
|
||||
ON_SELECT_TEXT_CHANGE,
|
||||
SET_KEYBOARD_TYPE,
|
||||
GET_KEYBOARD_WINDOW_HEIGHT,
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ namespace MiscServices {
|
||||
virtual void releaseInput(MessageParcel& data) override;
|
||||
virtual void startInput(MessageParcel& data) override;
|
||||
virtual void stopInput(MessageParcel& data) override;
|
||||
virtual void DispatchKey(MessageParcel& data) override;
|
||||
virtual int32_t setInputMethodCore(sptr<IInputMethodCore> &core) override;
|
||||
|
||||
int32_t Prepare(int32_t displayId, sptr<InputClientStub> &client, sptr<InputDataChannelStub> &channel,
|
||||
|
@ -350,13 +350,18 @@ using namespace MessageID;
|
||||
bool InputMethodController::dispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent");
|
||||
if (mAgent == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent mAgent is nullptr");
|
||||
if (mImms == nullptr) {
|
||||
return false;
|
||||
}
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent (%{public}d, %{public}d)",
|
||||
keyEvent->GetKeyCode(), keyEvent->GetKeyAction());
|
||||
mAgent->DispatchKey(keyEvent->GetKeyCode(), keyEvent->GetKeyAction());
|
||||
MessageParcel data;
|
||||
if (!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&&data.WriteRemoteObject(mClient->AsObject().GetRefPtr())
|
||||
&&data.WriteInt32(keyEvent->GetKeyCode())
|
||||
&&data.WriteInt32(keyEvent->GetKeyAction()))) {
|
||||
return false;
|
||||
}
|
||||
mImms->DispatchKey(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,25 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodSystemAbilityProxy::DispatchKey(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::DispatchKey");
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
auto ret = Remote()->SendRequest(DISPATCH_KEY, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::DispatchKey SendRequest failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = reply.ReadInt32();
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::DispatchKey reply failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbilityProxy::setInputMethodCore(sptr<IInputMethodCore> &core)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore");
|
||||
|
@ -298,6 +298,7 @@ namespace MiscServices {
|
||||
DECLARE_NAPI_FUNCTION("InsertText", JS_InsertText),
|
||||
DECLARE_NAPI_FUNCTION("DeleteForward", JS_DeleteForward),
|
||||
DECLARE_NAPI_FUNCTION("DeleteBackward", JS_DeleteBackward),
|
||||
DECLARE_NAPI_FUNCTION("MoveCursor", JS_MoveCursor),
|
||||
DECLARE_NAPI_FUNCTION("HideKeyboardSelf", JS_HideKeyboardSelf),
|
||||
DECLARE_NAPI_FUNCTION("GetTextBeforeCursor", JS_GetTextBeforeCursor),
|
||||
DECLARE_NAPI_FUNCTION("GetTextAfterCursor", JS_GetTextAfterCursor),
|
||||
|
@ -37,6 +37,7 @@ namespace MiscServices {
|
||||
RELEASE_INPUT,
|
||||
START_INPUT,
|
||||
STOP_INPUT,
|
||||
DISPATCH_KEY,
|
||||
SET_INPUT_METHOD_CORE,
|
||||
GET_DISPLAY_MODE,
|
||||
GET_KEYBOARD_WINDOW_HEIGHT,
|
||||
@ -52,6 +53,7 @@ namespace MiscServices {
|
||||
virtual void releaseInput(MessageParcel& data) = 0;
|
||||
virtual void startInput(MessageParcel& data) = 0;
|
||||
virtual void stopInput(MessageParcel& data) = 0;
|
||||
virtual void DispatchKey(MessageParcel& data) = 0;
|
||||
virtual int32_t setInputMethodCore(sptr<IInputMethodCore> &core) = 0;
|
||||
|
||||
virtual int32_t getDisplayMode(int32_t retMode) = 0;
|
||||
|
@ -26,12 +26,14 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> {
|
||||
public:
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
virtual void prepareInput(MessageParcel& data) override;
|
||||
virtual void releaseInput(MessageParcel& data) override;
|
||||
virtual void startInput(MessageParcel& data) override;
|
||||
virtual void stopInput(MessageParcel& data) override;
|
||||
virtual void DispatchKey(MessageParcel& data) override;
|
||||
void setInputMethodCoreFromHap(MessageParcel& data);
|
||||
protected:
|
||||
int32_t getUserId(int32_t uid);
|
||||
|
@ -165,6 +165,7 @@ namespace MiscServices {
|
||||
void OnReleaseInput(Message *msg);
|
||||
void OnStartInput(Message *msg);
|
||||
void OnStopInput(Message *msg);
|
||||
void DispatchKey(Message *msg);
|
||||
void OnClientDied(const wptr<IRemoteObject>& who);
|
||||
void OnImsDied(const wptr<IRemoteObject>& who);
|
||||
void OnHideKeyboardSelf(int flags);
|
||||
|
@ -418,6 +418,7 @@ namespace MiscServices {
|
||||
case MSG_ID_SET_DISPLAY_MODE:
|
||||
case MSG_ID_CLIENT_DIED:
|
||||
case MSG_ID_IMS_DIED:
|
||||
case MSG_ID_DISPATCH_KEY:
|
||||
case MSG_ID_RESTART_IMS: {
|
||||
OnHandleMessage(msg);
|
||||
break;
|
||||
|
@ -61,6 +61,12 @@ namespace MiscServices {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case DISPATCH_KEY: {
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
DispatchKey(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case SET_INPUT_METHOD_CORE: {
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
setInputMethodCoreFromHap(*msgParcel);
|
||||
@ -245,6 +251,21 @@ namespace MiscServices {
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
void InputMethodSystemAbilityStub::DispatchKey(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::DispatchKey");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
parcel->WriteInt32(data.ReadInt32());
|
||||
parcel->WriteInt32(data.ReadInt32());
|
||||
|
||||
Message *msg = new Message(MSG_ID_DISPATCH_KEY, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Prepare input
|
||||
\n Send prepareInput command to work thread.
|
||||
The handling of prepareInput is in the work thread of PerUserSession.
|
||||
|
@ -152,6 +152,10 @@ namespace MiscServices {
|
||||
OnStopInput(msg);
|
||||
break;
|
||||
}
|
||||
case MSG_ID_DISPATCH_KEY: {
|
||||
DispatchKey(msg);
|
||||
break;
|
||||
}
|
||||
case MSG_ID_SET_INPUT_METHOD_CORE: {
|
||||
onSetInputMethodCore(msg);
|
||||
break;
|
||||
@ -1338,5 +1342,21 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("PerUserSession::OnStopInput End...[%{public}d]\n", userId_);
|
||||
}
|
||||
}
|
||||
|
||||
void PerUserSession::DispatchKey(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::DispatchKey");
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
|
||||
sptr<IRemoteObject> clientObject = data->ReadRemoteObject();
|
||||
int32_t keyCode = data->ReadInt32();
|
||||
int32_t state = data->ReadInt32();
|
||||
|
||||
if (localControlChannel[currentIndex]->GetAgentAndChannel(&imsAgent, &imsChannel) == true) {
|
||||
IMSA_HILOGI("PerUserSession::DispatchKey GetAgentAndChannel");
|
||||
sptr<InputMethodAgentProxy> agent = new InputMethodAgentProxy(imsAgent->AsObject().GetRefPtr());
|
||||
agent->DispatchKey(keyCode, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user