• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "input_method_agent_proxy.h"
17 
18 namespace OHOS {
19 namespace MiscServices {
20     using namespace ErrorCode;
InputMethodAgentProxy(const sptr<IRemoteObject> & object)21     InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object)
22         : IRemoteProxy<IInputMethodAgent>(object)
23     {
24     }
25 
DispatchKeyEvent(MessageParcel & data)26     bool InputMethodAgentProxy::DispatchKeyEvent(MessageParcel& data)
27     {
28         IMSA_HILOGI("InputMethodAgentProxy::DispatchKeyEvent");
29         MessageParcel reply;
30         MessageOption option;
31 
32         auto ret = Remote()->SendRequest(DISPATCH_KEY_EVENT, data, reply, option);
33         if (ret != NO_ERROR) {
34             IMSA_HILOGI("InputMethodAgentProxy::DispatchKeyEvent SendRequest failed");
35         }
36         ret = reply.ReadBool();
37         return ret;
38     }
39 
OnCursorUpdate(int32_t positionX,int32_t positionY,int32_t height)40     void InputMethodAgentProxy::OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height)
41     {
42         IMSA_HILOGI("InputMethodAgentProxy::OnCursorUpdate");
43         MessageParcel data, reply;
44         MessageOption option;
45         if (!data.WriteInterfaceToken(GetDescriptor())) {
46             IMSA_HILOGI("InputMethodAgentProxy::OnCursorUpdate descriptor is not match");
47             return;
48         }
49 
50         data.WriteInt32(positionX);
51         data.WriteInt32(positionY);
52         data.WriteInt32(height);
53 
54         Remote()->SendRequest(ON_CURSOR_UPDATE, data, reply, option);
55     }
56 
OnSelectionChange(std::u16string text,int32_t oldBegin,int32_t oldEnd,int32_t newBegin,int32_t newEnd)57     void InputMethodAgentProxy::OnSelectionChange(std::u16string text, int32_t oldBegin, int32_t oldEnd,
58                                                   int32_t newBegin, int32_t newEnd)
59     {
60         IMSA_HILOGI("InputMethodAgentProxy::OnSelectionChange");
61         MessageParcel data, reply;
62         MessageOption option;
63         if (!data.WriteInterfaceToken(GetDescriptor())) {
64             IMSA_HILOGI("InputMethodAgentProxy::OnSelectionChange descriptor is not match");
65             return;
66         }
67 
68         data.WriteString16(text);
69         data.WriteInt32(oldBegin);
70         data.WriteInt32(oldEnd);
71         data.WriteInt32(newBegin);
72         data.WriteInt32(newEnd);
73 
74         Remote()->SendRequest(ON_SELECTION_CHANGE, data, reply, option);
75     }
76 
SetCallingWindow(uint32_t windowId)77     void InputMethodAgentProxy::SetCallingWindow(uint32_t windowId)
78     {
79         IMSA_HILOGI("InputMethodAgentProxy::SetCallingWindow");
80         MessageParcel data, reply;
81         MessageOption option;
82         if (!data.WriteInterfaceToken(GetDescriptor())) {
83             IMSA_HILOGI("InputMethodAgentProxy::SetCallingWindow descriptor is not match");
84             return;
85         }
86 
87         data.WriteUint32(windowId);
88         Remote()->SendRequest(SET_CALLING_WINDOW_ID, data, reply, option);
89     }
90 } // namespace MiscServices
91 } // namespace OHOS
92