• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 using namespace ::OHOS::Msdp::DeviceStatus;
22 
23 namespace {
24 constexpr ::OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, ::OHOS::Msdp::MSDP_DOMAIN_ID, "fusion_services_binding" };
25 } // namespace
26 
27 struct NativeService {
28     int32_t refCnt;
29 };
30 
NativeService_New()31 struct NativeService* NativeService_New()
32 {
33     CALL_DEBUG_ENTER;
34     struct NativeService *service = new NativeService;
35     service->refCnt = 1;
36     return service;
37 }
38 
NativeService_Ref(struct NativeService * service)39 struct NativeService* NativeService_Ref(struct NativeService *service)
40 {
41     CHKPP(service);
42     service->refCnt++;
43     return service;
44 }
45 
NativeService_Unref(struct NativeService * service)46 struct NativeService* NativeService_Unref(struct NativeService *service)
47 {
48     CHKPP(service);
49     if (service->refCnt > 0) {
50         service->refCnt--;
51     }
52     if (service->refCnt > 0) {
53         return service;
54     }
55     delete service;
56     FI_HILOGI("Device status service instance is deleted");
57     return nullptr;
58 }
59 
NativeService_OnDump(struct NativeService * service)60 void NativeService_OnDump(struct NativeService *service)
61 {
62     CALL_INFO_TRACE;
63     CHKPV(service);
64 }
65 
NativeService_OnStart(struct NativeService * service)66 void NativeService_OnStart(struct NativeService *service)
67 {
68     CALL_INFO_TRACE;
69     CHKPV(service);
70 }
71 
NativeService_OnStop(struct NativeService * service)72 void NativeService_OnStop(struct NativeService *service)
73 {
74     CALL_INFO_TRACE;
75     CHKPV(service);
76 }
77 
NativeService_AllocSocketFd(struct NativeService * service,const char * programName,int32_t moduleType,int32_t * toReturnClientFd,int32_t * tokenType)78 int32_t NativeService_AllocSocketFd(struct NativeService *service, const char *programName,
79     int32_t moduleType, int32_t *toReturnClientFd, int32_t *tokenType)
80 {
81     CALL_DEBUG_ENTER;
82     return RET_ERR;
83 }
84