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 "start_stop_d_inputs_call_back_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 {
StartStopDInputsCallbackStub()27 StartStopDInputsCallbackStub::StartStopDInputsCallbackStub() {}
28 
~StartStopDInputsCallbackStub()29 StartStopDInputsCallbackStub::~StartStopDInputsCallbackStub() {}
30 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)31 int32_t StartStopDInputsCallbackStub::OnRemoteRequest(
32     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
33 {
34     std::u16string descriptor = data.ReadInterfaceToken();
35     if (descriptor != IStartStopDInputsCallback::GetDescriptor()) {
36         return ERR_DH_INPUT_IPC_INVALID_DESCRIPTOR;
37     }
38     IStartStopDInputsCallback::Message msgCode = static_cast<IStartStopDInputsCallback::Message>(code);
39     switch (msgCode) {
40         case IStartStopDInputsCallback::Message::RESULT_STRING: {
41             std::string devId = data.ReadString();
42             int32_t status = data.ReadInt32();
43             DHLOGW("OnResultDhids received.");
44             OnResultDhids(devId, status);
45             break;
46         }
47         default:
48             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
49     }
50     return DH_SUCCESS;
51 }
52 } // namespace DistributedInput
53 } // namespace DistributedHardware
54 } // namespace OHOS
55