1 /*
2  * Copyright (c) 2022-2024 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_proxy.h"
17 
18 #include "ipc_types.h"
19 #include "parcel.h"
20 
21 #include "dinput_log.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 namespace DistributedInput {
StartStopDInputsCallbackProxy(const sptr<IRemoteObject> & object)26 StartStopDInputsCallbackProxy::StartStopDInputsCallbackProxy(const sptr<IRemoteObject> &object)
27     : IRemoteProxy<IStartStopDInputsCallback>(object)
28 {
29 }
30 
~StartStopDInputsCallbackProxy()31 StartStopDInputsCallbackProxy::~StartStopDInputsCallbackProxy() {}
32 
OnResultDhids(const std::string & devId,const int32_t & status)33 void StartStopDInputsCallbackProxy::OnResultDhids(const std::string &devId, const int32_t &status)
34 {
35     sptr<IRemoteObject> remote = Remote();
36     if (remote == nullptr) {
37         return;
38     }
39 
40     MessageParcel data;
41     MessageParcel reply;
42     MessageOption option;
43     if (!data.WriteInterfaceToken(GetDescriptor())) {
44         DHLOGE("StartStopDInputsCallbackProxy write token valid failed");
45         return;
46     }
47     if (!data.WriteString(devId)) {
48         DHLOGE("StartStopDInputsCallbackProxy write devId valid failed");
49         return;
50     }
51     if (!data.WriteInt32(status)) {
52         DHLOGE("StartStopDInputsCallbackProxy write status valid failed");
53         return;
54     }
55     int32_t ret = remote->SendRequest(static_cast<uint32_t>(IStartStopDInputsCallback::Message::RESULT_STRING),
56                                       data, reply, option);
57     if (ret != 0) {
58         DHLOGE("OnResultDhids error, ret = %{public}d", ret);
59         return;
60     }
61     DHLOGI("OnResultDhids success.");
62 }
63 } // namespace DistributedInput
64 } // namespace DistributedHardware
65 } // namespace OHOS
66