From 5ddef61179871629f9e3ba45990505095a323afe Mon Sep 17 00:00:00 2001 From: shawn_he Date: Thu, 17 Aug 2023 15:20:26 +0800 Subject: [PATCH] update doc Signed-off-by: shawn_he --- en/application-dev/dfx/cppcrash-guidelines.md | 29 +- .../js-apis-devicestatus-draginteraction.md | 98 ++++ .../apis/js-apis-geoLocationManager.md | 485 +++++++++++++----- .../reference/apis/js-apis-sms.md | 4 +- .../reference/errorcodes/errorcode-i18n.md | 26 +- .../reference/native-apis/_mind_spore.md | 125 ++++- .../reference/native-apis/context_8h.md | 16 +- .../reference/native-apis/tensor_8h.md | 44 +- en/application-dev/reference/syscap.md | 8 +- en/device-dev/get-code/sourcecode-acquire.md | 12 +- .../subsystems/subsys-boot-overview.md | 264 +++++----- .../subsystems/subsys-dfx-hidumper.md | 6 + .../changelogs-telephony.md | 121 +++++ .../changelogs-geoLocationManager.md | 36 ++ 14 files changed, 909 insertions(+), 365 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-devicestatus-draginteraction.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-telephony.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-geoLocationManager.md diff --git a/en/application-dev/dfx/cppcrash-guidelines.md b/en/application-dev/dfx/cppcrash-guidelines.md index 4454422fe4..c3ca07a4dc 100644 --- a/en/application-dev/dfx/cppcrash-guidelines.md +++ b/en/application-dev/dfx/cppcrash-guidelines.md @@ -1,4 +1,4 @@ -# cppcrash Log Analysis +# Process Crash (cppcrash) Log Analysis ## Introduction @@ -23,7 +23,7 @@ Process crash detection is implemented based on the Linux signal mechanism. Curr ## Crash Log Collection -Process crash log is the fault log managed together with the app freeze and JS application crash logs by the FaultLogger module. You can collect process crash logs in any of the following ways: +Process crash log is a type of fault logs managed together with the app freeze and JS application crash logs by the FaultLogger module. You can collect process crash logs in any of the following ways: ### Collecting Logs by Using Shell @@ -72,17 +72,14 @@ Thread name:crasher <- Abnormal thread ### Locating Faults Through Logs -1. Determine the faulty module and fault type based on fault logs. - - Generally, you can identify the faulty module based on the crash process name and identify the crash cause based on the signal. Besides, you can restore the function call chain of the crash stack based on the method name in the stack. - - In the example, **SIGSEGV** is thrown by the Linux kernel because of access to an invalid memory address. The problem occurs in the **TriggerSegmentFaultException** function. - - In most scenarios, a crash is caused by the top layer of the crash stack, such as null pointer access and proactive program abort. +- Determine the faulty module and fault type based on fault logs. + Generally, you can identify the faulty module based on the crash process name and identify the crash cause based on the signal. Besides, you can restore the function call chain of the crash stack based on the method name in the stack.\ + In the example, **SIGSEGV** is thrown by the Linux kernel because of access to an invalid memory address. The problem occurs in the **TriggerSegmentFaultException** function.\ + In most scenarios, a crash is caused by the top layer of the crash stack, such as null pointer access and proactive program abort.\ If the cause cannot be located through the call stack, you need to check for other faults, for example, memory corruption or stack overflow. -2. Use the addr2line tool of Linux to parse the code line number to restore the call stack at the time of process crash. +- Use the addr2line tool of Linux to parse the code line number to restore the call stack at the time of process crash. When using the addr2line tool to parse the code line number of the crash stack, make sure that binary files with debugging information is used. Generally, such files are generated during version build or application build. @@ -94,17 +91,17 @@ Thread name:crasher <- Abnormal thread \code root directory\out\product\exe.unstripped ``` - You can run `apt-get install addr2line` to install the addr2line tool on Linux. - + You can run `apt-get install addr2line` to install the addr2line tool on Linux.\ On On DevEco Studio, you can also use the llvm-addr2line tool archived in the SDK to parse code line numbers. The usage method is the same. - The following example shows how to use the addr2line tool to parse the code line number based on the offset address: + The following example shows how to use the addr2line tool to parse the code line number based on the offset address. + + **[product name]** indicates the device name. ``` - root:~/OpenHarmony/out/rk3568/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 0000332c + root:~/OpenHarmony/out/[product name]/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 0000332c base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57 ``` - In this example, the crash is caused by assignment of a value to an unwritable area. It is in code line 57 in the **dfx_crasher.c** file. You can modify it to avoid the crash. - + In this example, the crash is caused by assignment of a value to an unwritable area. It is in code line 57 in the **dfx_crasher.c** file. You can modify it to avoid the crash.\ If the obtained code line number is seemingly incorrect, you can fine-tune the address (for example, subtract the address by 1) or disable some compilation optimization items. It is known that the obtained code line number may be incorrect when Link Time Optimization (LTO) is enabled. diff --git a/en/application-dev/reference/apis/js-apis-devicestatus-draginteraction.md b/en/application-dev/reference/apis/js-apis-devicestatus-draginteraction.md new file mode 100644 index 0000000000..01b50c8fc5 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-devicestatus-draginteraction.md @@ -0,0 +1,98 @@ +# @ohos. deviceStatus.dragInteraction (Drag) + + The **dragInteraction** module provides the APIs to enable and disable listening for dragging status changes. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - The APIs provided by this module are system APIs. + +## Modules to Import + +```js +import dragInteraction from '@ohos.deviceStatus.dragInteraction' +``` + +## dragInteraction.on + +on(type: 'drag', callback: Callback<DragState>): void; + +Enables listening for dragging status changes. + +**System capability**: SystemCapability.Msdp.DeviceStatus.Drag + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | Yes | Event type. This field has a fixed value of **drag**.| +| callback | Callback<[DragState](#dragstate)> | Yes | Callback used to return the dragging status.| + +**Example** + +```js +try { + dragInteraction.on('drag', (data) => { + console.log(`Drag interaction event: ${JSON.stringify(data)}`); + }); +} catch (error) { + console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## dragInteraction.off + +off(type: 'drag', callback?: Callback<DragState>): void; + +Disables listening for dragging status changes. + +**System capability**: SystemCapability.Msdp.DeviceStatus.Drag + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | Yes | Event type. This field has a fixed value of **drag**.| +| callback | Callback<[DragState](#dragstate)> | No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.| + +**Example** + +```js +// Unregister a single callback. +function callback(event) { + console.log(`Drag interaction event: ${JSON.stringify(event)}`); + return false; +} +try { + dragInteraction.on('drag', callback); + dragInteraction.off("drag", callback); +} catch (error) { + console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` +```js +// Unregister all callbacks. +function callback(event) { + console.log(`Drag interaction event: ${JSON.stringify(event)}`); + return false; +} +try { + dragInteraction.on('drag', callback); + dragInteraction.off("drag"); +} catch (error) { + console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## DragState + +Enumerates dragging states. + +**System capability**: SystemCapability.Msdp.DeviceStatus.Drag + +| Name | Value | Description | +| -------- | ----------------- | ----------------- | +| MSG_DRAG_STATE_START | 1 | Dragging starts.| +| MSG_DRAG_STATE_STOP | 2 | Dragging is ended. | +| MSG_DRAG_STATE_CANCEL | 3 | Dragging is canceled. | diff --git a/en/application-dev/reference/apis/js-apis-geoLocationManager.md b/en/application-dev/reference/apis/js-apis-geoLocationManager.md index 263a1a525e..87bc2c4e99 100644 --- a/en/application-dev/reference/apis/js-apis-geoLocationManager.md +++ b/en/application-dev/reference/apis/js-apis-geoLocationManager.md @@ -53,7 +53,7 @@ Defines a reverse geocoding request. | locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| | latitude | number | Yes| Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**.| | longitude | number | Yes| Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**.| -| maxItems | number | Yes| Yes| Maximum number of location records to be returned. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| +| maxItems | number | Yes| Yes| Maximum number of location records to be returned. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended.| ## GeoCodeRequest @@ -66,7 +66,7 @@ Defines a geocoding request. | -------- | -------- | -------- | -------- | -------- | | locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| | description | string | Yes| Yes| Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**.| -| maxItems | number | Yes| Yes| Maximum number of location records to be returned. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| +| maxItems | number | Yes| Yes| Maximum number of location records to be returned. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended.| | minLatitude | number | Yes| Yes| Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges. The value ranges from **-90** to **90**.| | minLongitude | number | Yes| Yes| Minimum longitude. The value ranges from **-180** to **180**.| | maxLatitude | number | Yes| Yes| Maximum latitude. The value ranges from **-90** to **90**.| @@ -98,7 +98,7 @@ Defines a geographic location. | phoneNumber | string | Yes| No| Phone number.| | addressUrl | string | Yes| No| Website URL.| | descriptions | Array<string> | Yes| No| Additional descriptions.| -| descriptionsSize | number | Yes| No| Total number of additional descriptions. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| +| descriptionsSize | number | Yes| No| Total number of additional descriptions. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended.| | isFromMock | Boolean | Yes| No| Whether the geographical name is from the mock reverse geocoding function.
**System API**: This is a system API.| @@ -110,11 +110,11 @@ Defines a location request. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).| -| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).| -| timeInterval | number | Yes| Yes| Time interval at which location information is reported, in seconds. The value must be greater than **0**.| -| distanceInterval | number | Yes| Yes| Distance interval at which location information is reported. The value must be greater than **0**, in meters.| -| maxAccuracy | number | Yes| Yes| Location accuracy. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled. The value must be greater than **0**.| +| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request. This parameter is effective only when **scenario** is set to **UNSET**. If this parameter and **scenario** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).| +| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request. The **priority** parameter is effective only when this parameter is set to **UNSET**. If this parameter and **priority** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).| +| timeInterval | number | Yes| Yes| Time interval at which location information is reported, in seconds. The specified value must be greater than or equal to **0**. The default value is **1**.| +| distanceInterval | number | Yes| Yes| Distance interval at which location information is reported, in meters. The specified value must be greater than or equal to **0**. The default value is **0**.| +| maxAccuracy | number | Yes| Yes| Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled. The specified value must be greater than or equal to **0**. The default value is **0**.| ## CurrentLocationRequest @@ -125,10 +125,10 @@ Defines the current location request. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).| -| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).| -| maxAccuracy | number | Yes| Yes| Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled. The value must be greater than **0**.| -| timeoutMs | number | Yes| Yes| Timeout duration, in milliseconds. The minimum value is **1000**. The value must be greater than or equal to **1000**.| +| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request. This parameter is effective only when **scenario** is set to **UNSET**. If this parameter and **scenario** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).| +| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request. The **priority** parameter is effective only when this parameter is set to **UNSET**. If this parameter and **priority** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).| +| maxAccuracy | number | Yes| Yes| Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled. The specified value must be greater than or equal to **0**. The default value is **0**.| +| timeoutMs | number | Yes| Yes| Timeout duration, in milliseconds. The minimum value is **1000**. The specified value must be greater than or equal to **1000**.| ## SatelliteStatusInfo @@ -139,23 +139,23 @@ Defines the satellite status information. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| satellitesNumber | number | Yes| No| Number of satellites. The value must be greater than or equal to **0**.| -| satelliteIds | Array<number> | Yes| No| Array of satellite IDs. The value must be greater than or equal to **0**.| -| carrierToNoiseDensitys | Array<number> | Yes| No| Carrier-to-noise density ratio, that is, **cn0**. The value must be greater than **0**.| +| satellitesNumber | number | Yes| No| Number of satellites. The specified value must be greater than or equal to **0**.| +| satelliteIds | Array<number> | Yes| No| Array of satellite IDs. The specified value must be greater than or equal to **0**.| +| carrierToNoiseDensitys | Array<number> | Yes| No| Carrier-to-noise density ratio, that is, **cn0**. The specified value must be greater than **0**.| | altitudes | Array<number> | Yes| No| Satellite altitude angle information. The value ranges from **-90** to **90**, in degrees.| | azimuths | Array<number> | Yes| No| Azimuth information. The value ranges from **0** to **360**, in degrees.| -| carrierFrequencies | Array<number> | Yes| No| Carrier frequency. The value must be greater than or equal to **0**, in Hz.| +| carrierFrequencies | Array<number> | Yes| No| Carrier frequency, in Hz. The specified value must be greater than or equal to **0**.| ## CachedGnssLocationsRequest -Represents a request for reporting cached GNSS locations. +Defines a request for reporting cached GNSS locations. **System capability**: SystemCapability.Location.Location.Gnss | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| reportingPeriodSec | number | Yes| Yes| Interval for reporting the cached GNSS locations, in milliseconds. The value must be greater than **0**.| +| reportingPeriodSec | number | Yes| Yes| Interval for reporting the cached GNSS locations, in milliseconds. The specified value must be greater than **0**.| | wakeUpCacheQueueFull | boolean | Yes| Yes | **true**: reports the cached GNSS locations to the application when the cache queue is full.
**false**: discards the cached GNSS locations when the cache queue is full.| @@ -169,13 +169,13 @@ Defines a GNSS geofence. Currently, only circular geofences are supported. | -------- | -------- | -------- | -------- | -------- | | latitude | number | Yes| Yes|Latitude information. The value ranges from **-90** to **90**.| | longitude | number | Yes|Yes| Longitude information. The value ranges from **-180** to **180**.| -| radius | number | Yes|Yes| Radius of a circular geofence. The value must be greater than **0**, in meters.| -| expiration | number | Yes|Yes| Expiration period of a geofence, in milliseconds. The value must be greater than **0**.| +| radius | number | Yes|Yes| Radius of a circular geofence, in meters. The specified value must be greater than **0**.| +| expiration | number | Yes|Yes| Expiration period of a geofence, in milliseconds. The specified value must be greater than **0**.| ## GeofenceRequest -Represents a GNSS geofencing request. +Defines a GNSS geofencing request. **System capability**: SystemCapability.Location.Location.Geofence @@ -214,17 +214,17 @@ Defines a location. | direction | number | Yes| No| Direction information. The value ranges from **0** to **360**, in degrees.| | timeSinceBoot | number | Yes| No| Location timestamp since boot.| | additions | Array<string> | Yes| No| Additional description.| -| additionSize | number | Yes| No| Number of additional descriptions. The value must be greater than or equal to **0**. | +| additionSize | number | Yes| No| Number of additional descriptions. The specified value must be greater than or equal to **0**. | | isFromMock | Boolean | Yes| No| Whether the location information is from the mock location function.
**System API**: This is a system API.| ## ReverseGeocodingMockInfo -Represents information of the mock reverse geocoding function. +Defines the configuration of the mock reverse geocoding function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | @@ -234,21 +234,21 @@ Represents information of the mock reverse geocoding function. ## LocationMockConfig -Represents the information of the mock location function. +Defines the configuration of the mock location function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| timeInterval | number | Yes| Yes| Interval at which mock locations are reported, in seconds.| +| timeInterval | number | Yes| Yes| Time interval at which mock locations are reported, in seconds.| | locations | Array<[Location](#location)> | Yes| Yes| Array of mocked locations.| ## CountryCode -Represents country code information. +Defines the country code information. **System capability**: SystemCapability.Location.Location.Core @@ -258,6 +258,69 @@ Represents country code information. | type | [CountryCodeType](#countrycodetype) | Yes| No| Country code source.| +## LocatingRequiredDataConfig10+ + +Defines the configuration for obtaining the required data of the location service. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +| Name| Type| Readable|Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | [LocatingRequiredDataType](#locatingrequireddatatype10) | Yes| Yes| Type of the required data.| +| needStartScan | boolean | Yes| Yes| Whether to initiate scanning.| +| scanInterval | number | Yes| Yes| Scanning interval, in ms. The specified value must be greater than **0**. The default value is **10000**.| +| scanTimeout | number | Yes| Yes| Scanning timeout interval, in ms. The value ranges from **0** to **600000**. The default value is **10000**.| + + +## LocatingRequiredData10+ + +Defines the required data of the location service, including the Wi-Fi or Bluetooth scanning result. After obtaining the data, an application can use the data for services such as network positioning. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +| Name| Type| Readable|Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| wifiData | [WifiScanInfo](#wifiscaninfo10) | Yes| No| Wi-Fi scanning result.| +| bluetoothData | [BluetoothScanInfo](#bluetoothscaninfo10) | Yes| No| Bluetooth scanning result.| + + +## WifiScanInfo10+ + +Defines the Wi-Fi scanning information, including the SSID, BSSID, and RSSI of the scanned Wi-Fi hotspot. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +| Name| Type| Readable|Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| ssid | string | Yes| No| Service set identifier (SSID) of a Wi-Fi hotspot, in UTF-8 format.| +| bssid | string | Yes| No| Base station subsystem identifier (BSSID) of a Wi-Fi hotspot.| +| rssi | number | Yes| No| Received signal strength indicator (RSSI) of a Wi-Fi hotspot, in dBm.| +| frequency | number | Yes| No| Frequency of a Wi-Fi hotspot.| +| timestamp | number | Yes| No| Scanning timestamp.| + + +## BluetoothScanInfo10+ + +Defines the Bluetooth scanning information. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +| Name| Type| Readable|Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| deviceName | string | Yes| No| Name of a Bluetooth device.| +| macAddress | string | Yes| No| MAC address of a Bluetooth device.| +| rssi | number | Yes| No| Signal strength of a Bluetooth device, in dBm.| +| timestamp | number | Yes| No| Scanning timestamp.| + + ## LocationRequestPriority Sets the priority of the location request. @@ -280,7 +343,7 @@ Sets the priority of the location request. | Name| Value| Description| | -------- | -------- | -------- | -| UNSET | 0x300 | Scenario unspecified.
If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.| +| UNSET | 0x300 | Scenario unspecified.
If this option is used, [LocationRequestScenario](#locationrequest scenario) is invalid.| | NAVIGATION | 0x301 | Navigation.
This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.
In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.
The location result is reported at a minimum interval of 1 second by default.| | TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.
This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.
The location result is reported at a minimum interval of 1 second by default.| | CAR_HAILING | 0x303 | Ride hailing.
This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.
The location result is reported at a minimum interval of 1 second by default.| @@ -294,7 +357,7 @@ Defines the privacy statement type. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. | Name| Value| Description| | -------- | -------- | -------- | @@ -305,7 +368,7 @@ Defines the privacy statement type. ## CountryCodeType -Represents the country code source type. +Defines the country code source type. **System capability**: SystemCapability.Location.Location.Core @@ -317,11 +380,25 @@ Represents the country code source type. | COUNTRY_CODE_FROM_NETWORK | 4 | Country code obtained from the cellular network registration information.| +## LocatingRequiredDataType10+ + +Defines the type of the required data of the location service. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +| Name| Value| Description| +| -------- | -------- | -------- | +| WIFI | 1 | Wi-Fi scanning information.| +| BLUETOOTH | 2 | Bluetooth scanning information.| + + ## geoLocationManager.on('locationChange') on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void -Registers a listener for location changes with a location request initiated. +Subscribes to location change events with a location request initiated. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -331,13 +408,13 @@ Registers a listener for location changes with a location request initiated. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| + | type | string | Yes| Event type. The value **locationChange** indicates a location change.| | request | [LocationRequest](#locationrequest) | Yes| Location request.| - | callback | Callback<[Location](#location)> | Yes| Callback used to return the location change event.| + | callback | Callback<[Location](#location)> | Yes| Callback used to receive location change events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -349,7 +426,7 @@ For details about the following error codes, see [Location Error Codes](../error ```ts import geoLocationManager from '@ohos.geoLocationManager'; - let requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + let requestInfo = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET, 'timeInterval': 1, 'distanceInterval': 0, 'maxAccuracy': 0}; let locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); }; @@ -366,7 +443,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'locationChange', callback?: Callback<Location>): void -Unregisters the listener for location changes with the corresponding location request deleted. +Unsubscribes from location change events with the corresponding location request deleted. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -376,12 +453,12 @@ Unregisters the listener for location changes with the corresponding location re | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| + | type | string | Yes| Event type. The value **locationChange** indicates a location change.| | callback | Callback<[Location](#location)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -393,7 +470,7 @@ For details about the following error codes, see [Location Error Codes](../error ```ts import geoLocationManager from '@ohos.geoLocationManager'; - let requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + let requestInfo = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET, 'timeInterval': 1, 'distanceInterval': 0, 'maxAccuracy': 0}; let locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); }; @@ -410,7 +487,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'locationEnabledChange', callback: Callback<boolean>): void -Registers a listener for location service status change events. +Subscribes to location service status change events. **System capability**: SystemCapability.Location.Location.Core @@ -418,12 +495,12 @@ Registers a listener for location service status change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change event.| - | callback | Callback<boolean> | Yes| Callback used to return the location service status change event.| + | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change.| + | callback | Callback<boolean> | Yes| Callback used to receive location service status change events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -448,7 +525,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'locationEnabledChange', callback?: Callback<boolean>): void; -Unregisters the listener for location service status change events. +Unsubscribes from location service status change events. **System capability**: SystemCapability.Location.Location.Core @@ -456,12 +533,12 @@ Unregisters the listener for location service status change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change event.| + | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change.| | callback | Callback<boolean> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -487,7 +564,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; -Registers a listener for cached GNSS location reports. +Subscribes to cached GNSS location reports. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -499,11 +576,11 @@ Registers a listener for cached GNSS location reports. | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **cachedGnssLocationsChange** indicates reporting of cached GNSS locations.| | request | [CachedGnssLocationsRequest](#cachedgnsslocationsrequest) | Yes| Request for reporting cached GNSS location.| - | callback | Callback<boolean> | Yes| Callback used to return cached GNSS locations.| + | callback | Callback<boolean> | Yes| Callback used to receive cached GNSS locations.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -531,7 +608,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'cachedGnssLocationsChange', callback?: Callback<Array<Location>>): void; -Unregisters the listener for cached GNSS location reports. +Unsubscribes from cached GNSS location reports. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -546,7 +623,7 @@ Unregisters the listener for cached GNSS location reports. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -575,7 +652,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'satelliteStatusChange', callback: Callback<SatelliteStatusInfo>): void; -Registers a listener for GNSS satellite status change events. +Subscribes to GNSS satellite status change events. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -585,12 +662,12 @@ Registers a listener for GNSS satellite status change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change event.| - | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | Yes| Callback used to return GNSS satellite status changes.| + | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change.| + | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | Yes| Callback used to receive GNSS satellite status change events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -617,7 +694,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'satelliteStatusChange', callback?: Callback<SatelliteStatusInfo>): void; -Unregisters the listener for GNSS satellite status change events. +Unsubscribes from GNSS satellite status change events. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -627,12 +704,12 @@ Unregisters the listener for GNSS satellite status change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change event.| + | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change.| | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -660,7 +737,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'nmeaMessage', callback: Callback<string>): void; -Registers a listener for GNSS NMEA message change events. +Subscribes to GNSS NMEA message change events. **Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION @@ -670,12 +747,12 @@ Registers a listener for GNSS NMEA message change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change event.| - | callback | Callback<string> | Yes| Callback used to return GNSS NMEA message changes.| + | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change.| + | callback | Callback<string> | Yes| Callback used to receive GNSS NMEA message change events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -703,7 +780,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'nmeaMessage', callback?: Callback<string>): void; -Unregisters the listener for GNSS NMEA message change events. +Unsubscribes from GNSS NMEA message change events. **Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION @@ -713,12 +790,12 @@ Unregisters the listener for GNSS NMEA message change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change event.| + | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change.| | callback | Callback<string> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -747,7 +824,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; -Registers a listener for status change events of the specified geofence. +Subscribes to status change events of the specified geofence. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -757,13 +834,13 @@ Registers a listener for status change events of the specified geofence. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change event.| + | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change.| | request | [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.| - | want | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to return geofence (entrance or exit) events.| + | want | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -805,7 +882,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; -Unregisters the listener for status change events of the specified geofence. +Unsubscribes from status change events of the specified geofence. **Permission required**: ohos.permission.APPROXIMATELY_LOCATION @@ -815,13 +892,13 @@ Unregisters the listener for status change events of the specified geofence. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change event.| + | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change.| | request | [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.| - | want | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to return geofence (entrance or exit) events.| + | want | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -864,7 +941,7 @@ For details about the following error codes, see [Location Error Codes](../error on(type: 'countryCodeChange', callback: Callback<CountryCode>): void; -Registers a listener for country code change events. +Subscribes to country code change events. **System capability**: SystemCapability.Location.Location.Core @@ -872,12 +949,12 @@ Registers a listener for country code change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change event.| - | callback | Callback<[CountryCode](#countrycode)> | Yes| Callback used to return the country code change event.| + | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change.| + | callback | Callback<[CountryCode](#countrycode)> | Yes| Callback used to receive country code change events.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -905,7 +982,7 @@ For details about the following error codes, see [Location Error Codes](../error off(type: 'countryCodeChange', callback?: Callback<CountryCode>): void; -Unregisters the listener for country code change events. +Unsubscribes from country code change events. **System capability**: SystemCapability.Location.Location.Core @@ -913,12 +990,12 @@ Unregisters the listener for country code change events. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change event.| + | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change.| | callback | Callback<[CountryCode](#countrycode)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -942,6 +1019,89 @@ For details about the following error codes, see [Location Error Codes](../error ``` +## geoLocationManager.on('locatingRequiredDataChange')10+ + +on(type: 'locatingRequiredDataChange', config: LocatingRequiredDataConfig, callback: Callback<Array<LocatingRequiredData>>): void; + +Subscribes to changes in the required data of the location service, including Wi-Fi and Bluetooth scanning information. An application can then determine whether to enable Wi-Fi and Bluetooth scanning based on the return result. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value **locatingRequiredDataChange** indicates a change in the required data of the location service.| + | config | [LocatingRequiredDataConfig](#locatingrequireddataconfig10) | Yes| Configuration for obtaining the required data of the location service.| + | callback | Callback<Array<[LocatingRequiredData](#locatingrequireddata10)>> | Yes| Callback used to receive the required data of the location service.| + +**Error codes** + +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +|3301800 | Failed to start WiFi or Bluetooth scanning. | + +**Example** + + ```ts + import geoLocationManager from '@ohos.geoLocationManager'; + let callback = (code) => { + console.log('locatingRequiredDataChange: ' + JSON.stringify(code)); + } + let config = {'type': 1, 'needStartScan': true, 'scanInterval': 10000}; + try { + geoLocationManager.on('locatingRequiredDataChange', config, callback); + } catch (err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + } + ``` + + +## geoLocationManager.off('locatingRequiredDataChange')10+ + +off(type: 'locatingRequiredDataChange', callback?: Callback<Array<LocatingRequiredData>>): void; + +Unsubscribes from changes in the required data of the location service and stops Wi-Fi and Bluetooth scanning. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value **locatingRequiredDataChange** indicates a change in the required data of the location service.| + | callback | Callback<Array<[LocatingRequiredData](#locatingrequireddata10)>> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.| + +**Error codes** + +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). + +**Example** + + ```ts + import geoLocationManager from '@ohos.geoLocationManager'; + let callback = (code) => { + console.log('locatingRequiredDataChange: ' + JSON.stringify(code)); + } + let config = {'type': 1, 'needStartScan': true, 'scanInterval': 10000}; + try { + geoLocationManager.on('locatingRequiredDataChange', config, callback); + geoLocationManager.off('locatingRequiredDataChange', callback); + } catch (err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + } + ``` + ## geoLocationManager.getCurrentLocation @@ -958,11 +1118,11 @@ Obtains the current location. This API uses an asynchronous callback to return t | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | Yes| Location request.| - | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the current location.| + | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to receive the current location.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -974,7 +1134,7 @@ For details about the following error codes, see [Location Error Codes](../error ```ts import geoLocationManager from '@ohos.geoLocationManager'; - let requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; + let requestInfo = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET,'maxAccuracy': 0}; let locationChange = (err, location) => { if (err) { console.log('locationChanger: err=' + JSON.stringify(err)); @@ -1005,11 +1165,11 @@ Obtains the current location. This API uses an asynchronous callback to return t | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the current location.| + | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to receive the current location.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1061,7 +1221,7 @@ Obtains the current location. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1073,7 +1233,7 @@ For details about the following error codes, see [Location Error Codes](../error ```ts import geoLocationManager from '@ohos.geoLocationManager'; - let requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; + let requestInfo = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET,'maxAccuracy': 0}; try { geoLocationManager.getCurrentLocation(requestInfo).then((result) => { console.log('current location: ' + JSON.stringify(result)); @@ -1105,7 +1265,7 @@ Obtains the last location. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1141,7 +1301,7 @@ Checks whether the location service is enabled. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1165,7 +1325,7 @@ enableLocation(callback: AsyncCallback<void>): void; Enables the location service. This API uses an asynchronous callback to return the result. -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS @@ -1175,11 +1335,11 @@ Enables the location service. This API uses an asynchronous callback to return t | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the error message.| + | callback | AsyncCallback<void> | Yes| Callback used to receive the error message.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1207,7 +1367,7 @@ enableLocation(): Promise<void> Enables the location service. This API uses a promise to return the result. -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS @@ -1221,7 +1381,7 @@ Enables the location service. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1249,7 +1409,7 @@ disableLocation(): void; Disables the location service. -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS @@ -1257,7 +1417,7 @@ Disables the location service. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1275,7 +1435,6 @@ For details about the following error codes, see [Location Error Codes](../error ``` - ## geoLocationManager.getAddressesFromLocation getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void @@ -1289,11 +1448,11 @@ Converts coordinates into geographic description through reverse geocoding. This | 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.| + | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to receive the reverse geocoding result.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1342,7 +1501,7 @@ Converts coordinates into geographic description through reverse geocoding. This **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1380,11 +1539,11 @@ Converts geographic description into coordinates through geocoding. This API use | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.| - | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to return the geocoding result.| + | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to receive the geocoding result.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1433,7 +1592,7 @@ Converts geographic description into coordinates through geocoding. This API use **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1473,7 +1632,7 @@ Obtains the (reverse) geocoding service status. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1505,11 +1664,11 @@ Obtains the number of cached GNSS locations. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | Yes| Callback used to return the number of cached GNSS locations. | + | callback | AsyncCallback<number> | Yes| Callback used to receive the number of cached GNSS locations. | **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1553,7 +1712,7 @@ Obtains the number of cached GNSS locations. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1591,11 +1750,11 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the error message.| + | callback | AsyncCallback<void> | Yes| Callback used to receive the error message.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1633,11 +1792,11 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | Promise<void> | void | NA | Promise used to return the error code.| + | Promise<void> | void | NA | Promise used to receive the error code.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1675,11 +1834,11 @@ Sends an extended command to the location subsystem. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | command | [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.| - | callback | AsyncCallback<void> | Yes| Callback used to return the error code.| + | callback | AsyncCallback<void> | Yes| Callback used to receive the error code.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1720,11 +1879,11 @@ Sends an extended command to the location subsystem. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | Promise<void> | void | NA | Promise used to return the error code.| + | Promise<void> | void | NA | Promise used to receive the error code.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1760,11 +1919,11 @@ Obtains the current country code. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[CountryCode](#countrycode)> | Yes| Callback used to return the country code.| + | callback | AsyncCallback<[CountryCode](#countrycode)> | Yes| Callback used to receive the country code.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1802,11 +1961,11 @@ Obtains the current country code. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | Promise<[CountryCode](#countrycode)> | [CountryCode](#countrycode) | NA | Promise used to return the country code.| + | Promise<[CountryCode](#countrycode)> | [CountryCode](#countrycode) | NA | Promise used to receive the country code.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1839,11 +1998,11 @@ Enables the mock location function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1870,11 +2029,11 @@ Disables the mock location function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1903,7 +2062,7 @@ This API can be invoked only after [geoLocationManager.enableLocationMock](#geol **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Parameters** @@ -1913,7 +2072,7 @@ This API can be invoked only after [geoLocationManager.enableLocationMock](#geol **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1949,11 +2108,11 @@ Enables the mock reverse geocoding function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -1979,11 +2138,11 @@ Disables the mock geocoding function. **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -2011,7 +2170,7 @@ This API can be invoked only after [geoLocationManager.enableReverseGeocodingMoc **System capability**: SystemCapability.Location.Location.Core -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Parameters** @@ -2021,7 +2180,7 @@ This API can be invoked only after [geoLocationManager.enableReverseGeocodingMoc **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -2053,7 +2212,7 @@ isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications. -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.Location.Location.Core @@ -2067,11 +2226,11 @@ Checks whether a user agrees with the privacy statement of the location service. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | boolean | boolean | NA | Callback used to return the result, which indicates whether the user agrees with the privacy statement.| + | boolean | boolean | NA | Whether the user agrees with the privacy statement.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -2095,7 +2254,7 @@ setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean) Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications. -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS @@ -2106,11 +2265,11 @@ Sets the user confirmation status for the privacy statement of the location serv | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | [LocationPrivacyType](#locationprivacytype) | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.| - | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| + | isConfirmed | boolean | Yes| Whether the user agrees with the privacy statement.| **Error codes** -For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). | ID| Error Message| | -------- | ---------------------------------------- | @@ -2126,3 +2285,53 @@ For details about the following error codes, see [Location Error Codes](../error console.error("errCode:" + err.code + ",errMessage:" + err.message); } ``` + + +## geoLocationManager.getLocatingRequiredData10+ + +getLocatingRequiredData(config: LocatingRequiredDataConfig): Promise<Array<LocatingRequiredData>>; + +Obtains the required data of the location service. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [LocatingRequiredDataConfig](#locatingrequireddataconfig10) | Yes| Configuration for obtaining the required data of the location service.| + +**Return value** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | Promise<Array<[LocatingRequiredData](#locatingrequireddata10)>> | [LocatingRequiredData](#locatingrequireddata10) | NA | Callback used to receive the required data of the location service, such as the Wi-Fi and Bluetooth scanning information.| + +**Error codes** + +For details about the error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +|3301800 | Failed to start WiFi or Bluetooth scanning. | + +**Example** + + ```ts + import geoLocationManager from '@ohos.geoLocationManager'; + let config = {'type': 1, 'needStartScan': true, 'scanInterval': 10000}; + try { + geoLocationManager.getLocatingRequiredData(config).then((result) => { + console.log('getLocatingRequiredData return: ' + JSON.stringify(result)); + }) + .catch((error) => { + console.log('promise, getLocatingRequiredData: error=' + JSON.stringify(error)); + }); + } catch (err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index 41a3fe10bb..302ef98053 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -195,7 +195,7 @@ let destinationHost = '+861xxxxxxxxxx'; let serviceCenter = '+861xxxxxxxxxx'; let destinationPort = 1000; let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; -sms.sendMessage(options, (err) => { +sms.sendShortMessage(options, (err) => { console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1341,7 +1341,7 @@ sms.isImsSmsSupported(slotId, (err, data) => { isImsSmsSupported\(slotId: number\): Promise\ -This API uses an asynchronous callback to return the result. This API uses a promise to return the result. +Checks whether SMS is supported on IMS. This API uses a promise to return the result. **System API**: This is a system API. diff --git a/en/application-dev/reference/errorcodes/errorcode-i18n.md b/en/application-dev/reference/errorcodes/errorcode-i18n.md index 6b269c1744..96a13011fc 100644 --- a/en/application-dev/reference/errorcodes/errorcode-i18n.md +++ b/en/application-dev/reference/errorcodes/errorcode-i18n.md @@ -1,4 +1,4 @@ -# i18n Error Codes +# I18N Error Codes > **NOTE** > @@ -8,7 +8,7 @@ **Error Message** -Unspported para value. +param value not valid **Description** @@ -17,25 +17,7 @@ This error code is reported if an I18N API is called with invalid parameter valu **Possible Causes** Invalid parameter values are probably due to incorrect parameter types. - -**Solution** - -Check whether the parameter type is correct. - -## 890002 Incorrect Configuration Option - -**Error Message** - -param value not valid - -**Description** - -This error code is reported if an I18N API is called with invalid option values specified. - -**Possible Causes** - -Invalid option values are probably due to incorrect option types. - + **Solution** -Check whether the option type is correct. +Check whether the parameter types are correct. diff --git a/en/application-dev/reference/native-apis/_mind_spore.md b/en/application-dev/reference/native-apis/_mind_spore.md index e52fc4f327..2eba42c904 100644 --- a/en/application-dev/reference/native-apis/_mind_spore.md +++ b/en/application-dev/reference/native-apis/_mind_spore.md @@ -33,7 +33,7 @@ Provides APIs related to MindSpore Lite model inference. | Name | Description | | ------------------------------------------------------------ | ---------------------------------------------------- | | [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.| -| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | +| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | | [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. | @@ -109,18 +109,19 @@ Provides APIs related to MindSpore Lite model inference. | [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system. | -| [OH_AI_DestroyAllNNRTDeviceDescs](#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetElementOfNNRTDeviceDescs](#oh_ai_getelementofnnrtdevicedescs) (NNRTDeviceDesc \*descs, size_t index) | Obtains the pointer to an element in the NNRt device description array.| +| [OH_AI_DestroyAllNNRTDeviceDescs](#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](#nnrtdevicedesc) \*\*desc) | Destroys the NNRt device description array obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).| | [OH_AI_GetDeviceIdFromNNRTDeviceDesc](#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| | [OH_AI_GetNameFromNNRTDeviceDesc](#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description. | | [OH_AI_GetTypeFromNNRTDeviceDesc](#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description. | | [OH_AI_CreateNNRTDeviceInfoByName](#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| | [OH_AI_CreateNNRTDeviceInfoByType](#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| -| [OH_AI_DeviceInfoSetDeviceId](#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices. | -| [OH_AI_DeviceInfoGetDeviceId](#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices. | -| [OH_AI_DeviceInfoSetPerformanceMode](#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices. | -| [OH_AI_DeviceInfoGetPerformanceMode](#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. | -| [OH_AI_DeviceInfoSetPriority](#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices. | -| [OH_AI_DeviceInfoGetPriority](#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetDeviceId](#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This function is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetDeviceId](#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This function is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPerformanceMode](#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This function is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPerformanceMode](#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This function is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPriority](#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](#oh_ai_priority) priority) | Sets the priority of an NNRt task. This function is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPriority](#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRt task. This function is available only for NNRt devices. | | [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | | [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | | [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | @@ -131,9 +132,10 @@ Provides APIs related to MindSpore Lite model inference. | [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | | [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | | [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | +| [OH_AI_DeviceInfoAddExtension](#oh_ai_deviceinfoaddextension) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*name, const char \*value, size_t value_size) | Adds extended configuration in the form of key/value pairs to the device information. This function is available only for NNRt device information.| | [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | | [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | -| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Deeply copies a tensor. | +| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. | | [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the tensor name. | | [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor name. | | [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | @@ -147,7 +149,7 @@ Provides APIs related to MindSpore Lite model inference. | [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | | [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | | [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | - +| [OH_AI_TensorSetUserData](#oh_ai_tensorsetuserdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data, size_t data_size) | Sets the tensor as the user data. This function allows you to reuse user data as the model input, which helps to reduce data copy by one time.| ## Macro Description @@ -893,7 +895,7 @@ OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs (NNRTDeviceDesc ** desc) **Description** -Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs). +Destroys the NNRt device description array obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs). **Parameters** @@ -955,7 +957,7 @@ OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId (const OH_AI_DeviceInfoHandle devic **Description** -Obtains the ID of an NNRt device. This API is available only for NNRt devices. +Obtains the ID of an NNRt device. This function is available only for NNRt devices. **Parameters** @@ -1025,7 +1027,7 @@ OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_ **Description** -Obtains the NPU frequency type. This API is available only for NPU devices. +Obtains the NPU frequency type. This function is available only for NPU devices. **Parameters** @@ -1047,7 +1049,7 @@ OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode (const OH_AI_ **Description** -Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. +Obtains the performance mode of an NNRt device. This function is available only for NNRt devices. **Parameters** @@ -1073,7 +1075,7 @@ OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority (const OH_AI_DeviceInfoHand **Description** -Obtains the priority of an NNRT task. This API is available only for NNRt devices. +Obtains the priority of an NNRt task. This function is available only for NNRt devices. **Parameters** @@ -1143,7 +1145,7 @@ OH_AI_API void OH_AI_DeviceInfoSetDeviceId (OH_AI_DeviceInfoHandle device_info, **Description** -Sets the ID of an NNRt device. This API is available only for NNRt devices. +Sets the ID of an NNRt device. This function is available only for NNRt devices. **Parameters** @@ -1204,7 +1206,7 @@ OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode (OH_AI_DeviceInfoHandle device **Description** -Sets the performance mode of an NNRt device. This API is available only for NNRt devices. +Sets the performance mode of an NNRt device. This function is available only for NNRt devices. **Parameters** @@ -1227,7 +1229,7 @@ OH_AI_API void OH_AI_DeviceInfoSetPriority (OH_AI_DeviceInfoHandle device_info, **Description** -Sets the priority of an NNRt task. This API is available only for NNRt devices. +Sets the priority of an NNRt task. This function is available only for NNRt devices. **Parameters** @@ -1951,3 +1953,90 @@ Sets the tensor shape. | tensor | Handle of the tensor object. | | shape | Shape array. | | shape_num | Length of the tensor shape array.| + + +### OH_AI_TensorSetUserData() + +``` +OH_AI_API OH_AI_Status OH_AI_TensorSetUserData (OH_AI_TensorHandle tensor, void * data, size_t data_size ) +``` + +**Description** + +Sets the tensor as the user data. + +This function allows you to reuse user data as the model input, which helps to reduce data copy by one time. + +> **NOTE**
The user data is type of external data for the tensor and is not automatically released when the tensor is destroyed. The caller needs to release the data separately. In addition, the caller must ensure that the user data is valid during use of the tensor. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| tensor | Handle of the tensor object.| +| data | Start address of user data.| +| data_size | Length of the user data length.| + +**Returns** + +Execution status code. The value **OH_AI_STATUS_SUCCESS** indicates that the operation is successful. If the operation fails, an error code is returned. + +**Since** + +10 + + +### OH_AI_DeviceInfoAddExtension() + +``` +OH_AI_API OH_AI_Status OH_AI_DeviceInfoAddExtension (OH_AI_DeviceInfoHandle device_info, const char * name, const char * value, size_t value_size ) +``` + +**Description** + +Adds extended configuration in the form of key/value pairs to the device information. This function is available only for NNRt device information. + +>**NOTE**
Key value pairs currently supported include {"CachePath": "YourCachePath"}, {"CacheVersion": "YourCacheVersion"}, and {"QuantParam": "YourQuantConfig"}. Replace the actual value as required. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| name | Key in an extended key/value pair. The value is a C string.| +| value | Start address of the value in an extended key/value pair.| +| value_size | Length of the value in an extended key/value pair.| + +**Returns** + +Status code enumerated by **OH_AI_Status**. The value **OH_AI_STATUS_SUCCESS** indicates that the operation is successful. If the operation fails, an error code is returned. + +**Since** + +10 + + +### OH_AI_GetElementOfNNRTDeviceDescs() + +``` +OH_AI_API NNRTDeviceDesc* OH_AI_GetElementOfNNRTDeviceDescs (NNRTDeviceDesc * descs, size_t index ) +``` + +**Description** + +Obtains the pointer to an element in the NNRt device description array. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| descs | NNRt device description array.| +| index | Index of an array element.| + +**Returns** + +Pointer to an element in the NNRt device description array. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/context_8h.md b/en/application-dev/reference/native-apis/context_8h.md index 743fdbc9db..2445e715d0 100644 --- a/en/application-dev/reference/native-apis/context_8h.md +++ b/en/application-dev/reference/native-apis/context_8h.md @@ -52,15 +52,17 @@ Provides **Context** APIs for configuring runtime information. | [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices.| | [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices.| | [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system.| -| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetElementOfNNRTDeviceDescs](_mind_spore.md#oh_ai_getelementofnnrtdevicedescs) (NNRTDeviceDesc \*descs, size_t index) | Obtains the pointer to an element in the NNRt device description array.| +| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the NNRt device description array obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).| | [OH_AI_GetDeviceIdFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| | [OH_AI_GetNameFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description.| | [OH_AI_GetTypeFromNNRTDeviceDesc](_mind_spore.md#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description.| | [OH_AI_CreateNNRTDeviceInfoByName](_mind_spore.md#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| | [OH_AI_CreateNNRTDeviceInfoByType](_mind_spore.md#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](_mind_spore.md#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| -| [OH_AI_DeviceInfoSetDeviceId](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices.| -| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices.| -| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices.| -| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.| -| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices.| -| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetDeviceId](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRt task. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRt task. This function is available only for NNRt devices.| +| [OH_AI_DeviceInfoAddExtension](_mind_spore.md#oh_ai_deviceinfoaddextension) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*name, const char \*value, size_t value_size) | Adds extended configuration in the form of key/value pairs to the device information. This function is available only for NNRt device information.| diff --git a/en/application-dev/reference/native-apis/tensor_8h.md b/en/application-dev/reference/native-apis/tensor_8h.md index bf194ef55a..f7eca09400 100644 --- a/en/application-dev/reference/native-apis/tensor_8h.md +++ b/en/application-dev/reference/native-apis/tensor_8h.md @@ -5,10 +5,11 @@ Provides APIs for creating and modifying tensor information. -**Since:** +**Since** + 9 -**Related Modules:** +**Related Modules** [MindSpore](_mind_spore.md) @@ -18,28 +19,29 @@ Provides APIs for creating and modifying tensor information. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) | Defines the handle of a tensor object. | +| [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) | Defines the handle of a tensor object.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_TensorCreate](_mind_spore.md#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](_mind_spore.md#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | -| [OH_AI_TensorDestroy](_mind_spore.md#oh_ai_tensordestroy) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | -| [OH_AI_TensorClone](_mind_spore.md#oh_ai_tensorclone) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Clones a tensor. | -| [OH_AI_TensorSetName](_mind_spore.md#oh_ai_tensorsetname) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. | -| [OH_AI_TensorGetName](_mind_spore.md#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. | -| [OH_AI_TensorSetDataType](_mind_spore.md#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_DataType](_mind_spore.md#oh_ai_datatype) type) | Sets the data type of a tensor. | -| [OH_AI_TensorGetDataType](_mind_spore.md#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. | -| [OH_AI_TensorSetShape](_mind_spore.md#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. | -| [OH_AI_TensorGetShape](_mind_spore.md#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. | -| [OH_AI_TensorSetFormat](_mind_spore.md#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_Format](_mind_spore.md#oh_ai_format) format) | Sets the tensor data format. | -| [OH_AI_TensorGetFormat](_mind_spore.md#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | -| [OH_AI_TensorSetData](_mind_spore.md#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | -| [OH_AI_TensorGetData](_mind_spore.md#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | -| [OH_AI_TensorGetMutableData](_mind_spore.md#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | -| [OH_AI_TensorGetElementNum](_mind_spore.md#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | -| [OH_AI_TensorGetDataSize](_mind_spore.md#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | +| [OH_AI_TensorCreate](_mind_spore.md#oh_ai_tensorcreate) (const char \*name, OH_AI_DataType type, const int64_t \*shape,
size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object.| +| [OH_AI_TensorDestroy](_mind_spore.md#oh_ai_tensordestroy) (OH_AI_TensorHandle \*tensor) | Destroys a tensor object.| +| [OH_AI_TensorClone](_mind_spore.md#oh_ai_tensorclone) (OH_AI_TensorHandle tensor) | Clones a tensor.| +| [OH_AI_TensorSetName](_mind_spore.md#oh_ai_tensorsetname) (OH_AI_TensorHandle tensor, const char \ *name) | Sets the tensor name.| +| [OH_AI_TensorGetName](_mind_spore.md#oh_ai_tensorgetname) (const OH_AI_TensorHandle tensor) | Obtains the tensor name.| +| [OH_AI_TensorSetDataType](_mind_spore.md#oh_ai_tensorsetdatatype) (OH_AI_TensorHandle tensor, OH_AI_DataType type) | Sets the data type of a tensor.| +| [OH_AI_TensorGetDataType](_mind_spore.md#oh_ai_tensorgetdatatype) (const OH_AI_TensorHandle tensor) | Obtains the tensor type.| +| [OH_AI_TensorSetShape](_mind_spore.md#oh_ai_tensorsetshape) (OH_AI_TensorHandle tensor,
const int64_t \*shape, size_t shape_num) | Sets the tensor shape.| +| [OH_AI_TensorGetShape](_mind_spore.md#oh_ai_tensorgetshape) (const OH_AI_TensorHandle tensor, size_t \*shape_num) | Obtains the tensor shape.| +| [OH_AI_TensorSetFormat](_mind_spore.md#oh_ai_tensorsetformat) (OH_AI_TensorHandle tensor, OH_AI_Format format) | Sets the tensor data format.| +| [OH_AI_TensorGetFormat](_mind_spore.md#oh_ai_tensorgetformat) (const OH_AI_TensorHandle tensor) | Obtains the tensor data format.| +| [OH_AI_TensorSetData](_mind_spore.md#oh_ai_tensorsetdata) (OH_AI_TensorHandle tensor, void \*data) | Sets the tensor data.| +| [OH_AI_TensorGetData](_mind_spore.md#oh_ai_tensorgetdata) (const OH_AI_TensorHandle tensor) | Obtains the pointer to tensor data.| +| [OH_AI_TensorGetMutableData](_mind_spore.md#oh_ai_tensorgetmutabledata) (const OH_AI_TensorHandle tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated.| +| [OH_AI_TensorGetElementNum](_mind_spore.md#oh_ai_tensorgetelementnum) (const OH_AI_TensorHandle tensor) | Obtains the number of tensor elements.| +| [OH_AI_TensorGetDataSize](_mind_spore.md#oh_ai_tensorgetdatasize) (const OH_AI_TensorHandle tensor) | Obtains the number of bytes of the tensor data.| +| [OH_AI_TensorSetUserData](_mind_spore.md#oh_ai_tensorsetuserdata) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, void \*data, size_t data_size) | Sets the tensor as the user data. This function allows you to reuse user data as the model input, which helps to reduce data copy by one time.| diff --git a/en/application-dev/reference/syscap.md b/en/application-dev/reference/syscap.md index f5db3a40c6..b4dc9df76e 100644 --- a/en/application-dev/reference/syscap.md +++ b/en/application-dev/reference/syscap.md @@ -110,11 +110,11 @@ You can use either the ArtTS or native API to determine whether an API is availa - Method 2: Import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available. ```ts - import geolocation from '@ohos.geolocation'; + import geolocationManager from '@ohos.geoLocationManager'; - if (geolocation) { - geolocation.getCurrentLocation((location) => { - console.log(location.latitude, location.longitude); + if (geolocationManager) { + geolocationManager.getCurrentLocation((location) => { + console.log('current location: ' + JSON.stringify(location)); }); } else { console.log('This device does not support location information.'); diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md index bda7306a44..6d6555dfe4 100644 --- a/en/device-dev/get-code/sourcecode-acquire.md +++ b/en/device-dev/get-code/sourcecode-acquire.md @@ -201,12 +201,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB | | RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - | | **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| -| Full code base (for mini, small, and standard systems) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz.sha256)| 26.2 GB | -| Hi3861 solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz.sha256)| 25.1 MB | -| Hi3516 solution-LiteOS (binary)| 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz.sha256)| 287.6 MB | -| Hi3516 solution-Linux (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz.sha256)| 186.4 MB | -| RK3568 standard system solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz.sha256)| 4.5 GB | -| RELEASE-NOTES | 4.0 Beta1 | [Download](../../release-notes/OpenHarmony-v4.0-beta1.md)| - | - | +| Full code base (for mini, small, and standard systems) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/code-v4.0-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/code-v4.0-Beta2.tar.gz.sha256)| 27.7 GB | +| Hi3861 solution (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_pegasus.tar.gz.sha256)| 27.5 MB | +| Hi3516 solution-LiteOS (binary)| 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)| 300.9 MB | +| Hi3516 solution-Linux (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_Linux.tar.gz.sha256)| 192.4 MB | +| RK3568 standard system solution (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/dayu200_standard_arm32.tar.gz.sha256)| 5.2 GB | +| RELEASE-NOTES | 4.0 Beta1 | [Download](../../release-notes/OpenHarmony-v4.0-beta2.md) | - | - | | **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - | diff --git a/en/device-dev/subsystems/subsys-boot-overview.md b/en/device-dev/subsystems/subsys-boot-overview.md index 2636bc078b..24e184b3db 100644 --- a/en/device-dev/subsystems/subsys-boot-overview.md +++ b/en/device-dev/subsystems/subsys-boot-overview.md @@ -11,45 +11,45 @@ The following figure shows the context structure of the Startup subsystem. When the system is powered on, the kernel loads and starts services and applications as follows: -1. The kernel loads the init process, which is specified by **cmdline** of the kernel when the bootloader starts the kernel. -2. After the init process is started, **tmpfs** and **procfs** are mounted and basic **dev** nodes are created to establish a basic root file system. -3. The init process starts the ueventd process to listen for device hot-swap events in the kernel and creates **dev** nodes for related devices as well as partitions for the block device. -4. After mounting partitions (**system** and **vendor**) of the block device, the init process scans for the init startup script of each system service and starts the respective system ability (SA). +1. The kernel loads the init process, which is specified by `cmdline` of the kernel when the bootloader starts the kernel. +2. After the init process is started, `tmpfs` and `procfs` are mounted and basic `dev` nodes are created to establish a basic root file system. +3. The init process starts the ueventd process to listen for device hot-swap events in the kernel and creates `dev` nodes for related devices as well as partitions for the block device. +4. After mounting partitions (`system` and `vendor`) of the block device, the init process scans for the init startup script of each system service and starts the respective system ability (SA). 5. Each SA registers with the samgr process, which serves as the service registration center. The samgr process assigns each SA with an ID, which will be used by an application to access the desired SA. -6. The foundation process sends the application startup request to the appspawn process. The foundation implements application lifecycle management. It is a special SA service process that provides the user program management framework and basic services. -7. The appspawn process directly spawns the application process, eliminating the need for the application to load the JS runtime environment. This reduces the application startup time. +6. The foundation process implements application lifecycle management. It is a special SA service process that provides the user program management framework and basic services. +7. For an application, loading of the JS running environment involves a great deal of preparations. To reduce the application startup time, the appspawn process directly spawns an application process once receiving an application startup request from the foundation process. The Startup subsystem consists of the following modules: -- init module +- init Module - This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in Table 2 in [Job Management](../subsystems/subsys-boot-init-jobs.md) and starts the key system service processes in sequence with corresponding permissions granted. + This module corresponds to the init process, which is the first user-space process started after the kernel is initialized. After the init process starts, it reads and parses the `init.cfg` file. Based on the parsing result, the init module executes the commands listed in Table 2 in [Job Management](../subsystems/subsys-boot-init-jobs.md#available-apis) and starts the key system service processes in sequence with corresponding permissions granted. - ueventd module - This module listens for **netlink** events about hot swap of kernel device drivers and dynamically manages the **dev** node of the corresponding device based on the event type. + This module listens for **netlink** events about hot plug of kernel device drivers and dynamically manages the `dev` node of the corresponding device based on the event type. -- appspawn module +- appspawn Module This module spawns application processes upon receiving commands from the foundation, configures permissions for new processes, and calls the entry function of the application framework. -- bootstrap module +- bootstrap Module - This module provides entry identifiers for starting services and features. When SAMGR is started, the entry function identified by bootstrap is called and system services are started. + This module provides entry identifiers for starting services and features. When samgr is started, the entry function identified by bootstrap is called and system services are started. -- syspara module +- syspara This module provides APIs for obtaining device information, such as the product name, brand name, and manufacturer name, based on the OpenHarmony Product Compatibility Specifications (PCS). It also provides APIs for setting and obtaining system attributes. ## Constraints - The source code directory of the Startup subsystem varies according to the platform. + The source code directory of the Startup subsystem varies according to the platform. - **Table 1** Directories and applicable platforms of the Startup subsystem + **Table 1** Directories and applicable platforms of the Startup subsystem -| Source Code Directory| Applicable Platform| +| Name| Applicable Platform| | -------- | -------- | | base/startup/appspawn_lite | Small-system devices (reference memory ≥ 1 MiB), for example, Hi3516D V300 and Hi3518E V300| | base/startup/bootstrap_lite | Mini-system devices (reference memory ≥ 128 KiB), for example, Hi3861 V100| @@ -57,14 +57,14 @@ The Startup subsystem consists of the following modules: | base/startup/syspara_lite | - Mini-system devices (reference memory ≥ 128 KiB), for example, Hi3861 V100
- Small-system devices (reference memory ≥ 1 MiB), for example, Hi3516D V300 and Hi3518E V300| - init module - - To start a system service, you first need to write a boot script file named **init.cfg**, in which you define the service name, path of executable files, permissions, etc. - - The boot script of each system service is installed in the **/system/etc/init** directory. The init process scans this directory for the boot script to execute. + - To start a system service, you first need to write a boot script file named `init.cfg`, in which you define the service name, path of executable files, permissions, etc. + - The boot script of each system service is installed in the `/system/etc/init` directory. The init process scans this directory for the boot script to execute. -- When porting a new chip platform, you need to add the **/vendor/etc/init/init.{hardware}.cfg** file that contains the platform-level initialization configuration. This file is used to implement platform-level initialization, for example, installing the ko driver and configuring information on the related **/proc** nodes. +- When porting a new chip platform, you need to add the `/vendor/etc/init/init.{hardware}.cfg` file that contains the platform-level initialization configuration. This file is used to implement platform-level initialization, for example, installing the ko driver and configuring information on the related `/proc` nodes. > **NOTE** - > - > The configuration file **init.cfg** must be in JSON format. + > + > The configuration file `init.cfg` must be in JSON format. - bootstrap module: The zInit code must be configured in the link script. @@ -83,67 +83,67 @@ By default, the OpenHarmony standard system supports the images listed in the fo On each development board, you need to partition the memory to store the preceding images. When the SoC starts, the bootloader loads the images as follows: - Initializes hardware such as the ROM and RAM, and loads the partition table information. -- Loads the **boot.img** file based on the partition table and parses and loads the **ramdisk.img** file to the memory. -- Prepares the partition table information and ramdisk address and enters the kernel, so that the kernel loads the ramdisk image and starts the init process. -- Waits until the init process prepares the initial file system and mounts **required.fstab** (including **system.img** and **vendor.img**) to the file system. -- Scans the boot scripts in the **etc/init** directory in **system.img** and **vendor.img** and runs each boot command. +- Loads the `boot.img` file based on the partition table and parses and loads the `ramdisk.img` file to the memory. +- Prepares the partition table information and ramdisk address and enters the kernel, so that the kernel loads the the ramdisk image and starts the init process. +- Waits until the init process prepares the initial file system and mounts `required.fstab` (including `system.img` and `vendor.img`) to the file system. +- Scans the boot scripts in the `etc/init` directory in `system.img` and `vendor.img` and runs each boot command. ### U-Boot Process -[U-Boot](https://elinux.org/U-Boot) is used as an example to describe the key image loading process. When U-Boot starts the system, it passes the boot information to the system by using **bootargs**. +[U-Boot](https://elinux.org/U-Boot) is used as an example to describe the key image loading process. When U-Boot starts the system, it passes the boot information to the system by using `bootargs`. -- **boot.img** loading and parsing +- `boot.img` loading and parsing - - **boot.img** format + - `boot.img` format - **boot.img** building and loading vary depending on the platform. The implementation on mainstream OpenHarmony platforms is as follows: + `boot.img` building and loading varies depending on the platform. The implementation on mainstream OpenHarmony platforms is as follows: - - Hi3516D V300 + - Hi3516DV300 - On this platform, the **boot.img** file uses the flattened image tree (FIT) format. It is generated by the Mkimage tool by packing the **zImage-dtb** and **cpio** images, which are generated after kernel compilation, based on the information in the **.its** file. + On this platform, the `boot.img` file uses the flattened image tree (FIT) format. It is generated by the Mkimage tool by packing the `ramdisk.img` files, which are packed by using `zImage-dtb` or `cpio` during kernel building, based on the information in the `its` file. The related files and tool are described as follows: - 1. **.its** file + 1. `its` file - An image source file that describes the information about the image to be generated. You need to create the file, for example, the **ohos.its** file on the Hi3516 platform. + An image source file that describes the information about the image to be generated. You need to create the file, for example, the `ohos.its` file on the Hi3516 platform. 2. Mkimage packaging tool - A tool that parses **its** files and packs the corresponding images based on the image configuration to generate an **itb** file, that is, **boot.img**. + A tool that parses `its` files and packs the corresponding images based on the image configuration to generate an `itb` file, that is, `boot.img`. - 3. ramdisk + 3. `ramdisk` image - An image file generated by packing **cpio** images. + A `ramdisk.img` file packed by using `cpio`. - 4. zImage-dtb + 4. `zImage-dtb` image - An image file that contains the compressed kernel image and device description file image. + An image that contains the compressed kernel image and device description file image. - rk3568 - On this platform, the **boot.img** file is named **boot_linux.img**. The packaged files are different from those on the Hi3516D V300 platform. + On this platform, the `boot.img` file is named `boot_linux.img`. The packaged files are different from those on the Hi3516D V300 platform. 1. Image - Image file generated after kernel compilation. + Image file generated after kernel building. 2. toybrick.dtb - A file that is similar to the device description file image generated after dts compilation. + A file that is similar to the device description file image generated through `dts` building. 3. ramdisk.img - An image file generated by packing **cpio** images. + A `ramdisk.img` file packed by using `cpio`. - U-Boot loading - The ramdisk boot process is supported. In this scenario, you need to modify the product configuration file in **productdefine** and enable ramdisk generation by setting **enable_ramdisk**. The ramdisk processing method varies according to the platform. Take the Hi3516D V300 platform as an example. You need to change the original U-Boot parameter to **root=/dev/ram0 initrd=0x84000000,0x292e00**. + The ramdisk boot process is supported. In this scenario, you need to modify the product configuration file in `productdefine` and enable ramdisk generation by setting `enable_ramdisk`. The ramdisk processing method varies according to the platform. Take the Hi3516D V300 platform as an example. You need to change the original U-Boot parameter to `root=/dev/ram0 initrd=0x84000000,0x292e00`. - Kernel start - When the U-Boot starts the kernel, it can pass key information to the kernel through **bootargs**. The information varies according to the platform. The main fields are described in the table below. + When U-Boot starts the kernel, it can pass key information to the kernel through `bootargs`. The information varies according to the platform. The main fields are described in the table below. | Name | Example | Description | | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | @@ -151,53 +151,53 @@ On each development board, you need to partition the memory to store the precedi | init | /init | | | blkdevparts | mmcblk0:1M(boot),15M(kernel),200M(system),200M(vendor),
2M(misc),20M(updater),-(userdata) | Partition table information. The kernel creates physical partitions based on the information. | | hardware | Hi3516D V300, rk3568, etc. | (Mandatory information) Hardware platform.| - | root | /dev/ram0 (Hi3516D V00) , root=PARTUUID=614e0000-0000 rw (rk3568) | Boot device loaded by the kernel.| + | root | /dev/ram0 (Hi3516DV00), root=PARTUUID=614e0000-0000 rw (rk3568) | Boot device loaded by the kernel.| | rootfstype | ext4 | Type of the root file system.| - | default_boot_device | soc/10100000.himci.eMMC | (Recommended information) Default boot device. In the first phase of the boot process, a soft link will be created for the required device based on this field.| - | ohos.required_mount.xxx | /dev/block/platform/soc/10100000.himci.eMMC/by-name/xxx@/usr@ext4@ro,barrier=1@wait,required | The fstab information is first read from cmdline. If this fails, the system will try to read the information from the **fstab.required** file.| + | default_boot_device | soc/10100000.himci.eMMC | (Recommended information) Default boot device. In the first phase of the boot process, a soft link will be created for the `required` partition device based on this field.| + | ohos.required_mount.xxx | /dev/block/platform/soc/10100000.himci.eMMC/by-name/xxx@/usr@ext4@ro,barrier=1@wait,required | The fstab information is first read from cmdline. If this fails, the system will try to read the information from the `fstab.required` file.| -- Mounting of required partitions +- Mounting of `required` partitions - A required partition is one that is essential for system boot. It must be mounted before level-2 boot. For mandatory images like system and vendor images, the corresponding block device files must be created before mounting. This is usually done based on UEVENT events reported by the kernel. The init process needs to know the main device directory of the storage device. The bootloader passes the primary device directory of the storage device to the init process through **default_boot_device**. + A `required` partition is one that is essential for system boot. It must be mounted before level-2 boot. For mandatory images like system and vendor images, the corresponding block device files must be created before mounting. This is usually done based on the **uevent** messages reported by the kernel. The init process needs to know the main device directory of the storage device. The bootloader process passes the primary device directory of the storage device to the init process through `default_boot_device`. - Currently, the init process obtains required partition information in two ways. The init process first reads the required partition information through the **bootargs** in **/proc/cmdline**. If the attempt fails, the init process reads the **fstab.required** file in the ramdisk image. + Currently, the init process obtains `required` partition information in two ways. The init process first reads the `required` partition information through `bootargs` in `/proc/cmdline`. If the attempt fails, the init process reads the `fstab.required` file in the ramdisk image. - Logic of block device creation - Preparation - 1. The init process reads the required fstab information from **cmdline**. If the attempt fails, the init process reads the **fstab.required** file to obtain **PARTNAME** of the block devices that must be mounted, for example, **system** or **vendor**. - 2. Create a socket for receiving uevent messages reported by the kernel and read **default_boot_device** from **/proc/cmdline**. - 3. Traverse the **/sys/devices** directory with the fstab information and socket handle to get the kernel prepared for reporting uevent messages. + 1. The init process reads the `fstab.required` file from `cmdline`. If the attempt fails, the init process reads the `fstab.required` file to obtain `PARTNAME` of the block devices that must be mounted, for example, `system` or `vendor`. + 2. Create a socket for receiving **uevent** messages reported by the kernel and read `default_boot_device` from `/proc/cmdline`. + 3. Traverse the `/sys/devices` directory with the fstab information and socket handle to get the kernel prepared for reporting **uevent** messages. - - Event triggering + - Trigger event - 1. Use **ueventd** to trigger the kernel to report a uevent message. - 2. Check whether **partitionName** in the uevent message matches with device information in the required fstab. - 3. If they match, format the device node path and proceed with device node creation. + 1. Use **ueventd** to trigger the kernel to report a **uevent** message. + 2. Check whether `partitionName` in the **uevent** message matches with device information in the `fstab.required` file. + 3. If they match, format the device node path and proceed with device node creation. - - Device node creation + - Creating Nodes - 1. Format the path of the soft link to be created for required block device nodes. A soft link helps facilitate access to device nodes in user mode and improve their readability. - 2. Create device nodes based on the primary and secondary device numbers passed in the uevent message, and the device node path and soft link path obtained in the previous steps. Meanwhile, create a soft link for them. + 1. Format the path of the soft link to be created for required block device nodes. A soft link helps facilitate access to device nodes in user mode and improve their readability. + 2. Create device nodes based on the primary and secondary device numbers passed in the **uevent** message, and the device node path and soft link path obtained in the previous steps. Meanwhile, create a soft link for them. Up to now, the creation of block device nodes is complete. - - Mapping with **default_boot_device** + - Mapping with `default_boot_device` - The kernel writes **bootargs** information to **/proc/cmdline**. The information includes **default_boot_device**, which specifies the primary device directory required for system boot. The content prefixed with **ohos.required_mount.** is the partition mounting information required for system boot. It should be the same as that in the **fstab.required** file. In addition, the block device node in the partition mounting information should be a device node pointed by the soft link under **by-name** in the **default_boot_device** directory. For example, if the value of **default_boot_device** is **soc/10100000.himci.eMMC**, then the value of **ohos.required_mount.system** contains **/dev/block/platform/soc/10100000.himci.eMMC/by-name/system**, which is the soft link pointing to the system device node. + The kernel writes `bootargs` information to `/proc/cmdline`. The information includes `default_boot_device`, which specifies the primary device directory required for system boot. The content prefixed with `ohos.required_mount.` is the partition mounting information required for system boot. It should be the same as that in the `fstab.required` file. In addition, the block device node in the partition mounting information should be a device node pointed by the soft link under `by-name` in the `default_boot_device` directory. For example, if the value of `default_boot_device` is `soc/10100000.himci.eMMC`, then the value of `ohos.required_mount.system` contains `/dev/block/platform/soc/10100000.himci.eMMC/by-name/system`, which is the soft link pointing to the system device node. - During creation of a block device node, the device path will be matched against the value of **default_boot_device**. If the matching is successful, a soft link pointing to the real block device node will be created in **/dev/block/by-name**. In this way, device node access is made irrelevant to the chip platform. + During creation of a block device node, the device path will be matched against the value of `default_boot_device`. If the matching is successful, a soft link pointing to the real block device node will be created in `/dev/block/by-name`. In this way, device node access is made irrelevant to the chip platform. - Example - This example assumes the **system** partition as the required partition on the Hi3516D V300 platform to illustrate the boot process. During this process, the init process reads the required fstab information, creates a block device node, and mounts it to the required partition. The following provides the key code snippets and log information as reference for debugging. + This example assumes the `system` partition as the `required` partition on the Hi3516D V300 platform to illustrate the boot process. During this process, the init process reads the `fstab.required` file, creates a block device node, and mounts it to the `required` partition. The following provides the key code snippets and log information as reference for debugging. > **NOTE** - > + > > The code snippets below are exhibited in the logical sequence. They are not neighboring to each other in the source code. - 1. Obtain required device information. + 1. Obtain `required` partition device information. ``` Fstab* LoadRequiredFstab(void) { @@ -209,20 +209,20 @@ On each development board, you need to partition the memory to store the precedi if (access(fstabFile, F_OK) != 0) { fstabFile = "/system/etc/fstab.required"; } - INIT_ERROR_CHECK(access(fstabFile, F_OK) == 0, abort(), "Failed to get fstab.required"); + INIT_ERROR_CHECK(access(fstabFile, F_OK) == 0, abort(), "Failed get fstab.required"); fstab = ReadFstabFromFile(fstabFile, false); } return fstab; } ``` - The preceding code provides two methods for the init process to obtain the fstab information. First, the init process calls **LoadFstabFromCommandLine()** to read the fstab information from **cmdline**. If the attempt fails, the init process reads the **fstab.required** file to obtain the fstab information. + The preceding code provides two methods for the init process to obtain the fstab information. First, the init process calls `LoadFstabFromCommandLine()` to read the fstab information from `cmdline`. If the attempt fails, the init process outputs log information and continues to read the `fstab.required` file for the fstab information. - For the **system** partition, the key information read from **devices** is as follows: + For the `system` partition, the key information read from `devices` is as follows: ``` /dev/block/platform/fe310000.sdhci/by-name/system ``` - 2. Create a socket and trigger the kernel to report a uevent message. + 2. Create a socket and trigger the kernel to report a **uevent** message. ``` static int StartUeventd(char **requiredDevices, int num) { @@ -238,15 +238,15 @@ On each development board, you need to partition the memory to store the precedi } ``` - 3. Read information from **cmdline** to obtain **default_boot_device**. + 3. Read information from `cmdline` to obtain `default_boot_device`. ``` char *buffer = ReadFileData("/proc/cmdline"); int ret = GetProcCmdlineValue("default_boot_device", buffer, bootDevice, CMDLINE_VALUE_LEN_MAX); - INIT_CHECK_ONLY_ELOG(ret == 0, "Failed to get default_boot_device value from cmdline"); + INIT_CHECK_ONLY_ELOG(ret == 0, "Failed get default_boot_device value from cmdline"); ``` - In this example, the value of **default_boot_device** is **soc/10100000.himci.eMMC**. The value is stored in the global variable **bootDevice** and will be matched with the path of the **system** partition device when a soft link is created. + In this example, the value of `default_boot_device` is `soc/10100000.himci.eMMC`. The value is stored in the global variable `bootDevice` and will be matched with the path of the `system` partition device when a soft link is created. - 4. Process the uevent message of the required partition device. + 4. Process the **uevent** message of the `required` partition device. ``` if (uevent->partitionName == NULL) { INIT_LOGI("Match with %s for %s", devices[i], uevent->syspath); @@ -264,11 +264,11 @@ On each development board, you need to partition the memory to store the precedi break; } ``` - In this step, the device information in **devices** is matched with the uevent message reported by the kernel. The value of **uevent->partitionName** should be **system** for the uevent message of the **system** partition device. If the value matches the **/dev/block/platform/fe310000.sdhci/by-name/system** field in **devices**, the uevent message of the **system** partition device will be processed. + In this step, the device information in `devices` is matched with the **uevent** message reported by the kernel. The value of `uevent -> partitionName` should be `system` for the **uevent** message of the `system` partition device. If the value matches the `/dev/block/platform/fe310000.sdhci/by-name/system` field in `devices`, the **uevent** message of the `system` partition device will be processed. - 5. Create the required device node and the corresponding soft link. + 5. Create the `required` partition device node and the corresponding soft link. - The first thing is to format the path of the corresponding soft link. In this step, the value of **default_boot_device** in **bootargs** will be matched with the path of the required device node in the uevent message, so as to create a platform-irrelevant soft link that points to the device node. The key code is as follows: + The first thing is to format the path of the corresponding soft link. In this step, the value of `default_boot_device` in `bootargs` will be matched with the path of the required device node in the **uevent** message, so as to create a platform-irrelevant soft link that points to the device node. The key code is as follows: ``` if (STRINGEQUAL(bus, "/sys/bus/platform")) { INIT_LOGV("Find a platform device: %s", parent); @@ -285,29 +285,28 @@ On each development board, you need to partition the memory to store the precedi ``` The key variables in the code are as follows: - - **bus**: a string that saves the path of the bus connected to the current device. - - **parent**: a string that stores the device path obtained from **syspath** in the uevent message. - - **links**: a pointer to the memory that stores the soft link path. - - **bootDevice**: a string that stores the value of **default_boot_device** in **bootargs** - - According to the code, the corresponding soft link is created for the device only when the type of the connected bus is **platform**. The path of the soft link is as follows: + - `bus`: a string that saves the path of the bus connected to the current device. + - `parent`: a string that stores the device path obtained from `uevent -> syspath` in the **uevent** message. + - `links`: a pointer to the memory that stores the soft link path. + - `bootDevice`: a string that stores the value of `default_boot_device` in `bootargs`. + According to the code, the corresponding soft link is created for the device only when the type of the connected bus is `platform`. The path of the soft link is as follows: ``` /dev/block/platform/soc/10100000.himci.eMMC/by-name ``` - A platform-irrelevant soft link is created only when the device path matches that in **bootDevice**. + A platform-irrelevant soft link is created only when the device path matches that in `bootDevice`. For the **system** partition device, the path is as follows: ``` /sys/devices/platform/soc/10100000.himci.eMMC/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p5 ``` - Therefore, when processing the uevent message of the device, the init process compares the device path with that in **bootDevice**, that is, **soc/10100000.himci.eMMC**. If they match, a soft link will be created as follows: + Therefore, when processing the **uevent** message of the device, the init process compares the device path with that in `bootDevice`, that is, `soc/10100000.himci.eMMC`. If they match, a soft link will be created as follows: ``` /dev/block/by-name/system ``` - After the soft link path is formatted, the init process creates the device node and soft link based on the information in the uevent message. Up to now, the creation of a device node for the system partition is complete. + After the soft link path is formatted, the init process creates the device node and soft link based on the information in the **uevent** message. Up to now, the creation of a device node for the `system` partition is complete. - 6. Mount the required partition. + 6. Mount the `required` partition. After a device node is created, mount it to the corresponding partition. The code is as follows: ``` @@ -320,45 +319,47 @@ On each development board, you need to partition the memory to store the precedi return rc; } ``` - Therefore, when "Mount required partitions" is displayed, the required partition device is ready for mounting. During the mounting process, the following key information is printed: + Therefore, when "Mount required partitions" is displayed, the `required` partition device is ready for mounting. During the mounting process, the following key information is printed: ``` BEGET_LOGE("Unsupported file system \" %s \"", item->fsType); - // The current file system type is not supported. - + ``` + The current file system type is not supported. + ``` BEGET_LOGE("Cannot get stat of \" %s \", err = %d", target, errno); - // Failed to obtain the mount point directory. - + ``` + The attempt to obtain the mount point directory has failed. + ``` BEGET_LOGE("Failed to create dir \" %s \", err = %d", target, errno); - // Failed to create the mount point directory. - + ``` + The attempt to create the mount point directory has failed. + ``` BEGET_LOGI("Mount %s to %s successful", item->deviceName, item->mountPoint); - // The device is successfully mounted. The output also contains the name of the mounted device and information about the mount point. ``` + The device is successfully mounted. The output also contains the name of the mounted device and information about the mount point. +- Mounting of the `vendor` partition -- Mounting of vendor partitions - - After mounting required partitions, the init process scans each script file in the **vendor** partition. The initialization scripts related to the chip or development board are named in the format of **/vendor/etc/init.{ohos.boot.hardware}.cfg**. Wherein, **/vendor/etc/fstab.{ohos.boot.hardware}** represents the extended mount partition file; **hardware** is sourced from **bootargs**, which is passed from the bootloader to the kernel. +After mounting required partitions, the init process scans each script file in the `vendor` partition. The initialization scripts related to the chip or development board is named in the format of `/vendor/etc/init.{ohos.boot.hardware}.cfg`. Wherein, `/vendor/etc/fstab.{ohos.boot.hardware}` represents the extended mount partition file; `hardware` is sourced from `bootargs`, which is passed from the bootloader to the kernel. ### Boot Loading Without ramdisk -Certain development boards do not use the ramdisk boot mode. For these boards, the boot process is implemented by directly loading the **system.img** file through the kernel. In such case, you need to modify the product configuration file in **productdefine**. Specifically, you need to turn off the **enable_ramdisk** switch to disable ramdisk generation so that the init process does not boot from ramdisk to system. +Certain development boards do not use the ramdisk boot mode. For these boards, the boot process is implemented by directly loading the `system.img` file through the kernel. In such case, you need to modify the product configuration file in `productdefine`. Specifically, you need to turn off the `enable_ramdisk` switch to disable ramdisk generation so that the init process does not boot from ramdisk to system. -Boot loading in this scenario is similar to that in the preceding section. The only difference is as follows: If ramdisk is used, the init process mounts **system.img** to the **/usr** directory and then switches to the **/usr** directory using **chroot**. If ramdisk is not used, the init process directly runs the **init.cfg** file. +The boot loading process in this scenario is similar to that in the preceding section. The only difference is as follows: If ramdisk is used, the init process mounts `system.img` to the `/usr` directory and then switches to the `/usr` directory using `chroot`. If ramdisk is not used, the init process directly runs the `init.cfg` file. -For boot loading without ramdisk (that is, system as root), the block device where the root file system is located is passed to the kernel through **bootargs**, for example, **root=/dev/mmcblk0p5 and rootfstype=ext4**. During initialization of the root file system, the kernel parses the **root** field in **bootargs** to complete mounting of the root file system. +For the boot loading process without ramdisk, that is, system as root, the block device where the root file system is located is passed to the kernel through `bootargs`, for example, `root=/dev/mmcblk0p5, rootfstype=ext4`. During initialization of the root file system, the kernel parses the `root` field in `bootargs` to complete mounting of the root file system. ### Partition A/B Booting -Currently, OpenHarmony supports booting from partitions A and B (active and standby system partitions), both of which are configured in the same device storage. During the booting process, the system partition to load is determined based on the slot of the active partition. Partition A/B booting is supported only for the system partition and chipset partition. +Currently, OpenHarmony supports booting from partitions A and B (active and standby system partitions), both of which are configured in the same device storage. During the booting process, the system partition to load is determined based on the slot of the active partition. Partition A/B booting is supported only for the `system` and `chipset` partitions. - bootslots - Number of the supported boot partitions. If **bootslots** is set to **2**, the system can boot from both system partitions A and B. If **bootslots** is set to **1**, partition A/B booting is not supported and the system can boot only from the default system partition. + Number of the supported boot partitions. If `bootslots` is set to `2`, the system can boot from both system partitions A and B. If `bootslots` is set to `1`, partition A/B booting is not supported and the system can boot only from the default system partition. - In the initial phase of init process startup, the system reads the **bootslots** value to determine whether partition A/B booting is supported. If yes, the system continues to determine the system partition to mount. If not, the system mounts the system partition based on the default fstab. The API for the init process to obtain the **bootslots** value is as follows: + In the initial phase of init process startup, the system reads the `bootslots` value to determine whether partition A/B booting is supported. If yes, the system continues to determine the system partition to mount. If not, the system mounts the system partition based on the default fstab. The API for the init process to obtain the `bootslots` value is as follows: ``` int GetBootSlots(void) { @@ -368,16 +369,16 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan return GetSlotInfoFromCmdLine("bootslots"); } ``` - After normal system startup, you can obtain the **bootslots** value from the system parameter **ohos.boot.bootslots** to check whether the current system supports partition A/B booting. The command for obtaining **ohos.boot.bootslots** is as follows: + After normal system startup, you can obtain the `bootslots` value from the system parameter `ohos.boot.bootslots` to check whether the current system supports partition A/B booting. The command for obtaining `ohos.boot.bootslots` is as follows: ``` param get ohos.boot.bootslots ``` - currentslot - Current system partition, for example, partition A or partition B. The value of **currentslot** is a number. For example, **1** indicates partition A, and **2** indicates partition B. + Current system partition, for example, partition A or partition B. The value of `currentslot` is a number. For example, `1` indicates partition A, and `2` indicates partition B. - In the initial phase of startup, the init process determines whether the system supports partition A/B booting based on **bootslots**. If the system does not support partition A/B booting, the init process directly boots from the default system partition instead of obtaining the **currentslot** value. If the system supports partition A/B booting, the init process obtains the **currentslot** value and determines whether partition A or partition B is the current system partition. The API for the init process to obtain the **currentslot** value is as follows: + In the initial phase of startup, the init process determines whether the system supports partition A/B booting based on `bootslots`. If the system does not support partition A/B booting, the init process directly boots from the default system partition instead of obtaining the `currentslot` value. If the system supports partition A/B booting, the init process obtains the `currentslot` value and determines whether partition A or partition B is the current system partition. The API for the init process to obtain the `currentslot` value is as follows: ``` int GetCurrentSlot(void) { @@ -396,10 +397,10 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan } ``` -- Partition A/B booting process +- Partition A/B Booting Process - 1. Obtain the **currentslot** value to determine whether partition A or partition B is the current system partition. - 2. Construct new partition mounting configuration based on the original fstab file, and add the suffix **a** or **b** to the partitions that support partition A/B booting, that is, system and chipset partitions. + 1. Obtain the `currentslot` value to determine whether partition A or partition B is the current system partition. + 2. Construct new partition mounting configuration based on the original `fstab` file, and add the suffix `_a` or `_b` to the partitions that support partition A/B booting, that is, system and chipset partitions. 3. Mount the partition added with the corresponding suffix and enter the second phase of startup. This phase occurs in partition A or B and concludes the partition A/B booting process. The API for constructing new partition mounting configuration is as follows: @@ -420,7 +421,7 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan } ``` -- Development example +- Development Example The following uses the rk3568 platform as an example to illustrate how to change from default partition booting to partition A/B booting. @@ -429,50 +430,51 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan ![Original partition](figures/ABStartup_1.png) Use the original image to construct images of the partitions used for partition A/B booting, and test the partition A/B booting function. - - Copy the **system** and **vendor** images, and add the suffix **\_b** to them. - - Add partitions **system_b** and **vendor_b** to the partition table in **parameter.txt**. + - Copy the `system` and `vendor` images, and add the suffix `_b` to them. + - Add partitions `system_b` and `vendor_b` to the partition table in the `parameter.txt` file. 2. Burn the images of the partitions used for partition A/B booting. - - Import the partition configuration to the rk3568 burning tool, and select the **parameter.txt** file containing the **system_b** and **vendor_b** partitions. - - Select images (including **system_b** and **vendor_b** images) based on the new partition table configuration, and then burn the images. + - Import the partition configuration to the rk3568 burning tool, and select the `parameter.txt` file containing the `system_b` and `vendor_b` partitions. + - Select images (including `system_b` and `vendor_b` images) based on the new partition table configuration, and then burn the images. 3. After the configuration is complete, perform the following: - 1. Run the **cat /proc/cmdline** command. If the command output contains **bootslot=2**, the system supports partition A/B booting. + 1. Run the `cat /proc/cmdline` command. If the command output contains `bootslot=2`, the system supports partition A/B booting. ![cmdline](figures/ABStartup_2.png) - 2. Run the **param get ohos.boot.bootslot** command. If the command output contains **2**, the **bootslot** information is successfully written to the **parameter.txt**. + 2. Run the `param get ohos.boot.bootslot` command. If the command output contains `2`, the `bootslot` information is successfully written to the `parameter.txt` file. - 3. Run the **ls -l /dev/block/by-name** command. If the command output contains **system_b** and **vendor_b**, device nodes are successfully created in partition B. + 3. Run the `ls -l /dev/block/by-name` command. If the command output contains `system_b` and `vendor_b`, device nodes are successfully created in partition B. ![Device information](figures/ABStartup_3.png) - 4. Run the **df -h** command to check the partitions mounted to the system. + 4. Run the `df -h` command to check the partitions mounted to the system. ![Partition information](figures/ABStartup_4.png) - As shown in the figure, partition **mmcblk0p6** is mounted to the root file system (represented by a slash), and partition **mmcblk0p7** is mounted to **/vendor**. Based on the command output in step 3, **mmcblk0p6** is the **system** partition, and **mmcblk0p7** is the **vendor** partition. That is, the mounted partitions are the default partitions, that is, **system** and **vendor** partitions without suffixes. In other words, partition A is the default partition. + As shown in the figure, partition `mmcblk0p6` is mounted to the root file system (represented by a slash), and partition `mmcblk0p7` is mounted to `/vendor`. Based on the command output in step 3, `mmcblk0p6` is the `system` partition, and `mmcblk0p7` is the `vendor` partition. That is, the mounted partitions are the default partitions, that is, `system` and `vendor` partitions without suffixes. In other words, partition A is the default partition. Next, let's try booting from partition B. - 1) Run the **partitionslot setactive 2** command to set the slot of the active partition to **2**, that is, the slot of partition B. + 1. Run the `partitionslot setactive 2` command to set the slot of the active partition to `2`, that is, the slot of partition B. - ![Partition slot configuration](figures/ABStartup_5.png) + ![Partition slot configuration](figures/ABStartup_5.png) - 2) Run the **partitionslot getslot** command to check the configured slot. + 2. Run the `partitionslot getslot` command to check the configured slot. - ![View Slot](figures/ABStartup_6.png) + ![View Slot](figures/ABStartup_6.png) - If **current slot** is **2**, the slot of the active partition is successfully set to **2**. + If `current slot: 2` is `2`, the slot of the active partition is successfully set to `2`. - 3) Upon restarting, run the **df -h** command to check the partitions mounted to the system. - According to the command output, partition **mmcblk0p11** is mounted to the root file system, and partition **mmcblk0p12** is mounted to **/vendor**. + 3. Upon restarting, run the `df -h` command to check the partitions mounted to the system. + + According to the command output, partition `mmcblk0p11` is mounted to the root file system, and partition `mmcblk0p12` is mounted to `/vendor`. - ![Mounting information](figures/ABStartup_7.png) + ![Mounting information](figures/ABStartup_7.png) - 4) Run the **ls -l /dev/block/by-name** command again. + 4. Run the `ls -l /dev/block/by-name` command again. - ![New device information](figures/ABStartup_8.png) + ![New device information](figures/ABStartup_8.png) - **mmcblk0p11** corresponds to **system_b**, and **mmcblk0p12** corresponds to **vendor_b**. That is, the system is successfully booted from partition B. + `mmcblk0p11` corresponds to `system_b`, and `mmcblk0p12` corresponds to `vendor_b`. That is, the system is successfully booted from partition B. diff --git a/en/device-dev/subsystems/subsys-dfx-hidumper.md b/en/device-dev/subsystems/subsys-dfx-hidumper.md index bd1c46cdd2..6bbdda182b 100644 --- a/en/device-dev/subsystems/subsys-dfx-hidumper.md +++ b/en/device-dev/subsystems/subsys-dfx-hidumper.md @@ -191,3 +191,9 @@ The procedure is as follows: ``` hidumper -t [timeout] ``` + +19. Run the **hidumper --mem-smaps pid [-v]** command to obtain the detailed memory usage of the specified process. + + ``` + hidumper --mem-smaps pid [-v] + ``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-telephony.md b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-telephony.md new file mode 100644 index 0000000000..833cde00fc --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-telephony.md @@ -0,0 +1,121 @@ +# Telephony Subsystem Changelog + + + +## cl.telephony.1 SMS Module API Change + +Deprecated **sendMessage** and replaced it with **sendShortMessage**. + +**Change Impact** + +**sendMessage** is deprecated since API version 10. **sendShortMessage** should be used to replace **sendMessage** in application development. The API function remains unchanged. + +**Key API/Component Changes** + +API before change: + +```js +function sendMessage(options: SendMessageOptions): void; +``` + +API after change: + +```js +function sendShortMessage(options: SendMessageOptions, callback: AsyncCallback): void; +function sendShortMessage(options: SendMessageOptions): Promise; +``` + + + +**Adaptation Guide** + +Use the new API. The sample code is as follows: + +```js +let sendCallback = function (err, data) { + console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let deliveryCallback = function (err, data) { + console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let slotId = 0; +let content ='SMS message content'; +let destinationHost = '+861xxxxxxxxxx'; +let serviceCenter = '+861xxxxxxxxxx'; +let destinationPort = 1000; +let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; +sms.sendShortMessage(options, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +```js +let sendCallback = function (err, data) { + console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let deliveryCallback = function (err, data) { + console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let slotId = 0; +let content ='SMS message content'; +let destinationHost = '+861xxxxxxxxxx'; +let serviceCenter = '+861xxxxxxxxxx'; +let destinationPort = 1000; +let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; +let promise = sms.sendShortMessage(options); +promise.then(() => { + console.log(`sendShortMessage success`); +}).catch(err => { + console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`); +}); + +``` + +## cl.telephony.2 SIM Module API Change + +Changed the required permission of **getSimTelephoneNumber** from **ohos.permission.GET_TELEPHONY_STATE** to **ohos.permission.GET_PHONE_NUMBERS**. + +**Change Impact** + +The required permission of **getSimTelephoneNumber** is from **ohos.permission.GET_TELEPHONY_STATE** to **ohos.permission.GET_PHONE_NUMBERS** since API version 10. + +An application needs to be apply for the **ohos.permission.GET_PHONE_NUMBERS** permission. The API function remains unchanged. + +**Key API/Component Changes** + +API before change: + +```js + @permission ohos.permission.GET_TELEPHONY_STATE + function getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void; + + @permission ohos.permission.GET_TELEPHONY_STATE + function getSimTelephoneNumber(slotId: number): Promise; +``` + +API after change: + +```js + @permission ohos.permission.GET_PHONE_NUMBERS + function getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void; + + @permission ohos.permission.GET_PHONE_NUMBERS + function getSimTelephoneNumber(slotId: number): Promise; +``` + + + +**Adaptation Guide** + +Use the new API. + +In the **module.json** file, add the **ohos.permission.GET_PHONE_NUMBERS** permission or replace the existing permission with it. The sample code is as follows: + +```js +"requestPermissions" : [ + { + "name": "ohos.permission.GET_PHONE_NUMBERS", + "reason": "$string:GET_PHONE_NUMBERS" + } +] +``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-geoLocationManager.md b/en/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-geoLocationManager.md new file mode 100644 index 0000000000..17709f776a --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-geoLocationManager.md @@ -0,0 +1,36 @@ +# Location Subsystem Changelog + +## cl.location.1 Addition of APIs for Obtaining the Wi-Fi and Bluetooth Scanning Result + +APIs for obtaining the Wi-Fi and Bluetooth scanning result are added to **@ohos.geoLocationManager.d.ts**. They are all system APIs. + +**Change Impact** + +The system application can use the Wi-Fi and Bluetooth scanning result obtained by these APIs for network positioning. + +**Key API/Component Changes** + +| Class| API Type| Declaration| Change Type| +| -- | -- | -- | -- | +|geoLocationManager| method | function on(type: 'locatingRequiredDataChange', config: LocatingRequiredDataConfig, callback: Callback<Array<LocatingRequiredData>>): void; | Added| +|geoLocationManager| method | function off(type: 'locatingRequiredDataChange', callback?: Callback<Array<LocatingRequiredData>>): void; | Added| +|geoLocationManager| method | function getLocatingRequiredData(config: LocatingRequiredDataConfig): Promise<Array<LocatingRequiredData>>; | Added| + +**Adaptation Guide** + +The following example shows how to obtain Wi-Fi and Bluetooth scanning information at a time: + + ```ts + import geoLocationManager from '@ohos.geoLocationManager'; + let config = {'type': 1, 'needStartScan': true, 'scanInterval': 10000}; + try { + geoLocationManager.getLocatingRequiredData(config).then((result) => { + console.log('getLocatingRequiredData return: ' + JSON.stringify(result)); + }) + .catch((error) => { + console.log('promise, getLocatingRequiredData: error=' + JSON.stringify(error)); + }); + } catch (err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + } + ``` -- GitLab