提交 a621e5d1 编写于 作者: E ester.zhou 提交者: Gitee

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

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
...@@ -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';
......
...@@ -244,7 +244,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -244,7 +244,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
### 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
...@@ -387,3 +387,5 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap ...@@ -387,3 +387,5 @@ When a text is displayed in more than one line, [BreakIterator8](../reference/ap
```js ```js
var isboundary = breakIterator.isBoundary(5); var isboundary = breakIterator.isBoundary(5);
``` ```
```
\ No newline at end of file
...@@ -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"});
...@@ -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"});
...@@ -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"});
......
...@@ -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.|
# 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. |
...@@ -44,11 +45,11 @@ var batterySoc = batteryInfo.batterySOC; ...@@ -44,11 +45,11 @@ 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
......
...@@ -500,6 +500,7 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -500,6 +500,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
| [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.| | [CollatorOptions](#collatoroptions) | 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();
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -29,15 +29,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -29,15 +29,15 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.| | volumeUuid | string | Yes | UUID of the volume.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total size of the volume.| | Promise&lt;number&gt; | Promise used to return the total size of the volume.|
**Example** **Example**
...@@ -66,10 +66,10 @@ This is a system API and cannot be called by third-party applications. ...@@ -66,10 +66,10 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
**Example** **Example**
...@@ -97,15 +97,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -97,15 +97,15 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.| | volumeUuid | string | Yes | UUID of the volume.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the volume.| | Promise&lt;number&gt; | Promise used to return the available space of the volume.|
**Example** **Example**
...@@ -135,10 +135,10 @@ This is a system API and cannot be called by third-party applications. ...@@ -135,10 +135,10 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | ---------------------------- | | ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.|
**Example** **Example**
...@@ -166,15 +166,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -166,15 +166,15 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- | | ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.| | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
**Example** **Example**
...@@ -203,10 +203,10 @@ This is a system API and cannot be called by third-party applications. ...@@ -203,10 +203,10 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.| | callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.|
**Example** **Example**
...@@ -228,9 +228,9 @@ Asynchronously obtains space information of the current third-party application. ...@@ -228,9 +228,9 @@ Asynchronously obtains space information of the current third-party application.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. | | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
**Example** **Example**
...@@ -249,9 +249,9 @@ Asynchronously obtains space information of the current third-party application. ...@@ -249,9 +249,9 @@ Asynchronously obtains space information of the current third-party application.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. | | callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. |
**Example** **Example**
...@@ -294,9 +294,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -294,9 +294,9 @@ This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. | | Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
**Example** **Example**
...@@ -321,9 +321,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -321,9 +321,9 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ | | -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
**Example** **Example**
...@@ -351,9 +351,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -351,9 +351,9 @@ This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.| | Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
**Example** **Example**
...@@ -379,9 +379,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -379,9 +379,9 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- | | -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
**Example** **Example**
...@@ -408,9 +408,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -408,9 +408,9 @@ This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system space obtained.| | Promise&lt;number&gt; | Promise used to return the system space obtained.|
**Example** **Example**
...@@ -438,9 +438,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -438,9 +438,9 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
**Example** **Example**
...@@ -467,15 +467,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -467,15 +467,15 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.| | userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Example** **Example**
...@@ -504,10 +504,10 @@ This is a system API and cannot be called by third-party applications. ...@@ -504,10 +504,10 @@ This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. | | userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes | Callback invoked to return the information obtained.| | callback | callback:AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Example** **Example**
......
# animate<a name="EN-US_TOPIC_0000001127125042"></a> # animate
The **<animate\>** component is used to apply animation to an **<svg\>** component. The **<animate\>** component is used to apply animation to an **<svg\>** component.
>![](../../public_sys-resources/icon-note.gif) **NOTE:** >![](../../public_sys-resources/icon-note.gif) **NOTE**
>
>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions<a name="section11257113618419"></a> ## Required Permissions
None None
## Child Components<a name="section9288143101012"></a> ## Child Components
Not supported Not supported
## Attributes<a name="section2907183951110"></a> ## Attributes
<a name="table20633101642315"></a> <a name="table20633101642315"></a>
<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aaf1247770b244944bbcc9f28d9a6f00b"><a name="aaf1247770b244944bbcc9f28d9a6f00b"></a><a name="aaf1247770b244944bbcc9f28d9a6f00b"></a>Name</p> <table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aaf1247770b244944bbcc9f28d9a6f00b"><a name="aaf1247770b244944bbcc9f28d9a6f00b"></a><a name="aaf1247770b244944bbcc9f28d9a6f00b"></a>Name</p>
...@@ -193,7 +194,7 @@ Not supported ...@@ -193,7 +194,7 @@ Not supported
</tbody> </tbody>
</table> </table>
## Example<a name="section360556124815"></a> ## Example
``` ```
<!-- xxx.hml --> <!-- xxx.hml -->
......
...@@ -89,4 +89,4 @@ struct PathExample { ...@@ -89,4 +89,4 @@ struct PathExample {
} }
``` ```
![zh-cn_image_0000001219744193](figures/zh-cn_image_0000001219744193.png) ![en-us_image_0000001219744193](figures/en-us_image_0000001219744193.png)
...@@ -2031,6 +2031,8 @@ Resets the existing transformation matrix and creates a new transformation matri ...@@ -2031,6 +2031,8 @@ Resets the existing transformation matrix and creates a new transformation matri
![en-us_image_0000001193872526](figures/en-us_image_0000001193872526.png) ![en-us_image_0000001193872526](figures/en-us_image_0000001193872526.png)
### translate
### translate ### translate
translate(x: number, y: number): void translate(x: number, y: number): void
......
...@@ -9,14 +9,14 @@ The framework provides four pixel units, with vp as the reference data unit. ...@@ -9,14 +9,14 @@ The framework provides four pixel units, with vp as the reference data unit.
| px | Physical pixel unit of the screen. | | px | Physical pixel unit of the screen. |
| vp | Pixels specific to the screen density, which are converted into physical pixels of the screen based on the screen pixel density. | | vp | Pixels specific to the screen density, which are converted into physical pixels of the screen based on the screen pixel density. |
| fp | Font pixel, which is similar to vp and varies according to the system font size. | | fp | Font pixel, which is similar to vp and varies according to the system font size. |
| lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by [designWidth](../ui/ts-framework-js-tag.md)). For example, if designWidth is set to 720, then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels. | | lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by [designWidth](../quick-start/package-structure.md)). For example, if designWidth is set to 720, then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels. |
## Pixel Unit Conversion ## Pixel Unit Conversion
Conversion from other pixel units to px is supported. Conversion from other pixel units to px is supported.
| API | Description | | API | Description |
| -------- | -------- | | -------- | -------- |
| vp2px(value : number) : number | Converts a value in units of vp to a value in units of px. | | vp2px(value : number) : number | Converts a value in units of vp to a value in units of px. |
| px2vp(value : number) : number | Converts a value in units of px to a value in units of vp. | | px2vp(value : number) : number | Converts a value in units of px to a value in units of vp. |
......
# C Coding Style Guide # C Coding Style Guide
## <a name="c0-1"></a>Purpose ## Purpose
Rules are not perfect. They might disable useful features in specific situations and therefore affect code implementation. However, the purpose of developing rules is to get more benefits for most programmers. If a rule cannot be followed in your team operation, we can improve the rule together. Before referring to this coding style guide, you are expected to have the following basic capabilities of the C programming language: Rules are not perfect. They might disable useful features in specific situations and therefore affect code implementation. However, the purpose of developing rules is to get more benefits for most programmers. If a rule cannot be followed in your team operation, we can improve the rule together. Before referring to this coding style guide, you are expected to have the following basic capabilities of the C programming language:
...@@ -8,11 +8,11 @@ Rules are not perfect. They might disable useful features in specific situations ...@@ -8,11 +8,11 @@ Rules are not perfect. They might disable useful features in specific situations
2. Be familiar with the basic features of C. 2. Be familiar with the basic features of C.
3. Understand the standard library of C. 3. Understand the standard library of C.
## <a name="c0-2"></a>General Principles ## General Principles
Code must meet the requirements for **readability**, **maintainability**, **security**, **reliability**, **testability**, **efficiency**, and **portability** while ensuring functionality correctness. Code must meet the requirements for **readability**, **maintainability**, **security**, **reliability**, **testability**, **efficiency**, and **portability** while ensuring functionality correctness.
## <a name="c0-3"></a>Conventions ## Conventions
**Rule**: Conventions that must be followed during programming. **Rule**: Conventions that must be followed during programming.
...@@ -20,51 +20,64 @@ Code must meet the requirements for **readability**, **maintainability**, **secu ...@@ -20,51 +20,64 @@ Code must meet the requirements for **readability**, **maintainability**, **secu
It is necessary to understand the reason for these conventions and try to comply with them, no matter if they are rules or recommendations. It is necessary to understand the reason for these conventions and try to comply with them, no matter if they are rules or recommendations.
## <a name="c0-4"></a>Exceptions ## Exceptions
The only acceptable exceptions are those that do not violate the general principles and provide appropriate reasons for their existence. The only acceptable exceptions are those that do not violate the general principles and provide appropriate reasons for their existence.
Try to avoid exceptions because they affect the code consistency. Exceptions to 'Rules' should be very rare. Try to avoid exceptions because they affect the code consistency. Exceptions to 'Rules' should be very rare.
The style consistency principle is preferred in the following case: The style consistency principle is preferred in the following case:
**When you modify open-source or third-party code, comply with their respective code specifications.** **When you modify open-source or third-party code, comply with their respective code specifications.**
# <a name="c1"></a>1 Naming # 1 Naming
Names include file, function, variable, type, and macro names. Names include file, function, variable, type, and macro names.
Naming is considered the most difficult and important thing in software development. Naming is considered the most difficult and important thing in software development.
The name of an identifier must be clear, well defined, easy to understand, and accounting for reading habits. The name of an identifier must be clear, well defined, easy to understand, and accounting for reading habits.
The unified naming style is the most direct expression of the consistency principle. The unified naming style is the most direct expression of the consistency principle.
## <a name="c1-1"></a>General Conventions ## General Conventions
**CamelCase** **CamelCase**
CamelCase is the practice of writing compound words or phrases so that each word or abbreviation in the phrase begins with a capital letter, and with no intervening spaces or punctuation. CamelCase is the practice of writing compound words or phrases so that each word or abbreviation in the phrase begins with a capital letter, and with no intervening spaces or punctuation.
There are two conventions: **UpperCamelCase and lowerCamelCase**. There are two conventions: **UpperCamelCase and lowerCamelCase**.
**Unix\_like** **Unix\_like**
Unix\_like is also known as the snake style. In the Unix\_like style, words contain only lowercase letters and are separated by underscores (\_). Unix\_like is also known as the snake style. In the Unix\_like style, words contain only lowercase letters and are separated by underscores (\_).
Example: 'test_result' Example: 'test_result'
### <a name="r1-1"></a>Rule 1.1 Name identifiers in the CamelCase style. ### Rule 1.1 Name identifiers in the CamelCase style.
| Type| Naming Style | Type| Naming Style|
|----------|---------- |----------|----------|
| Function, struct, enum, union| UpperCamelCase | Function, struct, enum, union| UpperCamelCase|
| Variable, function parameter, macro parameter, struct body, union member| lowerCamelCase | Variable, function parameter, macro parameter, struct body, union member| lowerCamelCase|
| Macro, constant, enumerated value, goto tag| All capitalized, separated by underscores (\_) | Macro, constant, enumerated value, goto tag| All capitalized, separated by underscores (\_)|
Note: Note:
**Constant** in the above table refers to the variable that is of the basic data type, enum type, and string type and modified by **const** under the global scope, excluding arrays, structs, and unions. **Constant** in the above table refers to the variable that is of the basic data type, enum type, and string type and modified by **const** under the global scope, excluding arrays, structs, and unions.
**Variable** indicates the variables excluding those defined in **Constant**. These variables use the lowerCamelCase style. **Variable** indicates the variables excluding those defined in **Constant**. These variables use the lowerCamelCase style.
Unix\_like can be used for Linux or Unix friendly code. Unix\_like can be used for Linux or Unix friendly code.
For code that is using the Unix\_like style, you can continue using this style. For code that is using the Unix\_like style, you can continue using this style.
The same naming style must be used for the same function, struct, or union. The same naming style must be used for the same function, struct, or union.
### <a name="a1-1"></a>Rec 1.1 Use more accurate names for identifiers with a large scope. ### Rec 1.1 Use more accurate names for identifiers with a large scope.
Different from C++, C does not have namespace or class. Therefore, the names of identifiers in the global scope must not conflict with each other. Different from C++, C does not have namespace or class. Therefore, the names of identifiers in the global scope must not conflict with each other.
Names of global functions, global variables, macros, types, and enums must be accurately described and unique in the global scope. Names of global functions, global variables, macros, types, and enums must be accurately described and unique in the global scope.
Example: Example:
...@@ -75,7 +88,9 @@ int GetActiveConnectCount(void); // Good ...@@ -75,7 +88,9 @@ int GetActiveConnectCount(void); // Good
``` ```
For purposes of accurate naming, a module prefix can be added if necessary. For purposes of accurate naming, a module prefix can be added if necessary.
The module prefix and the naming body can be connected by following the CamelCase style. The module prefix and the naming body can be connected by following the CamelCase style.
Example: Example:
```c ```c
...@@ -86,26 +101,30 @@ enum XxxMyEnum { // OK ...@@ -86,26 +101,30 @@ enum XxxMyEnum { // OK
}; };
``` ```
## <a name="c1-2"></a>File Naming ## File Naming
### <a name="a1-2"></a>Rec 1.2 Use lowercase file names. ### Rec 1.2 Use lowercase file names.
Only lowercase letters, numbers, and underscores (\_) are allowed in file names. Only lowercase letters, numbers, and underscores (\_) are allowed in file names.
File names should be as short, accurate, and unambiguous as possible. File names should be as short, accurate, and unambiguous as possible.
The reason for using lowercase file names is that different systems process file names in different ways. (For example, file names in MS-DOS and Windows are not case sensitive, but those in Unix/Linux and macOS are case sensitive by default). The reason for using lowercase file names is that different systems process file names in different ways. (For example, file names in MS-DOS and Windows are not case sensitive, but those in Unix/Linux and macOS are case sensitive by default).
Good example: Good example:
`dhcp_user_log.c` `dhcp_user_log.c`
Bad examples: Bad examples:
`dhcp_user-log.c`: It is not recommended that you separate words with the hyphen (-). `dhcp_user-log.c`: It is not recommended that you separate words with the hyphen (-).
`dhcpuserlog.c`: The words are not separated, causing poor readability. `dhcpuserlog.c`: The words are not separated, causing poor readability.
## <a name="c1-3"></a>Function Naming ## Function Naming
Functions are named in the UpperCamelCase style. Functions are named in the UpperCamelCase style.
### <a name="a1-3"></a>Rec 1.3 Name functions to comply with reading habits. ### Rec 1.3 Name functions to comply with reading habits.
The "verb + object" structure can be used for action related function names. Example: The "verb + object" structure can be used for action related function names. Example:
...@@ -130,13 +149,14 @@ TotalCount() // OK ...@@ -130,13 +149,14 @@ TotalCount() // OK
GetTotalCount() // OK GetTotalCount() // OK
``` ```
## <a name="c1-4"></a>Variable Naming ## Variable Naming
Variables are named in the lowerCamelCase style. This includes global variables, local variables, parameters in the function declaration or definition as well as parameters in function-like macro. Variables are named in the lowerCamelCase style. This includes global variables, local variables, parameters in the function declaration or definition as well as parameters in function-like macro.
### <a name="r1-2"></a>Rule 1.2 Add the 'g_' prefix to global variables, but not to static variables in a function. ### Rule 1.2 Add the 'g_' prefix to global variables, but not to static variables in a function.
Global variables should be used as little as possible, and special attention should be paid to their use. This prefix highlights global variables so that developers can be more careful when handling them. Global variables should be used as little as possible, and special attention should be paid to their use. This prefix highlights global variables so that developers can be more careful when handling them.
Global static variables and global variables are named in the same way. Static variables in functions and common local variables are named in the same way. Global static variables and global variables are named in the same way. Static variables in functions and common local variables are named in the same way.
```c ```c
...@@ -151,7 +171,7 @@ void Func(void) ...@@ -151,7 +171,7 @@ void Func(void)
Notes: Constants are also global variables in essence. However, if constants are named using uppercase letters separated by underscores (\_), the current rule does not apply. Notes: Constants are also global variables in essence. However, if constants are named using uppercase letters separated by underscores (\_), the current rule does not apply.
### <a name="a1-4"></a>Rec 1.4 Keep local variables short and to the point. ### Rec 1.4 Keep local variables short and to the point.
The name of a local variable should be short on the premise that meanings can be expressed through context. The name of a local variable should be short on the premise that meanings can be expressed through context.
...@@ -184,6 +204,7 @@ int Func(...) ...@@ -184,6 +204,7 @@ int Func(...)
``` ```
Similarly, "tmp" can be used to address any type of temporary variable. Similarly, "tmp" can be used to address any type of temporary variable.
A short variable name should be used with caution, but sometimes a single-character variable is allowed, for example, a counter variable in a loop statement. A short variable name should be used with caution, but sometimes a single-character variable is allowed, for example, a counter variable in a loop statement.
```c ```c
...@@ -203,7 +224,7 @@ int Mul(int a, int b) ...@@ -203,7 +224,7 @@ int Mul(int a, int b)
} }
``` ```
## <a name="c1-5"></a>Type Naming ## Type Naming
Types are named in the UpperCamelCase style. Types are named in the UpperCamelCase style.
...@@ -248,14 +269,18 @@ typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'. ...@@ -248,14 +269,18 @@ typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'.
} Node; // UpperCamelCase. } Node; // UpperCamelCase.
``` ```
## <a name="c1-6"></a>Macro, Constant, and Enum Naming ## Macro, Constant, and Enum Naming
Use uppercase letters separated by underscores (\_) for macro names and enumerated values. Use uppercase letters separated by underscores (\_) for macro names and enumerated values.
You are advised to use uppercase letters separated with underscores (\_) for constant names. Global const variables can be named with the same style of global variables. You are advised to use uppercase letters separated with underscores (\_) for constant names. Global const variables can be named with the same style of global variables.
The constants here are defined as global const variables of the basic data type, enum type, or string type. The constants here are defined as global const variables of the basic data type, enum type, or string type.
Use uppercase letters separated by underscores (\_) for function-like macros. Use uppercase letters separated by underscores (\_) for function-like macros.
Exceptions: Exceptions:
1. Functions that use macros to implement generic functions, for example, macros that implement functions such as list and map, can be named in the same way as functions, using the UpperCamelCase style. 1. Functions that use macros to implement generic functions, for example, macros that implement functions such as list and map, can be named in the same way as functions, using the UpperCamelCase style.
2. A function-like macro that is used to replace a function in the earlier version can be named in the same way as functions, using the UpperCamelCase style. 2. A function-like macro that is used to replace a function in the earlier version can be named in the same way as functions, using the UpperCamelCase style.
3. Macros for printing logs can be named in the same way as functions, using the UpperCamelCase style. 3. Macros for printing logs can be named in the same way as functions, using the UpperCamelCase style.
...@@ -317,7 +342,7 @@ enum BaseColor { ...@@ -317,7 +342,7 @@ enum BaseColor {
}; };
``` ```
### <a name="a1-6"></a>Rec 1.5 Avoid temporary variables in function-like macros from polluting external scopes. ### Rec 1.5 Avoid temporary variables in function-like macros from polluting external scopes.
**If possible, use a function instead of a function-like macro. Define a function-like macro only when necessary.** **If possible, use a function instead of a function-like macro. Define a function-like macro only when necessary.**
...@@ -330,15 +355,18 @@ When defining local variables for a function-like macro, use double underscores ...@@ -330,15 +355,18 @@ When defining local variables for a function-like macro, use double underscores
} while (0) } while (0)
``` ```
# <a name="c2"></a>2 Formatting # 2 Formatting
## <a name="c2-1"></a>Line Length ## Line Length
### <a name="r2-1"></a>Rule 2.1 Include 120 characters or less in each line. ### Rule 2.1 Include 120 characters or less in each line.
A longer line makes it more difficult for reading. A longer line makes it more difficult for reading.
To meet the line length requirement, you can shorten the names of functions and variables and reduce the number of nesting layers. This improves code readability. To meet the line length requirement, you can shorten the names of functions and variables and reduce the number of nesting layers. This improves code readability.
Unless a long line is necessary to maintain readability and present complete information, steer your document clear of long lines. Unless a long line is necessary to maintain readability and present complete information, steer your document clear of long lines.
Even on a high-resolution monitor, a long line increases the difficulty of reading. Strive for clearness and conciseness. Even on a high-resolution monitor, a long line increases the difficulty of reading. Strive for clearness and conciseness.
Exceptions: Exceptions:
...@@ -354,19 +382,22 @@ Example: ...@@ -354,19 +382,22 @@ Example:
#endif #endif
``` ```
## <a name="c2-2"></a>Indentation ## Indentation
### <a name="r2-2"></a>Rule 2.2 Use spaces to indent and indent four spaces at a time. ### Rule 2.2 Use spaces to indent and indent four spaces at a time.
Only spaces can be used for indentation. Four spaces are indented each time. Do not use the Tab character to indent. Only spaces can be used for indentation. Four spaces are indented each time. Do not use the Tab character to indent.
Currently, almost all integrated development environments (IDEs) and code editors support automatic conversion of a Tab input to fours spaces. Configure your code editor to support indentation with spaces. Currently, almost all integrated development environments (IDEs) and code editors support automatic conversion of a Tab input to fours spaces. Configure your code editor to support indentation with spaces.
## <a name="c2-3"></a>Braces ## Braces
### <a name="r2-3"></a>Rule 2.3 Use the K\&R indentation style. ### Rule 2.3 Use the K\&R indentation style.
**K\&R style** **K\&R style**
While wrapping a line, the left brace of the function starts a new line and takes a single line. Other left braces are placed at the end of the line along with the statement. While wrapping a line, the left brace of the function starts a new line and takes a single line. Other left braces are placed at the end of the line along with the statement.
The right brace takes a single line, unless it is followed by the rest of the same statement, such as `while` in the `do` statement, `else` or `else if` in the `if` statement, a comma, or a semicolon. The right brace takes a single line, unless it is followed by the rest of the same statement, such as `while` in the `do` statement, `else` or `else if` in the `if` statement, a comma, or a semicolon.
Example: Example:
...@@ -386,9 +417,9 @@ int Foo(int a) ...@@ -386,9 +417,9 @@ int Foo(int a)
} }
``` ```
## <a name="c2-4"></a>Function Declaration and Definition ## Function Declaration and Definition
### <a name="r2-4"></a>Rule 2.4 Keep the return type and function name of the function declaration or definition in the same line, and align the function parameter list appropriately if it needs to be wrapped. ### Rule 2.4 Keep the return type and function name of the function declaration or definition in the same line, and align the function parameter list appropriately if it needs to be wrapped.
When a function is declared and defined, the return value type of the function should be in the same line as the function name. When a function is declared and defined, the return value type of the function should be in the same line as the function name.
...@@ -423,11 +454,12 @@ ReturnType ReallyReallyReallyReallyLongFunctionName( // The line leng ...@@ -423,11 +454,12 @@ ReturnType ReallyReallyReallyReallyLongFunctionName( // The line leng
} }
``` ```
## <a name="c2-5"></a>Function Calls ## Function Calls
### <a name="r2-5"></a>Rule 2.5 Align the parameter list appropriately if it needs to be wrapped. ### Rule 2.5 Align the parameter list appropriately if it needs to be wrapped.
In a function call, if the function parameter list is wrapped, it should be aligned appropriately. In a function call, if the function parameter list is wrapped, it should be aligned appropriately.
The left parenthesis is always followed by a function name, and the right parenthesis always follows the last parameter. The left parenthesis is always followed by a function name, and the right parenthesis always follows the last parameter.
Example: Example:
...@@ -454,11 +486,12 @@ int result = DealWithStructureLikeParams(left.x, left.y, // Indicates a grou ...@@ -454,11 +486,12 @@ int result = DealWithStructureLikeParams(left.x, left.y, // Indicates a grou
right.x, right.y); // Indicates another group of related parameters. right.x, right.y); // Indicates another group of related parameters.
``` ```
## <a name="c2-6"></a>Conditional Statements ## Conditional Statements
### <a name="r2-6"></a>Rule 2.6 Use braces for conditional statements. ### Rule 2.6 Use braces for conditional statements.
Use braces to enclose conditional statements, even if there is only one statement. Use braces to enclose conditional statements, even if there is only one statement.
Reason: Reason:
- Logic is intuitive and easy to read. - Logic is intuitive and easy to read.
...@@ -471,7 +504,7 @@ if (objectIsNotExist) { // Good: Braces are added to a single-line condi ...@@ -471,7 +504,7 @@ if (objectIsNotExist) { // Good: Braces are added to a single-line condi
} }
``` ```
### <a name="r2-7"></a>Rule 2.7 Do not place `if`, `else`, and `else if` in the same line. ### Rule 2.7 Do not place `if`, `else`, and `else if` in the same line.
In a conditional statement, branches, if any, should be written in different lines. In a conditional statement, branches, if any, should be written in different lines.
...@@ -491,9 +524,9 @@ Bad example: ...@@ -491,9 +524,9 @@ Bad example:
if (someConditions) { ... } else { ... } // Bad: They are in the same line. if (someConditions) { ... } else { ... } // Bad: They are in the same line.
``` ```
## <a name="c2-7"></a>Loops ## Loops
### <a name="r2-8"></a>Rule 2.8 Use braces for loop statements. ### Rule 2.8 Use braces for loop statements.
Use braces to enclose the `for` and `while` statements, even if there is only one loop. Use braces to enclose the `for` and `while` statements, even if there is only one loop.
...@@ -524,9 +557,9 @@ for (int i = 0; i < someRange; i++) ...@@ -524,9 +557,9 @@ for (int i = 0; i < someRange; i++)
while (condition); // Bad: The semicolon may be treated as part of the `while` statement. while (condition); // Bad: The semicolon may be treated as part of the `while` statement.
``` ```
## <a name="c2-8"></a>`switch` Statements ## `switch` Statements
### <a name="r2-9"></a>Rule 2.9 Indent the `case` or `default` statement in a `switch` statement block. ### Rule 2.9 Indent the `case` or `default` statement in a `switch` statement block.
Use the following indentation style for the `switch` statement: Use the following indentation style for the `switch` statement:
...@@ -554,9 +587,9 @@ default: // Bad: 'default' not indented ...@@ -554,9 +587,9 @@ default: // Bad: 'default' not indented
} }
``` ```
## <a name="c2-9"></a>Expressions ## Expressions
### <a name="a2-1"></a>Rec 2.1 Keep a consistent line break style for expressions and ensure that operators are placed at the end of the line. ### Rec 2.1 Keep a consistent line break style for expressions and ensure that operators are placed at the end of the line.
A long expression that does not meet the line length requirement must be wrapped appropriately. Generally, the expression is wrapped after a lower-priority operator or a hyphen, and the operator or hyphen is placed at the end of the line, indicating that the operation is to be continued. A long expression that does not meet the line length requirement must be wrapped appropriately. Generally, the expression is wrapped after a lower-priority operator or a hyphen, and the operator or hyphen is placed at the end of the line, indicating that the operation is to be continued.
...@@ -584,9 +617,9 @@ int sum = longVariableName1 + longVariableName2 + longVariableName3 + ...@@ -584,9 +617,9 @@ int sum = longVariableName1 + longVariableName2 + longVariableName3 +
longVariableName4 + longVariableName5 + longVariableName6; // OK: aligned longVariableName4 + longVariableName5 + longVariableName6; // OK: aligned
``` ```
## <a name="c2-10"></a>Variable Assignment ## Variable Assignment
### <a name="r2-10"></a> Rule 2.10 Do not write multiple variable definitions or assignment statements in one line. ### Rule 2.10 Do not write multiple variable definitions or assignment statements in one line.
It is recommended that each line contain only one variable initialization statement, which is easier to read and understand. It is recommended that each line contain only one variable initialization statement, which is easier to read and understand.
...@@ -619,13 +652,14 @@ for (i = 0; i < row; i++) { ...@@ -619,13 +652,14 @@ for (i = 0; i < row; i++) {
} }
``` ```
## <a name="c2-11"></a>Initialization ## Initialization
Initialization is applicable to structs, unions, and arrays. Initialization is applicable to structs, unions, and arrays.
### <a name="r2-11"></a>Rule 2.11 Use indentation or make a reasonable alignment for a new line. ### Rule 2.11 Use indentation or make a reasonable alignment for a new line.
For the struct or array initialization, use 4 spaces for indentation if a line break is made. For the struct or array initialization, use 4 spaces for indentation if a line break is made.
From better readability, make a reasonable alignment. From better readability, make a reasonable alignment.
```c ```c
...@@ -669,7 +703,7 @@ Note: ...@@ -669,7 +703,7 @@ Note:
- If the left brace is placed at the end of the line, the corresponding right brace should be placed into a new line. - If the left brace is placed at the end of the line, the corresponding right brace should be placed into a new line.
- If the left brace is followed by the content, the corresponding right brace should also follow the content. - If the left brace is followed by the content, the corresponding right brace should also follow the content.
### <a name="r2-12"></a>Rule 2.12 Initialize each member in a separate line during struct and union member initialization. ### Rule 2.12 Initialize each member in a separate line during struct and union member initialization.
The C99 standard supports the initialization of the struct and union members in their definition. This is called the designated initializer. In such a way, each member should be initialized in a separate line. The C99 standard supports the initialization of the struct and union members in their definition. This is called the designated initializer. In such a way, each member should be initialized in a separate line.
...@@ -687,9 +721,9 @@ struct Date date = { // Good: When the designated initializer is used, each m ...@@ -687,9 +721,9 @@ struct Date date = { // Good: When the designated initializer is used, each m
}; };
``` ```
## <a name="c2-12"></a>Pointers ## Pointers
### <a name="a2-2"></a>Rec 2.2 Ensure that the asterisk (\*) in the pointer type is followed by the variable name or follows the type. There must be a space before or after the asterisk. ### Rec 2.2 Ensure that the asterisk (\*) in the pointer type is followed by the variable name or follows the type. There must be a space before or after the asterisk.
When you declare or define a pointer variable or return a pointer type function, the asterisk can be placed on the left (following the type) or right (followed by the variable name). There must be only one space before or after the asterisk. When you declare or define a pointer variable or return a pointer type function, the asterisk can be placed on the left (following the type) or right (followed by the variable name). There must be only one space before or after the asterisk.
...@@ -719,16 +753,17 @@ int Foo(const char * restrict p); // OK ...@@ -719,16 +753,17 @@ int Foo(const char * restrict p); // OK
Do not use the asterisk to follow the `const` or `restrict` keywords. Do not use the asterisk to follow the `const` or `restrict` keywords.
## <a name="c2-13"></a>Compilation Preprocessing ## Compilation Preprocessing
### <a name="r2-13"></a>Rule 2.13 Place the number sign (#) at the beginning of a line for compilation preprocessing. In nested compilation preprocessing, the number sign (#) can be indented. ### Rule 2.13 Place the number sign (#) at the beginning of a line for compilation preprocessing. In nested compilation preprocessing, the number sign (#) can be indented.
The number sign (#) must be placed at the beginning of a line for compilation preprocessing, even if the code is embedded in the function body. The number sign (#) must be placed at the beginning of a line for compilation preprocessing, even if the code is embedded in the function body.
Try your best not to use compilation preprocessing macros. If they are needed in deed, they should be managed by dedicated personnel in a unified manner. Try your best not to use compilation preprocessing macros. If they are needed in deed, they should be managed by dedicated personnel in a unified manner.
## <a name="c2-14"></a>Whitespace ## Whitespace
### <a name="r2-14"></a>Rule 2.14 Use horizontal whitespaces to highlight keywords and important information, and avoid unnecessary whitespaces. ### Rule 2.14 Use horizontal whitespaces to highlight keywords and important information, and avoid unnecessary whitespaces.
Horizontal spaces should be used to highlight keywords and important information. Do not add spaces at the end of each line of code. The general rules are as follows: Horizontal spaces should be used to highlight keywords and important information. Do not add spaces at the end of each line of code. The general rules are as follows:
...@@ -821,7 +856,7 @@ switch (var) { // Good: A space is added after the `switch` keyword. ...@@ -821,7 +856,7 @@ switch (var) { // Good: A space is added after the `switch` keyword.
Note: The current IDE and code editor can be set to delete spaces at the end of a line. Configure your editor correctly. Note: The current IDE and code editor can be set to delete spaces at the end of a line. Configure your editor correctly.
### <a name="a2-3"></a>Rec 2.3 Arrange blank lines reasonably to keep the code compact. ### Rec 2.3 Arrange blank lines reasonably to keep the code compact.
Reduce unnecessary blank lines so that more code can be displayed for easy reading. The following rules are recommended: Reduce unnecessary blank lines so that more code can be displayed for easy reading. The following rules are recommended:
...@@ -862,7 +897,7 @@ int Foo(void) ...@@ -862,7 +897,7 @@ int Foo(void)
} }
``` ```
# <a name="c3"></a>3 Comments # 3 Comments
Generally, clear architecture and good symbol naming are recommended to improve code readability, and comments are provided only when necessary. Generally, clear architecture and good symbol naming are recommended to improve code readability, and comments are provided only when necessary.
...@@ -873,6 +908,7 @@ The comments must be concise, clear, and unambiguous, ensuring that the informat ...@@ -873,6 +908,7 @@ The comments must be concise, clear, and unambiguous, ensuring that the informat
**Comments are as important as code.** **Comments are as important as code.**
When writing a comment, you need to step into the reader's shoes and use comments to express what the reader really needs. Comments are used to express the code functionality and intention, rather than repeating code. When writing a comment, you need to step into the reader's shoes and use comments to express what the reader really needs. Comments are used to express the code functionality and intention, rather than repeating code.
When modifying the code, ensure that the comments are consistent. It is impolite to only modify code and not update the comments. This destroys the consistency between code and comments, and may cause confusion or even misleading. When modifying the code, ensure that the comments are consistent. It is impolite to only modify code and not update the comments. This destroys the consistency between code and comments, and may cause confusion or even misleading.
Comment code in fluent **English**. Comment code in fluent **English**.
...@@ -883,18 +919,19 @@ Comments must be added in the following scenarios (including but not limited to ...@@ -883,18 +919,19 @@ Comments must be added in the following scenarios (including but not limited to
3. Core algorithms 3. Core algorithms
4. A function that contains more than 50 lines 4. A function that contains more than 50 lines
## <a name="c3-1"></a>Comment Style ## Comment Style
In C code, both `/*` `*/` and `//` can be used. In C code, both `/*` `*/` and `//` can be used.
Comments can be classified into different types depending on the purpose and position, such as file header comments, function header comments, and general comments. Comments can be classified into different types depending on the purpose and position, such as file header comments, function header comments, and general comments.
Comments of the same type must keep a consistent style. Comments of the same type must keep a consistent style.
Note: The sample code used in this article sees extensive use of the '//' post-comment. This is only for better understanding, and does not mean that this comment style is better. Note: The sample code used in this article sees extensive use of the '//' post-comment. This is only for better understanding, and does not mean that this comment style is better.
## <a name="c3-2"></a>File Header Comments ## File Header Comments
### <a name="r3-1"></a>Rule 3.1 Include the copyright license in the file header comments. ### Rule 3.1 Include the copyright license in the file header comments.
/\* /\*
...@@ -911,9 +948,9 @@ Note: The sample code used in this article sees extensive use of the '//' post-c ...@@ -911,9 +948,9 @@ Note: The sample code used in this article sees extensive use of the '//' post-c
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. \*/ * limitations under the License. \*/
## <a name="c3-3"></a>Function Header Comments ## Function Header Comments
### <a name="r3-2"></a>Rule 3.2 Do not use empty function header comments with no content. ### Rule 3.2 Do not use empty function header comments with no content.
Not all functions need function header comments. Not all functions need function header comments.
...@@ -948,9 +985,11 @@ int Func2(void); ...@@ -948,9 +985,11 @@ int Func2(void);
``` ```
Use function names to describe functions, and only add function header comments if necessary. Use function names to describe functions, and only add function header comments if necessary.
Do not write useless or redundant function headers. Do not write empty function headers with no content. Do not write useless or redundant function headers. Do not write empty function headers with no content.
The following content is **optional** in the function header comment: function description, return value, performance constraint, usage, memory convention, algorithm implementation, and reentering requirement. The following content is **optional** in the function header comment: function description, return value, performance constraint, usage, memory convention, algorithm implementation, and reentering requirement.
In the function interface declaration in the external header file of the module, the function header comment should clearly describe important and useful information. In the function interface declaration in the external header file of the module, the function header comment should clearly describe important and useful information.
Example: Example:
...@@ -981,11 +1020,11 @@ Problems in the preceding example are as follows: ...@@ -981,11 +1020,11 @@ Problems in the preceding example are as follows:
- The function name has redundant information. - The function name has redundant information.
- It does not clearly state the party that should release the buffer. - It does not clearly state the party that should release the buffer.
## <a name="c3-4"></a>Code Comments ## Code Comments
### <a name="r3-3"></a>Rule 3.3 Place code comments above or to the right of the code. ### Rule 3.3 Place code comments above or to the right of the code.
### <a name="r3-4"></a>Rule 3.4 Add a space between the comment character and the comment content, and one space between the comment and code if the comment is placed to the right of the code. ### Rule 3.4 Add a space between the comment character and the comment content, and one space between the comment and code if the comment is placed to the right of the code.
Comments placed above code should be indented to the same level as the code. Comments placed above code should be indented to the same level as the code.
...@@ -1041,14 +1080,15 @@ Example: ...@@ -1041,14 +1080,15 @@ Example:
If the comment on the right exceeds the permitted line length, the comment can be placed above the code. If the comment on the right exceeds the permitted line length, the comment can be placed above the code.
### <a name="r3-5"></a>Rule 3.5 Delete unused code segments. Do not comment them out. ### Rule 3.5 Delete unused code segments. Do not comment them out.
Code that is commented out cannot be maintained. If you attempt to restore the code, it is very likely to introduce ignorable defects. Code that is commented out cannot be maintained. If you attempt to restore the code, it is very likely to introduce ignorable defects.
The correct method is to delete unnecessary code. If necessary, consider porting or rewriting the code. The correct method is to delete unnecessary code. If necessary, consider porting or rewriting the code.
Here, commenting out refers to the removal of code from compilation without actually deleting it. This is done by using /\* \*/, //, #if 0, #ifdef NEVER\_DEFINED, and so on. Here, commenting out refers to the removal of code from compilation without actually deleting it. This is done by using /\* \*/, //, #if 0, #ifdef NEVER\_DEFINED, and so on.
### <a name="a3-1"></a>Rec 3.1 Provide comments if `break` or `return` is not added to the end of the `case` statement block (fall-through). ### Rec 3.1 Provide comments if `break` or `return` is not added to the end of the `case` statement block (fall-through).
Sometimes, the same thing is needed for multiple `case` tags. When a `case` statement ends without `break` or `return`, the statement in the next `case` tag will be executed. This is called "fall-through". Sometimes, the same thing is needed for multiple `case` tags. When a `case` statement ends without `break` or `return`, the statement in the next `case` tag will be executed. This is called "fall-through".
...@@ -1085,14 +1125,15 @@ switch (var) { ...@@ -1085,14 +1125,15 @@ switch (var) {
} }
``` ```
# <a name="c4"></a>4 Header Files # 4 Header Files
**For the C programming language, the design of the header file reflects most of the system design.** **For the C programming language, the design of the header file reflects most of the system design.**
The correct use of the header file makes code more readable, reduces file size, and speeds up compilation and build performance. The correct use of the header file makes code more readable, reduces file size, and speeds up compilation and build performance.
The following programming specifications aim to help you properly plan header files. The following programming specifications aim to help you properly plan header files.
## <a name="c4-1"></a>Header File Responsibility ## Header File Responsibility
A header file is an external interface of a module or file. A header file is an external interface of a module or file.
...@@ -1108,6 +1149,7 @@ If a .c file does not need to open any interface externally, it should not exist ...@@ -1108,6 +1149,7 @@ If a .c file does not need to open any interface externally, it should not exist
Exceptions: the entry point of the program (for example, the file where the main function is located), unit test code, and dynamic library code. Exceptions: the entry point of the program (for example, the file where the main function is located), unit test code, and dynamic library code.
Example: Example:
Content of **foo.h**: Content of **foo.h**:
```c ```c
...@@ -1147,28 +1189,33 @@ Some simple header files, such as the command ID definition header file, do not ...@@ -1147,28 +1189,33 @@ Some simple header files, such as the command ID definition header file, do not
If a set of interface protocols has multiple instances and the interface is fixed, one .h file can have multiple .c files. If a set of interface protocols has multiple instances and the interface is fixed, one .h file can have multiple .c files.
### <a name="a4-2"></a>Rec 4.2 Use .h as the extension of the header file, rather than other unconventional extensions, for example, .inc. ### Rec 4.2 Use .h as the extension of the header file, rather than other unconventional extensions, for example, .inc.
Some products use .inc as the header file name extension, which does not comply with the C programming language. A header file using .inc as the file name extension usually indicates a private header file.
Some products use .inc as the header file name extension, which does not comply with the C programming language. A header file using .inc as the file name extension usually indicates a private header file. However, in practice, this recommendation is not followed properly. An .inc file is generally contained in multiple .c files. It is not recommended that private definitions be stored in header files. For details, see [Rec 4.1](#a4-1). However, in practice, this recommendation is not followed properly. An .inc file is generally contained in multiple .c files. It is not recommended that private definitions be stored in header files. For details, see [Rec 4.1](#a4-1).
## <a name="c4-2"></a>Header File Dependency ## Header File Dependency
The header file contains a dependency, and the dependency should be stable. The header file contains a dependency, and the dependency should be stable.
Generally, an unstable module depends on a stable module. When the unstable module changes, the build of the stable module is not affected. Generally, an unstable module depends on a stable module. When the unstable module changes, the build of the stable module is not affected.
Dependency direction is as follows: Products depend on the platform, and the platform depends on the standard library. Dependency direction is as follows: Products depend on the platform, and the platform depends on the standard library.
In addition to unstable modules depending on stable modules, each module depends on the interface. In this way, in case of any internal implementation changes to one module, users do not need to recompile another module. In addition to unstable modules depending on stable modules, each module depends on the interface. In this way, in case of any internal implementation changes to one module, users do not need to recompile another module.
It is assumed that the interface is the most stable. It is assumed that the interface is the most stable.
### <a name="r4-1"></a>Rule 4.1 Forbid cyclic dependency of header files. ### Rule 4.1 Forbid cyclic dependency of header files.
Cyclic dependency (also known as a circular dependency) of header files means that a.h contains b.h, b.h contains c.h, and c.h contains a.h. If any header file is modified, all code containing a.h, b.h, and c.h needs to be recompiled. Cyclic dependency (also known as a circular dependency) of header files means that a.h contains b.h, b.h contains c.h, and c.h contains a.h. If any header file is modified, all code containing a.h, b.h, and c.h needs to be recompiled.
For a unidirectional dependency: a.h contains b.h, b.h contains c.h, and c.h does not contain any header file, modifying a.h does not mean a need to recompile the source code for b.h or c.h. For a unidirectional dependency: a.h contains b.h, b.h contains c.h, and c.h does not contain any header file, modifying a.h does not mean a need to recompile the source code for b.h or c.h.
The cyclic dependency of header files reflects an obviously unreasonable architecture design, which can be avoided through optimization. The cyclic dependency of header files reflects an obviously unreasonable architecture design, which can be avoided through optimization.
### <a name="r4-4"></a>Rule 4.2 Include the internal #include protection character (#define protection) in the header file. ### Rule 4.2 Include the internal #include protection character (#define protection) in the header file.
To prevent header files from being included multiple times, all header files should be protected by #define. Do not use #pragma once. To prevent header files from being included multiple times, all header files should be protected by #define. Do not use #pragma once.
...@@ -1187,13 +1234,16 @@ Assume that the **timer.h** file of the timer component of the util subsystem is ...@@ -1187,13 +1234,16 @@ Assume that the **timer.h** file of the timer component of the util subsystem is
#endif // UTIL_TIMER_TIMER_H #endif // UTIL_TIMER_TIMER_H
``` ```
### <a name="r4-5"></a>Rule 4.3 Do not reference external function interfaces and variables by using declaration. ### Rule 4.3 Do not reference external function interfaces and variables by using declaration.
You can use the interfaces provided by other modules or files only by using header files. You can use the interfaces provided by other modules or files only by using header files.
Using external function interfaces and variables with an extern declaration may cause inconsistency between declarations and definitions when external interfaces are changed. Using external function interfaces and variables with an extern declaration may cause inconsistency between declarations and definitions when external interfaces are changed.
In addition, this kind of implicit dependency may cause architecture corruption. In addition, this kind of implicit dependency may cause architecture corruption.
Cases that do not comply with specifications: Cases that do not comply with specifications:
Content of **a.c**: Content of **a.c**:
```c ```c
...@@ -1233,11 +1283,14 @@ int Foo(void) ...@@ -1233,11 +1283,14 @@ int Foo(void)
``` ```
In some scenarios, if internal functions need to be referenced with no intrusion to the code, the extern declaration mode can be used. In some scenarios, if internal functions need to be referenced with no intrusion to the code, the extern declaration mode can be used.
Example: Example:
When performing unit testing on an internal function, you can use the extern declaration to reference the tested function. When performing unit testing on an internal function, you can use the extern declaration to reference the tested function.
When a function needs to be stubbed or patched, the function can be declared using extern. When a function needs to be stubbed or patched, the function can be declared using extern.
### <a name="r4-6"></a>Rule 4.4 Do not include header files in extern "C". ### Rule 4.4 Do not include header files in extern "C".
If a header file is included in extern "C", extern "C" may be nested. Some compilers restrict the number of nesting layers of extern "C". Too many nesting layers may cause compilation errors. If a header file is included in extern "C", extern "C" may be nested. Some compilers restrict the number of nesting layers of extern "C". Too many nesting layers may cause compilation errors.
...@@ -1281,38 +1334,46 @@ extern "C" { ...@@ -1281,38 +1334,46 @@ extern "C" {
} }
``` ```
In the **a.h** file, the **Foo** function is intended to be a C++ free function following the C++ specifications. However, in the **b.h** file, because `#include "a.h"` is placed inside `extern "C"`, the linking specification of the **Foo** function is changed incorrectly. In the **a.h** file, the **Foo** function is intended to be a C++ free function following the C++ specifications.
However, in the **b.h** file, because `#include "a.h"` is placed inside `extern "C"`, the linking specification of the **Foo** function is changed incorrectly.
Exceptions: In the C++ compilation environment, if you want to reference a header file written in pure C, a non-intrusive approach is to exclude the C header file from `extern "C"`. Exceptions: In the C++ compilation environment, if you want to reference a header file written in pure C, a non-intrusive approach is to exclude the C header file from `extern "C"`.
# <a name="c5"></a>5 Functions # 5 Functions
Functions help avoid repeated code and increase reusability. Functions are layered to reduce complexity and hide implementation details, making programs more modular and facilitating code reading and maintenance. Functions help avoid repeated code and increase reusability. Functions are layered to reduce complexity and hide implementation details, making programs more modular and facilitating code reading and maintenance.
Functions should be concise and short. Functions should be concise and short.
One function completes only one thing. One function completes only one thing.
## <a name="c5-1"></a>Function Design ## Function Design
The essence of function design is to write clean functions and organize code effectively. The code should be simple and not conceal the designer's intention, using clean abstractions and straightforward control statements to organize the function naturally. The essence of function design is to write clean functions and organize code effectively. The code should be simple and not conceal the designer's intention, using clean abstractions and straightforward control statements to organize the function naturally.
### <a name="r5-1"></a>Rule 5.1 Avoid long functions and ensure that functions contain no more than 50 lines (excluding blank lines and comments). ### Rule 5.1 Avoid long functions and ensure that functions contain no more than 50 lines (excluding blank lines and comments).
A function should be able to be displayed on one screen (fewer than 50 lines). It does only one thing and does it well. A function should be able to be displayed on one screen (fewer than 50 lines). It does only one thing and does it well.
A long function usually means that it aims to implement complex functionalities or contains excess details. A long function usually means that it aims to implement complex functionalities or contains excess details.
Exceptions: Exceptions:
Considering the code's aggregation and functionality, some functions may exceed 50 lines, but only if the code is readable and concise. Considering the code's aggregation and functionality, some functions may exceed 50 lines, but only if the code is readable and concise.
These exceptions should be minimal, such as specific algorithm processing. These exceptions should be minimal, such as specific algorithm processing.
Even if a large function works well in the moment, once someone modifies it, new problems may occur. It may even cause bugs that are difficult to discover. Even if a large function works well in the moment, once someone modifies it, new problems may occur. It may even cause bugs that are difficult to discover.
It is recommended that you split the code into several functions that are simpler and easier to manage so that others can easily read and modify the code. It is recommended that you split the code into several functions that are simpler and easier to manage so that others can easily read and modify the code.
### <a name="r5-2"></a>Rule 5.2 Avoid nesting a code block more than four times within a function. ### Rule 5.2 Avoid nesting a code block more than four times within a function.
The nested code block depth of a function refers to the layered depth of a code control block (created by statements such as `if`, `for`, `while`, and `switch`). The nested code block depth of a function refers to the layered depth of a code control block (created by statements such as `if`, `for`, `while`, and `switch`).
Each layer of nesting increases the difficulty in reading the code. Each layer of nesting increases the difficulty in reading the code.
Further functional decomposition should be done for better understanding. Further functional decomposition should be done for better understanding.
Using `guard clauses` can effectively reduce the nesting layers of the `if` statements. Example: Using `guard clauses` can effectively reduce the nesting layers of the `if` statements. Example:
...@@ -1350,10 +1411,12 @@ int Foo(...) ...@@ -1350,10 +1411,12 @@ int Foo(...)
``` ```
Exceptions: Exceptions:
Considering the code's aggregation and functionality, some functions may contain 4 or more nesting layers, but only if the code is readable and concise. Considering the code's aggregation and functionality, some functions may contain 4 or more nesting layers, but only if the code is readable and concise.
These exceptions should be rare. These exceptions should be rare.
### <a name="a5-1"></a>Rec 5.1 Process all returned error codes. ### Rec 5.1 Process all returned error codes.
A function (in a standard library, a third-party library, or a user-defined function) must be able to indicate errors. This can be done by using error tags, special return data, or other means. No matter when a function provides such a mechanism, the caller should immediately check the error indication after the function returns. A function (in a standard library, a third-party library, or a user-defined function) must be able to indicate errors. This can be done by using error tags, special return data, or other means. No matter when a function provides such a mechanism, the caller should immediately check the error indication after the function returns.
...@@ -1379,11 +1442,12 @@ DealWithFileHead(fileHead, sizeof(fileHead)); // Process the file header. ...@@ -1379,11 +1442,12 @@ DealWithFileHead(fileHead, sizeof(fileHead)); // Process the file header.
``` ```
If the return value of a function is ignored and `void` is returned frequently, check whether the return value of the function is designed properly. If the return value of a function is ignored and `void` is returned frequently, check whether the return value of the function is designed properly.
Only if the caller of a function really doesn't need a return value, should you design the function to return `void`. Only if the caller of a function really doesn't need a return value, should you design the function to return `void`.
## <a name="c5-2"></a>Function Parameters ## Function Parameters
### <a name="a5-2"></a>Rec 5.2 Use the return value instead of the output parameter when designing a function. ### Rec 5.2 Use the return value instead of the output parameter when designing a function.
Using return values rather than output parameters improves readability and usually provides the same or better performance. Using return values rather than output parameters improves readability and usually provides the same or better performance.
...@@ -1393,17 +1457,18 @@ Exceptions: ...@@ -1393,17 +1457,18 @@ Exceptions:
1. When multiple values are returned, you can design an output parameter for the function. 1. When multiple values are returned, you can design an output parameter for the function.
2. If memory allocation is involved, you can design an output parameter. The caller passes the allocated memory as an output parameter, and memory allocation is not performed in the function. 2. If memory allocation is involved, you can design an output parameter. The caller passes the allocated memory as an output parameter, and memory allocation is not performed in the function.
### <a name="a5-3"></a>Rec 5.3 Define function parameters in the sequence of input, output, and input/output parameters. ### Rec 5.3 Define function parameters in the sequence of input, output, and input/output parameters.
You are advised to define function parameters in the sequence of input, output, and input/output parameters. You are advised to define function parameters in the sequence of input, output, and input/output parameters.
### <a name="r5-3"></a>Rule 5.3 Provide a release function if allocation of resources, such as memory, locks, and queues, is involved. ### Rule 5.3 Provide a release function if allocation of resources, such as memory, locks, and queues, is involved.
Resources should be released from where they are applied for. If a function applies for resources, the module must provide resource functions. Resources should be released from where they are applied for. If a function applies for resources, the module must provide resource functions.
### <a name="a5-4"></a>Rec 5.4 Use strongly typed parameters. Do not use void\*. ### Rec 5.4 Use strongly typed parameters. Do not use void\*.
While different languages have their own views on strong typing and weak typing, it is generally believed that C/C++ is a strongly typed language. Since we use such a strongly typed language, we should keep this style. While different languages have their own views on strong typing and weak typing, it is generally believed that C/C++ is a strongly typed language. Since we use such a strongly typed language, we should keep this style.
The advantage of this strongly typed style is to prevent evasive errors by catching errors at the compilation stage. The advantage of this strongly typed style is to prevent evasive errors by catching errors at the compilation stage.
Strong types help the compiler find more errors.Pay attention to the usage of the `FooListAddNode` function in the following code: Strong types help the compiler find more errors.Pay attention to the usage of the `FooListAddNode` function in the following code:
...@@ -1448,12 +1513,14 @@ void FooListAddNode(FooNode *foo) ...@@ -1448,12 +1513,14 @@ void FooListAddNode(FooNode *foo)
Exceptions: For some generic interfaces, you can use the input parameter `void *` to pass different types of pointers. Exceptions: For some generic interfaces, you can use the input parameter `void *` to pass different types of pointers.
### <a name="a5-5"></a>Rec 5.5 It is the caller's responsibility to check the validity of internal function parameters of a module. ### Rec 5.5 It is the caller's responsibility to check the validity of internal function parameters of a module.
Validity check must be performed on parameters passed from external modules to protect programs from being damaged by invalid input data. Validity check must be performed on parameters passed from external modules to protect programs from being damaged by invalid input data.
When calling internal functions, by default, the caller is responsible for ensuring the validity of any returned data. If the callee takes responsibility for checking data validity, checks may be performed multiple times and redundant code is generated. This is not concise. When calling internal functions, by default, the caller is responsible for ensuring the validity of any returned data. If the callee takes responsibility for checking data validity, checks may be performed multiple times and redundant code is generated. This is not concise.
When the caller ensures the validity of any received data, this contractual programming makes logic simpler and code more readable. When the caller ensures the validity of any received data, this contractual programming makes logic simpler and code more readable.
Example: Example:
```c ```c
...@@ -1480,7 +1547,7 @@ void DealWithData(int data) ...@@ -1480,7 +1547,7 @@ void DealWithData(int data)
} }
``` ```
### <a name="a5-5"></a>Rec 5.5 Declare the pointer argument of a function as 'const' if it is not used to modify the pointed object. ### Rec 5.5 Declare the pointer argument of a function as 'const' if it is not used to modify the pointed object.
The const pointer argument, which restricts the function from modifying the object through the pointer, makes code stronger and safer. The const pointer argument, which restricts the function from modifying the object through the pointer, makes code stronger and safer.
...@@ -1492,7 +1559,7 @@ int strncmp(const char *s1, const char *s2, size_t n); // Good: The invariant pa ...@@ -1492,7 +1559,7 @@ int strncmp(const char *s1, const char *s2, size_t n); // Good: The invariant pa
Note: Whether to declare the pointer parameter as `const` depends on the function design, but not on whether there is a "modify object" action in the function entity. Note: Whether to declare the pointer parameter as `const` depends on the function design, but not on whether there is a "modify object" action in the function entity.
### <a name="a5-6"></a>Rec 5.6 Include no more than 5 parameters in a function. ### Rec 5.6 Include no more than 5 parameters in a function.
If a function has too many parameters, the function is easy to be affected by changes in external code, hindering maintenance. Too many function parameters will also increases the workload for testing. If a function has too many parameters, the function is easy to be affected by changes in external code, hindering maintenance. Too many function parameters will also increases the workload for testing.
...@@ -1501,11 +1568,11 @@ The number of parameters in a function must not exceed 5. If the number of param ...@@ -1501,11 +1568,11 @@ The number of parameters in a function must not exceed 5. If the number of param
- Check whether the function can be split. - Check whether the function can be split.
- Check whether any related parameters can be combined and defined as a struct. - Check whether any related parameters can be combined and defined as a struct.
## <a name="c5-3"></a>Inline Functions ## Inline Functions
An inline function is a function optimization method introduced by C99. Function inlining can eliminate the overhead of function calls; thanks to inlining, combination with the called code is implemented, so that the compiler can achieve further code optimization from a larger perspective. The inline function is similar to a function-like macro. For details, see [Rec 6.1](#rec-61-use-functions-instead-of-function-like-macros). An inline function is a function optimization method introduced by C99. Function inlining can eliminate the overhead of function calls; thanks to inlining, combination with the called code is implemented, so that the compiler can achieve further code optimization from a larger perspective. The inline function is similar to a function-like macro. For details, see [Rec 6.1](#a6-1).
### <a name="a5-7"></a>Rec 5.7 Include no more than 10 lines in an inline function (excluding blank lines and comments). ### Rec 5.7 Include no more than 10 lines in an inline function (excluding blank lines and comments).
Defining a function as an inline function generally aims to improve performance, though it may fail to do so.If the function body is short, function inlining can effectively reduce the size of the target code and improve the function execution efficiency. Defining a function as an inline function generally aims to improve performance, though it may fail to do so.If the function body is short, function inlining can effectively reduce the size of the target code and improve the function execution efficiency.
...@@ -1516,7 +1583,7 @@ It is recommended that inline functions be controlled to within **10** lines. ...@@ -1516,7 +1583,7 @@ It is recommended that inline functions be controlled to within **10** lines.
Do not abuse inline functions to improve performance. Avoid premature optimization. In general, a function can be defined as an inline function only when actual test data proves that the inlining achieves higher performance. Functions such as setter and getter functions, which are short and called frequently, can be defined as inline functions. Do not abuse inline functions to improve performance. Avoid premature optimization. In general, a function can be defined as an inline function only when actual test data proves that the inlining achieves higher performance. Functions such as setter and getter functions, which are short and called frequently, can be defined as inline functions.
### <a name="r5-3"></a>Rule 5.3 Define inline functions that will be called by multiple source files in the header file. ### Rule 5.3 Define inline functions that will be called by multiple source files in the header file.
Inline functions are unfolded in compilation. Therefore, the inline function definition must be visible in each source file that calls this function. Inline functions are unfolded in compilation. Therefore, the inline function definition must be visible in each source file that calls this function.
...@@ -1548,11 +1615,12 @@ int OtherFunc(void) ...@@ -1548,11 +1615,12 @@ int OtherFunc(void)
``` ```
Due to this restriction, if multiple source files need to call the same inline function, the definition of the inline function must be placed in the header file. Due to this restriction, if multiple source files need to call the same inline function, the definition of the inline function must be placed in the header file.
The inline function implementation in **gnu89** differs from that in the **C99** standard. For compatibility, you can declare the function as **static inline**. The inline function implementation in **gnu89** differs from that in the **C99** standard. For compatibility, you can declare the function as **static inline**.
# <a name="c6"></a>6 Macros # 6 Macros
## <a name="c6-1"></a>Function-like Macros ## Function-like Macros
A function-like macro is a macro (as shown in the following example) similar to a function. It contains several statements to implement a specific function. A function-like macro is a macro (as shown in the following example) similar to a function. It contains several statements to implement a specific function.
...@@ -1573,8 +1641,8 @@ Before defining a function-like macro, consider whether it can be replaced with ...@@ -1573,8 +1641,8 @@ Before defining a function-like macro, consider whether it can be replaced with
The disadvantages of the function-like macro are as follows: The disadvantages of the function-like macro are as follows:
- Function-like macros haves no type check, which is not as strict as the function call check. For the example code, see [Below](#macro_lack_of_type_check__example). - Function-like macros haves no type check, which is not as strict as the function call check. For the example code, see [Below](#macro_lack_of_type_check__example).
- If macro parameters are not calculated during macro expansion, unexpected results may be generated. For details, see [Rule 6.1](#rule-61-use-complete-parentheses-for-macro-parameters-when-defining-a-macro) and [Rule 6.3](#rule-63-do-not-pass-expressions-with-side-effects-to-a-function-like-macro). - If macro parameters are not calculated during macro expansion, unexpected results may be generated. For details, see [Rule 6.1](#r6-1) and [Rule 6.3](#r6-3).
- A macro has no independent scope. When it is used together with control flow statements, unexpected results described in [Rule 6.2](#rule-62-place-implementation-statements-of-function-like-macros-that-contain-multiple-statements-in-a-do-while0) may be generated. - A macro has no independent scope. When it is used together with control flow statements, unexpected results described in [Rule 6.2](#r6-2) may be generated.
- There are high skill requirements on the proper use of macros (for example, the usage of `#` and wide use of parentheses), which reduces readability. - There are high skill requirements on the proper use of macros (for example, the usage of `#` and wide use of parentheses), which reduces readability.
- Extensions of some macros can only be implemented by specific compilers in specific scenarios, such as `statement expression` of `gcc`, reducing the portability. - Extensions of some macros can only be implemented by specific compilers in specific scenarios, such as `statement expression` of `gcc`, reducing the portability.
- After the macro is expanded during precompilation, it is invisible during subsequent compilation, linking, and debugging. Besides, macros that contain multiple lines are expanded into a line. - After the macro is expanded during precompilation, it is invisible during subsequent compilation, linking, and debugging. Besides, macros that contain multiple lines are expanded into a line.
...@@ -1631,6 +1699,7 @@ int ErrLog(const char *file, unsigned long line, const char *fmt, ...); ...@@ -1631,6 +1699,7 @@ int ErrLog(const char *file, unsigned long line, const char *fmt, ...);
### <a name="r6-1"></a>Rule 6.1 Use complete parentheses for macro parameters when defining a macro. ### <a name="r6-1"></a>Rule 6.1 Use complete parentheses for macro parameters when defining a macro.
The macro parameter is replaced by text only when the macro is expanded. The value is calculated when the macro is compiled. After the text replacement, the statements contained in the macro are combined with called code. The macro parameter is replaced by text only when the macro is expanded. The value is calculated when the macro is compiled. After the text replacement, the statements contained in the macro are combined with called code.
The expression after combination may result in a different result than expected, especially when the macro parameter is in an expression. The expression after combination may result in a different result than expected, especially when the macro parameter is in an expression.
The following is an incorrect format: The following is an incorrect format:
...@@ -1640,7 +1709,9 @@ The following is an incorrect format: ...@@ -1640,7 +1709,9 @@ The following is an incorrect format:
``` ```
When the macro is used, the execution result is inconsistent with the expected result. When the macro is used, the execution result is inconsistent with the expected result.
`100 / SUM(2, 8)` is expanded to `(100 / 2) + 8`. The expected result is `100 / (2 + 8)`. `100 / SUM(2, 8)` is expanded to `(100 / 2) + 8`. The expected result is `100 / (2 + 8)`.
This problem can be solved by adding parentheses to the entire expression, as shown in the following: This problem can be solved by adding parentheses to the entire expression, as shown in the following:
```c ```c
...@@ -1648,6 +1719,7 @@ This problem can be solved by adding parentheses to the entire expression, as sh ...@@ -1648,6 +1719,7 @@ This problem can be solved by adding parentheses to the entire expression, as sh
``` ```
However, this method has the following problems: However, this method has the following problems:
`SUM(1 << 2, 8)` is extended to `1 << (2 + 8)` (because the priority of `<<` is lower than that of `+`), which is inconsistent with the expected result `(1 << 2) + 8`. `SUM(1 << 2, 8)` is extended to `1 << (2 + 8)` (because the priority of `<<` is lower than that of `+`), which is inconsistent with the expected result `(1 << 2) + 8`.
To solve this problem, add parentheses to each macro parameter, as shown in the following: To solve this problem, add parentheses to each macro parameter, as shown in the following:
...@@ -1722,6 +1794,7 @@ To solve the preceding problem, use braces to enclose the statements defined by ...@@ -1722,6 +1794,7 @@ To solve the preceding problem, use braces to enclose the statements defined by
``` ```
The brackets are not associated with semicolons (;). The semicolon following the braces is another statement. The brackets are not associated with semicolons (;). The semicolon following the braces is another statement.
In the following code example, the "suspended else' compilation error message is displayed. In the following code example, the "suspended else' compilation error message is displayed.
```c ```c
...@@ -1750,6 +1823,7 @@ Exceptions: ...@@ -1750,6 +1823,7 @@ Exceptions:
### <a name="r6-3"></a>Rule 6.3 Do not pass expressions with side effects to a function-like macro. ### <a name="r6-3"></a>Rule 6.3 Do not pass expressions with side effects to a function-like macro.
Since macros are replaced by text, if a function-like macro uses the same macro parameter multiple times and transfers expressions with side effects as macro parameters, unexpected results may occur. Since macros are replaced by text, if a function-like macro uses the same macro parameter multiple times and transfers expressions with side effects as macro parameters, unexpected results may occur.
As shown in the following example, the macro `SQUARE` is normal, but the `a++` expression with side effects is passed to the macro. As a result, the value of `a` is different from the expected value after the `SQUARE` macro is executed. As shown in the following example, the macro `SQUARE` is normal, but the `a++` expression with side effects is passed to the macro. As a result, the value of `a` is different from the expected value after the `SQUARE` macro is executed.
```c ```c
...@@ -1770,9 +1844,10 @@ a++; // Result: a = 6, which is added only once. ...@@ -1770,9 +1844,10 @@ a++; // Result: a = 6, which is added only once.
``` ```
In addition, if the macro parameter contains a function call, the function may be called repeatedly after the macro is expanded. In addition, if the macro parameter contains a function call, the function may be called repeatedly after the macro is expanded.
If the function execution results are the same, it is a waste; if the results are different, the execution result may not meet the expected value. If the function execution results are the same, it is a waste; if the results are different, the execution result may not meet the expected value.
### <a name="a6-2"></a>Rec 6.2 Exercise caution when you use the statements such as `return`, `goto`, `continue`, and `break` in a function-like macro definition. ### Rec 6.2 Exercise caution when you use the statements such as `return`, `goto`, `continue`, and `break` in a function-like macro definition.
Although process changing statements, such as `return`, `goto`, `continue`, and `break`, in a macro can simplify the code, they hide the real process, which hinders understanding and easily causes resource leakage. Although process changing statements, such as `return`, `goto`, `continue`, and `break`, in a macro can simplify the code, they hide the real process, which hinders understanding and easily causes resource leakage.
...@@ -1821,27 +1896,32 @@ CHECK_PTR(mem2, ERR_CODE_XXX); // Wrong: Memory leak. ...@@ -1821,27 +1896,32 @@ CHECK_PTR(mem2, ERR_CODE_XXX); // Wrong: Memory leak.
``` ```
If `mem2` fails to apply for memory, `CHECK_PTR` will return a message instead of releasing `mem1`. If `mem2` fails to apply for memory, `CHECK_PTR` will return a message instead of releasing `mem1`.
Besides, the name of the `CHECK_PTR` macro is not good. The macro name only reflects the check action and does not specify the result. Readers can see that a failure is returned when the pointer is null only after viewing the macro implementation. It's not inherently obvious. Besides, the name of the `CHECK_PTR` macro is not good. The macro name only reflects the check action and does not specify the result. Readers can see that a failure is returned when the pointer is null only after viewing the macro implementation. It's not inherently obvious.
In summary, it is not recommended to encapsulate process changing statements, such as `return`, `goto`, `continue`, and `break`, in macro definitions. In summary, it is not recommended to encapsulate process changing statements, such as `return`, `goto`, `continue`, and `break`, in macro definitions.
However, these macros can be used in special scenarios, such as return value judgment. However, these macros can be used in special scenarios, such as return value judgment.
Note: **Macro names must contain descriptive keywords if process changing statements, such as `return`, `goto`, `continue`, and `break`, are used.** Note: **Macro names must contain descriptive keywords if process changing statements, such as `return`, `goto`, `continue`, and `break`, are used.**
### <a name="a6-3"></a>Rec 6.3 Include no more than 10 lines in a function-like macro (excluding blank lines and comments). ### Rec 6.3 Include no more than 10 lines in a function-like macro (excluding blank lines and comments).
A function-like macro is more difficult to debug and locate than a function, especially when the macro is too long. A function-like macro is more difficult to debug and locate than a function, especially when the macro is too long.
Macro expansion will also lead to more compiled code. It is recommended that function-like macros contain no more than 10 lines. Macro expansion will also lead to more compiled code. It is recommended that function-like macros contain no more than 10 lines.
# <a name="c7"></a>7 Variables # 7 Variables
In C language coding, variables are the most important except for functions. In C language coding, variables are the most important except for functions.
When using a variable, you should always follow the principle of "single responsibility". When using a variable, you should always follow the principle of "single responsibility".
By scope, variables can be classified into global variables and local variables. By scope, variables can be classified into global variables and local variables.
## <a name="c7-1"></a>Global Variables ## Global Variables
Do not use or avoid using global variables. Do not use or avoid using global variables.
In program design, global variables are variables that are accessible to all scopes. Using unnecessary global variables is generally considered a bad habit. In program design, global variables are variables that are accessible to all scopes. Using unnecessary global variables is generally considered a bad habit.
Disadvantages of global variables: Disadvantages of global variables:
...@@ -1852,16 +1932,18 @@ Disadvantages of global variables: ...@@ -1852,16 +1932,18 @@ Disadvantages of global variables:
If unavoidable, the read and write of global variables should be encapsulated in a centralized manner. If unavoidable, the read and write of global variables should be encapsulated in a centralized manner.
### <a name="r7-1"></a>Rule 7.1 Do not use global variables as interfaces between modules. ### Rule 7.1 Do not use global variables as interfaces between modules.
Global variables are for the internal implementation of modules and should not be exposed as interfaces. Global variables are for the internal implementation of modules and should not be exposed as interfaces.
Global variables should be as centralized as possible. If the data of this module needs to be disclosed to external modules, a function as an interface to this data should be provided. Global variables should be as centralized as possible. If the data of this module needs to be disclosed to external modules, a function as an interface to this data should be provided.
## <a name="c7-2"></a>Local Variables ## Local Variables
### <a name="r7-2"></a>Rule 7.2 Do not use uninitialized variables as rvalues. ### Rule 7.2 Do not use uninitialized variables as rvalues.
The variable here refers to a local dynamic variable, and also includes a memory block obtained on a memory heap. The variable here refers to a local dynamic variable, and also includes a memory block obtained on a memory heap.
Because their initial values are unpredictable, it is prohibited to use them directly as rvalues without effective initialization. Because their initial values are unpredictable, it is prohibited to use them directly as rvalues without effective initialization.
```c ```c
...@@ -1888,11 +1970,14 @@ void Foo(...) ...@@ -1888,11 +1970,14 @@ void Foo(...)
``` ```
Uninitialized rvalues can be found by generic static check tools. Uninitialized rvalues can be found by generic static check tools.
For example, the PCLint tool reports a warning for the following two examples. For example, the PCLint tool reports a warning for the following two examples.
> Warning 530: Symbol 'data' (line ...) not initialized Warning 644: Variable 'data' (line ...) may not have been initialized > Warning 530: Symbol 'data' (line ...) not initialized
>
> Warning 644: Variable 'data' (line ...) may not have been initialized
### <a name="r7-3"></a>Rule 7.3 Forbid invalid and redundant variable initialization. ### Rule 7.3 Forbid invalid and redundant variable initialization.
If the initial value is not determined before initialization is performed, it is not concise or secure and may cause problems that are more difficult to discover. If the initial value is not determined before initialization is performed, it is not concise or secure and may cause problems that are more difficult to discover.
...@@ -1939,41 +2024,53 @@ void Foo(...) ...@@ -1939,41 +2024,53 @@ void Foo(...)
``` ```
In the preceding code, if 0 is not assigned before initialization, the static check tool can help find the problem of "direct use without being initialized". In the preceding code, if 0 is not assigned before initialization, the static check tool can help find the problem of "direct use without being initialized".
However, due to invalid initialization, the defect of placing "UseData" before "GetData" cannot be easily found. However, due to invalid initialization, the defect of placing "UseData" before "GetData" cannot be easily found.
Therefore, simple code should be written to initialize variables or memory blocks as required. Therefore, simple code should be written to initialize variables or memory blocks as required.
The C99 does not limit the definition position of local variables to before the first statement in a function. That is, a variable can now be defined close to a variable. The C99 does not limit the definition position of local variables to before the first statement in a function. That is, a variable can now be defined close to a variable.
This concise approach not only limits the scope of the variable scope, but also solves the problem of how to initialize the variable when it is defined. This concise approach not only limits the scope of the variable scope, but also solves the problem of how to initialize the variable when it is defined.
If this compilation environment is supported, you are advised to define local variables in this way. If this compilation environment is supported, you are advised to define local variables in this way.
**Exceptions:** **Exceptions:**
**As 'Secure Coding Standard' required, pointers, resource variables, and boolean variables can be treated as exceptions of this rule.** **As 'Secure Coding Standard' required, pointers, resource variables, and boolean variables can be treated as exceptions of this rule.**
### <a name="r7-4"></a>Rule 7.4 Do not use magic numbers. ### Rule 7.4 Do not use magic numbers.
The so-called magic numbers are the numbers that are unintelligible and difficult to understand. The so-called magic numbers are the numbers that are unintelligible and difficult to understand.
The magic number is not a concept that can be defined literally. It varies depending on context and service knowledge. The magic number is not a concept that can be defined literally. It varies depending on context and service knowledge.
For example, the number 12 varies in different contexts. For example, the number 12 varies in different contexts.
`type = 12;` is not intelligible, but `month = year * 12;` can be understood. `type = 12;` is not intelligible, but `month = year * 12;` can be understood.
The number 0 is sometimes seen as a magic number. For example, the `status = 0;` cannot truly express any status information. The number 0 is sometimes seen as a magic number. For example, the `status = 0;` cannot truly express any status information.
Solution: Solution:
Comments can be added for numbers that are used only once. Comments can be added for numbers that are used only once.
For numbers that are used multiple times, macro or const variables must be defined and self-commented with symbolic naming. For numbers that are used multiple times, macro or const variables must be defined and self-commented with symbolic naming.
The following cases are forbidden: The following cases are forbidden:
The name is not used to explain the meaning of a number, for example, `#define ZERO 0`. The name is not used to explain the meaning of a number, for example, `#define ZERO 0`.
The value is limited by the name, for example, `#define XX_TIMER_INTERVAL_300MS 300`. The value is limited by the name, for example, `#define XX_TIMER_INTERVAL_300MS 300`.
# <a name="c8"></a>8 Programming Practice # 8 Programming Practice
## <a name="c8-1"></a>Expressions ## Expressions
### <a name="a8-1"></a>Rec 8.1 When comparing expressions, follow the principle that the left side tends to change and the right side tends to remain unchanged. ### Rec 8.1 When comparing expressions, follow the principle that the left side tends to change and the right side tends to remain unchanged.
When a variable is compared with a constant, placing the constant on the left, for example, `if (MAX == v)` does not read naturally, and `if (MAX > v)` is more difficult to understand. When a variable is compared with a constant, placing the constant on the left, for example, `if (MAX == v)` does not read naturally, and `if (MAX > v)` is more difficult to understand.
The constant should be placed on the right according to the normal reading order and habit. The expression is written as follows: The constant should be placed on the right according to the normal reading order and habit. The expression is written as follows:
```c ```c
...@@ -1985,9 +2082,10 @@ There are special cases: for example, the expression `if (MIN < v && v < MAX)` i ...@@ -1985,9 +2082,10 @@ There are special cases: for example, the expression `if (MIN < v && v < MAX)` i
You do not need to worry about accidentally writing '==' as '=' because a compilation alarm will be generated for `if (v = MAX)` and an error will be reported by other static check tools. Use these tools to solve such writing errors and ensure that that code is readable. You do not need to worry about accidentally writing '==' as '=' because a compilation alarm will be generated for `if (v = MAX)` and an error will be reported by other static check tools. Use these tools to solve such writing errors and ensure that that code is readable.
### <a name="r8-1"></a>Do not reference a variable again in an expression containing an increment (++) or decrement (--) operator. ### Do not reference a variable again in an expression containing an increment (++) or decrement (--) operator.
In an expression containing a variable increment or decrement operator, if the variable is referenced again, the result is not explicitly defined in the C standard, which may vary between compilers or different compiler versions. In an expression containing a variable increment or decrement operator, if the variable is referenced again, the result is not explicitly defined in the C standard, which may vary between compilers or different compiler versions.
For better portability, you should not make any assumptions about the operation sequence not defined in any standards. For better portability, you should not make any assumptions about the operation sequence not defined in any standards.
Note that this problem cannot be solved by using parentheses because it is not a problem of priority. Note that this problem cannot be solved by using parentheses because it is not a problem of priority.
...@@ -2018,9 +2116,10 @@ i++; // Good: Single line. ...@@ -2018,9 +2116,10 @@ i++; // Good: Single line.
x = Func(i, i); x = Func(i, i);
``` ```
### <a name="a8-2"></a>Rec 8.2 Use parentheses to specify the sequence of expressions, instead of using the default priority. ### Rec 8.2 Use parentheses to specify the sequence of expressions, instead of using the default priority.
Parentheses can be used to better emphasize the purpose of used operators. This will prevent program errors due to the inconsistency between default priority and the intended design. Parentheses can be used to better emphasize the purpose of used operators. This will prevent program errors due to the inconsistency between default priority and the intended design.
However, too many parentheses muddy the code, reducing readability. Use them moderately. However, too many parentheses muddy the code, reducing readability. Use them moderately.
Parentheses are recommended when expressions contain operators that are not commonly used and are confusing, such as bitwise operators. Parentheses are recommended when expressions contain operators that are not commonly used and are confusing, such as bitwise operators.
...@@ -2029,14 +2128,16 @@ Parentheses are recommended when expressions contain operators that are not comm ...@@ -2029,14 +2128,16 @@ Parentheses are recommended when expressions contain operators that are not comm
c = (a & 0xFF) + b; /* Parentheses are required while using bit operators. */ c = (a & 0xFF) + b; /* Parentheses are required while using bit operators. */
``` ```
## <a name="c8-2"></a>Statements ## Statements
### <a name="r8-2"></a>Rule 8.2 Provide a 'default' branch for the `switch` statement. ### Rule 8.2 Provide a 'default' branch for the `switch` statement.
In most cases, the 'default' branch exists in the switch statement to ensure that there is a default processing action when the case tag is missing. In most cases, the 'default' branch exists in the switch statement to ensure that there is a default processing action when the case tag is missing.
Exceptions: Exceptions:
If the switch condition variable is of the enum type and the case branches cover all values, then the default branch is redundant. If the switch condition variable is of the enum type and the case branches cover all values, then the default branch is redundant.
A modern compiler can check whether the case branch of some enumerated values is missing in the switch statement. A warning will be displayed. A modern compiler can check whether the case branch of some enumerated values is missing in the switch statement. A warning will be displayed.
```c ```c
...@@ -2057,11 +2158,12 @@ switch (color) { ...@@ -2057,11 +2158,12 @@ switch (color) {
} }
``` ```
### <a name="a8-3"></a>Rec 8.3 Exercise caution when using the `goto` statement. ### Rec 8.3 Exercise caution when using the `goto` statement.
The `goto` statement destroys the program. Avoid using it if possible. You can only jump to statements following the `goto` statement, and only within the one function. The `goto` statement destroys the program. Avoid using it if possible. You can only jump to statements following the `goto` statement, and only within the one function.
The `goto` statement is used to implement function return to a single point within a function. The `goto` statement is used to implement function return to a single point within a function.
If a function has a large number of identical logics that cannot be encapsulated, for example, repeated file execution, the processed part of code after the file operation failure (for example, closing the file handle and releasing memory that is dynamically applied for) is usually placed in the last part of the function body. And the goto statement is placed right before these. In this way, the code becomes clear and concise. It can also be encapsulated in functions or macros, but doing so makes code less straightforward. If a function has a large number of identical logics that cannot be encapsulated, for example, repeated file execution, the processed part of code after the file operation failure (for example, closing the file handle and releasing memory that is dynamically applied for) is usually placed in the last part of the function body. And the goto statement is placed right before these. In this way, the code becomes clear and concise. It can also be encapsulated in functions or macros, but doing so makes code less straightforward.
Example: Example:
...@@ -2106,9 +2208,9 @@ EXIT: ...@@ -2106,9 +2208,9 @@ EXIT:
} }
``` ```
## <a name="c8-3"></a>Type Conversion ## Type Conversion
### <a name="a8-4"></a>Rec 8.4 Minimize unnecessary type conversion and forced conversion. ### Rec 8.4 Minimize unnecessary type conversion and forced conversion.
When the data type is forcibly changed, the meaning of the data and the value after conversion may change. If details are not considered, potential risks may be generated. When the data type is forcibly changed, the meaning of the data and the value after conversion may change. If details are not considered, potential risks may be generated.
......
# Code of Conduct<a name="EN-US_TOPIC_0000001055368056"></a> # Code of Conduct
The OpenHarmony community complies with the code of conduct specified in [Contributor Covenant](https://contributor-covenant.org/) of the open source community. For details, see [https://www.contributor-covenant.org/version/1/4/code-of-conduct/](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). The OpenHarmony community complies with the code of conduct specified in [Contributor Covenant](https://contributor-covenant.org/) of the open source community. For details, see [https://www.contributor-covenant.org/version/1/4/code-of-conduct/](https://www.contributor-covenant.org/version/1/4/code-of-conduct/).
......
# How to Contribute<a name="EN-US_TOPIC_0000001055208082"></a> # How to Contribute
## Contributing Code<a name="en-us_topic_0000001053868136_section10170447161315"></a> ## Contributing Code
## Before You Start<a name="en-us_topic_0000001053868136_section2734837154520"></a> ## Before You Start
**Signing the Developer Certificate of Origin** **Signing the Developer Certificate of Origin**
...@@ -12,13 +12,13 @@ Click [here](https://dco.openharmony.cn/#/sign) to sign the DCO, and click [here ...@@ -12,13 +12,13 @@ Click [here](https://dco.openharmony.cn/#/sign) to sign the DCO, and click [here
**Code of Conduct** **Code of Conduct**
OpenHarmony is an open source community that relies entirely on the friendly, welcoming environment of the community. Read and abide by the community's [Code of Conduct](code-of-conduct.md#EN-US_TOPIC_0000001055368056) before contributing to the community. OpenHarmony is an open source community that relies entirely on the friendly, welcoming environment of the community. Read and abide by the community's [Code of Conduct](code-of-conduct.md) before contributing to the community.
## **Finding the SIG Group You Are Interested** ## **Finding the SIG Group You Are Interested**
For details about how to participate in Special Interest Group (SIG), see **SIG Governance**. For details about how to participate in Special Interest Group (SIG), see **SIG Governance**.
## Starting Contributing<a name="en-us_topic_0000001053868136_section184321756134618"></a> ## Starting Contributing
For details about how to contribute to code, see [Code Contributing ](code-contribution.md). For details about how to contribute to code, see [Code Contributing ](code-contribution.md).
...@@ -26,11 +26,11 @@ For details about how to contribute to code, see [Code Contributing ](code-cont ...@@ -26,11 +26,11 @@ For details about how to contribute to code, see [Code Contributing ](code-cont
For details about how to develop test cases based on test requirements, see [Test Subsystem](../readme/test.md). For details about how to develop test cases based on test requirements, see [Test Subsystem](../readme/test.md).
## Contributing Documents<a name="en-us_topic_0000001053868136_section11234185012131"></a> ## Contributing Documents
For details, see [Documentation Contribution](documentation-contribution.md). For details, see [Documentation Contribution](documentation-contribution.md).
## Communication in Community<a name="en-us_topic_0000001053868136_section98614457153"></a> ## Communication in Community
For details, see [Communication in Community](communication-in-community.md#EN-US_TOPIC_0000001054608107). For details, see [Communication in Community](communication-in-community.md).
...@@ -96,7 +96,7 @@ import call from '@ohos.telephony.call'; ...@@ -96,7 +96,7 @@ import call from '@ohos.telephony.call';
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------ | | ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------ |
| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the current device. | | pluggedType | [BatteryPluggedType]\(#batterypluggedtype) | Yes | No | Charger type of the current device. |
| isBatteryPresent | boolean | Yes | No | Whether the battery is supported or present.| | isBatteryPresent | boolean | Yes | No | Whether the battery is supported or present.|
## Methods ## Methods
...@@ -270,7 +270,7 @@ The following is an example of the custom type of a key-value pair. ...@@ -270,7 +270,7 @@ The following is an example of the custom type of a key-value pair.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ |
| parameterUrl | string | Yes | Yes | Media output URI. Supported:<br>1. Relative path whose protocol type is `internal`. Example: <br/>Temporary directory: internal://cache/test.mp4<br>2. Absolute path. Example:<br/>file:///data/data/ohos.xxx.xxx/files/test.mp4| | parameterUrl | string | Yes | Yes | Media output URI. Supported:<br>1. Relative path whose protocol type is `internal`. Example: <br/>Temporary directory: internal://cache/test.mp4<br>2. Absolute path. Example:<br/>file:///data/data/ohos.xxx.xxx/files/test.mp4|
| parameterOne | [CustomEnum](#Enumeration)| Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. | | parameterOne | [CustomEnum](#enums) | Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. |
## Change History ## Change History
| Change Description| Date| | Change Description| Date|
......
# Photographing<a name="EN-US_TOPIC_0000001054954859"></a>
## When to Use<a name="en-us_topic_0000001052170554_section1963312376119"></a>
Use the camera module APIs to capture frames \(photographing\).
## Available APIs<a name="en-us_topic_0000001052170554_section56549532016"></a>
**Table 1** APIs for photographing
<a name="en-us_topic_0000001052170554_table2069447114914"></a>
<table><thead align="left"><tr id="en-us_topic_0000001052170554_row4903852104914"><th class="cellrowborder" valign="top" width="18.811881188118814%" id="mcps1.2.4.1.1"><p id="en-us_topic_0000001052170554_p2903252174918"><a name="en-us_topic_0000001052170554_p2903252174918"></a><a name="en-us_topic_0000001052170554_p2903252174918"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="46.534653465346544%" id="mcps1.2.4.1.2"><p id="en-us_topic_0000001052170554_p1595113912507"><a name="en-us_topic_0000001052170554_p1595113912507"></a><a name="en-us_topic_0000001052170554_p1595113912507"></a>Function</p>
</th>
<th class="cellrowborder" valign="top" width="34.65346534653466%" id="mcps1.2.4.1.3"><p id="en-us_topic_0000001052170554_p15951597508"><a name="en-us_topic_0000001052170554_p15951597508"></a><a name="en-us_topic_0000001052170554_p15951597508"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001052170554_row492815717494"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1592812716495"><a name="en-us_topic_0000001052170554_p1592812716495"></a><a name="en-us_topic_0000001052170554_p1592812716495"></a>CameraKit</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1492837144919"><a name="en-us_topic_0000001052170554_p1492837144919"></a><a name="en-us_topic_0000001052170554_p1492837144919"></a>int32_t GetCameraIds(std::list&lt;string&gt; cameraList)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p2092807134919"><a name="en-us_topic_0000001052170554_p2092807134919"></a><a name="en-us_topic_0000001052170554_p2092807134919"></a>Obtains IDs of cameras that are currently available.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row11928157114912"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p139287774911"><a name="en-us_topic_0000001052170554_p139287774911"></a><a name="en-us_topic_0000001052170554_p139287774911"></a>CameraKit</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p9928107174915"><a name="en-us_topic_0000001052170554_p9928107174915"></a><a name="en-us_topic_0000001052170554_p9928107174915"></a>CameraAbility&amp; GetCameraAbility(string cameraId)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p139281171494"><a name="en-us_topic_0000001052170554_p139281171494"></a><a name="en-us_topic_0000001052170554_p139281171494"></a>Obtains the camera capability</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row119282719496"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p159288734914"><a name="en-us_topic_0000001052170554_p159288734914"></a><a name="en-us_topic_0000001052170554_p159288734914"></a>CameraKit</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p99280794913"><a name="en-us_topic_0000001052170554_p99280794913"></a><a name="en-us_topic_0000001052170554_p99280794913"></a>void RegisterCameraDeviceCallback(CameraDeviceCallback* callback, EventHandler* handler)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p8928197134910"><a name="en-us_topic_0000001052170554_p8928197134910"></a><a name="en-us_topic_0000001052170554_p8928197134910"></a>Registers a camera callback for camera status changes.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row4928673496"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p14928770497"><a name="en-us_topic_0000001052170554_p14928770497"></a><a name="en-us_topic_0000001052170554_p14928770497"></a>CameraKit</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p14928197194915"><a name="en-us_topic_0000001052170554_p14928197194915"></a><a name="en-us_topic_0000001052170554_p14928197194915"></a>void UnregisterCameraDeviceCallback(CameraDeviceCallback* callback)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p17929197134913"><a name="en-us_topic_0000001052170554_p17929197134913"></a><a name="en-us_topic_0000001052170554_p17929197134913"></a>Unregisters a camera callback.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row16929187104912"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p6929157184911"><a name="en-us_topic_0000001052170554_p6929157184911"></a><a name="en-us_topic_0000001052170554_p6929157184911"></a>CameraKit</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1192910704914"><a name="en-us_topic_0000001052170554_p1192910704914"></a><a name="en-us_topic_0000001052170554_p1192910704914"></a>void CreateCamera(string cameraId, CameraStateCallback* callback, EventHandler* handler)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p12929167154912"><a name="en-us_topic_0000001052170554_p12929167154912"></a><a name="en-us_topic_0000001052170554_p12929167154912"></a>Creates a <strong id="en-us_topic_0000001052170554_b1512582132318"><a name="en-us_topic_0000001052170554_b1512582132318"></a><a name="en-us_topic_0000001052170554_b1512582132318"></a>Camera</strong> instance.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row592967184912"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p9929127134915"><a name="en-us_topic_0000001052170554_p9929127134915"></a><a name="en-us_topic_0000001052170554_p9929127134915"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p0929107204913"><a name="en-us_topic_0000001052170554_p0929107204913"></a><a name="en-us_topic_0000001052170554_p0929107204913"></a>string GetCameraId()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1592914710490"><a name="en-us_topic_0000001052170554_p1592914710490"></a><a name="en-us_topic_0000001052170554_p1592914710490"></a>Obtains the camera ID.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row13929197104913"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p16929167134913"><a name="en-us_topic_0000001052170554_p16929167134913"></a><a name="en-us_topic_0000001052170554_p16929167134913"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p15929175491"><a name="en-us_topic_0000001052170554_p15929175491"></a><a name="en-us_topic_0000001052170554_p15929175491"></a>CameraConfig&amp; GetCameraConfig()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p19298714917"><a name="en-us_topic_0000001052170554_p19298714917"></a><a name="en-us_topic_0000001052170554_p19298714917"></a>Obtains the camera configuration.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row1892918764915"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p69291072495"><a name="en-us_topic_0000001052170554_p69291072495"></a><a name="en-us_topic_0000001052170554_p69291072495"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p5930172494"><a name="en-us_topic_0000001052170554_p5930172494"></a><a name="en-us_topic_0000001052170554_p5930172494"></a>FrameConfig&amp; GetFrameConfig(int32_t type)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p19301176495"><a name="en-us_topic_0000001052170554_p19301176495"></a><a name="en-us_topic_0000001052170554_p19301176495"></a>Obtains the frame configuration.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row893019794915"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p893016714919"><a name="en-us_topic_0000001052170554_p893016714919"></a><a name="en-us_topic_0000001052170554_p893016714919"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1093067134915"><a name="en-us_topic_0000001052170554_p1093067134915"></a><a name="en-us_topic_0000001052170554_p1093067134915"></a>void Configure(CameraConfig&amp; config)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1493037114912"><a name="en-us_topic_0000001052170554_p1493037114912"></a><a name="en-us_topic_0000001052170554_p1493037114912"></a>Configures the camera using the <strong id="en-us_topic_0000001052170554_b1158653521815"><a name="en-us_topic_0000001052170554_b1158653521815"></a><a name="en-us_topic_0000001052170554_b1158653521815"></a>CameraConfig</strong> object.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row11930197174917"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p4930197184914"><a name="en-us_topic_0000001052170554_p4930197184914"></a><a name="en-us_topic_0000001052170554_p4930197184914"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p19304717492"><a name="en-us_topic_0000001052170554_p19304717492"></a><a name="en-us_topic_0000001052170554_p19304717492"></a>void Release()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p189301479494"><a name="en-us_topic_0000001052170554_p189301479494"></a><a name="en-us_topic_0000001052170554_p189301479494"></a>Releases the <strong id="en-us_topic_0000001052170554_b12391143101812"><a name="en-us_topic_0000001052170554_b12391143101812"></a><a name="en-us_topic_0000001052170554_b12391143101812"></a>Camera</strong> object and associated resources.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row109304717499"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p4930873496"><a name="en-us_topic_0000001052170554_p4930873496"></a><a name="en-us_topic_0000001052170554_p4930873496"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1893017720490"><a name="en-us_topic_0000001052170554_p1893017720490"></a><a name="en-us_topic_0000001052170554_p1893017720490"></a>int TriggerLoopingCapture(FrameConfig&amp; frameConfig)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p149307754918"><a name="en-us_topic_0000001052170554_p149307754918"></a><a name="en-us_topic_0000001052170554_p149307754918"></a>Starts looping-frame capture.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row19306794915"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p6930167194910"><a name="en-us_topic_0000001052170554_p6930167194910"></a><a name="en-us_topic_0000001052170554_p6930167194910"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p139311577499"><a name="en-us_topic_0000001052170554_p139311577499"></a><a name="en-us_topic_0000001052170554_p139311577499"></a>void StopLoopingCapture()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p693115764914"><a name="en-us_topic_0000001052170554_p693115764914"></a><a name="en-us_topic_0000001052170554_p693115764914"></a>Stops looping-frame capture.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row593116713492"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1193187174913"><a name="en-us_topic_0000001052170554_p1193187174913"></a><a name="en-us_topic_0000001052170554_p1193187174913"></a>Camera</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1493111713496"><a name="en-us_topic_0000001052170554_p1493111713496"></a><a name="en-us_topic_0000001052170554_p1493111713496"></a>int32_t TriggerSingleCapture(FrameConfig&amp; frameConfig)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1193137104919"><a name="en-us_topic_0000001052170554_p1193137104919"></a><a name="en-us_topic_0000001052170554_p1193137104919"></a>Starts single-frame capture.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row1693112711491"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p89312716494"><a name="en-us_topic_0000001052170554_p89312716494"></a><a name="en-us_topic_0000001052170554_p89312716494"></a>CameraConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p199312784912"><a name="en-us_topic_0000001052170554_p199312784912"></a><a name="en-us_topic_0000001052170554_p199312784912"></a>void SetFrameStateCallback(FrameStateCallback* callback, EventHandler* handler);</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p49312714495"><a name="en-us_topic_0000001052170554_p49312714495"></a><a name="en-us_topic_0000001052170554_p49312714495"></a>Sets a frame state callback to respond to state changes.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row9931076492"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p59317784917"><a name="en-us_topic_0000001052170554_p59317784917"></a><a name="en-us_topic_0000001052170554_p59317784917"></a>CameraConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p17931197124912"><a name="en-us_topic_0000001052170554_p17931197124912"></a><a name="en-us_topic_0000001052170554_p17931197124912"></a>static CameraConfig* CreateCameraConfig()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p5931177164912"><a name="en-us_topic_0000001052170554_p5931177164912"></a><a name="en-us_topic_0000001052170554_p5931177164912"></a>Creates a <strong id="en-us_topic_0000001052170554_b101608165182"><a name="en-us_topic_0000001052170554_b101608165182"></a><a name="en-us_topic_0000001052170554_b101608165182"></a>CameraConfig</strong> instance.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row29321744917"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1093219716492"><a name="en-us_topic_0000001052170554_p1093219716492"></a><a name="en-us_topic_0000001052170554_p1093219716492"></a>CameraAbility</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p12932979493"><a name="en-us_topic_0000001052170554_p12932979493"></a><a name="en-us_topic_0000001052170554_p12932979493"></a>std::list&lt;Size&gt; GetSupportedSizes(int format)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1493210764918"><a name="en-us_topic_0000001052170554_p1493210764918"></a><a name="en-us_topic_0000001052170554_p1493210764918"></a>Obtains the supported image sizes for a specified image format.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row1193267184910"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1393214717492"><a name="en-us_topic_0000001052170554_p1393214717492"></a><a name="en-us_topic_0000001052170554_p1393214717492"></a>CameraAbility</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p119321477495"><a name="en-us_topic_0000001052170554_p119321477495"></a><a name="en-us_topic_0000001052170554_p119321477495"></a>std::list&lt;T&gt; GetParameterRange(uint32_t key)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p139331079491"><a name="en-us_topic_0000001052170554_p139331079491"></a><a name="en-us_topic_0000001052170554_p139331079491"></a>Obtains the parameter value range based on a specified parameter key.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row0933197134920"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1493310764917"><a name="en-us_topic_0000001052170554_p1493310764917"></a><a name="en-us_topic_0000001052170554_p1493310764917"></a>CameraDevice</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p493313724915"><a name="en-us_topic_0000001052170554_p493313724915"></a><a name="en-us_topic_0000001052170554_p493313724915"></a>CameraDeviceCallback()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p993416724915"><a name="en-us_topic_0000001052170554_p993416724915"></a><a name="en-us_topic_0000001052170554_p993416724915"></a>A constructor used to create a <strong id="en-us_topic_0000001052170554_b99481043111719"><a name="en-us_topic_0000001052170554_b99481043111719"></a><a name="en-us_topic_0000001052170554_b99481043111719"></a>CameraDeviceCallback</strong> instance.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row093418712498"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p159341779492"><a name="en-us_topic_0000001052170554_p159341779492"></a><a name="en-us_topic_0000001052170554_p159341779492"></a>CameraDevice</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1493411774912"><a name="en-us_topic_0000001052170554_p1493411774912"></a><a name="en-us_topic_0000001052170554_p1493411774912"></a>void OnCameraStatus​(std::string cameraId, int32_t status)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1393419715491"><a name="en-us_topic_0000001052170554_p1393419715491"></a><a name="en-us_topic_0000001052170554_p1393419715491"></a>Called when the camera device status changes.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row109348711497"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p993419724914"><a name="en-us_topic_0000001052170554_p993419724914"></a><a name="en-us_topic_0000001052170554_p993419724914"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p993418720497"><a name="en-us_topic_0000001052170554_p993418720497"></a><a name="en-us_topic_0000001052170554_p993418720497"></a>CameraStateCallback​()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p693511794919"><a name="en-us_topic_0000001052170554_p693511794919"></a><a name="en-us_topic_0000001052170554_p693511794919"></a>A constructor used to create a <strong id="en-us_topic_0000001052170554_b10634201491717"><a name="en-us_topic_0000001052170554_b10634201491717"></a><a name="en-us_topic_0000001052170554_b10634201491717"></a>CameraStateCallback</strong> instance.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row159358717497"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1992012253527"><a name="en-us_topic_0000001052170554_p1992012253527"></a><a name="en-us_topic_0000001052170554_p1992012253527"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p29351077497"><a name="en-us_topic_0000001052170554_p29351077497"></a><a name="en-us_topic_0000001052170554_p29351077497"></a>void OnConfigured​(Camera&amp; camera)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p093515774914"><a name="en-us_topic_0000001052170554_p093515774914"></a><a name="en-us_topic_0000001052170554_p093515774914"></a>Called when the camera is configured.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row9935147184918"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p117291328135211"><a name="en-us_topic_0000001052170554_p117291328135211"></a><a name="en-us_topic_0000001052170554_p117291328135211"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p19935174496"><a name="en-us_topic_0000001052170554_p19935174496"></a><a name="en-us_topic_0000001052170554_p19935174496"></a>void OnConfigureFailed​(Camera&amp; camera,int32_t errorCode)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p159352077495"><a name="en-us_topic_0000001052170554_p159352077495"></a><a name="en-us_topic_0000001052170554_p159352077495"></a>Called when the camera fails to be configured.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row1935279498"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1514619311525"><a name="en-us_topic_0000001052170554_p1514619311525"></a><a name="en-us_topic_0000001052170554_p1514619311525"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p493512744915"><a name="en-us_topic_0000001052170554_p493512744915"></a><a name="en-us_topic_0000001052170554_p493512744915"></a>void OnCreated​(Camera&amp; camera)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1493511784914"><a name="en-us_topic_0000001052170554_p1493511784914"></a><a name="en-us_topic_0000001052170554_p1493511784914"></a>Called when the camera is successfully created.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row189351877493"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p172071933175218"><a name="en-us_topic_0000001052170554_p172071933175218"></a><a name="en-us_topic_0000001052170554_p172071933175218"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p129361977498"><a name="en-us_topic_0000001052170554_p129361977498"></a><a name="en-us_topic_0000001052170554_p129361977498"></a>void OnCreateFailed​(std::string cameraId,int32_t errorCode)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p2936197114919"><a name="en-us_topic_0000001052170554_p2936197114919"></a><a name="en-us_topic_0000001052170554_p2936197114919"></a>Called when the camera fails to be created.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row20936472491"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p61213391523"><a name="en-us_topic_0000001052170554_p61213391523"></a><a name="en-us_topic_0000001052170554_p61213391523"></a>CameraStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p793697174919"><a name="en-us_topic_0000001052170554_p793697174919"></a><a name="en-us_topic_0000001052170554_p793697174919"></a>void OnReleased​(Camera&amp; camera)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p49361719495"><a name="en-us_topic_0000001052170554_p49361719495"></a><a name="en-us_topic_0000001052170554_p49361719495"></a>Called when the camera is released.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row159361179493"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p10936147194918"><a name="en-us_topic_0000001052170554_p10936147194918"></a><a name="en-us_topic_0000001052170554_p10936147194918"></a>FrameStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p9936279496"><a name="en-us_topic_0000001052170554_p9936279496"></a><a name="en-us_topic_0000001052170554_p9936279496"></a>FrameStateCallback​()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p49367718499"><a name="en-us_topic_0000001052170554_p49367718499"></a><a name="en-us_topic_0000001052170554_p49367718499"></a>A constructor used to create a <strong id="en-us_topic_0000001052170554_b225612012172"><a name="en-us_topic_0000001052170554_b225612012172"></a><a name="en-us_topic_0000001052170554_b225612012172"></a>FrameStateCallback</strong> instance.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row1893617744916"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p136968511524"><a name="en-us_topic_0000001052170554_p136968511524"></a><a name="en-us_topic_0000001052170554_p136968511524"></a>FrameStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p209379744911"><a name="en-us_topic_0000001052170554_p209379744911"></a><a name="en-us_topic_0000001052170554_p209379744911"></a>void OnFrameFinished(Camera&amp; camera, FrameConfig&amp; frameConfig, FrameResult&amp; frameResult)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p19374724913"><a name="en-us_topic_0000001052170554_p19374724913"></a><a name="en-us_topic_0000001052170554_p19374724913"></a>Called when the frame capture is completed.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row093719718495"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p772975317527"><a name="en-us_topic_0000001052170554_p772975317527"></a><a name="en-us_topic_0000001052170554_p772975317527"></a>FrameStateCallback</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p189371471498"><a name="en-us_topic_0000001052170554_p189371471498"></a><a name="en-us_topic_0000001052170554_p189371471498"></a>void OnFrameError​(Camera&amp; camera, FrameConfig&amp; frameConfig, int32_t errorCode, FrameResult&amp; frameResult)</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p109371778497"><a name="en-us_topic_0000001052170554_p109371778497"></a><a name="en-us_topic_0000001052170554_p109371778497"></a>Called when the frame capture fails.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row179381979499"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p169381975499"><a name="en-us_topic_0000001052170554_p169381975499"></a><a name="en-us_topic_0000001052170554_p169381975499"></a>FrameConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p1793867124910"><a name="en-us_topic_0000001052170554_p1793867124910"></a><a name="en-us_topic_0000001052170554_p1793867124910"></a>int32_t GetFrameConfigType()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p1993817744915"><a name="en-us_topic_0000001052170554_p1993817744915"></a><a name="en-us_topic_0000001052170554_p1993817744915"></a>Obtains the frame configuration type.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row793817784912"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p69381724914"><a name="en-us_topic_0000001052170554_p69381724914"></a><a name="en-us_topic_0000001052170554_p69381724914"></a>FrameConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p149382077496"><a name="en-us_topic_0000001052170554_p149382077496"></a><a name="en-us_topic_0000001052170554_p149382077496"></a>std::list&lt;OHOS::Surface&gt; GetSurfaces()</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p893867114919"><a name="en-us_topic_0000001052170554_p893867114919"></a><a name="en-us_topic_0000001052170554_p893867114919"></a>Obtains a list of surface objects (shared memories).</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row109401570498"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p294019712492"><a name="en-us_topic_0000001052170554_p294019712492"></a><a name="en-us_topic_0000001052170554_p294019712492"></a>FrameConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p19940170499"><a name="en-us_topic_0000001052170554_p19940170499"></a><a name="en-us_topic_0000001052170554_p19940170499"></a>void AddSurface(OHOS::AGP::UISurface&amp; surface);</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p11940197144915"><a name="en-us_topic_0000001052170554_p11940197144915"></a><a name="en-us_topic_0000001052170554_p11940197144915"></a>Adds a surface.</p>
</td>
</tr>
<tr id="en-us_topic_0000001052170554_row994018711492"><td class="cellrowborder" valign="top" width="18.811881188118814%" headers="mcps1.2.4.1.1 "><p id="en-us_topic_0000001052170554_p1094016718493"><a name="en-us_topic_0000001052170554_p1094016718493"></a><a name="en-us_topic_0000001052170554_p1094016718493"></a>FrameConfig</p>
</td>
<td class="cellrowborder" valign="top" width="46.534653465346544%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001052170554_p139411279498"><a name="en-us_topic_0000001052170554_p139411279498"></a><a name="en-us_topic_0000001052170554_p139411279498"></a>void RemoveSurface(OHOS::AGP::UISurface&amp; surface);</p>
</td>
<td class="cellrowborder" valign="top" width="34.65346534653466%" headers="mcps1.2.4.1.3 "><p id="en-us_topic_0000001052170554_p39415717494"><a name="en-us_topic_0000001052170554_p39415717494"></a><a name="en-us_topic_0000001052170554_p39415717494"></a>Removes a surface.</p>
</td>
</tr>
</tbody>
</table>
## Limitations and Constraints<a name="en-us_topic_0000001052170554_section1165911177314"></a>
None
## How to Develop<a name="en-us_topic_0000001052170554_section138543918214"></a>
1. Extend the **CameraDeviceCallback** class and call **OnCameraStatus** to customize operations when the camera device changes, for example, when a camera becomes available or unavailable.
```
class SampleCameraDeviceCallback : public CameraDeviceCallback {
void OnCameraStatus(std::string cameraId, int32_t status) override
{
// Do something when camera is available or unavailable.
}
};
```
2. Extend the **FrameStateCallback** class. After obtaining the frame data, save the data as a file.
```
static void SampleSaveCapture(const char *p, uint32_t size)
{
cout << "Start saving picture" << endl;
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm *ltm = localtime(&tv.tv_sec);
if (ltm != nullptr) {
ostringstream ss("Capture_");
ss << "Capture" << ltm->tm_hour << "-" << ltm->tm_min << "-" << ltm->tm_sec << ".jpg";
ofstream pic("/sdcard/" + ss.str(), ofstream::out | ofstream::trunc);
cout << "write " << size << " bytes" << endl;
pic.write(p, size);
cout << "Saving picture end" << endl;
}
}
class TestFrameStateCallback : public FrameStateCallback {
void OnFrameFinished(Camera &camera, FrameConfig &fc, FrameResult &result) override
{
cout << "Receive frame complete inform." << endl;
if (fc.GetFrameConfigType() == FRAME_CONFIG_CAPTURE) {
cout << "Capture frame received." << endl;
list<Surface *> surfaceList = fc.GetSurfaces();
for (Surface *surface : surfaceList) {
SurfaceBuffer *buffer = surface->AcquireBuffer();
if (buffer != nullptr) {
char *virtAddr = static_cast<char *>(buffer->GetVirAddr());
if (virtAddr != nullptr) {
SampleSaveCapture(virtAddr, buffer->GetSize());
}
surface->ReleaseBuffer(buffer);
}
delete surface;
}
delete &fc;
}
}
};
```
3. Extend the **CameraStateCallback** class and customize operations when the camera state changes \(configuration successful or failed, and creation successful or failed\).
```
class SampleCameraStateMng : public CameraStateCallback {
public:
SampleCameraStateMng() = delete;
SampleCameraStateMng(EventHandler &eventHdlr) : eventHdlr_(eventHdlr) {}
~SampleCameraStateMng()
{
if (recordFd_ != -1) {
close(recordFd_);
}
}
void OnCreated(Camera &c) override
{
cout << "Sample recv OnCreate camera." << endl;
auto config = CameraConfig::CreateCameraConfig();
config->SetFrameStateCallback(&fsCb_, &eventHdlr_);
c.Configure(*config);
cam_ = &c;
}
void OnCreateFailed(const std::string cameraId, int32_t errorCode) override {}
void OnReleased(Camera &c) override {}
};
```
4. Create a **CameraKit** instance to set and obtain camera information.
```
CameraKit *camKit = CameraKit::GetInstance();
list<string> camList = camKit->GetCameraIds();
string camId;
for (auto &cam : camList) {
cout << "camera name:" << cam << endl;
const CameraAbility *ability = camKit->GetCameraAbility(cam);
/* Find the camera that fits your ability. */
list<CameraPicSize> sizeList = ability->GetSupportedSizes(0);
if (find(sizeList.begin(), sizeList.end(), CAM_PIC_1080P) != sizeList.end()) {
camId = cam;
break;
}
}
```
5. Create a **Camera** instance.
```
EventHandler eventHdlr; // Create a thread to handle callback events.
SampleCameraStateMng CamStateMng(eventHdlr);
camKit->CreateCamera(camId, CamStateMng, eventHdlr);
```
6. Based on the callback design in steps 1 to 3, perform related operations until the **OnCreated** callback obtains **cam\_**.
```
void OnCreated(Camera &c) override
{
cout << "Sample recv OnCreate camera." << endl;
auto config = CameraConfig::CreateCameraConfig();
config->SetFrameStateCallback(&fsCb_, &eventHdlr_);
c.Configure(*config);
cam_ = &c;
}
void Capture()
{
if (cam_ == nullptr) {
cout << "Camera is not ready." << endl;
return;
}
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
if (surface == nullptr) {
delete fc;
return;
}
surface->SetWidthAndHeight(1920, 1080); /* 1920:width,1080:height */
fc->AddSurface(*surface);
cam_->TriggerSingleCapture(*fc);
}
```
# Video Recording<a name="EN-US_TOPIC_0000001054754827"></a>
## When to Use<a name="en-us_topic_0000001051451869_section186634310418"></a>
Use the camera module APIs to capture video streams.
## Available APIs<a name="en-us_topic_0000001051451869_section125479541744"></a>
For details, see the available APIs described in development guidelines on photographing.
## Limitations and Constraints<a name="en-us_topic_0000001051451869_section1165911177314"></a>
None
## How to Develop<a name="en-us_topic_0000001051451869_section1196016315516"></a>
1. Perform step 1 through step 4 described in development guidelines on photographing.
2. Obtain the **FrameConfig** instance for audio recording.
```
/* Obtain the surface from the recorder. */
Surface *surface = recorder_->GetSurface(0);
surface->SetWidthAndHeight(1920, 1080);
surface->SetQueueSize(3);
surface->SetSize(1024 * 1024);
/* Add the surface to the FrameConfig instance. */
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_RECORD);
fc->AddSurface(*surface);
```
3. Start and stop video recording.
```
stateCallback->camera_->TriggerLoopingCapture(*fc); // Start recording.
stateCallback->camera_->StopLoopingCapture(); // Stop recording.
```
# Use Case<a name="EN-US_TOPIC_0000001055686082"></a>
- For details about the development board, compilation, burning, and image running, see [Quick Start](../quick-start/Readme-EN.md). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**.
Modify **output\_dir** in **applications/sample/camera/media/BUILD.gn**.
- Before: **output\_dir = "$root\_out\_dir/dev\_tools"**
- After: **output\_dir = "$root\_out\_dir/"**
Recompile the source code repository and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board.
- The sample code for camera development is stored in **applications/sample/camera/media/camera\_sample.cpp**.
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>You should insert a TF card \(maximum capacity: 128 GB\) for photographing and video recording functions. After the system is started, the TF card is automatically mounted to the **/sdcard** directory. If the TF card is inserted after the system is started, you have to manually mount the TF card. To view the photos and videos in the TF card, copy the content to a computer. The preview function does not require a TF card.
1. Run the **cd** command to go to the end path of the executable program and start **camera\_sample** by running the command in the following figure.
**Figure 1** Starting camera\_sample<a name="en-us_topic_0000001055301733_fig380985885020"></a>
![](figures/starting-camera_sample.png "starting-camera_sample")
The control commands are displayed as shown in the preceding figure. Press **S** to stop the current operation \(including video recording and preview\), and press **Q** to exit the program.
2. Press **1** to take a photo in JPG format. The photo is saved in the **/sdcard** directory and named **Capture\***.
**Figure 2** Serial port logs displayed after the photographing command is executed<a name="en-us_topic_0000001055301733_fig17819185018384"></a>
![](figures/serial-port-logs-displayed-after-the-photographing-command-is-executed.png "serial-port-logs-displayed-after-the-photographing-command-is-executed")
To view the saved file, exit the program and enter the file system. To start the program again, return to the previous step.
**Figure 3** Saved files<a name="en-us_topic_0000001055301733_fig166391743154619"></a>
![](figures/saved-files.png "saved-files")
3. Press **2** to start recording. The video file is in MP4 format and saved in the **/sdcard** directory with the name **Record\***. Press **S** to stop recording.
**Figure 4** Serial port logs displayed after the recording command is executed<a name="en-us_topic_0000001055301733_fig6340814174317"></a>
![](figures/serial-port-logs-displayed-after-the-recording-command-is-executed.png "serial-port-logs-displayed-after-the-recording-command-is-executed")
4. Press **Q** to exit.
**Figure 5** Serial port logs displayed after the exit command is executed<a name="en-us_topic_0000001055301733_fig1755682174514"></a>
![](figures/serial-port-logs-displayed-after-the-exit-command-is-executed.png "serial-port-logs-displayed-after-the-exit-command-is-executed")
# Camera Control Overview<a name="EN-US_TOPIC_0000001055366100"></a>
This document describes how to use the IoT camera development board and the built-in camera of the development kit to implement photographing and video recording.
You can perform operations provided in [Use Case](device-iotcamera-control-example.md) to learn more about development board peripheral control and then develop devices such as cameras.
If you want to view the sample effect first, see [Use Case](device-iotcamera-control-example.md). To customize application behavior, modify the sample code by referring to APIs described in the next section.
For details about basic concepts for camera development, see [Camera Overview](../subsystems/subsys-multimedia-camera-overview.md).
# Kernel Coding Specification<a name="EN-US_TOPIC_0000001079036432"></a> # Kernel Coding Specification
This kernel coding specification is developed based on the general programming specifications in the industry. It defines the programming styles for kernel developers to follow. This kernel coding specification is developed based on the general programming specifications in the industry. It defines the programming styles for kernel developers to follow.
......
...@@ -24,7 +24,7 @@ The CPU architecture includes two layers: general architecture definition layer ...@@ -24,7 +24,7 @@ The CPU architecture includes two layers: general architecture definition layer
| Header file name| los_&lt;function&gt;.h | los_arch_&lt;function&gt;.h | | Header file name| los_&lt;function&gt;.h | los_arch_&lt;function&gt;.h |
| Function name| Halxxxx | Halxxxx | | Function name| Halxxxx | Halxxxx |
LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see [Chip Architecture Adaptation](../porting/porting-chip-kernel-overview.md). LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V.
## Working Principles ## Working Principles
......
...@@ -16,7 +16,7 @@ The kernel used by module chips is LiteOS Cortex-M, which consists of four modul ...@@ -16,7 +16,7 @@ The kernel used by module chips is LiteOS Cortex-M, which consists of four modul
**Figure 1** Architecture of the LiteOS Cortex-M kernel<a name="fig10838105524917"></a> **Figure 1** Architecture of the LiteOS Cortex-M kernel<a name="fig10838105524917"></a>
<img src="figures/architecture-of-the-liteos-cortex-m-kernel.png" style="zoom:75%;" /> ![architecture-of-the-liteos-cortex-m-kernel.png](figures/architecture-of-the-liteos-cortex-m-kernel.png)
The directory structure of the kernel is described as follows: The directory structure of the kernel is described as follows:
......
...@@ -94,7 +94,7 @@ For device with 128 KB to 128 MB of memory, the OpenHarmony lite kernel is recom ...@@ -94,7 +94,7 @@ For device with 128 KB to 128 MB of memory, the OpenHarmony lite kernel is recom
- Secure boot must be enabled, and the trusted root must be in the chip and cannot be modified. In addition, you must consider the impact of secure upgrade (if available) on secure boot, that is, the signature or hash value of an image file must be updated after a secure upgrade. - Secure boot must be enabled, and the trusted root must be in the chip and cannot be modified. In addition, you must consider the impact of secure upgrade (if available) on secure boot, that is, the signature or hash value of an image file must be updated after a secure upgrade.
## Data security ## Data Security
### Security Mechanism ### Security Mechanism
......
# Privacy Protection<a name="EN-US_TOPIC_0000001083754024"></a> # Privacy Protection
## Overview<a name="section13200134331414"></a> ## Overview
Personal data plays an increasingly important role in social economy and daily life along with the development of the Internet and informatization. Meanwhile, personal data leakage risks are increasing. As consumer product developers, you shall take more effective measures to protect users' personal data and improve their trust in your products. To protect consumers' privacy and improve their experience on privacy, you should set high-level privacy protection policies for your product. Personal data plays an increasingly important role in social economy and daily life along with the development of the Internet and informatization. Meanwhile, personal data leakage risks are increasing. As consumer product developers, you shall take more effective measures to protect users' personal data and improve their trust in your products. To protect consumers' privacy and improve their experience on privacy, you should set high-level privacy protection policies for your product.
...@@ -49,7 +49,7 @@ Personal data plays an increasingly important role in social economy and daily l ...@@ -49,7 +49,7 @@ Personal data plays an increasingly important role in social economy and daily l
- Users provide information proactively, such as scenarios where a user enters their identification number and bank card number to bind the bank card. - Users provide information proactively, such as scenarios where a user enters their identification number and bank card number to bind the bank card.
## Data Classification<a name="section2371104991511"></a> ## Data Classification
Data is classified into five levels: very high, high, moderate, low, and public based on the data protection objectives and consequences \(the impact of legal risks caused by data leakage or damage on individuals, organizations, or the public\). Data is classified into five levels: very high, high, moderate, low, and public based on the data protection objectives and consequences \(the impact of legal risks caused by data leakage or damage on individuals, organizations, or the public\).
...@@ -116,7 +116,7 @@ Data is classified into five levels: very high, high, moderate, low, and public ...@@ -116,7 +116,7 @@ Data is classified into five levels: very high, high, moderate, low, and public
Note: For details about the definitions of privacy protection and data classification, see GDPR. Note: For details about the definitions of privacy protection and data classification, see GDPR.
## General Privacy Design Rules<a name="section10354102411162"></a> ## General Privacy Design Rules
To help you better complete privacy design for OpenHarmony products, we sort out general privacy design requirements. To help you better complete privacy design for OpenHarmony products, we sort out general privacy design requirements.
...@@ -133,7 +133,7 @@ When collecting personal data, clearly and explicitly notify users of the data t ...@@ -133,7 +133,7 @@ When collecting personal data, clearly and explicitly notify users of the data t
Guided by the preceding principles, we have designed some examples for your reference. The figures below are examples of a privacy notice and a privacy statement, respectively. Guided by the preceding principles, we have designed some examples for your reference. The figures below are examples of a privacy notice and a privacy statement, respectively.
**Figure 1** Examples of a privacy notice and a privacy statement<a name="fig1611815442274"></a> **Figure 1** Examples of a privacy notice and a privacy statement
![](figure/privacy-notice.png)![](figure/privacy-statement.png) ![](figure/privacy-notice.png)![](figure/privacy-statement.png)
...@@ -190,9 +190,9 @@ You shall obtain consent from users and comply with applicable laws and regulati ...@@ -190,9 +190,9 @@ You shall obtain consent from users and comply with applicable laws and regulati
Data processing security shall be ensured in technical terms, which include encrypted data storage and secure data transfer. Security mechanisms or measures shall be enabled by default for a system. Data processing security shall be ensured in technical terms, which include encrypted data storage and secure data transfer. Security mechanisms or measures shall be enabled by default for a system.
- A protection mechanism shall be available for personal data access, including identity authentication and access control. Identity authentication \(such as username and password\) allows only authenticated users to access data in multi-user scenarios. Access control \(for example, [permission control](security-guidelines-overall.md#section852593153614)\) can be applied to restrict access to applications. - A protection mechanism shall be available for personal data access, including identity authentication and access control. Identity authentication \(such as username and password\) allows only authenticated users to access data in multi-user scenarios. Access control \(for example, [permission control](../security/security-guidelines-overall.md)\) can be applied to restrict access to applications.
- Secure storage of personal data on distributed devices must meet Huawei Universal Keystore \(HUKS\) requirements, including secure storage of keys and data. - Secure storage of personal data on distributed devices must meet Huawei Universal Keystore \(HUKS\) requirements, including secure storage of keys and data.
- The transfer of personal data between distributed devices must meet the trust binding relationship between devices and security requirements of data transmission channels. For details, see [Security Guidelines](security-guidelines-overall.md#section26153183616). - The transfer of personal data between distributed devices must meet the trust binding relationship between devices and security requirements of data transmission channels. For details, see [Device Interconnection Security](../security/security-guidelines-overall.md#device-interconnection-security).
- Authentication data \(such as passwords and fingerprints\) shall be encrypted before being stored. - Authentication data \(such as passwords and fingerprints\) shall be encrypted before being stored.
**Localization** **Localization**
...@@ -203,7 +203,7 @@ User data shall be preferentially processed on the local device. Data that canno ...@@ -203,7 +203,7 @@ User data shall be preferentially processed on the local device. Data that canno
If your product is designed for minors or you can identify, based on the collected user age data, that the end user is a minor, you shall particularly analyze issues related to minors' personal data protection based on relevant national laws in the target market. Your product shall obtain explicit consent from the holders of parental responsibility over minors. If your product is designed for minors or you can identify, based on the collected user age data, that the end user is a minor, you shall particularly analyze issues related to minors' personal data protection based on relevant national laws in the target market. Your product shall obtain explicit consent from the holders of parental responsibility over minors.
## **Privacy Protection Requirements for Special Categories**<a name="section118861450201618"></a> ## **Privacy Protection Requirements for Special Categories**
In addition to these general privacy requirements, consumer hardware products have the following requirements for special categories. You shall comply with these requirements during product design. In addition to these general privacy requirements, consumer hardware products have the following requirements for special categories. You shall comply with these requirements during product design.
......
# AI Framework Development Guide # AI Framework Development
## **Overview** ## **Overview**
......
# HiTraceChain Development<a name="EN-US_TOPIC_0000001186134310"></a> # HiTraceChain Development
## Overview<a name="section3986195420436"></a> ## Overview
HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system.
## Use Cases<a name="section134561822574"></a> ## Use Cases
HiTraceChain can be used for the following purposes: HiTraceChain can be used for the following purposes:
...@@ -14,32 +14,36 @@ HiTraceChain can be used for the following purposes: ...@@ -14,32 +14,36 @@ HiTraceChain can be used for the following purposes:
- Works with the IDE to debug the detailed service process and time consumption distribution for system optimization. - Works with the IDE to debug the detailed service process and time consumption distribution for system optimization.
**Figure 1** Use cases of HiTraceChain<a name="fig179241023125715"></a> **Figure 1** Use cases of HiTraceChain
![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace") ![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace")
### Usage Example<a name="section63861653124417"></a> ### Usage Example
**Figure 2** Service calling process \(inter-device and inter-process synchronous call\)
**Figure 2** Service calling process \(inter-device and inter-process synchronous call\)<a name="fig173491014145819"></a>
![](figure/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)") ![](figure/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)")
1. Display the call relationship in the service process, analyze key paths and function dependency, and determine the time consumption and call frequency at each call point to detect performance bottlenecks. 1. Display the call relationship in the service process, analyze key paths and function dependency, and determine the time consumption and call frequency at each call point to detect performance bottlenecks.
**Figure 3** Service calling process<a name="fig205051834145813"></a> **Figure 3** Service calling process
![](figure/service-calling-process.png "service-calling-process") ![](figure/service-calling-process.png "service-calling-process")
**Figure 4** Time delay in the service calling process<a name="fig1212812422586"></a> **Figure 4** Time delay in the service calling process
![](figure/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process") ![](figure/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process")
2. Add **traceid** to logs and events automatically to facilitate comprehensive analysis and quick fault location. 2. Add **traceid** to logs and events automatically to facilitate comprehensive analysis and quick fault location.
## Available APIs<a name="section1517945334617"></a> ## Available APIs
HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain tracing. HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain tracing.
HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTraceChain sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTraceChain obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTraceChain clears **traceid** from the TLS of the calling thread. HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTraceChain sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTraceChain obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTraceChain clears **traceid** from the TLS of the calling thread.
### Java, C++, and C APIs<a name="section932504474"></a> ### Java, C++, and C APIs
**Table 1** Description of C++ and C APIs **Table 1** Description of C++ and C APIs
...@@ -195,7 +199,7 @@ HiTraceChain is implemented at layer C. It works by transferring **traceid** t ...@@ -195,7 +199,7 @@ HiTraceChain is implemented at layer C. It works by transferring **traceid** t
</tbody> </tbody>
</table> </table>
### Parameters of C++ APIs<a name="section2514638125"></a> ### Parameters of C++ APIs
**Table 2** Parameters of C++ APIs **Table 2** Parameters of C++ APIs
...@@ -428,7 +432,7 @@ HiTraceChain is implemented at layer C. It works by transferring **traceid** t ...@@ -428,7 +432,7 @@ HiTraceChain is implemented at layer C. It works by transferring **traceid** t
</tbody> </tbody>
</table> </table>
## Call Chain Processing<a name="section11257133933"></a> ## Call Chain Processing
Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTraceChain** requires transfer of **traceid** in the communication mechanism. Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTraceChain** requires transfer of **traceid** in the communication mechanism.
...@@ -438,7 +442,8 @@ The following figure shows the process of transferring **traceid** in synchron ...@@ -438,7 +442,8 @@ The following figure shows the process of transferring **traceid** in synchron
Extended communication mechanisms can also follow this implementation. Extended communication mechanisms can also follow this implementation.
**Figure 5** Call chain tracing in synchronous communication<a name="fig36822045171020"></a> **Figure 5** Call chain tracing in synchronous communication
![](figure/call-chain-tracing-in-synchronous-communication.png "call-chain-tracing-in-synchronous-communication") ![](figure/call-chain-tracing-in-synchronous-communication.png "call-chain-tracing-in-synchronous-communication")
The process is as follows: The process is as follows:
...@@ -471,9 +476,9 @@ The process is as follows: ...@@ -471,9 +476,9 @@ The process is as follows:
8. The service module on the client processes the transact reply response. 8. The service module on the client processes the transact reply response.
9. When the process ends, the service module on the client calls the **end\(\)** function to stop call chain tracing. 9. When the process ends, the service module on the client calls the **end\(\)** function to stop call chain tracing.
## How to Develop<a name="section14310412491"></a> ## How to Develop
### C++<a name="section114916381509"></a> ### C++
1. Develop the source code. 1. Develop the source code.
...@@ -499,7 +504,7 @@ The process is as follows: ...@@ -499,7 +504,7 @@ The process is as follows:
``` ```
### C<a name="section108292107514"></a> ### C
1. Develop the source code. 1. Develop the source code.
......
# Telephony Development<a name="EN-US_TOPIC_0000001167051994"></a> # Telephony Development
## Initializing a Modem Vendor Library<a name="section211mcpsimp"></a> ## Initializing a Modem Vendor Library
### When to Use<a name="section213mcpsimp"></a> ### When to Use
Initializing a modem vendor library means to implement **const HRilOps \*RilInitOps\(const struct HRilReport \*reportOps\)** function in the vendor library. This function is mainly used to: Initializing a modem vendor library means to implement **const HRilOps \*RilInitOps\(const struct HRilReport \*reportOps\)** function in the vendor library. This function is mainly used to:
...@@ -10,7 +10,7 @@ Initializing a modem vendor library means to implement **const HRilOps \*RilInit ...@@ -10,7 +10,7 @@ Initializing a modem vendor library means to implement **const HRilOps \*RilInit
- Create a thread for reading modem nodes. In this thread, the data reported by the modem is read cyclically and parsed as a specific service event for reporting. - Create a thread for reading modem nodes. In this thread, the data reported by the modem is read cyclically and parsed as a specific service event for reporting.
- Return the function pointer of the service request API to RIL Adapter. - Return the function pointer of the service request API to RIL Adapter.
### Available APIs<a name="section811343241215"></a> ### Available APIs
The following table describes the API for initializing a modem vendor library. The following table describes the API for initializing a modem vendor library.
...@@ -20,7 +20,7 @@ The following table describes the API for initializing a modem vendor library. ...@@ -20,7 +20,7 @@ The following table describes the API for initializing a modem vendor library.
| -------- | -------- | | -------- | -------- |
| const&nbsp;HRilOps&nbsp;\*RilInitOps(const&nbsp;struct&nbsp;HRilReport&nbsp;\*&nbsp;reportOps) | Provides an entry for running a modem vendor library.<br>Input parameter:<br>**reportOps**: Specifies the pointer to the event callback function, which is passed by RIL Adapter.<br/>Return result: function pointer of the service request API. | | const&nbsp;HRilOps&nbsp;\*RilInitOps(const&nbsp;struct&nbsp;HRilReport&nbsp;\*&nbsp;reportOps) | Provides an entry for running a modem vendor library.<br>Input parameter:<br>**reportOps**: Specifies the pointer to the event callback function, which is passed by RIL Adapter.<br/>Return result: function pointer of the service request API. |
### How to Develop<a name="section51031144122"></a> ### How to Develop
1. Set the event callback function pointers passed by RIL Adapter through **RilInitOps**. 1. Set the event callback function pointers passed by RIL Adapter through **RilInitOps**.
...@@ -37,7 +37,7 @@ The following table describes the API for initializing a modem vendor library. ...@@ -37,7 +37,7 @@ The following table describes the API for initializing a modem vendor library.
``` ```
1. Create the **g\_reader** main thread to enable message looping. 2. Create the **g\_reader** main thread to enable message looping.
``` ```
pthread_attr_t t; pthread_attr_t t;
...@@ -47,7 +47,7 @@ The following table describes the API for initializing a modem vendor library. ...@@ -47,7 +47,7 @@ The following table describes the API for initializing a modem vendor library.
``` ```
1. In the **g\_eventListeners** thread, use **open\(\)** to open a modem node and then create the **g\_reader** thread to read and process messages reported by the modem. 3. In the **g\_eventListeners** thread, use **open\(\)** to open a modem node and then create the **g\_reader** thread to read and process messages reported by the modem.
``` ```
g_fd = open(g_devicePath, O_RDWR); // Open the device node specified by g_devicePath. g_fd = open(g_devicePath, O_RDWR); // Open the device node specified by g_devicePath.
...@@ -57,7 +57,7 @@ The following table describes the API for initializing a modem vendor library. ...@@ -57,7 +57,7 @@ The following table describes the API for initializing a modem vendor library.
``` ```
1. Return the function pointer of the service request API. 4. Return the function pointer of the service request API.
``` ```
// Structure for the service request API of the call module // Structure for the service request API of the call module
...@@ -105,9 +105,9 @@ The following table describes the API for initializing a modem vendor library. ...@@ -105,9 +105,9 @@ The following table describes the API for initializing a modem vendor library.
``` ```
### Debugging and Verification<a name="section5351151517132"></a> ### Debugging and Verification
1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#preparations) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. For details about how to integrate a library file, see [Integrating Modem Vendor Libraries](#section590mcpsimp). 1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#how-to-obtain) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. For details about how to integrate a library file, see [Integrating Modem Vendor Libraries](#integrating-modem-vendor-libraries).
``` ```
hdc_std file send libril_vendor.z.so /system/lib/ hdc_std file send libril_vendor.z.so /system/lib/
...@@ -128,13 +128,13 @@ The following table describes the API for initializing a modem vendor library. ...@@ -128,13 +128,13 @@ The following table describes the API for initializing a modem vendor library.
``` ```
## Responding to Modem Service Requests<a name="section295mcpsimp"></a> ## Responding to Modem Service Requests
### When to Use<a name="section297mcpsimp"></a> ### When to Use
After receiving a specific telephony service request, RIL Adapter calls the target function pointer obtained in modem vendor library initialization to send a specific service request to the vendor library. Then, the vendor library processes the request based on the request ID. After receiving a specific telephony service request, RIL Adapter calls the target function pointer obtained in modem vendor library initialization to send a specific service request to the vendor library. Then, the vendor library processes the request based on the request ID.
### Available APIs<a name="section9503155219134"></a> ### Available APIs
The following table describes the APIs for responding to modem service requests, with the dial module as an example. The following table describes the APIs for responding to modem service requests, with the dial module as an example.
...@@ -145,7 +145,7 @@ The following table describes the APIs for responding to modem service requests, ...@@ -145,7 +145,7 @@ The following table describes the APIs for responding to modem service requests,
| void&nbsp;ReqDial(ReqDataInfo&nbsp;\*requestInfo,&nbsp;const&nbsp;void&nbsp;\*data,&nbsp;size_t&nbsp;dataLen); | Processes number dial requests.<br>Input parameters:<br>**requestInfo**: request type<br/>**data**: called number<br/>**dataLen**: data length<br/>Return value: none | | void&nbsp;ReqDial(ReqDataInfo&nbsp;\*requestInfo,&nbsp;const&nbsp;void&nbsp;\*data,&nbsp;size_t&nbsp;dataLen); | Processes number dial requests.<br>Input parameters:<br>**requestInfo**: request type<br/>**data**: called number<br/>**dataLen**: data length<br/>Return value: none |
| void&nbsp;(\*OnCallReport)(struct&nbsp;ReportInfo&nbsp;reportInfo,&nbsp;const&nbsp;void&nbsp;\*data,&nbsp;size_t&nbsp;dataLen); | Reports the execution result of a service request to RIL Adapter.<br>Input parameters:<br>**reportInfo**: request type<br/>**data**: called number<br/>**dataLen**: data length<br/>Return value: none | | void&nbsp;(\*OnCallReport)(struct&nbsp;ReportInfo&nbsp;reportInfo,&nbsp;const&nbsp;void&nbsp;\*data,&nbsp;size_t&nbsp;dataLen); | Reports the execution result of a service request to RIL Adapter.<br>Input parameters:<br>**reportInfo**: request type<br/>**data**: called number<br/>**dataLen**: data length<br/>Return value: none |
### How to Develop<a name="section17190412101414"></a> ### How to Develop
1. Implement processing of dial requests in the **ReqDial\(\)** API. 1. Implement processing of dial requests in the **ReqDial\(\)** API.
...@@ -199,9 +199,9 @@ The following table describes the APIs for responding to modem service requests, ...@@ -199,9 +199,9 @@ The following table describes the APIs for responding to modem service requests,
``` ```
### Debugging and Verification<a name="section10207938171413"></a> ### Debugging and Verification
1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#preparations) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. 1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#how-to-obtain) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device.
``` ```
hdc_std file send libril_vendor.z.so /system/lib/ hdc_std file send libril_vendor.z.so /system/lib/
...@@ -242,13 +242,13 @@ The following table describes the APIs for responding to modem service requests, ...@@ -242,13 +242,13 @@ The following table describes the APIs for responding to modem service requests,
``` ```
## Reporting Modem Events<a name="section390mcpsimp"></a> ## Reporting Modem Events
### When to Use<a name="section401mcpsimp"></a> ### When to Use
A modem node thread reads the messages reported by the modem cyclically, parses the messages into specific events, and then reports the events to RIL Adapter. A modem node thread reads the messages reported by the modem cyclically, parses the messages into specific events, and then reports the events to RIL Adapter.
### Available APIs<a name="section191193791518"></a> ### Available APIs
The following table describes the API for reporting modem events. The following table describes the API for reporting modem events.
...@@ -258,7 +258,7 @@ The following table describes the API for reporting modem events. ...@@ -258,7 +258,7 @@ The following table describes the API for reporting modem events.
| -------- | -------- | | -------- | -------- |
| void&nbsp;OnNotifyOps(const&nbsp;char&nbsp;\*s,&nbsp;const&nbsp;char&nbsp;\*smsPdu) | Distributes the events reported by the modem.<br>Input parameters:<br/>**s**: AT command prefix<br/>**smsPdu**: PDU of the SMS message<br/>Return value: none | | void&nbsp;OnNotifyOps(const&nbsp;char&nbsp;\*s,&nbsp;const&nbsp;char&nbsp;\*smsPdu) | Distributes the events reported by the modem.<br>Input parameters:<br/>**s**: AT command prefix<br/>**smsPdu**: PDU of the SMS message<br/>Return value: none |
### How to Develop<a name="section16394112401512"></a> ### How to Develop
1. Call **OnNotifyOps\(\)** in the g\_reader thread of the modem device node to parse reported modem events. On determining the command type, call **OnXxxReport\(\)** to report the parsed module events to the hril layer. 1. Call **OnNotifyOps\(\)** in the g\_reader thread of the modem device node to parse reported modem events. On determining the command type, call **OnXxxReport\(\)** to report the parsed module events to the hril layer.
...@@ -290,7 +290,7 @@ The following table describes the API for reporting modem events. ...@@ -290,7 +290,7 @@ The following table describes the API for reporting modem events.
``` ```
1. Distribute the reported events from the **hril** layer to the Telephony Service layer. 2. Distribute the reported events from the **hril** layer to the Telephony Service layer.
``` ```
// Report the call status proactively. // Report the call status proactively.
...@@ -316,9 +316,9 @@ The following table describes the API for reporting modem events. ...@@ -316,9 +316,9 @@ The following table describes the API for reporting modem events.
``` ```
### Debugging and Verification<a name="section16999174401516"></a> ### Debugging and Verification
1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#preparations) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. 1. Use the [hdc\_std](../subsystems/subsys-toolchain-hdc-guide.md#how-to-obtain) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device.
``` ```
hdc_std file send libril_vendor.z.so /system/lib/ hdc_std file send libril_vendor.z.so /system/lib/
...@@ -370,7 +370,7 @@ The following table describes the API for reporting modem events. ...@@ -370,7 +370,7 @@ The following table describes the API for reporting modem events.
``` ```
### Development Examples<a name="section33444350167"></a> ### Development Examples
- **Outgoing Call** - **Outgoing Call**
...@@ -492,11 +492,11 @@ The following table describes the API for reporting modem events. ...@@ -492,11 +492,11 @@ The following table describes the API for reporting modem events.
``` ```
## Integrating Modem Vendor Libraries<a name="section590mcpsimp"></a> ## Integrating Modem Vendor Libraries
### Configuring Compilation Information<a name="section592mcpsimp"></a> ### Configuring Compilation Information
Compile the modem vendor library into a dynamic library by using **BUILD.gn**. Upon startup, RIL Adapter loads the dynamic library to the system in dlopen mode and then initializes the library. For details about how to implement vendor library initialization, see [Initializing a Modem Vendor Library](#section211mcpsimp). The following is an example of **BUILD.gn**: Compile the modem vendor library into a dynamic library by using **BUILD.gn**. Upon startup, RIL Adapter loads the dynamic library to the system in dlopen mode and then initializes the library. For details about how to implement vendor library initialization, see [Initializing a Modem Vendor Library](#initializing-a-modem-vendor-library). The following is an example of **BUILD.gn**:
``` ```
import("//build/ohos.gni") import("//build/ohos.gni")
...@@ -523,7 +523,7 @@ ohos_shared_library("ril_vendor") { // Modem vendor library ...@@ -523,7 +523,7 @@ ohos_shared_library("ril_vendor") { // Modem vendor library
} }
``` ```
### Debugging and Verification<a name="section620mcpsimp"></a> ### Debugging and Verification
1. Compile the code. 1. Compile the code.
2. Check whether **libril\_vendor.z.so** exists in the **/out/{device_name}/telephony/ril\_adapter** directory. If yes, the integration is successful. Otherwise, correct the error and perform debugging and verification again. 2. Check whether **libril\_vendor.z.so** exists in the **/out/{device_name}/telephony/ril\_adapter** directory. If yes, the integration is successful. Otherwise, correct the error and perform debugging and verification again.
......
...@@ -395,6 +395,7 @@ ...@@ -395,6 +395,7 @@
- [Doubly Linked List](kernel/kernel-small-apx-dll.md) - [Doubly Linked List](kernel/kernel-small-apx-dll.md)
- [Bitwise Operation](kernel/kernel-small-apx-bitwise.md) - [Bitwise Operation](kernel/kernel-small-apx-bitwise.md)
- [Standard Library](kernel/kernel-small-apx-library.md) - [Standard Library](kernel/kernel-small-apx-library.md)
- [Kernel Coding Specification](kernel/kernel-mini-appx-code.md)
- Kernel for Standard Systems - Kernel for Standard Systems
- [Linux Kernel Overview](kernel/kernel-standard-overview.md) - [Linux Kernel Overview](kernel/kernel-standard-overview.md)
- [Applying Patches on OpenHarmony Development Boards](kernel/kernel-standard-patch.md) - [Applying Patches on OpenHarmony Development Boards](kernel/kernel-standard-patch.md)
...@@ -450,6 +451,7 @@ ...@@ -450,6 +451,7 @@
- Peripheral Driver Usage - Peripheral Driver Usage
- [Audio](driver/driver-peripherals-audio-des.md) - [Audio](driver/driver-peripherals-audio-des.md)
- [Camera](driver/driver-peripherals-camera-des.md) - [Camera](driver/driver-peripherals-camera-des.md)
- [Codec](driver/driver-peripherals-codec-des.md)
- [Facial Authentication](driver/driver-peripherals-face_auth-des.md) - [Facial Authentication](driver/driver-peripherals-face_auth-des.md)
- [Fingerprint Authentication](driver/driver-peripherals-fingerprint_auth-des.md) - [Fingerprint Authentication](driver/driver-peripherals-fingerprint_auth-des.md)
- [LCD](driver/driver-peripherals-lcd-des.md) - [LCD](driver/driver-peripherals-lcd-des.md)
...@@ -502,21 +504,7 @@ ...@@ -502,21 +504,7 @@
- [Utils Overview](subsystems/subsys-utils-overview.md) - [Utils Overview](subsystems/subsys-utils-overview.md)
- [Utils Development](subsystems/subsys-utils-guide.md) - [Utils Development](subsystems/subsys-utils-guide.md)
- [Utils FAQ](subsystems/subsys-utils-faqs.md) - [Utils FAQ](subsystems/subsys-utils-faqs.md)
- AI Framework - [AI Framework Development](subsystems/subsys-ai-aiframework-devguide.md)
- [AI Engine Framework](subsystems/subsys-aiframework-guide.md)
- [Development Environment](subsystems/subsys-aiframework-envbuild.md)
- Technical Specifications
- [Code Management](subsystems/subsys-aiframework-tech-codemanage.md)
- [Naming](subsystems/subsys-aiframework-tech-name.md)
- [API Development](subsystems/subsys-aiframework-tech-interface.md)
- Development Guidelines
- [SDK](subsystems/subsys-aiframework-devguide-sdk.md)
- [Plug-in](subsystems/subsys-aiframework-devguide-plugin.md)
- [Configuration File](subsystems/subsys-aiframework-devguide-conf.md)
- Development Examples
- [KWS SDK](subsystems/subsys-aiframework-demo-sdk.md)
- [KWS Plug-in](subsystems/subsys-aiframework-demo-plugin.md)
- [KWS Configuration File](subsystems/subsys-aiframework-demo-conf.md)
- Data Management - Data Management
- RDB - RDB
- [RDB Overview](subsystems/subsys-data-relational-database-overview.md) - [RDB Overview](subsystems/subsys-data-relational-database-overview.md)
...@@ -547,7 +535,7 @@ ...@@ -547,7 +535,7 @@
- [Development on Application Permission Management](subsystems/subsys-security-rightmanagement.md) - [Development on Application Permission Management](subsystems/subsys-security-rightmanagement.md)
- [Development on IPC Authentication](subsystems/subsys-security-communicationverify.md) - [Development on IPC Authentication](subsystems/subsys-security-communicationverify.md)
- [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md) - [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md)
- [Development on HUKS](subsystems/subsys-security-huks-guide.md)
- Startup - Startup
- [Startup](subsystems/subsys-boot-overview.md) - [Startup](subsystems/subsys-boot-overview.md)
- init Module - init Module
...@@ -561,11 +549,11 @@ ...@@ -561,11 +549,11 @@
- [bootstrap Module](subsystems/subsys-boot-bootstrap.md) - [bootstrap Module](subsystems/subsys-boot-bootstrap.md)
- [FAQs](subsystems/subsys-boot-faqs.md) - [FAQs](subsystems/subsys-boot-faqs.md)
- [Reference](subsystems/subsys-boot-ref.md) - [Reference](subsystems/subsys-boot-ref.md)
- DFX - DFX
- [DFX](subsystems/subsys-dfx-overview.md) - [DFX](subsystems/subsys-dfx-overview.md)
- [HiLog Development](subsystems/subsys-dfx-hilog-rich.md) - [HiLog Development](subsystems/subsys-dfx-hilog-rich.md)
- [HiLog\_Lite Development](subsystems/subsys-dfx-hilog-lite.md) - [HiLog\_Lite Development](subsystems/subsys-dfx-hilog-lite.md)
- [HiTrace Development](subsystems/subsys-dfx-hitrace.md) - [HiTraceChain Development](subsystems/subsys-dfx-hitracechain.md)
- [HiCollie Development](subsystems/subsys-dfx-hicollie.md) - [HiCollie Development](subsystems/subsys-dfx-hicollie.md)
- HiSysEvent Development - HiSysEvent Development
- [HiSysEvent Logging Configuration](subsystems/subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent Logging Configuration](subsystems/subsys-dfx-hisysevent-logging-config.md)
...@@ -592,13 +580,6 @@ ...@@ -592,13 +580,6 @@
- WLAN-connected Products - WLAN-connected Products
- [LED Peripheral Control](guide/device-wlan-led-control.md) - [LED Peripheral Control](guide/device-wlan-led-control.md)
- [Third-Party SDK Integration](guide/device-wlan-sdk.md) - [Third-Party SDK Integration](guide/device-wlan-sdk.md)
- Cameras Without a Screen
- Camera Control
- [Overview](guide/device-iotcamera-control-overview.md)
- Development Guidelines
- [Photographing](guide/device-iotcamera-control-demo-photodevguide.md)
- [Video Recording](guide/device-iotcamera-control-demo-videodevguide.md)
- [Use Case](guide/device-iotcamera-control-example.md)
- Cameras with a Screen - Cameras with a Screen
- Screen and Camera Control - Screen and Camera Control
- [Overview](guide/device-camera-control-overview.md) - [Overview](guide/device-camera-control-overview.md)
...@@ -648,7 +629,3 @@ ...@@ -648,7 +629,3 @@
# AI<a name="EN-US_TOPIC_0000001087226912"></a> # AI
## Introduction<a name="section187321516154516"></a> ## Introduction
The AI subsystem is the part of OpenHarmony that provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins. The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies. The AI subsystem is the part of OpenHarmony that provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins. The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies.
**Figure 1** AI engine framework<a name="fig17296164711526"></a> **Figure 1** AI engine framework<a name="fig17296164711526"></a>
![](figures/ai-engine-framework.png "ai-engine-framework") ![](figures/ai-engine-framework.png "ai-engine-framework")
## Directory Structure<a name="section571610913453"></a> ## Directory Structure
``` ```
/foundation/ai/engine # Home directory of the AI subsystem /foundation/ai/engine # Home directory of the AI subsystem
...@@ -32,7 +32,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI ...@@ -32,7 +32,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
│ │ └── server_executor # Executor of the server module │ │ └── server_executor # Executor of the server module
``` ```
## Constraints<a name="section5748426453"></a> ## Constraints
* **Programming language**: C/C++ * **Programming language**: C/C++
...@@ -40,7 +40,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI ...@@ -40,7 +40,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
* **Others**: The System Ability Manager \(Samgr\) has been started and is running properly. * **Others**: The System Ability Manager \(Samgr\) has been started and is running properly.
## Usage<a name="section6370123616447"></a> ## Usage
1. Compile the AI subsystem. 1. Compile the AI subsystem.
...@@ -406,7 +406,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI ...@@ -406,7 +406,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
``` ```
## Repositories Involved<a name="section10492183517430"></a> ## Repositories Involved
[AI subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ai.md) [AI subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ai.md)
...@@ -420,8 +420,8 @@ Dependency repositories: ...@@ -420,8 +420,8 @@ Dependency repositories:
[startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README.md) [startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README.md)
## Reference<a name="section6808423133718"></a> ## Reference
[AI Engine Framework Development Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-aiframework-guide.md) [AI Framework Development](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md)
# Startup<a name="EN-US_TOPIC_0000001124561621"></a> # Startup
## Introduction<a name="section11660541593"></a> ## Introduction
The startup subsystem is responsible for starting key system processes and services after the kernel is started and before applications are started. The subsystem consists of the following modules: The startup subsystem is responsible for starting key system processes and services after the kernel is started and before applications are started. The subsystem consists of the following modules:
...@@ -8,7 +8,7 @@ The startup subsystem is responsible for starting key system processes and servi ...@@ -8,7 +8,7 @@ The startup subsystem is responsible for starting key system processes and servi
This module can be used on platforms powered by LiteOS Cortex-A or Linux kernel. This module can be used on platforms powered by LiteOS Cortex-A or Linux kernel.
The module starts system service processes from the time the kernel loads the first user-space process to the time the first application is started. In addition to loading key system processes, it needs to configure their permissions during the startup and keep the specified process alive after sub-processes are started. If a key process exits abnormally, the module needs to perform a system restart. For details, see [init Module](../device-dev/subsystems/subsys-boot-init.md). The module starts system service processes from the time the kernel loads the first user-space process to the time the first application is started. In addition to loading key system processes, it needs to configure their permissions during the startup and keep the specified process alive after sub-processes are started. If a key process exits abnormally, the module needs to perform a system restart. For details, see [init Module](../device-dev/subsystems/subsys-boot-init-cfg.md).
- appspawn - appspawn
...@@ -27,58 +27,22 @@ The startup subsystem is responsible for starting key system processes and servi ...@@ -27,58 +27,22 @@ The startup subsystem is responsible for starting key system processes and servi
This module obtains and sets system attributes. This module obtains and sets system attributes.
The module can be used on all platforms. Supported system attributes consist of default, OEM-specified, and custom system attributes. OEM-specified system attributes provide only default values. The specific values need to be adjusted as required. For details, see [syspara Module](../device-dev/subsystems/subsys-boot-syspara.md). The module can be used on all platforms. Supported system attributes consist of default, OEM-specified, and custom system attributes. OEM-specified system attributes provide only default values. The specific values need to be adjusted as required. For details, see [syspara Module](../device-dev/subsystems/subsys-boot-init-sysparam.md).
## Directory Structure<a name="section161941989596"></a> ## Directory Structure
**Table 1** Directory structure of the source code for the startup subsystem **Table 1** Directory structure of the source code for the startup subsystem
<a name="table2977131081412"></a> | Directory | Description | Applicable Platform |
| ------------------------------ | ------------------------------------------------------------ | --------------------------------------------------- |
<table><thead align="left"><tr id="row7977610131417"><th class="cellrowborder" valign="top" width="20.880000000000003%" id="mcps1.2.4.1.1"><p id="p18792459121314"><a name="p18792459121314"></a><a name="p18792459121314"></a>Directory</p> | base/startup/appspawn_lite | appspawn module of the Lite edition for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them. | Platforms using the LiteOS Cortex-A kernel |
</th> | base/startup/appspawn_standard | appspawn module of the Standard version for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them. | Platforms using the Linux kernel |
<th class="cellrowborder" valign="top" width="65.2%" id="mcps1.2.4.1.2"><p id="p77921459191317"><a name="p77921459191317"></a><a name="p77921459191317"></a>Description</p> | base/startup/bootstrap_lite | bootstrap module for starting all services except core system services. | Platforms using the LiteOS Cortex-M kernel |
</th> | base/startup/init_lite | init_lite module for implementing the init process, which is the first user-space process loaded after the kernel is initialized. Upon startup, the process parses the configuration file in **/etc/init.cfg**. Based on the parsing result, the process then starts other key system processes and grants required permissions to them. | Platforms using the LiteOS Cortex-A or Linux kernel |
<th class="cellrowborder" valign="top" width="13.919999999999998%" id="mcps1.2.4.1.3"><p id="p101617019356"><a name="p101617019356"></a><a name="p101617019356"></a>Applicable Platform</p> | base/startup/syspara_lite | syspara module that provides APIs to obtain device information, including the product name, brand name, category name, and manufacturer name. | All platforms |
</th>
</tr>
</thead>
<tbody><tr id="row17977171010144"><td class="cellrowborder" valign="top" width="20.880000000000003%" headers="mcps1.2.4.1.1 "><p id="p2793159171311"><a name="p2793159171311"></a><a name="p2793159171311"></a>base/startup/appspawn_lite</p>
</td>
<td class="cellrowborder" valign="top" width="65.2%" headers="mcps1.2.4.1.2 "><p id="p879375920132"><a name="p879375920132"></a><a name="p879375920132"></a>appspawn module of the Lite edition for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them.</p>
</td>
<td class="cellrowborder" valign="top" width="13.919999999999998%" headers="mcps1.2.4.1.3 ">Platforms using the LiteOS Cortex-A kernel
</td>
</tr>
<tr id="row17977171010144"><td class="cellrowborder" valign="top" width="20.880000000000003%" headers="mcps1.2.4.1.1 "><p id="p2793159171311"><a name="p2793159171311"></a><a name="p2793159171311"></a>base/startup/appspawn_standard</p>
</td>
<td class="cellrowborder" valign="top" width="65.2%" headers="mcps1.2.4.1.2 "><p id="p879375920132"><a name="p879375920132"></a><a name="p879375920132"></a>appspawn module of the Standard version for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them.</p>
</td>
<td class="cellrowborder" valign="top" width="13.919999999999998%" headers="mcps1.2.4.1.3 ">Platforms using the Linux kernel
</td>
</tr>
<tr id="row6978161091412"><td class="cellrowborder" valign="top" width="20.880000000000003%" headers="mcps1.2.4.1.1 "><p id="p37931659101311"><a name="p37931659101311"></a><a name="p37931659101311"></a>base/startup/bootstrap_lite</p>
</td>
<td class="cellrowborder" valign="top" width="65.2%" headers="mcps1.2.4.1.2 "><p id="p6793059171318"><a name="p6793059171318"></a><a name="p6793059171318"></a>bootstrap module for starting all services except core system services.</p>
</td>
<td class="cellrowborder" valign="top" width="13.919999999999998%" headers="mcps1.2.4.1.3 ">Platforms using the LiteOS Cortex-M kernel
</td>
</tr>
<tr id="row6978201031415"><td class="cellrowborder" align="left" valign="top" width="20.880000000000003%" headers="mcps1.2.4.1.1 "><p id="p117935599130"><a name="p117935599130"></a><a name="p117935599130"></a>base/startup/init_lite</p>
</td>
<td class="cellrowborder" valign="top" width="65.2%" headers="mcps1.2.4.1.2 "><p id="p0793185971316"><a name="p0793185971316"></a><a name="p0793185971316"></a>init_lite module for implementing the init process, which is the first user-space process loaded after the kernel is initialized. Upon startup, the process parses the configuration file in **/etc/init.cfg**. Based on the parsing result, the process then starts other key system processes and grants required permissions to them.</p>
</td>
<td class="cellrowborder" valign="top" width="13.919999999999998%" headers="mcps1.2.4.1.3 ">Platforms using the LiteOS Cortex-A or Linux kernel</td>
</tr>
<tr id="row1897841071415"><td class="cellrowborder" valign="top" width="20.880000000000003%" headers="mcps1.2.4.1.1 "><p id="p469782418557"><a name="p469782418557"></a><a name="p469782418557"></a>base/startup/syspara_lite</p>
</td>
<td class="cellrowborder" valign="top" width="65.2%" headers="mcps1.2.4.1.2 "><p id="p15697102412558"><a name="p15697102412558"></a><a name="p15697102412558"></a>syspara module that provides APIs to obtain device information, including the product name, brand name, category name, and manufacturer name.</p>
</td>
<td class="cellrowborder" valign="top" width="13.919999999999998%" headers="mcps1.2.4.1.3 ">All platforms</td>
</tr>
</tbody>
</table>
``` ```
...@@ -111,7 +75,7 @@ base/startup/ ...@@ -111,7 +75,7 @@ base/startup/
└── simulator # Simulator adaptation └── simulator # Simulator adaptation
``` ```
## Repositories Involved<a name="section1371113476307"></a> ## Repositories Involved
[Startup subsystem](../device-dev/subsystems/subsys-boot-overview.md) [Startup subsystem](../device-dev/subsystems/subsys-boot-overview.md)
......
...@@ -77,7 +77,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -77,7 +77,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| -------- | -------- | | -------- | -------- |
| [I4AJEN](https://gitee.com/openharmony/third_party_freetype/issues/I4AJEN) | Fixed the CVE-2020-15999 security vulnerability of the third_party_freetype component.| | [I4AJEN](https://gitee.com/openharmony/third_party_freetype/issues/I4AJEN) | Fixed the CVE-2020-15999 security vulnerability of the third_party_freetype component.|
| [I4AJ6T](https://gitee.com/openharmony/third_party_mbedtls/issues/I4AJ6T) | Fixed the CVE-2020-36475 and CVE-2020-36478 security vulnerabilities of the third_party_mbedtls component.| | [I4AJ6T](https://gitee.com/openharmony/third_party_mbedtls/issues/I4AJ6T) | Fixed the CVE-2020-36475 and CVE-2020-36478 security vulnerabilities of the third_party_mbedtls component.|
| [I4AIYJ](https://gitee.com/openharmony/device_hisilicon_third_party_uboot/issues/I4AIYJ?from=project-issue) | Fixed the CVE-2021-27138 and CVE-2021-27097 security vulnerabilities of the third_party_uboot component.| | I4AIYJ | Fixed the CVE-2021-27138 and CVE-2021-27097 security vulnerabilities of the third_party_uboot component.|
| [I4HUM6](https://gitee.com/openharmony/third_party_lwip/issues/I4HUM6?from=project-issue) | Fixed the CVE-2020-22284 security vulnerability of the third_party_lwip component.| | [I4HUM6](https://gitee.com/openharmony/third_party_lwip/issues/I4HUM6?from=project-issue) | Fixed the CVE-2020-22284 security vulnerability of the third_party_lwip component.|
| I4QTVZ | Fixed the CVE-2021-44732 and CVE-2021-45450 security vulnerabilities of the third_party_mbedtls component.| | I4QTVZ | Fixed the CVE-2021-44732 and CVE-2021-45450 security vulnerabilities of the third_party_mbedtls component.|
| [I46RRM](https://gitee.com/openharmony/third_party_wpa_supplicant/issues/I46RRM?from=project-issue) | Fixed copying of secondary device types for the P2P group client.| | [I46RRM](https://gitee.com/openharmony/third_party_wpa_supplicant/issues/I46RRM?from=project-issue) | Fixed copying of secondary device types for the P2P group client.|
......
...@@ -179,6 +179,6 @@ Table 5 Issues resolved for the standard system ...@@ -179,6 +179,6 @@ Table 5 Issues resolved for the standard system
| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.| In the pressure test, there is a low probability that the log output is abnormal. The log output is normal in the commissioning scenario.| October 30| | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.| In the pressure test, there is a low probability that the log output is abnormal. The log output is normal in the commissioning scenario.| October 30|
| I48YPH | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.| There is a low probability that this issue occurs. If a networking failure occurs, initiate the networking again.| October 30| | I48YPH | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.| There is a low probability that this issue occurs. If a networking failure occurs, initiate the networking again.| October 30|
| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of self-networking between a standard-system device and mobile phone is 97%.| There is a low probability that the networking fails.| October 30| | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of self-networking between a standard-system device and mobile phone is 97%.| There is a low probability that the networking fails.| October 30|
| [I4BXWY](https://gitee.com/openharmony/multimedia_media_standard/issues/I4BXWY) | For Hi3516, noises occur during playback of an audio recording.| This issue occurs only when this development board is used.| October 30| | I4BXWY | For Hi3516, noises occur during playback of an audio recording.| This issue occurs only when this development board is used.| October 30|
| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.| This issue occurs only when this development board is used.| October 30| | I4BXY1 | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.| This issue occurs only when this development board is used.| October 30|
| [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.| There is a low probability that the UID of a child process fails to be set in the XTS pressure test scenario where child processes are repeatedly created.| October 30| | [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.| There is a low probability that the UID of a child process fails to be set in the XTS pressure test scenario where child processes are repeatedly created.| October 30|
...@@ -83,27 +83,27 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -83,27 +83,27 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4BJFU](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BJFU) | An error occurs when the dyload_posix module removes a file.| | [I4BJFU](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BJFU) | An error occurs when the dyload_posix module removes a file.|
| [I42N33](https://gitee.com/openharmony/third_party_mksh/issues/I42N33) | During the integration test, the Ctrl+C operation does not function after the **cat** command is run. A device restart is required.| | [I42N33](https://gitee.com/openharmony/third_party_mksh/issues/I42N33) | During the integration test, the Ctrl+C operation does not function after the **cat** command is run. A device restart is required.|
| [I4C8BO](https://gitee.com/openharmony/docs/issues/I4C8BO?from=project-issue) | The basic functions of the media subsystem (on a mini- or small-system device) are abnormal when Hi3516D V300 or Hi3518E V300 is burnt and configured by following the instructions in the official website.| | [I4C8BO](https://gitee.com/openharmony/docs/issues/I4C8BO?from=project-issue) | The basic functions of the media subsystem (on a mini- or small-system device) are abnormal when Hi3516D V300 or Hi3518E V300 is burnt and configured by following the instructions in the official website.|
| [I4BWKC](https://gitee.com/openharmony/drivers_framework/issues/I4BWKC) | The camera driver on the Hi3516D V300 board does not function properly in the pressure test.| | I4BWKC | The camera driver on the Hi3516D V300 board does not function properly in the pressure test.|
| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | The **ResetDriver** interface of the Hi3516D V300 board fails to be called.| | I4BW0G | The **ResetDriver** interface of the Hi3516D V300 board fails to be called.|
| [I4C7ZK](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4C7ZK) | For Hi3516D V300, the resident memory of the small system exceeds the baseline.| | [I4C7ZK](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4C7ZK) | For Hi3516D V300, the resident memory of the small system exceeds the baseline.|
| [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | For Hi3518E V300, the resident memory exceeds the baseline.| | [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | For Hi3518E V300, the resident memory exceeds the baseline.|
| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the HiLog pressure test, the hilogd restarts unexpectedly, and the hilog commands cannot be used.| | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the HiLog pressure test, the hilogd restarts unexpectedly, and the hilog commands cannot be used.|
| [I4EGMD](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4EGMD) | The serialization and deserialization methods of **Want** are defective.| | I4EGMD | The serialization and deserialization methods of **Want** are defective.|
| [I4CED3](https://gitee.com/openharmony/account_os_account/issues/I4CED3) | The JS API returns both "err" and "data" in one message.| | [I4CED3](https://gitee.com/openharmony/account_os_account/issues/I4CED3) | The JS API returns both "err" and "data" in one message.|
| [I4BXZ1](https://gitee.com/openharmony/app_samples/issues/I4BXZ1) | The **\<Picker>** component does not respond to clicks.| | I4BXZ1 | The **\<Picker>** component does not respond to clicks.|
| [I4CMMH](https://gitee.com/openharmony/ace_ace_engine/issues/I4CMMH) | The display effect of the **\<Toggle>** component is abnormal.| | I4CMMH | The display effect of the **\<Toggle>** component is abnormal.|
| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | The response time of the edit box is inappropriate.| | I4CE7D | The response time of the edit box is inappropriate.|
| [I4HI4C](https://gitee.com/openharmony/ai_engine/issues/I4HI4C) | There is a failed item of the TDD test on a small-system device. This failure is caused by the inappropriate test case comparison time range.| | [I4HI4C](https://gitee.com/openharmony/ai_engine/issues/I4HI4C) | There is a failed item of the TDD test on a small-system device. This failure is caused by the inappropriate test case comparison time range.|
| [I4EUOW](https://gitee.com/openharmony/ai_engine/issues/I4EUOW) | The number of case execution threads is inappropriate.| | [I4EUOW](https://gitee.com/openharmony/ai_engine/issues/I4EUOW) | The number of case execution threads is inappropriate.|
| [I4HTFS](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/issues/I4HTFS) | BMS adaptation for the mini system is not supported.| | I4HTFS | BMS adaptation for the mini system is not supported.|
| [I4C3BE](https://gitee.com/openharmony/communication_dsoftbus/issues/I4C3BE) | During passive Bluetooth Low Energy (BLE) discovery, the Bluetooth advertisement is frequently updated and, when the Bluetooth resources are used up, automatically disabled.| | [I4C3BE](https://gitee.com/openharmony/communication_dsoftbus/issues/I4C3BE) | During passive Bluetooth Low Energy (BLE) discovery, the Bluetooth advertisement is frequently updated and, when the Bluetooth resources are used up, automatically disabled.|
| [I4I7QL](https://gitee.com/openharmony/developtools_packing_tool/issues/I4I7QL) | Packing fails when an ability has two widgets.| | [I4I7QL](https://gitee.com/openharmony/developtools_packing_tool/issues/I4I7QL) | Packing fails when an ability has two widgets.|
| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | There is a possibility that the Wi-Fi **ResetDriver** interface fails to be called.| | I4BW0G | There is a possibility that the Wi-Fi **ResetDriver** interface fails to be called.|
| [I4GBB6](https://gitee.com/openharmony/device_qemu/issues/I4GBB6) | The RISC-V QEMU emulator fails to run.| | [I4GBB6](https://gitee.com/openharmony/device_qemu/issues/I4GBB6) | The RISC-V QEMU emulator fails to run.|
| [I4CE7E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CE7E) | **drivers/mtd/multi_partition/** in the LiteOS-A kernel is implemented by using the driver functions in **device/hisilicon**.| | [I4CE7E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CE7E) | **drivers/mtd/multi_partition/** in the LiteOS-A kernel is implemented by using the driver functions in **device/hisilicon**.|
| [I4JBEH](https://gitee.com/openharmony/drivers_framework/issues/I4JBEH) | Memory leakage occurs when the DMA transmission interface of HDF is repeatedly used.| | I4JBEH | Memory leakage occurs when the DMA transmission interface of HDF is repeatedly used.|
| [I4IGQ0](https://gitee.com/openharmony/drivers_framework/issues/I4IGQ0) | Resources are released after component detection fails.| | I4IGQ0 | Resources are released after component detection fails.|
| [I4JPCG](https://gitee.com/openharmony/drivers_framework/issues/I4JPCG) | The PWM backlight cannot be set to 0.| | I4JPCG | The PWM backlight cannot be set to 0.|
| [I4ERM4](https://gitee.com/openharmony/drivers_peripheral/issues/I4ERM4) | A test case fails to be displayed.| | [I4ERM4](https://gitee.com/openharmony/drivers_peripheral/issues/I4ERM4) | A test case fails to be displayed.|
| [I4CMUY](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4CMUY) | The hdf\_peripheral\_wlan\_test\_performance.bin test suite fails to run.| | [I4CMUY](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4CMUY) | The hdf\_peripheral\_wlan\_test\_performance.bin test suite fails to run.|
| [I4FIP2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FIP2) | The **ioctl** function of the LiteOS_A kernel does not support the **SIOCGIFBRDADDR** option.| | [I4FIP2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FIP2) | The **ioctl** function of the LiteOS_A kernel does not support the **SIOCGIFBRDADDR** option.|
...@@ -118,7 +118,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -118,7 +118,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4C5RW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5RW) | The error indicating that the **OS_TASK_STACK_PROTECT_SIZE** macro is not defined occurs when the MPU is enabled to protect the task stack.| | [I4C5RW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5RW) | The error indicating that the **OS_TASK_STACK_PROTECT_SIZE** macro is not defined occurs when the MPU is enabled to protect the task stack.|
| [I4G4VK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4VK) | Some macros are inappropriate. If they (for example, **inet_addr**) are changed to functions, the lwIP header file is not required for external calling.| | [I4G4VK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4VK) | Some macros are inappropriate. If they (for example, **inet_addr**) are changed to functions, the lwIP header file is not required for external calling.|
| [I4FVGV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FVGV) | The default lwIP configuration of the LiteOS_M kernel is inappropriate.| | [I4FVGV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FVGV) | The default lwIP configuration of the LiteOS_M kernel is inappropriate.|
| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | There is no necessary to start the input method after a 3-second delay.| | I4CE7D | There is no necessary to start the input method after a 3-second delay.|
| [I4CFOO](https://gitee.com/openharmony/multimedia_media_lite/issues/I4CFOO) | After an application running on the Linux system records videos for multiple times, the size of the last recording file is 0 when the system is restarted without exiting the application.| | [I4CFOO](https://gitee.com/openharmony/multimedia_media_lite/issues/I4CFOO) | After an application running on the Linux system records videos for multiple times, the size of the last recording file is 0 when the system is restarted without exiting the application.|
| [I4CLGW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLGW) | The page cache is inappropriate.| | [I4CLGW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLGW) | The page cache is inappropriate.|
| [I4HKQ2](https://gitee.com/openharmony/vendor_hisilicon/issues/I4HKQ2) | The mechanism for the LiteOS running on a mini-system board to obtain the UDID is inappropriate.| | [I4HKQ2](https://gitee.com/openharmony/vendor_hisilicon/issues/I4HKQ2) | The mechanism for the LiteOS running on a mini-system board to obtain the UDID is inappropriate.|
...@@ -132,24 +132,24 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -132,24 +132,24 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4BX4J](https://gitee.com/openharmony/hiviewdfx_hicollie/issues/I4BX4J?from=project-issue) | The Hi3516D V300 board fails to call the **hicollie** interface.| | [I4BX4J](https://gitee.com/openharmony/hiviewdfx_hicollie/issues/I4BX4J?from=project-issue) | The Hi3516D V300 board fails to call the **hicollie** interface.|
| [I4BX1X](https://gitee.com/openharmony/hiviewdfx_hitrace/issues/I4BX1X?from=project-issue) | The Hi3516D V300 board fails to call the **hitrace** interface.| | [I4BX1X](https://gitee.com/openharmony/hiviewdfx_hitrace/issues/I4BX1X?from=project-issue) | The Hi3516D V300 board fails to call the **hitrace** interface.|
| [I4BVUL](https://gitee.com/openharmony/communication_wifi/issues/I4BVUL?from=project-issue) | When access points (APs) are changed, the success rate for networking between standard-system devices and mobile phones is 91%, lower than the expected value (98%).| | [I4BVUL](https://gitee.com/openharmony/communication_wifi/issues/I4BVUL?from=project-issue) | When access points (APs) are changed, the success rate for networking between standard-system devices and mobile phones is 91%, lower than the expected value (98%).|
| [I4BW6E](https://gitee.com/openharmony/security_deviceauth/issues/I4BW6E) | During the test for networking between standard-system devices and mobile phones, when the mobile phone disables and enables the network access repeatedly for around 30 times, the networking fails.| | I4BW6E | During the test for networking between standard-system devices and mobile phones, when the mobile phone disables and enables the network access repeatedly for around 30 times, the networking fails.|
| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | During the test for networking between standard-system devices and mobile phones, when the Wi-Fi switch is turned on and off repeatedly, the networking success rate is 97%, lower than the expected value.| | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | During the test for networking between standard-system devices and mobile phones, when the Wi-Fi switch is turned on and off repeatedly, the networking success rate is 97%, lower than the expected value.|
| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH?from=project-issue) | During the test for discovery and networking performance, 3 out of 110 networking attempts fails.| | I48YPH | During the test for discovery and networking performance, 3 out of 110 networking attempts fails.|
| [I4492M](https://gitee.com/openharmony/communication_dsoftbus/issues/I4492M) | The offline device detection takes about 30s longer than the specifications.| | [I4492M](https://gitee.com/openharmony/communication_dsoftbus/issues/I4492M) | The offline device detection takes about 30s longer than the specifications.|
| [I44W7U](https://gitee.com/openharmony/graphic_standard/issues/I44W7U?from=project-issue) | The child window does not support zooming. As a result, the progress bar is hidden during video playback.| | I44W7U | The child window does not support zooming. As a result, the progress bar is hidden during video playback.|
| [I480Z1](https://gitee.com/openharmony/communication_dsoftbus/issues/I480Z1?from=project-issue) | Softbus_server crashes when executing **socketfuzz**.| | [I480Z1](https://gitee.com/openharmony/communication_dsoftbus/issues/I480Z1?from=project-issue) | Softbus_server crashes when executing **socketfuzz**.|
| [I4BGLS](https://gitee.com/openharmony/security_deviceauth/issues/I4BGLS?from=project-issue) | The key imported by using `import_signed_auth_info_hilink` is used for identifying the HiChain connection. After the key is imported, it is encrypted and stored in the file and is not cleared from the heap after being returned.| | I4BGLS | The key imported by using `import_signed_auth_info_hilink` is used for identifying the HiChain connection. After the key is imported, it is encrypted and stored in the file and is not cleared from the heap after being returned.|
| [I4A10Q](https://gitee.com/openharmony/startup_appspawn/issues/I4A10Q?from=project-issue) | The performance of Hi3516 3.0.0.6 static KPIs deteriorates severely.| | [I4A10Q](https://gitee.com/openharmony/startup_appspawn/issues/I4A10Q?from=project-issue) | The performance of Hi3516 3.0.0.6 static KPIs deteriorates severely.|
| [I4BXYT](https://gitee.com/openharmony/developtools_hdc_standard/issues/I4BXYT) | After device restart, developers must run the **hdc_std kill** command to discover the device again.| | I4BXYT | After device restart, developers must run the **hdc_std kill** command to discover the device again.|
| [I4KUTY](https://gitee.com/openharmony/ace_engine_lite/issues/I4KUTY) | There are invalid return values.| | I4KUTY | There are invalid return values.|
| [I4DMFV](https://gitee.com/openharmony/ark_js_runtime/issues/I4DMFV) | The conversion from UTF-16 to UTF-8 is inappropriate.| | I4DMFV | The conversion from UTF-16 to UTF-8 is inappropriate.|
| [I4HGVM](https://gitee.com/openharmony/communication_dsoftbus/issues/I4HGVM) | The dependency on mbedTLS is missing for the standard system.| | [I4HGVM](https://gitee.com/openharmony/communication_dsoftbus/issues/I4HGVM) | The dependency on mbedTLS is missing for the standard system.|
| [I4DLV2](https://gitee.com/openharmony/drivers_framework/issues/I4DLV2) | An invalid memory access error occurs due to the HidInfo\* type.| | I4DLV2 | An invalid memory access error occurs due to the HidInfo\* type.|
| [I4CIJJ](https://gitee.com/openharmony/third_party_flutter/issues/I4CIJJ) | ACE does not support GPU rendering.| | [I4CIJJ](https://gitee.com/openharmony/third_party_flutter/issues/I4CIJJ) | ACE does not support GPU rendering.|
| [I4G31Z](https://gitee.com/openharmony/third_party_freetype/issues/I4G31Z) | An update for the font engine version from 2.10.1 to 2.10.4 is unavailable.| | [I4G31Z](https://gitee.com/openharmony/third_party_freetype/issues/I4G31Z) | An update for the font engine version from 2.10.1 to 2.10.4 is unavailable.|
| [I4H06M](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4H06M) | An update for the OpenType text shaping engine from 2.6.1 to 2.8.1 is unavailable.| | [I4H06M](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4H06M) | An update for the OpenType text shaping engine from 2.6.1 to 2.8.1 is unavailable.|
| [I4FS7V](https://gitee.com/openharmony/third_party_lwip/issues/I4FS7V) | The **LWIP\_NETCONN\_FULLDUPLEX** macro is not used to control the initialization of **conn-&gt;mbox\_threads\_waiting**.| | [I4FS7V](https://gitee.com/openharmony/third_party_lwip/issues/I4FS7V) | The **LWIP\_NETCONN\_FULLDUPLEX** macro is not used to control the initialization of **conn-&gt;mbox\_threads\_waiting**.|
| [I43KL7](https://gitee.com/openharmony/graphic_standard/issues/I43KL7) | The synthesizer does not support GPU synthesis.| | I43KL7 | The synthesizer does not support GPU synthesis.|
## Known Issues ## Known Issues
...@@ -164,4 +164,4 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -164,4 +164,4 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | The JSON file corresponding to the WeekPluralNumbertest module is incorrectly configured. During case execution, the error message "required device does not exist" is displayed.| The JSON file configuration is incorrect. This issue does not affect functions.| 2022/01/15 | | [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | The JSON file corresponding to the WeekPluralNumbertest module is incorrectly configured. During case execution, the error message "required device does not exist" is displayed.| The JSON file configuration is incorrect. This issue does not affect functions.| 2022/01/15 |
| [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | During the XTS test on the standard system, there are three failed items of the HiCollieCppTest cases in the ActsHiCollieCppTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 | | [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | During the XTS test on the standard system, there are three failed items of the HiCollieCppTest cases in the ActsHiCollieCppTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 |
| [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | During the XTS test on the standard system, there is one failed item for faultloggertest in the ActsFaultLoggerTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 | | [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | During the XTS test on the standard system, there is one failed item for faultloggertest in the ActsFaultLoggerTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 |
| [I4NODO](https://gitee.com/openharmony/device_manager/issues/I4NODO) | During the test for the Hi3516 board running on a standard-system device, the E2E test of the distributed service hopping fails.| The DM component fails to repeatedly create a group. This issue affects the services that use hopping in the same way as that described in the issue details. Other services are not affected.| 2022/01/30 | | I4NODO | During the test for the Hi3516 board running on a standard-system device, the E2E test of the distributed service hopping fails.| The DM component fails to repeatedly create a group. This issue affects the services that use hopping in the same way as that described in the issue details. Other services are not affected.| 2022/01/30 |
...@@ -85,7 +85,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -85,7 +85,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4V2DN](https://gitee.com/openharmony/xts_acts/issues/I4V2DN?from=project-issue) | The execution of two test cases times out during the ActsLwipTest module test.| | [I4V2DN](https://gitee.com/openharmony/xts_acts/issues/I4V2DN?from=project-issue) | The execution of two test cases times out during the ActsLwipTest module test.|
| [I4V3KC](https://gitee.com/openharmony/xts_acts/issues/I4V3KC?from=project-issue) | The test case testPublish0010 fails in the Distributed Scheduler.| | [I4V3KC](https://gitee.com/openharmony/xts_acts/issues/I4V3KC?from=project-issue) | The test case testPublish0010 fails in the Distributed Scheduler.|
| [I4URGA](https://gitee.com/openharmony/applications_sample_camera/issues/I4URGA?from=project-issue) | A blue screen may appear when users search for WLAN signals on the **Settings** page.| | [I4URGA](https://gitee.com/openharmony/applications_sample_camera/issues/I4URGA?from=project-issue) | A blue screen may appear when users search for WLAN signals on the **Settings** page.|
| [I4SDCK](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4SDCK?from=project-issue) | An empty path or garbled characters are returned when users run **GetSrcPath** or **GetDataPath** on the Hi3516 development board of a small-system device.| | I4SDCK | An empty path or garbled characters are returned when users run **GetSrcPath** or **GetDataPath** on the Hi3516 development board of a small-system device.|
| [I4T6KZ](https://gitee.com/openharmony/communication_dsoftbus/issues/I4T6KZ) | The execution of **SendMessage** and **SendData4Data** fails during the transmission test.| | [I4T6KZ](https://gitee.com/openharmony/communication_dsoftbus/issues/I4T6KZ) | The execution of **SendMessage** and **SendData4Data** fails during the transmission test.|
| I4UOUS | Plaintext passwords are printed in the logs of the serial port interface on the Hi3516 development board of a small-system device.| | I4UOUS | Plaintext passwords are printed in the logs of the serial port interface on the Hi3516 development board of a small-system device.|
| [I4OWZO](https://gitee.com/openharmony/third_party_toybox/issues/I4OWZO) | An error message is displayed when the **toybox mv** command is run to move a file in the NFS path.| | [I4OWZO](https://gitee.com/openharmony/third_party_toybox/issues/I4OWZO) | An error message is displayed when the **toybox mv** command is run to move a file in the NFS path.|
...@@ -97,7 +97,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -97,7 +97,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4R4D3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4D3) | The **detach** attribute is not set for the thread created by **pthread_create**. After the thread proactively exits and **OsGetAllTskInfo** is invoked, the related task name contains garbled characters.| | [I4R4D3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4D3) | The **detach** attribute is not set for the thread created by **pthread_create**. After the thread proactively exits and **OsGetAllTskInfo** is invoked, the related task name contains garbled characters.|
| [I4R4A5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4A5) | Compute overflow occurs in the implementation of the **pthread_cond_timedwait** interface.| | [I4R4A5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4A5) | Compute overflow occurs in the implementation of the **pthread_cond_timedwait** interface.|
| [I4QJT4](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4QJT4) | The UartRead test case fails.| | [I4QJT4](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4QJT4) | The UartRead test case fails.|
| [I4U1DM](https://gitee.com/openharmony/distributedschedule_samgr_lite/issues/I4U1DM) | No lock is added when the LFQUE_Pop function is invoked by the QUEUE_Popfunction of samgr, causing potential data competition.| | I4U1DM | No lock is added when the LFQUE_Pop function is invoked by the QUEUE_Popfunction of samgr, causing potential data competition.|
**Table 4** Issues resolved for the standard system **Table 4** Issues resolved for the standard system
...@@ -106,7 +106,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -106,7 +106,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4UJNU](https://gitee.com/openharmony/applications_settings/issues/I4UJNU) | The WLAN password is displayed in plaintext in the hilog when the WLAN is connected.| | [I4UJNU](https://gitee.com/openharmony/applications_settings/issues/I4UJNU) | The WLAN password is displayed in plaintext in the hilog when the WLAN is connected.|
| [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | During the XT test, there is one failed item in the faultloggertest case of the ActsFaultLoggerTest module.| | [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | During the XT test, there is one failed item in the faultloggertest case of the ActsFaultLoggerTest module.|
| [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | During the XTS test, there are three failed items in the HiCollieCppTest case of the ActsHiCollieCppTest module.| | [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | During the XTS test, there are three failed items in the HiCollieCppTest case of the ActsHiCollieCppTest module.|
| [I4PPXV](https://gitee.com/openharmony/appexecfwk_standard/issues/I4PPXV?from=project-issue) | The application icon is missing after a user opens an application, exits the application, and then returns to the home screen.| | I4PPXV | The application icon is missing after a user opens an application, exits the application, and then returns to the home screen.|
| [I4OF9A](https://gitee.com/openharmony/distributeddatamgr_file/issues/I4OF9A?from=project-issue) | The **text** value read by the **file.readText** interface is unstable.| | [I4OF9A](https://gitee.com/openharmony/distributeddatamgr_file/issues/I4OF9A?from=project-issue) | The **text** value read by the **file.readText** interface is unstable.|
| [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | The JSON file corresponding to the WeekPluralNumbertest module is incorrectly configured. When a test case is executed, "required device does not exist" is reported, and the test suite cannot be executed.| | [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | The JSON file corresponding to the WeekPluralNumbertest module is incorrectly configured. When a test case is executed, "required device does not exist" is reported, and the test suite cannot be executed.|
| [I4OUVQ](https://gitee.com/openharmony/xts_tools/issues/I4OUVQ?from=project-issue) | During repeated pressure tests of XTS JS cases, the system stops responding and the test cannot continue.| | [I4OUVQ](https://gitee.com/openharmony/xts_tools/issues/I4OUVQ?from=project-issue) | During repeated pressure tests of XTS JS cases, the system stops responding and the test cannot continue.|
......
...@@ -86,7 +86,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -86,7 +86,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4SM0J](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4SM0J) | The **third_party_harfbuzz** repository uses the CC BY-NC-SA-3.0 license, which restricts the commercial use of the content in the repository.| | [I4SM0J](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4SM0J) | The **third_party_harfbuzz** repository uses the CC BY-NC-SA-3.0 license, which restricts the commercial use of the content in the repository.|
| [I4WPQW](https://gitee.com/openharmony/device_hisilicon_hardware/issues/I4WPQW) | The **libdisplay_layer.so** binary file is not updated in the **device_hisilicon_hardware** repository.| | [I4WPQW](https://gitee.com/openharmony/device_hisilicon_hardware/issues/I4WPQW) | The **libdisplay_layer.so** binary file is not updated in the **device_hisilicon_hardware** repository.|
| [I4WIVF](https://gitee.com/openharmony/third_party_boost/issues/I4WIVF) | Some files in the **third_party_boost** repository are incompatible with open-source protocols.| | [I4WIVF](https://gitee.com/openharmony/third_party_boost/issues/I4WIVF) | Some files in the **third_party_boost** repository are incompatible with open-source protocols.|
| [I4WRWM](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4WRWM) | Some TDD test cases are unavailable in the **aafwk_aafwk_lite** repository.| | I4WRWM | Some TDD test cases are unavailable in the **aafwk_aafwk_lite** repository.|
| [I4VPVY](https://gitee.com/openharmony/applications_sample_camera/issues/I4VPVY) | In the Hi3516D V300 development board running on a mini-system device, a user searches for Wi-Fi in **Settings** and touches the back button twice to return to the home screen. No application can be started from the home screen.| | [I4VPVY](https://gitee.com/openharmony/applications_sample_camera/issues/I4VPVY) | In the Hi3516D V300 development board running on a mini-system device, a user searches for Wi-Fi in **Settings** and touches the back button twice to return to the home screen. No application can be started from the home screen.|
| [I4UTY0](https://gitee.com/openharmony/applications_photos/issues/I4UTY0) | The HP copyright statement exists in the metadata of the **1.jpg** file in **demos**.| | [I4UTY0](https://gitee.com/openharmony/applications_photos/issues/I4UTY0) | The HP copyright statement exists in the metadata of the **1.jpg** file in **demos**.|
| [I4TP6D](https://gitee.com/openharmony/xts_acts/issues/I4TP6D) | The ActsWorkerJSTest test suite newly added for the Hi3516 development board running on a standard-system device cannot be executed properly.| | [I4TP6D](https://gitee.com/openharmony/xts_acts/issues/I4TP6D) | The ActsWorkerJSTest test suite newly added for the Hi3516 development board running on a standard-system device cannot be executed properly.|
...@@ -107,4 +107,4 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -107,4 +107,4 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| [I4YBB0](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YBB0) | No image is generated and the recorded video cannot be played when the system camera is used to take a photo and record a video. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera recording does not function.| 2022/04/01 | | [I4YBB0](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YBB0) | No image is generated and the recorded video cannot be played when the system camera is used to take a photo and record a video. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera recording does not function.| 2022/04/01 |
| [I4YB87](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YB87) | No image is generated when the system camera is used to take a photo. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera photographing does not function.| 2022/04/01 | | [I4YB87](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YB87) | No image is generated when the system camera is used to take a photo. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera photographing does not function.| 2022/04/01 |
| [I4YAGS](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YAGS?from=project-issue) | A blue screen is displayed when the system camera is accessed. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera preview does not function.| 2022/04/01 | | [I4YAGS](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YAGS?from=project-issue) | A blue screen is displayed when the system camera is accessed. This issue occurs only for the Hi3516D V300 development board running on a small-system device (Linux).| Camera preview does not function.| 2022/04/01 |
| [I4WLBU](https://gitee.com/openharmony/developtools_hdc_standard/issues/I4WLBU?from=project-issue) | In the Hi3516D V300 development board running on a standard-system device, the device cannot be found after burning during the ACTS test, and the message "Device not founded or connected" is reported.| The HDC tool causes the ACTS test to report this error occasionally. The error does not affect the actual function.| 2022/04/10 | | I4WLBU | In the Hi3516D V300 development board running on a standard-system device, the device cannot be found after burning during the ACTS test, and the message "Device not founded or connected" is reported.| The HDC tool causes the ACTS test to report this error occasionally. The error does not affect the actual function.| 2022/04/10 |
...@@ -198,9 +198,9 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -198,9 +198,9 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| Issue No.| Description| | Issue No.| Description|
| -------- | -------- | | -------- | -------- |
| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.| | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.|
| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH) | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.| | I48YPH | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.|
| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of automatic networking between a standard-system device and mobile phone is 97%.| | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of automatic networking between a standard-system device and mobile phone is 97%.|
| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.| | I4BXY1 | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.|
| [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.| | [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.|
...@@ -212,7 +212,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -212,7 +212,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| [I4NRS5](https://gitee.com/openharmony/kernel_linux_5.10/issues/I4NRS5) | [Kernel subsystem] A CVE vulnerability exists.| No patch has been released for the Linux kernel. The kernel will be updated after the patch is released in the community.| Depending on the patch release in the community| | [I4NRS5](https://gitee.com/openharmony/kernel_linux_5.10/issues/I4NRS5) | [Kernel subsystem] A CVE vulnerability exists.| No patch has been released for the Linux kernel. The kernel will be updated after the patch is released in the community.| Depending on the patch release in the community|
| [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | [HDF/Camera] The case fails when the RK3568 board runs the camera HDI tests.| The photographing and preview functions are normal. The recording function can be started but cannot be stopped.| 2021/12/31 | | [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | [HDF/Camera] The case fails when the RK3568 board runs the camera HDI tests.| The photographing and preview functions are normal. The recording function can be started but cannot be stopped.| 2021/12/31 |
| [I4OECR](https://gitee.com/openharmony/ark_js_runtime/issues/I4OECR) | An Ark stack exception occurs during XTS running (low probability).| There is a low probability that the Ark stack becomes abnormal during the XTS pressure test. This issue occurs only once in 48 hours. The exception stack is reported only in the log and does not affect the functions.| 2022/01/05| | I4OECR | An Ark stack exception occurs during XTS running (low probability).| There is a low probability that the Ark stack becomes abnormal during the XTS pressure test. This issue occurs only once in 48 hours. The exception stack is reported only in the log and does not affect the functions.| 2022/01/05|
| [I4OBTW](https://gitee.com/openharmony/ability_ability_runtime/issues/I4OBTW) | After all XTS cases are executed and the application is installed, aa start failures occur, affecting the OpenHarmony pipeline stability test.| During the XTS pressure test, when 100 application packages are installed in batches in a short period of time, 2 of them cannot be started. User experience is not affected.| 2022/01/05| | [I4OBTW](https://gitee.com/openharmony/ability_ability_runtime/issues/I4OBTW) | After all XTS cases are executed and the application is installed, aa start failures occur, affecting the OpenHarmony pipeline stability test.| During the XTS pressure test, when 100 application packages are installed in batches in a short period of time, 2 of them cannot be started. User experience is not affected.| 2022/01/05|
| [I4OLHF](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLHF?from=project-issue) | [Ark subsystem] The test process is abnormal due to the com.amsst.amsMissionSnapshotTest process.| This issue occurs occasionally during high-pressure tests.| 2022/01/05| | I4OLHF | [Ark subsystem] The test process is abnormal due to the com.amsst.amsMissionSnapshotTest process.| This issue occurs occasionally during high-pressure tests.| 2022/01/05|
| [I4OLUK](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLUK) | [Ark subsystem] The process stack is abnormal due to the com.ohos.systemui process.| This issue occurs occasionally during high-pressure tests.| 2022/01/05| | I4OLUK | [Ark subsystem] The process stack is abnormal due to the com.ohos.systemui process.| This issue occurs occasionally during high-pressure tests.| 2022/01/05|
...@@ -215,7 +215,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -215,7 +215,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| ArkUI | [Drag](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Drag)| This sample shows the drag operation function.| eTS | | ArkUI | [Drag](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Drag)| This sample shows the drag operation function.| eTS |
| ArkUI | [Animation](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/ArkUIAnimation)| This sample demonstrates the effect of the **AnimatorProperty** and **Explicit Animation**.| eTS | | ArkUI | [Animation](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/ArkUIAnimation)| This sample demonstrates the effect of the **AnimatorProperty** and **Explicit Animation**.| eTS |
| Data management| [Querying the DDM Result Set](https://gitee.com/openharmony/app_samples/tree/master/data/DDMQuery)| This sample shows how to create a query object to query data in a key-value (KV) store and obtain the result set in distributed data management (DDM).| eTS | | Data management| [Querying the DDM Result Set](https://gitee.com/openharmony/app_samples/tree/master/data/DDMQuery)| This sample shows how to create a query object to query data in a key-value (KV) store and obtain the result set in distributed data management (DDM).| eTS |
| Data management| [eTS RDB](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb)| This sample shows how to use a relational database (RDB) in eTS, including adding, deleting, modifying, and querying data.| eTS | | Data management| [eTS RDB](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) | This sample shows how to use a relational database (RDB) in eTS, including adding, deleting, modifying, and querying data.| eTS |
| Common event and notification| [Reminder Agent](https://gitee.com/openharmony/app_samples/tree/master/Notification/AlarmClock)| This sample shows how to use the reminder agent by simulating an alarm clock.| eTS | | Common event and notification| [Reminder Agent](https://gitee.com/openharmony/app_samples/tree/master/Notification/AlarmClock)| This sample shows how to use the reminder agent by simulating an alarm clock.| eTS |
| Common event and notification| [Event notification](https://gitee.com/openharmony/app_samples/tree/master/Notification/Emitter)| This sample shows the in-process event notification. After a user selects an offering and submits an order, the selected offering is displayed in the order list.| eTS | | Common event and notification| [Event notification](https://gitee.com/openharmony/app_samples/tree/master/Notification/Emitter)| This sample shows the in-process event notification. After a user selects an offering and submits an order, the selected offering is displayed in the order list.| eTS |
| Connectivity| [RPC](https://gitee.com/openharmony/app_samples/tree/master/Communication/RPC)| This sample shows the data exchange between the frontend and backend of a device. After the offering and quantity are selected at the frontend, the backend calculates the result and displays it at the frontend.| eTS | | Connectivity| [RPC](https://gitee.com/openharmony/app_samples/tree/master/Communication/RPC)| This sample shows the data exchange between the frontend and backend of a device. After the offering and quantity are selected at the frontend, the backend calculates the result and displays it at the frontend.| eTS |
...@@ -248,10 +248,10 @@ For more information, visit [Samples](https://gitee.com/openharmony/app_samples) ...@@ -248,10 +248,10 @@ For more information, visit [Samples](https://gitee.com/openharmony/app_samples)
| Issue No.| Description| | Issue No.| Description|
| -------- | -------- | | -------- | -------- |
| [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | [HDF/Camera] The case fails when the RK3568 board runs the camera HDI tests.| | [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | [HDF/Camera] The case fails when the RK3568 board runs the camera HDI tests.|
| [I4OECR](https://gitee.com/openharmony/ark_js_runtime/issues/I4OECR) | An Ark stack exception occurs during XTS running (low probability).| | I4OECR | An Ark stack exception occurs during XTS running (low probability).|
| [I4OBTW](https://gitee.com/openharmony/ability_ability_runtime/issues/I4OBTW) | After all XTS cases are executed and the application is installed, aa start failures occur, affecting the pipeline stability test.| | [I4OBTW](https://gitee.com/openharmony/ability_ability_runtime/issues/I4OBTW) | After all XTS cases are executed and the application is installed, aa start failures occur, affecting the pipeline stability test.|
| [I4OLHF](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLHF?from=project-issue) | [ArkUI subsystem] The test process is abnormal due to the com.amsst.amsMissionSnapshotTest process.| | I4OLHF | [ArkUI subsystem] The test process is abnormal due to the com.amsst.amsMissionSnapshotTest process.|
| [I4OLUK](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLUK) | [ArkUI subsystem] The process stack is abnormal due to the com.ohos.systemui process.| | I4OLUK | [ArkUI subsystem] The process stack is abnormal due to the com.ohos.systemui process.|
## Known Issues ## Known Issues
......
...@@ -151,7 +151,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op ...@@ -151,7 +151,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op
| Issue No. | Description | | Issue No. | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [I4UUFR](https://gitee.com/openharmony/third_party_e2fsprogs/issues/I4UUFR) | Local image compilation and build may fail for the Hi3516 development board. | | [I4UUFR](https://gitee.com/openharmony/third_party_e2fsprogs/issues/I4UUFR) | Local image compilation and build may fail for the Hi3516 development board. |
| [I4WDD3](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4WDD3) | [RK3568] A recorded video cannot be viewed. | | I4WDD3 | [RK3568] A recorded video cannot be viewed. |
| [I50EBB](https://gitee.com/openharmony/docs/issues/I50EBB) | [Hi3516 burning] Images of the Hi3516 development board on a standard-system device cannot be burnt by using DevEco Device Tool. | | [I50EBB](https://gitee.com/openharmony/docs/issues/I50EBB) | [Hi3516 burning] Images of the Hi3516 development board on a standard-system device cannot be burnt by using DevEco Device Tool. |
......
...@@ -58,6 +58,8 @@ onBundleAdded(bundleName: string): void ...@@ -58,6 +58,8 @@ onBundleAdded(bundleName: string): void
**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager **系统能力**:SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -82,6 +84,8 @@ onBundleRemoved(bundleName: string): void ...@@ -82,6 +84,8 @@ onBundleRemoved(bundleName: string): void
**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager **系统能力**:SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -11,7 +11,7 @@ GesturePath表示手势路径信息。 ...@@ -11,7 +11,7 @@ GesturePath表示手势路径信息。
## 导入模块 ## 导入模块
```ts ```ts
import GesturePath from "@ohos.accessibility.GesturePath"; import GesturePath from '@ohos.accessibility.GesturePath';
``` ```
## GesturePath ## GesturePath
...@@ -43,7 +43,7 @@ constructor(durationTime: number); ...@@ -43,7 +43,7 @@ constructor(durationTime: number);
**示例:** **示例:**
```typescript ```ts
let durationTime = 20; let durationTime = 20;
let gesturePath = new GesturePath(durationTime); let gesturePath = new GesturePath(durationTime);
``` ```
...@@ -11,7 +11,7 @@ GesturePoint表示手势触摸点。 ...@@ -11,7 +11,7 @@ GesturePoint表示手势触摸点。
## 导入模块 ## 导入模块
```ts ```ts
import GesturePoint from "@ohos.accessibility.GesturePoint"; import GesturePoint from '@ohos.accessibility.GesturePoint';
``` ```
## GesturePoint ## GesturePoint
...@@ -44,7 +44,7 @@ constructor(positionX: number, positionY: number); ...@@ -44,7 +44,7 @@ constructor(positionX: number, positionY: number);
**示例:** **示例:**
```typescript ```ts
let positionX = 1; let positionX = 1;
let positionY = 2; let positionY = 2;
let gesturePoint = new GesturePoint(positionX, positionY); let gesturePoint = new GesturePoint(positionX, positionY);
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
## 导入模块 ## 导入模块
```typescript ```ts
import config from "@ohos.accessibility.config"; import config from '@ohos.accessibility.config';
``` ```
## 属性 ## 属性
...@@ -27,171 +27,243 @@ import config from "@ohos.accessibility.config"; ...@@ -27,171 +27,243 @@ import config from "@ohos.accessibility.config";
| mouseKey | [Config](#config)\<boolean>| 是 | 是 | 表示鼠标键功能启用状态。 | | mouseKey | [Config](#config)\<boolean>| 是 | 是 | 表示鼠标键功能启用状态。 |
| mouseAutoClick | [Config](#config)\<number>| 是 | 是 | 表示鼠标自动点击功能启用状态。取值 0~5000,单位为毫秒。 | | mouseAutoClick | [Config](#config)\<number>| 是 | 是 | 表示鼠标自动点击功能启用状态。取值 0~5000,单位为毫秒。 |
| shortkey | [Config](#config)\<boolean>| 是 | 是 | 表示辅助扩展快捷键功能启用状态。 | | shortkey | [Config](#config)\<boolean>| 是 | 是 | 表示辅助扩展快捷键功能启用状态。 |
| shortkeyTarget | [Config](#config)\<string>| 是 | 是 | 表示辅助扩展快捷键的目标配置。取值为辅助应用的名称,格式为:"bundleName/abilityName"。 | | shortkeyTarget | [Config](#config)\<string>| 是 | 是 | 表示辅助扩展快捷键的目标配置。取值为辅助应用的名称,格式为:'bundleName/abilityName'。 |
| captions | [Config](#config)\<boolean>| 是 | 是 | 表示辅助字幕功能启用状态。 | | captions | [Config](#config)\<boolean>| 是 | 是 | 表示辅助字幕功能启用状态。 |
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](./js-apis-accessibility.md#captionsstyle8)>| 是 | 是 | 表示辅助字幕的配置。 | | captionsStyle | [Config](#config)\<[CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| 是 | 是 | 表示辅助字幕的配置。 |
## enableAbility ## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;): Promise&lt;void&gt;; enableAbility(name: string, capability: Array&lt;accessibility.Capability&gt;): Promise&lt;void&gt;;
启用辅助扩展。 启用辅助扩展,使用Promise异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 |
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;) | 是 | 辅助应用的能力属性。 | | capability | Array&lt;[accessibility.Capability](js-apis-accessibility.md#capability)&gt;) | 是 | 辅助应用的能力属性。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise实例,用于返回方法执行结果。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300001 | Invalid bundle name or ability name. |
| 9300002 | Target ability already enabled. |
**示例:** **示例:**
```typescript ```ts
config.enableAbility("com.ohos.example/axExtension", ['retrieve']) let name = 'com.ohos.example/axExtension';
.then(() => { let capability = ['retrieve'];
console.info('enable succeed'); try {
}).catch((error) => { config.enableAbility(name, capability).then(() => {
console.error('enable failed'); console.info('enable ability succeed');
}).catch((err) => {
console.error('failed to enable ability, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to enable ability, because ' + JSON.stringify(exception));
};
``` ```
## enableAbility ## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;, callback: AsyncCallback&lt;void&gt;): void; enableAbility(name: string, capability: Array&lt;accessibility.Capability&gt;, callback: AsyncCallback&lt;void&gt;): void;
启用辅助扩展。 启用辅助扩展,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 |
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt; | 是 | 辅助应用的能力属性。 | | capability | Array&lt;[accessibility.Capability](js-apis-accessibility.md#capability)&gt; | 是 | 辅助应用的能力属性。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回方法执行结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300001 | Invalid bundle name or ability name. |
| 9300002 | Target ability already enabled. |
**示例:** **示例:**
```typescript ```ts
config.enableAbility("com.ohos.example/axExtension", ['retrieve'], (err, data) => { let name = 'com.ohos.example/axExtension';
let capability = ['retrieve'];
try {
config.enableAbility(name, capability, (err, data) => {
if (err) { if (err) {
console.error('enable failed'); console.error('failed to enable ability, because ' + JSON.stringify(err));
return; return;
} }
console.info('enable succeed'); console.info('enable ability succeed');
}) });
``` } catch (exception) {
console.error('failed to enable ability, because ' + JSON.stringify(exception));
};
```
## disableAbility ## disableAbility
disableAbility(name: string): Promise&lt;void&gt;; disableAbility(name: string): Promise&lt;void&gt;;
关闭辅助扩展。 关闭辅助扩展,使用Promise异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise实例,用于返回方法执行结果。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300001 | Invalid bundle name or ability name. |
**示例:** **示例:**
```typescript ```ts
config.disableAbility("com.ohos.example/axExtension") let name = 'com.ohos.example/axExtension';
.then(() => { try {
console.info('disable succeed'); config.enableAbility(name).then(() => {
}).catch((error) => { console.info('disable ability succeed');
console.error('disable failed'); }).catch((err) => {
console.error('failed to disable ability, because ' + JSON.stringify(err));
}); });
``` } catch (exception) {
console.error('failed to disable ability, because ' + JSON.stringify(exception));
};
```
## disableAbility ## disableAbility
disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void; disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void;
关闭辅助扩展。 关闭辅助扩展,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回方法执行结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300001 | Invalid bundle name or ability name. |
**示例:** **示例:**
```typescript ```ts
config.disableAbility("com.ohos.example/axExtension", (err, data) => { let name = 'com.ohos.example/axExtension';
try {
config.disableAbility(name, (err, data) => {
if (err) { if (err) {
console.error('disable failed'); console.error('failed to enable ability, because ' + JSON.stringify(err));
return; return;
} }
console.info('disable succeed'); console.info('disable succeed');
}) });
``` } catch (exception) {
console.error('failed to enable ability, because ' + JSON.stringify(exception));
};
```
## on('enableAbilityListsStateChanged') ## on('enabledAccessibilityExtensionListChange')
on(type: 'enableAbilityListsStateChanged', callback: Callback&lt;void&gt;): void; on(type: 'enabledAccessibilityExtensionListChange', callback: Callback&lt;void&gt;): void;
添加启用的辅助扩展的列表变化监听。 添加启用的辅助扩展的列表变化监听,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | 是 | 参数固定为enableAbilityListsStateChanged,监听启用的辅助扩展的列表变化。 | | type | string | 是 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 |
| callback | Callback&lt;void&gt; | 是 | 回调函数,在启用的辅助扩展的列表变化时通过此函数进行通知。 | | callback | Callback&lt;void&gt; | 是 | 回调函数,在启用的辅助扩展的列表变化时通过此函数进行通知。 |
**示例:** **示例:**
```typescript ```ts
config.on('enableAbilityListsStateChanged',() => { try {
console.info('ax extension ability enable list changed'); config.on('enabledAccessibilityExtensionListChange', () => {
console.info('subscribe enabled accessibility extension list change state success');
}).catch((err) => {
console.error('failed to subscribe enabled accessibility extension list change state, because ' +
JSON.stringify(err));
}); });
``` } catch (exception) {
console.error('failed to subscribe enabled accessibility extension list change state, because ' +
JSON.stringify(exception));
};
```
## off('enableAbilityListsStateChanged') ## off('enabledAccessibilityExtensionListChange')
off(type: 'enableAbilityListsStateChanged', callback?: Callback&lt;void&gt;): void; off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback&lt;void&gt;): void;
取消启用的辅助扩展的列表变化监听。 取消启用的辅助扩展的列表变化监听,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | 否 | 参数固定为enableAbilityListsStateChanged,监听启用的辅助扩展的列表变化。 | | type | string | 否 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 |
| callback | Callback&lt;void&gt; | 否 | 要取消的监听回调函数。 | | callback | Callback&lt;void&gt; | 否 | 要取消的监听回调函数。 |
**示例:** **示例:**
```typescript ```ts
config.off('enableAbilityListsStateChanged'); try {
``` config.off('enabledAccessibilityExtensionListChange', () => {
console.info('unSubscribe enabled accessibility extension list change state success');
}).catch((err) => {
console.error('failed to unSubscribe enabled accessibility extension list change state, because ' +
JSON.stringify(err));
});
} catch (exception) {
console.error('failed to unSubscribe enabled accessibility extension list change state, because ' +
JSON.stringify(exception));
};
```
## Config ## Config
...@@ -201,152 +273,178 @@ off(type: 'enableAbilityListsStateChanged', callback?: Callback&lt;void&gt;): vo ...@@ -201,152 +273,178 @@ off(type: 'enableAbilityListsStateChanged', callback?: Callback&lt;void&gt;): vo
set(value: T): Promise&lt;void&gt;; set(value: T): Promise&lt;void&gt;;
设置属性。 设置属性,使用Promise异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | 是 | 设置的属性值。 | | value | T | 是 | 设置的属性值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise实例,用于返回方法执行结果。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.set(true) let value = true;
.then(() => { try {
console.info('highContrastText set succeed'); config.highContrastText.set(value).then(() => {
}).catch((error) => { console.info('set highContrastText succeed');
console.error('highContrastText set failed'); }).catch((err) => {
console.error('failed to set highContrastText, because ' + JSON.stringify(err));
}); });
``` } catch (exception) {
console.error('failed to set config, because ' + JSON.stringify(exception));
};
```
### set ### set
set(value: T, callback: AsyncCallback&lt;void&gt;): void; set(value: T, callback: AsyncCallback&lt;void&gt;): void;
设置属性。 设置属性,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | 是 | 设置的属性值。 | | value | T | 是 | 设置的属性值。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回方法执行结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.set(true, (err, data) => { let value = true;
try {
config.highContrastText.set(value, (err, data) => {
if (err) { if (err) {
console.error('highContrastText set failed'); console.error('failed to set highContrastText, because ' + JSON.stringify(err));
return; return;
} }
console.info('highContrastText set succeed'); console.info('set highContrastText succeed');
}) });
``` } catch (exception) {
console.error('failed to set config, because ' + JSON.stringify(exception));
};
```
### get ### get
get(): Promise&lt;T&gt;; get(): Promise&lt;T&gt;;
获取属性。 获取属性,使用Promise异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;T&gt; | Promise实例,用于返回属性值。 | | Promise&lt;T&gt; | Promise对象,返回对应属性值。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.get() let value;
.then((value) => { config.highContrastText.get().then((data) => {
console.info('highContrastText get succeed'); value = data;
}).catch((error) => { console.info('get highContrastText success');
console.error('highContrastText get failed'); }).catch((err) => {
}); console.error('failed to get highContrastText, because ' + JSON.stringify(err));
``` });
```
### get ### get
get(callback: AsyncCallback&lt;T&gt;): void; get(callback: AsyncCallback&lt;T&gt;): void;
获取属性。 获取属性,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回属性值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回属性值。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.get((err, data) => { let value;
config.highContrastText.get((err, data) => {
if (err) { if (err) {
console.error('highContrastText get failed'); console.error('failed to get highContrastText, because ' + JSON.stringify(err));
return; return;
} }
console.info('highContrastText get succeed'); value = data;
}) console.info('get highContrastText success');
``` });
```
### on ### on
on(callback: Callback&lt;T&gt;): void; on(callback: Callback&lt;T&gt;): void;
添加属性变化监听。 添加属性变化监听,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | 是 | 回调函数,在属性变化时通过此函数进行通知。 | | callback | Callback&lt;T&gt; | 是 | 回调函数,在属性变化时通过此函数进行通知。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.on(() => { try {
console.info('highContrastText changed'); config.highContrastText.on((err, data) => {
if (err) {
console.error('failed subscribe highContrastText, because ' + JSON.stringify(err));
return;
}
console.info('subscribe highContrastText success');
}); });
``` } catch (exception) {
console.error('failed subscribe highContrastText, because ' + JSON.stringify(exception));
}
```
### off ### off
off(callback?: Callback&lt;T&gt;): void; off(callback?: Callback&lt;T&gt;): void;
取消属性变化监听。 取消属性变化监听,使用callback异步回调
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | 否 | 要取消的监听回调函数。 | | callback | Callback&lt;T&gt; | 否 | 要取消的监听回调函数。 |
**示例:** **示例:**
```typescript ```ts
config.highContrastText.off(); config.highContrastText.off((err, data) => {
``` if (err) {
console.error('failed unSubscribe highContrastText, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe highContrastText success');
});
```
## DaltonizationColorFilter ## DaltonizationColorFilter
......
...@@ -11,14 +11,15 @@ AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境, ...@@ -11,14 +11,15 @@ AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,
## 使用说明 ## 使用说明
在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取。 在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取AccessibilityExtensionContex的实例
```js ```js
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'
let axContext;
class MainAbility extends AccessibilityExtensionAbility { class MainAbility extends AccessibilityExtensionAbility {
onConnect(): void { onConnect(): void {
console.log('AxExtensionAbility onConnect'); console.log('AxExtensionAbility onConnect');
let axContext = this.context; axContext = this.context;
} }
} }
``` ```
...@@ -97,11 +98,15 @@ setTargetBundleName(targetNames: Array\<string>): Promise\<void>; ...@@ -97,11 +98,15 @@ setTargetBundleName(targetNames: Array\<string>): Promise\<void>;
```ts ```ts
let targetNames = ['com.ohos.xyz']; let targetNames = ['com.ohos.xyz'];
this.context.setTargetBundleName().then(() => { try {
axContext.setTargetBundleName(targetNames).then(() => {
console.info('set target bundle names success'); console.info('set target bundle names success');
}).catch((err) => { }).catch((err) => {
console.error('failed to set target bundle names because ' + JSON.stringify(err)); console.error('failed to set target bundle names, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to set target bundle names, because ' + JSON.stringify(exception));
};
``` ```
## AccessibilityExtensionContext.setTargetBundleName ## AccessibilityExtensionContext.setTargetBundleName
...@@ -123,13 +128,17 @@ setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>) ...@@ -123,13 +128,17 @@ setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>)
```ts ```ts
let targetNames = ['com.ohos.xyz']; let targetNames = ['com.ohos.xyz'];
this.context.setTargetBundleName().then((err, data) => { try {
axContext.setTargetBundleName(targetNames, (err, data) => {
if (err) { if (err) {
console.error('failed to set target bundle names because ' + JSON.stringify(err)); console.error('failed to set target bundle names, because ' + JSON.stringify(err));
return; return;
} }
console.info('set target bundle names success'); console.info('set target bundle names success');
}); });
} catch (exception) {
console.error('failed to set target bundle names, because ' + JSON.stringify(exception));
};
``` ```
## AccessibilityExtensionContext.getFocusElement ## AccessibilityExtensionContext.getFocusElement
...@@ -152,16 +161,28 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>; ...@@ -152,16 +161,28 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;
| ----------------------------------- | ---------------------- | | ----------------------------------- | ---------------------- |
| Promise&lt;AccessibilityElement&gt; | Promise对象,返回当前对应的焦点元素。 | | Promise&lt;AccessibilityElement&gt; | Promise对象,返回当前对应的焦点元素。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let focusElement; let focusElement;
this.context.getFocusElement().then((data) => { try {
axContext.getFocusElement().then((data) => {
focusElement = data; focusElement = data;
console.log('get focus element success'); console.log('get focus element success');
}).catch((err) => { }).catch((err) => {
console.error('failed to get focus element because ' + JSON.stringify(err)); console.error('failed to get focus element, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to get focus element, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getFocusElement ## AccessibilityExtensionContext.getFocusElement
...@@ -178,18 +199,29 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void; ...@@ -178,18 +199,29 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回当前对应的焦点元素。 | | callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回当前对应的焦点元素。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let focusElement; try {
this.context.getFocusElement().then((err, data) => { axContext.getFocusElement((err, data) => {
if (err) { if (err) {
console.error('failed to get focus element because ' + JSON.stringify(err)); console.error('failed to get focus element, because ' + JSON.stringify(err));
return; return;
} }
focusElement = data; focusElement = data;
console.info('get focus element success'); console.info('get focus element success');
}); });
} catch (exception) {
console.error('failed to get focus element, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getFocusElement ## AccessibilityExtensionContext.getFocusElement
...@@ -210,15 +242,18 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib ...@@ -210,15 +242,18 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib
**示例:** **示例:**
```ts ```ts
let isAccessibilityFocus = true; try {
this.context.getFocusElement(isAccessibilityFocus).then((err, data) => { axContext.getFocusElement(isAccessibilityFocus, (err, data) => {
if (err) { if (err) {
console.error('failed to get focus element because ' + JSON.stringify(err)); console.error('failed to get focus element, because ' + JSON.stringify(err));
return; return;
} }
focusElement = data; focusElement = data;
console.info('get focus element success'); console.info('get focus element success');
}); });
} catch (exception) {
console.error('failed to get focus element, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindowRootElement ## AccessibilityExtensionContext.getWindowRootElement
...@@ -240,16 +275,28 @@ getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>; ...@@ -240,16 +275,28 @@ getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>;
| ----------------------------------- | ---------------------- | | ----------------------------------- | ---------------------- |
| Promise&lt;AccessibilityElement&gt; | Promise对象,返回指定屏幕的所有窗口。 | | Promise&lt;AccessibilityElement&gt; | Promise对象,返回指定屏幕的所有窗口。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let rootElement; let rootElement;
this.context.getWindowRootElement().then((data) => { try {
axContext.getWindowRootElement().then((data) => {
rootElement = data; rootElement = data;
console.log('get root element of the window success'); console.log('get root element of the window success');
}).catch((err) => { }).catch((err) => {
console.error('failed to get root element of the window because ' + JSON.stringify(err)); console.error('failed to get root element of the window, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to get root element of the window, ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindowRootElement ## AccessibilityExtensionContext.getWindowRootElement
...@@ -266,18 +313,29 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void; ...@@ -266,18 +313,29 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回指定窗口的根节点元素。 | | callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回指定窗口的根节点元素。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let rootElement; try {
this.context.getWindowRootElement().then((err, data) => { axContext.getWindowRootElement((err, data) => {
if (err) { if (err) {
console.error('failed to get root element of the window because ' + JSON.stringify(err)); console.error('failed to get root element of the window, because ' + JSON.stringify(err));
return; return;
} }
rootElement = data; rootElement = data;
console.info('get root element of the window success'); console.info('get root element of the window success');
}); });
} catch (exception) {
console.error('failed to get root element of the window, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindowRootElement ## AccessibilityExtensionContext.getWindowRootElement
...@@ -295,19 +353,29 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityEle ...@@ -295,19 +353,29 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityEle
| windowId | number | 是 | 指定窗口的编号,未指定则从当前活跃窗口获取。 | | windowId | number | 是 | 指定窗口的编号,未指定则从当前活跃窗口获取。 |
| callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回指定窗口的根节点元素。 | | callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回指定窗口的根节点元素。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let displayId = 10; try {
let rootElement; axContext.getWindowRootElement(windowId, (err, data) => {
this.context.getWindowRootElement(displayId).then((err, data) => {
if (err) { if (err) {
console.error('failed to get root element of the window because ' + JSON.stringify(err)); console.error('failed to get root element of the window, because ' + JSON.stringify(err));
return; return;
} }
rootElement = data; rootElement = data;
console.info('get root element of the window success'); console.info('get root element of the window success');
}); });
} catch (exception) {
console.error('failed to get root element of the window, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindows ## AccessibilityExtensionContext.getWindows
...@@ -330,16 +398,28 @@ getWindows(displayId?: number): Promise\<Array\<AccessibilityElement>>; ...@@ -330,16 +398,28 @@ getWindows(displayId?: number): Promise\<Array\<AccessibilityElement>>;
| ----------------------------------- | ---------------------- | | ----------------------------------- | ---------------------- |
| Promise&lt;Array&lt;AccessibilityElement&gt;&gt; | Promise对象,返回指定屏幕的所有窗口。 | | Promise&lt;Array&lt;AccessibilityElement&gt;&gt; | Promise对象,返回指定屏幕的所有窗口。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let windows; let windows;
this.context.getWindows().then((data) => { try {
axContext.getWindows().then((data) => {
windows = data; windows = data;
console.log('get windows success'); console.log('get windows success');
}).catch((err) => { }).catch((err) => {
console.error('failed to get windows because ' + JSON.stringify(err)); console.error('failed to get windows, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to get windows, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindows ## AccessibilityExtensionContext.getWindows
...@@ -356,18 +436,30 @@ getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void; ...@@ -356,18 +436,30 @@ getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;AccessibilityElement&gt;&gt; | 是 | 回调函数,返回指定屏幕的所有窗口。 | | callback | AsyncCallback&lt;Array&lt;AccessibilityElement&gt;&gt; | 是 | 回调函数,返回指定屏幕的所有窗口。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let windows; let windows;
this.context.getWindows().then((err, data) => { try {
axContext.getWindows((err, data) => {
if (err) { if (err) {
console.error('failed to get windows because ' + JSON.stringify(err)); console.error('failed to get windows, because ' + JSON.stringify(err));
return; return;
} }
windows = data; windows = data;
console.info('get windows success'); console.info('get windows success');
}); });
} catch (exception) {
console.error('failed to get windows, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.getWindows ## AccessibilityExtensionContext.getWindows
...@@ -385,19 +477,31 @@ getWindows(displayId: number, callback: AsyncCallback\<Array\<AccessibilityEleme ...@@ -385,19 +477,31 @@ getWindows(displayId: number, callback: AsyncCallback\<Array\<AccessibilityEleme
| displayId | number | 是 | 指定的屏幕编号,未指定则从默认主屏幕获取。 | | displayId | number | 是 | 指定的屏幕编号,未指定则从默认主屏幕获取。 |
| callback | AsyncCallback&lt;Array&lt;AccessibilityElement&gt;&gt; | 是 | 回调函数,返回指定屏幕的所有窗口。 | | callback | AsyncCallback&lt;Array&lt;AccessibilityElement&gt;&gt; | 是 | 回调函数,返回指定屏幕的所有窗口。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
let displayId = 10;
let windows; let windows;
this.context.getWindows(displayId).then((err, data) => { let displayId = 10;
try {
axContext.getWindows(displayId, (err, data) => {
if (err) { if (err) {
console.error('failed to get windows because ' + JSON.stringify(err)); console.error('failed to get windows, because ' + JSON.stringify(err));
return; return;
} }
windows = data; windows = data;
console.info('get windows success'); console.info('get windows success');
}); });
} catch (exception) {
console.error('failed to get windows, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.injectGesture ## AccessibilityExtensionContext.injectGesture
...@@ -420,20 +524,32 @@ injectGesture(gesturePath: GesturePath): Promise\<void>; ...@@ -420,20 +524,32 @@ injectGesture(gesturePath: GesturePath): Promise\<void>;
| ----------------------------------- | ---------------------- | | ----------------------------------- | ---------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
import { GesturePath } from "../@ohos.accessibility.GesturePath"; import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100); let gesturePath = new GesturePath(100);
for (let i = 0; i < 10; i++) { try {
let gesturePoint = new GesturePosition(100, i * 200); for (let i = 0; i < 10; i++) {
gesturePath.positions.push(gesturePoint); let gesturePoint = new GesturePoint(100, i * 200);
} gesturePath.points.push(gesturePoint);
this.context.gestureInject(gesturePath, () => { }
axContext.injectGesture(gesturePath).then(() => {
console.info('inject gesture success'); console.info('inject gesture success');
}).catch((err) => { }).catch((err) => {
console.error('failed to inject gesture because ' + JSON.stringify(err)); console.error('failed to inject gesture, because ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('failed to inject gesture, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityExtensionContext.injectGesture ## AccessibilityExtensionContext.injectGesture
...@@ -450,25 +566,38 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void ...@@ -450,25 +566,38 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | | gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,表示注入手势执行结果的回调。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,表示注入手势执行结果的回调。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100); let gesturePath = new GesturePath(100);
for (let i = 0; i < 10; i++) { try {
let gesturePoint = new GesturePosition(100, i * 200); for (let i = 0; i < 10; i++) {
gesturePath.positions.push(gesturePoint); let gesturePoint = new GesturePoint(100, i * 200);
} gesturePath.points.push(gesturePoint);
this.context.gestureInject(gesturePath, (err, data) => { }
axContext.injectGesture(gesturePath, (err, data) => {
if (err) { if (err) {
console.error('failed to inject gesture because ' + JSON.stringify(err)); console.error('failed to inject gesture, because ' + JSON.stringify(err));
return; return;
} }
console.info('inject gesture success'); console.info('inject gesture success');
}); });
} catch (exception) {
console.error('failed to inject gesture, because ' + JSON.stringify(exception));
}
``` ```
## AccessibilityElement<sup>9</sup> ## AccessibilityElement<sup>9+</sup>
无障碍节点元素。 无障碍节点元素, 在调用AccessibilityElement的方法前,需要先通过[AccessibilityExtensionContext.getFocusElement()](#accessibilityextensioncontextgetfocuselement)或者[AccessibilityExtensionContext.getWindowRootElement()](#accessibilityextensioncontextgetwindowrootelement)获取AccessibilityElement实例
**系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core
...@@ -489,18 +618,14 @@ attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>; ...@@ -489,18 +618,14 @@ attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let attributeNames; let attributeNames;
try { rootElement.attributeNames().then((data) => {
accessibilityElement.attributeNames().then((data) => {
console.log('get attribute names success'); console.log('get attribute names success');
attributeNames = data; attributeNames = data;
}).catch((err) => { }).catch((err) => {
console.log('get attribute names err: ' + JSON.stringify(err)); console.log('failed to get attribute names, because ' + JSON.stringify(err));
}); });
} catch (e) {
console.log('An unexpected error occurred. Error:' + e);
}
``` ```
## attributeNames ## attributeNames
...@@ -519,20 +644,16 @@ attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\ ...@@ -519,20 +644,16 @@ attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let attributeNames; let attributeNames;
try { rootElement.attributeNames((err, data) => {
accessibilityElement.attributeNames().then((err, data) => {
if (err) { if (err) {
console.error('failed to get attribute names because ' + JSON.stringify(err)); console.error('failed to get attribute names, because ' + JSON.stringify(err));
return; return;
} }
attributeNames = data; attributeNames = data;
console.info('get attribute names success'); console.info('get attribute names success');
}); });
} catch (e) {
console.log('An unexpected error occurred. Error:' + e);
}
``` ```
## AccessibilityElement.attributeValue ## AccessibilityElement.attributeValue
...@@ -554,21 +675,27 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi ...@@ -554,21 +675,27 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi
| ---------------------------------------- | ------------------------ | | ---------------------------------------- | ------------------------ |
| Promise&lt;ElementAttributeValues[T]&gt; | Promise对象,返回根据节点属性名称获取的属性值。 | | Promise&lt;ElementAttributeValues[T]&gt; | Promise对象,返回根据节点属性名称获取的属性值。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300004 | This property does not exist. |
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let attributeName = 'name';
let attributeValue;
try { try {
let attributeName = 'name'; rootElement.attributeValue(attributeName).then((data) => {
accessibilityElement.attributeValue(attributeName).then((data) => {
console.log('get attribute value by name success'); console.log('get attribute value by name success');
attribtueValue = data; attribtueValue = data;
}).catch((err) => { }).catch((err) => {
console.log('get attribute value by name err: ' + JSON.stringify(err)); console.log('failed to get attribute value, because ' + JSON.stringify(err));
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to get attribute value, because ' + JSON.stringify(exception));
} }
``` ```
## AccessibilityElement.attributeValue ## AccessibilityElement.attributeValue
...@@ -587,23 +714,31 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T, ...@@ -587,23 +714,31 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
| attributeName | T | 是 | 表示属性的名称。 | | attributeName | T | 是 | 表示属性的名称。 |
| callback | AsyncCallback&lt;ElementAttributeValues[T]&gt; | 是 | 回调函数,返回根据节点属性名称获取的属性值。 | | callback | AsyncCallback&lt;ElementAttributeValues[T]&gt; | 是 | 回调函数,返回根据节点属性名称获取的属性值。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300004 | This property does not exist. |
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let attributeValue; let attributeValue;
let attributeName = 'name';
try { try {
let attributeName = 'name'; rootElement.attributeValue(attributeName, (err, data) => {
accessibilityElement.attributeValue(attributeName).then((err, data) => {
if (err) { if (err) {
console.error('failed to get attribute value because ' + JSON.stringify(err)); console.error('failed to get attribute value, because ' + JSON.stringify(err));
return; return;
} }
attributeValue = data; attributeValue = data;
console.info('get attribute value success'); console.info('get attribute value success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to get attribute value, because ' + JSON.stringify(exception));
} }
``` ```
## actionNames ## actionNames
...@@ -623,18 +758,14 @@ actionNames(): Promise\<Array\<string>>; ...@@ -623,18 +758,14 @@ actionNames(): Promise\<Array\<string>>;
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let actionNames; let actionNames;
try { rootElement.actionNames().then((data) => {
accessibilityElement.actionNames().then((data) => {
console.log('get action names success'); console.log('get action names success');
actionNames = data; actionNames = data;
}).catch((err) => { }).catch((err) => {
console.log('get action names err: ' + JSON.stringify(err)); console.log('failed to get action names because ' + JSON.stringify(err));
}); });
} catch (e) {
console.log('An unexpected error occurred. Error:' + e);
}
``` ```
## actionNames ## actionNames
...@@ -653,20 +784,16 @@ actionNames(callback: AsyncCallback\<Array\<string>>): void; ...@@ -653,20 +784,16 @@ actionNames(callback: AsyncCallback\<Array\<string>>): void;
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let actionNames; let actionNames;
try { rootElement.actionNames((err, data) => {
accessibilityElement.actionNames().then((err, data) => {
if (err) { if (err) {
console.error('failed to get action names because ' + JSON.stringify(err)); console.error('failed to get action names, because ' + JSON.stringify(err));
return; return;
} }
actionNames = data; actionNames = data;
console.info('get action names success'); console.info('get action names success');
}); });
} catch (e) {
console.log('An unexpected error occurred. Error:' + e);
}
``` ```
## performAction ## performAction
...@@ -689,20 +816,28 @@ performAction(actionName: string, parameters?: object): Promise\<boolean>; ...@@ -689,20 +816,28 @@ performAction(actionName: string, parameters?: object): Promise\<boolean>;
| ---------------------------------------- | ------------------------ | | ---------------------------------------- | ------------------------ |
| Promise&lt;boolean&gt; | Promise对象,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 | | Promise&lt;boolean&gt; | Promise对象,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300005 | This action is not supported. |
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let performActionRes; let performActionRes;
try { try {
accessibilityElement.performAction('action').then((data) => { rootElement.performAction('action').then((data) => {
console.info('perform action success'); console.info('perform action success');
performActionRes = data; performActionRes = data;
}).catch((err) => { }).catch((err) => {
console.log('failed to perform action because ' + JSON.stringify(err)); console.log('failed to perform action, because ' + JSON.stringify(err));
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## performAction ## performAction
...@@ -718,24 +853,32 @@ performAction(actionName: string, callback: AsyncCallback\<boolean>): void; ...@@ -718,24 +853,32 @@ performAction(actionName: string, callback: AsyncCallback\<boolean>): void;
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- | | ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | 是 | 表示属性的名称。 | | actionName | string | 是 | 表示属性的名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。|
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300005 | This action is not supported. |
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let performActionRes; let performActionRes;
try { try {
accessibilityElement.performAction('action').then((err, data) => { rootElement.performAction('action', (err, data) => {
if (err) { if (err) {
console.error('failed to perform action because ' + JSON.stringify(err)); console.error('failed to perform action, because ' + JSON.stringify(err));
return; return;
} }
performActionRes = data; performActionRes = data;
console.info('perform action success'); console.info('perform action success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## performAction ## performAction
...@@ -752,35 +895,43 @@ performAction(actionName: string, parameters: object, callback: AsyncCallback\<b ...@@ -752,35 +895,43 @@ performAction(actionName: string, parameters: object, callback: AsyncCallback\<b
| ----------- | ---------------------------------------- | ---- | -------------- | | ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | 是 | 表示属性的名称。 | | actionName | string | 是 | 表示属性的名称。 |
| parameters | object | 是 | 表示执行操作时所需要的参数。 | | parameters | object | 是 | 表示执行操作时所需要的参数。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。|
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 9300005 | This action is not supported. |
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let actionName = 'action'; let actionName = 'action';
let parameters = { let parameters = {
'setText': 'test text' 'setText': 'test text'
}; };
let performActionRes; let performActionRes;
try { try {
accessibilityElement.performAction(actionName, parameters).then((err, data) => { rootElement.performAction(actionName, parameters, (err, data) => {
if (err) { if (err) {
console.error('failed to perform action because ' + JSON.stringify(err)); console.error('failed to perform action, because ' + JSON.stringify(err));
return; return;
} }
performActionRes = data; performActionRes = data;
console.info('perform action success'); console.info('perform action success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('content') ## findElement('content')
findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>; findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
根据节点内容查询所有节点元素。 根据节点内容查询所有节点元素,使用Promise异步回调
**系统能力:** SystemCapability.BarrierFree.Accessibility.Core **系统能力:** SystemCapability.BarrierFree.Accessibility.Core
...@@ -800,19 +951,19 @@ findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityEl ...@@ -800,19 +951,19 @@ findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityEl
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'content'; let type = 'content';
let condition = 'keyword'; let condition = 'keyword';
let elements; let elements;
try { try {
accessibilityElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
elements = data; elements = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err) => {
console.log('failed to find element because ' + JSON.stringify(err)); console.log('failed to find element, because ' + JSON.stringify(err));
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('content') ## findElement('content')
...@@ -834,28 +985,28 @@ findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\< ...@@ -834,28 +985,28 @@ findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'content'; let type = 'content';
let condition = 'keyword'; let condition = 'keyword';
let elements; let elements;
try { try {
accessibilityElement.findElement(type, condition).then((err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element because ' + JSON.stringify(err)); console.error('failed to find element, because ' + JSON.stringify(err));
return; return;
} }
elements = data; elements = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusType') ## findElement('focusType')
findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>; findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
根据焦点元素类型查询节点元素。 根据焦点元素类型查询节点元素,使用Promise异步回调
**系统能力:** SystemCapability.BarrierFree.Accessibility.Core **系统能力:** SystemCapability.BarrierFree.Accessibility.Core
...@@ -875,26 +1026,26 @@ findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElem ...@@ -875,26 +1026,26 @@ findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElem
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'focusType'; let type = 'focusType';
let condition = 'normal'; let condition = 'normal';
let elements; let element;
try { try {
accessibilityElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
elements = data; element = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err) => {
console.log('failed to find element because ' + JSON.stringify(err)); console.log('failed to find element, because ' + JSON.stringify(err));
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusType') ## findElement('focusType')
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
根据焦点元素类型查询节点元素。 根据焦点元素类型查询节点元素,使用callback异步回调
**系统能力:** SystemCapability.BarrierFree.Accessibility.Core **系统能力:** SystemCapability.BarrierFree.Accessibility.Core
...@@ -909,28 +1060,28 @@ findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<Ac ...@@ -909,28 +1060,28 @@ findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<Ac
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'focusType'; let type = 'focusType';
let condition = 'normal'; let condition = 'normal';
let elements; let element;
try { try {
accessibilityElement.findElement(type, condition).then((err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element because ' + JSON.stringify(err)); console.error('failed to find element, because ' + JSON.stringify(err));
return; return;
} }
elements = data; element = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusDirection') ## findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>; findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
根据下一焦点元素方向查询节点元素。 根据下一焦点元素方向查询节点元素,使用Promise异步回调
**系统能力:** SystemCapability.BarrierFree.Accessibility.Core **系统能力:** SystemCapability.BarrierFree.Accessibility.Core
...@@ -950,26 +1101,26 @@ findElement(type: 'focusDirection', condition: FocusDirection): Promise\<Accessi ...@@ -950,26 +1101,26 @@ findElement(type: 'focusDirection', condition: FocusDirection): Promise\<Accessi
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'focusDirection'; let type = 'focusDirection';
let condition = 'up'; let condition = 'up';
let elements; let element;
try { try {
accessibilityElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
elements = data; element = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err) => {
console.log('failed to find element because ' + JSON.stringify(err)); console.log('failed to find element, because ' + JSON.stringify(err));
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusDirection') ## findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
根据下一焦点元素方向查询所有节点元素。 根据下一焦点元素方向查询所有节点元素,使用callback异步回调
**系统能力:** SystemCapability.BarrierFree.Accessibility.Core **系统能力:** SystemCapability.BarrierFree.Accessibility.Core
...@@ -984,20 +1135,20 @@ findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCa ...@@ -984,20 +1135,20 @@ findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCa
**示例:** **示例:**
```ts ```ts
let accessibilityElement; let rootElement;
let type = 'focusDirection'; let type = 'focusDirection';
let condition = 'up'; let condition = 'up';
let elements; let elements;
try { try {
accessibilityElement.findElement(type, condition).then((err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element because ' + JSON.stringify(err)); console.error('failed to find element, because ' + JSON.stringify(err));
return; return;
} }
elements = data; elements = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (e) { } catch (exception) {
console.log('An unexpected error occurred. Error:' + e); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## 导入模块 ## 导入模块
```typescript ```ts
import accessibility from '@ohos.accessibility'; import accessibility from '@ohos.accessibility';
``` ```
...@@ -144,7 +144,7 @@ import accessibility from '@ohos.accessibility'; ...@@ -144,7 +144,7 @@ import accessibility from '@ohos.accessibility';
## CaptionsManager<sup>8+</sup> ## CaptionsManager<sup>8+</sup>
字幕配置管理,在调用CaptionsManager的方法前,需要先通过 [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8)获取 captionsManager实例。 字幕配置管理,在调用CaptionsManager的方法前,需要先通过 [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8)获取 CaptionsManager实例。
**系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Hearing **系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Hearing
...@@ -159,7 +159,7 @@ import accessibility from '@ohos.accessibility'; ...@@ -159,7 +159,7 @@ import accessibility from '@ohos.accessibility';
on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void; on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
监听字幕配置启用状态变化事件。 监听字幕配置启用状态变化事件,使用callback异步回调
**参数:** **参数:**
...@@ -170,18 +170,28 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void; ...@@ -170,18 +170,28 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
**示例:** **示例:**
```typescript ```ts
let captionsManager = accessibility.getCaptionsManager(); let result = false;
captionsManager.on('enableChange',(data) => { let captionsManager = accessibility.getCaptionsManager();
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) try {
captionsManager.on('enableChange', (err, data) => {
if (err) {
console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(err));
return;
}
result = data;
console.info('subscribe caption manager enable state change success');
}); });
``` } catch (exception) {
console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception));
}
```
### on('styleChange') ### on('styleChange')
on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void; on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;
监听字幕风格变化事件。 监听字幕风格变化事件,使用callback异步回调
**参数:** **参数:**
...@@ -192,18 +202,28 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void; ...@@ -192,18 +202,28 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;
**示例:** **示例:**
```typescript ```ts
let captionsManager = accessibility.getCaptionsManager(); let captionStyle;
captionsManager.on('styleChange',(data) => { let captionsManager = accessibility.getCaptionsManager();
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) try {
captionsManager.on('styleChange', (err, data) => {
if (err) {
console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(err));
return;
}
captionStyle = data;
console.info('subscribe caption manager style state change success');
}); });
``` } catch (exception) {
console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception));
}
```
### off('enableChange') ### off('enableChange')
off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void; off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
取消监听字幕配置启用状态变化事件。 取消监听字幕配置启用状态变化事件,使用callback异步回调
**参数:** **参数:**
...@@ -214,18 +234,28 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void; ...@@ -214,18 +234,28 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
**示例:** **示例:**
```typescript ```ts
let captionsManager = accessibility.getCaptionsManager(); let result = false;
captionsManager.off('enableChange',(data) => { let captionsManager = accessibility.getCaptionsManager();
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) try {
captionsManager.off('enableChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(err));
return;
}
result = data;
console.info('unSubscribe caption manager enable state change success');
}); });
``` } catch (exception) {
console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(exception));
}
```
### off('styleChange') ### off('styleChange')
off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void; off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;
取消字幕风格变化监听事件。 取消字幕风格变化监听事件,使用callback异步回调
**参数:** **参数:**
...@@ -236,12 +266,22 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void; ...@@ -236,12 +266,22 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;
**示例:** **示例:**
```typescript ```ts
let captionsManager = accessibility.getCaptionsManager(); let captionStyle;
captionsManager.off('styleChange',(data) => { let captionsManager = accessibility.getCaptionsManager();
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) try {
captionsManager.off('styleChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(err));
return;
}
captionStyle = data;
console.info('unSubscribe caption manager style state change success');
}); });
``` } catch (exception) {
console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(exception));
}
```
## EventInfo ## EventInfo
...@@ -284,11 +324,11 @@ constructor(jsonObject) ...@@ -284,11 +324,11 @@ constructor(jsonObject)
**示例:** **示例:**
```typescript ```ts
let eventInfo = new accessibility.EventInfo({ let eventInfo = new accessibility.EventInfo({
"type":"click", 'type':'click',
"bundleName":"com.example.MyApplication", 'bundleName':'com.example.MyApplication',
"triggerAction":"click" 'triggerAction':'click'
}); });
``` ```
...@@ -340,12 +380,17 @@ constructor(jsonObject) ...@@ -340,12 +380,17 @@ constructor(jsonObject)
| active | 窗口变为活动或不活动的窗口变化事件。 | | active | 窗口变为活动或不活动的窗口变化事件。 |
| focus | 窗口焦点发生变化的窗口变化事件。 | | focus | 窗口焦点发生变化的窗口变化事件。 |
## accessibility.getAbilityLists ## accessibility.getAbilityLists<sup>(deprecated)</sup>
getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt; getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;
查询辅助应用列表,使用Promise异步回调。 查询辅助应用列表,使用Promise异步回调。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃。
> 推荐使用[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9)。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
...@@ -363,26 +408,39 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;A ...@@ -363,26 +408,39 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;A
**示例:** **示例:**
```typescript ```ts
accessibility.getAbilityLists("spoken", "enable").then((data) => { let abilityType = 'spoken';
console.info('success data:getAbilityList1 : ' + JSON.stringify(data)); let abilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[];
try {
accessibility.getAbilityLists(abilityType, abilityState).then((data) => {
for (let item of data) { for (let item of data) {
console.info(item.id); console.info(item.id);
console.info(item.name); console.info(item.name);
console.info(item.description); console.info(item.description);
console.info(item.bundleName); console.info(item.bundleName);
extensionList.push(item);
} }
}).catch((err) => { console.info('get accessibility extension list success');
console.error('failed to getAbilityList1 because ' + JSON.stringify(err)); }).catch((err) => {
}); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
``` ```
## accessibility.getAbilityLists ## accessibility.getAbilityLists<sup>(deprecated)</sup>
getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void
查询辅助应用列表,使用callback异步回调。 查询辅助应用列表,使用callback异步回调。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃。
> 推荐使用[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9-1)。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
...@@ -395,21 +453,120 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn ...@@ -395,21 +453,120 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn
**示例:** **示例:**
```typescript ```ts
accessibility.getAbilityLists("visual", "enable", (err, data) => { let abilityType = 'spoken';
let abilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[];
try {
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
if (err) { if (err) {
console.error('failed to getAbilityList2 because ' + JSON.stringify(err)); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
return; return;
} }
console.info('success data:getAbilityList2 : ' + JSON.stringify(data));
for (let item of data) { for (let item of data) {
console.info(item.id); console.info(item.id);
console.info(item.name); console.info(item.name);
console.info(item.description); console.info(item.description);
console.info(item.bundleName); console.info(item.bundleName);
abilityList.push(item);
} }
}); console.info('get accessibility extension list success');
``` }).catch((err) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```
## accessibility.getAccessibilityExtensionList<sup>9+</sup>
getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;
查询辅助应用列表,使用Promise异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 |
| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | Promise对象,返回辅助应用信息列表。 |
**示例:**
```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let extensionList: accessibility.AccessibilityInfo[];
try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => {
for (let item of data) {
console.info(item.id);
console.info(item.name);
console.info(item.description);
console.info(item.bundleName);
extensionList.push(item);
}
console.info('get accessibility extension list success');
}).catch((err) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```
## accessibility.getAccessibilityExtensionList<sup>9+</sup>
getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void
查询辅助应用列表,使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 |
| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 |
| callback | AsyncCallback&lt;Array&lt;[AccessibilityAbilityInfo](#accessibilityabilityinfo)&gt;&gt; | 是 | 回调函数,返回辅助应用信息列表。 |
**示例:**
```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let extensionList: accessibility.AccessibilityInfo[];
try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => {
if (err) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
return;
}
for (let item of data) {
console.info(item.id);
console.info(item.name);
console.info(item.description);
console.info(item.bundleName);
extensionList.push(item);
}
console.info('get accessibility extension list success');
}).catch((err) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
}
```
## accessibility.getCaptionsManager<sup>8+</sup> ## accessibility.getCaptionsManager<sup>8+</sup>
...@@ -427,7 +584,7 @@ getCaptionsManager(): CaptionsManager ...@@ -427,7 +584,7 @@ getCaptionsManager(): CaptionsManager
**示例:** **示例:**
```typescript ```ts
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
``` ```
...@@ -435,7 +592,7 @@ let captionsManager = accessibility.getCaptionsManager(); ...@@ -435,7 +592,7 @@ let captionsManager = accessibility.getCaptionsManager();
on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
监听辅助应用启用状态变化事件。 监听辅助应用启用状态变化事件,使用callback异步回调
**系统能力**:以下各项对应的系统能力有所不同,详见下表。 **系统能力**:以下各项对应的系统能力有所不同,详见下表。
...@@ -448,17 +605,25 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -448,17 +605,25 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.on('accessibilityStateChange',(data) => { try {
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) accessibility.on('accessibilityStateChange', (err, data) => {
}); if (err) {
console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(err));
return;
}
console.info('subscribe accessibility state change success');
});
} catch (exception) {
console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception));
}
``` ```
## accessibility.on('touchGuideStateChange') ## accessibility.on('touchGuideStateChange')
on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
监听触摸浏览功能启用状态变化事件。 监听触摸浏览功能启用状态变化事件,使用callback异步回调
**系统能力**:以下各项对应的系统能力有所不同,详见下表。 **系统能力**:以下各项对应的系统能力有所不同,详见下表。
...@@ -471,17 +636,25 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -471,17 +636,25 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.on('touchGuideStateChange',(data) => { try {
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) accessibility.on('touchGuideStateChange', (err, data) => {
}); if (err) {
console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(err));
return;
}
console.info('subscribe touch guide state change success');
});
} catch (exception) {
console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception));
}
``` ```
## accessibility.off('accessibilityStateChange') ## accessibility.off('accessibilityStateChange')
off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void
取消监听辅助应用启用状态变化事件。 取消监听辅助应用启用状态变化事件,使用callback异步回调
**系统能力**:以下各项对应的系统能力有所不同,详见下表。 **系统能力**:以下各项对应的系统能力有所不同,详见下表。
...@@ -494,17 +667,25 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -494,17 +667,25 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.off('accessibilityStateChange',(data) => { try {
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) accessibility.on('accessibilityStateChange', (err, data) => {
}); if (err) {
console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe accessibility state change success');
});
} catch (exception) {
console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(exception));
}
``` ```
## accessibility.off('touchGuideStateChange') ## accessibility.off('touchGuideStateChange')
off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
取消监听触摸浏览启用状态变化事件。 取消监听触摸浏览启用状态变化事件,使用callback异步回调
**系统能力**:以下各项对应的系统能力有所不同,详见下表。 **系统能力**:以下各项对应的系统能力有所不同,详见下表。
...@@ -517,10 +698,18 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -517,10 +698,18 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.off('touchGuideStateChange',(data) => { try {
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) accessibility.on('touchGuideStateChange', (err, data) => {
}); if (err) {
console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe touch guide state change success');
});
} catch (exception) {
console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(exception));
}
``` ```
## accessibility.isOpenAccessibility ## accessibility.isOpenAccessibility
...@@ -539,7 +728,7 @@ isOpenAccessibility(): Promise&lt;boolean&gt; ...@@ -539,7 +728,7 @@ isOpenAccessibility(): Promise&lt;boolean&gt;
**示例:** **示例:**
```typescript ```ts
accessibility.isOpenAccessibility().then((data) => { accessibility.isOpenAccessibility().then((data) => {
console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
}).catch((err) => { }).catch((err) => {
...@@ -563,7 +752,7 @@ isOpenAccessibility(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -563,7 +752,7 @@ isOpenAccessibility(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.isOpenAccessibility((err, data) => { accessibility.isOpenAccessibility((err, data) => {
if (err) { if (err) {
console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
...@@ -589,7 +778,7 @@ isOpenTouchGuide(): Promise&lt;boolean&gt; ...@@ -589,7 +778,7 @@ isOpenTouchGuide(): Promise&lt;boolean&gt;
**示例:** **示例:**
```typescript ```ts
accessibility.isOpenTouchGuide().then((data) => { accessibility.isOpenTouchGuide().then((data) => {
console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
}).catch((err) => { }).catch((err) => {
...@@ -613,7 +802,7 @@ isOpenTouchGuide(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -613,7 +802,7 @@ isOpenTouchGuide(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```typescript ```ts
accessibility.isOpenTouchGuide((err, data) => { accessibility.isOpenTouchGuide((err, data) => {
if (err) { if (err) {
console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
...@@ -623,12 +812,17 @@ accessibility.isOpenTouchGuide((err, data) => { ...@@ -623,12 +812,17 @@ accessibility.isOpenTouchGuide((err, data) => {
}); });
``` ```
## accessibility.sendEvent ## accessibility.sendEvent<sup>(deprecated)</sup>
sendEvent(event: EventInfo): Promise&lt;void&gt; sendEvent(event: EventInfo): Promise&lt;void&gt;
发送无障碍事件, 使用Promise异步回调。 发送无障碍事件, 使用Promise异步回调。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃。
> 推荐使用[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9)。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
...@@ -645,11 +839,11 @@ sendEvent(event: EventInfo): Promise&lt;void&gt; ...@@ -645,11 +839,11 @@ sendEvent(event: EventInfo): Promise&lt;void&gt;
**示例:** **示例:**
```typescript ```ts
let eventInfo = new accessibility.EventInfo({ let eventInfo = new accessibility.EventInfo({
"type":"click", 'type':'click',
"bundleName":"com.example.MyApplication", 'bundleName':'com.example.MyApplication',
"triggerAction":"click" 'triggerAction':'click'
}); });
accessibility.sendEvent(eventInfo).then(() => { accessibility.sendEvent(eventInfo).then(() => {
console.info('send event success'); console.info('send event success');
...@@ -658,12 +852,17 @@ accessibility.sendEvent(eventInfo).then(() => { ...@@ -658,12 +852,17 @@ accessibility.sendEvent(eventInfo).then(() => {
}); });
``` ```
## accessibility.sendEvent ## accessibility.sendEvent<sup>(deprecated)</sup>
sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void
发送无障碍事件, 使用callback异步回调。 发送无障碍事件, 使用callback异步回调。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃。
> 推荐使用[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9-1)。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core **系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
...@@ -675,11 +874,11 @@ sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void ...@@ -675,11 +874,11 @@ sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```typescript ```ts
let eventInfo = new accessibility.EventInfo({ let eventInfo = new accessibility.EventInfo({
"type":"click", 'type':'click',
"bundleName":"com.example.MyApplication", 'bundleName':'com.example.MyApplication',
"triggerAction":"click" 'triggerAction':'click'
}); });
accessibility.sendEvent(eventInfo, (err, data) => { accessibility.sendEvent(eventInfo, (err, data) => {
if (err) { if (err) {
...@@ -688,4 +887,79 @@ accessibility.sendEvent(eventInfo, (err, data) => { ...@@ -688,4 +887,79 @@ accessibility.sendEvent(eventInfo, (err, data) => {
} }
console.info('sendEvent success'); console.info('sendEvent success');
}); });
``` ```
## accessibility.sendAccessibilityEvent<sup>9+</sup>
sendAccessibilityEvent(event: EventInfo): Promise&lt;void&gt;
发送无障碍事件, 使用Promise异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```ts
let eventInfo = new accessibility.EventInfo({
'type':'click',
'bundleName':'com.example.MyApplication',
'triggerAction':'click'
});
try {
accessibility.sendAccessibilityEvent(eventInfo).then(() => {
console.info('send event success');
}).catch((err) => {
console.error('failed to send event because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to send event because ' + JSON.stringify(exception));
}
```
## accessibility.sendAccessibilityEvent<sup>9+</sup>
sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void
发送无障碍事件, 使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 |
**示例:**
```ts
let eventInfo = new accessibility.EventInfo({
'type':'click',
'bundleName':'com.example.MyApplication',
'triggerAction':'click'
});
try {
accessibility.sendEvent(eventInfo, (err, data) => {
if (err) {
console.error('failed to send event because ' + JSON.stringify(err));
return;
}
console.info('send event success');
});
} catch (exception) {
console.error('failed to send event because ' + JSON.stringify(exception));
}
```
...@@ -94,8 +94,10 @@ onConnect(): void; ...@@ -94,8 +94,10 @@ onConnect(): void;
**示例:** **示例:**
```ts ```ts
onConnect(): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onConnect"); onConnect() {
console.log('AxExtensionAbility onConnect');
}
}; };
``` ```
...@@ -110,8 +112,10 @@ onDisconnect(): void; ...@@ -110,8 +112,10 @@ onDisconnect(): void;
**示例:** **示例:**
```ts ```ts
onDisconnect(): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onDisconnect"); onDisconnect() {
console.log('AxExtensionAbility onDisconnect');
}
}; };
``` ```
...@@ -127,15 +131,17 @@ onAccessibilityEvent(event: AccessibilityEvent): void; ...@@ -127,15 +131,17 @@ onAccessibilityEvent(event: AccessibilityEvent): void;
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ---------------------------------------- | ---- | --------------- | | ----- | ---------------------------------------- | ---- | --------------- |
| event | [AccessibilityEvent](accessibilityevent) | 是 | 无障碍事件回调函数。无返回值。 | | event | [AccessibilityEvent](#accessibilityevent) | 是 | 无障碍事件回调函数。无返回值。 |
**示例:** **示例:**
```ts ```ts
onAccessibilityEvent(event: AccessibilityEvent): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onAccessibilityEvent"); onAccessibilityEvent(event) {
console.log('AxExtensionAbility onAccessibilityEvent');
if (event.eventType == 'click') { if (event.eventType == 'click') {
console.log("AxExtensionAbility onAccessibilityEvent: click"); console.log('AxExtensionAbility onAccessibilityEvent: click');
}
} }
}; };
``` ```
...@@ -157,12 +163,14 @@ onKeyEvent(keyEvent: KeyEvent): boolean; ...@@ -157,12 +163,14 @@ onKeyEvent(keyEvent: KeyEvent): boolean;
**示例:** **示例:**
```ts ```ts
onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onKeyEvent"); onKeyEvent(keyEvent) {
console.log('AxExtensionAbility onKeyEvent');
if (keyEvent.keyCode == 22) { if (keyEvent.keyCode == 22) {
console.log("AxExtensionAbility onKeyEvent: intercept 22"); console.log('AxExtensionAbility onKeyEvent: intercept 22');
return true; return true;
} }
return false; return false;
}
}; };
``` ```
...@@ -19,7 +19,7 @@ import batteryInfo from '@ohos.batteryInfo'; ...@@ -19,7 +19,7 @@ import batteryInfo from '@ohos.batteryInfo';
**系统能力**:SystemCapability.PowerManager.BatteryManager.Core **系统能力**:SystemCapability.PowerManager.BatteryManager.Core
| 名称 | 类型 | 可读 | 可写 | 描述 | | 名称 | 类型 | 可读 | 可写 | 描述 |
| ----------------------------------------- | ---------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | | ----------------------------------------- | ---------------------------------------------- | ---- | ---- | ---------------------------------------------------------- |
| batterySOC | number | 是 | 否 | 表示当前设备剩余电池电量百分比。 | | batterySOC | number | 是 | 否 | 表示当前设备剩余电池电量百分比。 |
| chargingStatus | [BatteryChargeState](#batterychargestate) | 是 | 否 | 表示当前设备电池的充电状态。 | | chargingStatus | [BatteryChargeState](#batterychargestate) | 是 | 否 | 表示当前设备电池的充电状态。 |
| healthStatus | [BatteryHealthState](#batteryhealthstate) | 是 | 否 | 表示当前设备电池的健康状态。 | | healthStatus | [BatteryHealthState](#batteryhealthstate) | 是 | 否 | 表示当前设备电池的健康状态。 |
...@@ -30,15 +30,9 @@ import batteryInfo from '@ohos.batteryInfo'; ...@@ -30,15 +30,9 @@ import batteryInfo from '@ohos.batteryInfo';
| isBatteryPresent<sup>7+</sup> | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 | | isBatteryPresent<sup>7+</sup> | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 |
| batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | 是 | 否 | 表示当前设备电池电量的等级。 | | batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | 是 | 否 | 表示当前设备电池电量的等级。 |
| estimatedRemainingChargeTime<sup>9+</sup> | number | 是 | 否 | 表示当前设备充满电的预估时间,单位毫秒。 | | estimatedRemainingChargeTime<sup>9+</sup> | number | 是 | 否 | 表示当前设备充满电的预估时间,单位毫秒。 |
| totalEnergy<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的总容量,单位毫安时。此接口为系统接口,三方应用不支持调用。 | | totalEnergy<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的总容量,单位毫安时。此接口为系统接口。 |
| nowCurrent<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的电流,单位毫安。此接口为系统接口,三方应用不支持调用。 | | nowCurrent<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的电流,单位毫安。此接口为系统接口。 |
| remainingEnergy<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的剩余容量,单位毫安时。此接口为系统接口,三方应用不支持调用。 | | remainingEnergy<sup>9+</sup> | number | 是 | 否 | 表示当前设备电池的剩余容量,单位毫安时。此接口为系统接口。 |
- 示例:
```js
import batteryInfo from '@ohos.batteryInfo';
var batterySoc = batteryInfo.batterySOC;
```
## BatteryPluggedType ## BatteryPluggedType
...@@ -105,22 +99,22 @@ import batteryInfo from '@ohos.batteryInfo'; ...@@ -105,22 +99,22 @@ import batteryInfo from '@ohos.batteryInfo';
## CommonEventBatteryChangedCode<sup>9+</sup> ## CommonEventBatteryChangedCode<sup>9+</sup>
表示COMMON_EVENT_BATTERY_CHANGED通用事件的键代码 表示COMMON_EVENT_BATTERY_CHANGED通用事件附加信息的查询键
**系统能力**:SystemCapability.PowerManager.BatteryManager.Core **系统能力**:SystemCapability.PowerManager.BatteryManager.Core
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| -------------------- | ------ | -------------------------------------------------- | | -------------------- | ------ | -------------------------------------------------- |
| EXTRA_SOC | 0 | 表示剩余电池电量百分比的键代码。 | | EXTRA_SOC | 0 | 表示剩余电池电量百分比的查询键。 |
| EXTRA_VOLTAGE | 1 | 表示当前设备电池电压的键代码。 | | EXTRA_VOLTAGE | 1 | 表示当前设备电池电压的查询键。 |
| EXTRA_TEMPERATURE | 2 | 表示当前设备电池温度的键代码。 | | EXTRA_TEMPERATURE | 2 | 表示当前设备电池温度的查询键。 |
| EXTRA_HEALTH_STATE | 3 | 表示当前设备电池健康状态的键代码。 | | EXTRA_HEALTH_STATE | 3 | 表示当前设备电池健康状态的查询键。 |
| EXTRA_PLUGGED_TYPE | 4 | 表示当前设备连接的充电器类型的键代码。 | | EXTRA_PLUGGED_TYPE | 4 | 表示当前设备连接的充电器类型的查询键。 |
| EXTRA_MAX_CURRENT | 5 | 表示当前设备电池最大电流的键代码。 | | EXTRA_MAX_CURRENT | 5 | 表示当前设备电池最大电流的查询键。 |
| EXTRA_MAX_VOLTAGE | 6 | 表示当前设备电池最大电压的键代码。 | | EXTRA_MAX_VOLTAGE | 6 | 表示当前设备电池最大电压的查询键。 |
| EXTRA_CHARGE_STATE | 7 | 表示当前设备电池充电状态的键代码。 | | EXTRA_CHARGE_STATE | 7 | 表示当前设备电池充电状态的查询键。 |
| EXTRA_CHARGE_COUNTER | 8 | 表示当前设备电池充电次数的键代码。 | | EXTRA_CHARGE_COUNTER | 8 | 表示当前设备电池充电次数的查询键。 |
| EXTRA_PRESENT | 9 | 表示当前设备是否支持电池或者电池是否在位的键代码。 | | EXTRA_PRESENT | 9 | 表示当前设备是否支持电池或者电池是否在位的查询键。 |
| EXTRA_TECHNOLOGY | 10 | 表示当前设备电池技术型号的键代码。 | | EXTRA_TECHNOLOGY | 10 | 表示当前设备电池技术型号的查询键。 |
# 耗电统计
该模块提供软硬件耗电统计信息的查询接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 本模块接口为系统接口。
## 导入模块
```js
import batteryStats from '@ohos.batteryStatistics';
```
## batteryStats.getBatteryStats
getBatteryStats(): Promise<Array&lt;BatteryStatsInfo&gt;>
获取耗电信息列表。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------- | ------------------------------- |
| Promise<Array<[BatteryStatsInfo](#batterystatsinfo)>> | Promise对象,返回耗电信息列表。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
batteryStats.getBatteryStats()
.then(data => {
console.info('battery statistics info: ' + data);
})
.catch(err => {
console.error('get battery statisitics failed, err: ' + err);
});
```
## batteryStats.getBatteryStats
getBatteryStats(callback: AsyncCallback<Array&lt;BatteryStatsInfo&gt;>): void
获取耗电信息列表。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<Array<[BatteryStatsInfo](#batterystatsinfo)>> | 是 | 回调函数。当获取耗电信息列表成功,err为undefined,data为获取到的Array<[BatteryStatsInfo](#batterystatsinfo)>>;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
batteryStats.getBatteryStats((err, data) => {
if (typeof err === 'undefined') {
console.info('battery statistics info: ' + data);
} else {
console.error('get battery statisitics failed, err: ' + err);
}
});
```
## batteryStats.getAppPowerValue
getAppPowerValue(uid: number): number
获取应用的耗电量。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ----------- |
| uid | number | 是 | 应用的UID。 |
**返回值:**
| 类型 | 说明 |
| ------ | --------------------------------- |
| number | UID对应应用的耗电量,单位毫安时。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
try {
var value = batteryStats.getAppPowerValue(10021);
console.info('battery statistics value of app is: ' + value);
} catch(err) {
console.error('get battery statisitics value of app failed, err: ' + err);
}
```
## batteryStats.getAppPowerPercent
getAppPowerPercent(uid: number): number
获取应用的耗电百分比。
**系统能力:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ----------- |
| uid | number | 是 | 应用的UID。 |
**返回值:**
| 类型 | 说明 |
| ------ | ------------------------- |
| number | UID对应应用的耗电百分比。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
try {
var percent = batteryStats.getAppPowerPercent(10021);
console.info('battery statistics percent of app is: ' + percent);
} catch(err) {
console.error('get battery statisitics percent of app failed, err: ' + err);
}
```
## batteryStats.getHardwareUnitPowerValue
getHardwareUnitPowerValue(type: ConsumptionType): number
根据耗电类型获取硬件单元的耗电量。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | -------------- |
| type | [ConsumptionType](#consumptiontype) | 是 | 电量消耗类型。 |
**返回值:**
| 类型 | 说明 |
| ------ | ------------------------------------------ |
| number | 电量消耗类型对应硬件的耗电量,单位毫安时。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
try {
var value = batteryStats.getHardwareUnitPowerValue(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics percent of hardware is: ' + percent);
} catch(err) {
console.error('get battery statisitics percent of hardware failed, err: ' + err);
}
```
## batteryStats.getHardwareUnitPowerPercent
getHardwareUnitPowerPercent(type: ConsumptionType): number
根据耗电类型获取硬件单元的耗电百分比。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | -------------- |
| type | [ConsumptionType](#consumptiontype) | 是 | 电量消耗类型。 |
**返回值:**
| 类型 | 说明 |
| ------ | ---------------------------------- |
| number | 电量消耗类型对应硬件的耗电百分比。 |
**错误码:**
以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-batteryStatistics.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4600101 | 连接服务失败。 |
**示例:**
```js
try {
var value = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics percent of hardware is: ' + percent);
} catch(err) {
console.error('get battery statisitics percent of hardware failed, err: ' + err);
}
```
## BatteryStatsInfo
设备的耗电信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
### 属性
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ----------------------------------- | ---- | ---- | ---------------------- |
| uid | number | 是 | 否 | 耗电信息相关的UID。 |
| type | [ConsumptionType](#consumptiontype) | 是 | 否 | 耗电信息相关的类型。 |
| power | number | 是 | 否 | 耗电的值,单位毫安时。 |
## ConsumptionType
表示电量消耗类型的枚举值。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.PowerManager.BatteryStatistics
| 名称 | 值 | 说明 |
| -------------------------- | ---- | ----------------------------- |
| CONSUMPTION_TYPE_INVALID | -17 | 表示电量消耗类型未知。 |
| CONSUMPTION_TYPE_APP | -16 | 表示应用消耗的电量类型。 |
| CONSUMPTION_TYPE_BLUETOOTH | -15 | 表示蓝牙消耗的电量类型。 |
| CONSUMPTION_TYPE_IDLE | -14 | 表示CPU空闲时消耗的电量类型。 |
| CONSUMPTION_TYPE_PHONE | -13 | 表示通话来电消耗的电量类型。 |
| CONSUMPTION_TYPE_RADIO | -12 | 表示无线通讯消耗的电量类型。 |
| CONSUMPTION_TYPE_SCREEN | -11 | 表示屏幕消耗的电量类型。 |
| CONSUMPTION_TYPE_USER | -10 | 表示用户消耗的电量类型。 |
| CONSUMPTION_TYPE_WIFI | -9 | 表示无线网消耗的电量类型。 |
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
该模块提供屏幕亮度的设置接口。 该模块提供屏幕亮度的设置接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 >
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 本模块接口为系统接口。
## 导入模块 ## 导入模块
...@@ -18,18 +20,30 @@ setValue(value: number): void ...@@ -18,18 +20,30 @@ setValue(value: number): void
设置系统的屏幕亮度。 设置系统的屏幕亮度。
此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------- | | ------ | ------ | ---- | ----------------------- |
| value | number | 是 | 亮度的值(0~255) | | value | number | 是 | 亮度的值。范围:0~255。 |
**错误码:**
以下错误码的详细介绍请参见[屏幕亮度错误码](../errorcodes/errorcode-brightness.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4700101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
brightness.setValue(128); try {
brightness.setValue(128);
} catch(err) {
console.error('set brightness failed, err: ' + err);
}
``` ```
...@@ -22,6 +22,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba ...@@ -22,6 +22,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -71,6 +73,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId ...@@ -71,6 +73,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -121,6 +125,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId ...@@ -121,6 +125,8 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -173,6 +179,8 @@ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void ...@@ -173,6 +179,8 @@ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -214,6 +222,8 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void ...@@ -214,6 +222,8 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -256,6 +266,8 @@ disableAdmin(admin: Want, userId?: number): Promise\<void> ...@@ -256,6 +266,8 @@ disableAdmin(admin: Want, userId?: number): Promise\<void>
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -295,8 +307,12 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void ...@@ -295,8 +307,12 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。 以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -331,8 +347,12 @@ disableSuperAdmin(bundleName: String): Promise\<void> ...@@ -331,8 +347,12 @@ disableSuperAdmin(bundleName: String): Promise\<void>
以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。 以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -370,6 +390,8 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void ...@@ -370,6 +390,8 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -409,6 +431,8 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): ...@@ -409,6 +431,8 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>):
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -441,6 +465,8 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> ...@@ -441,6 +465,8 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -476,6 +502,8 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void ...@@ -476,6 +502,8 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -504,6 +532,8 @@ isSuperAdmin(bundleName: String): Promise\<boolean> ...@@ -504,6 +532,8 @@ isSuperAdmin(bundleName: String): Promise\<boolean>
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -559,14 +589,12 @@ let wantTemp = { ...@@ -559,14 +589,12 @@ let wantTemp = {
}; };
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error code:" + error.code);
return; return;
} }
mgr.setDateTime(wantTemp, 1526003846000, (error, value) => { mgr.setDateTime(wantTemp, 1526003846000, (error) => {
if (error != null) { if (error != null) {
console.log(error); console.log("error code:" + error.code);
} else {
console.log(value);
} }
}); });
}); });
...@@ -603,24 +631,26 @@ let wantTemp = { ...@@ -603,24 +631,26 @@ let wantTemp = {
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => { enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => {
mgr.setDateTime(wantTemp, 1526003846000).then((value) => { mgr.setDateTime(wantTemp, 1526003846000).catch((error) => {
console.log(value); console.log("error code:" + error.code);
}).catch((error) => {
console.log(error);
}) })
}).catch((error) => { }).catch((error) => {
console.log(error); console.log("error code:" + error.code);
}) })
``` ```
## enterpriseDeviceManager.setEnterpriseInfo ## enterpriseDeviceManager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback&lt;boolean&gt;): void setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>;): void
设置设备管理员应用的企业信息,使用callback形式返回是否设置成功。 设置设备管理员应用的企业信息,使用callback形式返回是否设置成功。
**需要权限:** ohos.permission.SET_ENTERPRISE_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -659,12 +689,16 @@ enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => { ...@@ -659,12 +689,16 @@ enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
## enterpriseDeviceManager.setEnterpriseInfo ## enterpriseDeviceManager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise&lt;boolean&gt; setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>;
设置设备管理员应用的企业信息,使用Promise形式返回是否设置成功。 设置设备管理员应用的企业信息,使用Promise形式返回是否设置成功。
**需要权限:** ohos.permission.SET_ENTERPRISE_INFO
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -710,6 +744,8 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): v ...@@ -710,6 +744,8 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): v
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -750,6 +786,8 @@ getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt; ...@@ -750,6 +786,8 @@ getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -791,10 +829,12 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback ...@@ -791,10 +829,12 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback
订阅系统管理事件。使用callback异步回调。 订阅系统管理事件。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -824,10 +864,12 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise ...@@ -824,10 +864,12 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise
订阅系统管理事件。使用Promise异步回调。 订阅系统管理事件。使用Promise异步回调。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -861,10 +903,12 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callba ...@@ -861,10 +903,12 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callba
取消订阅系统管理事件。使用callback异步回调。 取消订阅系统管理事件。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -894,10 +938,12 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promi ...@@ -894,10 +938,12 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promi
取消订阅系统管理事件。使用callback异步回调。 取消订阅系统管理事件。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -32,6 +32,8 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void ...@@ -32,6 +32,8 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -81,6 +83,8 @@ setDateTime(admin: Want, time: number): Promise\<void> ...@@ -81,6 +83,8 @@ setDateTime(admin: Want, time: number): Promise\<void>
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -5,21 +5,19 @@ ...@@ -5,21 +5,19 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```js ```js
import power from '@ohos.power'; import power from '@ohos.power';
``` ```
## power.shutdown
## power.shutdownDevice shutdown(reason: string): void
shutdownDevice(reason: string): void
系统关机。 系统关机。
此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.REBOOT **需要权限:** ohos.permission.REBOOT
...@@ -31,20 +29,32 @@ shutdownDevice(reason: string): void ...@@ -31,20 +29,32 @@ shutdownDevice(reason: string): void
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| reason | string | 是 | 关机原因。 | | reason | string | 是 | 关机原因。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.shutdownDevice("shutdown_test"); try {
console.info('power_shutdown_device_test success') power.shutdown('shutdown_test');
} catch(err) {
console.error('shutdown failed, err: ' + err);
}
``` ```
## power.reboot<sup>9+</sup>
## power.rebootDevice reboot(reason: string): void
rebootDevice(reason: string): void
重启设备。 重启设备。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.REBOOT **需要权限:** ohos.permission.REBOOT
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
...@@ -52,114 +62,158 @@ rebootDevice(reason: string): void ...@@ -52,114 +62,158 @@ rebootDevice(reason: string): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ---------- |
| reason | string | 是 | 重启原因。 | | reason | string | 是 | 重启原因。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.rebootDevice("reboot_test"); try {
console.info('power_reboot_device_test success') power.reboot('reboot_test');
} catch(err) {
console.error('reboot failed, err: ' + err);
}
``` ```
## power.isActive<sup>9+</sup>
## power.isScreenOn isActive(): boolean
isScreenOn(callback: AsyncCallback&lt;boolean&gt;): void
检测当前设备的亮灭屏状态。 检测当前设备是否处于活动状态。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:** **错误码:**
| 参数名 | 类型 | 必填 | 说明 | 以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 指定的callback回调方法,用于获取返回值。<br/>callback返回值:亮屏返回true,灭屏返回false。 | | 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.isScreenOn((error, screenOn) => { try {
if (typeof error === "undefined") { var isActive = power.isActive();
console.info('screenOn status is ' + screenOn); console.info('power is active: ' + isActive);
} else { } catch(err) {
console.log('error: ' + error); console.error('check active status failed, err: ' + err);
} }
})
``` ```
## power.wakeup<sup>9+</sup>
## power.isScreenOn wakeup(detail: string): void
isScreenOn(): Promise&lt;boolean&gt; 唤醒设备。
检测当前设备的亮灭屏状态 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**返回值:** **参数:**
| 类型 | 说明 |
| ---------------------- | --------------------------------------- | | 参数名 | 类型 | 必填 | 说明 |
| Promise&lt;boolean&gt; | Promise实例,用于异步获取返回值,亮屏返回true,灭屏返回false。 | | ------ | ------ | ---- | ---------- |
| detail | string | 是 | 唤醒原因。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.isScreenOn() try {
.then(screenOn => { power.wakeup('wakeup_test');
console.info('screenOn status is ' + screenOn); } catch(err) {
}) console.error('wakeup failed, err: ' + err);
.catch(error => { }
console.log('error: ' + error);
})
``` ```
## power.wakeupDevice<sup>9+</sup> ## power.suspend<sup>9+</sup>
wakeupDevice(detail: string): void suspend(): void
唤醒设备。 休眠设备。
此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:** **错误码:**
| 参数名 | 类型 | 必填 | 说明 | 以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| ------ | ------ | ---- | ---------- |
| detail | string | 是 | 唤醒原因。 | | 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.wakeupDevice("application"); try {
console.info('power_wakeup_device_test success') power.suspend();
} catch(err) {
console.error('suspend failed, err: ' + err);
}
``` ```
## power.suspendDevice<sup>9+</sup> ## power.getPowerMode<sup>9+</sup>
suspendDevice(): void getPowerMode(): DevicePowerMode
休眠设备 获取当前设备的电源模式
此接口为系统接口,三方应用不支持调用。 **需要权限:** ohos.permission.POWER_OPTIMIZATION
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**返回值:**
| 类型 | 说明 |
| ------------------------------------ | ---------- |
| [DevicePowerMode](#devicepowermode9) | 电源模式。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.suspendDevice(); try {
console.info('power_suspend_device_test success') var mode = power.getPowerMode();
console.info('power mode: ' + mode);
} catch(err) {
console.error('get power mode failed, err: ' + err);
}
``` ```
## power.getPowerMode<sup>9+</sup> ## power.setPowerMode<sup>9+</sup>
setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void
getPowerMode(callback: AsyncCallback&lt;DevicePowerMode&gt;): void 设置当前设备的电源模式。使用callback异步回调。
获取当前设备的电源模式 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.POWER_OPTIMIZATION **需要权限:** ohos.permission.POWER_OPTIMIZATION
...@@ -169,114 +223,149 @@ getPowerMode(callback: AsyncCallback&lt;DevicePowerMode&gt;): void ...@@ -169,114 +223,149 @@ getPowerMode(callback: AsyncCallback&lt;DevicePowerMode&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;DevicePowerMode&gt; | 是 | 指定的callback回调方法,用于获取返回值。<br/>callback返回值:[DevicePowerMode](#devicepowermode9)。 | | mode | [DevicePowerMode](#devicepowermode9) | 是 | 电源模式。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当设置电源模式成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:** **示例:**
```js ```js
power.getPowerMode((error, mode) => { power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, err => {
if (typeof error === "undefined") { if (typeof err === 'undefined') {
console.info('power mode is ' + mode); console.info('set power mode to MODE_PERFORMANCE');
} else { } else {
console.log('error: ' + error); console.error('set power mode failed, err: ' + err);
} }
}) });
``` ```
## power.setPowerMode<sup>9+</sup>
## power.getPowerMode<sup>9+</sup> setPowerMode(mode: DevicePowerMode): Promise&lt;void&gt;
getPowerMode(): Promise&lt;DevicePowerMode&gt; 设置当前设备的电源模式。使用Promise异步回调。
获取当前设备的电源模式 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.POWER_OPTIMIZATION **需要权限:** ohos.permission.POWER_OPTIMIZATION
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------------ | ---- | ---------- |
| mode | [DevicePowerMode](#devicepowermode9) | 是 | 电源模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------ | ------------------------------------------------------------ | | ------------------- | -------------------------------------- |
| Promise&lt;DevicePowerMode&gt; | Promise实例,用于异步获取返回值,[DevicePowerMode](#devicepowermode9)。 | | Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[系统电源管理错误码](../errorcodes/errorcode-power.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 链接服务失败。 |
**示例:** **示例:**
```js ```js
power.getPowerMode() power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE)
.then(mode => { .then(() => {
console.info('power mode is ' + mode); console.info('set power mode to MODE_PERFORMANCE');
})
.catch(error => {
console.log('error: ' + error);
}) })
.catch(err => {
console.error('set power mode failed, err: ' + err);
});
``` ```
## power.setPowerMode<sup>9+</sup> ## power.rebootDevice<sup>(deprecated)</sup>
setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void rebootDevice(reason: string): void
设置当前设备的电源模式 > 从API version 9开始不再维护,建议使用[power.reboot](#powerreboot9)替代
此接口为系统接口,三方应用不支持调用 重启设备
**需要权限:** ohos.permission.POWER_OPTIMIZATION **需要权限:** ohos.permission.REBOOT
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------ | | ------ | ------ | ---- | ----- |
| mode | [DevicePowerMode](#devicepowermode9) | 是 | 电源模式。 | | reason | string | 是 | 重启原因。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 指定的callback回调方法。 |
**示例:** **示例:**
```js ```js
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, error => { power.rebootDevice('reboot_test');
if (typeof error === "undefined") {
console.info('set power mode to MODE_PERFORMANCE');
} else {
console.log('error: ' + error);
}
})
``` ```
## power.isScreenOn<sup>(deprecated)</sup>
## power.setPowerMode<sup>9+</sup> isScreenOn(callback: AsyncCallback&lt;boolean&gt;): void
setPowerMode(mode: DevicePowerMode): Promise&lt;void&gt;
设置当前设备的电源模式。
此接口为系统接口,三方应用不支持调用 > 从API version 9开始不再维护,建议使用[power.isActive](#powerisactive9)替代
**需要权限:** ohos.permission.POWER_OPTIMIZATION 检测当前设备的亮灭屏状态。使用callback异步回调。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------------ | ---- | ---------- | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| mode | [DevicePowerMode](#devicepowermode9) | 是 | 电源模式。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当检测成功,err为undefined,data为获取到的亮灭屏状态,返回true表示梁平,返回false表示灭屏;否则为错误对象。 |
**返回值:** **示例:**
```js
power.isScreenOn((err, data) => {
if (typeof err === 'undefined') {
console.info('screen on status is ' + data);
} else {
console.error('check screen status failed, err: ' + err);
}
})
```
## power.isScreenOn<sup>(deprecated)</sup>
isScreenOn(): Promise&lt;boolean&gt;
> 从API version 9开始不再维护,建议使用[power.isActive](#powerisactive9)替代。
检测当前设备的亮灭屏状态。使用Promise异步回调。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
**返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------- | | ---------------------- | -------------------------------------------------- |
| Promise&lt;void&gt; | Promise实例。 | | Promise&lt;boolean&gt; | Promise对象。返回true表示亮屏;返回false表示灭屏。 |
**示例:** **示例:**
```js ```js
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) power.isScreenOn()
.then(() => { .then(data => {
console.info('set power mode to MODE_PERFORMANCE'); console.info('screen on status is ' + data);
}) })
.catch(error => { .catch(err => {
console.log('error: ' + error); console.error('check screen status failed, err: ' + err);
}) })
``` ```
...@@ -286,7 +375,6 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) ...@@ -286,7 +375,6 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE)
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| ----------------------- | ------ | ---------------------- | | ----------------------- | ------ | ---------------------- |
| MODE_NORMAL | 600 | 表示标准模式,默认值。 | | MODE_NORMAL | 600 | 表示标准模式,默认值。 |
......
...@@ -46,7 +46,7 @@ prompt.showToast({ ...@@ -46,7 +46,7 @@ prompt.showToast({
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 是 | 显示的文本信息。 | | message | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 是 | 显示的文本信息。 |
| duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 | | duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 |
| bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 | | bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 |
...@@ -147,8 +147,8 @@ prompt.showDialog({ ...@@ -147,8 +147,8 @@ prompt.showDialog({
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ---------------------------------------- | ---- | ---------------------------------------- | | ------- | ---------------------------------------- | ---- | ---------------------------------------- |
| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 否 | 标题文本。 | | title | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 否 | 标题文本。 |
| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 否 | 内容文本。 | | message | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 否 | 内容文本。 |
| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | | buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 |
## ShowDialogSuccessResponse ## ShowDialogSuccessResponse
...@@ -256,7 +256,7 @@ prompt.showActionMenu({ ...@@ -256,7 +256,7 @@ prompt.showActionMenu({
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ---------------------------------------- | ---- | ---------------------------------------- | | ------- | ---------------------------------------- | ---- | ---------------------------------------- |
| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 否 | 标题文本。 | | title | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 否 | 标题文本。 |
| buttons | Array&lt;[Button](#button)&gt; | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | | buttons | Array&lt;[Button](#button)&gt; | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 |
## ActionMenuSuccessResponse ## ActionMenuSuccessResponse
...@@ -277,6 +277,6 @@ prompt.showActionMenu({ ...@@ -277,6 +277,6 @@ prompt.showActionMenu({
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----- | ---------------------------------------- | ---- | ------- | | ----- | ---------------------------------------- | ---- | ------- |
| text | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 是 | 按钮文本内容。 | | text | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 是 | 按钮文本内容。 |
| color | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 是 | 按钮文本颜色。 | | color | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup> | 是 | 按钮文本颜色。 |
# Runninglock锁 # RunningLock锁
该模块主要提供Runninglock锁相关操作的接口,包括创建、查询、持锁、释放锁等操作。 该模块主要提供RunningLock锁相关操作的接口,包括创建、查询、持锁、释放锁等操作。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import runningLock from '@ohos.runningLock'; import runningLock from '@ohos.runningLock';
``` ```
## runningLock.isSupported<sup>9+</sup>
## RunningLockType isSupported(type: RunningLockType): boolean;
RunningLock锁的类型 查询系统是否支持该类型的锁
**系统能力:** 以下各项对应的系统能力均为SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
| 名称 | 默认值 | 描述 | **参数:**
| ------------------------ | ---- | ------------------- |
| BACKGROUND | 1 | 阻止系统休眠的锁。 |
| PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | 是 | 需要查询的锁的类型。 |
## isRunningLockTypeSupported **返回值:**
isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boolean&gt;): void | 类型 | 说明 |
| ------- | --------------------------------------- |
| boolean | 返回true表示支持,返回false表示不支持。 |
查询系统是否支持该类型的锁。 **错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:**
```js
try {
var isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND);
console.info('BACKGROUND type supported: ' + isSupported);
} catch(err) {
console.error('check supported failed, err: ' + err);
}
```
## runningLock.create<sup>9+</sup>
createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLock&gt;): void
创建RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**需要权限:** ohos.permission.RUNNING_LOCK
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | RunningLockType | 是 | 需要查询的锁的类型。 | | name | string | 是 | 锁的名字。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 指定的callback回调方法,用于获取返回值。<br/>callback返回值:支持返回true,不支持返回false。 | | type | [RunningLockType](#runninglocktype) | 是 | 要创建的锁的类型。 |
| callback | AsyncCallback<[RunningLock](#runninglock)> | 是 | 回调函数。当创建锁成功,err为undefined,data为创建的RunningLock;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|----------|
| 4900101 | 连接服务器失败。 |
**示例:** **示例:**
``` ```js
runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => { runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => {
if (typeof error === "undefined") { if (typeof err === 'undefined') {
console.info('BACKGROUND support status is ' + supported); console.info('created running lock: ' + lock);
} else { } else {
console.log('error: ' + error); console.error('create running lock failed, err: ' + err);
} }
});
```
## runningLock.create<sup>9+</sup>
createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&gt;
创建RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
**需要权限:** ohos.permission.RUNNING_LOCK
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | ------------------ |
| name | string | 是 | 锁的名字。 |
| type | [RunningLockType](#runninglocktype) | 是 | 要创建的锁的类型。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------ | ------------------------------------ |
| Promise&lt;[RunningLock](#runninglock)&gt; | Promise对象,返回RunningLock锁对象。 |
**错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|----------|
| 4900101 | 连接服务器失败。 |
**示例:**
```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => {
console.info('created running lock: ' + lock);
}) })
.catch(err => {
console.error('create running lock failed, error: ' + err);
});
``` ```
## runningLock.isRunningLockTypeSupported<sup>(deprecated)</sup>
## isRunningLockTypeSupported isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boolean&gt;): void
isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean&gt; > 从API version 9开始不再维护,建议使用[runningLock.isSupported](#runninglockissupported9)替代。
查询系统是否支持该类型的锁。 查询系统是否支持该类型的锁。使用callback异步回调。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | --------------- | ---- | ---------- | | -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| type | RunningLockType | 是 | 需要查询的锁的类型。 | | type | [RunningLockType](#runninglocktype) | 是 | 需要查询的锁的类型。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当查询成功,err为undefined,data为获取到的支持情况,返回true表示支持,返回false表示不支持;否则为错误对象。 |
**示例:**
```js
runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err, data) => {
if (typeof err === 'undefined') {
console.info('BACKGROUND lock support status: ' + data);
} else {
console.log('check BACKGROUND lock support status failed, err: ' + err);
}
});
```
## runningLock.isRunningLockTypeSupported<sup>(deprecated)</sup>
isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean>
> 从API version 9开始不再维护,建议使用[runningLock.isSupported](#runninglockissupported9)替代。
查询系统是否支持该类型的锁。使用Promise异步回调。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | 是 | 需要查询的锁的类型。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------- | ---------------------------------------- | | ---------------------- | ---------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于异步获取返回值,支持返回true,不支持返回false。 | | Promise&lt;boolean&gt; | Promise对象。返回true表示支持;返回false表示不支持。 |
**示例:** **示例:**
``` ```js
runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND)
.then(supported => { .then(data => {
console.info('PROXIMITY_SCREEN_CONTROL support status is ' + supported); console.info('BACKGROUND lock support status: ' + data);
}) })
.catch(error => { .catch(err => {
console.log('error: ' + error); console.log('check BACKGROUND lock support status failed, err: ' + err);
}); });
``` ```
## runningLock.createRunningLock<sup>(deprecated)</sup>
## createRunningLock
createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLock&gt;): void createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLock&gt;): void
> 从API version 9开始不再维护,建议使用[runningLock.create](#runninglockcreate9)替代。
创建RunningLock锁。 创建RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
...@@ -99,33 +209,30 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l ...@@ -99,33 +209,30 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------------------------- | | -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
| name | string | 是 | 锁的名字。 | | name | string | 是 | 锁的名字。 |
| type | RunningLockType | 是 | 要创建的锁的类型。 | | type | [RunningLockType](#runninglocktype) | 是 | 要创建的锁的类型。 |
| callback | AsyncCallback&lt;[RunningLock](#runninglock)&gt; | 是 | 指定的callback回调方法,用于获取返回的RunningLock锁对象。 | | callback | AsyncCallback<[RunningLock](#runninglock)> | 是 | 回调函数。当创建锁成功,err为undefined,data为创建的RunningLock;否则为错误对象。 |
**示例:** **示例:**
``` ```js
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND, (error, lockIns) => { runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => {
if (typeof error === "undefined") { if (typeof err === 'undefined') {
console.log('create runningLock test error: ' + error); console.info('created running lock: ' + lock);
} else { } else {
var used = lockIns.isUsed(); console.error('create running lock failed, err: ' + err);
console.info('runninglock is used: ' + used);
lockIns.lock(500);
used = lockIns.isUsed();
console.info('after lock runninglock is used ' + used);
} }
}) });
``` ```
## runningLock.createRunningLock<sup>(deprecated)</sup>
## createRunningLock
createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&gt; createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&gt;
创建Runninglock锁。 > 从API version 9开始不再维护,建议使用[runningLock.create](#runninglockcreate9)替代。
创建RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
...@@ -134,38 +241,156 @@ createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&g ...@@ -134,38 +241,156 @@ createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&g
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | --------------- | ---- | --------- | | ------ | ----------------------------------- | ---- | ------------------ |
| name | string | 是 | 锁的名字。 | | name | string | 是 | 锁的名字。 |
| type | RunningLockType | 是 | 要创建的锁的类型。 | | type | [RunningLockType](#runninglocktype) | 是 | 要创建的锁的类型。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------------------- | ---------------------------------- | | ------------------------------------------ | ------------------------------------ |
| Promise&lt;[RunningLock](#runninglock)&gt; | Promise实例,用于异步获取返回的RunningLock锁对象。 | | Promise&lt;[RunningLock](#runninglock)&gt; | Promise对象,返回RunningLock锁对象。 |
**示例:** **示例:**
```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => {
console.info('created running lock: ' + lock);
})
.catch(err => {
console.log('create running lock failed, err: ' + err);
});
``` ```
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
.then(runninglock => { ## RunningLock
console.info('create runningLock success');
阻止系统休眠的锁。
### hold<sup>9+</sup>
hold(timeout: number): void
锁定和持有RunningLock。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
**需要权限:** ohos.permission.RUNNING_LOCK
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ----------------------------------------- |
| timeout | number | 否 | 锁定和持有RunningLock的时长,单位:毫秒。 |
**错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|----------|
| 4900101 | 连接服务器失败。 |
**示例:**
```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => {
console.info('create running lock success');
try {
lock.hold(500);
console.info('hold running lock success');
} catch(err) {
console.error('hold running lock failed, err: ' + err);
}
}) })
.catch(error => { .catch(err => {
console.log('create runningLock test error: ' + error); console.error('create running lock failed, err: ' + err);
});
```
### unhold<sup>9+</sup>
unhold(): void
释放RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
**需要权限:** ohos.permission.RUNNING_LOCK
**错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|----------|
| 4900101 | 连接服务器失败。 |
**示例:**
```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => {
console.info('create running lock success');
try {
lock.unhold();
console.info('unhold running lock success');
} catch(err) {
console.error('unhold running lock failed, err: ' + err);
}
}) })
.catch(err => {
console.error('create running lock failed, err: ' + err);
});
``` ```
### isHolding<sup>9+</sup>
## RunningLock isHolding(): boolean
阻止系统休眠的锁 查询当前RunningLock是持有状态还是释放状态
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
### lock **返回值:**
| 类型 | 说明 |
| ------- | ------------------------------------------------------------ |
| boolean | 返回true表示当前RunningLock是持有状态,返回false表示当前RunningLock是释放状态。 |
**错误码:**
以下错误码的详细介绍请参见[RunningLock锁错误码](../errorcodes/errorcode-runninglock.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4900101 | 连接服务失败。 |
**示例:**
```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => {
console.info('create running lock success');
try {
var isHolding = lock.isHolding();
console.info('check running lock holding status: ' + isHolding);
} catch(err) {
console.error('check running lock holding status failed, err: ' + err);
}
})
.catch(err => {
console.error('create running lock failed, err: ' + err);
});
```
### lock<sup>(deprecated)</sup>
lock(timeout: number): void lock(timeout: number): void
> 从API version 9开始不再维护,建议使用[RunningLock.hold](#hold9)替代。
锁定和持有RunningLock。 锁定和持有RunningLock。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
...@@ -180,23 +405,24 @@ lock(timeout: number): void ...@@ -180,23 +405,24 @@ lock(timeout: number): void
**示例:** **示例:**
``` ```js
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(runningLock => { .then(lock => {
runningLock.lock(100) lock.lock(500);
console.info('create runningLock success') console.info('create running lock and lock success');
}) })
.catch(error => { .catch(err => {
console.log('create runningLock test error: ' + error) console.error('create running lock failed, err: ' + err);
}); });
``` ```
### unlock<sup>(deprecated)</sup>
### unlock
unlock(): void unlock(): void
释放Runninglock锁。 > 从API version 9开始不再维护,建议使用[RunningLock.unhold](#unhold9)替代。
释放RunningLock锁。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
...@@ -204,40 +430,52 @@ unlock(): void ...@@ -204,40 +430,52 @@ unlock(): void
**示例:** **示例:**
``` ```js
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(runningLock => { .then(lock => {
runningLock.unlock() lock.unlock();
console.info('create and unLock runningLock success') console.info('create running lock and unlock success');
}) })
.catch(error => { .catch(err => {
console.log('create runningLock test error: ' + error) console.error('create running lock failed, err: ' + err);
}); });
``` ```
### isUsed<sup>(deprecated)</sup>
### isUsed
isUsed(): boolean isUsed(): boolean
查询当前Runninglock是持有状态还是释放状态。 > 从API version 9开始不再维护,建议使用[RunningLock.isHolding](#isholding9)替代。
查询当前RunningLock是持有状态还是释放状态。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------- | | ------- | ------------------------------------------------------------ |
| boolean | 当前RunningLock是持有状态返回true,释放状态返回false。 | | boolean | 返回true表示当前RunningLock是持有状态,返回false表示当前RunningLock是释放状态。 |
**示例:** **示例:**
``` ```js
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(runningLock => { .then(lock => {
var used = runningLock.isUsed() var isUsed = lock.isUsed();
console.info('runningLock used status: ' + used) console.info('check running lock used status: ' + isUsed);
}) })
.catch(error => { .catch(err => {
console.log('runningLock isUsed test error: ' + error) console.error('check running lock used status failed, err: ' + err);
}); });
``` ```
## RunningLockType
RunningLock锁的类型。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core
| 名称 | 默认值 | 描述 |
| ------------------------ | ------ | -------------------------------------- |
| BACKGROUND | 1 | 阻止系统休眠的锁。 |
| PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 |
# 电量信息 # 电量信息
> **说明:** 该模块提供充电状态及剩余电量的查询功能。
> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.batteryInfo`](js-apis-battery-info.md)。
> > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 从API Version 6开始不再维护,建议使用[`@ohos.batteryInfo`](js-apis-battery-info.md)替代。
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -16,7 +17,7 @@ import battery from '@system.battery'; ...@@ -16,7 +17,7 @@ import battery from '@system.battery';
## battery.getStatus ## battery.getStatus
getStatus(Object): void getStatus(options?: GetStatusOptions): void;
获取设备当前的充电状态及剩余电量。 获取设备当前的充电状态及剩余电量。
...@@ -26,29 +27,35 @@ getStatus(Object): void ...@@ -26,29 +27,35 @@ getStatus(Object): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | (data: [BatteryResponse](#batteryresponse)) => void | 否 | 接口调用成功的回调函数。| | options | [GetStatusOptions](#getstatusoptions) | 否 | 包含接口调用结果的对象。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。|
| complete | () => void | 否 | 接口调用结束的回调函数。 |
**示例:** **示例:**
```js ```js
export default { battery.getStatus({
getStatus() {
battery.getStatus({
success: function(data) { success: function(data) {
console.log('success get battery level:' + data.level); console.log('success get battery level:' + data.level);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('fail to get battery level code:' + code + ', data: ' + data); console.error('fail to get battery level code:' + code + ', data: ' + data);
}, }
}); });
},
}
``` ```
## GetStatusOptions
包含接口调用结果的对象。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BatteryResponse](#batteryresponse)) => void | 否 | 接口调用成功的回调函数,data为[BatteryResponse](#batteryresponse)类型的返回值。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## BatteryResponse ## BatteryResponse
包含充电状态及剩余电量的对象。
| 参数名 | 类型 | 说明 | | 参数名 | 类型 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| charging | boolean | 当前电池是否在充电中。 | | charging | boolean | 当前电池是否在充电中。 |
......
# 屏幕亮度 # 屏幕亮度
> **说明:** 该模块提供屏幕亮度和模式的查询、调节接口。
> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.brightness`](js-apis-brightness.md)。
> > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 从API Version 7 开始不再维护,建议使用[`@ohos.brightness`](js-apis-brightness.md)替代。
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -16,7 +17,7 @@ import brightness from '@system.brightness'; ...@@ -16,7 +17,7 @@ import brightness from '@system.brightness';
## brightness.getValue ## brightness.getValue
getValue(Object): void getValue(options?: GetBrightnessOptions): void
获得设备当前的屏幕亮度值。 获得设备当前的屏幕亮度值。
...@@ -26,38 +27,25 @@ getValue(Object): void ...@@ -26,38 +27,25 @@ getValue(Object): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | 否 | 接口调用成功的回调函数。 | | options | [GetBrightnessOptions](#getbrightnessoptions) | 否 | 获取屏幕亮度的参数对象。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
success返回值:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| value | number | 屏幕亮度,取值为1-255之间的整数。 |
**示例:** **示例:**
```js ```js
export default {
getValue() {
brightness.getValue({ brightness.getValue({
success: function(data){ success: function(data) {
console.log('success get brightness value:' + data.value); console.log('success get brightness value:' + data.value);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('get brightness fail, code: ' + code + ', data: ' + data); console.error('get brightness fail, code: ' + code + ', data: ' + data);
},
});
},
} }
});
``` ```
## brightness.setValue ## brightness.setValue
setValue(Object): void etValue(options?: SetBrightnessOptions): void
设置设备当前的屏幕亮度值。 设置设备当前的屏幕亮度值。
...@@ -67,33 +55,26 @@ setValue(Object): void ...@@ -67,33 +55,26 @@ setValue(Object): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 屏幕亮度,值为1-255之间的整数。<br/>-&nbsp;如果值小于等于0,系统按1处理。<br/>-&nbsp;如果值大于255,系统按255处理。<br/>-&nbsp;如果值为小数,系统将处理为整数。例如设置为8.1,系统按8处理。 | | options | [SetBrightnessOptions](#setbrightnessoptions) | 否 | 设置屏幕亮度的参数对象。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
**示例:** **示例:**
```js ```js
export default {
setValue() {
brightness.setValue({ brightness.setValue({
value: 100, value: 100,
success: function(){ success: function() {
console.log('handling set brightness success.'); console.log('handling set brightness success.');
}, },
fail: function(data, code){ fail: function(data, code) {
console.log('handling set brightness value fail, code:' + code + ', data: ' + data); console.error('handling set brightness value fail, code:' + code + ', data: ' + data);
},
});
},
} }
});
``` ```
## brightness.getMode ## brightness.getMode
getMode(Object): void getMode(options?: GetBrightnessModeOptions: void
获得当前屏幕亮度模式。 获得当前屏幕亮度模式。
...@@ -103,37 +84,25 @@ getMode(Object): void ...@@ -103,37 +84,25 @@ getMode(Object): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | 否 | 接口调用成功的回调函数。 | | options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | 否 | 获取屏幕亮度模式的参数对象。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
success返回值:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| mode | number | 值为0或1:<br/>-&nbsp;0为手动调节屏幕亮度模式<br/>-&nbsp;1为自动调节屏幕亮度模式 |
**示例:** **示例:**
```js ```js
export default {
getMode() {
brightness.getMode({ brightness.getMode({
success: function(data){ success: function(data) {
console.log('success get mode:' + data.mode); console.log('success get mode:' + data.mode);
}, },
fail: function(data, code){ fail: function(data, code){
console.log('handling get mode fail, code:' + code + ', data: ' + data); console.error('handling get mode fail, code:' + code + ', data: ' + data);
},
});
},
} }
});
``` ```
## brightness.setMode ## brightness.setMode
setMode(Object): void setMode(options?: SetBrightnessModeOptions): void
设置设备当前的屏幕亮度模式。 设置设备当前的屏幕亮度模式。
...@@ -142,74 +111,118 @@ setMode(Object): void ...@@ -142,74 +111,118 @@ setMode(Object): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mode | number | 是 | 值为0或1<br/>-&nbsp;0为手动调节屏幕亮度。<br/>-&nbsp;1为自动调节屏幕亮度。 | | options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | 否 | 设置屏幕亮度模式的参数对象。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
**示例:** **示例:**
```js ```js
export default {
setMode() {
brightness.setMode({ brightness.setMode({
mode: 1, mode: 1,
success: function(){ success: function() {
console.log('handling set mode success.'); console.log('handling set mode success.');
}, },
fail: function(data, code){ fail: function(data, code) {
console.log('handling set mode fail, code:' + code + ', data: ' + data); console.error('handling set mode fail, code:' + code + ', data: ' + data);
},
});
},
} }
});
``` ```
## brightness.setKeepScreenOn ## brightness.setKeepScreenOn
setKeepScreenOn(Object): void setKeepScreenOn(options?: SetKeepScreenOnOptions): void
>从API version 7开始不再维护,建议使用[window.setKeepScreenOn](js-apis-window.md#setkeepscreenon)替代。
设置屏幕是否保持常亮状态,开启常亮模式推荐在onShow()阶段调用。 设置屏幕是否保持常亮状态,开启常亮模式推荐在onShow()阶段调用。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| keepScreenOn | boolean | 是 | 是否保持屏幕常亮。 | | options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | 否 | 设置屏幕常亮的参数对象。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
**示例:** **示例:**
```js ```js
export default {
setKeepScreenOn() {
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: function () { success: function () {
console.log('handling set keep screen on success.') console.log('handling set keep screen on success.');
}, },
fail: function (data, code) { fail: function (data, code) {
console.log('handling set keep screen on fail, code:' + code + ', data: ' + data); console.error('handling set keep screen on fail, code:' + code + ', data: ' + data);
},
});
},
} }
});
``` ```
## ## GetBrightnessOptions
获取屏幕亮度的参数对象。
| 名称 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | 否 | 接口调用成功的回调函数。data为[BrightnessResponse](#brightnessresponse)类型的返回值。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## SetBrightnessOptions
设置屏幕亮度的参数对象。
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| value | number | 是 | 屏幕亮度,值为1-255之间的整数。<br/>-&nbsp;如果值小于等于0,系统按1处理。<br/>-&nbsp;如果值大于255,系统按255处理。<br/>-&nbsp;如果值为小数,系统将处理为整数。例如设置为8.1,系统按8处理。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## BrightnessResponse ## BrightnessResponse
包含屏幕亮度的对象。
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| value | number | 屏幕亮度,取值为1-255之间的整数。 | | value | number | 屏幕亮度,范围:1到255。 |
## GetBrightnessModeOptions
获取屏幕亮度模式的参数对象。
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | 否 | 接口调用成功的回调函数。data为[BrightnessModeResponse](#brightnessmoderesponse)类型的返回值。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## SetBrightnessModeOptions
设置屏幕亮度模式的参数对象。
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
| mode | number | 是 | 0表示手动调节屏幕亮度模式,1表示自动调节屏幕亮度模式。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## BrightnessModeResponse ## BrightnessModeResponse
包含屏幕亮度模式的对象。
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| mode | number | 值为0或1。<br> -0为手动调节屏幕亮度模式。<br>-1为手动调节屏幕亮度模式。 | | mode | number | 0表示手动调节屏幕亮度模式,1表示自动调节屏幕亮度模式。 |
## SetKeepScreenOnOptions
设置屏幕常亮的参数对象。
| 名称 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
| keepScreenOn | boolean | 是 | true表示保持屏幕常亮,false表示取消屏幕常亮。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
...@@ -5,35 +5,121 @@ ...@@ -5,35 +5,121 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```js ```js
import thermal from '@ohos.thermal'; import thermal from '@ohos.thermal';
``` ```
## thermal.registerThermalLevelCallback<sup>9+</sup>
## ThermalLevel registerThermalLevelCallback(callback: Callback&lt;ThermalLevel&gt;): void
热档位信息 订阅热档位变化时的回调提醒
**系统能力:** 以下各项对应的系统能力均为SystemCapability.PowerManager.ThermalManager **系统能力:** SystemCapability.PowerManager.ThermalManager
| 名称 | 默认值 | 描述 | **参数:**
| ---------- | ---- | ---------------------------------------- |
| COOL | 0 | 表明设备处于低温的状态,业务执行不受热控的限制。 | | 参数名 | 类型 | 必填 | 说明 |
| NORMAL | 1 | 表明设备处于正常工作状态,但温度不低,需要注意是否临近发热状态 | | -------- | ---------------------------- | ---- | ------------------------------ |
| WARM | 2 | 表明设备已经进入温热状态,部分无感知业务需要考虑停止或延迟执行。 | | callback | Callback&lt;ThermalLevel&gt; | 是 | 回调函数,返回变化后的热档位。 |
| HOT | 3 | 表明设备已经明显发热,无感知业务应全面停止,其他业务应考虑降规格及负载。 |
| OVERHEATED | 4 | 表明设备已经发热严重,无感知业务应全面停止,主要业务需降低规格及负载。 | **错误码:**
| WARNING | 5 | 表明设备已经发热严重并且即将进入紧急状态,无感知业务应全面停止,主要业务应降低至最低规格。 |
| EMERGENCY | 6 | 表明设备已经进入紧急状态,所有业务应当全面停止工作,可保留部分紧急求助功能。 | 以下错误码的详细介绍请参见[耗电统计错误码](../errorcodes/errorcode-thermal.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4800101 | 连接服务失败。 |
**示例:**
```js
try {
thermal.registerThermalLevelCallback(level => {
console.info('thermal level is: ' + level);
});
console.info('register thermal level callback success.');
} catch(err) {
console.error('register thermal level callback failed, err: ' + err);
}
```
## thermal.unregisterThermalLevelCallback<sup>9+</sup>
unregisterThermalLevelCallback(callback?: Callback\<void>): void
取消订阅热档位变化时的回调提醒。
**系统能力:** SystemCapability.PowerManager.ThermalManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------------------------------- |
| callback | Callback&lt;void&gt; | 可选 | 回调函数,无返回值。不填该参数则取消所有回调。 |
**错误码:**
以下错误码的详细介绍请参见[热管理错误码](../errorcodes/errorcode-thermal.md)
## thermal.subscribeThermalLevel | 错误码ID | 错误信息 |
|---------|---------|
| 4800101 | 连接服务失败。 |
**示例:**
```js
try {
thermal.unregisterThermalLevelCallback(() => {
console.info('unsubscribe thermal level success.');
});
console.info('unregister thermal level callback success.');
} catch(err) {
console.error('unregister thermal level callback failed, err: ' + err);
}
```
## thermal.getLevel<sup>9+</sup>
getLevel(): ThermalLevel
获取当前热档位信息。
**系统能力:** SystemCapability.PowerManager.ThermalManager
**返回值:**
| 类型 | 说明 |
| ------------ | ------------ |
| ThermalLevel | 热档位信息。 |
**错误码:**
以下错误码的详细介绍请参见[热管理错误码](../errorcodes/errorcode-thermal.md)
| 错误码ID | 错误信息 |
|---------|---------|
| 4800101 | 连接服务失败。 |
**示例:**
```js
try {
var level = thermal.getLevel();
console.info('thermal level is: ' + level);
} catch(err) {
console.error('get thermal level failed, err: ' + err);
}
```
## thermal.subscribeThermalLevel<sup>(deprecated)</sup>
subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void
> 从API version 9开始不再维护,建议使用[thermal.registerThermalLevelCallback](#thermalregisterthermallevelcallback9)替代。
订阅热档位变化时的回调提醒。 订阅热档位变化时的回调提醒。
**系统能力:** SystemCapability.PowerManager.ThermalManager **系统能力:** SystemCapability.PowerManager.ThermalManager
...@@ -41,22 +127,23 @@ subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void ...@@ -41,22 +127,23 @@ subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------------------------- | | -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;ThermalLevel&gt; | 是 | 指定的callback回调方法,用于获取返回值。<br/>AsyncCallback只返回一个参数,为热档位信息,此时可能会产生告警,可通过`// @ts-ignore`进行抑制。 | | callback | AsyncCallback&lt;ThermalLevel&gt; | 是 | 回调函数。AsyncCallback只返回一个参数,为热档位信息,此时可能会产生告警,可通过`// @ts-ignore`进行抑制。 |
**示例:** **示例:**
```js ```js
var lev = 0; thermal.subscribeThermalLevel((level) => {
thermal.subscribeThermalLevel((lev) => { console.info('thermal level is: ' + level);
console.info("Thermal level is: " + lev); });
})
``` ```
## thermal.unsubscribeThermalLevel ## thermal.unsubscribeThermalLevel<sup>(deprecated)</sup>
unsubscribeThermalLevel(callback?: AsyncCallback\<void>): void unsubscribeThermalLevel(callback?: AsyncCallback\<void>): void
> 从API version 9开始不再维护,建议使用[thermal.unregisterThermalLevelCallback](#thermalunregisterthermallevelcallback9)替代。
取消订阅热档位变化时的回调提醒。 取消订阅热档位变化时的回调提醒。
**系统能力:** SystemCapability.PowerManager.ThermalManager **系统能力:** SystemCapability.PowerManager.ThermalManager
...@@ -64,21 +151,23 @@ unsubscribeThermalLevel(callback?: AsyncCallback\<void>): void ...@@ -64,21 +151,23 @@ unsubscribeThermalLevel(callback?: AsyncCallback\<void>): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | --------------------- | | -------- | ------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback&lt;void&gt; | 可选 | 指定的callback回调方法,无返回值。 | | callback | AsyncCallback&lt;void&gt; | 否 | 回调函数,无返回值。不填该参数则取消所有回调。 |
**示例:** **示例:**
```js ```js
thermal.unsubscribeThermalLevel(() => { thermal.unsubscribeThermalLevel(() => {
console.info("Unsubscribe completed."); console.info('unsubscribe thermal level success.');
}); });
``` ```
## thermal.getThermalLevel ## thermal.getThermalLevel<sup>(deprecated)</sup>
getThermalLevel(): ThermalLevel getThermalLevel(): ThermalLevel
> 从API version 9开始不再维护,建议使用[thermal.getLevel](#thermalgetlevel9)替代。
获取当前热档位信息。 获取当前热档位信息。
**系统能力:** SystemCapability.PowerManager.ThermalManager **系统能力:** SystemCapability.PowerManager.ThermalManager
...@@ -92,6 +181,22 @@ getThermalLevel(): ThermalLevel ...@@ -92,6 +181,22 @@ getThermalLevel(): ThermalLevel
**示例:** **示例:**
```js ```js
var lev = thermal.getThermalLevel(); var level = thermal.getThermalLevel();
console.info("Thermal level is: " + lev); console.info('thermal level is: ' + level);
``` ```
## ThermalLevel
热档位信息。
**系统能力:** SystemCapability.PowerManager.ThermalManager
| 名称 | 默认值 | 描述 |
| ---------- | ------ | ------------------------------------------------------------ |
| COOL | 0 | 表明设备处于低温的状态,业务执行不受热控的限制。 |
| NORMAL | 1 | 表明设备处于正常工作状态,但温度不低,需要注意是否临近发热状态 |
| WARM | 2 | 表明设备已经进入温热状态,部分无感知业务需要考虑停止或延迟执行。 |
| HOT | 3 | 表明设备已经明显发热,无感知业务应全面停止,其他业务应考虑降规格及负载。 |
| OVERHEATED | 4 | 表明设备已经发热严重,无感知业务应全面停止,主要业务需降低规格及负载。 |
| WARNING | 5 | 表明设备已经发热严重并且即将进入紧急状态,无感知业务应全面停止,主要业务应降低至最低规格。 |
| EMERGENCY | 6 | 表明设备已经进入紧急状态,所有业务应当全面停止工作,可保留部分紧急求助功能。 |
...@@ -23,6 +23,99 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要 ...@@ -23,6 +23,99 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest' import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'
``` ```
## MatchPattern
控件属性支持的匹配模式。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 值 | 说明 |
| ----------- | ---- | -------------- |
| EQUALS | 0 | 等于给定值。 |
| CONTAINS | 1 | 包含给定值。 |
| STARTS_WITH | 2 | 以给定值开始。 |
| ENDS_WITH | 3 | 以给定值结束。 |
## ResizeDirection<sup>9+</sup>
窗口调整大小的方向。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 说明 |
| ---------- | -------- |
| LEFT | 左方。 |
| RIGHT | 右方。 |
| UP | 上方。 |
| DOWN | 下方。 |
| LEFT_UP | 左上方。 |
| LEFT_DOWN | 左下方。 |
| RIGHT_UP | 右上方。 |
| RIGHT_DOWN | 右下方。 |
## Point<sup>9+</sup>
坐标点信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ---- | -------- | ---- | ---- | ---------------- |
| X | number | 是 | 否 | 坐标点的横坐标。 |
| Y | number | 是 | 否 | 坐标点的纵坐标。 |
## Rect<sup>9+</sup>
控件的边框信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ------- | -------- | ---- | ---- | ------------------------- |
| leftX | number | 是 | 否 | 控件边框的左上角的X坐标。 |
| topY | number | 是 | 否 | 控件边框的左上角的Y坐标。 |
| rightX | number | 是 | 否 | 控件边框的右下角的X坐标。 |
| bottomY | number | 是 | 否 | 控件边框的右下角的Y坐标。 |
## WindowMode<sup>9+</sup>
**系统能力**:SystemCapability.Test.UiTest
窗口的窗口模式。
| 名称 | 说明 |
| ---------- | ---------- |
| FULLSCREEN | 全屏模式。 |
| PRIMARY | 主窗口。 |
| SECONDARY | 第二窗口。 |
| FLOATING | 浮动窗口。 |
## DisplayRotation<sup>9+</sup>
**系统能力**:SystemCapability.Test.UiTest
设备显示器的显示方向。
| 名称 | 说明 |
| ------------ | ---------------------------------------- |
| ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 |
| ROTATION_90 | 设备显示器顺时针旋转90°,水平显示。 |
| ROTATION_180 | 设备显示器顺时针旋转180°,逆向垂直显示。 |
| ROTATION_270 | 设备显示器顺时针旋转270°,逆向水平显示。 |
## WindowFilter<sup>9+</sup>
窗口的标志属性信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 必填 | 可读 | 可写 | 描述 |
| ---------- | -------- | ---- | ---- | ---- | -------------------------- |
| bundleName | string | 否 | 是 | 否 | 窗口归属应用的包名。 |
| title | string | 否 | 是 | 否 | 窗口的标题信息。 |
| focused | boolean | 否 | 是 | 否 | 窗口是否处于获焦状态。 |
| actived | boolean | 否 | 是 | 否 | 窗口是否正与用户进行交互。 |
## On<sup>9+</sup> ## On<sup>9+</sup>
UiTest框架在API9中,通过On类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。<br> UiTest框架在API9中,通过On类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。<br>
...@@ -597,15 +690,15 @@ async function demo() { ...@@ -597,15 +690,15 @@ async function demo() {
getBoundsCenter(): Promise\<Point> getBoundsCenter(): Promise\<Point>
获取控件对象的中心点信息。 获取控件对象所占区域的中心点信息。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------- | --------------------------------------- | | -------------------------- | ----------------------------------------------- |
| Promise\<[Point](#point9)> | 以Promise形式返回控件对象的中心点信息。 | | Promise\<[Point](#point9)> | 以Promise形式返回控件对象所占区域的中心点信息。 |
**错误码:** **错误码:**
...@@ -630,7 +723,7 @@ async function demo() { ...@@ -630,7 +723,7 @@ async function demo() {
isClickable(): Promise\<boolean> isClickable(): Promise\<boolean>
获取控件对象可点击状态 获取控件对象可点击属性
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -638,7 +731,7 @@ isClickable(): Promise\<boolean> ...@@ -638,7 +731,7 @@ isClickable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回控件对象可点击状态,true:可点击,false:不可点击。 | | Promise\<boolean> | 以Promise形式返回控件对象是否可点击,true:可点击,false:不可点击。 |
**错误码:** **错误码:**
...@@ -668,7 +761,7 @@ async function demo() { ...@@ -668,7 +761,7 @@ async function demo() {
isLongClickable(): Promise\<boolean> isLongClickable(): Promise\<boolean>
获取控件对象可长按点击状态 获取控件对象可长按点击属性
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -676,7 +769,7 @@ isLongClickable(): Promise\<boolean> ...@@ -676,7 +769,7 @@ isLongClickable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回控件对象能否长按点击状态,true:可长按点击,false:不可长按点击。 | | Promise\<boolean> | 以Promise形式返回控件对象是否可安装点击,true:可长按点击,false:不可长按点击。 |
**错误码:** **错误码:**
...@@ -744,7 +837,7 @@ async function demo() { ...@@ -744,7 +837,7 @@ async function demo() {
isCheckable(): Promise\<boolean> isCheckable(): Promise\<boolean>
获取控件对象能否被勾选属性。 获取控件对象能否被勾选属性。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -752,7 +845,7 @@ isCheckable(): Promise\<boolean> ...@@ -752,7 +845,7 @@ isCheckable(): Promise\<boolean>
| 错误码ID | 错误码信息 | | 错误码ID | 错误码信息 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回控件对象能否被勾选的属性,true:可被勾选,false:不可被勾选。 | | Promise\<boolean> | 以Promise形式返回控件对象能否可被勾选属性,true:可被勾选,false:不可被勾选。 |
**错误码:** **错误码:**
...@@ -782,7 +875,7 @@ async function demo() { ...@@ -782,7 +875,7 @@ async function demo() {
isScrollable(): Promise\<boolean> isScrollable(): Promise\<boolean>
获取控件对象可滑动状态 获取控件对象可滑动属性
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -790,7 +883,7 @@ isScrollable(): Promise\<boolean> ...@@ -790,7 +883,7 @@ isScrollable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回控件对象可滑动状态,true:可滑动,false:不可滑动。 | | Promise\<boolean> | 以Promise形式返回控件对象是否可滑动,true:可滑动,false:不可滑动。 |
**错误码:** **错误码:**
...@@ -860,7 +953,7 @@ async function demo() { ...@@ -860,7 +953,7 @@ async function demo() {
isFocused(): Promise\<boolean> isFocused(): Promise\<boolean>
判断控件对象是否获焦 判断控件对象获焦状态
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -868,7 +961,7 @@ isFocused(): Promise\<boolean> ...@@ -868,7 +961,7 @@ isFocused(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回控件对象是否获焦,true:获焦,false:未获焦。 | | Promise\<boolean> | 以Promise形式返回控件对象获焦状态,true:获焦,false:未获焦。 |
**错误码:** **错误码:**
...@@ -905,8 +998,8 @@ isSelected(): Promise\<boolean> ...@@ -905,8 +998,8 @@ isSelected(): Promise\<boolean>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ----------------------------------------------------- | | ----------------- | --------------------------------------------------- |
| Promise\<boolean> | 控件对象被选中状态,true:被选中,false:未被选中。 | | Promise\<boolean> | 控件对象被选中状态,true:被选中,false:未被选中。 |
**错误码:** **错误码:**
...@@ -943,8 +1036,8 @@ inputText(text: string): Promise\<void> ...@@ -943,8 +1036,8 @@ inputText(text: string): Promise\<void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------- | | ------ | ------ | ---- | ---------------------------------------- |
| text | string | 是 | 输入的文本信息。 | | text | string | 是 | 输入的文本信息,当前支持英文和特殊字符。 |
**错误码:** **错误码:**
...@@ -994,7 +1087,7 @@ async function demo() { ...@@ -994,7 +1087,7 @@ async function demo() {
scrollSearch(on: ON): Promise\<Component> scrollSearch(on: ON): Promise\<Component>
在控件上滑动查找目标控件(适用于List等支持滑动的控件)。 在控件上滑动查找目标控件(适用支持滑动的控件)。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1033,7 +1126,7 @@ async function demo() { ...@@ -1033,7 +1126,7 @@ async function demo() {
scrollToTop(speed?: number): Promise\<void> scrollToTop(speed?: number): Promise\<void>
在控件上滑动到顶部(适用于List等支持滑动的控件)。 在控件上滑动到顶部(适用支持滑动的控件)。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1066,7 +1159,7 @@ async function demo() { ...@@ -1066,7 +1159,7 @@ async function demo() {
scrollToBottom(speed?: number): Promise\<void> scrollToBottom(speed?: number): Promise\<void>
在控件上滑动到底部(适用于List等支持滑动的控件)。 在控件上滑动到底部(适用支持滑动的控件)。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1197,8 +1290,8 @@ async function demo() { ...@@ -1197,8 +1290,8 @@ async function demo() {
## Driver<sup>9+</sup> ## Driver<sup>9+</sup>
UiTest框架在API9中,Driver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等API Driver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能力
该类提供的方法除Driver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await调用。 该类提供的方法除Driver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await方式调用。
### create<sup>9+</sup> ### create<sup>9+</sup>
...@@ -1414,7 +1507,7 @@ async function demo() { ...@@ -1414,7 +1507,7 @@ async function demo() {
assertComponentExist(on: On): Promise\<void> assertComponentExist(on: On): Promise\<void>
断言API,用于断言当前界面存在满足给出的目标控件属性的控件。 断言API,用于断言当前界面是否存在满足给出的目标属性的控件。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1471,7 +1564,7 @@ async function demo() { ...@@ -1471,7 +1564,7 @@ async function demo() {
triggerKey(keyCode: number): Promise\<void> triggerKey(keyCode: number): Promise\<void>
Driver对象采取如下操作:通过key值找到对应键并点击 Driver对象采取如下操作:传入key值实现模拟点击对应按键的效果
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1502,7 +1595,7 @@ async function demo() { ...@@ -1502,7 +1595,7 @@ async function demo() {
triggerCombineKeys(key0: number, key1: number, key2?: number): Promise\<void> triggerCombineKeys(key0: number, key1: number, key2?: number): Promise\<void>
Driver对象通过给定的key值,找到对应组合键并点击。例如,Key值为(2072, 2019)时,Driver对象找到组合键并点击ctrl+c。 Driver对象通过给定的key值,找到对应组合键并点击。例如,Key值为(2072, 2019)时,Driver对象找到key值对应的组合键并点击,如ctrl+c。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1600,7 +1693,7 @@ async function demo() { ...@@ -1600,7 +1693,7 @@ async function demo() {
longClick(x: number, y: number): Promise\<void> longClick(x: number, y: number): Promise\<void>
Driver对象采取如下操作:在目标坐标点长按 Driver对象采取如下操作:在目标坐标点长按。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1632,7 +1725,7 @@ async function demo() { ...@@ -1632,7 +1725,7 @@ async function demo() {
swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\<void> swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\<void>
Driver对象采取如下操作:从给出的起始坐标点滑向给出的目的坐标点。 Driver对象采取如下操作:从起始坐标点滑向目的坐标点。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1667,7 +1760,7 @@ async function demo() { ...@@ -1667,7 +1760,7 @@ async function demo() {
drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\<void> drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\<void>
Driver对象采取如下操作:从给出的起始坐标点拖拽至给出的目的坐标点。 Driver对象采取如下操作:从起始坐标点拖拽至目的坐标点。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -1863,15 +1956,15 @@ async function demo() { ...@@ -1863,15 +1956,15 @@ async function demo() {
getDisplayDensity(): Promise\<Point> getDisplayDensity(): Promise\<Point>
获取当前设备屏幕的分辨率。 获取当前设备屏幕的分辨率。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------- | ------------------------------------------- | | -------------------------- | ----------------------------------------- |
| Promise\<[Point](#point9)> | 以Promise的形式返回当前设备屏幕的分辨率。 | | Promise\<[Point](#point9)> | 以Promise的形式返回当前设备屏幕的分辨率。 |
**错误码:** **错误码:**
...@@ -1894,7 +1987,7 @@ async function demo() { ...@@ -1894,7 +1987,7 @@ async function demo() {
wakeUpDisplay(): Promise\<void> wakeUpDisplay(): Promise\<void>
唤醒当前设备的屏幕 唤醒当前设备即设备亮屏
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -2024,14 +2117,14 @@ injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise\<bool ...@@ -2024,14 +2117,14 @@ injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise\<bool
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------- | ---- | ------------------------------------------------------------ |
| pointers | [PointerMatrix](#pointermatrix9) | 是 | 起始点的坐标。 | | pointers | [PointerMatrix](#pointermatrix9) | 是 | 滑动轨迹,包括操作手指个数和滑动坐标序列。 |
| speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | | speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ----------------------------------------- | | ----------------- | ------------------------------------- |
| Promise\<boolean> | 以Promise的形式返回植入操作是否成功完成。 | | Promise\<boolean> | 以Promise的形式返回操作是否成功完成。 |
**错误码:** **错误码:**
...@@ -2058,7 +2151,7 @@ async function demo() { ...@@ -2058,7 +2151,7 @@ async function demo() {
## PointerMatrix<sup>9+</sup> ## PointerMatrix<sup>9+</sup>
表示存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。 存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。
### create<sup>9+</sup> ### create<sup>9+</sup>
...@@ -2121,22 +2214,22 @@ async function demo() { ...@@ -2121,22 +2214,22 @@ async function demo() {
## UiWindow<sup>9+</sup> ## UiWindow<sup>9+</sup>
UiTest中,UiWindow类代表了UI界面上的一个窗口,提供窗口属性获取,窗口拖动、调整窗口大小等API UiWindow代表了UI界面上的一个窗口,提供窗口属性获取,窗口拖动、调整窗口大小等能力
该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 该类提供的所有方法都使用Promise方式作为异步方法,需使用await方式调用。
### getBundleName<sup>9+</sup> ### getBundleName<sup>9+</sup>
getBundleName(): Promise\<string> getBundleName(): Promise\<string>
获取窗口的包名信息。 获取窗口归属应用的包名信息。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------- | --------------------------------- | | ---------------- | ----------------------------------------- |
| Promise\<string> | 以Promise形式返回窗口的包名信息。 | | Promise\<string> | 以Promise形式返回窗口归属应用的包名信息。 |
**错误码:** **错误码:**
...@@ -2260,7 +2353,7 @@ async function demo() { ...@@ -2260,7 +2353,7 @@ async function demo() {
isFocused(): Promise\<boolean> isFocused(): Promise\<boolean>
判断窗口是否获焦 判断窗口是否处于获焦状态
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -2268,7 +2361,7 @@ isFocused(): Promise\<boolean> ...@@ -2268,7 +2361,7 @@ isFocused(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回窗口对象是否获,true:获焦,false:未获焦。 | | Promise\<boolean> | 以Promise形式返回窗口对象是否获取获焦状态,true:获焦,false:未获焦。 |
**错误码:** **错误码:**
...@@ -2293,7 +2386,7 @@ async function demo() { ...@@ -2293,7 +2386,7 @@ async function demo() {
isActived(): Promise\<boolean> isActived(): Promise\<boolean>
判断窗口是否为用户交互窗口。 判断窗口是否为用户正在交互窗口。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -2301,7 +2394,7 @@ isActived(): Promise\<boolean> ...@@ -2301,7 +2394,7 @@ isActived(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | 以Promise形式返回窗口对象是否为用户交互窗口,true:交互窗口,false:非交互窗口。 | | Promise\<boolean> | 以Promise形式返回窗口对象是否为用户正在交互窗口,true:交互窗口,false:非交互窗口。 |
**错误码:** **错误码:**
...@@ -2388,7 +2481,7 @@ async function demo() { ...@@ -2388,7 +2481,7 @@ async function demo() {
resize(wide: number, height: number, direction: ResizeDirection): Promise\<void> resize(wide: number, height: number, direction: ResizeDirection): Promise\<void>
根据传入的宽、高和调整方向来调整窗口的大小。适用于支持大小调整的窗口。 根据传入的宽、高和调整方向来调整窗口的大小。适用于支持调整大小的窗口。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -2424,7 +2517,7 @@ async function demo() { ...@@ -2424,7 +2517,7 @@ async function demo() {
split(): Promise\<void> split(): Promise\<void>
将窗口模式切换成分屏模式。适用于支持切屏操作的窗口。 将窗口模式切换成分屏模式。适用于支持切换分屏模式的窗口。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -2560,99 +2653,6 @@ async function demo() { ...@@ -2560,99 +2653,6 @@ async function demo() {
} }
``` ```
## MatchPattern
控件属性支持的匹配模式。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 值 | 说明 |
| ----------- | ---- | -------------- |
| EQUALS | 0 | 等于给定值。 |
| CONTAINS | 1 | 包含给定值。 |
| STARTS_WITH | 2 | 从给定值开始。 |
| ENDS_WITH | 3 | 以给定值结束。 |
## ResizeDirection<sup>9+</sup>
窗口调整大小的方向。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 说明 |
| ---------- | -------- |
| LEFT | 左方。 |
| RIGHT | 右方。 |
| UP | 上方。 |
| DOWN | 下方。 |
| LEFT_UP | 左上方。 |
| LEFT_DOWN | 左下方。 |
| RIGHT_UP | 右上方。 |
| RIGHT_DOWN | 右下方。 |
## Point<sup>9+</sup>
坐标点信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ---- | -------- | ---- | ---- | ---------------- |
| X | number | 是 | 否 | 坐标点的横坐标。 |
| Y | number | 是 | 否 | 坐标点的纵坐标。 |
## Rect<sup>9+</sup>
控件的边框信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ------- | -------- | ---- | ---- | ------------------------- |
| leftX | number | 是 | 否 | 控件边框的左上角的X坐标。 |
| topY | number | 是 | 否 | 控件边框的左上角的Y坐标。 |
| rightX | number | 是 | 否 | 控件边框的右下角的X坐标。 |
| bottomY | number | 是 | 否 | 控件边框的右下角的Y坐标。 |
## WindowMode<sup>9+</sup>
**系统能力**:SystemCapability.Test.UiTest
窗口的窗口模式。
| 名称 | 说明 |
| ---------- | ---------- |
| FULLSCREEN | 全屏模式。 |
| PRIMARY | 主窗口。 |
| SECONDARY | 第二窗口。 |
| FLOATING | 浮动窗口。 |
## DisplayRotation<sup>9+</sup>
**系统能力**:SystemCapability.Test.UiTest
设备显示器的显示方向。
| 名称 | 说明 |
| ------------ | ---------------------------------------- |
| ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 |
| ROTATION_90 | 设备显示器顺时针旋转90°,水平显示。 |
| ROTATION_180 | 设备显示器顺时针旋转180°,逆向垂直显示。 |
| ROTATION_270 | 设备显示器顺时针旋转270°,逆向水平显示。 |
## WindowFilter<sup>9+</sup>
窗口的标志属性信息。
**系统能力**:SystemCapability.Test.UiTest
| 名称 | 参数类型 | 必填 | 可读 | 可写 | 描述 |
| ---------- | -------- | ---- | ---- | ---- | -------------------------- |
| bundleName | string | 否 | 是 | 否 | 窗口对应的包名。 |
| title | string | 否 | 是 | 否 | 窗口的标题。 |
| focused | boolean | 否 | 是 | 否 | 窗口是否获焦。 |
| actived | boolean | 否 | 是 | 否 | 窗口是否正与用户进行交互。 |
## By<sup>(deprecated)</sup> ## By<sup>(deprecated)</sup>
UiTest框架通过By类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。<br> UiTest框架通过By类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。<br>
...@@ -2729,7 +2729,7 @@ id(id: number): By ...@@ -2729,7 +2729,7 @@ id(id: number): By
指定目标控件id属性,返回By对象自身。 指定目标控件id属性,返回By对象自身。
从API version9开始不再维护,被废弃。 从API version9开始废弃。
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -3051,7 +3051,7 @@ getId(): Promise\<number> ...@@ -3051,7 +3051,7 @@ getId(): Promise\<number>
获取控件对象的id值。 获取控件对象的id值。
从API version9开始不再维护,建议使用[getId<sup>9+</sup>](#getid9) 从API version9开始不再维护,被废弃
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
...@@ -3077,7 +3077,7 @@ getKey(): Promise\<string> ...@@ -3077,7 +3077,7 @@ getKey(): Promise\<string>
获取控件对象的key值。 获取控件对象的key值。
从API version9开始不再维护,被废弃。 从API version9开始不再维护,建议使用[getId<sup>9+</sup>](#getid9)
**系统能力**:SystemCapability.Test.UiTest **系统能力**:SystemCapability.Test.UiTest
......
...@@ -18,7 +18,7 @@ Refresh\(value: \{ refreshing: boolean, offset?: number&nbsp;|&nbsp;string , fr ...@@ -18,7 +18,7 @@ Refresh\(value: \{ refreshing: boolean, offset?: number&nbsp;|&nbsp;string , fr
| 参数 | 参数名 | 必填 | 参数描述 | | 参数 | 参数名 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| refreshing | boolean | 是 | 当前组件是否正在刷新。<br/>该参数支持[$$](../../ui/ts-syntactic-sugar.md)双向绑定变量。 | | refreshing | boolean | 是 | 当前组件是否正在刷新。<br/>该参数支持[$$](../../quick-start/arkts-restrictions-and-extensions.md#变量的双向绑定)双向绑定变量。 |
| offset | string&nbsp;\|&nbsp;number | 否 | 刷新组件静止时距离父组件顶部的距离。<br/>默认值:16,单位vp | | offset | string&nbsp;\|&nbsp;number | 否 | 刷新组件静止时距离父组件顶部的距离。<br/>默认值:16,单位vp |
| friction | number&nbsp;\|&nbsp;string | 否 | 下拉摩擦系数,取值范围为0到100。<br/>默认值:62<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 | | friction | number&nbsp;\|&nbsp;string | 否 | 下拉摩擦系数,取值范围为0到100。<br/>默认值:62<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
......
...@@ -18,7 +18,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut ...@@ -18,7 +18,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------------------- | ---------------------------------------- | ------------------------- | ---------------------- | | ---------------------- | ---------------------------------------- | ------------------------- | ---------------------- |
| builder | [CustomDialog](../../ui/ts-component-based-customdialog.md) | 是 | 自定义弹窗内容构造器。 | | builder | [CustomDialog](../../quick-start/arkts-dynamic-ui-elememt-building.md#customdialog) | 是 | 自定义弹窗内容构造器。 |
| cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层退出时的回调。 | | cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层退出时的回调。 |
| autoCancel | boolean | 否 | 是否允许点击遮障层退出。<br>默认值:true | | autoCancel | boolean | 否 | 是否允许点击遮障层退出。<br>默认值:true |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default | | alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default |
......
...@@ -213,5 +213,5 @@ ...@@ -213,5 +213,5 @@
| 名称 | 类型定义 | 描述 | | 名称 | 类型定义 | 描述 |
| ------------- | ---------------------- | ---------------------------------------- | | ------------- | ---------------------- | ---------------------------------------- |
| CustomBuilder | ()&nbsp;=&gt;&nbsp;any | 该方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](../../ui/ts-component-based-builder.md)。 | | CustomBuilder | ()&nbsp;=&gt;&nbsp;any | 该方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder)。 |
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| ---------- | ---------------------------- | ------------------------------------------ | | ---------- | ---------------------------- | ------------------------------------------ |
| visibility | [Visibility](ts-appendix-enums.md#visibility) | 控制当前组件显示或隐藏。注意,即使组件处于隐藏状态,在页面刷新时仍存在重新创建过程,因此当对性能有严格要求时建议使用[条件渲染](../../ui/ts-rending-control-syntax-if-else.md)代替。<br>默认值:Visibility.Visible| | visibility | [Visibility](ts-appendix-enums.md#visibility) | 控制当前组件显示或隐藏。注意,即使组件处于隐藏状态,在页面刷新时仍存在重新创建过程,因此当对性能有严格要求时建议使用[条件渲染](../../quick-start/arkts-rendering-control.md#条件渲染)代替。<br>默认值:Visibility.Visible|
## 示例 ## 示例
......
# 无障碍子系统错误码
## 9300001 输入无效的包名称或者Ability名称
**错误信息**
Invalid bundle name or ability name.
**错误描述**
当输入的包名称或者Ability名称无效时,方法将返回该错误码。
**可能原因**
该错误码表示输入无效的包名称或者Ability名称,可能原因如下:
1. 包名称不存在。
2. 包里面没有对应的Ability。
**处理步骤**
1. 检查包名称是否正确。
2. 检查包名对应的Ability是否正确。
## 9300002 目标Ability已启用
**错误信息**
Target ability already enabled.
**错误描述**
当目标Ability已启用时,方法将返回该错误码。
**可能原因**
该错误码表示目标Ability已启用,可能原因是目标Ability已经启用,无法再次启用。
**处理步骤**
1. 停止该目标Ability。
2. 重新启用该目标Ability。
## 9300003 不具备执行该操作的无障碍权限
**错误信息**
Do not have accessibility right for this operation.
**错误描述**
当应用执行了用户在启用无障碍扩展应用时没有开启的辅助操作时,方法将返回该错误码。
**可能原因**
该错误码表示应用不具备该操作的无障碍权限,可能原因是应用执行了用户在启用无障碍扩展应用时没有开启的辅助操作。
**处理步骤**
1. 尝试向用户提示请求执行无障碍辅助操作的必要性,并获取用户授权。
2. 重新启用无障碍扩展应用,并开启所需的辅助操作。
## 9300004 属性不存在
**错误信息**
This property does not exist.
**错误描述**
当输入无障碍节点元素中不存在的属性时,方法将返回该错误码。
**可能原因**
该错误码表示输入了无效的无障碍节点元素的属性,可能原因是无障碍节点元素中不存在该属性。
**处理步骤**
检查无障碍节点元素中是否存在该属性。
## 9300005 不支持该操作
**错误信息**
This action is not supported.
**错误描述**
当应用执行无障碍节点元素不支持的操作时,方法将返回该错误码。
**可能原因**
该错误码表示执行了无障碍节点元素不支持的操作,可能原因是无障碍节点元素不支持执行该操作。
**处理步骤**
确认该无障碍节点元素支持的操作列表中是否包含该操作。
\ No newline at end of file
# 耗电统计错误码
## 4600101 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
1. 系统服务停止运行。
2. 系统服务内部通讯发生异常。
**处理步骤**
检查系统服务是否正常运行。
1. 在控制台中输入如下命令,查看当前的系统服务列表。
```bash
> hdc shell hidumper -ls
```
2. 查看系统服务列表中是否包含BatteryStatisticsService系统服务。
# 屏幕亮度错误码
## 4700101 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
1. 系统服务停止运行。
2. 系统服务内部通讯发生异常。
**处理步骤**
检查系统服务是否正常运行。
1. 在控制台中输入如下命令,查看当前的系统服务列表。
```bash
> hdc shell hidumper -ls
```
2. 查看系统服务列表中是否包含DisplayPowerManagerService系统服务。
# 系统电源管理错误码
## 4900101 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
1. 系统服务停止运行。
2. 系统服务内部通讯发生异常。
**处理步骤**
检查系统服务是否正常运行。
1. 在控制台中输入如下命令,查看当前的系统服务列表。
```bash
> hdc shell hidumper -ls
```
2. 查看系统服务列表中是否包含PowerManagerService系统服务。
## 4900102 正在关机中
**错误信息**
Operation failed. System is shutting down.
**错误描述**
操作失败,系统正在关机。
**可能原因**
系统正在处于关机过程中。
**处理步骤**
在系统正常运行的状态下进行操作。
# RunningLock锁错误码
## 4900101 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
1. 系统服务停止运行。
2. 系统服务内部通讯发生异常。
**处理步骤**
检查系统服务是否正常运行。
1. 在控制台中输入如下命令,查看当前的系统服务列表。
```bash
> hdc shell hidumper -ls
```
2. 查看系统服务列表中是否包含PowerManagerService系统服务。
# 热管理错误码
## 4800101 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
1. 系统服务停止运行。
2. 系统服务内部通讯发生异常。
**处理步骤**
检查系统服务是否正常运行。
1. 在控制台中输入如下命令,查看当前的系统服务列表。
```bash
> hdc shell hidumper -ls
```
2. 查看系统服务列表中是否包含ThermalService系统服务。
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## 组件和装饰器 ## 组件和装饰器
在声明式UI中,所有的页面都是由组件构成。组件的数据结构为struct,装饰器[@Component](../ui/ts-component-based-component.md)是组件化的标志。用@Component修饰的struct表示这个结构体有了组件化的能力。 在声明式UI中,所有的页面都是由组件构成。组件的数据结构为struct,装饰器@Component是组件化的标志。用@Component修饰的struct表示这个结构体有了组件化的能力。
自定义组件的声明方式为: 自定义组件的声明方式为:
...@@ -22,7 +22,7 @@ interface Builder { ...@@ -22,7 +22,7 @@ interface Builder {
} }
``` ```
[@Entry](../ui/ts-component-based-entry.md)修饰的Component表示该Component是页面的总入口,也可以理解为页面的根节点。值得注意的是,一个页面有且仅能有一个@Entry,只有被@Entry修饰的组件或者其子组件,才会在页面上显示。 @Entry修饰的Component表示该Component是页面的总入口,也可以理解为页面的根节点。值得注意的是,一个页面有且仅能有一个@Entry,只有被@Entry修饰的组件或者其子组件,才会在页面上显示。
@Component和@Entry都是基础且十分重要的装饰器。简单地理解,装饰器就是某一种修饰,给被装饰的对象赋予某一种能力,比如@Entry就是页面入口的能力,@Component就是组件化能力。 @Component和@Entry都是基础且十分重要的装饰器。简单地理解,装饰器就是某一种修饰,给被装饰的对象赋予某一种能力,比如@Entry就是页面入口的能力,@Component就是组件化能力。
......
**标准系统方案之瑞芯微RK3568移植案例** # 标准系统方案之瑞芯微RK3568移植案例
本文章是基于瑞芯微RK3568芯片的DAYU200开发板,进行标准系统相关功能的移植,主要包括产品配置添加,内核启动、升级,音频ADM化,Camera,TP,LCD,WIFI,BT,vibrator、sensor、图形显示模块的适配案例总结,以及相关功能的适配。 ​本文章是基于瑞芯微RK3568芯片的DAYU200开发板,进行标准系统相关功能的移植,主要包括产品配置添加,内核启动、升级,音频ADM化,Camera,TP,LCD,WIFI,BT,vibrator、sensor、图形显示模块的适配案例总结,以及相关功能的适配。
## 产品配置和目录规划 ## 产品配置和目录规划
...@@ -212,7 +212,7 @@ init相关配置请参考[启动子系统的规范要求](https://gitee.com/open ...@@ -212,7 +212,7 @@ init相关配置请参考[启动子系统的规范要求](https://gitee.com/open
ADM结构框图如下,Audio Peripheral Drivers和Platform Drivers为平台适配需要完成的工作。 ADM结构框图如下,Audio Peripheral Drivers和Platform Drivers为平台适配需要完成的工作。
<img src="figures/dayu200/dayu200-audio-03.png" alt="dayu200-audio-03.png" style="zoom: 50%;" /> ![dayu200-audio-03.png](figures/dayu200/dayu200-audio-03.png)
结合第1步梳理出来的Audio结构分析,Audio Peripheral Drivers包含Rk809的驱动,Platform Drivers包含DMA驱动和I2S驱动。 结合第1步梳理出来的Audio结构分析,Audio Peripheral Drivers包含Rk809的驱动,Platform Drivers包含DMA驱动和I2S驱动。
...@@ -1085,7 +1085,7 @@ product.gni中指定了chipset_build_deps camera_device_manager_deps 和 camera_ ...@@ -1085,7 +1085,7 @@ product.gni中指定了chipset_build_deps camera_device_manager_deps 和 camera_
#### 框架适配介绍 #### 框架适配介绍
<img src="figures/dayu200/dayu200-camera-01.png" alt="img" style="zoom:67%;" /> ![dayu200-camera-01.png](figures/dayu200/dayu200-camera-01.png)
以V4l2为例,pipeline的连接方式是在HCS配置文件中配置连接,数据源我们称之为SourceNode,主要包括硬件设备的控制、数据流的轮转等。 以V4l2为例,pipeline的连接方式是在HCS配置文件中配置连接,数据源我们称之为SourceNode,主要包括硬件设备的控制、数据流的轮转等。
...@@ -1883,7 +1883,8 @@ struct v4l2_buffer { ...@@ -1883,7 +1883,8 @@ struct v4l2_buffer {
- InputController:提供input设备的业务控制接口,包括获取器件信息及设备类型、设置电源状态等。 - InputController:提供input设备的业务控制接口,包括获取器件信息及设备类型、设置电源状态等。
**图 1** INPUT模块HDI接口层框架图 **图 1** INPUT模块HDI接口层框架图
<img src="figures/dayu200/dayu200-tp-01.png" alt="dayu200-tp-01.png" style="zoom: 67%;" />
![dayu200-tp-01.png](figures/dayu200/dayu200-tp-01.png)
相关目录下源代码目录结构如下所示 相关目录下源代码目录结构如下所示
...@@ -1922,7 +1923,7 @@ tp驱动的适配依赖hdf的input模型,hdf的input模型提供了TP,KEY, ...@@ -1922,7 +1923,7 @@ tp驱动的适配依赖hdf的input模型,hdf的input模型提供了TP,KEY,
从功能的角度看hdf input模块的框架如下: 从功能的角度看hdf input模块的框架如下:
<img src="figures/dayu200/dayu200-tp-02.png" alt="tp" style="zoom: 50%;" /> ![dayu200-tp-02.png](figures/dayu200/dayu200-tp-02.png)
因为hdf input模型的高度抽象集成,TP驱动的适配驱动主要涉及器件驱动层的适配。 因为hdf input模型的高度抽象集成,TP驱动的适配驱动主要涉及器件驱动层的适配。
...@@ -2294,7 +2295,7 @@ device4 :: deviceNode { ...@@ -2294,7 +2295,7 @@ device4 :: deviceNode {
基于HDF框架开发的 背光驱动模型 基于HDF框架开发的 背光驱动模型
<img src="figures/dayu200/dayu200-backlight-01.png" style="zoom:80%;" /> ![dayu200-backlight-01.png](figures/dayu200/dayu200-backlight-01.png)
rk3568背光是通过pwm控制占空比实现的,具体使用的是pwm4 rk3568背光是通过pwm控制占空比实现的,具体使用的是pwm4
...@@ -2398,7 +2399,7 @@ static struct BacklightOps g_blDevOps = { ...@@ -2398,7 +2399,7 @@ static struct BacklightOps g_blDevOps = {
其实使用的就是HDF PWM 实现的对接内核pwm的接口 其实使用的就是HDF PWM 实现的对接内核pwm的接口
<img src="figures/dayu200/dayu200-backlight-02.png" style="zoom:80%;" /> ![dayu200-backlight-02.png](figures/dayu200/dayu200-backlight-02.png)
在LCD HDF器件驱动注册背光 在LCD HDF器件驱动注册背光
...@@ -2493,7 +2494,7 @@ HDF WiFi框架总体框架图 ...@@ -2493,7 +2494,7 @@ HDF WiFi框架总体框架图
#### 驱动模块初始化流程分析 #### 驱动模块初始化流程分析
<img src="figures/dayu200/dayu200-wifi-02.png" alt="dayu200-wifi-02.png" style="zoom: 67%;" /> ![dayu200-wifi-02.png](figures/dayu200/dayu200-wifi-02.png)
Ap6275s 是一款SDIO设备WiFi模组驱动,使用标准Linux的SDIO设备驱动。内核模块初始化入口module_init()调用dhd_wifi_platform_load_sdio()函数进行初始化工作,这里调用wifi_platform_set_power()进行GPIO上电,调用dhd_wlan_set_carddetect()进行探测SDIO设备卡,最后调用sdio_register_driver(&bcmsdh_sdmmc_driver);进行SDIO设备驱动的注册,SDIO总线已经检测到WiFi模块设备 根据设备号和厂商号与该设备驱动匹配, 所以立即回调该驱动的bcmsdh_sdmmc_probe()函数,这里进行WiFi模组芯片的初始化工作,最后创建net_device网络接口wlan0,然后注册到Linux内核协议栈中。 Ap6275s 是一款SDIO设备WiFi模组驱动,使用标准Linux的SDIO设备驱动。内核模块初始化入口module_init()调用dhd_wifi_platform_load_sdio()函数进行初始化工作,这里调用wifi_platform_set_power()进行GPIO上电,调用dhd_wlan_set_carddetect()进行探测SDIO设备卡,最后调用sdio_register_driver(&bcmsdh_sdmmc_driver);进行SDIO设备驱动的注册,SDIO总线已经检测到WiFi模块设备 根据设备号和厂商号与该设备驱动匹配, 所以立即回调该驱动的bcmsdh_sdmmc_probe()函数,这里进行WiFi模组芯片的初始化工作,最后创建net_device网络接口wlan0,然后注册到Linux内核协议栈中。
...@@ -2557,7 +2558,7 @@ HDF WLAN驱动框架由Module、NetDevice、NetBuf、BUS、HAL、Client 和 Mess ...@@ -2557,7 +2558,7 @@ HDF WLAN驱动框架由Module、NetDevice、NetBuf、BUS、HAL、Client 和 Mess
代码流程框图如下: 代码流程框图如下:
<img src="figures/dayu200/dayu200-wifi-03.png" alt="dayu200-wifi-03.png" style="zoom: 67%;" /> ![dayu200-wifi-03.png](figures/dayu200/dayu200-wifi-03.png)
代码位于device/hihope/rk3568/wifi/bcmdhd_wifi6/hdf_driver_bdh_register.c 代码位于device/hihope/rk3568/wifi/bcmdhd_wifi6/hdf_driver_bdh_register.c
...@@ -2801,7 +2802,7 @@ p2p-p2p0-0 Link encap:Ethernet HWaddr 12:2c:6b:11:21:e0 Driver bcmsdh_sdmmc ...@@ -2801,7 +2802,7 @@ p2p-p2p0-0 Link encap:Ethernet HWaddr 12:2c:6b:11:21:e0 Driver bcmsdh_sdmmc
蓝牙整体硬件架构上分为主机(计算机或MCU)和主机控制器(实际蓝牙芯片组)两部分;主机和控制器之间的通信遵循主机控制器接口(HCI),如下所示: 蓝牙整体硬件架构上分为主机(计算机或MCU)和主机控制器(实际蓝牙芯片组)两部分;主机和控制器之间的通信遵循主机控制器接口(HCI),如下所示:
<img src="figures/dayu200/dayu200-bt-01.png" style="zoom: 33%;" /> ![dayu200-bt-01.png](figures/dayu200/dayu200-bt-01.png)
HCI定义了如何交换命令,事件,异步和同步数据包。异步数据包(ACL)用于数据传输,而同步数据包(SCO)用于带有耳机和免提配置文件的语音。 HCI定义了如何交换命令,事件,异步和同步数据包。异步数据包(ACL)用于数据传输,而同步数据包(SCO)用于带有耳机和免提配置文件的语音。
...@@ -3148,7 +3149,7 @@ void hw_process_event(HC_BT_HDR *p_buf) ...@@ -3148,7 +3149,7 @@ void hw_process_event(HC_BT_HDR *p_buf)
基于HDF(Hardware Driver Foundation)驱动框架开发的Sensor驱动模型 基于HDF(Hardware Driver Foundation)驱动框架开发的Sensor驱动模型
<img src="figures/dayu200/dayu200-sensor-01.png" style="zoom: 80%;" /> ![dayu200-sensor-01.png](figures/dayu200/dayu200-sensor-01.png)
rk3568 支持accel sensor,整体的驱动框架openharmony 主线已经具备,只需要实现具体的器件驱动即可。 rk3568 支持accel sensor,整体的驱动框架openharmony 主线已经具备,只需要实现具体的器件驱动即可。
...@@ -3383,7 +3384,7 @@ Vibrator驱动模型主要包含Vibrator(传感器)相关的HDI接口与实 ...@@ -3383,7 +3384,7 @@ Vibrator驱动模型主要包含Vibrator(传感器)相关的HDI接口与实
**图 1** Vibrator驱动模型图 **图 1** Vibrator驱动模型图
<img src="figures/dayu200/dayu200-vibrator-01.png" style="zoom:80%;" /> ![dayu200-vibrator-01.png](figures/dayu200/dayu200-vibrator-01.png)
rk3568 支持线性马达,整体的驱动框架openharmony 主线已经具备,只需要实现具体的器件驱动即可。 rk3568 支持线性马达,整体的驱动框架openharmony 主线已经具备,只需要实现具体的器件驱动即可。
......
...@@ -1551,7 +1551,8 @@ struct v4l2_buffer { ...@@ -1551,7 +1551,8 @@ struct v4l2_buffer {
- InputController:提供input设备的业务控制接口,包括获取器件信息及设备类型、设置电源状态等。 - InputController:提供input设备的业务控制接口,包括获取器件信息及设备类型、设置电源状态等。
**图 1** INPUT模块HDI接口层框架图 **图 1** INPUT模块HDI接口层框架图
<img src="figures/dayu200/dayu200-tp-01.png" alt="dayu200-tp-01.png" style="zoom: 67%;" />
![dayu200-tp-01.png](figures/dayu200/dayu200-tp-01.png)
相关目录下源代码目录结构如下所示 相关目录下源代码目录结构如下所示
......
# 启动恢复子系统<a name="ZH-CN_TOPIC_0000001124561621"></a> # 启动恢复子系统<a name="ZH-CN_TOPIC_0000001124561621"></a>
- [简介](#section11660541593)
- [目录](#section161941989596)
- [约束](#section1718733212019)
- [使用说明](#section8533192617117)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a> ## 简介<a name="section11660541593"></a>
...@@ -14,7 +9,7 @@ ...@@ -14,7 +9,7 @@
支持使用LiteOS-A和Linux内核的平台。 支持使用LiteOS-A和Linux内核的平台。
负责处理从内核加载第一个用户态进程开始,到第一个应用程序启动之间的系统服务进程启动过程。启动恢复子系统除负责加载各系统关键进程之外,还需在启动的同时设置其对应权限,并在子进程启动后对指定进程实行保活(若进程意外退出要重新启动),对于核心进程意外退出时,启动恢复子系统还要执行系统重启操作。详见“[init启动引导组件](../device-dev/subsystems/subsys-boot-init.md)”部分。 负责处理从内核加载第一个用户态进程开始,到第一个应用程序启动之间的系统服务进程启动过程。启动恢复子系统除负责加载各系统关键进程之外,还需在启动的同时设置其对应权限,并在子进程启动后对指定进程实行保活(若进程意外退出要重新启动),对于核心进程意外退出时,启动恢复子系统还要执行系统重启操作。详见“[init启动引导组件](../device-dev/subsystems/subsys-boot-init-cfg.md)”部分。
- appspawn应用孵化器组件 - appspawn应用孵化器组件
...@@ -33,7 +28,7 @@ ...@@ -33,7 +28,7 @@
负责提供获取与设置操作系统相关的系统属性。 负责提供获取与设置操作系统相关的系统属性。
支持全量系统平台。支持的系统属性包括:默认系统属性、OEM厂商系统属性和自定义系统属性。OEM厂商部分仅提供默认值,具体值需OEM产品方按需进行调整,详见“[syspara系统属性组件](../device-dev/subsystems/subsys-boot-syspara.md)”部分。 支持全量系统平台。支持的系统属性包括:默认系统属性、OEM厂商系统属性和自定义系统属性。OEM厂商部分仅提供默认值,具体值需OEM产品方按需进行调整,详见“[syspara系统属性组件](../device-dev/subsystems/subsys-boot-init-sysparam.md)”部分。
## 目录<a name="section161941989596"></a> ## 目录<a name="section161941989596"></a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册