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 "stop_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 {
StopDInputCallbackProxy(const sptr<IRemoteObject> & object)26 StopDInputCallbackProxy::StopDInputCallbackProxy(const sptr<IRemoteObject> &object)
27     : IRemoteProxy<IStopDInputCallback>(object)
28 {
29 }
30 
~StopDInputCallbackProxy()31 StopDInputCallbackProxy::~StopDInputCallbackProxy()
32 {
33 }
34 
OnResult(const std::string & devId,const uint32_t & inputTypes,const int32_t & status)35 void StopDInputCallbackProxy::OnResult(const std::string &devId, const uint32_t &inputTypes, 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("StopDInputCallbackProxy write token valid failed");
47         return;
48     }
49     if (!data.WriteString(devId)) {
50         DHLOGE("StopDInputCallbackProxy write devId failed");
51         return;
52     }
53     if (!data.WriteUint32(inputTypes)) {
54         DHLOGE("StopDInputCallbackProxy write inputTypes failed");
55         return;
56     }
57     if (!data.WriteInt32(status)) {
58         DHLOGE("StopDInputCallbackProxy write status failed");
59         return;
60     }
61     int32_t ret = remote->SendRequest(
62         static_cast<int32_t>(IStopDInputCallback::Message::RESULT), data, reply, option);
63     if (ret != 0) {
64         return;
65     }
66 }
67 } // namespace DistributedInput
68 } // namespace DistributedHardware
69 } // namespace OHOS
70