1 /*
2  * Copyright (c) 2021-2023 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 "prepare_d_input_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 {
PrepareDInputCallbackProxy(const sptr<IRemoteObject> & object)26 PrepareDInputCallbackProxy::PrepareDInputCallbackProxy(const sptr<IRemoteObject> &object)
27     : IRemoteProxy<IPrepareDInputCallback>(object)
28 {
29 }
30 
~PrepareDInputCallbackProxy()31 PrepareDInputCallbackProxy::~PrepareDInputCallbackProxy()
32 {
33 }
34 
OnResult(const std::string & deviceId,const int32_t & status)35 void PrepareDInputCallbackProxy::OnResult(const std::string &deviceId, const int32_t &status)
36 {
37     sptr<IRemoteObject> remote = Remote();
38     if (remote == nullptr) {
39         return;
40     }
41 
42     MessageParcel data;
43     MessageParcel reply;
44     MessageOption option;
45     if (!data.WriteInterfaceToken(GetDescriptor())) {
46         DHLOGE("PrepareDInputCallbackProxy write token valid failed");
47         return;
48     }
49     if (!data.WriteString(deviceId)) {
50         return;
51     }
52     if (!data.WriteInt32(status)) {
53         return;
54     }
55     int32_t ret = remote->SendRequest(
56         static_cast<uint32_t>(IPrepareDInputCallback::Message::RESULT), data, reply, option);
57     if (ret != 0) {
58         return;
59     }
60 }
61 } // namespace DistributedInput
62 } // namespace DistributedHardware
63 } // namespace OHOS
64