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 16import { AsyncCallback, Callback } from './@ohos.base'; 17import { WantAgent } from './@ohos.wantAgent'; 18 19/** 20 * Provides interfaces for acquiring location information, managing location switches, 21 * geocoding, reverse geocoding, country code, fencing and other functions. 22 * 23 * @namespace geoLocationManager 24 * @since 9 25 */ 26declare namespace geoLocationManager { 27 /** 28 * Subscribe location changed. 29 * 30 * @permission ohos.permission.APPROXIMATELY_LOCATION 31 * @param { 'locationChange' } type - Indicates the location service event to be subscribed to. 32 * @param { LocationRequest } request - Indicates the location request parameters. 33 * @param { Callback<Location> } callback - Indicates the callback for reporting the location result. 34 * @throws { BusinessError } 201 - Permission denied. 35 * @throws { BusinessError } 401 - Parameter error. 36 * @throws { BusinessError } 801 - Capability not supported. 37 * @throws { BusinessError } 3301000 - Location service is unavailable. 38 * @throws { BusinessError } 3301100 - The location switch is off. 39 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 40 * @syscap SystemCapability.Location.Location.Core 41 * @since 9 42 */ 43 function on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void; 44 45 /** 46 * Unsubscribe location changed. 47 * 48 * @permission ohos.permission.APPROXIMATELY_LOCATION 49 * @param { 'locationChange' } type - Indicates the location service event to be subscribed to. 50 * @param { Callback<Location> } [callback] - Indicates the callback for reporting the location result. 51 * @throws { BusinessError } 201 - Permission denied. 52 * @throws { BusinessError } 401 - Parameter error. 53 * @throws { BusinessError } 801 - Capability not supported. 54 * @throws { BusinessError } 3301000 - Location service is unavailable. 55 * @throws { BusinessError } 3301100 - The location switch is off. 56 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 57 * @syscap SystemCapability.Location.Location.Core 58 * @since 9 59 */ 60 function off(type: 'locationChange', callback?: Callback<Location>): void; 61 62 /** 63 * Subscribe location switch changed. 64 * 65 * @param { 'locationEnabledChange' } type - Indicates the location service event to be subscribed to. 66 * @param { Callback<boolean> } callback - Indicates the callback for reporting the location switch status. 67 * @throws { BusinessError } 401 - Parameter error. 68 * @throws { BusinessError } 801 - Capability not supported. 69 * @throws { BusinessError } 3301000 - Location service is unavailable. 70 * @syscap SystemCapability.Location.Location.Core 71 * @since 9 72 */ 73 function on(type: 'locationEnabledChange', callback: Callback<boolean>): void; 74 75 /** 76 * Unsubscribe location switch changed. 77 * 78 * @param { 'locationEnabledChange' } type - Indicates the location service event to be subscribed to. 79 * @param { Callback<boolean> } [callback] - Indicates the callback for reporting the location switch status. 80 * @throws { BusinessError } 401 - Parameter error. 81 * @throws { BusinessError } 801 - Capability not supported. 82 * @throws { BusinessError } 3301000 - Location service is unavailable. 83 * @syscap SystemCapability.Location.Location.Core 84 * @since 9 85 */ 86 function off(type: 'locationEnabledChange', callback?: Callback<boolean>): void; 87 88 /** 89 * Subscribe to cache GNSS locations update messages. 90 * 91 * @permission ohos.permission.APPROXIMATELY_LOCATION 92 * @param { 'cachedGnssLocationsChange' } type - Indicates the location service event to be subscribed to. 93 * @param { CachedGnssLocationsRequest } request - Indicates the cached GNSS locations request parameters. 94 * @param { Callback<Array<Location>> } callback - Indicates the callback for reporting the cached GNSS locations. 95 * @throws { BusinessError } 201 - Permission denied. 96 * @throws { BusinessError } 401 - Parameter error. 97 * @throws { BusinessError } 801 - Capability not supported. 98 * @throws { BusinessError } 3301000 - Location service is unavailable. 99 * @throws { BusinessError } 3301100 - The location switch is off. 100 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 101 * @syscap SystemCapability.Location.Location.Gnss 102 * @since 9 103 */ 104 function on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; 105 106 /** 107 * Unsubscribe to cache GNSS locations update messages. 108 * 109 * @permission ohos.permission.APPROXIMATELY_LOCATION 110 * @param { 'cachedGnssLocationsChange' } type - Indicates the location service event to be subscribed to. 111 * @param { Callback<Array<Location>> } [callback] - Indicates the callback for reporting the cached gnss locations. 112 * @throws { BusinessError } 201 - Permission denied. 113 * @throws { BusinessError } 401 - Parameter error. 114 * @throws { BusinessError } 801 - Capability not supported. 115 * @throws { BusinessError } 3301000 - Location service is unavailable. 116 * @throws { BusinessError } 3301100 - The location switch is off. 117 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 118 * @syscap SystemCapability.Location.Location.Gnss 119 * @since 9 120 */ 121 function off(type: 'cachedGnssLocationsChange', callback?: Callback<Array<Location>>): void; 122 123 /** 124 * Subscribe satellite status changed. 125 * 126 * @permission ohos.permission.APPROXIMATELY_LOCATION 127 * @param { 'satelliteStatusChange' } type - Indicates the location service event to be subscribed to. 128 * @param { Callback<SatelliteStatusInfo> } callback - Indicates the callback for reporting the satellite status. 129 * @throws { BusinessError } 201 - Permission denied. 130 * @throws { BusinessError } 401 - Parameter error. 131 * @throws { BusinessError } 801 - Capability not supported. 132 * @throws { BusinessError } 3301000 - Location service is unavailable. 133 * @throws { BusinessError } 3301100 - The location switch is off. 134 * @syscap SystemCapability.Location.Location.Gnss 135 * @since 9 136 */ 137 function on(type: 'satelliteStatusChange', callback: Callback<SatelliteStatusInfo>): void; 138 139 /** 140 * Unsubscribe satellite status changed. 141 * 142 * @permission ohos.permission.APPROXIMATELY_LOCATION 143 * @param { 'satelliteStatusChange' } type - Indicates the location service event to be subscribed to. 144 * @param { Callback<SatelliteStatusInfo> } [callback] - Indicates the callback for reporting the satellite status. 145 * @throws { BusinessError } 201 - Permission denied. 146 * @throws { BusinessError } 401 - Parameter error. 147 * @throws { BusinessError } 801 - Capability not supported. 148 * @throws { BusinessError } 3301000 - Location service is unavailable. 149 * @throws { BusinessError } 3301100 - The location switch is off. 150 * @syscap SystemCapability.Location.Location.Gnss 151 * @since 9 152 */ 153 function off(type: 'satelliteStatusChange', callback?: Callback<SatelliteStatusInfo>): void; 154 155 /** 156 * Subscribe nmea message changed. 157 * 158 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 159 * @param { 'nmeaMessage' } type - Indicates the location service event to be subscribed to. 160 * @param { Callback<string> } callback - Indicates the callback for reporting the nmea message. 161 * @throws { BusinessError } 201 - Permission denied. 162 * @throws { BusinessError } 401 - Parameter error. 163 * @throws { BusinessError } 801 - Capability not supported. 164 * @throws { BusinessError } 3301000 - Location service is unavailable. 165 * @throws { BusinessError } 3301100 - The location switch is off. 166 * @syscap SystemCapability.Location.Location.Gnss 167 * @since 9 168 */ 169 function on(type: 'nmeaMessage', callback: Callback<string>): void; 170 171 /** 172 * Unsubscribe nmea message changed. 173 * 174 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 175 * @param { 'nmeaMessage' } type - Indicates the location service event to be subscribed to. 176 * @param { Callback<string> } [callback] - Indicates the callback for reporting the nmea message. 177 * @throws { BusinessError } 201 - Permission denied. 178 * @throws { BusinessError } 401 - Parameter error. 179 * @throws { BusinessError } 801 - Capability not supported. 180 * @throws { BusinessError } 3301000 - Location service is unavailable. 181 * @throws { BusinessError } 3301100 - The location switch is off. 182 * @syscap SystemCapability.Location.Location.Gnss 183 * @since 9 184 */ 185 function off(type: 'nmeaMessage', callback?: Callback<string>): void; 186 187 /** 188 * Add a geofence and subscribe geo fence status changed. 189 * 190 * @permission ohos.permission.APPROXIMATELY_LOCATION 191 * @param { 'gnssFenceStatusChange' } type - Indicates the location service event to be subscribed to. 192 * @param { GeofenceRequest } request - Indicates the Geo-fence configuration parameters. 193 * @param { WantAgent } want - Indicates which ability to start when the geofence event is triggered. 194 * @throws { BusinessError } 201 - Permission denied. 195 * @throws { BusinessError } 401 - Parameter error. 196 * @throws { BusinessError } 801 - Capability not supported. 197 * @throws { BusinessError } 3301000 - Location service is unavailable. 198 * @throws { BusinessError } 3301100 - The location switch is off. 199 * @throws { BusinessError } 3301600 - Failed to operate the geofence. 200 * @syscap SystemCapability.Location.Location.Geofence 201 * @since 9 202 */ 203 function on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 204 205 /** 206 * Remove a geofence and unsubscribe geo fence status changed. 207 * 208 * @permission ohos.permission.APPROXIMATELY_LOCATION 209 * @param { 'gnssFenceStatusChange' } type - Indicates the location service event to be subscribed to. 210 * @param { GeofenceRequest } request - Indicates the Geo-fence configuration parameters. 211 * @param { WantAgent } want - Indicates which ability to start when the geofence event is triggered. 212 * @throws { BusinessError } 201 - Permission denied. 213 * @throws { BusinessError } 401 - Parameter error. 214 * @throws { BusinessError } 801 - Capability not supported. 215 * @throws { BusinessError } 3301000 - Location service is unavailable. 216 * @throws { BusinessError } 3301100 - The location switch is off. 217 * @throws { BusinessError } 3301600 - Failed to operate the geofence. 218 * @syscap SystemCapability.Location.Location.Geofence 219 * @since 9 220 */ 221 function off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 222 223 /** 224 * Registering the callback function for listening to country code changes. 225 * 226 * @param { 'countryCodeChange' } type - Indicates the location service event to be subscribed to. 227 * @param { Callback<CountryCode> } callback - Indicates the callback for reporting country code changes. 228 * @throws { BusinessError } 401 - Parameter error. 229 * @throws { BusinessError } 801 - Capability not supported. 230 * @throws { BusinessError } 3301000 - Location service is unavailable. 231 * @throws { BusinessError } 3301500 - Failed to query the area information. 232 * @syscap SystemCapability.Location.Location.Core 233 * @since 9 234 */ 235 function on(type: 'countryCodeChange', callback: Callback<CountryCode>): void; 236 237 /** 238 * Unregistering the callback function for listening to country code changes. 239 * 240 * @param { 'countryCodeChange' } type - Indicates the location service event to be subscribed to. 241 * @param { Callback<CountryCode> } [callback] - Indicates the callback for reporting country code changes. 242 * @throws { BusinessError } 401 - Parameter error. 243 * @throws { BusinessError } 801 - Capability not supported. 244 * @throws { BusinessError } 3301000 - Location service is unavailable. 245 * @throws { BusinessError } 3301500 - Failed to query the area information. 246 * @syscap SystemCapability.Location.Location.Core 247 * @since 9 248 */ 249 function off(type: 'countryCodeChange', callback?: Callback<CountryCode>): void; 250 251 /** 252 * Subscribe to changes in WiFi/BT scanning information, 253 * and use the WiFi/BT scanning information for localization. 254 * 255 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 256 * @param { 'locatingRequiredDataChange' } type - Indicates the location service event to be subscribed to. 257 * @param { LocatingRequiredDataConfig } config - Indicates the locating required data configuration parameters. 258 * @param { Callback<Array<LocatingRequiredData>> } [callback] - Indicates the callback for reporting WiFi/BT scan info. 259 * @throws { BusinessError } 201 - Permission denied. 260 * @throws { BusinessError } 401 - Invalid parameter. 261 * @throws { BusinessError } 801 - Capability not supported. 262 * @throws { BusinessError } 3301800 - Failed to start WiFi or Bluetooth scanning. 263 * @syscap SystemCapability.Location.Location.Core 264 * @systemapi 265 * @since 10 266 */ 267 function on(type: 'locatingRequiredDataChange', config: LocatingRequiredDataConfig, callback: Callback<Array<LocatingRequiredData>>): void; 268 269 /** 270 * Stop WiFi/BT scanning and unsubscribe from WiFi/BT scanning information changes. 271 * 272 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 273 * @param { 'locatingRequiredDataChange' } type - Indicates the location service event to be subscribed to. 274 * @param { Callback<Array<LocatingRequiredData>> } [callback] - Indicates the callback for reporting WiFi/BT scan info. 275 * @throws { BusinessError } 201 - Permission denied. 276 * @throws { BusinessError } 401 - Invalid parameter. 277 * @throws { BusinessError } 801 - Capability not supported. 278 * @syscap SystemCapability.Location.Location.Core 279 * @systemapi 280 * @since 10 281 */ 282 function off(type: 'locatingRequiredDataChange', callback?: Callback<Array<LocatingRequiredData>>): void; 283 284 /** 285 * Obtain current location. 286 * 287 * @permission ohos.permission.APPROXIMATELY_LOCATION 288 * @param { CurrentLocationRequest } request - Indicates the location request parameters. 289 * @param { AsyncCallback<Location> } callback - Indicates the callback for reporting the location result. 290 * @throws { BusinessError } 201 - Permission denied. 291 * @throws { BusinessError } 401 - Parameter error. 292 * @throws { BusinessError } 801 - Capability not supported. 293 * @throws { BusinessError } 3301000 - Location service is unavailable. 294 * @throws { BusinessError } 3301100 - The location switch is off. 295 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 296 * @syscap SystemCapability.Location.Location.Core 297 * @since 9 298 */ 299 function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void; 300 301 /** 302 * Obtain current location. 303 * 304 * @permission ohos.permission.APPROXIMATELY_LOCATION 305 * @param { AsyncCallback<Location> } callback - Indicates the callback for reporting the location result. 306 * @throws { BusinessError } 201 - Permission denied. 307 * @throws { BusinessError } 401 - Parameter error. 308 * @throws { BusinessError } 801 - Capability not supported. 309 * @throws { BusinessError } 3301000 - Location service is unavailable. 310 * @throws { BusinessError } 3301100 - The location switch is off. 311 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 312 * @syscap SystemCapability.Location.Location.Core 313 * @since 9 314 */ 315 function getCurrentLocation(callback: AsyncCallback<Location>): void; 316 317 /** 318 * Obtain current location. 319 * 320 * @permission ohos.permission.APPROXIMATELY_LOCATION 321 * @param { CurrentLocationRequest } [request] - Indicates the location request parameters. 322 * @returns { Promise<Location> } The promise returned by the function. 323 * @throws { BusinessError } 201 - Permission denied. 324 * @throws { BusinessError } 401 - Parameter error. 325 * @throws { BusinessError } 801 - Capability not supported. 326 * @throws { BusinessError } 3301000 - Location service is unavailable. 327 * @throws { BusinessError } 3301100 - The location switch is off. 328 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 329 * @syscap SystemCapability.Location.Location.Core 330 * @since 9 331 */ 332 function getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>; 333 334 /** 335 * Obtain last known location. 336 * 337 * @permission ohos.permission.APPROXIMATELY_LOCATION 338 * @returns { Location } The last known location information. 339 * @throws { BusinessError } 201 - Permission denied. 340 * @throws { BusinessError } 801 - Capability not supported. 341 * @throws { BusinessError } 3301000 - Location service is unavailable. 342 * @throws { BusinessError } 3301100 - The location switch is off. 343 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 344 * @syscap SystemCapability.Location.Location.Core 345 * @since 9 346 */ 347 function getLastLocation(): Location; 348 349 /** 350 * Obtain current location switch status. 351 * 352 * @returns { boolean } Returns {@code true} if the location switch on, returns {@code false} otherwise. 353 * @throws { BusinessError } 801 - Capability not supported. 354 * @throws { BusinessError } 3301000 - Location service is unavailable. 355 * @syscap SystemCapability.Location.Location.Core 356 * @since 9 357 */ 358 function isLocationEnabled(): boolean; 359 360 /** 361 * Enable location switch. 362 * 363 * @permission ohos.permission.MANAGE_SECURE_SETTINGS 364 * @param { AsyncCallback<void> } callback - Indicates the callback for reporting the error message. 365 * @throws { BusinessError } 201 - Permission denied. 366 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 367 * @throws { BusinessError } 401 - Parameter error. 368 * @throws { BusinessError } 801 - Capability not supported. 369 * @throws { BusinessError } 3301000 - Location service is unavailable. 370 * @syscap SystemCapability.Location.Location.Core 371 * @systemapi 372 * @since 9 373 */ 374 function enableLocation(callback: AsyncCallback<void>): void; 375 376 /** 377 * Enable location switch. 378 * 379 * @permission ohos.permission.MANAGE_SECURE_SETTINGS 380 * @returns { Promise<void> } The promise returned by the function. 381 * @throws { BusinessError } 201 - Permission denied. 382 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 383 * @throws { BusinessError } 801 - Capability not supported. 384 * @throws { BusinessError } 3301000 - Location service is unavailable. 385 * @syscap SystemCapability.Location.Location.Core 386 * @systemapi 387 * @since 9 388 */ 389 function enableLocation(): Promise<void>; 390 391 /** 392 * Disable location switch. 393 * 394 * @permission ohos.permission.MANAGE_SECURE_SETTINGS 395 * @throws { BusinessError } 201 - Permission denied. 396 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 397 * @throws { BusinessError } 801 - Capability not supported. 398 * @throws { BusinessError } 3301000 - Location service is unavailable. 399 * @syscap SystemCapability.Location.Location.Core 400 * @systemapi 401 * @since 9 402 */ 403 function disableLocation(): void; 404 405 /** 406 * Obtain address info from location. 407 * 408 * @param { ReverseGeoCodeRequest } request - Indicates the reverse geocode query parameters. 409 * @param { AsyncCallback<Array<GeoAddress>> } callback - Indicates the callback for reporting the address info. 410 * @throws { BusinessError } 401 - Parameter error. 411 * @throws { BusinessError } 801 - Capability not supported. 412 * @throws { BusinessError } 3301000 - Location service is unavailable. 413 * @throws { BusinessError } 3301300 - Reverse geocoding query failed. 414 * @syscap SystemCapability.Location.Location.Geocoder 415 * @since 9 416 */ 417 function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; 418 419 /** 420 * Obtain address info from location. 421 * 422 * @param { ReverseGeoCodeRequest } request - Indicates the reverse geocode query parameters. 423 * @returns { Promise<Array<GeoAddress>> } The promise returned by the function. 424 * @throws { BusinessError } 401 - Parameter error. 425 * @throws { BusinessError } 801 - Capability not supported. 426 * @throws { BusinessError } 3301000 - Location service is unavailable. 427 * @throws { BusinessError } 3301300 - Reverse geocoding query failed. 428 * @syscap SystemCapability.Location.Location.Geocoder 429 * @since 9 430 */ 431 function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; 432 433 /** 434 * Obtain latitude and longitude info from location address. 435 * 436 * @param { GeoCodeRequest } request - Indicates the geocode query parameters. 437 * @param { AsyncCallback<Array<GeoAddress>> } callback - Indicates the callback for reporting the latitude and longitude result. 438 * @throws { BusinessError } 401 - Parameter error. 439 * @throws { BusinessError } 801 - Capability not supported. 440 * @throws { BusinessError } 3301000 - Location service is unavailable. 441 * @throws { BusinessError } 3301400 - Geocoding query failed. 442 * @syscap SystemCapability.Location.Location.Geocoder 443 * @since 9 444 */ 445 function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; 446 447 /** 448 * Obtain latitude and longitude info from location address. 449 * 450 * @param { GeoCodeRequest } request - Indicates the geocode query parameters. 451 * @returns { Promise<Array<GeoAddress>> } The promise returned by the function. 452 * @throws { BusinessError } 401 - Parameter error. 453 * @throws { BusinessError } 801 - Capability not supported. 454 * @throws { BusinessError } 3301000 - Location service is unavailable. 455 * @throws { BusinessError } 3301400 - Geocoding query failed. 456 * @syscap SystemCapability.Location.Location.Geocoder 457 * @since 9 458 */ 459 function getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>>; 460 461 /** 462 * Obtain geocoding service status. 463 * 464 * @returns { boolean } Returns {@code true} if geocoding service is available, returns {@code false} otherwise. 465 * @throws { BusinessError } 801 - Capability not supported. 466 * @throws { BusinessError } 3301000 - Location service is unavailable. 467 * @syscap SystemCapability.Location.Location.Geocoder 468 * @since 9 469 */ 470 function isGeocoderAvailable(): boolean; 471 472 /** 473 * Obtain the number of cached GNSS locations reported at a time. 474 * 475 * @permission ohos.permission.APPROXIMATELY_LOCATION 476 * @param { AsyncCallback<number> } callback - Indicates the callback for reporting the cached GNSS locations size. 477 * @throws { BusinessError } 201 - Permission denied. 478 * @throws { BusinessError } 401 - Parameter error. 479 * @throws { BusinessError } 801 - Capability not supported. 480 * @throws { BusinessError } 3301000 - Location service is unavailable. 481 * @throws { BusinessError } 3301100 - The location switch is off. 482 * @syscap SystemCapability.Location.Location.Gnss 483 * @since 9 484 */ 485 function getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; 486 487 /** 488 * Obtain the number of cached GNSS locations. 489 * 490 * @permission ohos.permission.APPROXIMATELY_LOCATION 491 * @returns { Promise<number> } The promise returned by the function. 492 * @throws { BusinessError } 201 - Permission denied. 493 * @throws { BusinessError } 801 - Capability not supported. 494 * @throws { BusinessError } 3301000 - Location service is unavailable. 495 * @throws { BusinessError } 3301100 - The location switch is off. 496 * @syscap SystemCapability.Location.Location.Gnss 497 * @since 9 498 */ 499 function getCachedGnssLocationsSize(): Promise<number>; 500 501 /** 502 * All prepared GNSS locations are returned to the application through the callback function, 503 * and the bottom-layer buffer is cleared. 504 * 505 * @permission ohos.permission.APPROXIMATELY_LOCATION 506 * @param { AsyncCallback<void> } callback - Indicates the callback for reporting the error message. 507 * If the function fails to execute, the error message will be carried in the first parameter err of AsyncCallback, 508 * If the function executes successfully, execute the callback function only, no data will be returned. 509 * @throws { BusinessError } 201 - Permission denied. 510 * @throws { BusinessError } 401 - Parameter error. 511 * @throws { BusinessError } 801 - Capability not supported. 512 * @throws { BusinessError } 3301000 - Location service is unavailable. 513 * @throws { BusinessError } 3301100 - The location switch is off. 514 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 515 * @syscap SystemCapability.Location.Location.Gnss 516 * @since 9 517 */ 518 function flushCachedGnssLocations(callback: AsyncCallback<void>): void; 519 520 /** 521 * All prepared GNSS locations are returned to the application, 522 * and the bottom-layer buffer is cleared. 523 * 524 * @permission ohos.permission.APPROXIMATELY_LOCATION 525 * @returns { Promise<void> } The promise returned by the function. 526 * @throws { BusinessError } 201 - Permission denied. 527 * @throws { BusinessError } 801 - Capability not supported. 528 * @throws { BusinessError } 3301000 - Location service is unavailable. 529 * @throws { BusinessError } 3301100 - The location switch is off. 530 * @throws { BusinessError } 3301200 - Failed to obtain the geographical location. 531 * @syscap SystemCapability.Location.Location.Gnss 532 * @since 9 533 */ 534 function flushCachedGnssLocations(): Promise<void>; 535 536 /** 537 * Send extended commands to location subsystem. 538 * 539 * @param { LocationCommand } command - Indicates the extended command message body. 540 * @param { AsyncCallback<void> } callback - Indicates the callback for reporting the error message. 541 * If the function fails to execute, the error message will be carried in the first parameter err of AsyncCallback, 542 * If the function executes successfully, execute the callback function only, no data will be returned. 543 * @throws { BusinessError } 401 - Parameter error. 544 * @throws { BusinessError } 801 - Capability not supported. 545 * @throws { BusinessError } 3301000 - Location service is unavailable. 546 * @syscap SystemCapability.Location.Location.Core 547 * @since 9 548 */ 549 function sendCommand(command: LocationCommand, callback: AsyncCallback<void>): void; 550 551 /** 552 * Send extended commands to location subsystem. 553 * 554 * @param { LocationCommand } command - Indicates the extended command message body. 555 * @returns { Promise<void> } The promise returned by the function. 556 * @throws { BusinessError } 401 - Parameter error. 557 * @throws { BusinessError } 801 - Capability not supported. 558 * @throws { BusinessError } 3301000 - Location service is unavailable. 559 * @syscap SystemCapability.Location.Location.Core 560 * @since 9 561 */ 562 function sendCommand(command: LocationCommand): Promise<void>; 563 564 /** 565 * Obtain the current country code. 566 * 567 * @param { AsyncCallback<CountryCode> } callback - Indicates the callback for reporting the country code. 568 * @throws { BusinessError } 401 - Parameter error. 569 * @throws { BusinessError } 801 - Capability not supported. 570 * @throws { BusinessError } 3301000 - Location service is unavailable. 571 * @throws { BusinessError } 3301500 - Failed to query the area information. 572 * @syscap SystemCapability.Location.Location.Core 573 * @since 9 574 */ 575 function getCountryCode(callback: AsyncCallback<CountryCode>): void; 576 577 /** 578 * Obtain the current country code. 579 * 580 * @returns { Promise<CountryCode> } The promise returned by the function. 581 * @throws { BusinessError } 801 - Capability not supported. 582 * @throws { BusinessError } 3301000 - Location service is unavailable. 583 * @throws { BusinessError } 3301500 - Failed to query the area information. 584 * @syscap SystemCapability.Location.Location.Core 585 * @since 9 586 */ 587 function getCountryCode(): Promise<CountryCode>; 588 589 /** 590 * Enable the geographical location simulation function. 591 * 592 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 593 * @throws { BusinessError } 801 - Capability not supported. 594 * @throws { BusinessError } 3301000 - Location service is unavailable. 595 * @throws { BusinessError } 3301100 - The location switch is off. 596 * @syscap SystemCapability.Location.Location.Core 597 * @systemapi 598 * @since 9 599 */ 600 function enableLocationMock(): void; 601 602 /** 603 * Disable the geographical location simulation function. 604 * 605 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 606 * @throws { BusinessError } 801 - Capability not supported. 607 * @throws { BusinessError } 3301000 - Location service is unavailable. 608 * @throws { BusinessError } 3301100 - The location switch is off. 609 * @syscap SystemCapability.Location.Location.Core 610 * @systemapi 611 * @since 9 612 */ 613 function disableLocationMock(): void; 614 615 /** 616 * Set the configuration parameters for location simulation. 617 * 618 * @param { LocationMockConfig } config - Indicates the configuration parameters for location simulation. 619 * Contains the array of locations and reporting intervals that need to be simulated. 620 * @throws { BusinessError } 401 - Parameter error. 621 * @throws { BusinessError } 801 - Capability not supported. 622 * @throws { BusinessError } 3301000 - Location service is unavailable. 623 * @throws { BusinessError } 3301100 - The location switch is off. 624 * @syscap SystemCapability.Location.Location.Core 625 * @systemapi 626 * @since 9 627 */ 628 function setMockedLocations(config: LocationMockConfig): void; 629 630 /** 631 * Enable the reverse geocoding simulation function. 632 * 633 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 634 * @throws { BusinessError } 801 - Capability not supported. 635 * @throws { BusinessError } 3301000 - Location service is unavailable. 636 * @syscap SystemCapability.Location.Location.Core 637 * @systemapi 638 * @since 9 639 */ 640 function enableReverseGeocodingMock(): void; 641 642 /** 643 * Disable the reverse geocoding simulation function. 644 * 645 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 646 * @throws { BusinessError } 801 - Capability not supported. 647 * @throws { BusinessError } 3301000 - Location service is unavailable. 648 * @syscap SystemCapability.Location.Location.Core 649 * @systemapi 650 * @since 9 651 */ 652 function disableReverseGeocodingMock(): void; 653 654 /** 655 * Set the configuration parameters for simulating reverse geocoding. 656 * 657 * @param { Array<ReverseGeocodingMockInfo> } mockInfos - Indicates the set of locations and place names to be simulated. 658 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 659 * @throws { BusinessError } 401 - Parameter error. 660 * @throws { BusinessError } 801 - Capability not supported. 661 * @throws { BusinessError } 3301000 - Location service is unavailable. 662 * @syscap SystemCapability.Location.Location.Core 663 * @systemapi 664 * @since 9 665 */ 666 function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void; 667 668 /** 669 * Querying location privacy protocol confirmation status. 670 * 671 * @param { LocationPrivacyType } type - Indicates location privacy protocol type. 672 * @returns { boolean } Returns {@code true} if the location privacy protocol has been confirmed, returns {@code false} otherwise. 673 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 674 * @throws { BusinessError } 401 - Parameter error. 675 * @throws { BusinessError } 801 - Capability not supported. 676 * @throws { BusinessError } 3301000 - Location service is unavailable. 677 * @syscap SystemCapability.Location.Location.Core 678 * @systemapi 679 * @since 9 680 */ 681 function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; 682 683 /** 684 * Set location privacy protocol confirmation status. 685 * 686 * @permission ohos.permission.MANAGE_SECURE_SETTINGS 687 * @param { LocationPrivacyType } type - Indicates location privacy protocol type. 688 * @param { boolean } isConfirmed - Indicates whether the location privacy protocol has been confirmed. 689 * @throws { BusinessError } 201 - Permission denied. 690 * @throws { BusinessError } 202 - System API is not allowed called by third HAP. 691 * @throws { BusinessError } 401 - Parameter error. 692 * @throws { BusinessError } 801 - Capability not supported. 693 * @throws { BusinessError } 3301000 - Location service is unavailable. 694 * @syscap SystemCapability.Location.Location.Core 695 * @systemapi 696 * @since 9 697 */ 698 function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void; 699 700 /** 701 * Get WiFi/BT scanning information, and use the WiFi/BT scanning information for localization. 702 * 703 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 704 * @param { LocatingRequiredDataConfig } config - Indicates the request parameters for obtaining the data required for locating. 705 * @returns { Promise<Array<LocatingRequiredData>> } The promise returned by the function, for reporting WiFi/BT scan info. 706 * @throws { BusinessError } 201 - Permission denied. 707 * @throws { BusinessError } 401 - Invalid parameter. 708 * @throws { BusinessError } 801 - Capability not supported. 709 * @throws { BusinessError } 3301800 - Failed to start WiFi or Bluetooth scanning. 710 * @syscap SystemCapability.Location.Location.Core 711 * @systemapi 712 * @since 10 713 */ 714 function getLocatingRequiredData(config: LocatingRequiredDataConfig): Promise<Array<LocatingRequiredData>>; 715 716 /** 717 * Configuration parameters for simulating reverse geocoding. 718 * 719 * @typedef ReverseGeocodingMockInfo 720 * @syscap SystemCapability.Location.Location.Core 721 * @systemapi 722 * @since 9 723 */ 724 export interface ReverseGeocodingMockInfo { 725 /** 726 * Location for which reverse geocoding query is required. 727 * 728 * @type { ReverseGeoCodeRequest } 729 * @syscap SystemCapability.Location.Location.Core 730 * @systemapi 731 * @since 9 732 */ 733 location: ReverseGeoCodeRequest; 734 735 /** 736 * Actual address information corresponding to the location. 737 * 738 * @type { GeoAddress } 739 * @syscap SystemCapability.Location.Location.Core 740 * @systemapi 741 * @since 9 742 */ 743 geoAddress: GeoAddress; 744 } 745 746 /** 747 * Parameters for configuring the location simulation function. 748 * 749 * @typedef LocationMockConfig 750 * @syscap SystemCapability.Location.Location.Core 751 * @systemapi 752 * @since 9 753 */ 754 export interface LocationMockConfig { 755 /** 756 * Interval for reporting simulated locations. 757 * 758 * @type { number } 759 * @syscap SystemCapability.Location.Location.Core 760 * @systemapi 761 * @since 9 762 */ 763 timeInterval: number; 764 765 /** 766 * Mock location array. 767 * 768 * @type { Array<Location> } 769 * @syscap SystemCapability.Location.Location.Core 770 * @systemapi 771 * @since 9 772 */ 773 locations: Array<Location>; 774 } 775 776 /** 777 * Satellite status information. 778 * 779 * @typedef SatelliteStatusInfo 780 * @syscap SystemCapability.Location.Location.Gnss 781 * @since 9 782 */ 783 export interface SatelliteStatusInfo { 784 /** 785 * Number of satellites. 786 * 787 * @type { number } 788 * @syscap SystemCapability.Location.Location.Gnss 789 * @since 9 790 */ 791 satellitesNumber: number; 792 793 /** 794 * Satellite ID array. 795 * 796 * @type { Array<number> } 797 * @syscap SystemCapability.Location.Location.Gnss 798 * @since 9 799 */ 800 satelliteIds: Array<number>; 801 802 /** 803 * Carrier to noise density array. 804 * 805 * @type { Array<number> } 806 * @syscap SystemCapability.Location.Location.Gnss 807 * @since 9 808 */ 809 carrierToNoiseDensitys: Array<number>; 810 811 /** 812 * Satellite altitude array. 813 * 814 * @type { Array<number> } 815 * @syscap SystemCapability.Location.Location.Gnss 816 * @since 9 817 */ 818 altitudes: Array<number>; 819 820 /** 821 * Satellite azimuth array. 822 * 823 * @type { Array<number> } 824 * @syscap SystemCapability.Location.Location.Gnss 825 * @since 9 826 */ 827 azimuths: Array<number>; 828 829 /** 830 * Satellite carrier frequency array. 831 * 832 * @type { Array<number> } 833 * @syscap SystemCapability.Location.Location.Gnss 834 * @since 9 835 */ 836 carrierFrequencies: Array<number>; 837 } 838 839 /** 840 * Parameters for requesting to report cache location information. 841 * 842 * @typedef CachedGnssLocationsRequest 843 * @syscap SystemCapability.Location.Location.Gnss 844 * @since 9 845 */ 846 export interface CachedGnssLocationsRequest { 847 /** 848 * GNSS cache location report period. 849 * 850 * @type { number } 851 * @syscap SystemCapability.Location.Location.Gnss 852 * @since 9 853 */ 854 reportingPeriodSec: number; 855 856 /** 857 * Indicates whether to wake up the listener when the GNSS cache location queue is full. 858 * 859 * @type { boolean } 860 * @syscap SystemCapability.Location.Location.Gnss 861 * @since 9 862 */ 863 wakeUpCacheQueueFull: boolean; 864 } 865 866 /** 867 * Configuring parameters in geo fence requests. 868 * 869 * @typedef GeofenceRequest 870 * @syscap SystemCapability.Location.Location.Geofence 871 * @since 9 872 */ 873 export interface GeofenceRequest { 874 /** 875 * Indicate the user scenario. 876 * 877 * @type { LocationRequestScenario } 878 * @syscap SystemCapability.Location.Location.Geofence 879 * @since 9 880 */ 881 scenario: LocationRequestScenario; 882 883 /** 884 * Circular fence information. 885 * 886 * @type { Geofence } 887 * @syscap SystemCapability.Location.Location.Geofence 888 * @since 9 889 */ 890 geofence: Geofence; 891 } 892 893 /** 894 * Circular fence information. 895 * 896 * @typedef Geofence 897 * @syscap SystemCapability.Location.Location.Geofence 898 * @since 9 899 */ 900 export interface Geofence { 901 /** 902 * Latitude of the center point of the circular fence. 903 * 904 * @type { number } 905 * @syscap SystemCapability.Location.Location.Geofence 906 * @since 9 907 */ 908 latitude: number; 909 910 /** 911 * Longitude of the center point of the circular fence. 912 * 913 * @type { number } 914 * @syscap SystemCapability.Location.Location.Geofence 915 * @since 9 916 */ 917 longitude: number; 918 919 /** 920 * Radius of the circular fence. 921 * 922 * @type { number } 923 * @syscap SystemCapability.Location.Location.Geofence 924 * @since 9 925 */ 926 radius: number; 927 928 /** 929 * Expiration of the circular fence. 930 * 931 * @type { number } 932 * @syscap SystemCapability.Location.Location.Geofence 933 * @since 9 934 */ 935 expiration: number; 936 } 937 938 /** 939 * Configuring parameters in reverse geocode requests. 940 * 941 * @typedef ReverseGeoCodeRequest 942 * @syscap SystemCapability.Location.Location.Geocoder 943 * @since 9 944 */ 945 export interface ReverseGeoCodeRequest { 946 /** 947 * Indicates the language area information. 948 * 949 * @type { ?string } 950 * @syscap SystemCapability.Location.Location.Geocoder 951 * @since 9 952 */ 953 locale?: string; 954 955 /** 956 * Latitude for reverse geocoding query. 957 * 958 * @type { number } 959 * @syscap SystemCapability.Location.Location.Geocoder 960 * @since 9 961 */ 962 latitude: number; 963 964 /** 965 * Longitude for reverse geocoding query. 966 * 967 * @type { number } 968 * @syscap SystemCapability.Location.Location.Geocoder 969 * @since 9 970 */ 971 longitude: number; 972 973 /** 974 * Indicates the maximum number of addresses returned by reverse geocoding query. 975 * 976 * @type { ?number } 977 * @syscap SystemCapability.Location.Location.Geocoder 978 * @since 9 979 */ 980 maxItems?: number; 981 } 982 983 /** 984 * Configuring parameters in geocode requests. 985 * 986 * @typedef GeoCodeRequest 987 * @syscap SystemCapability.Location.Location.Geocoder 988 * @since 9 989 */ 990 export interface GeoCodeRequest { 991 /** 992 * Indicates the language area information. 993 * 994 * @type { ?string } 995 * @syscap SystemCapability.Location.Location.Geocoder 996 * @since 9 997 */ 998 locale?: string; 999 1000 /** 1001 * Address information. 1002 * 1003 * @type { string } 1004 * @syscap SystemCapability.Location.Location.Geocoder 1005 * @since 9 1006 */ 1007 description: string; 1008 1009 /** 1010 * Indicates the maximum number of geocode query results. 1011 * 1012 * @type { ?number } 1013 * @syscap SystemCapability.Location.Location.Geocoder 1014 * @since 9 1015 */ 1016 maxItems?: number; 1017 1018 /** 1019 * Indicates the minimum latitude for geocoding query results. 1020 * 1021 * @type { ?number } 1022 * @syscap SystemCapability.Location.Location.Geocoder 1023 * @since 9 1024 */ 1025 minLatitude?: number; 1026 1027 /** 1028 * Indicates the minimum longitude for geocoding query results. 1029 * 1030 * @type { ?number } 1031 * @syscap SystemCapability.Location.Location.Geocoder 1032 * @since 9 1033 */ 1034 minLongitude?: number; 1035 1036 /** 1037 * Indicates the maximum latitude for geocoding query results. 1038 * 1039 * @type { ?number } 1040 * @syscap SystemCapability.Location.Location.Geocoder 1041 * @since 9 1042 */ 1043 maxLatitude?: number; 1044 1045 /** 1046 * Indicates the maximum longitude for geocoding query results. 1047 * 1048 * @type { ?number } 1049 * @syscap SystemCapability.Location.Location.Geocoder 1050 * @since 9 1051 */ 1052 maxLongitude?: number; 1053 } 1054 1055 /** 1056 * Data struct describes geographic locations. 1057 * 1058 * @typedef GeoAddress 1059 * @syscap SystemCapability.Location.Location.Geocoder 1060 * @since 9 1061 */ 1062 export interface GeoAddress { 1063 /** 1064 * Indicates latitude information. 1065 * A positive value indicates north latitude, 1066 * and a negative value indicates south latitude. 1067 * 1068 * @type { ?number } 1069 * @syscap SystemCapability.Location.Location.Geocoder 1070 * @since 9 1071 */ 1072 latitude?: number; 1073 1074 /** 1075 * Indicates longitude information. 1076 * A positive value indicates east longitude , 1077 * and a negative value indicates west longitude. 1078 * 1079 * @type { ?number } 1080 * @syscap SystemCapability.Location.Location.Geocoder 1081 * @since 9 1082 */ 1083 longitude?: number; 1084 1085 /** 1086 * Indicates language used for the location description. 1087 * zh indicates Chinese, and en indicates English. 1088 * 1089 * @type { ?string } 1090 * @syscap SystemCapability.Location.Location.Geocoder 1091 * @since 9 1092 */ 1093 locale?: string; 1094 1095 /** 1096 * Indicates landmark of the location. 1097 * 1098 * @type { ?string } 1099 * @syscap SystemCapability.Location.Location.Geocoder 1100 * @since 9 1101 */ 1102 placeName?: string; 1103 1104 /** 1105 * Indicates country code. 1106 * 1107 * @type { ?string } 1108 * @syscap SystemCapability.Location.Location.Geocoder 1109 * @since 9 1110 */ 1111 countryCode?: string; 1112 1113 /** 1114 * Indicates country name. 1115 * 1116 * @type { ?string } 1117 * @syscap SystemCapability.Location.Location.Geocoder 1118 * @since 9 1119 */ 1120 countryName?: string; 1121 1122 /** 1123 * Indicates administrative region name. 1124 * 1125 * @type { ?string } 1126 * @syscap SystemCapability.Location.Location.Geocoder 1127 * @since 9 1128 */ 1129 administrativeArea?: string; 1130 1131 /** 1132 * Indicates sub-administrative region name. 1133 * 1134 * @type { ?string } 1135 * @syscap SystemCapability.Location.Location.Geocoder 1136 * @since 9 1137 */ 1138 subAdministrativeArea?: string; 1139 1140 /** 1141 * Indicates locality information. 1142 * 1143 * @type { ?string } 1144 * @syscap SystemCapability.Location.Location.Geocoder 1145 * @since 9 1146 */ 1147 locality?: string; 1148 1149 /** 1150 * Indicates sub-locality information. 1151 * 1152 * @type { ?string } 1153 * @syscap SystemCapability.Location.Location.Geocoder 1154 * @since 9 1155 */ 1156 subLocality?: string; 1157 1158 /** 1159 * Indicates road name. 1160 * 1161 * @type { ?string } 1162 * @syscap SystemCapability.Location.Location.Geocoder 1163 * @since 9 1164 */ 1165 roadName?: string; 1166 1167 /** 1168 * Indicates auxiliary road information. 1169 * 1170 * @type { ?string } 1171 * @syscap SystemCapability.Location.Location.Geocoder 1172 * @since 9 1173 */ 1174 subRoadName?: string; 1175 1176 /** 1177 * Indicates house information. 1178 * 1179 * @type { ?string } 1180 * @syscap SystemCapability.Location.Location.Geocoder 1181 * @since 9 1182 */ 1183 premises?: string; 1184 1185 /** 1186 * Indicates postal code. 1187 * 1188 * @type { ?string } 1189 * @syscap SystemCapability.Location.Location.Geocoder 1190 * @since 9 1191 */ 1192 postalCode?: string; 1193 1194 /** 1195 * Indicates phone number. 1196 * 1197 * @type { ?string } 1198 * @syscap SystemCapability.Location.Location.Geocoder 1199 * @since 9 1200 */ 1201 phoneNumber?: string; 1202 1203 /** 1204 * Indicates website URL. 1205 * 1206 * @type { ?string } 1207 * @syscap SystemCapability.Location.Location.Geocoder 1208 * @since 9 1209 */ 1210 addressUrl?: string; 1211 1212 /** 1213 * Indicates additional information. 1214 * 1215 * @type { ?Array<string> } 1216 * @syscap SystemCapability.Location.Location.Geocoder 1217 * @since 9 1218 */ 1219 descriptions?: Array<string>; 1220 1221 /** 1222 * Indicates the amount of additional descriptive information. 1223 * 1224 * @type { ?number } 1225 * @syscap SystemCapability.Location.Location.Geocoder 1226 * @since 9 1227 */ 1228 descriptionsSize?: number; 1229 1230 /** 1231 * Indicates whether it is an mock GeoAddress 1232 * 1233 * @type { ?Boolean } 1234 * @syscap SystemCapability.Location.Location.Geocoder 1235 * @systemapi 1236 * @since 9 1237 */ 1238 isFromMock?: Boolean; 1239 } 1240 1241 /** 1242 * Configuring parameters in location requests. 1243 * 1244 * @typedef LocationRequest 1245 * @syscap SystemCapability.Location.Location.Core 1246 * @since 9 1247 */ 1248 export interface LocationRequest { 1249 /** 1250 * Priority of the location request. 1251 * 1252 * @type { ?LocationRequestPriority } 1253 * @syscap SystemCapability.Location.Location.Core 1254 * @since 9 1255 */ 1256 priority?: LocationRequestPriority; 1257 1258 /** 1259 * User scenario of the location request. 1260 * 1261 * @type { ?LocationRequestScenario } 1262 * @syscap SystemCapability.Location.Location.Core 1263 * @since 9 1264 */ 1265 scenario?: LocationRequestScenario; 1266 1267 /** 1268 * Location report interval. 1269 * 1270 * @type { ?number } 1271 * @syscap SystemCapability.Location.Location.Core 1272 * @since 9 1273 */ 1274 timeInterval?: number; 1275 1276 /** 1277 * Location report distance interval. 1278 * 1279 * @type { ?number } 1280 * @syscap SystemCapability.Location.Location.Core 1281 * @since 9 1282 */ 1283 distanceInterval?: number; 1284 1285 /** 1286 * Accuracy requirements for reporting locations. 1287 * 1288 * @type { ?number } 1289 * @syscap SystemCapability.Location.Location.Core 1290 * @since 9 1291 */ 1292 maxAccuracy?: number; 1293 } 1294 1295 /** 1296 * Configuring parameters in current location requests. 1297 * 1298 * @typedef CurrentLocationRequest 1299 * @syscap SystemCapability.Location.Location.Core 1300 * @since 9 1301 */ 1302 export interface CurrentLocationRequest { 1303 /** 1304 * Priority of the location request. 1305 * 1306 * @type { ?LocationRequestPriority } 1307 * @syscap SystemCapability.Location.Location.Core 1308 * @since 9 1309 */ 1310 priority?: LocationRequestPriority; 1311 1312 /** 1313 * User scenario of the location request. 1314 * 1315 * @type { ?LocationRequestScenario } 1316 * @syscap SystemCapability.Location.Location.Core 1317 * @since 9 1318 */ 1319 scenario?: LocationRequestScenario; 1320 1321 /** 1322 * Accuracy requirements for reporting locations. 1323 * 1324 * @type { ?number } 1325 * @syscap SystemCapability.Location.Location.Core 1326 * @since 9 1327 */ 1328 maxAccuracy?: number; 1329 1330 /** 1331 * Timeout interval of a single location request. 1332 * 1333 * @type { ?number } 1334 * @syscap SystemCapability.Location.Location.Core 1335 * @since 9 1336 */ 1337 timeoutMs?: number; 1338 } 1339 1340 /** 1341 * Provides information about geographic locations. 1342 * 1343 * @typedef Location 1344 * @syscap SystemCapability.Location.Location.Core 1345 * @since 9 1346 */ 1347 export interface Location { 1348 /** 1349 * Indicates latitude information. 1350 * A positive value indicates north latitude, 1351 * and a negative value indicates south latitude. 1352 * 1353 * @type { number } 1354 * @syscap SystemCapability.Location.Location.Core 1355 * @since 9 1356 */ 1357 latitude: number; 1358 1359 /** 1360 * Indicates Longitude information. 1361 * A positive value indicates east longitude , 1362 * and a negative value indicates west longitude. 1363 * 1364 * @type { number } 1365 * @syscap SystemCapability.Location.Location.Core 1366 * @since 9 1367 */ 1368 longitude: number; 1369 1370 /** 1371 * Indicates location altitude, in meters. 1372 * 1373 * @type { number } 1374 * @syscap SystemCapability.Location.Location.Core 1375 * @since 9 1376 */ 1377 altitude: number; 1378 1379 /** 1380 * Indicates location accuracy, in meters. 1381 * 1382 * @type { number } 1383 * @syscap SystemCapability.Location.Location.Core 1384 * @since 9 1385 */ 1386 accuracy: number; 1387 1388 /** 1389 * Indicates speed, in m/s. 1390 * 1391 * @type { number } 1392 * @syscap SystemCapability.Location.Location.Core 1393 * @since 9 1394 */ 1395 speed: number; 1396 1397 /** 1398 * Indicates location timestamp in the UTC format. 1399 * 1400 * @type { number } 1401 * @syscap SystemCapability.Location.Location.Core 1402 * @since 9 1403 */ 1404 timeStamp: number; 1405 1406 /** 1407 * Indicates direction information. 1408 * 1409 * @type { number } 1410 * @syscap SystemCapability.Location.Location.Core 1411 * @since 9 1412 */ 1413 direction: number; 1414 1415 /** 1416 * Indicates location timestamp since boot. 1417 * 1418 * @type { number } 1419 * @syscap SystemCapability.Location.Location.Core 1420 * @since 9 1421 */ 1422 timeSinceBoot: number; 1423 1424 /** 1425 * Indicates additional information. 1426 * 1427 * @type { ?Array<string> } 1428 * @syscap SystemCapability.Location.Location.Core 1429 * @since 9 1430 */ 1431 additions?: Array<string>; 1432 1433 /** 1434 * Indicates the amount of additional descriptive information. 1435 * 1436 * @type { ?number } 1437 * @syscap SystemCapability.Location.Location.Core 1438 * @since 9 1439 */ 1440 additionSize?: number; 1441 1442 /** 1443 * Indicates whether it is an mock location. 1444 * 1445 * @type { ?Boolean } 1446 * @syscap SystemCapability.Location.Location.Core 1447 * @systemapi 1448 * @since 9 1449 */ 1450 isFromMock?: Boolean; 1451 } 1452 1453 /** 1454 * Describes the request parameters for obtaining the data required for locating. 1455 * @typedef LocatingRequiredDataConfig 1456 * @syscap SystemCapability.Location.Location.Core 1457 * @systemapi 1458 * @since 10 1459 */ 1460 export interface LocatingRequiredDataConfig { 1461 /** 1462 * Indicates the type of locating required data. 1463 * 1464 * @type {LocatingRequiredDataType} 1465 * @syscap SystemCapability.Location.Location.Core 1466 * @systemapi 1467 * @since 10 1468 */ 1469 type: LocatingRequiredDataType; 1470 1471 /** 1472 * Indicates whether to start scanning. 1473 * 1474 * @type {boolean} 1475 * @syscap SystemCapability.Location.Location.Core 1476 * @systemapi 1477 * @since 10 1478 */ 1479 needStartScan: boolean; 1480 1481 /** 1482 * Indicates the interval between scans. The unit is millisecond. 1483 * This parameter needs to be set only when scanning information is continuously monitored. 1484 * 1485 * @type {?number} 1486 * @syscap SystemCapability.Location.Location.Core 1487 * @systemapi 1488 * @since 10 1489 */ 1490 scanInterval?: number; 1491 1492 /** 1493 * Indicates the timeout period of a single scan. The unit is millisecond. The default value is 10000. 1494 * This parameter needs to be set only when getLocatingRequiredData is used. 1495 * 1496 * @type {?number} 1497 * @syscap SystemCapability.Location.Location.Core 1498 * @systemapi 1499 * @since 10 1500 */ 1501 scanTimeout?: number; 1502 } 1503 1504 /** 1505 * Describes the structure of the data required for locating. 1506 * @typedef LocatingRequiredData 1507 * @syscap SystemCapability.Location.Location.Core 1508 * @systemapi 1509 * @since 10 1510 */ 1511 export interface LocatingRequiredData { 1512 /** 1513 * WiFi scan info. 1514 * 1515 * @type {?WifiScanInfo} 1516 * @syscap SystemCapability.Location.Location.Core 1517 * @systemapi 1518 * @since 10 1519 */ 1520 wifiData?: WifiScanInfo; 1521 1522 /** 1523 * Bluetooth scan info. 1524 * 1525 * @type {?BluetoothScanInfo} 1526 * @syscap SystemCapability.Location.Location.Core 1527 * @systemapi 1528 * @since 10 1529 */ 1530 bluetoothData?: BluetoothScanInfo; 1531 } 1532 1533 /** 1534 * Describes the scanned WiFi information. 1535 * @typedef WifiScanInfo 1536 * @syscap SystemCapability.Location.Location.Core 1537 * @systemapi 1538 * @since 10 1539 */ 1540 export interface WifiScanInfo { 1541 /** 1542 * WiFi SSID: the maximum length is 32. 1543 * 1544 * @type {string} 1545 * @syscap SystemCapability.Location.Location.Core 1546 * @systemapi 1547 * @since 10 1548 */ 1549 ssid: string; 1550 1551 /** 1552 * WiFi bssid(MAC): the length is 6. 1553 * 1554 * @type {string} 1555 * @syscap SystemCapability.Location.Location.Core 1556 * @systemapi 1557 * @since 10 1558 */ 1559 bssid: string; 1560 1561 /** 1562 * Received signal strength indicator (RSSI). 1563 * 1564 * @type {number} 1565 * @syscap SystemCapability.Location.Location.Core 1566 * @systemapi 1567 * @since 10 1568 */ 1569 rssi: number; 1570 1571 /** 1572 * Frequency 1573 * 1574 * @type {number} 1575 * @syscap SystemCapability.Location.Location.Core 1576 * @systemapi 1577 * @since 10 1578 */ 1579 frequency: number; 1580 1581 /** 1582 * Time stamp. 1583 * 1584 * @type {number} 1585 * @syscap SystemCapability.Location.Location.Core 1586 * @systemapi 1587 * @since 10 1588 */ 1589 timestamp: number; 1590 } 1591 1592 /** 1593 * Describes the contents of the Bluetooth scan results. 1594 * 1595 * @typedef BluetoothScanInfo 1596 * @syscap SystemCapability.Location.Location.Core 1597 * @systemapi 1598 * @since 10 1599 */ 1600 export interface BluetoothScanInfo { 1601 /** 1602 * The local name of the device. 1603 * 1604 * @type {string} 1605 * @syscap SystemCapability.Location.Location.Core 1606 * @systemapi 1607 * @since 10 1608 */ 1609 deviceName: string; 1610 1611 /** 1612 * Mac address of the scanned device. 1613 * 1614 * @type {string} 1615 * @syscap SystemCapability.Location.Location.Core 1616 * @systemapi 1617 * @since 10 1618 */ 1619 macAddress: string; 1620 1621 /** 1622 * RSSI of the remote device. 1623 * 1624 * @type {number} 1625 * @syscap SystemCapability.Location.Location.Core 1626 * @systemapi 1627 * @since 10 1628 */ 1629 rssi: number; 1630 1631 /** 1632 * Time stamp. 1633 * 1634 * @type {number} 1635 * @syscap SystemCapability.Location.Location.Core 1636 * @systemapi 1637 * @since 10 1638 */ 1639 timestamp: number; 1640 } 1641 1642 /** 1643 * Enum for location priority. 1644 * 1645 * @enum { number } 1646 * @syscap SystemCapability.Location.Location.Core 1647 * @since 9 1648 */ 1649 export enum LocationRequestPriority { 1650 /** 1651 * Default priority. 1652 * 1653 * @syscap SystemCapability.Location.Location.Core 1654 * @since 9 1655 */ 1656 UNSET = 0x200, 1657 1658 /** 1659 * Preferentially ensure the locating accuracy. 1660 * 1661 * @syscap SystemCapability.Location.Location.Core 1662 * @since 9 1663 */ 1664 ACCURACY, 1665 1666 /** 1667 * Preferentially ensure low power consumption for locating. 1668 * 1669 * @syscap SystemCapability.Location.Location.Core 1670 * @since 9 1671 */ 1672 LOW_POWER, 1673 1674 /** 1675 * Preferentially ensure that the first location is time-consuming. 1676 * 1677 * @syscap SystemCapability.Location.Location.Core 1678 * @since 9 1679 */ 1680 FIRST_FIX 1681 } 1682 1683 /** 1684 * Enum for location scenario. 1685 * 1686 * @enum { number } 1687 * @syscap SystemCapability.Location.Location.Core 1688 * @since 9 1689 */ 1690 export enum LocationRequestScenario { 1691 /** 1692 * Default scenario. 1693 * 1694 * @syscap SystemCapability.Location.Location.Core 1695 * @since 9 1696 */ 1697 UNSET = 0x300, 1698 1699 /** 1700 * Navigation scenario. High positioning precision and real-time performance are required. 1701 * 1702 * @syscap SystemCapability.Location.Location.Core 1703 * @since 9 1704 */ 1705 NAVIGATION, 1706 1707 /** 1708 * Trajectory tracking scenario. High positioning precision is required. 1709 * 1710 * @syscap SystemCapability.Location.Location.Core 1711 * @since 9 1712 */ 1713 TRAJECTORY_TRACKING, 1714 1715 /** 1716 * Car hailing scenario. High positioning precision and real-time performance are required. 1717 * 1718 * @syscap SystemCapability.Location.Location.Core 1719 * @since 9 1720 */ 1721 CAR_HAILING, 1722 1723 /** 1724 * Daily life scenarios. Low requirements on positioning precision and real-time performance. 1725 * 1726 * @syscap SystemCapability.Location.Location.Core 1727 * @since 9 1728 */ 1729 DAILY_LIFE_SERVICE, 1730 1731 /** 1732 * Power saving scenarios. 1733 * 1734 * @syscap SystemCapability.Location.Location.Core 1735 * @since 9 1736 */ 1737 NO_POWER 1738 } 1739 1740 /** 1741 * Enum for location privacy type. 1742 * 1743 * @enum { number } 1744 * @syscap SystemCapability.Location.Location.Core 1745 * @systemapi 1746 * @since 9 1747 */ 1748 export enum LocationPrivacyType { 1749 /** 1750 * Other scenarios. 1751 * 1752 * @syscap SystemCapability.Location.Location.Core 1753 * @systemapi 1754 * @since 9 1755 */ 1756 OTHERS = 0, 1757 1758 /** 1759 * Privacy agreement for the startup wizard scenario. 1760 * 1761 * @syscap SystemCapability.Location.Location.Core 1762 * @systemapi 1763 * @since 9 1764 */ 1765 STARTUP, 1766 1767 /** 1768 * Privacy agreement pop-up when network location is enabled. 1769 * 1770 * @syscap SystemCapability.Location.Location.Core 1771 * @systemapi 1772 * @since 9 1773 */ 1774 CORE_LOCATION 1775 } 1776 1777 /** 1778 * Location subsystem command structure. 1779 * 1780 * @typedef LocationCommand 1781 * @syscap SystemCapability.Location.Location.Core 1782 * @since 9 1783 */ 1784 export interface LocationCommand { 1785 /** 1786 * Information about the scenario where the command is sent. 1787 * 1788 * @type { LocationRequestScenario } 1789 * @syscap SystemCapability.Location.Location.Core 1790 * @since 9 1791 */ 1792 scenario: LocationRequestScenario; 1793 1794 /** 1795 * Sent command content. 1796 * 1797 * @type { string } 1798 * @syscap SystemCapability.Location.Location.Core 1799 * @since 9 1800 */ 1801 command: string; 1802 } 1803 1804 /** 1805 * Country code structure. 1806 * 1807 * @typedef CountryCode 1808 * @syscap SystemCapability.Location.Location.Core 1809 * @since 9 1810 */ 1811 export interface CountryCode { 1812 /** 1813 * Country code character string. 1814 * 1815 * @type { string } 1816 * @syscap SystemCapability.Location.Location.Core 1817 * @since 9 1818 */ 1819 country: string; 1820 1821 /** 1822 * Country code source. 1823 * 1824 * @type { CountryCodeType } 1825 * @syscap SystemCapability.Location.Location.Core 1826 * @since 9 1827 */ 1828 type: CountryCodeType; 1829 } 1830 1831 /** 1832 * Enum for country code type. 1833 * 1834 * @enum { number } 1835 * @syscap SystemCapability.Location.Location.Core 1836 * @since 9 1837 */ 1838 export enum CountryCodeType { 1839 /** 1840 * Country code obtained from the locale setting. 1841 * 1842 * @syscap SystemCapability.Location.Location.Core 1843 * @since 9 1844 */ 1845 COUNTRY_CODE_FROM_LOCALE = 1, 1846 1847 /** 1848 * Country code obtained from the SIM information. 1849 * 1850 * @syscap SystemCapability.Location.Location.Core 1851 * @since 9 1852 */ 1853 COUNTRY_CODE_FROM_SIM, 1854 1855 /** 1856 * Query the country code information from the reverse geocoding result. 1857 * 1858 * @syscap SystemCapability.Location.Location.Core 1859 * @since 9 1860 */ 1861 COUNTRY_CODE_FROM_LOCATION, 1862 1863 /** 1864 * Obtain the country code from the cell registration information. 1865 * 1866 * @syscap SystemCapability.Location.Location.Core 1867 * @since 9 1868 */ 1869 COUNTRY_CODE_FROM_NETWORK 1870 } 1871 1872 /** 1873 * Enum for locating required data type. 1874 * 1875 * @enum { number } 1876 * @syscap SystemCapability.Location.Location.Core 1877 * @systemapi 1878 * @since 10 1879 */ 1880 export enum LocatingRequiredDataType { 1881 /** 1882 * Obtains WiFi scanning information for locating. 1883 * 1884 * @syscap SystemCapability.Location.Location.Core 1885 * @systemapi 1886 * @since 10 1887 */ 1888 WIFI = 1, 1889 1890 /** 1891 * Obtains BT scanning information for locating. 1892 * 1893 * @syscap SystemCapability.Location.Location.Core 1894 * @systemapi 1895 * @since 10 1896 */ 1897 BLUETOOTH 1898 } 1899} 1900 1901export default geoLocationManager; 1902