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