diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 1df441c53064f8f07af76029d4083b0459e1f329..ab24bda4c1ab7280efc24dab72d40430644ead96 100644 --- a/api/@ohos.geolocation.d.ts +++ b/api/@ohos.geolocation.d.ts @@ -13,14 +13,14 @@ * limitations under the License. */ import { AsyncCallback, Callback } from './basic.d.ts'; +import WantAgent from '@ohos.wantAgent'; /** * Provides interfaces for initiating location requests, ending the location service, * and obtaining the location result cached by the system. * * @since 7 - * @SysCap SystemCapability.Location#LOCATION - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core * @import import geolocation from '@ohos.geolocation' * @permission ohos.permission.LOCATION */ @@ -29,8 +29,8 @@ declare namespace geolocation { * subscribe location changed * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param request Indicates the location request parameters. * @param callback Indicates the callback for reporting the location result. */ @@ -40,8 +40,8 @@ declare namespace geolocation { * unsubscribe location changed * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location result. */ function off(type: 'locationChange', callback?: Callback) : void; @@ -50,8 +50,8 @@ declare namespace geolocation { * subscribe location switch changed * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location result. */ function on(type: 'locationServiceState', callback: Callback) : void; @@ -60,18 +60,101 @@ declare namespace geolocation { * unsubscribe location switch changed * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location result. */ function off(type: 'locationServiceState', callback?: Callback) : void; + /** + * subscribe to cache GNSS locations update messages + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param request Indicates the cached GNSS locations request parameters. + * @param callback Indicates the callback for reporting the cached GNSS locations. + */ + function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback>) : void; + + /** + * unsubscribe to cache GNSS locations update messages + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the cached gnss locations. + */ + function off(type: 'cachedGnssLocationsReporting', callback?: Callback>) : void; + + /** + * subscribe gnss status changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the gnss status change. + */ + function on(type: 'gnssStatusChange', callback: Callback) : void; + + /** + * unsubscribe gnss status changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the gnss status change. + */ + function off(type: 'gnssStatusChange', callback?: Callback) : void; + + /** + * subscribe nmea message changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the nmea message. + */ + function on(type: 'nmeaMessageChange', callback: Callback) : void; + + /** + * unsubscribe nmea message changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the nmea message. + */ + function off(type: 'nmeaMessageChange', callback?: Callback) : void; + + /** + * add a geofence and subscribe geo fence status changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + * @param request Indicates the Geo-fence configuration parameters. + * @param callback Indicates the callback for reporting the fence status. + */ + function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; + + /** + * remove a geofence and unsubscribe geo fence status changed + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + * @param request Indicates the Geo-fence configuration parameters. + * @param callback Indicates the callback for reporting the remove fence result. + */ + function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; + /** * obtain current location * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location result. */ function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback) : void; @@ -82,8 +165,8 @@ declare namespace geolocation { * obtain last known location * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location result. */ function getLastLocation(callback: AsyncCallback) : void; @@ -93,8 +176,8 @@ declare namespace geolocation { * obtain current location switch status * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location switch result. */ function isLocationEnabled(callback: AsyncCallback) : void; @@ -104,8 +187,8 @@ declare namespace geolocation { * request enable location * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location switch status. */ function requestEnableLocation(callback: AsyncCallback) : void; @@ -115,10 +198,9 @@ declare namespace geolocation { * enable location switch * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core * @systemapi - * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location switch result. */ function enableLocation(callback: AsyncCallback) : void; @@ -128,10 +210,9 @@ declare namespace geolocation { * disable location switch * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core * @systemapi - * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the location switch result. */ function disableLocation(callback: AsyncCallback) : void; @@ -141,8 +222,8 @@ declare namespace geolocation { * obtain address info from location * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the address info. */ function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback>) : void; @@ -152,8 +233,8 @@ declare namespace geolocation { * obtain latitude and longitude info from location address * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the latitude and longitude result. */ function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback>) : void; @@ -163,18 +244,136 @@ declare namespace geolocation { * obtain geocode service status * * @since 7 - * @SysCap SystemCapability.Location.Location - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION * @param callback Indicates the callback for reporting the geocode service status. */ function isGeoServiceAvailable(callback: AsyncCallback) : void; function isGeoServiceAvailable() : Promise; + /** + * obtain the number of cached GNSS locations reported at a time + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the cached GNSS locations size. + */ + function getCachedGnssLocationsSize(callback: AsyncCallback) : void; + function getCachedGnssLocationsSize() : Promise; + + /** + * all prepared GNSS locations are returned to the application through the callback function, + * and the bottom-layer buffer is cleared. + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the result. + */ + function flushCachedGnssLocations(callback: AsyncCallback) : void; + function flushCachedGnssLocations() : Promise; + + /** + * send extended commands to location subsystem. + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param command Indicates the extended Command Message Body,it is a JSON string. + * @param callback Indicates the callback for reporting the send command result. + */ + function sendCommand(command: LocationCommand, callback: AsyncCallback) : void; + function sendCommand(command: LocationCommand) : Promise; + + /** + * satellite status information + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + */ + export interface SatelliteStatusInfo { + satellitesNumber: number; + satelliteIds: Array; + carrierToNoiseDensitys: Array; + altitude: Array; + azimuths: Array; + carrierFrequencies: Array; + } + + /** + * parameters for requesting to report cache location information + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + */ + export interface CachedGnssLoactionsRequest { + reportingPeriodSec: number; + wakeUpCacheQueueFull: boolean; + } + + /** + * configuring parameters in geo fence requests + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + */ + export interface GeofenceRequest { + priority: LocationRequestPriority; + scenario: LocationRequestScenario; + geofence: Geofence; + } + + /** + * configuring parameters in geo fence requests + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + */ + export interface Geofence { + latitude: number; + longitude: number; + radius: number; + expiration: number; + } + + /** + * querying location privacy protocol confirmation status. + * + * @since 8 + * @systemapi + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param type indicates location privacy protocol type. + * @param callback indicates the callback for reporting the location privacy protocol confirmation status. + */ + function isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback) : void; + function isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise; + + /** + * set location privacy protocol confirmation status. + * + * @since 8 + * @systemapi + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param type indicates location privacy protocol type. + * @param isConfirmed indicates whether the location privacy protocol has been confirmed. + * @param callback Indicates the callback for reporting whether the action is set successfully. + */ + function setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback) : void; + function setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise; + /** * configuring parameters in reverse geocode requests * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION */ export interface ReverseGeoCodeRequest { locale?: string; @@ -187,7 +386,8 @@ declare namespace geolocation { * configuring parameters in geocode requests * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION */ export interface GeoCodeRequest { locale?: string; @@ -203,7 +403,8 @@ declare namespace geolocation { * data struct describes geographic locations. * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION */ export interface GeoAddress { latitude?: number; @@ -230,7 +431,8 @@ declare namespace geolocation { * configuring parameters in location requests * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export interface LocationRequest { priority?: LocationRequestPriority; @@ -244,7 +446,8 @@ declare namespace geolocation { * configuring parameters in current location requests * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export interface CurrentLocationRequest { priority?: LocationRequestPriority; @@ -257,7 +460,8 @@ declare namespace geolocation { * provides information about geographic locations * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export interface Location { latitude: number; @@ -276,7 +480,8 @@ declare namespace geolocation { * enum for location priority * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export enum LocationRequestPriority { UNSET = 0x200, @@ -289,7 +494,8 @@ declare namespace geolocation { * enum for location scenario * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export enum LocationRequestScenario { UNSET = 0x300, @@ -304,7 +510,8 @@ declare namespace geolocation { * enum for error code * * @since 7 - * @devices phone, tablet, tv, wearable, car + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION */ export enum GeoLocationErrorCode { INPUT_PARAMS_ERROR = 101, @@ -315,6 +522,31 @@ declare namespace geolocation { LAST_KNOWN_LOCATION_ERROR, LOCATION_REQUEST_TIMEOUT_ERROR, } + + /** + * enum for location privacy type + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export enum LocationPrivacyType { + OTHERS = 0, + STARTUP, + CORE_LOCATION, + } + + /** + * Location subsystem command structure + * + * @since 8 + * @SysCap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export interface LocationCommand { + scenario: LocationRequestScenario; + command: string; + } } -export default geolocation; +export default geolocation; \ No newline at end of file