提交 0fec7947 编写于 作者: W wangshuainan1 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nwangshuainan1 <wangshuainan1@huawei.com>
此差异已折叠。
...@@ -235,13 +235,13 @@ export default class MainAbility extends Ability { ...@@ -235,13 +235,13 @@ export default class MainAbility extends Ability {
For details, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md). For details, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md).
### Obtaining the Context on an eTS Page ### Obtaining the Context on an ArkTS Page
In the stage model, in the `onWindowStageCreate` lifecycle of an ability, you can call `SetUIContent` of `WindowStage` to load an eTS page. In some scenarios, you need to obtain the context on the page to call related APIs. In the stage model, in the `onWindowStageCreate` lifecycle of an ability, you can call `SetUIContent` of `WindowStage` to load an ArkTS page. In some scenarios, you need to obtain the context on the page to call related APIs.
**How to Obtain** **How to Obtain**
Use the API described in the table below to obtain the context associated with an eTS page. Use the API described in the table below to obtain the context associated with an ArkTS page.
| API | Description | | API | Description |
| :------------------------------------ | :--------------------------- | | :------------------------------------ | :--------------------------- |
......
...@@ -92,7 +92,7 @@ After the preceding code is executed, the **startAbility()** API is called to st ...@@ -92,7 +92,7 @@ After the preceding code is executed, the **startAbility()** API is called to st
- If the Service ability is not running, the system calls **onStart()** to initialize the Service ability, and then calls **onCommand()** on the Service ability. - If the Service ability is not running, the system calls **onStart()** to initialize the Service ability, and then calls **onCommand()** on the Service ability.
- If the Service ability is running, the system directly calls **onCommand()** on the Service ability. - If the Service ability is running, the system directly calls **onCommand()** on the Service ability.
The following code snippet shows how to start a Service ability running on the remote device. For details about **getRemoteDeviceId()**, see [Connecting to a Remote Service Ability](#connecting-to-a-remote-service-ability-applying-only-to-system-applications). The following code snippet shows how to start a Service ability running on the remote device. For details about **getRemoteDeviceId()**, see [Connecting to a Remote Service Ability](#connecting-to-a-remote-service-ability).
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
......
...@@ -12,7 +12,7 @@ To use related APIs, you must declare the **ohos.permission.INTERNET** permissio ...@@ -12,7 +12,7 @@ To use related APIs, you must declare the **ohos.permission.INTERNET** permissio
For details about how to apply for permissions, see [Access Control Development](../security/accesstoken-guidelines.md). For details about how to apply for permissions, see [Access Control Development](../security/accesstoken-guidelines.md).
The following table describes the related APIs. The following table provides only a simple description of the related APIs. For details, see [API Reference](../reference/apis/js-apis-http.md).
| API | Description | | API | Description |
| ----------------------------------------- | --------------------------------------------------------- | | ----------------------------------------- | --------------------------------------------------------- |
......
...@@ -15,15 +15,18 @@ Your application can call location-specific APIs to obtain the location informat ...@@ -15,15 +15,18 @@ Your application can call location-specific APIs to obtain the location informat
Location awareness helps determine where a mobile device locates. The system identifies the location of a mobile device with its coordinates, and uses location technologies such as Global Navigation Satellite System (GNSS) and network positioning (for example, base station positioning or WLAN/Bluetooth positioning) to provide diverse location-based services. These advanced location technologies make it possible to obtain the accurate location of the mobile device, regardless of whether it is indoors or outdoors. Location awareness helps determine where a mobile device locates. The system identifies the location of a mobile device with its coordinates, and uses location technologies such as Global Navigation Satellite System (GNSS) and network positioning (for example, base station positioning or WLAN/Bluetooth positioning) to provide diverse location-based services. These advanced location technologies make it possible to obtain the accurate location of the mobile device, regardless of whether it is indoors or outdoors.
- **Coordinate** - **Coordinate**
A coordinate describes a location on the earth using the longitude and latitude in reference to the World Geodetic Coordinate System 1984. A coordinate describes a location on the earth using the longitude and latitude in reference to the World Geodetic Coordinate System 1984.
- **GNSS positioning** - **GNSS positioning**
GNSS positioning locates a mobile device by using the location algorithm offered by the device chip to compute the location information provided by the Global Navigation Satellite System, for example, GPS, GLONASS, BeiDou, and Galileo. Whichever positioning system will be used during the location process depends on a hardware capability of the device. GNSS positioning locates a mobile device by using the location algorithm offered by the device chip to compute the location information provided by the Global Navigation Satellite System, for example, GPS, GLONASS, BeiDou, and Galileo. Whichever positioning system will be used during the location process depends on a hardware capability of the device.
- **Base station positioning** - **Base station positioning**
Base station positioning estimates the current location of a mobile device based on the location of the resident base station in reference to the neighboring base stations. This technology provides only a low accuracy and requires access to the cellular network. Base station positioning estimates the current location of a mobile device based on the location of the resident base station in reference to the neighboring base stations. This technology provides only a low accuracy and requires access to the cellular network.
- **WLAN or Bluetooth positioning** - **WLAN or Bluetooth positioning**
WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A high density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network. WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A high density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## When to Use ## When to Use
The sample server provides a package search server for checking update packages and obtaining the update package download URLs, which was previously unavailable in the real-world update service. The sample server supports update service testing and secondary development function verification, building an end-to-end environment to cater for diverse update service use cases. The sample server provides a package search server for checking update packages and obtaining the update package download URLs, which was previously unavailable in the real-world update service. The sample server supports update service testing and functional verification for secondary development, building an end-to-end environment to cater for diverse update service use cases.
## How to Develop ## How to Develop
...@@ -14,8 +14,6 @@ The sample server provides a package search server for checking update packages ...@@ -14,8 +14,6 @@ The sample server provides a package search server for checking update packages
openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem -x509 -days 365 -out serverCert.cer -subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=hijk/emailAddress=test.com" openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem -x509 -days 365 -out serverCert.cer -subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=hijk/emailAddress=test.com"
``` ```
2. Modify the **bundle.json** file. 2. Modify the **bundle.json** file.
Add **sub_component** to the **build** field. Add **sub_component** to the **build** field.
...@@ -32,13 +30,13 @@ The sample server provides a package search server for checking update packages ...@@ -32,13 +30,13 @@ The sample server provides a package search server for checking update packages
Go to the **update_updateservice** directory and run the following commands to create a code directory: Go to the **update_updateservice** directory and run the following commands to create a code directory:
``` ```
mkdir server_sample // Create the server_sample folder. mkdir server_sample // Create the server_sample folder.
touch server_sample/BUILD.gn // Create the BUILD.gn file. touch server_sample/BUILD.gn // Create the BUILD.gn file.
mkdir server_sample/include // Create the include folder to store the header file of the sample server. mkdir server_sample/include // Create the include folder to store the header file of the sample server.
touch server_process.h // Create the server_process.h header file. touch server_process.h // Create the server_process.h header file.
mkdir server_sample/src // Create the src folder to store the C/C++ files of the sample server. mkdir server_sample/src // Create the src folder to store the C/C++ files of the sample server.
touch server_sample/src/server_process.c // Create the server_process.c file. touch server_sample/src/server_process.c // Create the server_process.c file.
touch server_sample/src/main.cpp // Create the main.cpp file. touch server_sample/src/main.cpp // Create the main.cpp file.
``` ```
4. Write the **BUILD.gn** file. 4. Write the **BUILD.gn** file.
......
...@@ -38,7 +38,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -38,7 +38,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
// Import the USB API package. // Import the USB API package.
import usb from '@ohos.usb'; import usb from '@ohos.usb';
// Obtain the USB device list. // Obtain the USB device list.
var deviceList = usb.getDevices(); let deviceList = usb.getDevices();
/* /*
Example deviceList structure Example deviceList structure
[ [
...@@ -81,21 +81,21 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -81,21 +81,21 @@ You can set a USB device as the USB host to connect to other USB devices for dat
number: 1, number: 1,
type: 3, type: 3,
interfaceId: 0, interfaceId: 0,
}, }
], ]
}, }
], ]
}, }
], ]
}, }
], ]
*/ */
``` ```
2. Obtain the device operation permissions. 2. Obtain the device operation permissions.
```js ```js
var deviceName = deviceList[0].name; let deviceName = deviceList[0].name;
// Request the permissions to operate a specified device. // Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => { usb.requestRight(deviceName).then(hasRight => {
console.info("usb device request right result: " + hasRight); console.info("usb device request right result: " + hasRight);
...@@ -108,7 +108,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -108,7 +108,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
```js ```js
// Open the device, and obtain the USB device pipe for data transfer. // Open the device, and obtain the USB device pipe for data transfer.
var pipe = usb.connectDevice(deviceList[0]); let pipe = usb.connectDevice(deviceList[0]);
/* /*
Claim the corresponding interface from deviceList. Claim the corresponding interface from deviceList.
interface1 must be one present in the device configuration. interface1 must be one present in the device configuration.
...@@ -127,7 +127,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -127,7 +127,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) { if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength); console.info("usb readData result Length : " + dataLength);
var resultStr = this.ab2str(dataUint8Array); // Convert uint8 data into a string. let resultStr = this.ab2str(dataUint8Array); // Convert uint8 data into a string.
console.info("usb readData buffer : " + resultStr); console.info("usb readData buffer : " + resultStr);
} else { } else {
console.info("usb readData failed : " + dataLength); console.info("usb readData failed : " + dataLength);
......
...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai ...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai
**Table 1** APIs for application event logging **Table 1** APIs for application event logging
| API | Description | | API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ---------------------------------------------------- |
| write(string eventName, EventType type, object keyValues, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result. | | write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(string eventName, EventType type, object keyValues): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. | | write(AppEventInfo info): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. |
| write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events by domain in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(AppEventInfo info): Promise\<void> | Logs application events by domain in asynchronous mode. This API uses a promise to return the result.|
When an asynchronous callback is used, the return value can be processed directly in the callback. When an asynchronous callback is used, the return value can be processed directly in the callback.
...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("1 writeTest").onClick(()=>{ Button("1 writeTest").onClick(()=>{
// Perform event logging based on the input event parameters.
hiAppEvent.write({ hiAppEvent.write({
domain: "test_domain", domain: "test_domain",
name: "test_event", name: "test_event",
...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("2 addWatcherTest").onClick(()=>{ Button("2 addWatcherTest").onClick(()=>{
// Add an event watcher based on the input subscription parameters.
hiAppEvent.addWatcher({ hiAppEvent.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [{ domain: "test_domain" }], appEventFilters: [{ domain: "test_domain" }],
...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve
timeOut: 2 timeOut: 2
}, },
onTrigger: function (curRow, curSize, holder) { onTrigger: function (curRow, curSize, holder) {
// If the holder object is null, return an error after recording it in the log.
if (holder == null) { if (holder == null) {
console.error("HiAppEvent holder is null"); console.error("HiAppEvent holder is null");
return; return;
} }
// Set the size threshold to 1,000 bytes for obtaining an event package.
holder.setSize(1000);
let eventPkg = null; let eventPkg = null;
// Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained.
while ((eventPkg = holder.takeNext()) != null) { while ((eventPkg = holder.takeNext()) != null) {
console.info("HiAppEvent eventPkg.packageId=" + eventPkg.packageId); // Parse the obtained event package and display the result on the Log page.
console.info("HiAppEvent eventPkg.row=" + eventPkg.row); console.info('HiAppEvent eventPkg.packageId=' + eventPkg.packageId);
console.info("HiAppEvent eventPkg.size=" + eventPkg.size); console.info('HiAppEvent eventPkg.row=' + eventPkg.row);
console.info('HiAppEvent eventPkg.size=' + eventPkg.size);
// Traverse and parse event string arrays in the obtained event package.
for (const eventInfo of eventPkg.data) { for (const eventInfo of eventPkg.data) {
console.info("HiAppEvent eventPkg.data=" + eventInfo); console.info('HiAppEvent eventPkg.data=' + eventInfo);
} }
} }
} }
...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("3 removeWatcherTest").onClick(()=>{ Button("3 removeWatcherTest").onClick(()=>{
// Remove the specified event watcher.
hiAppEvent.removeWatcher({ hiAppEvent.removeWatcher({
name: "watcher1" name: "watcher1"
}) })
......
# FAQs # FAQs
- [Ability Framework Development](faqs-ability.md) - [Ability Framework Development](faqs-ability.md)
- [Data Management Development](faqs-data-management.md)
- [File Management Development](faqs-file-management.md)
- [Graphics and Image Development](faqs-graphics.md)
- [hdc_std Command Usage](faqs-ide.md)
- [IDE Usage](faqs-hdc-std.md)
- [ArkUI (JavaScript) Development](faqs-ui-js.md) - [ArkUI (JavaScript) Development](faqs-ui-js.md)
- [ArkUI (eTS) Development](faqs-ui-ets.md) - [ArkUI (eTS) Development](faqs-ui-ets.md)
- [Graphics and Image Development](faqs-graphics.md) - [Graphics and Image Development](faqs-graphics.md)
- [File Management Development](faqs-file-management.md) - [File Management Development](faqs-file-management.md)
- [Network and Connection Development](faqs-connectivity.md)
- [Data Management Development](faqs-data-management.md) - [Data Management Development](faqs-data-management.md)
- [Device Management Development](faqs-device-management.md) - [Device Management Development](faqs-device-management.md)
- [Native API Usage](faqs-native.md) - [Native API Usage](faqs-native.md)
- [Network and Connection Development](faqs-connectivity.md)
- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md) - [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md)
- [hdc_std Command Usage](faqs-ide.md)
- [IDE Usage](faqs-hdc-std.md)
- [Development Board](faqs-development-board.md) - [Development Board](faqs-development-board.md)
...@@ -19,7 +19,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 ...@@ -19,7 +19,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
Error code 28 refers to **CURLE_OPERATION_TIMEDOUT**, which means a libcurl library operation timeout. For details, see any HTTP status code description available. Error code 28 refers to **CURLE_OPERATION_TIMEDOUT**, which means a cURL operation timeout. For details, see any HTTP status code description available.
Reference: [Development Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-http.md#httpresponse) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html) Reference: [Development Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-http.md#httpresponse) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html)
......
...@@ -9,15 +9,15 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -9,15 +9,15 @@ You can use APIs provided in the following table to obtain the system language a
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.i18n | getSystemLanguage(): string | Obtains the system language. | | ohos.i18n | getSystemLanguage(): string | Obtains the system language. |
| ohos.i18n | getSystemRegion(): string | Obtains the system region. | | ohos.i18n | getSystemRegion(): string | Obtains the system region. |
| ohos.i18n | getSystemLocale(): string | Obtains the system locale. | | ohos.i18n | getSystemLocale(): string | Obtains the system locale. |
| ohos.i18n | isRTL(locale: string): boolean<sup>7+</sup> | Checks whether the locale uses a right-to-left (RTL) language. | | ohos.i18n | isRTL(locale: string): boolean<sup>7+</sup> | Checks whether the locale uses a right-to-left (RTL) language. |
| ohos.i18n | is24HourClock(): boolean<sup>7+</sup> | Checks whether the system uses a 24-hour clock. | | ohos.i18n | is24HourClock(): boolean<sup>7+</sup> | Checks whether the system uses a 24-hour clock. |
| ohos.i18n | getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a language. | | ohos.i18n | getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a language. |
| ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a country name. | | ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a country name. |
### How to Develop ### How to Develop
...@@ -26,7 +26,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -26,7 +26,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module). Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module).
```js ```js
var language = i18n.getSystemLanguage(); var language = i18n.getSystemLanguage();
``` ```
...@@ -42,7 +42,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -42,7 +42,7 @@ You can use APIs provided in the following table to obtain the system language a
3. Obtain the system locale. 3. Obtain the system locale.
Call the **getSystemLocale** method to obtain the system locale. Call the **getSystemLocale** method to obtain the system locale.
```js ```js
var locale = i18n.getSystemLocale(); var locale = i18n.getSystemLocale();
``` ```
...@@ -51,7 +51,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -51,7 +51,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **isRTL** method to check whether the locale's language is RTL. Call the **isRTL** method to check whether the locale's language is RTL.
```js ```js
var rtl = i18n.isRTL("zh-CN"); var rtl = i18n.isRTL("zh-CN");
``` ```
...@@ -67,7 +67,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -67,7 +67,7 @@ You can use APIs provided in the following table to obtain the system language a
6. Obtain the localized display of a language. 6. Obtain the localized display of a language.
Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
```js ```js
var language = "en"; var language = "en";
var locale = "zh-CN"; var locale = "zh-CN";
...@@ -78,7 +78,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -78,7 +78,7 @@ You can use APIs provided in the following table to obtain the system language a
7. Obtain the localized display of a country. 7. Obtain the localized display of a country.
Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
```js ```js
var country = "US"; var country = "US";
var locale = "zh-CN"; var locale = "zh-CN";
...@@ -116,7 +116,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -116,7 +116,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used. Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used.
```js ```js
var calendar = i18n.getCalendar("zh-CN", "gregory"); var calendar = i18n.getCalendar("zh-CN", "gregory");
``` ```
...@@ -135,7 +135,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -135,7 +135,7 @@ You can use APIs provided in the following table to obtain the system language a
3. Set the year, month, day, hour, minute, and second for the **Calendar** object. 3. Set the year, month, day, hour, minute, and second for the **Calendar** object.
Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object.
```js ```js
calendar.set(2021, 12, 21, 6, 0, 0) calendar.set(2021, 12, 21, 6, 0, 0)
``` ```
...@@ -144,7 +144,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -144,7 +144,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set. Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set.
```js ```js
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
var timezone = calendar.getTimeZone(); var timezone = calendar.getTimeZone();
...@@ -163,7 +163,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -163,7 +163,7 @@ You can use APIs provided in the following table to obtain the system language a
6. Set and obtain the minimum count of days in the first week for the **Calendar** object. 6. Set and obtain the minimum count of days in the first week for the **Calendar** object.
Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object.
```js ```js
calendar.setMinimalDaysInFirstWeek(3); calendar.setMinimalDaysInFirstWeek(3);
var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
...@@ -173,7 +173,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -173,7 +173,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **getDisplayName** method to obtain the localized display of the **Calendar** object. Call the **getDisplayName** method to obtain the localized display of the **Calendar** object.
```js ```js
var localizedName = calendar.getDisplayName("zh-CN"); var localizedName = calendar.getDisplayName("zh-CN");
``` ```
...@@ -196,11 +196,11 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -196,11 +196,11 @@ You can use APIs provided in the following table to obtain the system language a
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)<sup>8+</sup> | Instantiates a **PhoneNumberFormat** object. | | ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)<sup>8+</sup> | Instantiates a **PhoneNumberFormat** object. |
| ohos.i18n | isValidNumber(number: string): boolean<sup>8+</sup> | Checks whether the value of **number** is a phone number in the correct format. | | ohos.i18n | isValidNumber(number: string): boolean<sup>8+</sup> | Checks whether the value of **number** is a phone number in the correct format. |
| ohos.i18n | format(number: string): string<sup>8+</sup> | Formats the value of **number** based on the specified country and style. | | ohos.i18n | format(number: string): string<sup>8+</sup> | Formats the value of **number** based on the specified country and style. |
### How to Develop ### How to Develop
...@@ -209,7 +209,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -209,7 +209,7 @@ You can use APIs provided in the following table to obtain the system language a
Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**. Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**.
```js ```js
var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"}); var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"});
``` ```
...@@ -223,7 +223,7 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -223,7 +223,7 @@ You can use APIs provided in the following table to obtain the system language a
3. Format a phone number. 3. Format a phone number.
Call the **format** method of **PhoneNumberFormat** to format the input phone number. Call the **format** method of **PhoneNumberFormat** to format the input phone number.
```js ```js
var formattedNumber = phoneNumberFormat.format("15812341234"); var formattedNumber = phoneNumberFormat.format("15812341234");
``` ```
...@@ -236,15 +236,15 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -236,15 +236,15 @@ The **unitConvert** API is provided to help you implement measurement conversion
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.i18n | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string<sup>8+</sup> | Converts one measurement unit (**fromUnit**) into another (**toUnit**) and formats the unit based on the specified locale and style. | | ohos.i18n | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string<sup>8+</sup> | Converts one measurement unit (**fromUnit**) into another (**toUnit**) and formats the unit based on the specified locale and style. |
### How to Develop ### How to Develop
1. Convert a measurement unit. 1. Convert a measurement unit.
Call the [unitConvert](../reference/apis/js-apis-i18n.md#unitconvert8) method to convert a measurement unit and format the display result. Call the [unitConvert](../reference/apis/js-apis-i18n.md#unitconvert9) method to convert a measurement unit and format the display result.
```js ```js
...@@ -254,7 +254,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -254,7 +254,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
var locale = "en-US"; var locale = "en-US";
var style = "long"; var style = "long";
i18n.Util.unitConvert(fromUtil, toUtil, number, locale, style); i18n.Util.unitConvert(fromUtil, toUtil, number, locale, style);
``` ```
## Alphabet Index ## Alphabet Index
...@@ -278,7 +278,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -278,7 +278,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale. Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale.
```js ```js
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
``` ```
...@@ -294,7 +294,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -294,7 +294,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
3. Add an index. 3. Add an index.
Call the **addLocale** method to add the alphabet index of a new locale to the current index list. Call the **addLocale** method to add the alphabet index of a new locale to the current index list.
```js ```js
indexUtil.addLocale("ar") indexUtil.addLocale("ar")
``` ```
...@@ -302,7 +302,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -302,7 +302,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
4. Obtain the index of a string. 4. Obtain the index of a string.
Call the **getIndex** method to obtain the alphabet index of a string. Call the **getIndex** method to obtain the alphabet index of a string.
```js ```js
var text = "access index"; var text = "access index";
indexUtil.getIndex(text); indexUtil.getIndex(text);
...@@ -336,7 +336,7 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap ...@@ -336,7 +336,7 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap
Call the **getLineInstance** method to instantiate a **BreakIterator** object. Call the **getLineInstance** method to instantiate a **BreakIterator** object.
```js ```js
var locale = "en-US" var locale = "en-US"
var breakIterator = i18n.getLineInstance(locale); var breakIterator = i18n.getLineInstance(locale);
...@@ -357,7 +357,7 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap ...@@ -357,7 +357,7 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap
Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed. Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed.
```js ```js
var pos = breakIterator.current(); var pos = breakIterator.current();
``` ```
...@@ -383,7 +383,9 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap ...@@ -383,7 +383,9 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap
Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position. Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position.
```js ```js
var isboundary = breakIterator.isBoundary(5); var isboundary = breakIterator.isBoundary(5);
``` ```
```
\ No newline at end of file
...@@ -13,13 +13,13 @@ Use [Locale](../reference/apis/js-apis-intl.md#locale) APIs to maximize or minim ...@@ -13,13 +13,13 @@ Use [Locale](../reference/apis/js-apis-intl.md#locale) APIs to maximize or minim
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Instantiates a **Locale** object. | | ohos.intl | constructor()<sup>8+</sup> | Instantiates a **Locale** object. |
| ohos.intl | constructor(locale?: string, options?: options) | Instantiates a **Locale** object based on the locale parameter and options. | | ohos.intl | constructor(locale?: string, options?: options) | Instantiates a **Locale** object based on the locale parameter and options. |
| ohos.intl | toString(): string | Converts locale information into a string. | | ohos.intl | toString(): string | Converts locale information into a string. |
| ohos.intl | maximize(): Locale | Maximizes locale information. | | ohos.intl | maximize(): Locale | Maximizes locale information. |
| ohos.intl | minimize(): Locale | Minimizes locale information. | | ohos.intl | minimize(): Locale | Minimizes locale information. |
### How to Develop ### How to Develop
...@@ -81,13 +81,13 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md#datetimeformat) APIs to f ...@@ -81,13 +81,13 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md#datetimeformat) APIs to f
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Creates a **DateTimeFormat** object. | | ohos.intl | constructor()<sup>8+</sup> | Creates a **DateTimeFormat** object. |
| ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: DateTimeOptions) | Creates a **DateTimeFormat** object and sets the locale and other formatting-related attributes. | | ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: DateTimeOptions) | Creates a **DateTimeFormat** object and sets the locale and other formatting-related attributes. |
| ohos.intl | format(date: Date): string | Calculates the date and time based on the locale and other formatting-related attributes of the **DateTimeFormat** object. | | ohos.intl | format(date: Date): string | Calculates the date and time based on the locale and other formatting-related attributes of the **DateTimeFormat** object. |
| ohos.intl | formatRange(startDate: Date, endDate: Date): string | Calculates the period based on the locale and other formatting-related attributes of the **DateTimeFormat** object. | | ohos.intl | formatRange(startDate: Date, endDate: Date): string | Calculates the period based on the locale and other formatting-related attributes of the **DateTimeFormat** object. |
| ohos.intl | resolvedOptions(): DateTimeOptions | Obtains the related attributes of the **DateTimeFormat** object. | | ohos.intl | resolvedOptions(): DateTimeOptions | Obtains the related attributes of the **DateTimeFormat** object. |
### How to Develop ### How to Develop
...@@ -144,12 +144,12 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md#numberformat) APIs to forma ...@@ -144,12 +144,12 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md#numberformat) APIs to forma
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Creates a **NumberFormat** object. | | ohos.intl | constructor()<sup>8+</sup> | Creates a **NumberFormat** object. |
| ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: NumberOptions) | Creates a **NumberFormat** object and sets the locale and other formatting-related attributes. | | ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: NumberOptions) | Creates a **NumberFormat** object and sets the locale and other formatting-related attributes. |
| ohos.intl | format(number: number): string | Calculates the number based on the locale and other formatting-related attributes of the **NumberFormat** object. | | ohos.intl | format(number: number): string | Calculates the number based on the locale and other formatting-related attributes of the **NumberFormat** object. |
| ohos.intl | resolvedOptions(): NumberOptions | Obtains attributes of the **NumberFormat** object. | | ohos.intl | resolvedOptions(): NumberOptions | Obtains attributes of the **NumberFormat** object. |
### How to Develop ### How to Develop
...@@ -195,12 +195,12 @@ Use [Collator](../reference/apis/js-apis-intl.md#collator8) APIs to sort strings ...@@ -195,12 +195,12 @@ Use [Collator](../reference/apis/js-apis-intl.md#collator8) APIs to sort strings
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Creates a **Collator** object. | | ohos.intl | constructor()<sup>8+</sup> | Creates a **Collator** object. |
| ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: CollatorOptions)<sup>8+</sup> | Creates a **Collator** object and sets the locale and other related attributes. | | ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: CollatorOptions)<sup>8+</sup> | Creates a **Collator** object and sets the locale and other related attributes. |
| ohos.intl | compare(first: string, second: string): number<sup>8+</sup> | Calculates the comparison result of two strings based on the locale and other attributes of the **Collator** object. | | ohos.intl | compare(first: string, second: string): number<sup>8+</sup> | Calculates the comparison result of two strings based on the locale and other attributes of the **Collator** object. |
| ohos.intl | resolvedOptions(): CollatorOptions<sup>8+</sup> | Obtains attributes of the **Collator** object. | | ohos.intl | resolvedOptions(): CollatorOptions<sup>8+</sup> | Obtains attributes of the **Collator** object. |
### How to Develop ### How to Develop
...@@ -214,7 +214,7 @@ Use [Collator](../reference/apis/js-apis-intl.md#collator8) APIs to sort strings ...@@ -214,7 +214,7 @@ Use [Collator](../reference/apis/js-apis-intl.md#collator8) APIs to sort strings
var collator = new intl.Collator(); var collator = new intl.Collator();
``` ```
Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8). Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9).
```js ```js
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}); var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"});
...@@ -246,11 +246,11 @@ Use [PluralRules](../reference/apis/js-apis-intl.md#pluralrules8) APIs to determ ...@@ -246,11 +246,11 @@ Use [PluralRules](../reference/apis/js-apis-intl.md#pluralrules8) APIs to determ
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Creates a **PluralRules** object. | | ohos.intl | constructor()<sup>8+</sup> | Creates a **PluralRules** object. |
| ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: PluralRulesOptions)<sup>8+</sup> | Creates a **PluralRules** object and sets the locale and other related attributes. | | ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: PluralRulesOptions)<sup>8+</sup> | Creates a **PluralRules** object and sets the locale and other related attributes. |
| ohos.intl | select(n: number): string<sup>8+</sup> | Determines the singular-plural type based on the locale and other formatting-related attributes of the **PluralRules** object. | | ohos.intl | select(n: number): string<sup>8+</sup> | Determines the singular-plural type based on the locale and other formatting-related attributes of the **PluralRules** object. |
### How to Develop ### How to Develop
...@@ -264,7 +264,7 @@ Use [PluralRules](../reference/apis/js-apis-intl.md#pluralrules8) APIs to determ ...@@ -264,7 +264,7 @@ Use [PluralRules](../reference/apis/js-apis-intl.md#pluralrules8) APIs to determ
var pluralRules = new intl.PluralRules(); var pluralRules = new intl.PluralRules();
``` ```
Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8). Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9).
```js ```js
var pluralRules = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); var pluralRules = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
...@@ -287,13 +287,13 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8) ...@@ -287,13 +287,13 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8)
### Available APIs ### Available APIs
| Module | API | Description | | Module | API | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.intl | constructor()<sup>8+</sup> | Creates a **RelativeTimeFormat** object. | | ohos.intl | constructor()<sup>8+</sup> | Creates a **RelativeTimeFormat** object. |
| ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions)<sup>8+</sup> | Creates a **RelativeTimeFormat** object and sets the locale and other formatting-related attributes. | | ohos.intl | constructor(locale: string \| Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions)<sup>8+</sup> | Creates a **RelativeTimeFormat** object and sets the locale and other formatting-related attributes. |
| ohos.intl | format(value: number, unit: string): string<sup>8+</sup> | Calculates the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | | ohos.intl | format(value: number, unit: string): string<sup>8+</sup> | Calculates the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. |
| ohos.intl | formatToParts(value: number, unit: string): Array&lt;object&gt;<sup>8+</sup> | Returns each part of the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | | ohos.intl | formatToParts(value: number, unit: string): Array&lt;object&gt;<sup>8+</sup> | Returns each part of the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. |
| ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions<sup>8+</sup> | Obtains attributes of the **RelativeTimeFormat** object. | | ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions<sup>8+</sup> | Obtains attributes of the **RelativeTimeFormat** object. |
### How to Develop ### How to Develop
...@@ -307,7 +307,7 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8) ...@@ -307,7 +307,7 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8)
var relativeTimeFormat = new intl.RelativeTimeFormat(); var relativeTimeFormat = new intl.RelativeTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8). Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9).
```js ```js
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
- [Drawing Development](drawing-guidelines.md) - [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md) - [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md) - [Native Window Development](native-window-guidelines.md)
- [Using MindSpore Lite for Model Inference](native-window-guidelines.md)
# Using MindSpore Lite for Model Inference
## When to Use
MindSpore Lite is an AI engine that provides AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition.
This document describes the general development process for MindSpore Lite model inference.
## Basic Concepts
Before getting started, you need to understand the following basic concepts:
**Tensor**: a special data structure that is similar to arrays and matrices. It is a basic data structure used in MindSpore Lite network operations.
**Float16 inference**: a mode in which Float16 is used for inference. Float16, also called half-precision, uses 16 bits to represent a number.
## Available APIs
APIs involved in MindSpore Lite model inference are categorized into context APIs, model APIs, and tensor APIs.
### Context APIs
| API | Description |
| ------------------ | ----------------- |
|OH_AI_ContextHandle OH_AI_ContextCreate()|Creates a context object.|
|void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num)|Sets the number of runtime threads.|
| void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode)|Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency.|
|OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type)|Creates a runtime device information object.|
|void OH_AI_ContextDestroy(OH_AI_ContextHandle *context)|Destroys a context object.|
|void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16)|Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.|
|void OH_AI_ContextAddDeviceInfo(OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info)|Adds a runtime device information object.|
### Model APIs
| API | Description |
| ------------------ | ----------------- |
|OH_AI_ModelHandle OH_AI_ModelCreate()|Creates a model object.|
|OH_AI_Status OH_AI_ModelBuildFromFile(OH_AI_ModelHandle model, const char *model_path,OH_AI_ModelType odel_type, const OH_AI_ContextHandle model_context)|Loads and builds a MindSpore model from a model file.|
|void OH_AI_ModelDestroy(OH_AI_ModelHandle *model)|Destroys a model object.|
### Tensor APIs
| API | Description |
| ------------------ | ----------------- |
|OH_AI_TensorHandleArray OH_AI_ModelGetInputs(const OH_AI_ModelHandle model)|Obtains the input tensor array structure of a model.|
|int64_t OH_AI_TensorGetElementNum(const OH_AI_TensorHandle tensor)|Obtains the number of tensor elements.|
|const char *OH_AI_TensorGetName(const OH_AI_TensorHandle tensor)|Obtains the name of a tensor.|
|OH_AI_DataType OH_AI_TensorGetDataType(const OH_AI_TensorHandle tensor)|Obtains the tensor data type.|
|void *OH_AI_TensorGetMutableData(const OH_AI_TensorHandle tensor)|Obtains the pointer to variable tensor data.|
## How to Develop
The following figure shows the development process for MindSpore Lite model inference.
**Figure 1** Development process for MindSpore Lite model inference
![how-to-use-mindspore-lite](figures/01.png)
The development process consists of the following main steps:
1. Prepare the required model.
The required model can be downloaded directly or obtained using the model conversion tool.
- If the downloaded model is in the `.ms` format, you can use it directly for inference. The following uses the **mobilenetv2.ms** model as an example.
- If the downloaded model uses a third-party framework, such as TensorFlow, TensorFlow Lite, Caffe, or ONNX, you can use the [model conversion tool](https://www.mindspore.cn/lite/docs/en/r1.5/use/benchmark_tool.html) to convert it to the `.ms` format.
2. Create a context, and set parameters such as the number of runtime threads and device type.
```c
// Create a context, and set the number of runtime threads to 2 and the thread affinity mode to 1 (big cores first).
OH_AI_ContextHandle context = OH_AI_ContextCreate();
if (context == NULL) {
printf("OH_AI_ContextCreate failed.\n");
return OH_AI_STATUS_LITE_ERROR;
}
const int thread_num = 2;
OH_AI_ContextSetThreadNum(context, thread_num);
OH_AI_ContextSetThreadAffinityMode(context, 1);
// Set the device type to CPU, and disable Float16 inference.
OH_AI_DeviceInfoHandle cpu_device_info = OH_AI_DeviceInfoCreate(OH_AI_DEVICETYPE_CPU);
if (cpu_device_info == NULL) {
printf("OH_AI_DeviceInfoCreate failed.\n");
OH_AI_ContextDestroy(&context);
return OH_AI_STATUS_LITE_ERROR;
}
OH_AI_DeviceInfoSetEnableFP16(cpu_device_info, false);
OH_AI_ContextAddDeviceInfo(context, cpu_device_info);
```
3. Create, load, and build the model.
Call **OH_AI_ModelBuildFromFile** to load and build the model.
In this example, the **argv[1]** parameter passed to **OH_AI_ModelBuildFromFile** indicates the specified model file path.
```c
// Create a model.
OH_AI_ModelHandle model = OH_AI_ModelCreate();
if (model == NULL) {
printf("OH_AI_ModelCreate failed.\n");
OH_AI_ContextDestroy(&context);
return OH_AI_STATUS_LITE_ERROR;
}
// Load and build the model. The model type is OH_AI_ModelTypeMindIR.
int ret = OH_AI_ModelBuildFromFile(model, argv[1], OH_AI_ModelTypeMindIR, context);
if (ret != OH_AI_STATUS_SUCCESS) {
printf("OH_AI_ModelBuildFromFile failed, ret: %d.\n", ret);
OH_AI_ModelDestroy(&model);
return ret;
}
```
4. Input data.
Before executing model inference, you need to populate data to the input tensor. In this example, random data is used to populate the model.
```c
// Obtain the input tensor.
OH_AI_TensorHandleArray inputs = OH_AI_ModelGetInputs(model);
if (inputs.handle_list == NULL) {
printf("OH_AI_ModelGetInputs failed, ret: %d.\n", ret);
OH_AI_ModelDestroy(&model);
return ret;
}
// Use random data to populate the tensor.
ret = GenerateInputDataWithRandom(inputs);
if (ret != OH_AI_STATUS_SUCCESS) {
printf("GenerateInputDataWithRandom failed, ret: %d.\n", ret);
OH_AI_ModelDestroy(&model);
return ret;
}
```
5. Execute model inference.
Call **OH_AI_ModelPredict** to perform model inference.
```c
// Execute model inference.
OH_AI_TensorHandleArray outputs;
ret = OH_AI_ModelPredict(model, inputs, &outputs, NULL, NULL);
if (ret != OH_AI_STATUS_SUCCESS) {
printf("OH_AI_ModelPredict failed, ret: %d.\n", ret);
OH_AI_ModelDestroy(&model);
return ret;
}
```
6. Obtain the output.
After model inference is complete, you can obtain the inference result through the output tensor.
```c
// Obtain the output tensor and print the information.
for (size_t i = 0; i < outputs.handle_num; ++i) {
OH_AI_TensorHandle tensor = outputs.handle_list[i];
int64_t element_num = OH_AI_TensorGetElementNum(tensor);
printf("Tensor name: %s, tensor size is %zu ,elements num: %lld.\n", OH_AI_TensorGetName(tensor),
OH_AI_TensorGetDataSize(tensor), element_num);
const float *data = (const float *)OH_AI_TensorGetData(tensor);
printf("output data is:\n");
const int max_print_num = 50;
for (int j = 0; j < element_num && j <= max_print_num; ++j) {
printf("%f ", data[j]);
}
printf("\n");
}
```
7. Destroy the model.
If the MindSpore Lite inference framework is no longer needed, you need to destroy the created model.
```c
// Destroy the model.
OH_AI_ModelDestroy(&model);
```
## Verification
1. Compile **CMakeLists.txt**.
```cmake
cmake_minimum_required(VERSION 3.14)
project(Demo)
add_executable(demo main.c)
target_link_libraries(
demo
mindspore-lite.huawei
pthread
dl
)
```
- To use ohos-sdk for cross compilation, you need to set the native toolchain path for the CMake tool as follows: `-DCMAKE_TOOLCHAIN_FILE="/xxx/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake"`.
- The toolchain builds a 64-bit application by default. To build a 32-bit application, add the following configuration: `-DOHOS_ARCH="armeabi-v7a"`.
2. Run the CMake tool.
- Use hdc_std to connect to the RK3568 development board and put **demo** and **mobilenetv2.ms** to the same directory on the board.
- Run the hdc_std shell command to access the development board, go to the directory where **demo** is located, and run the following command:
```shell
./demo mobilenetv2.ms
```
The inference is successful if the output is similar to the following:
```shell
# ./QuickStart ./mobilenetv2.ms
Tensor name: Softmax-65, tensor size is 4004 ,elements num: 1001.
output data is:
0.000018 0.000012 0.000026 0.000194 0.000156 0.001501 0.000240 0.000825 0.000016 0.000006 0.000007 0.000004 0.000004 0.000004 0.000015 0.000099 0.000011 0.000013 0.000005 0.000023 0.000004 0.000008 0.000003 0.000003 0.000008 0.000014 0.000012 0.000006 0.000019 0.000006 0.000018 0.000024 0.000010 0.000002 0.000028 0.000372 0.000010 0.000017 0.000008 0.000004 0.000007 0.000010 0.000007 0.000012 0.000005 0.000015 0.000007 0.000040 0.000004 0.000085 0.000023
```
...@@ -17,11 +17,11 @@ You can `import` the native .so that contains the JS processing logic. For examp ...@@ -17,11 +17,11 @@ You can `import` the native .so that contains the JS processing logic. For examp
### .so Naming Rules ### .so Naming Rules
Each module has a .so file. For example, if the module name is `hello`, name the .so file **libhello.so**. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`. Each module has a .so file. For example, if the module name is `hello`, name the .so file `libhello.so`. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`.
### JS Objects and Threads ### JS Objects and Threads
The Ark engine prevents NAPIs from being called to operate JS objects in non-JS threads. Otherwise, the application will crash. The Ark engine prevents NAPIs from being called to operate JS objects in non-JS threads. Otherwise, the application will crash. Observe the following rules:
* The NAPIs can be used only in JS threads. * The NAPIs can be used only in JS threads.
* **env** is bound to a thread and cannot be used across threads. The JS object created by a NAPI can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread. * **env** is bound to a thread and cannot be used across threads. The JS object created by a NAPI can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread.
...@@ -640,8 +640,3 @@ export default { ...@@ -640,8 +640,3 @@ export default {
} }
} }
``` ```
## Samples
The following samples are provided for native API development:
- [`NativeAPI`: NativeAPI (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/Native/NativeAPI)
- [First Native C++ Application (eTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/NativeTemplateDemo)
- [Native Component (eTS) (API9) ](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/XComponent)
...@@ -32,7 +32,8 @@ import commonEvent from '@ohos.commonEvent'; ...@@ -32,7 +32,8 @@ import commonEvent from '@ohos.commonEvent';
2. Create a **subscribeInfo** object. For details about the data types and parameters of the object, see [CommonEventSubscribeInfo](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo). 2. Create a **subscribeInfo** object. For details about the data types and parameters of the object, see [CommonEventSubscribeInfo](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo).
```js ```js
private subscriber = null // Used to save the created subscriber object for subsequent subscription and unsubscription. // Used to save the created subscriber object for subsequent subscription and unsubscription.
private subscriber = null
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
......
# Common Event and Notification Overview # Common Event and Notification Overview
The common event and notification module enables applications to publish messages to other applications, and receive messages from the system or other applications. These messages can be news push messages, advertisement notifications, or warning information. The common event and notification module enables applications to publish messages to other applications, and receive messages from the system or other applications. These messages can be news push messages, advertisement notifications, warning information, and more.
Common Event Service (CES) enables applications to publish, subscribe to, and unsubscribe from common events. Based on the sender type, common events are classified into system common events and custom common events. Common Event Service (CES) enables applications to publish, subscribe to, and unsubscribe from common events. Based on the sender type, common events are classified into system common events and custom common events.
......
...@@ -2,18 +2,15 @@ ...@@ -2,18 +2,15 @@
HUAWEI DevEco Studio For OpenHarmony (DevEco Studio for short) is a one-stop, distributed platform developed based on the IntelliJ IDEA Community (Open Source) Edition. It helps you develop versatile all-device, all-scenario applications, offering distributed multi-device development, debugging, and simulation, as well as comprehensive quality and security safeguards. HUAWEI DevEco Studio For OpenHarmony (DevEco Studio for short) is a one-stop integrated development environment (IDE) powered by the IntelliJ IDEA Community Edition and oriented to OpenHarmony devices in all scenarios. It allows you to create project templates, and develop, build, debug, and release OpenHarmony applications from end to end.
[DevEco Studio 3.0 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) stands out in the following aspects: [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/) stands out in the following aspects:
- One-stop information acquisition platform - **Efficient and intelligent code editing**: Code highlighting, intelligent code completion, code error check, automatic code navigation, code formatting, and code search for programming languages such as ArkTS, JavaScript, and C/C++. For details, see [Editor Usage Tips](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-editor-usage-tips-0000001263360493).
- A wide range of device project templates - **Low-code development**: A diverse array of features to punch up your UI development productivity, including component drag and drop, visualized data binding, instant previewing, and low-code development for service widgets. For details, see [Using Low-Code Development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652).
- Efficient code editing - **Multi-device bidirectional real-time preview**: Bidirectional preview, real-time preview, live preview, component preview, and multi-device preview of UI code to quickly view how your code runs on devices. For details, see [Previewing Your App/Service](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596).
- Visualized UI development - **High-performance build system**: Hvigor, a compilation and building tool to compile and package applications/services in one-click mode, better supporting ArkTS/JS development.
- Bidirectional and instant UI preview - **One-stop information acquisition**: A one-stop information acquisition platform that takes into account the developer journey of learning, development, and help seeking, in order to facilitate developer activities.
- High-performing compilation tool Hvigor - **Efficient code debugging**: Various debugging capabilities such as TS, JS, and C/C++ code breakpoint setting, single-step execution, and variable viewing, improving the efficiency of analyzing application/service issues.
- Support for application development based on the device System Capability (SysCap) sets
- Automatic application signing mechanism
- A diverse array of code debugging and profiling features
For more information, see [HUAWEI DevEco Studio For OpenHarmony User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421). For more information, see [DevEco Studio (OpenHarmony) User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421).
# Development References # Development References
- [SysCap List](syscap-list.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](arkui-ts/Readme-EN.md) - [Component Reference (ArkTS-based Declarative Development Paradigm)](arkui-ts/Readme-EN.md)
- [Component Reference (JavaScript-based Web-like Development Paradigm)](arkui-js/Readme-EN.md) - [Component Reference (JavaScript-compatible Web-like Development Paradigm)](arkui-js/Readme-EN.md)
- [API Reference (JS and TS APIs)](apis/Readme-EN.md) - [API Reference (JS and TS APIs)](apis/Readme-EN.md)
- API Reference (Native APIs) - API Reference (Native APIs)
- [Standard Libraries Supported by Native APIs](native-lib/Readme-EN.md) - [Standard Libraries Supported by Native APIs](native-lib/Readme-EN.md)
# APIs # APIs
- [API Reference Document Description](development-intro.md) - [API Reference Document Description](development-intro.md)
- Ability Framework - Ability Framework
- FA Model - FA Model
- [@ohos.ability.featureAbility](js-apis-featureAbility.md) - [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- [@ohos.ability.particleAbility](js-apis-particleAbility.md) - [@ohos.ability.particleAbility](js-apis-particleAbility.md)
...@@ -28,8 +26,6 @@ ...@@ -28,8 +26,6 @@
- application/[FormExtensionContext](js-apis-formextensioncontext.md) - application/[FormExtensionContext](js-apis-formextensioncontext.md)
- application/[PermissionRequestResult](js-apis-permissionrequestresult.md) - application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md) - application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- [InputMethodExtensionAbility](js-apis-inputmethod-extension-ability.md)
- [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md)
- FA and Stage Models - FA and Stage Models
- [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md) - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md) - [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
...@@ -60,18 +56,15 @@ ...@@ -60,18 +56,15 @@
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md) - application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) - application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md) - application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[ProcessRunningInformation](js-apis-processrunninginformation.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md) - application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md) - continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](js-apis-commonEvent.md) - [@ohos.commonEvent](js-apis-commonEvent.md)
- [@ohos.events.emitter](js-apis-emitter.md) - [@ohos.events.emitter](js-apis-emitter.md)
- [@ohos.notification](js-apis-notification.md) - [@ohos.notification](js-apis-notification.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md)
- application/[EventHub](js-apis-eventhub.md) - application/[EventHub](js-apis-eventhub.md)
- Bundle Management
- Bundle Management
- [@ohos.bundle](js-apis-Bundle.md) - [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md) - [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md)
- [@ohos.bundle.innerBundleManager)](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundle.innerBundleManager)](js-apis-Bundle-InnerBundleManager.md)
...@@ -92,17 +85,14 @@ ...@@ -92,17 +85,14 @@
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md) - bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef](js-apis-bundle-PermissionDef.md) - bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- bundle/[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md) - bundle/[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[ShortcutInfo](js-apis-bundle-ShortcutInfo.md) - bundle/[ShortcutInfo<sup>(deprecated)</sup>](js-apis-bundle-ShortcutInfo.md)
- bundle/[PackInfo](js-apis-bundle-PackInfo.md)
- UI Page - UI Page
- [@ohos.animator](js-apis-animator.md) - [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md) - [@ohos.mediaquery](js-apis-mediaquery.md)
- [@ohos.prompt](js-apis-prompt.md)
- [@ohos.router](js-apis-router.md) - [@ohos.router](js-apis-router.md)
- [@ohos.uiAppearance](js-apis-uiappearance.md) - [@ohos.uiAppearance](js-apis-uiappearance.md)
- Graphics
- Graphics
- [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md) - [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md)
- [@ohos.display ](js-apis-display.md) - [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md) - [@ohos.effectKit](js-apis-effectKit.md)
...@@ -111,42 +101,31 @@ ...@@ -111,42 +101,31 @@
- [@ohos.window](js-apis-window.md) - [@ohos.window](js-apis-window.md)
- [webgl](js-apis-webgl.md) - [webgl](js-apis-webgl.md)
- [webgl2](js-apis-webgl2.md) - [webgl2](js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio](js-apis-audio.md) - [@ohos.multimedia.audio](js-apis-audio.md)
- [@ohos.multimedia.camera](js-apis-camera.md) - [@ohos.multimedia.camera](js-apis-camera.md)
- [@ohos.multimedia.image](js-apis-image.md) - [@ohos.multimedia.image](js-apis-image.md)
- [@ohos.multimedia.media](js-apis-media.md) - [@ohos.multimedia.media](js-apis-media.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- Resource Management - Resource Management
- [@ohos.i18n](js-apis-i18n.md) - [@ohos.i18n](js-apis-i18n.md)
- [@ohos.intl](js-apis-intl.md) - [@ohos.intl](js-apis-intl.md)
- [@ohos.resourceManager](js-apis-resource-manager.md) - [@ohos.resourceManager](js-apis-resource-manager.md)
- Resource Scheduling
- Resource Scheduling
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md) - [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md)
- [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.workScheduler ](js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](js-apis-config-policy.md) - [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- enterpriseDeviceManager/[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) - enterpriseDeviceManager/[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)
- Security - Security
- [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager](js-apis-privacyManager.md) - [@ohos.privacyManager](js-apis-privacyManager.md)
- [@ohos.security.huks ](js-apis-huks.md) - [@ohos.security.huks ](js-apis-huks.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md) - [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- [@system.cipher](js-apis-system-cipher.md) - [@system.cipher](js-apis-system-cipher.md)
- Data Management - Data Management
...@@ -155,7 +134,6 @@ ...@@ -155,7 +134,6 @@
- [@ohos.data.dataShare](js-apis-data-dataShare.md) - [@ohos.data.dataShare](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md) - [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md)
- [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md) - [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- [@ohos.data.preferences](js-apis-data-preferences.md) - [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md) - [@ohos.data.rdb](js-apis-data-rdb.md)
...@@ -167,46 +145,44 @@ ...@@ -167,46 +145,44 @@
- [@ohos.document](js-apis-document.md) - [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md) - [@ohos.environment](js-apis-environment.md)
- [@ohos.fileio](js-apis-fileio.md) - [@ohos.fileio](js-apis-fileio.md)
- [@ohos.fileManager](js-apis-filemanager.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md) - [@ohos.statfs](js-apis-statfs.md)
- [@ohos.storageStatistics](js-apis-storage-statistics.md) - [@ohos.storageStatistics](js-apis-storage-statistics.md)
- [@ohos.volumeManager](js-apis-volumemanager.md) - [@ohos.volumeManager](js-apis-volumemanager.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- Telephony Service - Telephony Service
- [@ohos.contact](js-apis-contact.md) - [@ohos.contact](js-apis-contact.md)
- [@ohos.telephony.call](js-apis-call.md) - [@ohos.telephony.call](js-apis-call.md)
- [@ohos.telephony.data](js-apis-telephony-data.md)
- [@ohos.telephony.observer](js-apis-observer.md) - [@ohos.telephony.observer](js-apis-observer.md)
- [@ohos.telephony.radio](js-apis-radio.md) - [@ohos.telephony.radio](js-apis-radio.md)
- [@ohos.telephony.sim](js-apis-sim.md) - [@ohos.telephony.sim](js-apis-sim.md)
- [@ohos.telephony.sms](js-apis-sms.md) - [@ohos.telephony.sms](js-apis-sms.md)
- [@ohos.telephony.data](js-apis-telephony-data.md)
- Network Management - Network Management
- [@ohos.net.connection](js-apis-net-connection.md) - [@ohos.net.connection](js-apis-net-connection.md)
- [@ohos.net.ethernet](js-apis-net-ethernet.md)
- [@ohos.net.http](js-apis-http.md) - [@ohos.net.http](js-apis-http.md)
- [@ohos.request](js-apis-request.md) - [@ohos.net.policy](js-apis-net-policy.md)
- [@ohos.net.sharing](js-apis-net-sharing.md)
- [@ohos.net.socket](js-apis-socket.md) - [@ohos.net.socket](js-apis-socket.md)
- [@ohos.net.statistics](js-apis-net-statistics.md)
- [@ohos.net.tlsSocket](js-apis-tlsSocket.md)
- [@ohos.net.webSocket](js-apis-webSocket.md) - [@ohos.net.webSocket](js-apis-webSocket.md)
- [@ohos.request](js-apis-request.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](js-apis-bluetooth.md) - [@ohos.bluetooth](js-apis-bluetooth.md)
- [@ohos.connectedTag](js-apis-connectedTag.md) - [@ohos.connectedTag](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation](js-apis-cardEmulation.md) - [@ohos.nfc.cardEmulation](js-apis-cardEmulation.md)
- [@ohos.nfc.controller](js-apis-nfcController.md) - [@ohos.nfc.controller](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md) - [@ohos.nfc.tag](js-apis-nfcTag.md)
- [@ohos.nfc.tag](js-apis-nfctech.md)
- [@ohos.nfc.tag](js-apis-tagSession.md)
- [@ohos.rpc](js-apis-rpc.md) - [@ohos.rpc](js-apis-rpc.md)
- [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md) - [@ohos.wifiext](js-apis-wifiext.md)
- tag/[nfctech](js-apis-nfctech.md)
- tag/[tagSession](js-apis-tagSession.md)
- Basic Features - Basic Features
- [@ohos.accessibility](js-apis-accessibility.md) - [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md)
- [@ohos.faultLogger](js-apis-faultLogger.md) - [@ohos.faultLogger](js-apis-faultLogger.md)
- [@ohos.hiAppEvent](js-apis-hiappevent.md) - [@ohos.hiAppEvent](js-apis-hiappevent.md)
- [@ohos.hichecker](js-apis-hichecker.md) - [@ohos.hichecker](js-apis-hichecker.md)
...@@ -217,13 +193,16 @@ ...@@ -217,13 +193,16 @@
- [@ohos.hiTraceMeter](js-apis-hitracemeter.md) - [@ohos.hiTraceMeter](js-apis-hitracemeter.md)
- [@ohos.inputMethod](js-apis-inputmethod.md) - [@ohos.inputMethod](js-apis-inputmethod.md)
- [@ohos.inputMethodEngine](js-apis-inputmethodengine.md) - [@ohos.inputMethodEngine](js-apis-inputmethodengine.md)
- [@ohos.inputmethodextensionability](js-apis-inputmethod-extension-ability.md)
- [@ohos.inputmethodextensioncontext](js-apis-inputmethod-extension-context.md)
- [@ohos.pasteboard](js-apis-pasteboard.md) - [@ohos.pasteboard](js-apis-pasteboard.md)
- [@ohos.screenLock](js-apis-screen-lock.md) - [@ohos.screenLock](js-apis-screen-lock.md)
- [@ohos.systemTime](js-apis-system-time.md) - [@ohos.systemTime](js-apis-system-time.md)
- [@ohos.systemTimer](js-apis-system-timer.md) - [@ohos.systemTimer](js-apis-system-timer.md)
- [@ohos.wallpaper](js-apis-wallpaper.md) - [@ohos.wallpaper](js-apis-wallpaper.md)
- [console](js-apis-logs.md)
- [Timer](js-apis-timer.md) - [Timer](js-apis-timer.md)
- Device Management - Device Management
- [@ohos.batteryInfo ](js-apis-battery-info.md) - [@ohos.batteryInfo ](js-apis-battery-info.md)
...@@ -239,6 +218,7 @@ ...@@ -239,6 +218,7 @@
- [@ohos.multimodalInput.keyCode](js-apis-keycode.md) - [@ohos.multimodalInput.keyCode](js-apis-keycode.md)
- [@ohos.multimodalInput.keyEvent](js-apis-keyevent.md) - [@ohos.multimodalInput.keyEvent](js-apis-keyevent.md)
- [@ohos.multimodalInput.mouseEvent](js-apis-mouseevent.md) - [@ohos.multimodalInput.mouseEvent](js-apis-mouseevent.md)
- [@ohos.multimodalInput.pointer](js-apis-pointer.md)
- [@ohos.multimodalInput.touchEvent](js-apis-touchevent.md) - [@ohos.multimodalInput.touchEvent](js-apis-touchevent.md)
- [@ohos.power](js-apis-power.md) - [@ohos.power](js-apis-power.md)
- [@ohos.runningLock](js-apis-runninglock.md) - [@ohos.runningLock](js-apis-runninglock.md)
...@@ -249,15 +229,12 @@ ...@@ -249,15 +229,12 @@
- [@ohos.update](js-apis-update.md) - [@ohos.update](js-apis-update.md)
- [@ohos.usb](js-apis-usb.md) - [@ohos.usb](js-apis-usb.md)
- [@ohos.vibrator](js-apis-vibrator.md) - [@ohos.vibrator](js-apis-vibrator.md)
- Account Management
- Account Management
- [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.appAccount](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.distributedAccount](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md) - [@ohos.account.osAccount](js-apis-osAccount.md)
- Language Base Class Library
- Language Base Class Library - [@ohos.buffer](js-apis-buffer.md)
- [@ohos.convertxml](js-apis-convertxml.md) - [@ohos.convertxml](js-apis-convertxml.md)
- [@ohos.process](js-apis-process.md) - [@ohos.process](js-apis-process.md)
- [@ohos.uri](js-apis-uri.md) - [@ohos.uri](js-apis-uri.md)
...@@ -279,16 +256,15 @@ ...@@ -279,16 +256,15 @@
- [@ohos.util.Vector](js-apis-vector.md) - [@ohos.util.Vector](js-apis-vector.md)
- [@ohos.worker](js-apis-worker.md) - [@ohos.worker](js-apis-worker.md)
- [@ohos.xml](js-apis-xml.md) - [@ohos.xml](js-apis-xml.md)
- Test - Test
- [@ohos.application.testRunner](js-apis-testRunner.md) - [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md) - [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained
- APIs No Longer Maintained
- [@ohos.bytrace](js-apis-bytrace.md) - [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.data.storage](js-apis-data-storage.md) - [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.prompt](js-apis-prompt.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md)
- [@system.app](js-apis-system-app.md) - [@system.app](js-apis-system-app.md)
- [@system.battery](js-apis-system-battery.md) - [@system.battery](js-apis-system-battery.md)
- [@system.bluetooth](js-apis-system-bluetooth.md) - [@system.bluetooth](js-apis-system-bluetooth.md)
...@@ -308,4 +284,3 @@ ...@@ -308,4 +284,3 @@
- [@system.sensor](js-apis-system-sensor.md) - [@system.sensor](js-apis-system-sensor.md)
- [@system.storage](js-apis-system-storage.md) - [@system.storage](js-apis-system-storage.md)
- [@system.vibrator](js-apis-system-vibrate.md) - [@system.vibrator](js-apis-system-vibrate.md)
- [console](js-apis-logs.md)
\ No newline at end of file
...@@ -14,7 +14,7 @@ This module provides APIs for accessing ability-specific resources. You can use ...@@ -14,7 +14,7 @@ This module provides APIs for accessing ability-specific resources. You can use
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js ```js
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability';
class MainAbility extends Ability { class MainAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
let context = this.context; let context = this.context;
...@@ -34,7 +34,7 @@ class MainAbility extends Ability { ...@@ -34,7 +34,7 @@ class MainAbility extends Ability {
## AbilityContext.startAbility ## AbilityContext.startAbility
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
Starts an ability. This API uses an asynchronous callback to return the result. Starts an ability. This API uses an asynchronous callback to return the result.
...@@ -63,9 +63,9 @@ Starts an ability. This API uses an asynchronous callback to return the result. ...@@ -63,9 +63,9 @@ Starts an ability. This API uses an asynchronous callback to return the result.
## AbilityContext.startAbility ## AbilityContext.startAbility
startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void;
Starts an ability with start options specified. This API uses an asynchronous callback to return the result. Starts an ability with the start options specified. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -1143,7 +1143,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call ...@@ -1143,7 +1143,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call
## AbilityContext.setMissionLabel ## AbilityContext.setMissionLabel
setMissionLabel(label: string): Promise&lt;void&gt; setMissionLabel(label: string): Promise&lt;void&gt;;
Sets a label for this ability in the mission. This API uses a promise to return the result. Sets a label for this ability in the mission. This API uses a promise to return the result.
...@@ -1190,7 +1190,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call ...@@ -1190,7 +1190,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
**Example** **Example**
```js ```js
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image';
var imagePixelMap; var imagePixelMap;
var color = new ArrayBuffer(0); var color = new ArrayBuffer(0);
var initializationOptions = { var initializationOptions = {
...@@ -1237,7 +1237,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return ...@@ -1237,7 +1237,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return
**Example** **Example**
```js ```js
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image';
var imagePixelMap; var imagePixelMap;
var color = new ArrayBuffer(0); var color = new ArrayBuffer(0);
var initializationOptions = { var initializationOptions = {
......
...@@ -19,5 +19,5 @@ import StartOptions from '@ohos.application.StartOptions'; ...@@ -19,5 +19,5 @@ import StartOptions from '@ohos.application.StartOptions';
| Name| Readable| Writable| Type| Mandatory| Description| | Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#AbilityConstant.WindowMode) | Yes| No| number | No| Window mode.| | [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | Yes| No| number | No| Window mode.|
| displayId | Yes| No| number | No| Display ID.| | displayId | Yes| No| number | No| Display ID.|
...@@ -294,6 +294,9 @@ Registers an observer to listen for the state changes of all applications. ...@@ -294,6 +294,9 @@ Registers an observer to listen for the state changes of all applications.
}, },
onProcessDied(processData) { onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData); console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
...@@ -335,6 +338,9 @@ Registers an observer to listen for the state changes of a specified application ...@@ -335,6 +338,9 @@ Registers an observer to listen for the state changes of a specified application
}, },
onProcessDied(processData) { onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData); console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
var bundleNameList = ['bundleName1', 'bundleName2']; var bundleNameList = ['bundleName1', 'bundleName2'];
...@@ -707,6 +713,18 @@ Called when the application state changes. ...@@ -707,6 +713,18 @@ Called when the application state changes.
var applicationStateObserver = { var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData); console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
...@@ -734,8 +752,20 @@ Called when the ability state changes. ...@@ -734,8 +752,20 @@ Called when the ability state changes.
```js ```js
var applicationStateObserver = { var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) { onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData); console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
...@@ -762,8 +792,20 @@ Called when a process is created. ...@@ -762,8 +792,20 @@ Called when a process is created.
```js ```js
var applicationStateObserver = { var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) { onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData); console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
...@@ -790,8 +832,20 @@ Called when a process is terminated. ...@@ -790,8 +832,20 @@ Called when a process is terminated.
```js ```js
var applicationStateObserver = { var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) { onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData); console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
} }
} }
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
...@@ -818,6 +872,18 @@ Called when the process state changes. ...@@ -818,6 +872,18 @@ Called when the process state changes.
```js ```js
var applicationStateObserver = { var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) { onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData); console.log('------------ onProcessStateChanged -----------', processData);
} }
......
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
The **BackgroundTaskManager** module provides APIs to manage background tasks. The **BackgroundTaskManager** module provides APIs to manage background tasks.
If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type. If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task to delay the suspension or a continuous task to prevent the suspension.
If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup. If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup.
If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task. If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task.
> **NOTE** If a privileged system application needs to use certain system resources (for example, resources required to receive common events) when suspended, it can request efficiency resources.
> **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -298,6 +300,64 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() ...@@ -298,6 +300,64 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
``` ```
## backgroundTaskManager.applyEfficiencyResources<sup>9+</sup>
applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresourcesrequest9)): boolean
Requests efficiency resources from the system.
A process and its application can request the same type of resources at the same time, for example, CPU resources. When the application releases the resources, the same type of resources requested by the process are also released.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- |
| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest9) | Yes | Necessary information carried in the request, including the resource type and timeout interval. For details, see [EfficiencyResourcesRequest](#efficiencyresourcesrequest9).|
**Return value**
| Type | Description |
| -------------- | ---------------- |
| boolean | Returns **true** if the request for the resources is successful; returns **false** otherwise.|
**Example**
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
let request = {
resourceTypes: backgroundTaskManager.ResourceType.CPU,
isApply: true,
timeOut: 0,
reason: "apply",
isPersist: true,
isProcess: false,
};
let res = backgroundTaskManager.applyEfficiencyResources(request);
console.info("result of applyEfficiencyResources is: " + res)
```
## backgroundTaskManager.resetAllEfficiencyResources<sup>9+</sup>
resetAllEfficiencyResources(): void
Releases all resources that have been requested.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**System API**: This is a system API.
**Example**
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
backgroundTaskManager.backgroundTaskManager.resetAllEfficiencyResources();
```
## DelaySuspendInfo ## DelaySuspendInfo
Provides the information about the suspension delay. Provides the information about the suspension delay.
...@@ -325,3 +385,38 @@ Provides the information about the suspension delay. ...@@ -325,3 +385,38 @@ Provides the information about the suspension delay.
| WIFI_INTERACTION | 7 | WLAN-related.<br>This is a system API.| | WIFI_INTERACTION | 7 | WLAN-related.<br>This is a system API.|
| VOIP | 8 | Audio and video calls.<br>This is a system API. | | VOIP | 8 | Audio and video calls.<br>This is a system API. |
| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | | TASK_KEEPING | 9 | Computing task (effective only for specific devices). |
## EfficiencyResourcesRequest<sup>9+</sup>
Describes the parameters for requesting efficiency resources.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**System API**: This is a system API.
| Name | Type | Mandatory | Description |
| --------------- | ------ | ---- | ---------------------------------------- |
| resourceTypes | number | Yes | Type of the resource to request. |
| isApply | boolean | Yes | Whether the request is used to apply for resources. The value **true** means that the request is used to apply for resources, and **false** means that the request is used to release resources. |
| timeOut | number | Yes | Duration for which the resource will be used, in milliseconds. |
| isPersist | boolean | No | Whether the resource is permanently held. If the value is **true**, **timeOut** is invalid. |
| isProcess | boolean | No | Whether the request is initiated by a process. The value **true** means that the request is initiated by a process, and **false** means that the request is initiated by an application. |
| reason | string | Yes | Reason for requesting the resource. |
## ResourceType<sup>9+</sup>
Enumerates the efficiency resource types.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**System API**: This is a system API.
| Name | Value | Description |
| ----------------------- | ---- | --------------------- |
| CPU | 1 | CPU resources, which prevent the application from being suspended. |
| COMMON_EVENT | 2 | A type of software resources, which prevent common events from being proxied when the application is suspended. |
| TIMER | 4 | A type of software resources, which prevent timers from being proxied when the application is suspended. |
| WORK_SCHEDULER | 8 | WORK_SCHEDULER resources, which ensure that the application has more time to execute the task. |
| BLUETOOTH | 16 | A type of hardware resources, which prevent Bluetooth resources from being proxied when the application is suspended. |
| GPS | 32 | A type of hardware resources, which prevent GPS resources from being proxied when the application is suspended. |
| AUDIO | 64 | A type of hardware resources, which prevent audio resources from being proxied when the application is suspended.|
# Battery Info # Battery Info
>![](../../public_sys-resources/icon-note.gif) **NOTE:** >**NOTE**
>
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Battery Info module provides APIs for querying the charger type, battery health status, and battery charging status. The Battery Info module provides APIs for querying the charger type, battery health status, and battery charging status.
...@@ -25,7 +26,7 @@ Describes battery information. ...@@ -25,7 +26,7 @@ Describes battery information.
| batterySOC | number | Yes | No | Battery state of charge (SoC) of the current device, in unit of percentage. | | batterySOC | number | Yes | No | Battery state of charge (SoC) of the current device, in unit of percentage. |
| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the current device. | | chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the current device. |
| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the current device. | | healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the current device. |
| pluggedType | [BatteryPluggedType](#batterypluggertype) | Yes | No | Charger type of the current device. | | pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the current device. |
| voltage | number | Yes | No | Battery voltage of the current device, in unit of microvolt. | | voltage | number | Yes | No | Battery voltage of the current device, in unit of microvolt. |
| technology | string | Yes | No | Battery technology of the current device. | | technology | string | Yes | No | Battery technology of the current device. |
| batteryTemperature | number | Yes | No | Battery temperature of the current device, in unit of 0.1°C. | | batteryTemperature | number | Yes | No | Battery temperature of the current device, in unit of 0.1°C. |
...@@ -43,12 +44,12 @@ var batterySoc = batteryInfo.batterySOC; ...@@ -43,12 +44,12 @@ var batterySoc = batteryInfo.batterySOC;
Enumerates charger types. Enumerates charger types.
| Name | Default Value | Description | | Name | Default Value | Description |
| -------- | ------------- | ---------------- | | -------- | ------------- | ----------------- |
| NONE | 0 | Unknown type | | NONE | 0 | Unknown type. |
| AC | 1 | AC charger | | AC | 1 | AC charger. |
| USB | 2 | USB charger | | USB | 2 | USB charger. |
| WIRELESS | 3 | Wireless charger | | WIRELESS | 3 | Wireless charger. |
## BatteryChargeState ## BatteryChargeState
......
# BundleInfo # BundleInfo
The **BundleInfo** module provides bundle information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **BundleInfo** module provides bundle information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**.
## BundleInfo ## BundleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Bundle name. | | name | string | Yes | No | Bundle name. |
| type | string | Yes | No | Bundle type. | | type | string | Yes | No | Bundle type. |
| appId | string | Yes | No | ID of the application to which the bundle belongs. | | appId | string | Yes | No | ID of the application to which the bundle belongs. |
| uid | number | Yes | No | UID of the application to which the bundle belongs. | | uid | number | Yes | No | UID of the application to which the bundle belongs. |
| installTime | number | Yes | No | Time when the HAP file was installed. | | installTime | number | Yes | No | Time when the HAP file was installed. |
| updateTime | number | Yes | No | Time when the HAP file was updated. | | updateTime | number | Yes | No | Time when the HAP file was updated. |
| appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. | | appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. |
| abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | No | Ability configuration information.<br>The value is obtained by passing **GET_BUNDLE_WITH_ABILITIES**.| | abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | No | Ability configuration information.<br>The value is obtained by passing **GET_BUNDLE_WITH_ABILITIES**.|
| reqPermissions | Array\<string> | Yes | No | Permissions to request from the system for running the application.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.| | reqPermissions | Array\<string> | Yes | No | Permissions to request from the system for running the application.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.|
| reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | Yes | No | Detailed information of the permissions to request from the system.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.| | reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | Yes | No | Detailed information of the permissions to request from the system.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.|
| vendor | string | Yes | No | Vendor of the bundle. | | vendor | string | Yes | No | Vendor of the bundle. |
| versionCode | number | Yes | No | Version number of the bundle. | | versionCode | number | Yes | No | Version number of the bundle. |
| versionName | string | Yes | No | Version description of the bundle. | | versionName | string | Yes | No | Version description of the bundle. |
| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. | | compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. |
| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. | | targetVersion | number | Yes | No | Latest SDK version required for running the bundle. |
| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. | | isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. |
| hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | No | Module configuration information. | | hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | No | Module configuration information. |
| entryModuleName | string | Yes | No | Name of the entry module. | | entryModuleName | string | Yes | No | Name of the entry module. |
| cpuAbi | string | Yes | No | CPU and ABI information of the bundle. | | cpuAbi | string | Yes | No | CPU and ABI information of the bundle. |
| isSilentInstallation | string | Yes | No | Whether the application can be installed in silent mode. | | isSilentInstallation | string | Yes | No | Whether the application can be installed in silent mode. |
| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | | minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. |
| entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. | | entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. |
| reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. | | reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. |
| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Extension ability information.<br>The value is obtained by passing **GET_BUNDLE_WITH_EXTENSION_ABILITY**.| | extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Extension ability information.<br>The value is obtained by passing **GET_BUNDLE_WITH_EXTENSION_ABILITY**.|
...@@ -45,8 +45,8 @@ Provides the detailed information of the permissions to request from the system. ...@@ -45,8 +45,8 @@ Provides the detailed information of the permissions to request from the system.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------------------- | ----------------------- | ---- | ---- | -------------------- | | --------------------- | ----------------------- | ---- | ---- | ---------------------- |
| name | string | Yes | Yes | Name of the permission to request. | | name | string | Yes | Yes | Name of the permission to request. |
| reason | string | Yes | Yes | Reason for requesting the permission. | | reason | string | Yes | Yes | Reason for requesting the permission. |
| reasonId<sup>9+</sup> | number | Yes | Yes | ID of the reason for requesting the permission.| | reasonId<sup>9+</sup> | number | Yes | Yes | ID of the reason for requesting the permission.|
...@@ -60,7 +60,7 @@ Describes the application scenario and timing for using the permission. ...@@ -60,7 +60,7 @@ Describes the application scenario and timing for using the permission.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------- | -------------- | ---- | ---- | ------------------------- | | --------- | -------------- | ---- | ---- | --------------------------- |
| abilities | Array\<string> | Yes | Yes | Abilities that use the permission.| | abilities | Array\<string> | Yes | Yes | Abilities that use the permission.|
| when | string | Yes | Yes | Time when the permission is used. | | when | string | Yes | Yes | Time when the permission is used. |
# PackInfo
The **PackInfo** module provides the bundle package information, which can be obtained using [bundle.getBundlePackInfo](js-apis-Bundle.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## BundlePackFlag
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Value | Description |
| ------------------ | ---------- | ---------------------------------- |
| GET_PACK_INFO_ALL | 0x00000000 | All information about the package. |
| GET_PACKAGES | 0x00000001 | Package information about the package.|
| GET_BUNDLE_SUMMARY | 0x00000002 | Bundle summary of the package. |
| GET_MODULE_SUMMARY | 0x00000004 | Module summary of the package. |
## BundlePackInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| -------- | --------------------------------------- | ---- | ---- | ----------------------------- |
| packages | Array\<[PackageConfig](#packageconfig)> | Yes | No | Package configuration information. |
| summary | [PackageSummary](#packagesummary) | Yes | No | Package summary.|
## PackageConfig
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| deviceType | Array\<string> | Yes | No | Device types supported. |
| name | string | Yes | No | Package name. |
| moduleType | string | Yes | No | Module type. |
| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the application. The value **true** means that the HAP file will be automatically installed when the user installs the application, and **false** means the opposite.|
## PackageSummary
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------- | --------------------------------------------- | ---- | ---- | -------------------- |
| app | [BundleConfigInfo](#bundleconfiginfo) | Yes | No | Bundle configuration information. |
| modules | Array\<[ModuleConfigInfo](#moduleconfiginfo)> | Yes | No | Module configuration information.|
## BundleConfigInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ---------- | ------------------- | ---- | ---- | ---------------------------------- |
| bundleName | string | Yes | No | Bundle name of an application. It uniquely identifies the application.|
| version | [Version](#version) | Yes | No | Bundle version. |
## ModuleConfigInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
| apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. |
| deviceType | Array\<string> | Yes | No | Device type of the module. |
| distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. |
| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. |
| extensionAbilities | Array\<[ExtensionAbilities](#extensionabilities)> | Yes | No | Extension ability information of the module.|
## ModuleDistroInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
| mainAbility | string | Yes | No | Name of the main ability. |
| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the application. The value **true** means that the HAP file will be automatically installed when the user installs the application, and **false** means the opposite.|
| installationFree | boolean | Yes | No | Whether the HAP file supports the installation-free feature. The value **true** means that the HAP file supports the installation-free feature and meets installation-free constraints, and **false** means the opposite.|
| moduleName | string | Yes | No | Module name. |
| moduleType | string | Yes | No | Module type. |
## ModuleAbilityInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Logical name of the ability. The name must be unique in the application. |
| label | string | Yes | No | Name of the ability displayed to users. The value is a resource index to names in multiple languages.|
| visible | boolean | Yes | No | Whether the ability can be called by other applications. The value **true** means that the ability can be called by other applications, and **false** means the opposite.|
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information. |
## ExtensionAbilities
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Specification of the widget. A widget is a brief view of an application that is embedded on the home screen to receive periodical updates.|
## AbilityFormInfo
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Widget name. |
| type | string | Yes | No | Widget type. |
| updateEnabled | boolean | Yes | No | Whether the widget supports periodical update. The value **true** means that the widget supports periodical update, and **false** means the opposite.|
| scheduledUpdateTime | string | Yes | No | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. |
| updateDuration | number | Yes | No | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. A widget can be updated periodically, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). If both are configured, **updateDuration** takes precedence.|
| supportDimensions | Array\<number> | Yes | No | Dimensions of the widget. The value can be **1\*2**, **2\*2**, **2\*4**, **4\*4**, or a combination of these options. At least one option must be specified when defining the widget.|
| defaultDimension | number | Yes | No | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.|
## ApiVersion
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----------- | ------ | ---- | ---- | -------------------- |
| releaseType | string | Yes | No | Name of the API version. |
| compatible | number | Yes | No | Minimum API version.|
| target | numbe | Yes | No | Target API version. |
## Version
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
| minCompatibleVersionCode | number | Yes | No | Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario. The value is a 32-bit non-negative integer.|
| name | string | Yes | No | Application version number visible to users. |
| code | number | Yes | No | Application version number used only for application management. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version.|
...@@ -827,7 +827,7 @@ call.reject(1, (error, data) => { ...@@ -827,7 +827,7 @@ call.reject(1, (error, data) => {
## call.reject<sup>7+</sup> ## call.reject<sup>7+</sup>
reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback<void\>\): void reject\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result. Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result.
......
# Standard NFC Card Emulation # Standard NFC Card Emulation
The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. You can use the APIs provided by this module to determine the card emulation type supported and implement Host-based Card Emulation (HCE).
> **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -12,6 +12,17 @@ The **cardEmulation** module implements Near-Field Communication (NFC) card emul ...@@ -12,6 +12,17 @@ The **cardEmulation** module implements Near-Field Communication (NFC) card emul
import cardEmulation from '@ohos.nfc.cardEmulation'; import cardEmulation from '@ohos.nfc.cardEmulation';
``` ```
## FeatureType
Enumerates the NFC card emulation types.
**System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description|
| -------- | -------- | -------- |
| HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.|
| ESE | 2 | embedded Secure Element (eSE) emulation.|
## cardEmulation.isSupported ## cardEmulation.isSupported
...@@ -19,23 +30,31 @@ isSupported(feature: number): boolean ...@@ -19,23 +30,31 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported. Checks whether a certain type of card emulation is supported.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| feature | number | Yes | Card emulation type. For details, see [FeatureType](#featuretype).|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the card emulation is supported; returns **false** otherwise.| | boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
## HceService<sup>8+</sup> ## HceService<sup>8+</sup>
Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance. Implements HCE, including receiving Application Protocol Data Units (APDUs) from the peer card reader and sending a response. Before using HCE-related APIs, check whether the device supports HCE.
### startHCE<sup>8+</sup> ### startHCE<sup>8+</sup>
startHCE(aidList: string[]): boolean startHCE(aidList: string[]): boolean
Starts HCE. Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
...@@ -45,13 +64,13 @@ Starts HCE. ...@@ -45,13 +64,13 @@ Starts HCE.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- | | ------- | -------- | ---- | ----------------------- |
| aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.| | aidList | string[] | Yes | AID list to register.|
### stopHCE<sup>8+</sup> ### stopHCE<sup>8+</sup>
stopHCE(): boolean stopHCE(): boolean
Stops HCE. Stops HCE, including removing the foreground preferred attribute and releasing the dynamically registered AID list.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
...@@ -61,7 +80,7 @@ Stops HCE. ...@@ -61,7 +80,7 @@ Stops HCE.
on(type: "hceCmd", callback: AsyncCallback<number[]>): void; on(type: "hceCmd", callback: AsyncCallback<number[]>): void;
Subscribes to messages from the peer device after **startHCE()**. Registers a callback to receive APDUs from the peer card reader.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
...@@ -72,13 +91,13 @@ Subscribes to messages from the peer device after **startHCE()**. ...@@ -72,13 +91,13 @@ Subscribes to messages from the peer device after **startHCE()**.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------- | | -------- | ----------------------- | ---- | -------------------------------------------- |
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. | | type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the subscribed event. The input parameter is a data array that complies with the Application Protocol Data Unit (APDU).| | callback | AsyncCallback<number[]> | Yes | Callback invoked to return the APDU. Each number in the callback is a hexadecimal number ranging from **0x00** to **0xFF**.|
### sendResponse<sup>8+</sup> ### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void; sendResponse(responseApdu: number[]): void;
Sends a response to the peer device. Sends a response to the peer card reader.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
...@@ -88,16 +107,25 @@ Sends a response to the peer device. ...@@ -88,16 +107,25 @@ Sends a response to the peer device.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | -------- | ---- | -------------------------------------------------- | | ------------ | -------- | ---- | -------------------------------------------------- |
| responseApdu | number[] | Yes | Data to send, which is an array that complies with the APDU.| | responseApdu | number[] | Yes | Response APDU sent to the peer card reader. Each number of the APDU is a hexadecimal number ranging from **0x00** to **0xFF**.|
**Example** **Example**
```js ```js
import cardEmulation from '@ohos.nfc.cardEmulation';
var isHceSupported = cardEmulation.isSupported(cardEmulation.FeatureType.HCE);
if (!isHceSupported) {
console.log('this device is not supported for HCE, ignore it.');
return;
}
// The device supports HCE and transimits APDUs with the remote NFC reader.
var hceService = new cardEmulation.HceService(); var hceService = new cardEmulation.HceService();
hceService.startHCE([ hceService.startHCE([
"F0010203040506", "A0000000041010" "F0010203040506", "A0000000041010"
]) ]);
hceService.stopHCE();
hceService.on("hceCmd", (err, res) => { hceService.on("hceCmd", (err, res) => {
if(err.data === 0) { if(err.data === 0) {
console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res)); console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res));
...@@ -108,4 +136,7 @@ hceService.on("hceCmd", (err, res) => { ...@@ -108,4 +136,7 @@ hceService.on("hceCmd", (err, res) => {
console.log('callback => Operation hceCmd failed. Cause: ' + err.data); console.log('callback => Operation hceCmd failed. Cause: ' + err.data);
} }
}) })
// Stop HCE when the application exits the NFC card emulation.
hceService.stopHCE();
``` ```
...@@ -202,8 +202,8 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -202,8 +202,8 @@ Updates a contact based on the specified contact information and attributes. Thi
contact.updateContact({ contact.updateContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
},{ }, {
attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err) => { }, (err) => {
if (err) { if (err) {
console.log('updateContact callback: err->${JSON.stringify(err)}'); console.log('updateContact callback: err->${JSON.stringify(err)}');
...@@ -432,7 +432,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn ...@@ -432,7 +432,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
```js ```js
contact.queryMyCard({ contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => { }, (err, data) => {
if (err) { if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`); console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
...@@ -469,7 +469,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ...@@ -469,7 +469,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
```js ```js
let promise = contact.queryMyCard({ let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}); });
promise.then((data) => { promise.then((data) => {
console.log(`queryMyCard success: data->${JSON.stringify(data)}`); console.log(`queryMyCard success: data->${JSON.stringify(data)}`);
...@@ -487,7 +487,7 @@ Selects a contact. This API uses an asynchronous callback to return the result. ...@@ -487,7 +487,7 @@ Selects a contact. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts
**Parameters** **Parameters**
...@@ -516,7 +516,7 @@ Selects a contact. This API uses a promise to return the result. ...@@ -516,7 +516,7 @@ Selects a contact. This API uses a promise to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts
**Return Value** **Return Value**
......
...@@ -16,19 +16,6 @@ import emitter from '@ohos.events.emitter' ...@@ -16,19 +16,6 @@ import emitter from '@ohos.events.emitter'
None None
## EventPriority
Enumerates the event emit priority levels.
**System capability**: SystemCapability.Notification.Emitter
| Name | Value | Description |
| --------- | ---- | ------------------------------------------------- |
| IMMEDIATE | 0 | The event will be emitted immediately. |
| HIGH | 1 | The event will be emitted before low-priority events. |
| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority. |
| IDLE | 3 | The event will be emitted after all the other events. |
## emitter.on ## emitter.on
on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata)\>): void on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata)\>): void
...@@ -39,21 +26,21 @@ Subscribes to an event in persistent manner. This API uses a callback to return ...@@ -39,21 +26,21 @@ Subscribes to an event in persistent manner. This API uses a callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | --------------------------------------- |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. The **EventPriority** settings do not take effect.|
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.| | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
**Example** **Example**
```javascript ```javascript
var innerEvent = { let innerEvent = {
eventId: 1 eventId: 1
}; };
var callback = (eventData) => { function EmitterCallback(eventData) {
console.info('callback'); console.info('callback');
}; }
emitter.on(innerEvent, callback); emitter.on(innerEvent, EmitterCallback);
``` ```
## emitter.once ## emitter.once
...@@ -66,21 +53,21 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve ...@@ -66,21 +53,21 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | --------------------------------------- |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. The **EventPriority** settings do not take effect.|
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.| | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
**Example** **Example**
```javascript ```javascript
var innerEvent = { let innerEvent = {
eventId: 1 eventId: 1
}; };
var callback = (eventData) => { function EmitterCallback(eventData) {
console.info('once callback'); console.info('once callback');
}; };
emitter.once(innerEvent, callback); emitter.once(innerEvent, EmitterCallback);
``` ```
## emitter.off ## emitter.off
...@@ -121,18 +108,31 @@ Emits an event to the event queue. ...@@ -121,18 +108,31 @@ Emits an event to the event queue.
**Example** **Example**
```javascript ```javascript
var eventData = { let eventData = {
data: { data: {
"content": "c", "content": "c",
"id": 1, "id": 1,
}}; }};
var innerEvent = { let innerEvent = {
eventId: 1, eventId: 1,
priority: emitter.EventPriority.HIGH priority: emitter.EventPriority.HIGH
}; };
emitter.emit(innerEvent, eventData); emitter.emit(innerEvent, eventData);
``` ```
## EventPriority
Enumerates the event emit priority levels.
**System capability**: SystemCapability.Notification.Emitter
| Name | Value | Description |
| --------- | ---- | --------------------------------------------------- |
| IMMEDIATE | 0 | The event will be emitted immediately. |
| HIGH | 1 | The event will be emitted before low-priority events. |
| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.|
| IDLE | 3 | The event will be emitted after all the other events. |
## InnerEvent ## InnerEvent
Describes an in-process event. Describes an in-process event.
...@@ -141,7 +141,7 @@ Describes an in-process event. ...@@ -141,7 +141,7 @@ Describes an in-process event.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------- | ------------------------------- | ---- | ---- | ---------------------------------- | | -------- | ------------------------------- | ---- | ---- | ---------------------------------- |
| eventId | number | Yes | Yes | Event ID, which is used to identify an event.| | eventId | number | Yes | Yes | Event ID.|
| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event. | | priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event. |
## EventData ## EventData
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
The **ExtensionContext** module, inherited from **Context**, implements the context for Extension abilities. The **ExtensionContext** module, inherited from **Context**, implements the context for Extension abilities.
This module allows access to Extension abilities. This module provides APIs for accessing resources of a specific Extension ability. An Extension ability can use the context directly provided by **ExtensionContext** or that extended from **ExtensionContext**. For example, **ServiceExtension** uses **[ServiceExtensionContext](js-apis-service-extension-context.md)**, which extends the capabilities of starting, stopping, binding, and unbinding abilities based on **ExtensionContext**.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model. > - The APIs of this module can be used only in the stage model.
## Attributes ## Attributes
...@@ -15,6 +15,99 @@ This module allows access to Extension abilities. ...@@ -15,6 +15,99 @@ This module allows access to Extension abilities.
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. | | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the HAP file<br>(See **api\bundle\hapModuleInfo.d.ts** in the **SDK** directory.) |
| config | Configuration | Yes| No| Module configuration information.| | config | Configuration | Yes| No| Module configuration information.<br>(See **api\@ohos.application.Configuration.d.ts** in the **SDK** directory.)|
| extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | Yes| No| Extension ability information.| | extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | Yes| No| Extension ability information.<br>(See **api\bundle\extensionAbilityInfo.d.ts** in the **SDK** directory.)|
## When to Use
**ExtensionContext** provides information about an Extension ability, module, and HAP file. You can use the information based on service requirements. The following uses **ServiceExtension** as an example to describe a use case of **ExtensionContext**.
**Scenario description**
To adapt to devices with different performance, an application provides three modules: highPerformance, midPerformance, and lowPerformance. Each of them provides a Service Extension ability for the entry. During application installation, the application market installs the HAP file of the entry and the HAP file of the module that matches the device performance. During application running, the entry parses **ServiceExtensionContext.HapModuleInfo** to obtain the HAP file information and executes service logic based on this file.
![Example](figures/en_us_image_ExtensionContext_Example.png)
**Example**
Define a **ServiceExtension** with the same name for the three modules.
``` js
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import Want from '@ohos.application.Want'
export default class TheServiceExtension extends ServiceExtension {
onCreate(want:Want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
// Pass ExtensionContext to entry via globalThis.
globalThis.ExtensionContext = this.context;
}
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility onConnect, want:' + want.abilityName);
return null;
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
};
```
Start **ServiceExtension** within the **onCreate** callback of the main ability of the entry.
``` js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate");
let wantExt = {
deviceId: "",
bundleName: "com.example.TheServiceExtension",
abilityName: "TheServiceExtension",
};
this.context.startServiceExtensionAbility(wantExt);
}
};
```
Create a **ServiceModule.ts** file in the entry to execute service logic.
``` js
export default class ServiceModel {
moduleName: string;
constructor() {}
executeTask() {
if (globalThis.ExtensionContext == undefined) {
console.log("ERROR, ServiceExtension does not exist");
return;
}
var moduleInfo = globalThis.ExtensionContext.currentHapModuleInfo;
this.moduleName = moduleInfo.name;
// Execute service logic based on the module name, which differentiates devices with different performance.
switch (this.moduleName) {
case "highPerformance":
console.log("This is high performance device.");
// Execute the corresponding service logic.
break;
case "midPerformance":
console.log("This is mid performance device.");
// Execute the corresponding service logic.
break;
case "lowPerformance":
console.log("This is low performance device.");
// Execute the corresponding service logic.
break;
default:
console.log("ERROR, invalid moduleName.");
break;
}
}
};
```
# User File Access and Management
The **fileManager** module provides APIs for accessing and managing user files. It interworks with the underlying file management services to implement media library and external card management, and provides capabilities for applications to query and create user files.
>**NOTE**<br/>
>
>- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs of this module are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**.
## Modules to Import
```js
import filemanager from '@ohos.fileManager';
```
## filemanager.getRoot
getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt;
Obtains information about the root album or directory in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
**Return value**
| Type| Description|
| --- | -- |
| Promise&lt;[FileInfo](#fileinfo)[]&gt; | Promise used to return the root album or directory information obtained.|
**Example**
```js
filemanager.getRoot().then((fileInfos) => {
for (var i = 0; i < fileInfos.length; i++) {
console.log("files:"+JSON.stringify(fileInfos));
}
}).catch((err) => {
console.log(err)
});
```
## filemanager.getRoot
getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
Obtains information about the root album or directory in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the root album or directory information obtained. |
**Example**
```js
let options = {
"dev":{
"name":"local"
}
};
filemanager.getRoot(options, (err, fileInfos)=>{
for (var i = 0; i < fileInfos.length; i++) {
console.log("files:"+JSON.stringify(fileInfos));
}
});
```
## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise&lt;FileInfo[]&gt;
Obtains information about the second-level album or files in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| path | string | Yes| URI of the directory to query.|
| type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
**Return value**
| Type| Description|
| --- | -- |
| Promise&lt;FileInfo[]&gt; | Promise used to return the album or file information obtained.|
**Error**
| Error Info| Error Code|Description|
| -- | --- | -- |
| No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service.|
| Not a directory | 20 | The object specified by the URI is not a directory or album.|
**Example**
```js
// Obtain all files in the directory. You can use getRoot to obtain the directory URI.
filemanager.getRoot().then((fileInfos) => {
let file = fileInfos.find(item => item.name == "file_folder");
let path = file.path;
filemanager.listFile(path, "file").then((files) => {
console.log("files:" + JSON.stringify(files));
}).catch((err) => {
console.log("failed to get files" + err);
});
}).catch((err) => {
console.log("failed to get root" + err);
});
```
## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
Obtains information about the second-level album or files in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | URI of the directory to query. |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the root album or directory information obtained. |
**Error**
| Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- |
| No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service. |
| Not a directory | 20 | The object specified by the URI is not a directory or album.|
**Example**
```js
// Obtain all files in the directory. You can use getRoot to obtain the directory URI.
filemanager.getRoot().then((fileInfos) => {
let file = fileInfos.find(item => item.name == "image_album");
let path = file.path;
filemanager.listFile(path, "image",function(err, files){
console.log("files:" + JSON.stringify(files));
})
}).catch((err) => {
console.log("failed to get root" + err);
});
```
## filemanager.createFile
createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| filename | string | Yes| Name of the file to create.|
| path | string | Yes| URI of the file to create.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
**Return value**
| Type| Description|
| --- | -- |
| Promise&lt;string&gt; | Promise used to return the URI of the file created.|
**Error**
| Error Info| Error Code|Description|
| -- | --- | -- |
| Operation not permitted | 1 | A file with the same name already exists.|
| No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service.|
| Not a directory | 20 | The object specified by the URI is not a directory or album.|
**Example**
```js
// Create a file.
let media_path = "" // Obtain the file URI using listFile() and getRoot().
let name = "xxx.jpg" // File to be saved.
filemanager.createFile(media_path, name).then((uri) => {
// The URI of the file created is returned.
console.log("file uri:"+uri);
}).catch((err) => {
console.log(err);
});
```
## filemanager.createFile
createFile(path : string, filename: string, options? : {dev? : DevInfo}, callback : AsyncCallback&lt;string&gt;) : void
Creates a file in the specified path in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the root album or directory information obtained. |
**Error**
| Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- |
| Operation not permitted | 1 | A file with the same name already exists. |
| No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service. |
| Not a directory | 20 | The object specified by the URI is not a directory or album.|
**Example**
```js
// Create a file.
// Call listFile() and getRoot() to obtain the file URI.
let media_path = ""
// File to be saved.
let name = "xxx.jpg"
let options = {
"dev":{
"name":"local"
}
};
filemanager.createFile(media_path, name, options, function(err, uri) {
// The URI of the file created is returned.
console.log("file uri:"+uri);
});
```
## FileInfo
Defines the file information returned by **getRoot()** or **listFile()**.
**System capability**: SystemCapability.FileManagement.UserFileService
### Attributes
| Name| Type| Readable| Writable| Description|
| --- | -- | -- | -- | -- |
| name | string | Yes| No| File name.|
| path | string | Yes| No| URI of the file.|
| type | string | Yes| No| File type.|
| size | number | Yes| No| File size.|
| addedTime | number | Yes| No| Time when the file was scanned to the database.|
| modifiedTime | number | Yes| No| Time when the file was modified.|
## DevInfo
Defines the device type.
**System capability**: SystemCapability.FileManagement.UserFileService
### Attributes
| Name| Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | -------- |
| name | string | Yes | Yes | Device name.|
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration.
> **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -18,11 +19,11 @@ Before using application event logging, you need to understand the requirements ...@@ -18,11 +19,11 @@ Before using application event logging, you need to understand the requirements
**Event Domain** **Event Domain**
An event domain is a string that contains a maximum of 32 characters, including digits (0 to 9), letters (a to z), and underscores (_). It cannot start with an underscore (_). An event domain is a string that contains a maximum of 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It cannot start with an underscore (\_).
**Event Name** **Event Name**
An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (_). It cannot start with an underscore (_). An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It cannot start with an underscore (\_).
**Event Type** **Event Type**
...@@ -32,7 +33,7 @@ An event type is an enumerated value of [EventType](#eventtype). ...@@ -32,7 +33,7 @@ An event type is an enumerated value of [EventType](#eventtype).
An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows: An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows:
- The parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (_). It cannot start or end with an underscore (_). - The parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It cannot start or end with an underscore (\_).
- The parameter value is a string, number, boolean, or array. - The parameter value is a string, number, boolean, or array.
- When the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be truncated. - When the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be truncated.
- When the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. - When the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.
...@@ -404,12 +405,30 @@ Defines a subscription data holder for processing subscription events. ...@@ -404,12 +405,30 @@ Defines a subscription data holder for processing subscription events.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent **System capability**: SystemCapability.HiviewDFX.HiAppEvent
### constructor<sup>9+</sup>
constructor(watcherName: string);
A constructor used to create a **holder** object. It is called automatically when a **Watcher** object is added.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Example**
```js
let holder = hiAppEvent.addWatcher({
name: "watcher",
});
```
### setSize<sup>9+</sup> ### setSize<sup>9+</sup>
setSize(size: number): void setSize(size: number): void
Sets the data size threshold for fetching an application event package. The default value is **512*1024**, in bytes. Sets the data size threshold for fetching an application event package. The default value is **512*1024**, in bytes.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Example** **Example**
```js ```js
...@@ -425,6 +444,8 @@ takeNext(): [AppEventPackage](#appeventpackage9) ...@@ -425,6 +444,8 @@ takeNext(): [AppEventPackage](#appeventpackage9)
Extracts subscription event data based on the configured data size threshold. If all subscription event data has been extracted, **null** will be returned. Extracts subscription event data based on the configured data size threshold. If all subscription event data has been extracted, **null** will be returned.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Example** **Example**
```js ```js
......
# HiDebug # HiDebug
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data.
...@@ -16,7 +17,7 @@ import hidebug from '@ohos.hidebug'; ...@@ -16,7 +17,7 @@ import hidebug from '@ohos.hidebug';
getNativeHeapSize(): bigint getNativeHeapSize(): bigint
Obtains the total size of the native heap memory. Obtains the total size of the heap memory of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release. This API is defined but not implemented in OpenHarmony 3.1 Release.
...@@ -26,84 +27,80 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. ...@@ -26,84 +27,80 @@ This API is defined but not implemented in OpenHarmony 3.1 Release.
| Type | Description | | Type | Description |
| ------ | --------------------------- | | ------ | --------------------------- |
| bigint | Total size of the native heap memory, in kB.| | bigint | Total size of the heap memory of this application, in kB.|
**Example** **Example**
```js
```js let nativeHeapSize = hidebug.getNativeHeapSize();
let nativeHeapSize = hidebug.getNativeHeapSize(); ```
```
## hidebug.getNativeHeapAllocatedSize ## hidebug.getNativeHeapAllocatedSize
getNativeHeapAllocatedSize(): bigint getNativeHeapAllocatedSize(): bigint
Obtains the size of the allocated native heap memory. Obtains the size of the allocated heap memory of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release. This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------------- | | ------ | --------------------------------- |
| bigint | Size of the allocated native heap memory, in kB.| | bigint | Size of the allocated heap memory of this application, in kB.|
**Example** **Example**
```js
```js let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); ```
```
## hidebug.getNativeHeapFreeSize ## hidebug.getNativeHeapFreeSize
getNativeHeapFreeSize(): bigint getNativeHeapFreeSize(): bigint
Obtains the size of the free native heap memory. Obtains the size of the free heap memory of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release. This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------------- | | ------ | ------------------------------- |
| bigint | Size of the free native heap memory, in kB.| | bigint | Size of the free heap memory of this application, in kB.|
**Example** **Example**
```js
```js let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize();
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); ```
```
## hidebug.getPss ## hidebug.getPss
getPss(): bigint getPss(): bigint
Obtains the PSS of this process. Obtains the size of the used physical memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------- | | ------ | ------------------------- |
| bigint | PSS of the process, in kB.| | bigint | Used physical memory of this process, in kB.|
**Example** **Example**
```js
```js let pss = hidebug.getPss();
let pss = hidebug.getPss(); ```
```
## hidebug.getSharedDirty ## hidebug.getSharedDirty
...@@ -114,18 +111,17 @@ Obtains the size of the shared dirty memory of this process. ...@@ -114,18 +111,17 @@ Obtains the size of the shared dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| bigint | Size of the shared dirty memory of the process, in kB.| | bigint | Size of the shared dirty memory of this process, in kB.|
**Example** **Example**
```js
```js let sharedDirty = hidebug.getSharedDirty();
let sharedDirty = hidebug.getSharedDirty(); ```
```
## hidebug.getPrivateDirty<sup>9+<sup> ## hidebug.getPrivateDirty<sup>9+<sup>
...@@ -135,11 +131,11 @@ Obtains the size of the private dirty memory of this process. ...@@ -135,11 +131,11 @@ Obtains the size of the private dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| bigint | Size of the private dirty memory of the process, in kB.| | bigint | Size of the private dirty memory of this process, in kB.|
**Example** **Example**
...@@ -157,18 +153,17 @@ For example, if the CPU usage is **50%**, **0.5** is returned. ...@@ -157,18 +153,17 @@ For example, if the CPU usage is **50%**, **0.5** is returned.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
**Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| number | CPU usage of the process.| | number | CPU usage of this process.|
**Example** **Example**
```js
```js let cpuUsage = hidebug.getCpuUsage();
let cpuUsage = hidebug.getCpuUsage(); ```
```
## hidebug.startProfiling ## hidebug.startProfiling
...@@ -195,6 +190,7 @@ hidebug.stopProfiling(); ...@@ -195,6 +190,7 @@ hidebug.stopProfiling();
``` ```
## hidebug.stopProfiling ## hidebug.stopProfiling
stopProfiling() : void stopProfiling() : void
...@@ -225,7 +221,7 @@ Exports data from the specified heap file. ...@@ -225,7 +221,7 @@ Exports data from the specified heap file.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example** **Example**
...@@ -250,7 +246,6 @@ This is a system API and cannot be called by third-party applications. ...@@ -250,7 +246,6 @@ This is a system API and cannot be called by third-party applications.
| serviceid | number | Yes | ID of the system service. | | serviceid | number | Yes | ID of the system service. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| string | Absolute path of the file that contains the service information to dump. | | string | Absolute path of the file that contains the service information to dump. |
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Provides system event logging APIs for system HAP applications. Provides system event logging APIs for system HAP applications.
> **NOTE**<br> > **NOTE**
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs. > - The APIs of this module are system APIs.
...@@ -19,7 +19,7 @@ Enumerates event types. ...@@ -19,7 +19,7 @@ Enumerates event types.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| FAULT | 1 | Error event.| | FAULT | 1 | Error event.|
| STATISTIC | 2 | Statistic event.| | STATISTIC | 2 | Statistic event.|
...@@ -32,7 +32,7 @@ Defines a system event. ...@@ -32,7 +32,7 @@ Defines a system event.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| domain | string | Yes| Event domain.| | domain | string | Yes| Event domain.|
| name | string | Yes| Event name.| | name | string | Yes| Event name.|
...@@ -50,7 +50,7 @@ Writes event information to the event file. This API uses an asynchronous callba ...@@ -50,7 +50,7 @@ Writes event information to the event file. This API uses an asynchronous callba
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| info | [SysEventInfo](#syseventinfo) | Yes| System event information.| | info | [SysEventInfo](#syseventinfo) | Yes| System event information.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.<br>- Value **0**: The event verification is successful, and the event will be written to the event file asynchronously. <br>- A value greater than **0**: Invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.<br>- A value smaller than **0**: The event parameter verification fails, and the event will not be written to the event file.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.<br>- Value **0**: The event verification is successful, and the event will be written to the event file asynchronously. <br>- A value greater than **0**: Invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.<br>- A value smaller than **0**: The event parameter verification fails, and the event will not be written to the event file.|
...@@ -91,13 +91,13 @@ Writes event information to the event file. This API uses a promise to return th ...@@ -91,13 +91,13 @@ Writes event information to the event file. This API uses a promise to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory | Description|
| --------- | ----------------------- | ---- | --------------- | | --------- | ----------------------- | ---- | --------------- |
| info | [SysEventInfo](#syseventinfo) | Yes | System event information.| | info | [SysEventInfo](#syseventinfo) | Yes | System event information.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------------------------------------------------------ | | ------------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | Promise used to return the result. Depending on whether event writing is successful, you can use the **then()** or **catch()** method to process the callback.| | Promise&lt;void&gt; | Promise used to return the result. Depending on whether event writing is successful, you can use the **then()** or **catch()** method to process the callback.|
...@@ -138,7 +138,7 @@ Enumerates matching rule types. ...@@ -138,7 +138,7 @@ Enumerates matching rule types.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| WHOLE_WORD | 1 | Whole word matching.| | WHOLE_WORD | 1 | Whole word matching.|
| PREFIX | 2 | Prefix matching.| | PREFIX | 2 | Prefix matching.|
...@@ -150,7 +150,7 @@ Defines rules for event subscription. ...@@ -150,7 +150,7 @@ Defines rules for event subscription.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| domain | string | Yes| Event domain.| | domain | string | Yes| Event domain.|
| name | string | Yes| Event name.| | name | string | Yes| Event name.|
...@@ -163,7 +163,7 @@ Defines a watcher for event subscription. ...@@ -163,7 +163,7 @@ Defines a watcher for event subscription.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| rules | [WatchRule](#watchrule)[] | Yes| Array of matching rules for event subscription.| | rules | [WatchRule](#watchrule)[] | Yes| Array of matching rules for event subscription.|
| onEvent | function | Yes| Callback for event subscription: (info: [SysEventInfo](#syseventinfo)) => void| | onEvent | function | Yes| Callback for event subscription: (info: [SysEventInfo](#syseventinfo)) => void|
...@@ -181,7 +181,7 @@ Adds a watcher for event subscription. ...@@ -181,7 +181,7 @@ Adds a watcher for event subscription.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| ------ | ----------------------------- | ---- | ------------------------ | | ------ | ----------------------------- | ---- | ------------------------ |
| watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.| | watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.|
...@@ -223,7 +223,7 @@ Removes a watcher used for event subscription. ...@@ -223,7 +223,7 @@ Removes a watcher used for event subscription.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory | Description |
| ------ | ------------- | ---- | ------------------------ | | ------ | ------------- | ---- | ------------------------ |
| watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.| | watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.|
...@@ -260,7 +260,7 @@ Defines arguments for event query. ...@@ -260,7 +260,7 @@ Defines arguments for event query.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| beginTime | number | Yes| Start time (13-digit timestamp) for event query.| | beginTime | number | Yes| Start time (13-digit timestamp) for event query.|
| endTime | number | Yes| End time (13-digit timestamp) for event query.| | endTime | number | Yes| End time (13-digit timestamp) for event query.|
...@@ -272,7 +272,7 @@ Defines rules for event query. ...@@ -272,7 +272,7 @@ Defines rules for event query.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| domain | string | Yes| Event domain.| | domain | string | Yes| Event domain.|
| names | string[] | Yes| Array of event names.| | names | string[] | Yes| Array of event names.|
...@@ -283,7 +283,7 @@ Defines an event query instance. ...@@ -283,7 +283,7 @@ Defines an event query instance.
**System capability**: SystemCapability.HiviewDFX.HiSysEvent **System capability**: SystemCapability.HiviewDFX.HiSysEvent
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| onQuery | function | Yes| Callback of queried events: (infos: [SysEventInfo](#syseventinfo)[]) => void| | onQuery | function | Yes| Callback of queried events: (infos: [SysEventInfo](#syseventinfo)[]) => void|
| onComplete | function | Yes| Callback of query result statistics: (reason: number, total: number) => void| | onComplete | function | Yes| Callback of query result statistics: (reason: number, total: number) => void|
...@@ -300,7 +300,7 @@ Queries system events. ...@@ -300,7 +300,7 @@ Queries system events.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory | Description |
| ------ | ----------------------------- | ---- | ------------------------ | | ------ | ----------------------------- | ---- | ------------------------ |
| queryArg | [QueryArg](#queryarg) | Yes | Arguments for event query.| | queryArg | [QueryArg](#queryarg) | Yes | Arguments for event query.|
| rules | [QueryRule](#queryrule)[] | Yes | Array of event query rules.| | rules | [QueryRule](#queryrule)[] | Yes | Array of event query rules.|
......
...@@ -358,7 +358,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques ...@@ -358,7 +358,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| method | [RequestMethod](#requestmethod) | No | Request method. | | method | [RequestMethod](#requestmethod) | No | Request method. |
| extraData | string \| Object \| ArrayBuffer<sup>8+</sup> | No | Additional data of the request.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request.<br>- If the HTTP request uses a GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter is a supplement to the HTTP request parameters and will be added to the URL when the request is sent.<sup>8+</sup><br>- To pass in a string object, you first need to encode the object on your own.<sup>8+</sup> | | extraData | string \| Object \| ArrayBuffer<sup>6+</sup> | No | Additional data of the request.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request.<br>- If the HTTP request uses a GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter is a supplement to the HTTP request parameters and will be added to the URL when the request is sent.<sup>6+</sup><br>- To pass in a string object, you first need to encode the object on your own.<sup>8+</sup> |
| header | Object | No | HTTP request header. The default value is **{'Content-Type': 'application/json'}**. | | header | Object | No | HTTP request header. The default value is **{'Content-Type': 'application/json'}**. |
| readTimeout | number | No | Read timeout duration. The default value is **60000**, in ms. | | readTimeout | number | No | Read timeout duration. The default value is **60000**, in ms. |
| connectTimeout | number | No | Connection timeout interval. The default value is **60000**, in ms. | | connectTimeout | number | No | Connection timeout interval. The default value is **60000**, in ms. |
...@@ -432,7 +432,7 @@ Defines the response to an HTTP request. ...@@ -432,7 +432,7 @@ Defines the response to an HTTP request.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| result | string \| Object \| ArrayBuffer<sup>8+</sup> | Yes | Response content returned based on **Content-type** in the response header:<br>- application/json: a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content.<br>- application/octet-stream: ArrayBuffer<br>- Others: string| | result | string \| Object \| ArrayBuffer<sup>6+</sup> | Yes | Response content returned based on **Content-type** in the response header:<br>- application/json: a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content.<br>- application/octet-stream: ArrayBuffer<br>- Others: string|
| responseCode | [ResponseCode](#responsecode) \| number | Yes | Result code for an HTTP request. If the callback function is successfully executed, a result code defined in [ResponseCode](#responsecode) will be returned. Otherwise, an error code will be returned in the **err** field in **AsyncCallback**. For details, see [Error Codes](#error-codes).| | responseCode | [ResponseCode](#responsecode) \| number | Yes | Result code for an HTTP request. If the callback function is successfully executed, a result code defined in [ResponseCode](#responsecode) will be returned. Otherwise, an error code will be returned in the **err** field in **AsyncCallback**. For details, see [Error Codes](#error-codes).|
| header | Object | Yes | Response header. The return value is a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content. Common fields and parsing methods are as follows:<br>- Content-Type: header['Content-Type'];<br>- Status-Line: header['Status-Line'];<br>- Date: header.Date/header['Date'];<br>- Server: header.Server/header['Server'];| | header | Object | Yes | Response header. The return value is a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content. Common fields and parsing methods are as follows:<br>- Content-Type: header['Content-Type'];<br>- Status-Line: header['Status-Line'];<br>- Date: header.Date/header['Date'];<br>- Server: header.Server/header['Server'];|
| cookies<sup>8+</sup> | Array\<string\> | Yes | Cookies returned by the server. | | cookies<sup>8+</sup> | Array\<string\> | Yes | Cookies returned by the server. |
......
...@@ -64,7 +64,7 @@ Creates a Locale object. ...@@ -64,7 +64,7 @@ Creates a Locale object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------- | ---- | ---------------------------- | | ------- | ------------- | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
| options | LocaleOptions | No | Options for creating the **Locale** object. | | options<sup>9+</sup> | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. |
**Example** **Example**
``` ```
...@@ -181,7 +181,7 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -181,7 +181,7 @@ Creates a **DateTimeOptions** object for the specified locale.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------------------------------- | ---- | ---------------------------- | | ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [DateTimeOptions](#datetimeoptions) | No | Options for creating a **DateTimeFormat** object. | | options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. |
**Example** **Example**
``` ```
...@@ -265,7 +265,7 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -265,7 +265,7 @@ Obtains the formatting options for **DateTimeFormat** object.
| Type | Description | | Type | Description |
| ----------------------------------- | ----------------------------- | | ----------------------------------- | ----------------------------- |
| [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.| | [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.|
**Example** **Example**
``` ```
...@@ -332,7 +332,7 @@ Parameters ...@@ -332,7 +332,7 @@ Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------- | | ------- | ------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [NumberOptions](#numberoptions) | No | Options for creating a **NumberFormat** object. | | options<sup>9+</sup> | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. |
**Example** **Example**
``` ```
...@@ -380,7 +380,7 @@ Obtains the options of the **NumberFormat** object. ...@@ -380,7 +380,7 @@ Obtains the options of the **NumberFormat** object.
| Type | Description | | Type | Description |
| ------------------------------- | --------------------------- | | ------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.| | [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.|
**Example** **Example**
...@@ -449,7 +449,7 @@ Creates a Collator object. ...@@ -449,7 +449,7 @@ Creates a Collator object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------------------------------- | ---- | ---------------------------- | | ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [CollatorOptions](#collatoroptions) | No | Options for creating a **Collator** object. | | options<sup>9+</sup> | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. |
**Example** **Example**
``` ```
...@@ -497,9 +497,10 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -497,9 +497,10 @@ Returns properties reflecting the locale and collation options of a **Collator**
| Type | Description | | Type | Description |
| ----------------------------------- | ----------------- | | ----------------------------------- | ----------------- |
| [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.| | [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.|
**Example** **Example**
``` ```
var collator = new Intl.Collator("zh-Hans"); var collator = new Intl.Collator("zh-Hans");
var options = collator.resolvedOptions(); var options = collator.resolvedOptions();
...@@ -552,7 +553,7 @@ Parameters ...@@ -552,7 +553,7 @@ Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------------------- | | ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [PluralRulesOptions](#pluralrulesoptions) | No | Options for creating a **PluralRules** object. | | options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. |
**Example** **Example**
``` ```
...@@ -634,7 +635,7 @@ Creates a **RelativeTimeFormat** object. ...@@ -634,7 +635,7 @@ Creates a **RelativeTimeFormat** object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------------------- | | ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No | Options for creating a **RelativeTimeFormat** object. | | options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. |
**Example** **Example**
``` ```
...@@ -710,7 +711,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -710,7 +711,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
| Type | Description | | Type | Description |
| ---------------------------------------- | --------------------------------- | | ---------------------------------------- | --------------------------------- |
| [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.| | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions8) | Formatting options for **RelativeTimeFormat** objects.|
**Example** **Example**
``` ```
......
...@@ -42,18 +42,18 @@ Registers a listener to observe the mission status. ...@@ -42,18 +42,18 @@ Registers a listener to observe the mission status.
**Example** **Example**
```js ```js
var listener = { var listener = {
onMissionCreated: function(mission){"--------onMissionCreated-------"}, onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
}; };
console.log("registerMissionListener") console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener); var listenerid = missionManager.registerMissionListener(listener);
```
```
## missionManager.unregisterMissionListener ## missionManager.unregisterMissionListener
...@@ -77,21 +77,22 @@ Deregisters a mission status listener. This API uses an asynchronous callback to ...@@ -77,21 +77,22 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
var listener = { var listener = {
onMissionCreated: function(mission){"--------onMissionCreated-------"}, onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
}; };
console.log("registerMissionListener") console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener); var listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid, (error) => { missionManager.unregisterMissionListener(listenerid, (error) => {
console.log("unregisterMissionListener"); console.log("unregisterMissionListener");
}) })
``` ```
## missionManager.unregisterMissionListener ## missionManager.unregisterMissionListener
...@@ -120,21 +121,22 @@ Deregisters a mission status listener. This API uses a promise to return the res ...@@ -120,21 +121,22 @@ Deregisters a mission status listener. This API uses a promise to return the res
**Example** **Example**
```js ```js
var listener = { var listener = {
onMissionCreated: function(mission){"--------onMissionCreated-------"}, onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
}; onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
console.log("registerMissionListener") };
var listenerid = missionManager.registerMissionListener(listener); console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err){
console.log(err); missionManager.unregisterMissionListener(listenerid).catch(function (err) {
}); console.log(err);
``` });
```
## missionManager.getMissionInfo ## missionManager.getMissionInfo
......
...@@ -61,11 +61,37 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -61,11 +61,37 @@ connection.getDefaultNet().then(function (netHandle) {
}) })
``` ```
## connection.getDefaultNetSync
getDefaultNetSync(): NetHandle;
Obtains the default active data network in synchronous mode.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| --------- | ---------------------------------- |
| NetHandle | Handle of the default active data network.|
**Example**
```js
let netHandle = connection.getDefaultNetSync();
```
## connection.hasDefaultNet ## connection.hasDefaultNet
hasDefaultNet(callback: AsyncCallback\<boolean>): void hasDefaultNet(callback: AsyncCallback\<boolean>): void
Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. Checks whether the default data network is activated. This API uses an asynchronous callback to return the result.
The default network priority is as follows: Ethernet > Wi-Fi > cellular. When only one network is connected, it is treated as the default data network.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -89,6 +115,9 @@ connection.hasDefaultNet(function (error, has) { ...@@ -89,6 +115,9 @@ connection.hasDefaultNet(function (error, has) {
hasDefaultNet(): Promise\<boolean> hasDefaultNet(): Promise\<boolean>
Checks whether the default data network is activated. This API uses a promise to return the result. Checks whether the default data network is activated. This API uses a promise to return the result.
The default network priority is as follows: Ethernet > Wi-Fi > cellular. When only one network is connected, it is treated as the default data network.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -160,7 +189,7 @@ connection.getAllNets().then(function (nets) { ...@@ -160,7 +189,7 @@ connection.getAllNets().then(function (nets) {
getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void
Obtains connection properties of the network corresponding to given network handle. This API uses an asynchronous callback to return the result. Obtains connection properties of the network corresponding to the given network handle. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -792,6 +821,108 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** ...@@ -792,6 +821,108 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle**
| ------ | ------ | ------------------------- | | ------ | ------ | ------------------------- |
| netId | number | Network ID. The value must be greater than or equal to 100.| | netId | number | Network ID. The value must be greater than or equal to 100.|
### bindSocket
bindSocket(socketParam: TCPSocket \| UDPSocket, callback: AsyncCallback\<void>): void;
Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------ | ---- | -------------------------------|
| socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes| **TCPSocket** or **UDPSocket** object.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
connection.getDefaultNet().then(function (netHandle) {
var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx";
if (socketType == "TCPSocket") {
tcp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
netHandle.bindSocket(tcp, function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
} else {
udp.on('message', callback);
udp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
udp.on('message', (data) => {
console.log(JSON.stringify(data))
});
netHandle.bindSocket(udp, function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
});
})
}
}
```
### bindSocket
bindSocket(socketParam: TCPSocket \| UDPSocket): Promise\<void>;
Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------------- | --------------------- | ---- | ------------------------------ |
| socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes | **TCPSocket** or **UDPSocket** object.|
**Return value**
| Type | Description |
| -------------- | ---------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
connection.getDefaultNet().then(function (netHandle) {
var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx";
if(socketType == "TCPSocket") {
tcp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
netHandle.bindSocket(tcp).then(err, data) {
console.log(JSON.stringify(data))
})
} else {
udp.on('message', callback);
udp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
udp.on('message', (data) => {
console.log(JSON.stringify(data))
});
netHandle.bindSocket(tcp).then(err, data) {
console.log(JSON.stringify(data))
});
})
}
}
```
### getAddressesByName ### getAddressesByName
getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void
......
# Ethernet Connection Management
The Ethernet Connection Management module provides wired network capabilities, which allow users to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import ethernet from '@ohos.net.ethernet'
```
## ethernet.setIfaceConfig
setIfaceConfig(iface: string, ic: InterfaceConfiguration, callback: AsyncCallback\<void>): void;
Sets the network interface configuration. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------------ |
| iface | string | Yes | Name of the network interface. |
| ic | [InterfaceConfiguration](#interfaceconfiguration) | Yes | Network interface configuration to set. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, the return result is empty. If the operation fails, an error code is returned.|
**Example**
```js
ethernet.setIfaceConfig("eth0", {mode:ethernet.STATIC,ipAddr:"192.168.1.123", routeAddr:"192.168.1.1",
gateAddr:"192.168.1.1", maskAddr:"255.255.255.0", dnsAddr0:"1.1.1.1", dnsAddr1:"2.2.2.2"},
(error) => {
if (error) {
console.log("setIfaceConfig callback error = " + error);
} else {
console.log("setIfaceConfig callback ok ");
}
});
```
## ethernet.setIfaceConfig
setIfaceConfig(iface: string, ic: InterfaceConfiguration): Promise\<void>;
Sets the network interface configuration. This API uses a promise to return the result.
**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------- | ---- | ------------------------ |
| iface | string | Yes | Name of the network interface. |
| ic | [InterfaceConfiguration](#interfaceconfiguration) | Yes | Network interface configuration to set.|
**Return value**
| Type | Description |
| ------------------- | ----------------------------------------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```js
ethernet.setIfaceConfig("eth0", {mode:ethernet.STATIC,ipAddr:"192.168.1.123", routeAddr:"192.168.1.1",
gateAddr:"192.168.1.1", maskAddr:"255.255.255.0", dnsAddr0:"1.1.1.1", dnsAddr1:"2.2.2.2"}).then(() => {
console.log("setIfaceConfig promiss ok ");
}).catch((error) => {
console.log("setIfaceConfig promiss error = " + error);
});
```
## ethernet.getIfaceConfig
getIfaceConfig(iface: string, callback: AsyncCallback\<InterfaceConfiguration>): void;
Obtains the configuration of a network interface. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ----------------------------------------------- | ----- | ------------ |
| iface | string | Yes | Name of the network interface.|
| callback | AsyncCallback\<[InterfaceConfiguration](#interfaceconfiguration)> | Yes | Callback used to return the configuration. |
**Example**
```js
ethernet.getIfaceConfig("eth0", (error, value) => {
if (error) {
console.log("getIfaceConfig callback error = " + error);
} else {
console.log("getIfaceConfig callback mode = " + value.mode);
console.log("getIfaceConfig callback ipAddr = " + value.ipAddr);
console.log("getIfaceConfig callback routeAddr = " + value.routeAddr);
console.log("getIfaceConfig callback gateAddr = " + value.gateAddr);
console.log("getIfaceConfig callback maskAddr = " + value.maskAddr);
console.log("getIfaceConfig callback dns0Addr = " + value.dns0Addr);
console.log("getIfaceConfig callback dns1Addr = " + value.dns1Addr);
}
});
```
## ethernet.getIfaceConfig
getIfaceConfig(iface: string): Promise\<InterfaceConfiguration>;
Obtains the configuration of a network interface. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------ |
| iface | string | Yes | Name of the network interface.|
**Return value**
| Type | Description |
| --------------------------------- | ---------------------------------- |
| Promise\<[InterfaceConfiguration](#interfaceconfiguration)> | Promise used to return the configuration. |
**Example**
```js
ethernet.getIfaceConfig("eth0").then((data) => {
console.log("getIfaceConfig promiss mode = " + data.mode);
console.log("getIfaceConfig promiss ipAddr = " + data.ipAddr);
console.log("getIfaceConfig promiss routeAddr = " + data.routeAddr);
console.log("getIfaceConfig promiss gateAddr = " + data.gateAddr);
console.log("getIfaceConfig promiss maskAddr = " + data.maskAddr);
console.log("getIfaceConfig promiss dns0Addr = " + data.dns0Addr);
console.log("getIfaceConfig promiss dns1Addr = " + data.dns1Addr);
}).catch((error) => {
console.log("getIfaceConfig promiss error = " + error);
});
```
## ethernet.isIfaceActive
isIfaceActive(iface?: string, callback: AsyncCallback\<number>): void;
Checks whether a network interface is active. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------------------- |
| iface | string | No | Name of the network interface. If this parameter is left empty, the API checks for any active network interface. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. The value **1** means that the network interface is active, **0** means that the network interface is inactive, and any other value means that an error has occurred.|
**Example**
```js
ethernet.isIfaceActive("eth0", (error, value) => {
if (error) {
console.log("whether2Activate callback error = " + error);
} else {
console.log("whether2Activate callback = " + value);
}
});
```
## ethernet.isIfaceActive
isIfaceActive(iface?: string): Promise\<number>;
Checks whether a network interface is active. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| iface | string | No | Name of the network interface. If this parameter is left empty, the API checks for any active network interface.|
**Return value**
| Type | Description |
| ----------------| ------------------------------------------------------------------ |
| Promise\<number> | Promise used to return the result. The value **1** means that the network interface is active, **0** means that the network interface is inactive, and any other value means that an error has occurred.|
**Example**
```js
ethernet.isIfaceActive("eth0").then((data) => {
console.log("isIfaceActive promiss = " + data);
}).catch((error) => {
console.log("isIfaceActive promiss error = " + error);
});
```
## ethernet.getAllActiveIfaces
getAllActiveIfaces(callback: AsyncCallback\<Array\<string>>): void;
Obtains all active network interfaces. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback\<Array\<string>> | Yes | Callback used to return all the active network interface names obtained.|
**Example**
```js
ethernet.getAllActiveIfaces((error, value) => {
if (error) {
console.log("getAllActiveIfaces callback error = " + error);
} else {
console.log("getAllActiveIfaces callback value.length = " + value.length);
for (let i = 0; i < value.length; i++) {
console.log("getAllActiveIfaces callback = " + value[i]);
}
}
});
```
## ethernet.getAllActiveIfaces
getAllActiveIfaces(): Promise\<Array\<string>>;
Obtains all active network interfaces. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
**Return value**
| Type | Description |
| ------------------------------ | ----------------------------------------------- |
| Promise\<Array\<string>> | Promise used to return all the active network interface names obtained.|
**Example**
```js
ethernet.getAllActiveIfaces().then((data) => {
console.log("getAllActiveIfaces promiss data.length = " + data.length);
for (let i = 0; i < data.length; i++) {
console.log("getAllActiveIfaces promiss = " + data[i]);
}
}).catch((error) => {
console.log("getAllActiveIfaces promiss error = " + error);
});
```
## InterfaceConfiguration
Defines the network configuration for the Ethernet connection.
**System capability**: SystemCapability.Communication.NetManager.Core
| Name | Type | Description |
| ----------------------- | ----------------------------------- | ------------------------------------------------------------ |
| mode | [IPSetMode](#ipsetmode) | Configuration mode of the Ethernet connection.|
| ipAddr | string | Static IP address of the Ethernet connection. The value must be an IPv4 address, which is a 32-bit number displayed in dotted decimal notation and each 8-bit field ranges from 0 to 255. This parameter does not need to be configured in Dynamic Host Configuration Protocol (DHCP) mode.|
| route | string | Route of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode.|
| gateway | string | Gateway of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode.|
| netMask | string | Subnet mask of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode.|
| dnsServers | string | DNS server addresses of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode. Multiple addresses are separated by commas (,).|
## IPSetMode
Defines the configuration mode of the Ethernet connection.
**System capability**: SystemCapability.Communication.NetManager.Core
| Name | Value | Description |
| ------------------------ | ---- | ---------------------- |
| STATIC | 0 | Static configuration.|
| DHCP | 1 | Dynamic configuration.|
此差异已折叠。
# Standard NFC # Standard NFC
The **nfcController** module implements Near-Field Communication (NFC). The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state.
> **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -12,12 +12,24 @@ The **nfcController** module implements Near-Field Communication (NFC). ...@@ -12,12 +12,24 @@ The **nfcController** module implements Near-Field Communication (NFC).
import controller from '@ohos.nfc.controller'; import controller from '@ohos.nfc.controller';
``` ```
## NfcState
Enumerates the NFC states.
**System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description|
| -------- | -------- | -------- |
| STATE_OFF | 1 | NFC is closed (OFF).|
| STATE_TURNING_ON | 2 | NFC is turning on.|
| STATE_ON | 3 | NFC is open (ON).|
| STATE_TURNING_OFF | 4 | NFC is turning off.|
## controller.isNfcAvailable ## controller.isNfcAvailable
isNfcAvailable(): boolean isNfcAvailable(): boolean
Checks whether NFC is available. Checks whether the device supports NFC.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
...@@ -25,7 +37,7 @@ Checks whether NFC is available. ...@@ -25,7 +37,7 @@ Checks whether NFC is available.
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if NFC is available; returns **false** otherwise.| | boolean | Returns **true** if the device supports NFC; returns **false** otherwise.|
## controller.openNfc ## controller.openNfc
...@@ -42,7 +54,7 @@ Opens NFC. ...@@ -42,7 +54,7 @@ Opens NFC.
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## controller.closeNfc ## controller.closeNfc
...@@ -76,7 +88,7 @@ Checks whether NFC is open. ...@@ -76,7 +88,7 @@ Checks whether NFC is open.
## controller.getNfcState ## controller.getNfcState
getNfcState(): NfcState getNfcState(): [NfcState](#nfcstate)
Obtains the NFC state. Obtains the NFC state.
...@@ -86,13 +98,13 @@ Obtains the NFC state. ...@@ -86,13 +98,13 @@ Obtains the NFC state.
| **Type**| **Description** | | **Type**| **Description** |
| -------- | ---------------------- | | -------- | ---------------------- |
| NfcState | NFC state obtained. For details, see [NfcState](#nfcstate).| | [NfcState](#nfcstate) | NFC state obtained. For details, see [NfcState](#nfcstate).|
## controller.on('nfcStateChange') ## controller.on('nfcStateChange')
on(type: "nfcStateChange", callback: Callback&lt;NfcState&gt;): void on(type: "nfcStateChange", callback: Callback&lt;[NfcState](#nfcstate)&gt;): void
Subscribes to NFC state changes. Subscribes to NFC state changes. A callback will be invoked to return the NFC state when the NFC state changes.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
...@@ -101,15 +113,15 @@ Subscribes to NFC state changes. ...@@ -101,15 +113,15 @@ Subscribes to NFC state changes.
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.| | type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.|
| callback | Callback&lt;NfcState&gt; | Yes| Callback invoked to return the NFC state changes.| | callback | Callback&lt;[NfcState](#nfcstate)&gt; | Yes| Callback invoked to return the NFC state.|
## controller.off('nfcStateChange') ## controller.off('nfcStateChange')
off(type: "nfcStateChange", callback?: Callback&lt;NfcState&gt;): void off(type: "nfcStateChange", callback?: Callback&lt;[NfcState](#nfcstate)&gt;): void
Unsubscribes from the NFC state changes. Unsubscribes from the NFC state changes. The subscriber will not receive NFC state change notifications.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
...@@ -118,35 +130,37 @@ Unsubscribes from the NFC state changes. ...@@ -118,35 +130,37 @@ Unsubscribes from the NFC state changes.
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.| | type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.|
| callback | Callback&lt;NfcState&gt; | No| Callback used to return the NFC state changes. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
**Example** **Example**
```js ```js
import nfcController from '@ohos.nfcController'; import controller from '@ohos.nfc.controller';
var NFC_STATE_NOTIFY = "nfcStateChange"; // Define a callback key.
var NFC_STATE_CALLBACK_KEY = "nfcStateChange";
var recvNfcStateNotifyFunc = result => {
console.info("nfc state receive state: " + result); // Register the callback to receive NFC state change notifications.
controller.on(NFC_STATE_CALLBACK_KEY, (err, nfcState)=> {
if (err) {
console.log("controller on callback err: " + err);
} else {
console.log("controller on callback nfcState: " + nfcState);
}
});
// Open NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
if (!controller.isNfcOpen()) {
var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret);
} }
// Subscribe to the NFC state changes.
nfcController.on(NFC_STATE_NOTIFY, recvNfcStateNotifyFunc);
// Unsubscribe from the NFC state changes.
nfcController.off(NFC_STATE_NOTIFY, recvNfcStateNotifyFunc);
```
## NfcState
Enumerates the NFC states.
**System capability**: SystemCapability.Communication.NFC.Core // Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
if (controller.isNfcOpen()) {
var ret = controller.closeNfc();
console.log("controller closeNfc ret: " + ret);
}
| Name| Default Value| Description| // Unregister the callback.
| -------- | -------- | -------- | controller.off(NFC_STATE_CALLBACK_KEY);
| STATE_OFF | 1 | Off| ```
| STATE_TURNING_ON | 2 | Turning on|
| STATE_ON | 3 | On|
| STATE_TURNING_OFF | 4 | Turning off|
...@@ -37,4 +37,4 @@ export default class MainAbility extends Ability { ...@@ -37,4 +37,4 @@ export default class MainAbility extends Ability {
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| No| Permissions requested.| | permissions | Array&lt;string&gt; | Yes| No| Permissions requested.|
| authResults | Array&lt;number&gt; | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. | | authResults | Array&lt;number&gt; | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and a non-zero value means the opposite. |
...@@ -384,6 +384,27 @@ promise.then(data => { ...@@ -384,6 +384,27 @@ promise.then(data => {
}); });
``` ```
## radio.isNrSupported<sup>7+</sup>
isNrSupported\(\): boolean
Checks whether the current device supports 5G \(NR\).
**System capability**: SystemCapability.Telephony.CoreService
**Return value**
| Type | Description |
| ------- | -------------------------------- |
| boolean | - **true**: The current device supports 5G \(NR\).<br>- **false**: The current device does not support 5G \(NR\).|
**Example**
```js
let result = radio.isNrSupported();
console.log("Result: "+ result);
```
## radio.isNrSupported<sup>8+</sup> ## radio.isNrSupported<sup>8+</sup>
......
...@@ -6,8 +6,8 @@ You can use the APIs of this module to start, terminate, connect, and disconnect ...@@ -6,8 +6,8 @@ You can use the APIs of this module to start, terminate, connect, and disconnect
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model. > - The APIs of this module can be used only in the stage model.
## Usage ## Usage
......
此差异已折叠。
...@@ -433,7 +433,7 @@ ws.off('open', callback1); ...@@ -433,7 +433,7 @@ ws.off('open', callback1);
on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void
Enables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Enables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented.
>![](public_sys-resources/icon-note.gif) **NOTE:** >![](public_sys-resources/icon-note.gif) **NOTE:**
>The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). >The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\).
...@@ -462,7 +462,7 @@ ws.on('message', (err, value) => { ...@@ -462,7 +462,7 @@ ws.on('message', (err, value) => {
off\(type: 'message', callback?: AsyncCallback<string | ArrayBuffer\>\): void off\(type: 'message', callback?: AsyncCallback<string | ArrayBuffer\>\): void
Disables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Disables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented.
>![](public_sys-resources/icon-note.gif) **NOTE:** >![](public_sys-resources/icon-note.gif) **NOTE:**
>The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). >The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\).
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册