From a58adcae3710ea123f290206339040acce04600b Mon Sep 17 00:00:00 2001 From: liu-binjun Date: Thu, 30 Jun 2022 17:14:47 +0800 Subject: [PATCH 1/3] feature:add interfaces for api9 Signed-off-by: liu-binjun --- api/@ohos.geolocation.d.ts | 155 ++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 2 deletions(-) diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 13d87e726d..56d7c34f54 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; -- Gitee From 9a1c19a9e0a226e39319e99a8b37300c077fc1e0 Mon Sep 17 00:00:00 2001 From: liu-binjun Date: Thu, 7 Jul 2022 21:35:24 +0800 Subject: [PATCH 2/3] bugfix:fix review issues Signed-off-by: liu-binjun --- api/@ohos.geolocation.d.ts | 232 ++++++++++++++++++++++++++++++++++--- 1 file changed, 216 insertions(+), 16 deletions(-) diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 56d7c34f54..56c14d6488 100644 --- a/api/@ohos.geolocation.d.ts +++ b/api/@ohos.geolocation.d.ts @@ -165,7 +165,7 @@ declare namespace geolocation { * @syscap SystemCapability.Location.Location.Core * @param callback Indicates the callback for reporting country code changes. */ - function off(type: 'countryCodeChange', callback: Callback) : void; + function off(type: 'countryCodeChange', callback?: Callback) : void; /** * obtain current location @@ -323,8 +323,8 @@ declare namespace geolocation { * @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; + function enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback) : void; + function enableLocationMock(scenario?: LocationRequestScenario) : Promise; /** * diable the geographical location simulation function. @@ -335,11 +335,11 @@ declare namespace geolocation { * @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; + function disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback) : void; + function disableLocationMock(scenario?: LocationRequestScenario) : Promise; /** - * sets the configuration parameters for location simulation. + * set the configuration parameters for location simulation. * * @since 9 * @syscap SystemCapability.Location.Location.Core @@ -347,8 +347,8 @@ declare namespace geolocation { * @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; + function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback) : void; + function setMockedLocations(config: LocationMockConfig) : Promise; /** * enable the reverse geocoding simulation function. @@ -358,8 +358,8 @@ declare namespace geolocation { * @systemapi * @param callback Indicates whether the reverse geocoding simulation function is enabled. */ - function enableReverseGeocodingMock(callback: AsyncCallback) : void; - function enableReverseGeocodingMock() : Promise; + function enableReverseGeocodingMock(callback: AsyncCallback) : void; + function enableReverseGeocodingMock() : Promise; /** * disable the reverse geocoding simulation function. @@ -369,11 +369,11 @@ declare namespace geolocation { * @systemapi * @param callback Indicates whether the reverse geocoding simulation function is enabled. */ - function disableReverseGeocodingMock(callback: AsyncCallback) : void; - function disableReverseGeocodingMock() : Promise; + function disableReverseGeocodingMock(callback: AsyncCallback) : void; + function disableReverseGeocodingMock() : Promise; /** - * sets the configuration parameters for simulating reverse geocoding. + * set the configuration parameters for simulating reverse geocoding. * * @since 9 * @syscap SystemCapability.Location.Location.Core @@ -381,8 +381,8 @@ declare namespace geolocation { * @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; + function setReverseGeocodingMockInfo(mockInfos: Array, callback: AsyncCallback) : void; + function setReverseGeocodingMockInfo(mockInfos: Array) : Promise; /** * configuration parameters for simulating reverse geocoding. @@ -404,7 +404,6 @@ declare namespace geolocation { * @systemapi */ export interface LocationMockConfig { - scenario: LocationRequestScenario; timeInterval: number; locations: Array; } @@ -530,24 +529,123 @@ 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 the amount of additional descriptive 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; } @@ -588,16 +686,74 @@ 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 GeoAddress + * @since 9 + */ isFromMock: Boolean; } @@ -639,14 +795,58 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export enum GeoLocationErrorCode { + /** + * Indicates function not supported. + * @since 7 + */ 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 position switch. + * @since 7 + */ LOCATION_SWITCH_ERROR, + + /** + * Indicates failed to get the last cache 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, } -- Gitee From 0b6b06a5c5c4e66f404f2bb437fca19466c80967 Mon Sep 17 00:00:00 2001 From: liu-binjun Date: Mon, 11 Jul 2022 22:04:33 +0800 Subject: [PATCH 3/3] bugfix:Correct spelling mistakes Signed-off-by: liu-binjun --- api/@ohos.geolocation.d.ts | 39 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index 56c14d6488..d8a755e11c 100644 --- a/api/@ohos.geolocation.d.ts +++ b/api/@ohos.geolocation.d.ts @@ -305,7 +305,7 @@ declare namespace geolocation { function sendCommand(command: LocationCommand) : Promise; /** - * Obtain the current country code. + * obtain the current country code. * * @since 9 * @syscap SystemCapability.Location.Location.Core @@ -321,19 +321,23 @@ declare namespace geolocation { * @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. + * @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; /** - * diable the geographical location simulation function. + * 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 whether the position simulation function is enabled. + * @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; @@ -345,7 +349,9 @@ declare namespace geolocation { * @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. + * @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; @@ -356,7 +362,9 @@ declare namespace geolocation { * @since 9 * @syscap SystemCapability.Location.Location.Core * @systemapi - * @param callback Indicates whether the reverse geocoding simulation function is enabled. + * @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; @@ -367,7 +375,9 @@ declare namespace geolocation { * @since 9 * @syscap SystemCapability.Location.Location.Core * @systemapi - * @param callback Indicates whether the reverse geocoding simulation function is enabled. + * @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; @@ -379,7 +389,10 @@ declare namespace geolocation { * @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. + * @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; @@ -631,7 +644,7 @@ declare namespace geolocation { addressUrl?: string; /** - * Indicates the amount of additional descriptive information. + * Indicates additional information. * @since 7 */ descriptions?: Array; @@ -751,7 +764,7 @@ declare namespace geolocation { additionSize?: number; /** - * Indicates whether it is an mock GeoAddress + * Indicates whether it is an mock location. * @since 9 */ isFromMock: Boolean; @@ -797,7 +810,7 @@ declare namespace geolocation { export enum GeoLocationErrorCode { /** * Indicates function not supported. - * @since 7 + * @since 9 */ NOT_SUPPORTED = 100, @@ -826,13 +839,13 @@ declare namespace geolocation { LOCATOR_ERROR, /** - * Indicates operation failure caused by abnormal position switch. + * Indicates operation failure caused by abnormal location switch. * @since 7 */ LOCATION_SWITCH_ERROR, /** - * Indicates failed to get the last cache location. + * Indicates failed to get the last known location. * @since 7 */ LAST_KNOWN_LOCATION_ERROR, -- Gitee