• 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_client_stub.h"
17 #include "global.h"
18 
19 namespace OHOS {
20 namespace MiscServices {
InputClientStub()21     InputClientStub::InputClientStub()
22     {
23     }
24 
~InputClientStub()25     InputClientStub::~InputClientStub()
26     {
27     }
28 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29     int32_t InputClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
30                                              MessageOption &option)
31     {
32         IMSA_HILOGI("InputClientStub::OnRemoteRequest. code = %{public}u", code);
33         auto descriptorToken = data.ReadInterfaceToken();
34         if (descriptorToken != GetDescriptor()) {
35             return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
36         }
37         switch (code) {
38             case ON_INPUT_READY: {
39                 if (msgHandler == nullptr) {
40                     break;
41                 }
42                 MessageParcel *parcel = new MessageParcel();
43                 parcel->WriteRemoteObject(data.ReadRemoteObject());
44 
45                 Message *msg = new Message(MessageID::MSG_ID_ON_INPUT_READY, parcel);
46                 msgHandler->SendMessage(msg);
47                 break;
48             }
49             case ON_INPUT_RELEASED: {
50                 if (msgHandler == nullptr) {
51                     break;
52                 }
53                 MessageParcel *parcel = new MessageParcel();
54                 parcel->WriteInt32(data.ReadInt32());
55                 Message *msg = new Message(MessageID::MSG_ID_EXIT_SERVICE, parcel);
56                 msgHandler->SendMessage(msg);
57                 break;
58             }
59             case SET_DISPLAY_MODE: {
60                 if (msgHandler == nullptr) {
61                     break;
62                 }
63                 MessageParcel *parcel = new MessageParcel();
64                 parcel->WriteInt32(data.ReadInt32());
65                 Message *msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel);
66                 msgHandler->SendMessage(msg);
67                 break;
68             }
69             default:
70                 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
71         }
72         return NO_ERROR;
73     }
74 
onInputReady(const sptr<IInputMethodAgent> & agent)75     int32_t InputClientStub::onInputReady(const sptr<IInputMethodAgent>& agent)
76     {
77         return ErrorCode::NO_ERROR;
78     }
79 
onInputReleased(int32_t retValue)80     int32_t InputClientStub::onInputReleased(int32_t retValue)
81     {
82         return ErrorCode::NO_ERROR;
83     }
84 
setDisplayMode(int32_t mode)85     int32_t InputClientStub::setDisplayMode(int32_t mode)
86     {
87         return ErrorCode::NO_ERROR;
88     }
89 
SetHandler(MessageHandler * handler)90     void InputClientStub::SetHandler(MessageHandler *handler)
91     {
92         msgHandler = handler;
93     }
94 }
95 }