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 "fusion_services_binding.h"
17 
18 #include "devicestatus_define.h"
19 #include "fi_log.h"
20 
21 #undef LOG_TAG
22 #define LOG_TAG "fusion_services_binding"
23 
24 using namespace ::OHOS::Msdp::DeviceStatus;
25 
26 struct NativeService {
27     int32_t refCnt { 0 };
28 };
29 
NativeServiceNew(void)30 struct NativeService* NativeServiceNew(void)
31 {
32     CALL_DEBUG_ENTER;
33     struct NativeService *service = new NativeService;
34     service->refCnt = 1;
35     return service;
36 }
37 
NativeServiceRef(struct NativeService * service)38 struct NativeService* NativeServiceRef(struct NativeService *service)
39 {
40     CHKPP(service);
41     service->refCnt++;
42     return service;
43 }
44 
NativeServiceUnref(struct NativeService * service)45 struct NativeService* NativeServiceUnref(struct NativeService *service)
46 {
47     CHKPP(service);
48     if (service->refCnt > 0) {
49         service->refCnt--;
50     }
51     if (service->refCnt > 0) {
52         return service;
53     }
54     delete service;
55     FI_HILOGI("Device status service instance is deleted");
56     return nullptr;
57 }
58 
NativeServiceOnDump(struct NativeService * service)59 void NativeServiceOnDump(struct NativeService *service)
60 {
61     CALL_INFO_TRACE;
62     CHKPV(service);
63 }
64 
NativeServiceOnStart(struct NativeService * service)65 void NativeServiceOnStart(struct NativeService *service)
66 {
67     CALL_INFO_TRACE;
68     CHKPV(service);
69 }
70 
NativeServiceOnStop(struct NativeService * service)71 void NativeServiceOnStop(struct NativeService *service)
72 {
73     CALL_INFO_TRACE;
74     CHKPV(service);
75 }
76 
NativeServiceAllocSocketFd(struct NativeService * service,const char * programName,int32_t moduleType,int32_t * toReturnClientFd,int32_t * tokenType)77 int32_t NativeServiceAllocSocketFd(struct NativeService *service, const char *programName,
78     int32_t moduleType, int32_t *toReturnClientFd, int32_t *tokenType)
79 {
80     CALL_DEBUG_ENTER;
81     return RET_ERR;
82 }
83