• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 "ipc_callback_proxy.h"
17 #include "hc_log.h"
18 #include "ipc_adapt.h"
19 #include "system_ability_definition.h"
20 
21 namespace OHOS {
ProxyDevAuthCb(const sptr<IRemoteObject> & impl)22 ProxyDevAuthCb::ProxyDevAuthCb(const sptr<IRemoteObject> &impl) : IRemoteProxy<ICommIpcCallback>(impl)
23 {}
24 
~ProxyDevAuthCb()25 ProxyDevAuthCb::~ProxyDevAuthCb()
26 {}
27 
DoCallBack(int32_t callbackId,uintptr_t cbHook,MessageParcel & dataParcel,MessageParcel & reply,MessageOption & option)28 void ProxyDevAuthCb::DoCallBack(int32_t callbackId, uintptr_t cbHook,
29     MessageParcel &dataParcel, MessageParcel &reply, MessageOption &option)
30 {
31     int32_t ret;
32     MessageParcel data;
33 
34     sptr<IRemoteObject> remote = Remote();
35     if (remote == nullptr) {
36         LOGE("Proxy DoCallBack Remote() is null");
37         return;
38     }
39     if (!data.WriteInterfaceToken(GetDescriptor())) {
40         LOGE("[IPC][S->C]: Failed to write interface token!");
41         return;
42     }
43     (void)data.WriteInt32(callbackId);
44     (void)data.WritePointer(cbHook);
45     if (dataParcel.GetDataSize() > 0) {
46         (void)data.WriteBuffer(reinterpret_cast<const void *>(dataParcel.GetData()), dataParcel.GetDataSize());
47     }
48     ret = remote->SendRequest(static_cast<uint32_t>(DevAuthCbInterfaceCode::DEV_AUTH_CALLBACK_REQUEST),
49         data, reply, option);
50     if (ret != NO_ERROR) {
51         LOGE("SendRequest is failed, error code: %d", ret);
52     }
53     return;
54 }
55 }