diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 13d87e726..56d7c34f5 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,111 @@ 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 whether the position simulation function is enabled. + */ + function enableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback) : void; + function enableLocationMock(scenario: LocationRequestScenario) : Promise; + + /** + * diable 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 whether the position simulation function is enabled. + */ + function disableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback) : void; + function disableLocationMock(scenario: LocationRequestScenario) : Promise; + + /** + * sets 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 whether the parameters of the location simulation function are set successfully. + */ + 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 whether the reverse geocoding simulation function is enabled. + */ + 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 whether the reverse geocoding simulation function is enabled. + */ + function disableReverseGeocodingMock(callback: AsyncCallback) : void; + function disableReverseGeocodingMock() : Promise; + + /** + * sets 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 whether the parameters of the reverse geocoding simulation are set successfully. + */ + 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 { + scenario: LocationRequestScenario; + timeInterval: number; + locations: Array; + } + /** * satellite status information * @@ -425,6 +548,7 @@ declare namespace geolocation { addressUrl?: string; descriptions?: Array; descriptionsSize?: number; + isFromMock: Boolean; } /** @@ -474,6 +598,7 @@ declare namespace geolocation { timeSinceBoot: number; additions?: Array; additionSize?: number; + isFromMock: Boolean; } /** @@ -514,13 +639,15 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export enum GeoLocationErrorCode { - INPUT_PARAMS_ERROR = 101, + NOT_SUPPORTED = 100, + INPUT_PARAMS_ERROR, REVERSE_GEOCODE_ERROR, GEOCODE_ERROR, LOCATOR_ERROR, LOCATION_SWITCH_ERROR, LAST_KNOWN_LOCATION_ERROR, LOCATION_REQUEST_TIMEOUT_ERROR, + QUERY_COUNTRY_CODE_ERROR, } /** @@ -547,6 +674,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;