1 /*
2 * Copyright (c) 2024 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 "geolocationmanager_ffi.h"
17 #include "geolocationmanager_impl.h"
18
19 namespace OHOS {
20 namespace GeoLocationManager {
21 extern "C" {
FfiOHOSGeoLocationManagerGetLastLocation(int32_t * errCode)22 CJLocation FfiOHOSGeoLocationManagerGetLastLocation(int32_t* errCode)
23 {
24 return GetLastLocation(*errCode);
25 }
26
FfiOHOSGeoLocationManagerIsLocationEnabled(int32_t * errCode)27 bool FfiOHOSGeoLocationManagerIsLocationEnabled(int32_t* errCode)
28 {
29 return IsLocationEnabled(*errCode);
30 }
31
FfiOHOSGeoLocationManagerIsGeocoderAvailable(int32_t * errCode)32 bool FfiOHOSGeoLocationManagerIsGeocoderAvailable(int32_t* errCode)
33 {
34 return IsGeocoderAvailable(*errCode);
35 }
36
FfiOHOSGeoLocationManagerGetCachedGnssLocationsSize(int32_t * errCode)37 int32_t FfiOHOSGeoLocationManagerGetCachedGnssLocationsSize(int32_t* errCode)
38 {
39 return GetCachedGnssLocationsSize(*errCode);
40 }
41
FfiOHOSGeoLocationManagerGetCurrentLocation(int32_t * errCode)42 CJLocation FfiOHOSGeoLocationManagerGetCurrentLocation(int32_t* errCode)
43 {
44 return GetCurrentLocation(*errCode);
45 }
46
FfiOHOSGeoLocationManagerGetCurrentLocationCurrent(CJCurrentLocationRequest request,int32_t * errCode)47 CJLocation FfiOHOSGeoLocationManagerGetCurrentLocationCurrent(CJCurrentLocationRequest request, int32_t* errCode)
48 {
49 return GetCurrentLocationCurrent(request, *errCode);
50 }
51
FfiOHOSGeoLocationManagerGetCurrentLocationSingle(CJSingleLocationRequest request,int32_t * errCode)52 CJLocation FfiOHOSGeoLocationManagerGetCurrentLocationSingle(CJSingleLocationRequest request, int32_t* errCode)
53 {
54 return GetCurrentLocationSingle(request, *errCode);
55 }
56
FfiOHOSGeoLocationManagerFlushCachedGnssLocations(int32_t * errCode)57 FFI_EXPORT void FfiOHOSGeoLocationManagerFlushCachedGnssLocations(int32_t* errCode)
58 {
59 return FlushCachedGnssLocations(*errCode);
60 }
61
FfiOHOSGeoLocationManagerSendCommand(CJLocationCommand command,int32_t * errCode)62 void FfiOHOSGeoLocationManagerSendCommand(CJLocationCommand command, int32_t* errCode)
63 {
64 return SendCommand(command, *errCode);
65 }
66
FfiOHOSGeoLocationManagerGetCountryCode(int32_t * errCode)67 CJCountryCode FfiOHOSGeoLocationManagerGetCountryCode(int32_t* errCode)
68 {
69 return GetCountryCode(*errCode);
70 }
71
FfiOHOSGeoLocationManagerGetAddressesFromLocation(CJReverseGeoCodeRequest request,int32_t * errCode)72 CJGeoAddressArr FfiOHOSGeoLocationManagerGetAddressesFromLocation(CJReverseGeoCodeRequest request,
73 int32_t* errCode)
74 {
75 return GetAddressesFromLocation(request, *errCode);
76 }
77
FfiOHOSGeoLocationManagerGetAddressesFromLocationName(CJGeoCodeRequest request,int32_t * errCode)78 CJGeoAddressArr FfiOHOSGeoLocationManagerGetAddressesFromLocationName(CJGeoCodeRequest request,
79 int32_t* errCode)
80 {
81 return GetAddressesFromLocationName(request, *errCode);
82 }
83
FfiGeoLocationManagerOnLocationChange(CJLocationRequest request,int64_t callbackId)84 int32_t FfiGeoLocationManagerOnLocationChange(CJLocationRequest request, int64_t callbackId)
85 {
86 return OnLocationRequest(request, callbackId);
87 }
88
FfiGeoLocationManagerOnContinuousLocationRequest(CJContinuousLocationRequest request,int64_t callbackId)89 int32_t FfiGeoLocationManagerOnContinuousLocationRequest(CJContinuousLocationRequest request, int64_t callbackId)
90 {
91 return OnContinuousLocationRequest(request, callbackId);
92 }
93
FfiGeoLocationManagerOffLocationChange(int64_t callbackId)94 int32_t FfiGeoLocationManagerOffLocationChange(int64_t callbackId)
95 {
96 return OffLocationChange(callbackId);
97 }
98
FfiGeoLocationManagerOffLocationChangeAll()99 int32_t FfiGeoLocationManagerOffLocationChangeAll()
100 {
101 return OffLocationChangeAll();
102 }
103
FfiGeoLocationManagerOnLocationError(int64_t callbackId)104 int32_t FfiGeoLocationManagerOnLocationError(int64_t callbackId)
105 {
106 return OnLocationError(callbackId);
107 }
108
FfiGeoLocationManagerOffLocationError(int64_t callbackId)109 int32_t FfiGeoLocationManagerOffLocationError(int64_t callbackId)
110 {
111 return OffLocationError(callbackId);
112 }
113
FfiGeoLocationManagerOffLocationErrorAll()114 int32_t FfiGeoLocationManagerOffLocationErrorAll()
115 {
116 return OffLocationErrorAll();
117 }
118
FfiGeoLocationManagerOnLocationEnabledChange(int64_t callbackId)119 int32_t FfiGeoLocationManagerOnLocationEnabledChange(int64_t callbackId)
120 {
121 return OnLocationEnabledChange(callbackId);
122 }
123
FfiGeoLocationManagerOffLocationEnabledChange(int64_t callbackId)124 int32_t FfiGeoLocationManagerOffLocationEnabledChange(int64_t callbackId)
125 {
126 return OffLocationEnabledChange(callbackId);
127 }
128
FfiGeoLocationManagerOffLocationEnabledChangeAll()129 int32_t FfiGeoLocationManagerOffLocationEnabledChangeAll()
130 {
131 return OffLocationEnabledChangeAll();
132 }
133
FfiGeoLocationManagerOnCachedGnssLocationsChange(CJCachedGnssLocationsRequest request,int64_t callbackId)134 int32_t FfiGeoLocationManagerOnCachedGnssLocationsChange(CJCachedGnssLocationsRequest request,
135 int64_t callbackId)
136 {
137 return OnCachedGnssLocationsChange(request, callbackId);
138 }
139
FfiGeoLocationManagerOffCachedGnssLocationsChange(int64_t callbackId)140 int32_t FfiGeoLocationManagerOffCachedGnssLocationsChange(int64_t callbackId)
141 {
142 return OffCachedGnssLocationsChange(callbackId);
143 }
144
FfiGeoLocationManagerOffCachedGnssLocationsChangeAll()145 int32_t FfiGeoLocationManagerOffCachedGnssLocationsChangeAll()
146 {
147 return OffCachedGnssLocationsChangeAll();
148 }
149
FfiGeoLocationManagerOnSatelliteStatusChange(int64_t callbackId)150 int32_t FfiGeoLocationManagerOnSatelliteStatusChange(int64_t callbackId)
151 {
152 return OnSatelliteStatusChange(callbackId);
153 }
154
FfiGeoLocationManagerOffSatelliteStatusChange(int64_t callbackId)155 int32_t FfiGeoLocationManagerOffSatelliteStatusChange(int64_t callbackId)
156 {
157 return OffSatelliteStatusChange(callbackId);
158 }
159
FfiGeoLocationManagerOffSatelliteStatusChangeAll()160 int32_t FfiGeoLocationManagerOffSatelliteStatusChangeAll()
161 {
162 return OffSatelliteStatusChangeAll();
163 }
164
FfiGeoLocationManagerOnNmeaMessage(int64_t callbackId)165 int32_t FfiGeoLocationManagerOnNmeaMessage(int64_t callbackId)
166 {
167 return OnNmeaMessage(callbackId);
168 }
169
FfiGeoLocationManagerOffNmeaMessage(int64_t callbackId)170 int32_t FfiGeoLocationManagerOffNmeaMessage(int64_t callbackId)
171 {
172 return OffNmeaMessage(callbackId);
173 }
174
FfiGeoLocationManagerOffNmeaMessageAll()175 int32_t FfiGeoLocationManagerOffNmeaMessageAll()
176 {
177 return OffNmeaMessageAll();
178 }
179
FfiGeoLocationManagerOnCountryCodeChange(int64_t callbackId)180 int32_t FfiGeoLocationManagerOnCountryCodeChange(int64_t callbackId)
181 {
182 return OnCountryCodeChange(callbackId);
183 }
184
FfiGeoLocationManagerOffCountryCodeChange(int64_t callbackId)185 int32_t FfiGeoLocationManagerOffCountryCodeChange(int64_t callbackId)
186 {
187 return OffCountryCodeChange(callbackId);
188 }
189
FfiGeoLocationManagerOffCountryCodeChangeAll()190 int32_t FfiGeoLocationManagerOffCountryCodeChangeAll()
191 {
192 return OffCountryCodeChangeAll();
193 }
194
FfiGeoLocationManagerGetGeofenceSupportedCoordTypes(int32_t * errCode)195 CArrI32 FfiGeoLocationManagerGetGeofenceSupportedCoordTypes(int32_t* errCode)
196 {
197 return GetGeofenceSupportedCoordTypes(*errCode);
198 }
199 }
200 }
201 }
202