1 /*
2 * Copyright (C) 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 "constant_definition.h"
17 #include "napi_util.h"
18 #include "location_log.h"
19 #include "location_napi_adapter.h"
20 #include "location_napi_event.h"
21 #include "location_napi_system.h"
22 #include "geofence_definition.h"
23 #include "beacon_fence.h"
24
25 namespace OHOS {
26 namespace Location {
CoordinateSystemTypeConstructor(napi_env env)27 napi_value CoordinateSystemTypeConstructor(napi_env env)
28 {
29 napi_value coordinateSystemType;
30 NAPI_CALL(env, napi_create_object(env, &coordinateSystemType));
31 SetEnumPropertyByInteger(env, coordinateSystemType, CoordinateSystemType::WGS84, "WGS84");
32 SetEnumPropertyByInteger(env, coordinateSystemType, CoordinateSystemType::GCJ02, "GCJ02");
33 return coordinateSystemType;
34 }
35
GeofenceTransitionEventConstructor(napi_env env)36 napi_value GeofenceTransitionEventConstructor(napi_env env)
37 {
38 napi_value geofenceTransitionStatus = nullptr;
39 NAPI_CALL(env, napi_create_object(env, &geofenceTransitionStatus));
40 SetEnumPropertyByInteger(env, geofenceTransitionStatus,
41 GeofenceTransitionEvent::GEOFENCE_TRANSITION_EVENT_ENTER, "GEOFENCE_TRANSITION_EVENT_ENTER");
42 SetEnumPropertyByInteger(env, geofenceTransitionStatus,
43 GeofenceTransitionEvent::GEOFENCE_TRANSITION_EVENT_EXIT, "GEOFENCE_TRANSITION_EVENT_EXIT");
44 SetEnumPropertyByInteger(env, geofenceTransitionStatus,
45 GeofenceTransitionEvent::GEOFENCE_TRANSITION_EVENT_DWELL, "GEOFENCE_TRANSITION_EVENT_DWELL");
46 return geofenceTransitionStatus;
47 }
48
SvConstellationTypeConstructor(napi_env env)49 napi_value SvConstellationTypeConstructor(napi_env env)
50 {
51 napi_value satelliteConstellationCategory = nullptr;
52 NAPI_CALL(env, napi_create_object(env, &satelliteConstellationCategory));
53 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
54 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_UNKNOWN, "CONSTELLATION_CATEGORY_UNKNOWN");
55 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
56 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_GPS, "CONSTELLATION_CATEGORY_GPS");
57 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
58 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_SBAS, "CONSTELLATION_CATEGORY_SBAS");
59 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
60 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_GLONASS, "CONSTELLATION_CATEGORY_GLONASS");
61 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
62 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_QZSS, "CONSTELLATION_CATEGORY_QZSS");
63 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
64 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_BEIDOU, "CONSTELLATION_CATEGORY_BEIDOU");
65 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
66 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_GALILEO, "CONSTELLATION_CATEGORY_GALILEO");
67 SetEnumPropertyByInteger(env, satelliteConstellationCategory,
68 SatelliteConstellation::SV_CONSTELLATION_CATEGORY_IRNSS, "CONSTELLATION_CATEGORY_IRNSS");
69 return satelliteConstellationCategory;
70 }
71
SatelliteAdditionalInfoTypeConstructor(napi_env env)72 napi_value SatelliteAdditionalInfoTypeConstructor(napi_env env)
73 {
74 napi_value satelliteAdditionalInfo = nullptr;
75 NAPI_CALL(env, napi_create_object(env, &satelliteAdditionalInfo));
76 SetEnumPropertyByInteger(env, satelliteAdditionalInfo,
77 SatelliteAdditionalInfo::SV_ADDITIONAL_INFO_NULL, "SATELLITES_ADDITIONAL_INFO_NULL");
78 SetEnumPropertyByInteger(env, satelliteAdditionalInfo,
79 SatelliteAdditionalInfo::SV_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST,
80 "SATELLITES_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST");
81 SetEnumPropertyByInteger(env, satelliteAdditionalInfo,
82 SatelliteAdditionalInfo::SV_ADDITIONAL_INFO_ALMANAC_DATA_EXIST,
83 "SATELLITES_ADDITIONAL_INFO_ALMANAC_DATA_EXIST");
84 SetEnumPropertyByInteger(env, satelliteAdditionalInfo,
85 SatelliteAdditionalInfo::SV_ADDITIONAL_INFO_USED_IN_FIX,
86 "SATELLITES_ADDITIONAL_INFO_USED_IN_FIX");
87 SetEnumPropertyByInteger(env, satelliteAdditionalInfo,
88 SatelliteAdditionalInfo::SV_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST,
89 "SATELLITES_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST");
90 return satelliteAdditionalInfo;
91 }
92
LocationRequestPriorityTypeConstructor(napi_env env)93 napi_value LocationRequestPriorityTypeConstructor(napi_env env)
94 {
95 napi_value locationRequestPriority = nullptr;
96 NAPI_CALL(env, napi_create_object(env, &locationRequestPriority));
97 SetEnumPropertyByInteger(env, locationRequestPriority, PRIORITY_UNSET, "UNSET");
98 SetEnumPropertyByInteger(env, locationRequestPriority, PRIORITY_ACCURACY, "ACCURACY");
99 SetEnumPropertyByInteger(env, locationRequestPriority, PRIORITY_LOW_POWER, "LOW_POWER");
100 SetEnumPropertyByInteger(env, locationRequestPriority, PRIORITY_FAST_FIRST_FIX, "FIRST_FIX");
101 return locationRequestPriority;
102 }
103
LocationRequestScenarioTypeConstructor(napi_env env)104 napi_value LocationRequestScenarioTypeConstructor(napi_env env)
105 {
106 napi_value locationRequestScenario = nullptr;
107 NAPI_CALL(env, napi_create_object(env, &locationRequestScenario));
108 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_UNSET, "UNSET");
109 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_NAVIGATION, "NAVIGATION");
110 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_TRAJECTORY_TRACKING, "TRAJECTORY_TRACKING");
111 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_CAR_HAILING, "CAR_HAILING");
112 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_DAILY_LIFE_SERVICE, "DAILY_LIFE_SERVICE");
113 SetEnumPropertyByInteger(env, locationRequestScenario, SCENE_NO_POWER, "NO_POWER");
114 return locationRequestScenario;
115 }
116
UserActivityScenarioTypeConstructor(napi_env env)117 napi_value UserActivityScenarioTypeConstructor(napi_env env)
118 {
119 napi_value userActivityScenario = nullptr;
120 NAPI_CALL(env, napi_create_object(env, &userActivityScenario));
121 SetEnumPropertyByInteger(env, userActivityScenario, LOCATION_SCENE_NAVIGATION, "NAVIGATION");
122 SetEnumPropertyByInteger(env, userActivityScenario, LOCATION_SCENE_SPORT, "SPORT");
123 SetEnumPropertyByInteger(env, userActivityScenario, LOCATION_SCENE_TRANSPORT, "TRANSPORT");
124 SetEnumPropertyByInteger(env, userActivityScenario, LOCATION_SCENE_DAILY_LIFE_SERVICE, "DAILY_LIFE_SERVICE");
125 return userActivityScenario;
126 }
127
LocatingPriorityTypeConstructor(napi_env env)128 napi_value LocatingPriorityTypeConstructor(napi_env env)
129 {
130 napi_value locatingPriority = nullptr;
131 NAPI_CALL(env, napi_create_object(env, &locatingPriority));
132 SetEnumPropertyByInteger(env, locatingPriority, LOCATION_PRIORITY_ACCURACY, "PRIORITY_ACCURACY");
133 SetEnumPropertyByInteger(env, locatingPriority, LOCATION_PRIORITY_LOCATING_SPEED, "PRIORITY_LOCATING_SPEED");
134 return locatingPriority;
135 }
136
PowerConsumptionScenarioTypeConstructor(napi_env env)137 napi_value PowerConsumptionScenarioTypeConstructor(napi_env env)
138 {
139 napi_value powerConsumptionScenario = nullptr;
140 NAPI_CALL(env, napi_create_object(env, &powerConsumptionScenario));
141 SetEnumPropertyByInteger(env, powerConsumptionScenario,
142 LOCATION_SCENE_HIGH_POWER_CONSUMPTION, "HIGH_POWER_CONSUMPTION");
143 SetEnumPropertyByInteger(env, powerConsumptionScenario,
144 LOCATION_SCENE_LOW_POWER_CONSUMPTION, "LOW_POWER_CONSUMPTION");
145 SetEnumPropertyByInteger(env, powerConsumptionScenario,
146 LOCATION_SCENE_NO_POWER_CONSUMPTION, "NO_POWER_CONSUMPTION");
147 return powerConsumptionScenario;
148 }
149
LocationPrivacyTypeConstructor(napi_env env)150 napi_value LocationPrivacyTypeConstructor(napi_env env)
151 {
152 napi_value locationPrivacyType = nullptr;
153 NAPI_CALL(env, napi_create_object(env, &locationPrivacyType));
154 SetEnumPropertyByInteger(env, locationPrivacyType, PRIVACY_TYPE_OTHERS, "OTHERS");
155 SetEnumPropertyByInteger(env, locationPrivacyType, PRIVACY_TYPE_STARTUP, "STARTUP");
156 SetEnumPropertyByInteger(env, locationPrivacyType, PRIVACY_TYPE_CORE_LOCATION, "CORE_LOCATION");
157 return locationPrivacyType;
158 }
159
CountryCodeTypeConstructor(napi_env env)160 napi_value CountryCodeTypeConstructor(napi_env env)
161 {
162 napi_value countryCodeType = nullptr;
163 NAPI_CALL(env, napi_create_object(env, &countryCodeType));
164 SetEnumPropertyByInteger(env, countryCodeType, COUNTRY_CODE_FROM_LOCALE, "COUNTRY_CODE_FROM_LOCALE");
165 SetEnumPropertyByInteger(env, countryCodeType, COUNTRY_CODE_FROM_SIM, "COUNTRY_CODE_FROM_SIM");
166 SetEnumPropertyByInteger(env, countryCodeType, COUNTRY_CODE_FROM_LOCATION, "COUNTRY_CODE_FROM_LOCATION");
167 SetEnumPropertyByInteger(env, countryCodeType, COUNTRY_CODE_FROM_NETWORK, "COUNTRY_CODE_FROM_NETWORK");
168 return countryCodeType;
169 }
170
GeoLocationErrorCodeTypeConstructor(napi_env env)171 napi_value GeoLocationErrorCodeTypeConstructor(napi_env env)
172 {
173 napi_value geoLocationErrorCode = nullptr;
174 NAPI_CALL(env, napi_create_object(env, &geoLocationErrorCode));
175 SetEnumPropertyByInteger(env, geoLocationErrorCode, INPUT_PARAMS_ERROR, "INPUT_PARAMS_ERROR");
176 SetEnumPropertyByInteger(env, geoLocationErrorCode, REVERSE_GEOCODE_ERROR, "REVERSE_GEOCODE_ERROR");
177 SetEnumPropertyByInteger(env, geoLocationErrorCode, GEOCODE_ERROR, "GEOCODE_ERROR");
178 SetEnumPropertyByInteger(env, geoLocationErrorCode, LOCATOR_ERROR, "LOCATOR_ERROR");
179 SetEnumPropertyByInteger(env, geoLocationErrorCode, LOCATION_SWITCH_ERROR, "LOCATION_SWITCH_ERROR");
180 SetEnumPropertyByInteger(env, geoLocationErrorCode, LAST_KNOWN_LOCATION_ERROR, "LAST_KNOWN_LOCATION_ERROR");
181 SetEnumPropertyByInteger(env, geoLocationErrorCode,
182 LOCATION_REQUEST_TIMEOUT_ERROR, "LOCATION_REQUEST_TIMEOUT_ERROR");
183 return geoLocationErrorCode;
184 }
185
LocatingRequiredDataTypeConstructor(napi_env env)186 napi_value LocatingRequiredDataTypeConstructor(napi_env env)
187 {
188 napi_value locatingPriority = nullptr;
189 NAPI_CALL(env, napi_create_object(env, &locatingPriority));
190 SetEnumPropertyByInteger(env, locatingPriority, LocatingRequiredDataType::WIFI, "WIFI");
191 SetEnumPropertyByInteger(env, locatingPriority, LocatingRequiredDataType::BLUE_TOOTH, "BLUE_TOOTH");
192 return locatingPriority;
193 }
194
LocationSourceTypeConstructor(napi_env env)195 napi_value LocationSourceTypeConstructor(napi_env env)
196 {
197 napi_value locationSourceType = nullptr;
198 NAPI_CALL(env, napi_create_object(env, &locationSourceType));
199 SetEnumPropertyByInteger(env, locationSourceType, LocationSourceType::GNSS_TYPE, "GNSS");
200 SetEnumPropertyByInteger(env, locationSourceType, LocationSourceType::NETWORK_TYPE, "NETWORK");
201 SetEnumPropertyByInteger(env, locationSourceType, LocationSourceType::INDOOR_TYPE, "INDOOR");
202 SetEnumPropertyByInteger(env, locationSourceType, LocationSourceType::RTK_TYPE, "RTK");
203 return locationSourceType;
204 }
205
LocationErrorConstructor(napi_env env)206 napi_value LocationErrorConstructor(napi_env env)
207 {
208 napi_value locationError = nullptr;
209 NAPI_CALL(env, napi_create_object(env, &locationError));
210 SetEnumPropertyByInteger(env, locationError, LocationErr::LOCATING_FAILED_DEFAULT, "LOCATING_FAILED_DEFAULT");
211 SetEnumPropertyByInteger(env, locationError,
212 LocationErr::LOCATING_FAILED_LOCATION_PERMISSION_DENIED, "LOCATING_FAILED_LOCATION_PERMISSION_DENIED");
213 SetEnumPropertyByInteger(env, locationError,
214 LocationErr::LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED, "LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED");
215 SetEnumPropertyByInteger(env, locationError,
216 LocationErr::LOCATING_FAILED_LOCATION_SWITCH_OFF, "LOCATING_FAILED_LOCATION_SWITCH_OFF");
217 SetEnumPropertyByInteger(env, locationError,
218 LocationErr::LOCATING_FAILED_INTERNET_ACCESS_FAILURE, "LOCATING_FAILED_INTERNET_ACCESS_FAILURE");
219 return locationError;
220 }
221
SportsTypeConstructor(napi_env env)222 napi_value SportsTypeConstructor(napi_env env)
223 {
224 napi_value sportsType = nullptr;
225 NAPI_CALL(env, napi_create_object(env, &sportsType));
226 SetEnumPropertyByInteger(env, sportsType, SportsType::RUNNING, "RUNNING");
227 SetEnumPropertyByInteger(env, sportsType, SportsType::WALKING, "WALKING");
228 SetEnumPropertyByInteger(env, sportsType, SportsType::CYCLING, "CYCLING");
229 return sportsType;
230 }
231
BeaconFenceInfoTypeConstructor(napi_env env)232 napi_value BeaconFenceInfoTypeConstructor(napi_env env)
233 {
234 napi_value beaconFenceInfoType = nullptr;
235 NAPI_CALL(env, napi_create_object(env, &beaconFenceInfoType));
236 SetEnumPropertyByInteger(env, beaconFenceInfoType, BeaconFenceInfoType::BEACON_MANUFACTURE_DATA,
237 "BEACON_MANUFACTURE_DATA");
238 return beaconFenceInfoType;
239 }
240
241 #ifndef ENABLE_NAPI_MANAGER
242 /*
243 * Module initialization function
244 */
Init(napi_env env,napi_value exports)245 static napi_value Init(napi_env env, napi_value exports)
246 {
247 LBSLOGI(LOCATION_NAPI, "Init,location_napi_entry");
248
249 napi_property_descriptor desc[] = {
250 DECLARE_NAPI_FUNCTION("getLastLocation", GetLastLocation),
251 DECLARE_NAPI_FUNCTION("isLocationEnabled", IsLocationEnabled),
252 DECLARE_NAPI_FUNCTION("requestEnableLocation", RequestEnableLocation),
253 DECLARE_NAPI_FUNCTION("enableLocation", EnableLocation),
254 DECLARE_NAPI_FUNCTION("disableLocation", DisableLocation),
255 DECLARE_NAPI_FUNCTION("getAddressesFromLocation", GetAddressesFromLocation),
256 DECLARE_NAPI_FUNCTION("getAddressesFromLocationName", GetAddressesFromLocationName),
257 DECLARE_NAPI_FUNCTION("isGeoServiceAvailable", IsGeoServiceAvailable),
258 DECLARE_NAPI_FUNCTION("getCachedGnssLocationsSize", GetCachedGnssLocationsSize),
259 DECLARE_NAPI_FUNCTION("flushCachedGnssLocations", FlushCachedGnssLocations),
260 DECLARE_NAPI_FUNCTION("sendCommand", SendCommand),
261 DECLARE_NAPI_FUNCTION("on", On),
262 DECLARE_NAPI_FUNCTION("off", Off),
263 DECLARE_NAPI_FUNCTION("getCurrentLocation", GetCurrentLocation),
264
265 DECLARE_NAPI_FUNCTION("getLocation", GetLocation),
266 DECLARE_NAPI_FUNCTION("getLocationType", GetLocationType),
267 DECLARE_NAPI_FUNCTION("subscribe", Subscribe),
268 DECLARE_NAPI_FUNCTION("unsubscribe", Unsubscribe),
269 DECLARE_NAPI_FUNCTION("getSupportedCoordTypes", GetSupportedCoordTypes),
270
271 DECLARE_NAPI_PROPERTY("LocationRequestPriority", LocationRequestPriorityTypeConstructor(env)),
272 DECLARE_NAPI_PROPERTY("LocationRequestScenario", LocationRequestScenarioTypeConstructor(env)),
273 DECLARE_NAPI_PROPERTY("LocationPrivacyType", LocationPrivacyTypeConstructor(env)),
274 DECLARE_NAPI_PROPERTY("GeoLocationErrorCode", GeoLocationErrorCodeTypeConstructor(env)),
275 };
276
277 NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(napi_property_descriptor), desc));
278 return exports;
279 }
280
281 static napi_module g_locationModule = {
282 .nm_version = 1,
283 .nm_flags = 0,
284 .nm_filename = nullptr,
285 .nm_register_func = Init,
286 .nm_modname = "geolocation",
287 .nm_priv = ((void *)0),
288 .reserved = { 0 }
289 };
290
291 #else
292
293 /*
294 * Module initialization function
295 */
InitManager(napi_env env,napi_value exports)296 static napi_value InitManager(napi_env env, napi_value exports)
297 {
298 LBSLOGD(LOCATION_NAPI, "Init, location_napi_manager_entry");
299
300 napi_property_descriptor desc[] = {
301 DECLARE_NAPI_FUNCTION("on", On),
302 DECLARE_NAPI_FUNCTION("off", Off),
303 DECLARE_NAPI_FUNCTION("getCurrentLocation", GetCurrentLocation),
304 DECLARE_NAPI_FUNCTION("getLastLocation", GetLastLocation),
305 DECLARE_NAPI_FUNCTION("isLocationEnabled", IsLocationEnabled),
306 DECLARE_NAPI_FUNCTION("enableLocation", EnableLocation),
307 DECLARE_NAPI_FUNCTION("disableLocation", DisableLocation),
308 DECLARE_NAPI_FUNCTION("requestEnableLocation", RequestEnableLocation),
309 DECLARE_NAPI_FUNCTION("isGeocoderAvailable", IsGeoServiceAvailable),
310 DECLARE_NAPI_FUNCTION("getAddressesFromLocation", GetAddressesFromLocation),
311 DECLARE_NAPI_FUNCTION("getAddressesFromLocationName", GetAddressesFromLocationName),
312 DECLARE_NAPI_FUNCTION("isLocationPrivacyConfirmed", IsLocationPrivacyConfirmed),
313 DECLARE_NAPI_FUNCTION("setLocationPrivacyConfirmStatus", SetLocationPrivacyConfirmStatus),
314 DECLARE_NAPI_FUNCTION("getCachedGnssLocationsSize", GetCachedGnssLocationsSize),
315 DECLARE_NAPI_FUNCTION("flushCachedGnssLocations", FlushCachedGnssLocations),
316 DECLARE_NAPI_FUNCTION("sendCommand", SendCommand),
317 DECLARE_NAPI_FUNCTION("getCountryCode", GetIsoCountryCode),
318 DECLARE_NAPI_FUNCTION("enableLocationMock", EnableLocationMock),
319 DECLARE_NAPI_FUNCTION("disableLocationMock", DisableLocationMock),
320 DECLARE_NAPI_FUNCTION("setMockedLocations", SetMockedLocations),
321 DECLARE_NAPI_FUNCTION("enableReverseGeocodingMock", EnableReverseGeocodingMock),
322 DECLARE_NAPI_FUNCTION("disableReverseGeocodingMock", DisableReverseGeocodingMock),
323 DECLARE_NAPI_FUNCTION("setReverseGeocodingMockInfo", SetReverseGeocodingMockInfo),
324 DECLARE_NAPI_FUNCTION("getLocatingRequiredData", GetLocatingRequiredData),
325 DECLARE_NAPI_FUNCTION("addGnssGeofence", AddGnssGeofence),
326 DECLARE_NAPI_FUNCTION("removeGnssGeofence", RemoveGnssGeofence),
327 DECLARE_NAPI_FUNCTION("getGeofenceSupportedCoordTypes", GetGeofenceSupportedCoordTypes),
328 DECLARE_NAPI_FUNCTION("getCurrentWifiBssidForLocating", GetCurrentWifiBssidForLocating),
329 DECLARE_NAPI_FUNCTION("isLocationEnabledByUserId", IsLocationEnabledByUserId),
330 DECLARE_NAPI_FUNCTION("enableLocationByUserId", EnableLocationByUserId),
331 DECLARE_NAPI_FUNCTION("disableLocationByUserId", DisableLocationByUserId),
332 DECLARE_NAPI_FUNCTION("getPoiInfo", GetPoiInfo),
333 DECLARE_NAPI_FUNCTION("isPoiServiceSupported", IsPoiServiceSupported),
334 DECLARE_NAPI_FUNCTION("setLocationSwitchIgnored", SetLocationSwitchIgnored),
335 DECLARE_NAPI_FUNCTION("getDistanceBetweenLocations", GetDistanceBetweenLocations),
336 DECLARE_NAPI_FUNCTION("addBeaconFence", AddBeaconFence),
337 DECLARE_NAPI_FUNCTION("removeBeaconFence", RemoveBeaconFence),
338 DECLARE_NAPI_FUNCTION("isBeaconFenceSupported", IsBeaconFenceSupported),
339
340 DECLARE_NAPI_PROPERTY("LocationRequestPriority", LocationRequestPriorityTypeConstructor(env)),
341 DECLARE_NAPI_PROPERTY("LocationRequestScenario", LocationRequestScenarioTypeConstructor(env)),
342 DECLARE_NAPI_PROPERTY("LocationPrivacyType", LocationPrivacyTypeConstructor(env)),
343 DECLARE_NAPI_PROPERTY("CountryCodeType", CountryCodeTypeConstructor(env)),
344 DECLARE_NAPI_PROPERTY("LocatingRequiredDataType", LocatingRequiredDataTypeConstructor(env)),
345 DECLARE_NAPI_PROPERTY("GeofenceTransitionEvent", GeofenceTransitionEventConstructor(env)),
346 DECLARE_NAPI_PROPERTY("CoordinateSystemType", CoordinateSystemTypeConstructor(env)),
347 DECLARE_NAPI_PROPERTY("SatelliteConstellationCategory", SvConstellationTypeConstructor(env)),
348 DECLARE_NAPI_PROPERTY("SatelliteAdditionalInfo", SatelliteAdditionalInfoTypeConstructor(env)),
349 DECLARE_NAPI_PROPERTY("UserActivityScenario", UserActivityScenarioTypeConstructor(env)),
350 DECLARE_NAPI_PROPERTY("LocatingPriority", LocatingPriorityTypeConstructor(env)),
351 DECLARE_NAPI_PROPERTY("PowerConsumptionScenario", PowerConsumptionScenarioTypeConstructor(env)),
352 DECLARE_NAPI_PROPERTY("LocationSourceType", LocationSourceTypeConstructor(env)),
353 DECLARE_NAPI_PROPERTY("LocationError", LocationErrorConstructor(env)),
354 DECLARE_NAPI_PROPERTY("SportsType", SportsTypeConstructor(env)),
355 DECLARE_NAPI_PROPERTY("BeaconFenceInfoType", BeaconFenceInfoTypeConstructor(env)),
356 };
357
358 NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(napi_property_descriptor), desc));
359 return exports;
360 }
361
362 static napi_module g_locationManagerModule = {
363 .nm_version = 1,
364 .nm_flags = 0,
365 .nm_filename = nullptr,
366 .nm_register_func = InitManager,
367 .nm_modname = "geoLocationManager",
368 .nm_priv = ((void *)0),
369 .reserved = { 0 }
370 };
371 #endif
372
373 #ifndef ENABLE_NAPI_MANAGER
RegisterGeolocationModule(void)374 extern "C" __attribute__((constructor)) void RegisterGeolocationModule(void)
375 {
376 napi_module_register(&g_locationModule);
377 }
378 #else
RegisterGeolocationManagerModule(void)379 extern "C" __attribute__((constructor)) void RegisterGeolocationManagerModule(void)
380 {
381 napi_module_register(&g_locationManagerModule);
382 }
383 #endif
384 } // namespace Location
385 } // namespace OHOS
386