diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 13d87e726d3e111d54abef61a805f9222880787e..d8a755e11c027b7b3a0ae7f528d2da1609a0cc62 100644 --- a/api/@ohos.geolocation.d.ts +++ b/api/@ohos.geolocation.d.ts @@ -149,6 +149,24 @@ declare namespace geolocation { */ function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; + /** + * registering the callback function for listening to country code changes. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting country code changes. + */ + function on(type: 'countryCodeChange', callback: Callback) : void; + + /** + * unregistering the callback function for listening to country code changes. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting country code changes. + */ + function off(type: 'countryCodeChange', callback?: Callback) : void; + /** * obtain current location * @@ -286,6 +304,123 @@ declare namespace geolocation { function sendCommand(command: LocationCommand, callback: AsyncCallback) : void; function sendCommand(command: LocationCommand) : Promise; + /** + * obtain the current country code. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting the country code. + */ + function getCountryCode(callback: AsyncCallback) : void; + function getCountryCode() : Promise; + + /** + * enable the geographical location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param scenario Indicates the scenarios where location simulation is required. + * @param callback Indicates a callback function, which is used to report the result + * of enabling the location simulation function. If the enabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If enabling succeeds, no data will be returned. + */ + function enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback) : void; + function enableLocationMock(scenario?: LocationRequestScenario) : Promise; + + /** + * disable the geographical location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param scenario Indicates the scenarios where location simulation is required. + * @param callback Indicates a callback function, which is used to report the result + * of disabling the location simulation function. If the disabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. + */ + function disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback) : void; + function disableLocationMock(scenario?: LocationRequestScenario) : Promise; + + /** + * set the configuration parameters for location simulation. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param config Indicates the configuration parameters for location simulation. + * @param callback Indicates a callback function, which is used to report the result of setting + * the simulation locations. If the setting fails, the error message will be carried in the first + * parameter err of AsyncCallback. If the setting succeeds, no data will be returned. + */ + function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback) : void; + function setMockedLocations(config: LocationMockConfig) : Promise; + + /** + * enable the reverse geocoding simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the result + * of enabling the reverse geocode simulation function. If the enabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If enabling succeeds, no data will be returned. + */ + function enableReverseGeocodingMock(callback: AsyncCallback) : void; + function enableReverseGeocodingMock() : Promise; + + /** + * disable the reverse geocoding simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the result + * of disabling the reverse geocode simulation function. If the disabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. + */ + function disableReverseGeocodingMock(callback: AsyncCallback) : void; + function disableReverseGeocodingMock() : Promise; + + /** + * set the configuration parameters for simulating reverse geocoding. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param mockInfos Indicates the set of locations and place names to be simulated. + * @param callback Indicates a callback function, which is used to report the result of setting + * the configuration parameters for simulating reverse geocoding. If the setting fails, + * the error message will be carried in the first parameter err of AsyncCallback. + * If the setting succeeds, no data will be returned. + */ + function setReverseGeocodingMockInfo(mockInfos: Array, callback: AsyncCallback) : void; + function setReverseGeocodingMockInfo(mockInfos: Array) : Promise; + + /** + * configuration parameters for simulating reverse geocoding. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + */ + export interface ReverseGeocodingMockInfo { + location: ReverseGeoCodeRequest; + geoAddress: GeoAddress; + } + + /** + * parameters for configuring the location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + */ + export interface LocationMockConfig { + timeInterval: number; + locations: Array; + } + /** * satellite status information * @@ -407,24 +542,124 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export interface GeoAddress { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 7 + */ latitude?: number; + + /** + * Indicates longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 7 + */ longitude?: number; + + /** + * Indicates language used for the location description. + * zh indicates Chinese, and en indicates English. + * @since 7 + */ locale?: string; + + /** + * Indicates landmark of the location. + * @since 7 + */ placeName?: string; + + /** + * Indicates country code. + * @since 7 + */ countryCode?: string; + + /** + * Indicates country name. + * @since 7 + */ countryName?: string; + + /** + * Indicates administrative region name. + * @since 7 + */ administrativeArea?: string; + + /** + * Indicates sub-administrative region name. + * @since 7 + */ subAdministrativeArea?: string; + + /** + * Indicates locality information. + * @since 7 + */ locality?: string; + + /** + * Indicates sub-locality information. + * @since 7 + */ subLocality?: string; + + /** + * Indicates road name. + * @since 7 + */ roadName?: string; + + /** + * Indicates auxiliary road information. + * @since 7 + */ subRoadName?: string; + + /** + * Indicates house information. + * @since 7 + */ premises?: string; + + /** + * Indicates postal code. + * @since 7 + */ postalCode?: string; + + /** + * Indicates phone number. + * @since 7 + */ phoneNumber?: string; + + /** + * Indicates website URL. + * @since 7 + */ addressUrl?: string; + + /** + * Indicates additional information. + * @since 7 + */ descriptions?: Array; + + /** + * Indicates the amount of additional descriptive information. + * @since 7 + */ descriptionsSize?: number; + + /** + * Indicates whether it is an mock GeoAddress + * @since 9 + */ + isFromMock: Boolean; } /** @@ -464,16 +699,75 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export interface Location { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 7 + */ latitude: number; + + /** + * Indicates Longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 7 + */ longitude: number; + + /** + * Indicates location altitude, in meters. + * @since 7 + */ altitude: number; + + /** + * Indicates location accuracy, in meters. + * @since 7 + */ accuracy: number; + + /** + * Indicates speed, in m/s. + * @since 7 + */ speed: number; + + /** + * Indicates location timestamp in the UTC format. + * @since 7 + */ timeStamp: number; + + /** + * Indicates direction information. + * @since 7 + */ direction: number; + + /** + * Indicates location timestamp since boot. + * @since 7 + */ timeSinceBoot: number; + + /** + * Indicates additional information. + * @since 7 + */ additions?: Array; + + /** + * Indicates the amount of additional descriptive information. + * @since 7 + */ additionSize?: number; + + /** + * Indicates whether it is an mock location. + * @since 9 + */ + isFromMock: Boolean; } /** @@ -514,13 +808,59 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export enum GeoLocationErrorCode { - INPUT_PARAMS_ERROR = 101, + /** + * Indicates function not supported. + * @since 9 + */ + NOT_SUPPORTED = 100, + + /** + * Indicates input parameter error. + * @since 7 + */ + INPUT_PARAMS_ERROR, + + /** + * Indicates reverse geocode query failed. + * @since 7 + */ REVERSE_GEOCODE_ERROR, + + /** + * Indicates geocode query failed. + * @since 7 + */ GEOCODE_ERROR, + + /** + * Indicates positioning failed. + * @since 7 + */ LOCATOR_ERROR, + + /** + * Indicates operation failure caused by abnormal location switch. + * @since 7 + */ LOCATION_SWITCH_ERROR, + + /** + * Indicates failed to get the last known location. + * @since 7 + */ LAST_KNOWN_LOCATION_ERROR, + + /** + * Indicates location request timeout. + * @since 7 + */ LOCATION_REQUEST_TIMEOUT_ERROR, + + /** + * Indicates country code query failed. + * @since 9 + */ + QUERY_COUNTRY_CODE_ERROR, } /** @@ -547,6 +887,30 @@ declare namespace geolocation { scenario: LocationRequestScenario; command: string; } + + /** + * country code structure + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export interface CountryCode { + country: string; + type: CountryCodeType; + } + + /** + * enum for country code type + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export enum CountryCodeType { + COUNTRY_CODE_FROM_LOCALE = 1, + COUNTRY_CODE_FROM_SIM, + COUNTRY_CODE_FROM_LOCATION, + COUNTRY_CODE_FROM_NETWORK, + } } -export default geolocation; \ No newline at end of file +export default geolocation;