1 /*
2 * Copyright (c) 2022 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_node_listener_stub.h"
17
18 #include "string_ex.h"
19
20 #include "constants_dinput.h"
21 #include "dinput_errcode.h"
22 #include "dinput_log.h"
23
24 namespace OHOS {
25 namespace DistributedHardware {
26 namespace DistributedInput {
InputNodeListenerStub()27 InputNodeListenerStub::InputNodeListenerStub() {}
28
~InputNodeListenerStub()29 InputNodeListenerStub::~InputNodeListenerStub() {}
30
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)31 int32_t InputNodeListenerStub::OnRemoteRequest(
32 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
33 {
34 if (data.ReadInterfaceToken() != GetDescriptor()) {
35 DHLOGE("InputNodeListenerStub read token valid failed");
36 return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL;
37 }
38 InputNodeListener::Message msgCode = static_cast<InputNodeListener::Message>(code);
39 switch (msgCode) {
40 case InputNodeListener::Message::RESULT_ON: {
41 std::string srcDevId = data.ReadString();
42 std::string sinkDevId = data.ReadString();
43 std::string sinkNodeId = data.ReadString();
44 std::string sinkNodeDesc = data.ReadString();
45 OnNodeOnLine(srcDevId, sinkDevId, sinkNodeId, sinkNodeDesc);
46 break;
47 }
48 case InputNodeListener::Message::RESULT_OFF: {
49 std::string srcDevId = data.ReadString();
50 std::string sinkDevId = data.ReadString();
51 std::string sinkNodeId = data.ReadString();
52 OnNodeOffLine(srcDevId, sinkDevId, sinkNodeId);
53 break;
54 }
55 default:
56 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
57 }
58 return DH_SUCCESS;
59 }
60 } // namespace DistributedInput
61 } // namespace DistributedHardware
62 } // namespace OHOS
63