1 /*
2  * Copyright (c) 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 "dcamera_sink_callback_proxy.h"
17 
18 #include "parcel.h"
19 
20 #include "anonymous_string.h"
21 #include "distributed_camera_errno.h"
22 #include "distributed_hardware_log.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
OnNotifyResourceInfo(const ResourceEventType & type,const std::string & subtype,const std::string & networkId,bool & isSensitive,bool & isSameAccout)26 int32_t DCameraSinkCallbackProxy::OnNotifyResourceInfo(const ResourceEventType &type, const std::string &subtype,
27     const std::string &networkId, bool &isSensitive, bool &isSameAccout)
28 {
29     sptr<IRemoteObject> remote = Remote();
30     if (remote == nullptr) {
31         DHLOGE("DCameraSinkCallbackProxy remote service null");
32         return DCAMERA_BAD_VALUE;
33     }
34     MessageParcel req;
35     MessageParcel reply;
36     MessageOption option;
37     if (!req.WriteInterfaceToken(DCameraSinkCallbackProxy::GetDescriptor())) {
38         DHLOGE("Write token failed");
39         return DCAMERA_BAD_VALUE;
40     }
41 
42     int32_t resType = static_cast<int32_t>(type);
43     if (!req.WriteInt32(resType) || !req.WriteString(subtype) || !req.WriteString(networkId)) {
44         DHLOGE("DCameraSinkCallbackProxy InitSink write params failed");
45         return DCAMERA_BAD_VALUE;
46     }
47     remote->SendRequest(NOTIFY_RESOURCEINFO, req, reply, option);
48     int32_t result = reply.ReadInt32();
49     isSensitive = reply.ReadBool();
50     isSameAccout = reply.ReadBool();
51     return result;
52 }
53 } // namespace DistributedHardware
54 } // namespace OHOS
55