diff --git a/en/application-dev/reference/apis/js-apis-geolocation.md b/en/application-dev/reference/apis/js-apis-geolocation.md index d08cc7aafb9e16ecd89533e4a772c18372d23da5..f15805a326e19b0a579d1da1ae0e44e9937fef6f 100644 --- a/en/application-dev/reference/apis/js-apis-geolocation.md +++ b/en/application-dev/reference/apis/js-apis-geolocation.md @@ -24,7 +24,7 @@ Registers a listener for location changes with a location request initiated. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| | request | LocationRequest | Yes| Location request.| @@ -54,7 +54,7 @@ Unregisters the listener for location changes with the corresponding location re **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| | callback | Callback<[Location](#location)> | No| Callback used to return the location change event.| @@ -84,7 +84,7 @@ Registers a listener for location service status change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| | callback | Callback<boolean> | Yes| Callback used to return the location service status change event.| @@ -112,7 +112,7 @@ Unregisters the listener for location service status change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| | callback | Callback<boolean> | No| Callback used to return the location service status change event.| @@ -141,7 +141,7 @@ Registers a listener for cached GNSS location reports. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| | request | CachedGnssLocationsRequest | Yes| Request for reporting cached GNSS location.| @@ -171,7 +171,7 @@ Unregisters the listener for cached GNSS location reports. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| | callback | Callback<boolean> | No| Callback used to return cached GNSS locations.| @@ -201,7 +201,7 @@ Registers a listener for GNSS satellite status change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| | callback | Callback<SatelliteStatusInfo> | Yes| Callback used to return GNSS satellite status changes.| @@ -229,7 +229,7 @@ Unregisters the listener for GNSS satellite status change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| | callback | Callback<SatelliteStatusInfo> | No| Callback used to return GNSS satellite status changes.| @@ -257,7 +257,7 @@ Registers a listener for GNSS NMEA message change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| | callback | Callback<string> | Yes| Callback used to return GNSS NMEA message changes.| @@ -285,7 +285,7 @@ Unregisters the listener for GNSS NMEA message change events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| | callback | Callback<string> | No| Callback used to return GNSS NMEA message changes.| @@ -314,7 +314,7 @@ Registers a listener for status change events of the specified geofence. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| | request | GeofenceRequest | Yes| Geofencing request.| @@ -359,7 +359,7 @@ Unregisters the listener for status change events of the specified geofence. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| | request | GeofenceRequest | Yes| Geofencing request.| @@ -402,7 +402,7 @@ Subscribe to country code information reporting events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is "countrycodechange", which means subscribing to the submission of country code information. | | callback | Callback<CountryCode> | Yes | Callback is used to receive the country code information report. | @@ -428,7 +428,7 @@ Unsubscribe from the country code to report events. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is "countrycodechange", which means unsubscribing to the submission of country code information. | | callback | Callback<CountryCode> | Yes | Callback is used to receive the country code information report. | @@ -458,7 +458,7 @@ Obtains the current location. This API uses an asynchronous callback to return t **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.| | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the current location.| @@ -493,13 +493,13 @@ Obtains the current location. This API uses a promise to return the result. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<[Location](#location)> | Promise used to return the current location.| @@ -526,7 +526,7 @@ Obtains the previous location. This API uses an asynchronous callback to return **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the previous location.| @@ -557,7 +557,7 @@ Obtains the previous location. This API uses a promise to return the result. **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<[Location](#location)> | Promise used to return the previous location.| @@ -584,7 +584,7 @@ Checks whether the location service is enabled. This API uses an asynchronous ca **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| @@ -614,7 +614,7 @@ Checks whether the location service is enabled. This API uses a promise to retur **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| @@ -640,7 +640,7 @@ Requests to enable the location service. This API uses an asynchronous callback **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| @@ -670,7 +670,7 @@ Requests to enable the location service. This API uses a promise to return the r **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| @@ -697,7 +697,7 @@ Enables the location service. This API uses an asynchronous callback to return t **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| @@ -729,7 +729,7 @@ Enables the location service. This API uses a promise to return the result. **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| @@ -755,7 +755,7 @@ Disables the location service. This API uses an asynchronous callback to return **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| @@ -787,7 +787,7 @@ Disables the location service. This API uses a promise to return the result. **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| @@ -811,7 +811,7 @@ Checks whether the (reverse) geocoding service is available. This API uses an as **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the (reverse) geocoding service status.| @@ -841,7 +841,7 @@ Checks whether the (reverse) geocoding service is available. This API uses a pro **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the (reverse) geocoding service status.| @@ -866,7 +866,7 @@ Converts coordinates into geographic description through reverse geocoding. This **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.| | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to return the reverse geocoding result.| @@ -898,13 +898,13 @@ Converts coordinates into geographic description through reverse geocoding. This **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | Promise used to return the reverse geocoding result.| @@ -930,7 +930,7 @@ Converts geographic description into coordinates through geocoding. This API use **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.| | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to return the geocoding result.| @@ -962,13 +962,13 @@ Converts geographic description into coordinates through geocoding. This API use **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | Callback used to return the geocoding result.| @@ -994,7 +994,7 @@ Obtains the number of cached GNSS locations. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | Yes| Callback used to return the number of cached GNSS locations. | @@ -1024,7 +1024,7 @@ Obtains the number of cached GNSS locations. **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<number> | Promise used to return the number of cached GNSS locations.| @@ -1049,7 +1049,7 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result.| @@ -1079,7 +1079,7 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the operation result.| @@ -1104,7 +1104,7 @@ Sends an extended command to the location subsystem. This API can only be called **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | command | LocationCommand | Yes| Extended command (string) to be sent.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result.| @@ -1136,13 +1136,13 @@ Sends an extended command to the location subsystem. This API can only be called **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | command | LocationCommand | Yes| Extended command (string) to be sent.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the operation result.| @@ -1170,7 +1170,7 @@ Checks whether a user agrees with the privacy statement of the location service. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| @@ -1203,13 +1203,13 @@ Checks whether a user agrees with the privacy statement of the location service. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the result, which indicates whether the user agrees with the privacy statement.| @@ -1236,7 +1236,7 @@ Sets the user confirmation status for the privacy statement of the location serv **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| @@ -1270,14 +1270,14 @@ Sets the user confirmation status for the privacy statement of the location serv **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the operation result.| @@ -1300,7 +1300,7 @@ Query the current country code. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<CountryCode> | Yes | Callback is used to receive the country code. | @@ -1332,7 +1332,7 @@ None **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<CountryCode> | return country code. | @@ -1361,7 +1361,7 @@ Enable the position simulation function of a scene, and only one scene can be en **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | No | Indicates under what scenario the position simulation function is enabled. | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1392,14 +1392,14 @@ Enable the position simulation function of a scene, and only one scene can be en **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | No | Indicates which scene's position simulation function is enabled. If this parameter is not carried, it means that the position simulation function of all scenes is enabled. | **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1433,7 +1433,7 @@ To disable the position simulation function. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | No | Indicates to disable the position simulation function of a scene. If this parameter is not carried, it means to disable the position simulation function of all scenes. | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1465,13 +1465,13 @@ To disable the position simulation function. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | No | Indicates to disable the position simulation function of a scene. If this parameter is not carried, it means to disable the position simulation function of all scenes. | **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr, otherwise it will return an error message | @@ -1505,7 +1505,7 @@ Set the simulated location information, and then report the simulated location a **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | config | LocationMockConfig | Yes | Indicates the configuration parameters of location simulation, including the time interval of simulation location reporting and the array of simulation locations. | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1543,13 +1543,13 @@ Set the simulated location information, and then report the simulated location a **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | config | LocationMockConfig | Yes | Indicates the configuration parameters of location simulation, including the time interval of simulation location reporting and the array of simulation locations. | **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1591,7 +1591,7 @@ Enable reverse geocoding simulation function. **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1625,7 +1625,7 @@ None **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1658,7 +1658,7 @@ Disable reverse geocoding simulation function. **Parameters**: - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message | @@ -1692,7 +1692,7 @@ None **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1725,7 +1725,7 @@ Set the configuration information of the reverse geocoding simulation function, **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | mockInfos | Array<ReverseGeocodingMockInfo> | Yes | An array of configuration parameters indicating the inverse geocoding simulation function. The configuration parameters of the inverse geocoding simulation function include a location and a place name. | | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1734,11 +1734,11 @@ Set the configuration information of the reverse geocoding simulation function, ```js var mockInfos = [ - {"location": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, ]; geolocation.setReverseGeocodingMockInfo(mockInfos, (err, data) => { if (err) { @@ -1763,13 +1763,13 @@ Set the configuration information of the reverse geocoding simulation function, **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | mockInfos | Array<ReverseGeocodingMockInfo> | Yes | An array of configuration parameters indicating the inverse geocoding simulation function. The configuration parameters of the inverse geocoding simulation function include a location and a place name. | **Return value** - | Name| Description| + | Name| Description| | -------- | -------- | | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | @@ -1777,11 +1777,11 @@ Set the configuration information of the reverse geocoding simulation function, ```js var mockInfos = [ - {"location": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, ]; geolocation.setReverseGeocodingMockInfo(mockInfos) .then((result) => { diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index e3e3ed792be478083abb801f9cb62c151aa4f0f2..c5624597587250de137733ebd6d8ffb36bbccb48 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -200,7 +200,9 @@ - [@ohos.screenLock (锁屏管理)](js-apis-screen-lock.md) - [@ohos.systemTime (设置系统时间)](js-apis-system-time.md) - [@ohos.wallpaper (壁纸)](js-apis-wallpaper.md) + - [@ohos.systemTimer(设置系统时间)](js-apis-system-timer.md) - [Timer (定时器)](js-apis-timer.md) + - 设备管理 - [@ohos.batteryInfo (电量信息)](js-apis-battery-info.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index a3bd5bc6b452bb0f5565c05a0c888eb60a373b10..2243e9fd02bd700c8e91001293027337eec10e02 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -1912,7 +1912,7 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeI **示例:** ``` audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { - console.info('[GET_RENDERER_STATE_1_CALLBACK] **** Get Callback Called ****'); + console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); if (err) { console.log('getCurrentAudioRendererInfoArray :ERROR: '+ err.message); resultFlag = false; @@ -1960,7 +1960,7 @@ getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray> **示例:** ``` await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { - console.info('[GET_RENDERER_STATE_3_PROMISE] ######### Get Promise is called ##########'); + console.info('getCurrentAudioRendererInfoArray ######### Get Promise is called ##########'); if (AudioRendererChangeInfoArray != null) { for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; @@ -1985,7 +1985,6 @@ await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (Audi } }).catch((err) => { console.log('getCurrentAudioRendererInfoArray :ERROR: ' + err.message); - resultFlag = false; }); ``` @@ -2006,10 +2005,9 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeI **示例:** ``` audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info('[GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****'); + console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); if (err) { console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message); - resultFlag = false; } else { if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { @@ -2051,8 +2049,8 @@ getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray> **示例:** ``` -await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { - console.info('AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****'); +await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****'); if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); @@ -2075,7 +2073,6 @@ await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then( function (Au } }).catch((err) => { console.log('getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); - resultFlag = false; }); ``` @@ -2096,7 +2093,7 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr **示例:** ``` -audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { +audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; console.info('## RendererChange on is called for ' + i + ' ##'); @@ -2125,7 +2122,7 @@ audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) = off(type: "audioRendererChange"); -监听音频渲染器更改事件。 +取消监听音频渲染器更改事件。 **系统能力:** SystemCapability.Multimedia.Audio.Renderer @@ -2137,8 +2134,8 @@ off(type: "audioRendererChange"); **示例:** ``` -audioStreamManagerCB.off('audioRendererChange'); -console.info('[RENDERER-CHANGE-ON-001] ######### RendererChange Off is called #########'); +audioStreamManager.off('audioRendererChange'); +console.info('######### RendererChange Off is called #########'); ``` ### on('audioCapturerChange')9+ @@ -2184,7 +2181,7 @@ audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => off(type: "audioCapturerChange"); -监听音频捕获器更改事件。 +取消监听音频捕获器更改事件。 **系统能力:** SystemCapability.Multimedia.Audio.Capturer @@ -2197,7 +2194,7 @@ off(type: "audioCapturerChange"); **示例:** ``` audioStreamManager.off('audioCapturerChange'); -console.info('[GET_CAPTURER_STATE_2_PROMISE] ######### CapturerChange Off is called #########'); +console.info('######### CapturerChange Off is called #########'); ``` @@ -2228,8 +2225,8 @@ var AudioStreamInfo = { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var streamManagerCB = audioManager.getStreamManager(); -streamManagerCB.isAudioRendererLowLatencySupported(AudioStreamInfo, (result) => { +var audioStreamManager = audioManager.getStreamManager(); +audioStreamManager.isAudioRendererLowLatencySupported(AudioStreamInfo, (result) => { console.info('isAudioRendererLowLatencySupported success var = ' + result); }); ``` @@ -2266,8 +2263,8 @@ var AudioStreamInfo = { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var streamManager = await audioManager.getStreamManager(); -var result = streamManager.isAudioRendererLowLatencySupported(AudioStreamInfo); +var audioStreamManager = await audioManager.getStreamManager(); +var result = audioStreamManager.isAudioRendererLowLatencySupported(AudioStreamInfo); console.info('isAudioRendererLowLatencySupported success var =' + result); ``` @@ -2298,6 +2295,7 @@ import audio from '@ohos.multimedia.audio'; var audioStreamManager; var audioStreamManagerCB; var Tag = "AFCapLog : "; +var resultFlag = false; await audioManager.getStreamManager().then(async function (data) { audioStreamManager = data; @@ -2337,7 +2335,7 @@ audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) = } if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) { resultFlag = true; - console.info(Tag + '[RENDERER-CHANGE-ON-001] ResultFlag for '+ i +' is:'+ resultFlag); + console.info(Tag + 'ResultFlag for '+ i +' is:'+ resultFlag); } } }); @@ -2369,6 +2367,7 @@ import audio from '@ohos.multimedia.audio'; const audioManager = audio.getAudioManager(); var Tag = "AFCapLog : "; +var resultFlag = false; audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); @@ -2390,7 +2389,7 @@ audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => } if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { resultFlag = true; - console.info(Tag + '[CAPTURER-CHANGE-ON-001] ResultFlag for element ' + i + ' is: ' + resultFlag); + console.info(Tag + 'ResultFlag for element ' + i + ' is: ' + resultFlag); } } }); diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index 9a237033df49f7b5c50d0d7d4efee60588caa5b5..ac3e4d5e4c5da4f553e8979f5c972e7338a60308 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -21,7 +21,7 @@ import data_rdb from '@ohos.data.rdb'; getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void -获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以callback形式返回。 +获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -51,7 +51,7 @@ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> -获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以Promise形式返回。 +获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -85,7 +85,7 @@ promise.then(async (rdbStore) => { deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void -删除数据库,结果以callback形式返回。 +删除数据库,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -111,7 +111,7 @@ data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { deleteRdbStore(context: Context, name: string): Promise<void> -使用指定的数据库文件配置删除数据库,结果以Promise形式返回。 +使用指定的数据库文件配置删除数据库,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -953,7 +953,7 @@ predicates.notIn("NAME", ["Lisa", "Rose"]) insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void -向目标表中插入一行数据,结果以callback形式返回。 +向目标表中插入一行数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -972,12 +972,12 @@ const valueBucket = { "SALARY": 100.5, "CODES": new Uint8Array([1, 2, 3, 4, 5]), } -rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { - if (err) { - console.info("Insert failed, err: " + err) - return +rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) { + if (status) { + console.log("Insert is failed"); + return; } - console.log("Insert first done: " + ret) + console.log("Insert is successful, rowId = " + rowId); }) ``` @@ -986,7 +986,7 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { insert(table: string, values: ValuesBucket):Promise<number> -向目标表中插入一行数据,结果以Promise形式返回。 +向目标表中插入一行数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1010,19 +1010,113 @@ const valueBucket = { "CODES": new Uint8Array([1, 2, 3, 4, 5]), } let promise = rdbStore.insert("EMPLOYEE", valueBucket) -promise.then(async (ret) => { - console.log("Insert first done: " + ret) -}).catch((err) => { - console.log("Insert failed, err: " + err) +promise.then((rowId) => { + console.log("Insert is successful, rowId = " + rowId); +}).catch((status) => { + console.log("Insert is failed"); }) ``` +### batchInsert9+ + +batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>):void + +向目标表中插入一组数据,使用callback异步回调。 + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| table | string | 是 | 指定的目标表名。 | +| values | Array<[ValuesBucket](#valuesbucket)> | 是 | 表示要插入到表中的一组数据。 | +| callback | AsyncCallback<number> | 是 | 指定callback回调函数。如果操作成功,返回插入的数据个数,否则返回-1。 | + +**示例:** +```js +const valueBucket1 = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]) +} +const valueBucket2 = { + "NAME": "Jack", + "AGE": 19, + "SALARY": 101.5, + "CODES": new Uint8Array([6, 7, 8, 9, 10]) +} +const valueBucket3 = { + "NAME": "Tom", + "AGE": 20, + "SALARY": 102.5, + "CODES": new Uint8Array([11, 12, 13, 14, 15]) +} + +var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); +rdbStore.batchInsert("EMPLOYEE", valueBuckets, function(status, insertNum) { + if (status) { + console.log("bathInsert is failed, status = " + status); + return; + } + console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); +}) +``` + +### batchInsert9+ + +batchInsert(table: string, values: Array<ValuesBucket>):Promise<number> + +向目标表中插入一组数据,使用Promise异步回调。 + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| table | string | 是 | 指定的目标表名。 | +| values | Array<[ValuesBucket](#valuesbucket)> | 是 | 表示要插入到表中的一组数据。 | + +**返回值**: +| 类型 | 说明 | +| -------- | -------- | +| Promise<number> | 指定Promise回调函数。如果操作成功,返回插入的数据个数,否则返回-1。 | + +**示例:** +```js +const valueBucket1 = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]) +} +const valueBucket2 = { + "NAME": "Jack", + "AGE": 19, + "SALARY": 101.5, + "CODES": new Uint8Array([6, 7, 8, 9, 10]) +} +const valueBucket3 = { + "NAME": "Tom", + "AGE": 20, + "SALARY": 102.5, + "CODES": new Uint8Array([11, 12, 13, 14, 15]) +} + +var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); +let promise = rdbStore.batchInsert("EMPLOYEE", valueBuckets); +promise.then((insertNum) => { + console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); +}).catch((status) => { + console.log("bathInsert is failed, status = " + status); +}) +``` ### update update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void -根据RdbPredicates的指定实例对象更新数据库中的数据,结果以callback形式返回。 +根据RdbPredicates的指定实例对象更新数据库中的数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1057,7 +1151,7 @@ rdbStore.update(valueBucket, predicates, function (err, ret) { update(values: ValuesBucket, predicates: RdbPredicates):Promise<number> -根据RdbPredicates的指定实例对象更新数据库中的数据,结果以Promise形式返回。 +根据RdbPredicates的指定实例对象更新数据库中的数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1093,7 +1187,7 @@ promise.then(async (ret) => { ### update9+ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void -根据DataSharePredicates的指定实例对象更新数据库中的数据,结果以callback形式返回。 +根据DataSharePredicates的指定实例对象更新数据库中的数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1128,7 +1222,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> -根据DataSharePredicates的指定实例对象更新数据库中的数据,结果以Promise形式返回。 +根据DataSharePredicates的指定实例对象更新数据库中的数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1168,7 +1262,7 @@ promise.then(async (ret) => { delete(predicates: RdbPredicates, callback: AsyncCallback<number>):void -根据RdbPredicates的指定实例对象从数据库中删除数据,结果以callback形式返回。 +根据RdbPredicates的指定实例对象从数据库中删除数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1196,7 +1290,7 @@ rdbStore.delete(predicates, function (err, rows) { delete(predicates: RdbPredicates):Promise<number> -根据RdbPredicates的指定实例对象从数据库中删除数据,结果以Promise形式返回。 +根据RdbPredicates的指定实例对象从数据库中删除数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1227,7 +1321,7 @@ promise.then((rows) => { delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void -根据DataSharePredicates的指定实例对象从数据库中删除数据,结果以callback形式返回。 +根据DataSharePredicates的指定实例对象从数据库中删除数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1255,7 +1349,7 @@ rdbStore.delete("EMPLOYEE", predicates, function (err, rows) { delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise<number> -根据DataSharePredicates的指定实例对象从数据库中删除数据,结果以Promise形式返回。 +根据DataSharePredicates的指定实例对象从数据库中删除数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1287,7 +1381,7 @@ promise.then((rows) => { query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void -根据指定条件查询数据库中的数据,结果以callback形式返回。 +根据指定条件查询数据库中的数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1317,7 +1411,7 @@ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (e query(predicates: RdbPredicates, columns?: Array<string>):Promise<ResultSet> -根据指定条件查询数据库中的数据,结果以Promise形式返回。 +根据指定条件查询数据库中的数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1349,7 +1443,7 @@ query(predicates: RdbPredicates, columns?: Array<string>):Promise<Resul query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void -根据指定条件查询数据库中的数据,结果以callback形式返回。 +根据指定条件查询数据库中的数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1380,7 +1474,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> -根据指定条件查询数据库中的数据,结果以Promise形式返回。 +根据指定条件查询数据库中的数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1414,7 +1508,7 @@ promise.then((resultSet) => { querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void -根据指定SQL语句查询数据库中的数据,结果以callback形式返回。 +根据指定SQL语句查询数据库中的数据,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1442,7 +1536,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> -根据指定SQL语句查询数据库中的数据,结果以Promise形式返回。 +根据指定SQL语句查询数据库中的数据,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1473,7 +1567,7 @@ promise.then((resultSet) => { executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>):void -执行包含指定参数但不返回值的SQL语句,结果以callback形式返回。 +执行包含指定参数但不返回值的SQL语句,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1501,7 +1595,7 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void> -执行包含指定参数但不返回值的SQL语句,结果以Promise形式返回。 +执行包含指定参数但不返回值的SQL语句,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1620,7 +1714,7 @@ try { backup(destName:string, callback: AsyncCallback<void>):void -以指定名称备份数据库,结果以callback形式返回。 +以指定名称备份数据库,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1645,7 +1739,7 @@ rdbStore.backup("dbBackup.db", function(err) { backup(destName:string): Promise<void> -以指定名称备份数据库,结果以promise形式返回。 +以指定名称备份数据库,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1673,7 +1767,7 @@ promiseBackup.then(()=>{ restore(srcName:string, callback: AsyncCallback<void>):void -从指定的数据库备份文件恢复数据库,结果以callback形式返回。 +从指定的数据库备份文件恢复数据库,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1698,7 +1792,7 @@ rdbStore.restore("dbBackup.db", function(err) { restore(srcName:string): Promise<void> -从指定的数据库备份文件恢复数据库,结果以promise形式返回。 +从指定的数据库备份文件恢复数据库,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1726,7 +1820,7 @@ promiseRestore.then(()=>{ setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void -设置分布式列表,结果以callback形式返回。 +设置分布式列表,使用callback异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1754,7 +1848,7 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { setDistributedTables(tables: Array<string>): Promise<void> -设置分布式列表,结果以Promise形式返回。 +设置分布式列表,使用Promise异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1784,7 +1878,7 @@ promise.then(() => { obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 结果以callback形式返回。 +根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 使用callback异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1813,7 +1907,7 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, obtainDistributedTableName(device: string, table: string): Promise<string> -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,结果以Promise形式返回。 +根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,使用Promise异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1844,7 +1938,7 @@ promise.then((tableName) => { sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void -在设备之间同步数据, 结果以callback形式返回。 +在设备之间同步数据, 使用callback异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1878,7 +1972,7 @@ rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, resul sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>> -在设备之间同步数据,结果以Promise形式返回。 +在设备之间同步数据,使用Promise异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1947,7 +2041,7 @@ try { off(event:'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void -从数据库中删除指定类型的指定观察者, 结果以callback形式返回。 +从数据库中删除指定类型的指定观察者, 使用callback异步回调。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index cac1ec40cf6d581f7f19f1f2774cca54021fbfe7..21a164bd5006b04eb34b932d543a8deed0419420 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -9,7 +9,7 @@ - 认证和取消认证设备 - 查询可信设备列表 - 查询本地设备信息,包括设备名称,设备类型和设备标识 - +- 发布设备发现 > **说明:** > > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -61,7 +61,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | deviceName | string | 是 | 设备名称。 | | deviceType | [DeviceType](#devicetype) | 是 | 设备类型。 | | networkId8+ | string | 是 | 设备网络标识。 | - +| range9+ | number | 是 | 发现设备的距离。 | ## DeviceType @@ -184,6 +184,18 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | token | number | 是 | 认证Token。 | | extraInfo | {[key:string] : any} | 否 | 认证信息可扩展字段。 | +## PublishInfo + +发布设备参数 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + +| 名称 | 类型 | 必填 | 描述 | +| ------------- | --------------------------------- | ---- | ----------------- | +| publishId | number | 是 | 发布设备标识,用于标识不同的发布周期。 | +| mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 | +| freq | [ExchangeFreq](#exchangefreq) | 是 | 发现频率。 | +| ranging | boolean | 是 | 发布的设备是否支持测距能力。 | ## DeviceManager @@ -359,6 +371,45 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void dmInstance.startDeviceDiscovery(subscribeInfo); //当有设备发现时,通过deviceFound回调通知给应用程序 ``` +### startDeviceDiscovery9+ + +startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions: string): void + +发现周边设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | ------------- | ------------------------------- | ---- | ----- | + | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 | + | filterOptions | [string](#filteroptions) | 否 | 发现设备过滤信息。| + +- 示例: + ```js + //生成发现标识,随机数确保每次调用发现接口的标识不一致 + var subscribeId = Math.floor(Math.random() * 10000 + 1000); + var subscribeInfo = { + "subscribeId": subscribeId, + "mode": 0xAA, //主动模式 + "medium": 0, //自动发现类型,同时支持多种发现类型 + "freq": 2, //高频率 + "isSameAccount": false, + "isWakeRemote": false, + "capability": 1 + }; + var filterOptions = { + "filter_op": "OR", // 可选, 默认"OR" + "filters": [ + { + "type": "range", + "value": 50 // 需过滤发现设备的距离,单位(cm) + } + ] +}; + dmInstance.startDeviceDiscovery(subscribeInfo, JSON.stringify(filterOptions)); //当有设备发现时,通过deviceFound回调通知给应用程序 + ``` + ### stopDeviceDiscovery stopDeviceDiscovery(subscribeId: number): void @@ -378,6 +429,51 @@ stopDeviceDiscovery(subscribeId: number): void dmInstance.stopDeviceDiscovery(subscribeId); ``` +### publishDeviceDiscovery9+ + +publishDeviceDiscovery(publishInfo: PublishInfo): void + +发现设备发现。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | ------------- | ------------------------------- | ---- | ----- | + | publishInfo | [PublishInfo](#publishinfo) | 是 | 发布设备发现信息。 | + +- 示例: + ```js + //生成发布标识,随机数确保每次调用发现接口的标识不一致 + var publishId = Math.floor(Math.random() * 10000 + 1000); + var publishInfo = { + "publishId": publishId, + "mode": 0xAA, //主动模式 + "freq": 2, //高频率 + "ranging": 1 //支持发现时测距 + }; + dmInstance.publishDeviceDiscovery(publishInfo); //当有发布结果时,通过回调通知给应用程序 + ``` + +### unPublishDeviceDiscovery + +unPublishDeviceDiscovery(publishId: number): void + +停止发布设备发现。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | ----------- | -------- | ---- | ----- | + | publishId | number | 是 | 发布标识。 | + +- 示例: + ```js + //入参需要和publishDeviceDiscovery接口传入的publishId配对使用 + dmInstance.unPublishDeviceDiscovery(publishId); + ``` + ### authenticateDevice authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void @@ -599,6 +695,93 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: ); ``` +### on('publishSuccess') + +on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void + +注册发布设备发现回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | -------------------------- | + | type | string | 是 | 注册发布设备发现回调,以便将发布结果时通知应用程序。 | + | callback | Callback<{ publishId: number }> | 是 | 注册设备发布的回调方法。 | + +- 示例: + ```js + dmInstance.on('publishSuccess', (data) => { + console.info("publishSuccess:" + JSON.stringify(data)); + } + ); + ``` + +### off('publishSuccess') + +off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void + +取消注册设备发现回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | 是 | 取消注册设备发现回调。 | + | callback | Callback<{ publishId: number }> | 是 | 指示要取消注册的设备发布回调。 | + +- 示例: + ```js + dmInstance.off('publishSuccess', (data) => { + console.info('publishSuccess' + JSON.stringify(data)); + } + ); + ``` + +### on('publishFail') + +on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void + +注册设备发布失败回调监听。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | ----------------------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 注册设备发布失败回调,以便在发布设备失败时通知应用程序。 | + | callback | Callback<{ publishId: number, reason: number }> | 是 | 注册设备发布失败的回调方法。 | + +- 示例: + ```js + dmInstance.on('publishFail', (data) => { + this.log("publishFail on:" + JSON.stringify(data)); + } + ); + ``` + +### off('publishFail') + +off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void + +取消注册设备发现失败回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- 参数: + | 名称 | 参数类型 | 必填 | 说明 | + | -------- | ----------------------------------------------------- | ---- | ----------------- | + | type | string | 是 | 取消注册设备发布失败回调。 | + | callback | Callback<{ publishId: number, reason: number }> | 是 | 指示要取消注册的设备发布失败回调。 | + +- 示例: + ```js + dmInstance.off('publishFail', (data) => { + console.info('publishFail' + JSON.stringify(data)); + } + ); + ``` ### on('serviceDie') diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index a0512d075e978281605477d13f402967fcb043b3..22e041d0a45217c562d4c421d82b9a721f0cfcce 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -174,6 +174,42 @@ getAllDisplay(): Promise<Array<Display>> }); ``` +## display.hasPrivateWindow9+ + +hasPrivateWindow(displayId: number): boolean + +查询指定display对象上是否有可见的隐私窗口。可通过[setPrivacyMode](js-apis-window.md#setprivacymode7)接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。 + +此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- |----------| +| id | number | 是 | 显示设备的id。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- |-----------------------------------------------------------------------| +|boolean | 查询的display对象上是否有可见的隐私窗口。
true表示此display对象上有可见的隐私窗口,false表示此display对象上没有可见的隐私窗口。
| + +**示例:** + + ```js + var ret = display.hasPrivateWindow(displayClass.id); + if (ret == undefined) { + console.log("HasPrivateWindow undefined."); + } + if (ret) { + console.log("HasPrivateWindow."); + } else if (!ret) { + console.log("Don't HasPrivateWindow."); + } + ``` + ## display.on('add'|'remove'|'change') on(type: 'add'|'remove'|'change', callback: Callback<number>): void @@ -215,3 +251,4 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void ```js display.off("remove"); ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index af1e4a30179d3e012aabc248ccd460f15894b34a..3cd5bb1b94919b8e48c4b2c8b215254963bd05aa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -22,13 +22,14 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat **系统能力**:SystemCapability.Location.Location.Core -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationChange”,表示位置变化。 | | request | LocationRequest | 是 | 设置位置请求参数。 | | callback | Callback<[Location](#location)> | 是 | 接收位置变化状态变化监听。 | + **示例** @@ -52,9 +53,9 @@ off(type: 'locationChange', callback?: Callback<Location>) : void **系统能力**:SystemCapability.Location.Location.Core -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationChange”,表示位置变化。 | | callback | Callback<[Location](#location)> | 否 | 接收位置变化状态变化监听。 | @@ -82,9 +83,9 @@ on(type: 'locationServiceState', callback: Callback<boolean>) : void **系统能力**:SystemCapability.Location.Location.Core -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationServiceState”,表示位置服务状态。 | | callback | Callback<boolean> | 是 | 接收位置服务状态变化监听。 | @@ -112,7 +113,7 @@ off(type: 'locationServiceState', callback?: Callback<boolean>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationServiceState”,表示位置服务状态。 | | callback | Callback<boolean> | 否 | 接收位置服务状态变化监听。 | @@ -141,7 +142,7 @@ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, ca **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsReporting”,表示GNSS缓存定位结果上报。 | | request | CachedGnssLocationsRequest | 是 | GNSS缓存功能配置参数 | @@ -171,7 +172,7 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsReporting”,表示GNSS缓存定位结果上报。 | | callback | Callback<boolean> | 否 | 接收GNSS缓存位置上报。 | @@ -201,7 +202,7 @@ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : vo **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“gnssStatusChange”,表示订阅GNSS卫星状态信息上报。 | | callback | Callback<SatelliteStatusInfo> | 是 | 接收GNSS卫星状态信息上报。 | @@ -229,7 +230,7 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“gnssStatusChange”,表示订阅GNSS卫星状态信息上报。 | | callback | Callback<SatelliteStatusInfo> | 否 | 接收GNSS卫星状态信息上报。 | @@ -257,7 +258,7 @@ on(type: 'nmeaMessageChange', callback: Callback<string>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“nmeaMessageChange”,表示订阅GNSS NMEA信息上报。 | | callback | Callback<string> | 是 | 接收GNSS NMEA信息上报。 | @@ -285,7 +286,7 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“nmeaMessageChange”,表示订阅GNSS NMEA信息上报。 | | callback | Callback<string> | 否 | 接收GNSS NMEA信息上报。 | @@ -314,7 +315,7 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“fenceStatusChange”,表示订阅围栏事件上报。 | | request | GeofenceRequest | 是 | 围栏的配置参数。 | @@ -359,7 +360,7 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“fenceStatusChange”,表示订阅围栏事件上报。 | | request | GeofenceRequest | 是 | 围栏的配置参数。 | @@ -402,7 +403,7 @@ on(type: 'countryCodeChange', callback: Callback<CountryCode>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示订阅国家码信息上报。 | | callback | Callback<CountryCode> | 是 | 接收国家码信息上报。 | @@ -428,7 +429,7 @@ off(type: 'countryCodeChange', callback?: Callback<CountryCode>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示取消订阅国家码信息上报。 | | callback | Callback<CountryCode> | 是 | 接收国家码信息上报。 | @@ -458,7 +459,7 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | 否 | 设置位置请求参数。 | | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收位置信息的回调。 | @@ -493,13 +494,13 @@ getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | 否 | 设置位置请求参数。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<[Location](#location)> | 返回位置信息。 | @@ -526,7 +527,7 @@ getLastLocation(callback: AsyncCallback<Location>) : void **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收上次位置的回调。 | @@ -557,7 +558,7 @@ getLastLocation() : Promise<Location> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<[Location](#location)> | 返回上次位置信息。 | @@ -584,7 +585,7 @@ isLocationEnabled(callback: AsyncCallback<boolean>) : void **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | @@ -614,7 +615,7 @@ isLocationEnabled() : Promise<boolean> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 返回位置服务是否可用的状态。 | @@ -640,7 +641,7 @@ requestEnableLocation(callback: AsyncCallback<boolean>) : void **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | @@ -670,7 +671,7 @@ requestEnableLocation() : Promise<boolean> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 返回位置服务是否可用。 | @@ -697,7 +698,7 @@ enableLocation(callback: AsyncCallback<boolean>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | @@ -729,7 +730,7 @@ enableLocation() : Promise<boolean> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 返回位置服务是否可用。 | @@ -755,7 +756,7 @@ disableLocation(callback: AsyncCallback<boolean>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | @@ -787,7 +788,7 @@ disableLocation() : Promise<boolean> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 返回位置服务是否可用。 | @@ -811,7 +812,7 @@ isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收地理编码服务状态的回调。 | @@ -841,7 +842,7 @@ isGeoServiceAvailable() : Promise<boolean> **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 返回地理编码服务是否可用的状态。 | @@ -866,7 +867,7 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地理编码请求的相关参数。 | | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收逆地理编码请求的回调参数。 | @@ -898,13 +899,13 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<G **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地理编码请求的相关参数。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | 返回地理描述信息。 | @@ -930,7 +931,7 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地理编码请求的相关参数。 | | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收地理编码请求的回调参数。 | @@ -962,13 +963,13 @@ getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoA **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地理编码请求的相关参数。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | 设置接收地理编码请求的回调参数。 | @@ -994,7 +995,7 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | 是 | 用来接收GNSS芯片缓存位置个数的回调。 | @@ -1024,7 +1025,7 @@ getCachedGnssLocationsSize() : Promise<number>; **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<number> | 返回GNSS缓存位置的个数。 | @@ -1049,7 +1050,7 @@ flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用来接收清空GNSS芯片缓存位置操作的结果。 | @@ -1079,7 +1080,7 @@ flushCachedGnssLocations() : Promise<boolean>; **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 清空所有GNSS缓存位置是否成功。 | @@ -1104,7 +1105,7 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | command | LocationCommand | 是 | 指定目标场景,和将要发送的命令(字符串)。 | | callback | AsyncCallback<boolean> | 是 | 用来接收命令发送的结果。 | @@ -1136,13 +1137,13 @@ sendCommand(command: LocationCommand) : Promise<boolean>; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | command | LocationCommand | 是 | 指定目标场景,和将要发送的命令(字符串)。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 表示命令发送成功或失败。 | @@ -1170,7 +1171,7 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&l **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | | callback | AsyncCallback<boolean> | 是 | 表示用户是否同意定位服务隐私申明。 | @@ -1203,13 +1204,13 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean> **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 表示用户是否同意定位服务隐私申明。 | @@ -1236,7 +1237,7 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | | isConfirmed | boolean | 是 | 表示用户是否同意定位服务隐私申明。 | @@ -1270,14 +1271,14 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | | isConfirmed | boolean | 是 | 表示用户是否同意定位服务隐私申明。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<boolean> | 表示操作是否成功。 | @@ -1300,7 +1301,7 @@ getCountryCode(callback: AsyncCallback<CountryCode>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<CountryCode> | 是 | 用来接收国家码。 | @@ -1332,7 +1333,7 @@ getCountryCode() : Promise<CountryCode>; **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<CountryCode> | 返回国家码。 | @@ -1361,7 +1362,7 @@ enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback&l **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | 否 | 指示在什么场景下使能位置模拟功能。 | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1392,14 +1393,14 @@ enableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | 否 | 指示使能什么场景的位置模拟功能。如果不携带该参数则表示使能所有场景的位置模拟功能。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1433,7 +1434,7 @@ disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback& **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | 否 | 指示去使能某个场景的位置模拟功能。如果不携带该参数则表示去使能所有场景的位置模拟功能。 | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1465,13 +1466,13 @@ disableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | scenario | LocationRequestScenario | 否 | 指示去使能某个场景的位置模拟功能。如果不携带该参数则表示去使能所有场景的位置模拟功能。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1505,7 +1506,7 @@ setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void&g **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | LocationMockConfig | 是 | 指示位置模拟的配置参数,包含模拟位置上报的时间间隔和模拟位置数组。 | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1543,13 +1544,13 @@ setMockedLocations(config: LocationMockConfig) : Promise<void>; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | LocationMockConfig | 是 | 指示位置模拟的配置参数,包含模拟位置上报的时间间隔和模拟位置数组。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1591,7 +1592,7 @@ enableReverseGeocodingMock(callback: AsyncCallback<void>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1625,7 +1626,7 @@ enableReverseGeocodingMock() : Promise<void>; **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1658,7 +1659,7 @@ disableReverseGeocodingMock(callback: AsyncCallback<void>) : void; **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1692,7 +1693,7 @@ disableReverseGeocodingMock() : Promise<void>; **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1725,7 +1726,7 @@ setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, ca **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | mockInfos | Array<ReverseGeocodingMockInfo> | 是 | 指示逆地理编码模拟功能的配置参数数组。逆地理编码模拟功能的配置参数包含了一个位置和一个地名。 | | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1734,11 +1735,11 @@ setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, ca ```js var mockInfos = [ - {"location": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, ]; geolocation.setReverseGeocodingMockInfo(mockInfos, (err, data) => { if (err) { @@ -1763,13 +1764,13 @@ setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>) : **参数**: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | mockInfos | Array<ReverseGeocodingMockInfo> | 是 | 指示逆地理编码模拟功能的配置信息数组。逆地理编码模拟功能的配置信息包含了一个位置和一个地名。 | **返回值**: - | 参数名 | 说明 | + | 参数名 | 说明 | | -------- | -------- | | Promise<void> | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | @@ -1777,11 +1778,11 @@ setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>) : ```js var mockInfos = [ - {"location": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "shanghai", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "beijing", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "shenzhen", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "wuhan", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "chengdu", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, ]; geolocation.setReverseGeocodingMockInfo(mockInfos) .then((result) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 99a973e7cbb6bc7e04286dcad8417c8e4acdbb22..4c0a3d2cac9d0341f4edc8d77bc0a3cdd9fc1627 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -276,7 +276,7 @@ Codec MIME类型枚举。 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | 是 | 是 | 音频媒体URI,支持当前主流的视频格式(m4a、aac、mp3、ogg、wav)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.READ_MEDIA;如果需要使用网络素材,还需要申请ohos.permission.INTERNET。 | +| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(m4a、aac、mp3、ogg、wav)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.READ_MEDIA;如果需要使用网络素材,还需要申请ohos.permission.INTERNET。 | | fdSrc9+ | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 音频媒体文件描述,使用场景:应用中的音频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
音乐1(地址偏移:0,字节长度:100)
音乐2(地址偏移:101,字节长度:50)
音乐3(地址偏移:151,字节长度:150)
1. 播放音乐1:AVFileDescriptor { fd = 资源句柄; offset = 0; lengt = 100; }
2. 播放音乐2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放音乐3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的音乐文件: 请使用src=fd://xx
**注意事项**:
**需要权限:** ohos.permission.READ_MEDIA | | loop | boolean | 是 | 是 | 音频循环播放属性,设置为'true'表示循环播放。 | | audioInterruptMode9+ | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | @@ -651,7 +651,7 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 | 名称 | 类型 | 描述 | | ------------------ | ------ | ---------------------------------------------- | -| idle | string | 音频播放空闲,dateload/reset成功后处于此状态。 | +| idle | string | 音频播放空闲,dataload/reset成功后处于此状态。 | | playing | string | 音频正在播放,play成功后处于此状态。 | | paused | string | 音频暂停播放,pause成功后处于此状态。 | | stopped | string | 音频播放停止,stop/播放结束后处于此状态。 | @@ -695,7 +695,7 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | | url8+ | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.READ_MEDIA;如果需要使用网络素材,还需要申请ohos.permission.INTERNET。 | -| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 音频媒体文件描述,使用场景:应用中的音频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
音乐1(地址偏移:0,字节长度:100)
音乐2(地址偏移:101,字节长度:50)
音乐3(地址偏移:151,字节长度:150)
1. 播放音乐1:AVFileDescriptor { fd = 资源句柄; offset = 0; lengt = 100; }
2. 播放音乐2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放音乐3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的音乐文件: 请使用src=fd://xx
**注意事项**:
**需要权限:** ohos.permission.READ_MEDIA | +| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 视频媒体文件描述,使用场景:应用中的视频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
视频1(地址偏移:0,字节长度:100)
视频2(地址偏移:101,字节长度:50)
视频3(地址偏移:151,字节长度:150)
1. 播放视频1:AVFileDescriptor { fd = 资源句柄; offset = 0; lengt = 100; }
2. 播放视频2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放视频3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的视频文件: 请使用src=fd://xx
**注意事项**:
**需要权限:** ohos.permission.READ_MEDIA | | loop8+ | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。 | | videoScaleType9+ | [VideoScaleType](#videoscaletype9) | 是 | 是 | 视频缩放模式。 | | audioInterruptMode9+ | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | @@ -1537,7 +1537,7 @@ videoPlayer.on('error', (error) => { // 设置'error'事件回调 console.info(`video error called, errCode is ${error.code}`); // 打印错误码 console.info(`video error called, errMessage is ${error.message}`);// 打印错误类型详细描述 }); -videoPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 +videoPlayer.url = 'fd://error'; //设置错误的播放地址,触发'error'事件 ``` ### on('availableBitratesCollect')9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index c0663bf4f58c0c68ec1ed140a0092f0350cf5316..dfc5e94bbb4043fdd0d79e40a10fe4d9cf3d8651 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -257,17 +257,12 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Pr **示例:** ``` -async function example() { - // 使用Promise方式创建Image类型文件 - let mediaType = mediaLibrary.MediaType.IMAGE; - let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; - const path = await media.getPublicDirectory(DIR_IMAGE); - media.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { - console.info("createAsset successfully:"+ JSON.stringify(asset)); - }).catch(function(err){ - console.info("createAsset failed with error:"+ err); - }); -} +let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; +media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){ + console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult)); +}).catch(function(err){ + console.info("getPublicDirectory failed with error:"+ err); +}); ``` ### getPublicDirectory8+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index 40e5f6498283fd9625f251508de80b7e2b0d8faa..47ced8209ebc0e4508c4f56535041cc9d3004baa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -3,8 +3,8 @@ 本模块主要由时间、时区和定时三大功能组成。其中,定时服务用来管理和使用时间、时区。开发者可以通过对系统进行设置、获取等操作管理系统时间、时区,也可以通过定时功能实现定时服务如闹钟服务等。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - +>- 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +>- 本模块接口为系统接口,三方应用不支持调用。 ## 导入模块 @@ -22,7 +22,7 @@ setTime(time : number, callback : AsyncCallback<void>) : void **需要权限:** ohos.permission.SET_TIME -**系统能力:** SystemCapability.Miscservices.Time +**系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -201,7 +201,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> ## systemTime.getRealTime8+ -getRealTime(callback: AsyncCallback<number>): void +getRealTime(isNano?: boolean, callback: AsyncCallback<number>): void 获取自系统启动以来经过的时间,包括深度睡眠时间,使用callback形式返回结果。 @@ -229,7 +229,7 @@ getRealTime(callback: AsyncCallback<number>): void ## systemTime.getRealTime8+ -getRealTime(): Promise<number> +getRealTime(isNano?: boolean): Promise<number> 获取自系统启动以来经过的时间,包括深度睡眠时间,使用Promise形式返回结果。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md new file mode 100644 index 0000000000000000000000000000000000000000..6f16a4b45aa4c92ac1e5a3d3b617ccfa0def1799 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md @@ -0,0 +1,287 @@ +# 设置系统时间 + +本模块主要由时间、时区和定时三大功能组成。其中,定时服务用来管理和使用时间、时区。开发者可以通过对系统进行设置、获取等操作管理系统时间、时区,也可以通过定时功能实现定时服务如闹钟服务等。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +>- 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +>- 本模块接口为系统接口,三方应用不支持调用。 + +## 导入模块 + + +``` +import systemTimer from '@ohos.systemTimer'; +``` + + +## systemTime.createTimer + +createTimer(options: TimerOptions, callback: AsyncCallback<number>): void + +创建定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------| ---- | --------------------------------------------------------------------------------------- | +| options | TimerOptions | 是 | const TIMER_TYPE_REALTIME: 设置为系统启动时间定时器,否则为walltime定时器;
const TIMER_TYPE_WAKEUP: 设置为唤醒定时器,否则为非唤醒;
const TIMER_TYPE_EXACT: 设置为精准定时器,否则为非精准定时器;
const TIMER_TYPE_IDLE: number: 设置为IDLE模式定时器,否则为非IDLE模式定时器(暂不支持) | +| repeat | boolean | 是 | true 为循环定时器,false为单次定时器。 | +| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 | +| wantAgent| wantAgent | 否 | 设置通知的wantagent,定时器到期后通知。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------------------------------------------------ | +| syncCallback<number>| 以回调函数的形式返回定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + systemTime.createTimer(options, (error, data) => { + if (error) { + console.error(`failed to systemTime.createTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.createTimer + +createTimer(options: TimerOptions): Promise<number> + +创建定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------| ---- | --------------------------------------------------------------------------------------- | +| options | TimerOptions | 是 | const TIMER_TYPE_REALTIME: 设置为系统启动时间定时器,否则为walltime定时器;
const TIMER_TYPE_WAKEUP: 设置为唤醒定时器,否则为非唤醒;
const TIMER_TYPE_EXACT: 设置为精准定时器,否则为非精准定时器;
const TIMER_TYPE_IDLE: number: 设置为IDLE模式定时器,否则为非IDLE模式定时器(暂不支持) | +| repeat | boolean | 是 | true 为循环定时器,false为单次定时器。 | +| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 | +| wantAgent| wantAgent | 否 | 设置通知的wantagent,定时器到期后通知。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------------------------------------------ | +| Promise<number> | 以Promise形式返回定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + systemTime.createTimer(options).then((data) => { + console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.createTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.startTimer + +startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void>): void + +开始定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | +| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | + + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + systemTime.startTimer(timerId, 10000, (error, data) => { + if (error) { + console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + }); + ``` + +## systemTime.startTimer + +startTimer(timer: number, triggerTime: number): Promise<void> + +开始定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 +| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | + + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + systemTime.startTimer(timerId, 10000).then((data) => { + console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.stopTimer + +stopTimer(timer: number, callback: AsyncCallback<void>): void + +停止定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + systemTime.stopTimer(timerId, (error, data) => { + if (error) { + console.error(`failed to systemTime.stopTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.stopTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.stopTimer + +stopTimer(timer: number): Promise<void> + +停止定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + systemTime.stopTimer(timerId).then((data) => { + console.log(`systemTime.stopTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.stopTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.destroyTimer + +destroyTimer(timer: number, callback: AsyncCallback<void>): void + +销毁定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + let stopTimerRes = systemTimer.stopTimer(timerId) + systemTime.destroyTimer(timerId, (error, data) => { + if (error) { + console.error(`failed to systemTime.destroyTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.destroyTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.destroyTimer + +destroyTimer(timer: number): Promise<void> + +销毁定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + let stopTimerRes = systemTimer.stopTimer(timerId) + systemTime.destroyTimer(timerId).then((data) => { + console.log(`systemTime.destroyTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.destroyTimer because ` + JSON.stringify(error)); + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 987b7e92d511026fa4af7392eed989a40748107d..afe53ef7b86fe284054c7855ace5aa2619cb003e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -2724,7 +2724,7 @@ promise.then((data)=> { setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -设置窗口是否为隐私模式,使用callback异步回调。 +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2753,7 +2753,7 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { setPrivacyMode(isPrivacyMode: boolean): Promise<void> -设置窗口是否为隐私模式,使用Promise异步回调。 +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2781,6 +2781,25 @@ promise.then((data)=> { }); ``` +### setSnapshotSkip9+ +setSnapshotSkip(isSkip: boolean): void + +截屏录屏是否忽略当前窗口。 + +此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| +```js +var isSkip = true; +windowClass.setSnapshotSkip(isSkip); +``` + ### setTouchable7+ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index cf096c29978b1941bc14cbbc7441be311b18d01e..30d39ae55f5ec9ab7cb6d5d8ae142e971ad07862 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -819,6 +819,7 @@ - [@ohos.screenLock (锁屏管理)](reference/apis/js-apis-screen-lock.md) - [@ohos.systemTime (设置系统时间)](reference/apis/js-apis-system-time.md) - [@ohos.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) + - [@ohos.systemTimer(设置系统时间)](js-apis-system-timer.md) - [Timer (定时器)](reference/apis/js-apis-timer.md) - 设备管理 - [@ohos.batteryInfo (电量信息)](reference/apis/js-apis-battery-info.md) diff --git a/zh-cn/readme/figures/location_En-1.png b/zh-cn/readme/figures/location_En-1.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae4bcd7173f2e95004c96fa13d420c09f017f76 Binary files /dev/null and b/zh-cn/readme/figures/location_En-1.png differ diff --git a/zh-cn/readme/figures/location_zh-1.png b/zh-cn/readme/figures/location_zh-1.png new file mode 100644 index 0000000000000000000000000000000000000000..3638a47483ec2e0f0d8443e3ab2410b333886118 Binary files /dev/null and b/zh-cn/readme/figures/location_zh-1.png differ diff --git "a/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" index 4eb10f45572aa713365606b167267265bde94edb..62c1be27a8e6dda14147674172ed944bdd361cbe 100644 --- "a/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" @@ -40,7 +40,7 @@ **图 1** **子系统架构图** -![](figures/zh-1.png) +![](figures/location_zh-1.png) ## 目录 diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md b/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..f36d6fb6771768f124b4afe3c2d09f4ddd2295d0 --- /dev/null +++ b/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md @@ -0,0 +1,112 @@ +# OpenHarmony启用应用沙箱机制-适配指导 + +## 验证流程 + +![](figures\verification-process.png) + +1. 取发布版本自验证功能,如果功能正常,则适配流程结束。 +2. 取版本验证发现自身应用功能异常,则进行问题定位,通过分析代码识别到问题点,通过[适配流程](#适配流程)中的方法来进行文件访问模型的适配。 +3. 适配完毕之后,重新验证功能,功能正常则适配流程结束。功能依旧存在问题则重新回到第二步继续定位,直到问题解决为止。 + +## 适配流程 + +![](figures\adaptation-process.png) + +1. 定位出app异常的问题点之后,识别该问题是否是app源代码访问路径出错导致的,是否是访问有效文件可以通过下一章节的[沙箱文件访问规格清单](#沙箱文件访问规格清单)自查。 +2. 如果是app源码访问无效路径,则可以通过调整访问路径的策略,将原来访问/data目录从绝对路径访问方式调整为使用context接口进行访问,具体请见context接口使用说明: + https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/context-userguide.md + https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-ability-context.md + https://gitee.com/OpenHarmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md +3. 如果是app调用三方模块,异常调用栈出现在三方模块中,而app源码没有使用绝对路径去访问文件,则适配过程如下: + - 通知三方模块,让其访问文件路径通过context接口进行访问而非使用绝对路径的方式。 + - 如果三方模块是个公共模块,除了给appspawn孵化的进程使用之外还给native进程使用,则可以将三方模块抽象成一个服务,应用通过ipc的方式去访问服务。 + +## 沙箱文件访问规格清单 + +**应用根目录访问路径清单** + +| 路径名 | 备注 | +| --------------------- | ------------------------------------------ | +| bin | 存放着各种二进制文件 | +| config | 配置目录 | +| data | 应用数据目录 | +| dev | 设备节点 | +| etc | /system/etc的软连接 | +| init | /system/bin/init的软连接 | +| lib | /system/lib的软连接 | +| mnt | 挂载目录 | +| proc | proc文件系统目录 | +| sys | sys文件系统目录 | +| sys_prod | 此目录不同设备上存在差异,部分设备无此目录 | +| system/app | 系统目录资源 | +| system/fonts | 系统文字资源 | +| system/lib | 系统库 | +| system/data | 系统目录资源 | +| system/usr | 系统目录资源 | +| system/profile | 系统目录资源 | +| system/bin | 系统程序 | +| system/etc | 系统配置 | +| vendor/lib/chipsetsdk | 芯片组件目录,目前仅挂载chipsetsdk | + +**应用数据目录访问路径清单** + +| 路径名 | 备注 | +| ---------------------------------- | ------------------------------------------------------------ | +| /data | 应用数据目录 | +| /data/storage | 应用数据 | +| /data/bundles | 所有应用安装目录,仅应用apl权限为BASIC及以上权限的应用可访问 | +| /data/storage/el1 | 应用el1加密级别数据目录 | +| /data/storage/el2 | 应用el2加密级别数据目录 | +| /data/storage/el1/base | 应用el1加密级别数据目录 | +| /data/storage/el1/bundles | 应用el1加密级别应用安装包目录 | +| /data/storage/el1/database | 应用el1加密级别数据库存储目录 | +| /data/storage/el2/base | 应用el2加密级别数据目录 | +| /data/storage/el2/database | 应用el2加密级别数据库存储目录 | +| /data/storage/el2/auth_groups | 应用el2加密级别无账号分布式数据融合目录 | +| /data/storage/el2/distributedfiles | 应用el2加密级别有账号分布式数据融合目录 | + +启用应用沙箱之后,应用命名空间内无法再访问物理路径下数据目录的访问方式,而是只能通过context接口来访问应用的数据目录,具体访问应用数据目录的方式可以通过context接口进行访问,参考[适配流程](#适配流程)中的context接口访问链接了解更多细节。 +应用的物理数据目录跟沙箱数据目录存储的是同一份应用的数据,通过bind mount技术进行关联,改动任意一处会影响另一处的数据。应用在命名空间下访问数据,只能通过沙箱路径来访问,下面列出应用的数据目录在物理路径跟沙箱路径下的对应关系。 + +**应用的数据目录在物理路径跟沙箱路径下的对应关系** + +| 物理路径 | 沙箱路径 | 备注 | +| ------------------------------------------------------------ | ---------------------------------- | --------------------------------------- | +| /data/app/el1/bundle/public/\\ | /data/storage/el1/bundle | 应用安装包目录 | +| /data/app/el1/\/base/\ | /data/storage/el1/base | 应用el1级别加密数据目录 | +| /data/app/el2/\/base/\ | /data/storage/el2/base | 应用el2级别加密数据目录 | +| /data/app/el1/\/database/\ | /data/storage/el1/database | 应用el1级别加密数据库目录 | +| /data/app/el2/\/database/\ | /data/storage/el2/database | 应用el2级别加密数据库目录 | +| /mnt/hmdfs/\/account/merge_view/data/\ | /data/storage/el2/distributedfiles | 应用el2加密级别有账号分布式数据融合目录 | +| /mnt/hmdfs/\/non_account/merge_view/data/ | /data/storage/el2/auth_groups | 应用el2加密级别无账号分布式数据融合目录 | +| /mnt/hmdfs/ | /mnt/hmdfs/ | 分布式文件系统目录 | + +> **说明:**
\代表当前的用户ID +> \代表当前的应用包名 + +更多物理路径沙箱路径的对应关系,请访问: +https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox64.json + +## 案例:Contacts.hap拨号场景无法触发音频问题 + +联系人应用沙箱整改前访问资源文件的方式如下,可以看到访问的路径是绝对路径硬编码,为/data/app/el1此类目录,而此类目录在应用沙箱中是访问受限的,所以会造成访问异常。 + +![](figures\example1.png) + +此代码的核心是想通过fileIO接口open固定路径得到fdNumber,使用fdNumber去做接下来的文件访问。FileIO是通过路径得到fdNumber的,而现在路径访问已经被限制了,因此考虑用其他的接口去获取fdNumber即可, +查阅OpenHarmony相关开发手册得知,使用resourceManager可以获取fdNumber。 +更改后的代码如下: + +![](figures\example2.png) + +## 规避方案 + +如果发现应用异常且定位没有结论,可以使用关闭进程沙箱的方式来规避问题,规避方式如下: + +1. 打开OpenHarmony startup_appspawn仓的源码,找到应用沙箱配置文件,根据自己编译类型修改对应的配置代码文件。 + 32位修改:https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox.json + 64位修改:https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox.json + +2. 在json中文件找到camera的配置,在下方参照camera的配置新建一条自身应用的配置,将包名改为自身应用报名,其他项保持跟camera一致即可,OFF字段代表关闭进程沙箱。 + + ![](figures\example3.png) \ No newline at end of file diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md b/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..1eb1557a8670a9aac9a4f5ba354b216c4d01ccb1 --- /dev/null +++ b/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md @@ -0,0 +1,58 @@ +# 3.2 beta2相对3.2 beta1变更详细说明 + +## 启用应用沙箱机制 + +基于namespace机制强化OpenHarmony应用数据安全,建立应用沙盒机制,增加目录可见性数据访问防线,减少了应用数据和用户隐私信息泄露,建立了更加严格安全的应用沙盒隔离能力。 +同时也解决了目录混乱、文件访问方式多途径造成的文件管理的垃圾文件、文件混乱等体验问题和并发稳定性问题。 + +**变更影响** + +OpenHarmony启用应用沙箱机制后,所有被appspawn进程孵化的应用访问资源会受到应用沙箱的限制。 +如果应用没有适配应用沙箱的文件访问模型,则会导致应用功能异常。 +应用对于/data目录下文件的访问,需要将所有硬编码路径访问的方式调整为使用context接口访问,具体请见[适配流程](application-sandbox-adaptation-guide.md#适配流程)。 + +**关键的接口/组件变更** + +OpenHarmony应用沙箱组件 + +**适配指导** + +请参考[适配指导](application-sandbox-adaptation-guide.md)。 + +## 增加对于自定义组件Struct的编译校验 + +**变更1**:自定义组件Struct的生命周期函数(比如aboutToAppear)不能使用private修饰。 + +**变更影响** + +旧版本只有编辑器做了校验,新版本编译也加了校验报错。 + +**关键的接口/组件变更** + +无 + +**适配指导** + +当出现以下情况时,将private修饰去掉,即可通过编译。 + +![](figures\compile-change1-1.png) + +![](figures\compile-change1-2.png) + +**变更2:**自定义组件Struct的成员属性不能和内置属性方法名重名。 + +**变更影响** + +与内置属性方法名重名的Struct的成员属性无法通过校验。 + +**关键的接口/组件变更** + +无 + +**适配指导** + +当出现以下情况时,修改属性名,使其与内置属性方法名不重名。 + +![](figures\compile-change2-1.png) + +![](figures\compile-change2-2.png) \ No newline at end of file diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png new file mode 100644 index 0000000000000000000000000000000000000000..05b1892b5508c56ca029e930a6f0c1360f6a7967 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..01e3e90dd66f2aad624a5fbbf88600833442a3fc Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..3607345cc1b59633f8dc0c35ae99393525c15496 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png new file mode 100644 index 0000000000000000000000000000000000000000..22c62fb46ef2311b6ff4f040baf72938317b1ef2 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png new file mode 100644 index 0000000000000000000000000000000000000000..6ef778e4d6b361f43b5e7d8493236bda03cd9b24 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png new file mode 100644 index 0000000000000000000000000000000000000000..db7b455ef72cac51d6bea1be36283c1c1c269ec0 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png new file mode 100644 index 0000000000000000000000000000000000000000..9bb60d4b1e05dcb152e15553611db0c1da4d2b33 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png new file mode 100644 index 0000000000000000000000000000000000000000..b9923c8a00716601316b4129b143a3fad854beb7 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png new file mode 100644 index 0000000000000000000000000000000000000000..97bb2b82243470253462271e1c7164d77d64b4dc Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png differ diff --git a/zh-cn/website.md b/zh-cn/website.md index 975255a04342b01bdc0fe7074f0f1972263f92f3..1edc4cf36f5c38ac154fac3af0336e2c89ab9a03 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -125,7 +125,10 @@ - [资源调度](release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler_api-9-canary.md) - [窗口管理](release-notes/api-change/v3.1-Release/js-apidiff-window_api-9-canary.md) - [Native API差异报告](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md) - + - 变更说明 + - OpenHamrony 3.2 Beta2 + - [3.2 beta2相对3.2 beta1变更详细说明](release-notes\changelog\v3.2-beta2\changelog-v3.2-beta2.md) + - [OpenHarmony启用应用沙箱机制-适配指导](release-notes\changelog\v3.2-beta2\application-sandbox-adaptation-guide.md) - OpenHarmony三方组件 - [OpenHarmony三方组件简介](third-party-components/third-party-components-introduction.md) - [OpenHarmony JS/TS三方组件使用指导](third-party-components/npm-third-party-guide.md)