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 "add_white_list_infos_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 {
AddWhiteListInfosCallbackProxy(const sptr<IRemoteObject> & object)26 AddWhiteListInfosCallbackProxy::AddWhiteListInfosCallbackProxy(const sptr<IRemoteObject> &object)
27     : IRemoteProxy<IAddWhiteListInfosCallback>(object)
28 {
29 }
30 
~AddWhiteListInfosCallbackProxy()31 AddWhiteListInfosCallbackProxy::~AddWhiteListInfosCallbackProxy()
32 {
33 }
34 
OnResult(const std::string & deviceId,const std::string & strJson)35 void AddWhiteListInfosCallbackProxy::OnResult(const std::string &deviceId, const std::string &strJson)
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("AddWhiteListInfosCallbackProxy write token valid failed");
47         return;
48     }
49     if (!data.WriteString(deviceId)) {
50         DHLOGE("AddWhiteListInfosCallbackProxy write deviceId failed");
51         return;
52     }
53     if (!data.WriteString(strJson)) {
54         DHLOGE("AddWhiteListInfosCallbackProxy write strJson failed");
55         return;
56     }
57     remote->SendRequest(static_cast<uint32_t>(IAddWhiteListInfosCallback::Message::RESULT), data, reply, option);
58 }
59 } // namespace DistributedInput
60 } // namespace DistributedHardware
61 } // namespace OHOS
62