提交 5b3f1850 编写于 作者: Z zhuhan 提交者: Gitee

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

Signed-off-by: Nzhuhan <zhuhan10@huawei.com>
...@@ -369,10 +369,10 @@ zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @mayunteng_1 @ning ...@@ -369,10 +369,10 @@ zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @mayunteng_1 @ning
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-inputevent.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-inputevent.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md @feng-aiwen @ge-yafang @SuperShrimp @murphy1984 zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md @feng-aiwen @ningningW @SuperShrimp @murphy1984
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md @feng-aiwen @ge-yafang @SuperShrimp @murphy1984 zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md @feng-aiwen @ningningW @SuperShrimp @murphy1984
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @feng-aiwen @ge-yafang @SuperShrimp @murphy1984 zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @feng-aiwen @ningningW @SuperShrimp @murphy1984
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @feng-aiwen @ge-yafang @SuperShrimp @murphy1984 zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @feng-aiwen @ningningW @SuperShrimp @murphy1984
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-intl.md @Buda-Liu @ningningW @budda-wang @yangqing3 zh-cn/application-dev/reference/apis/js-apis-intl.md @Buda-Liu @ningningW @budda-wang @yangqing3
zh-cn/application-dev/reference/apis/js-apis-keycode.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-keycode.md @mayunteng_1 @ningningW @cococoler @alien0208
...@@ -407,12 +407,12 @@ zh-cn/application-dev/reference/apis/js-apis-prompt.md @huaweimaxuchu @HelloCrea ...@@ -407,12 +407,12 @@ zh-cn/application-dev/reference/apis/js-apis-prompt.md @huaweimaxuchu @HelloCrea
zh-cn/application-dev/reference/apis/js-apis-queue.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-queue.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-radio.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-radio.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @jayleehw @RayShih @li-weifeng2 @currydavids zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @jayleehw @RayShih @li-weifeng2 @currydavids
zh-cn/application-dev/reference/apis/js-apis-request.md @feng-aiwen @zengyawen @nagexiucai @murphy1984 zh-cn/application-dev/reference/apis/js-apis-request.md @feng-aiwen @ningningW @nagexiucai @murphy1984
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ningningW @budda-wang @yangqing3 zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ningningW @budda-wang @yangqing3
zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @feng-aiwen @ge-yafang @wangzhangjun @murphy1984 zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @feng-aiwen @ningningW @wangzhangjun @murphy1984
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
...@@ -446,8 +446,8 @@ zh-cn/application-dev/reference/apis/js-apis-system-request.md @zhang-hai-feng @ ...@@ -446,8 +446,8 @@ zh-cn/application-dev/reference/apis/js-apis-system-request.md @zhang-hai-feng @
zh-cn/application-dev/reference/apis/js-apis-system-router.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-system-router.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-system-storage.md @feng-aiwen @ge-yafang @gong-a-shi @logic42 zh-cn/application-dev/reference/apis/js-apis-system-storage.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-system-time.md @feng-aiwen @ge-yafang @illybyy @murphy1984 zh-cn/application-dev/reference/apis/js-apis-system-time.md @feng-aiwen @ningningW @illybyy @murphy1984
zh-cn/application-dev/reference/apis/js-apis-system-timer.md @feng-aiwen @ge-yafang @illybyy @murphy1984 zh-cn/application-dev/reference/apis/js-apis-system-timer.md @feng-aiwen @ningningW @illybyy @murphy1984
zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-testRunner.md @inter515 @littlejerry1 @RayShih @inter515 @jiyong zh-cn/application-dev/reference/apis/js-apis-testRunner.md @inter515 @littlejerry1 @RayShih @inter515 @jiyong
...@@ -466,7 +466,7 @@ zh-cn/application-dev/reference/apis/js-apis-util.md @gongjunsong @ge-yafang @fl ...@@ -466,7 +466,7 @@ zh-cn/application-dev/reference/apis/js-apis-util.md @gongjunsong @ge-yafang @fl
zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-vibrator.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain zh-cn/application-dev/reference/apis/js-apis-vibrator.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @feng-aiwen @ge-yafang @wangzhangjun @murphy1984 zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @feng-aiwen @ningningW @wangzhangjun @murphy1984
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-webgl.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-webgl.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
...@@ -527,7 +527,7 @@ zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @panqinxu @zen ...@@ -527,7 +527,7 @@ zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @panqinxu @zen
zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md @cheng_guohong @RayShih @cheng_guohong @xiangkejin123 zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md @cheng_guohong @RayShih @cheng_guohong @xiangkejin123
zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md @stone2050 @zengyawen @stesen @elsen-liu zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md @stone2050 @zengyawen @stesen @elsen-liu
zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md @feng-aiwen @ge-yafang @SuperShrimp @murphy1984 zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md @feng-aiwen @ningningW @SuperShrimp @murphy1984
zh-cn/application-dev/reference/apis/js-apis-installer.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-installer.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-matrix4.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-matrix4.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
...@@ -581,7 +581,7 @@ zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md @zengyawen ...@@ -581,7 +581,7 @@ zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md @zengyawen
zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md @zengyawen zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md @zengyawen
zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @zengyawen zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @zengyawen
zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @ningningW zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md @ge-yafang zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md @ningningW zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @RayShih zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @RayShih
zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @ge-yafang zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @ge-yafang
...@@ -589,7 +589,7 @@ zh-cn/application-dev/reference/errorcodes/errorcode-power.md @zengyawen ...@@ -589,7 +589,7 @@ zh-cn/application-dev/reference/errorcodes/errorcode-power.md @zengyawen
zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @ge-yafang zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @ge-yafang
zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @HelloCrease zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @HelloCrease
zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @ningningW zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-request.md @zengyawen zh-cn/application-dev/reference/errorcodes/errorcode-request.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @ningningW zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-router.md @HelloCrease zh-cn/application-dev/reference/errorcodes/errorcode-router.md @HelloCrease
zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @RayShih zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @RayShih
......
# Ability Development # Ability Development
> **NOTE**<br/>
> This folder is deprecated. Read [Application Models](../application-models/Readme-EN.md) instead.
- [Ability Framework Overview](ability-brief.md) - [Ability Framework Overview](ability-brief.md)
- [Context Usage](context-userguide.md) - [Context Usage](context-userguide.md)
- FA Model - FA Model
......
...@@ -73,10 +73,10 @@ The ability assistant enables you to start applications, atomic services, and te ...@@ -73,10 +73,10 @@ The ability assistant enables you to start applications, atomic services, and te
| -a/--all | - | Prints ability information in all missions. | | -a/--all | - | Prints ability information in all missions. |
| -l/--mission-list | type (All logs are printed if this parameter is left unspecified.)| Prints mission stack information.<br>The following values are available for **type**:<br>- NORMAL <br>- DEFAULT_STANDARD<br>- DEFAULT_SINGLE<br>- LAUNCHER | | -l/--mission-list | type (All logs are printed if this parameter is left unspecified.)| Prints mission stack information.<br>The following values are available for **type**:<br>- NORMAL <br>- DEFAULT_STANDARD<br>- DEFAULT_SINGLE<br>- LAUNCHER |
| -e/--extension | elementName | Prints extended component information. | | -e/--extension | elementName | Prints extended component information. |
| -u/--userId | UserId | Prints stack information of a specified user ID. This parameter must be used together with other parameters. <br/>Example commands: aa **dump -a -u 100** and **aa dump -d -u 100**. | | -u/--userId | UserId | Prints stack information of a specified user ID. This parameter must be used together with other parameters. <br/>Example commands: aa **dump -a -u 100** and **aa dump -d -u 100**.|
| -d/--data | - | Prints Data ability information. | | -d/--data | - | Prints Data ability information. |
| -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. | | -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. |
| -c/--client | - | Prints detailed ability information. This parameter must be used together with other parameters. <br/>Example commands: **aa dump -a -c** and **aa dump -i 21 -c**. | | -c/--client | - | Prints detailed ability information. This parameter must be used together with other parameters. <br/>Example commands: **aa dump -a -c** and **aa dump -i 21 -c**.|
**Method** **Method**
......
...@@ -46,19 +46,19 @@ For details about how to use DevEco Studio to start the test framework, see [Ope ...@@ -46,19 +46,19 @@ For details about how to use DevEco Studio to start the test framework, see [Ope
## Introduction to TestRunner ## Introduction to TestRunner
**TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, DevEco Studio initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-testRunner.md). **TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, DevEco Studio initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-application-testRunner.md).
## Introduction to AbilityDelegatorRegistry ## Introduction to AbilityDelegatorRegistry
**AbilityDelegatorRegistry** is the **AbilityDelegator** repository class provided by the test framework. You can use **AbilityDelegatorRegistry** to obtain an **AbilityDelegator** instance and the input and generated parameters **AbilityDelegatorArgs** during the test. You can use **AbilityDelegator** to invoke the function set provided by the test framework for testing and verification. For details, see [AbilityDelegatorRegistry](../reference/apis/js-apis-abilityDelegatorRegistry.md). **AbilityDelegatorRegistry** is the **AbilityDelegator** repository class provided by the test framework. You can use **AbilityDelegatorRegistry** to obtain an **AbilityDelegator** instance and the input and generated parameters **AbilityDelegatorArgs** during the test. You can use **AbilityDelegator** to invoke the function set provided by the test framework for testing and verification. For details, see [AbilityDelegatorRegistry](../reference/apis/js-apis-application-abilityDelegatorRegistry.md).
## Introduction to AbilityDelegatorArgs ## Introduction to AbilityDelegatorArgs
**AbilityDelegatorArgs** is a test parameter class provided by the test framework. You can use **AbilityDelegatorArgs** to obtain the parameters passed and generated during the test. For details, see [AbilityDelegatorArgs](../reference/apis/js-apis-application-abilityDelegatorArgs.md). **AbilityDelegatorArgs** is a test parameter class provided by the test framework. You can use **AbilityDelegatorArgs** to obtain the parameters passed and generated during the test. For details, see [AbilityDelegatorArgs](../reference/apis/js-apis-inner-application-abilityDelegatorArgs.md).
## Introduction to AbilityMonitor ## Introduction to AbilityMonitor
**AbilityMonitor** is provided by the test framework for binding to and listening for abilities. You can use **AbilityMonitor** to bind to an **Ability** instance and add **AbilityMonitor** to the listening list. When **AbilityMonitor** is bound to an ability, the creation and lifecycle changes of the ability will trigger the related callback in **AbilityMonitor**. You can test and verify the ability in these callbacks. For details, see [AbilityMonitor](../reference/apis/js-apis-application-abilityMonitor.md). **AbilityMonitor** is provided by the test framework for binding to and listening for abilities. You can use **AbilityMonitor** to bind to an **Ability** instance and add **AbilityMonitor** to the listening list. When **AbilityMonitor** is bound to an ability, the creation and lifecycle changes of the ability will trigger the related callback in **AbilityMonitor**. You can test and verify the ability in these callbacks. For details, see [AbilityMonitor](../reference/apis/js-apis-inner-application-abilityMonitor.md).
**Example** **Example**
...@@ -131,7 +131,7 @@ abilityDelegator.startAbility(want, (err, data) => { ...@@ -131,7 +131,7 @@ abilityDelegator.startAbility(want, (err, data) => {
### Scheduling the Ability Lifecycle ### Scheduling the Ability Lifecycle
**AbilityDelegator** provides APIs to display and schedule the ability lifecycle and supports the foreground and background. It works with **AbilityMonitor** to listen for the ability lifecycle. For details, see [AbilityDelegator](../reference/apis/js-apis-application-abilityDelegator.md). **AbilityDelegator** provides APIs to display and schedule the ability lifecycle and supports the foreground and background. It works with **AbilityMonitor** to listen for the ability lifecycle. For details, see [AbilityDelegator](../reference/apis/js-apis-inner-application-abilityDelegator.md).
### Running a Shell Command ### Running a Shell Command
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
**Context** provides the capability of obtaining contextual information of an application. **Context** provides the capability of obtaining contextual information of an application.
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model. The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model.
- FA model
Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
- FA model
Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
- Stage model - Stage model
The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model). The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).
...@@ -239,7 +239,7 @@ export default class MainAbility extends Ability { ...@@ -239,7 +239,7 @@ export default class MainAbility extends Ability {
### application/FormExtensionContext ### application/FormExtensionContext
For details, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md). For details, see [FormExtensionContext](../reference/apis/js-apis-inner-application-formExtensionContext.md).
### Obtaining the Context on an ArkTS Page ### Obtaining the Context on an ArkTS Page
......
...@@ -188,7 +188,7 @@ As the entry of the ability continuation capability, **continuationManager** is ...@@ -188,7 +188,7 @@ As the entry of the ability continuation capability, **continuationManager** is
} }
``` ```
The preceding multi-device collaboration operation is performed across devices in the stage model. For details about this operation in the FA model, see [Page Ability Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/ability/fa-pageability.md). The preceding multi-device collaboration operation is performed across devices in the stage model. For details about this operation in the FA model, see [Page Ability Development](fa-pageability.md).
You can also instruct the device selection module to update the device connection state. The sample code is as follows: You can also instruct the device selection module to update the device connection state. The sample code is as follows:
......
...@@ -38,4 +38,6 @@ When an ability is started, an application process as well as a thread for this ...@@ -38,4 +38,6 @@ When an ability is started, an application process as well as a thread for this
For details about the project directory structure of the FA model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section4154183910141). For details about the project directory structure of the FA model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section4154183910141).
For details about how to configure the application package structure of the FA model, see [Application Package Structure Configuration File](../quick-start/package-structure.md). For details about how to configure the application package structure of the FA model, see [Application Package Structure Configuration File](../quick-start/application-configuration-file-overview-fa.md).
<!--no_check-->
\ No newline at end of file
...@@ -148,7 +148,7 @@ The basic dependency packages include: ...@@ -148,7 +148,7 @@ The basic dependency packages include:
1. Create a Data ability helper. 1. Create a Data ability helper.
For details about the APIs provided by **DataAbilityHelper**, see [DataAbilityHelper Module](../reference/apis/js-apis-dataAbilityHelper.md). For details about the APIs provided by **DataAbilityHelper**, see [DataAbilityHelper Module](../reference/apis/js-apis-inner-ability-dataAbilityHelper.md).
```js ```js
// Different from the URI defined in the config.json file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/). // Different from the URI defined in the config.json file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
......
...@@ -43,7 +43,7 @@ The table below describes the **LifecycleForm** APIs, which represent the lifecy ...@@ -43,7 +43,7 @@ The table below describes the **LifecycleForm** APIs, which represent the lifecy
| onDestroy(formId: string): void | Called to notify the widget provider that a widget has been destroyed. | | onDestroy(formId: string): void | Called to notify the widget provider that a widget has been destroyed. |
| onAcquireFormState?(want: Want): formInfo.FormState | Called to instruct the widget provider to receive the status query result of a widget. | | onAcquireFormState?(want: Want): formInfo.FormState | Called to instruct the widget provider to receive the status query result of a widget. |
The table below describes the **FormProvider** APIs. For details, see [FormProvider](../reference/apis/js-apis-formprovider.md). The table below describes the **FormProvider** APIs. For details, see [FormProvider](../reference/apis/js-apis-application-formProvider.md).
**Table 2** FormProvider APIs **Table 2** FormProvider APIs
......
...@@ -61,7 +61,7 @@ By default, **singleton** is used. ...@@ -61,7 +61,7 @@ By default, **singleton** is used.
| API | Description | | API | Description |
| --------------------------------------------------- | --------------- | | --------------------------------------------------- | --------------- |
| void startAbility(parameter: StartAbilityParameter) | Starts an ability. | | void startAbility(parameter: StartAbilityParameter) | Starts an ability. |
| Context getContext(): | Obtains the application context.| | Context getContext(): | Obtains the application context.|
| void terminateSelf() | Terminates the ability. | | void terminateSelf() | Terminates the ability. |
| bool hasWindowFocus() | Checks whether the ability has focus. | | bool hasWindowFocus() | Checks whether the ability has focus. |
......
...@@ -22,7 +22,9 @@ The differences between **onCommand()** and **onConnect()** are as follows: ...@@ -22,7 +22,9 @@ The differences between **onCommand()** and **onConnect()** are as follows:
### Creating and Registering a Service Ability ### Creating and Registering a Service Ability
1. Override the Service ability-related lifecycle callbacks to implement your own logic for processing interaction requests. 1. Override the Service ability-related lifecycle callbacks to implement your own logic for processing interaction requests.
```ts ```ts
export default { export default {
...@@ -45,7 +47,7 @@ The differences between **onCommand()** and **onConnect()** are as follows: ...@@ -45,7 +47,7 @@ The differences between **onCommand()** and **onConnect()** are as follows:
} }
} }
``` ```
2. Register a Service ability. 2. Register a Service ability.
Declare the Service ability in the **config.json** file by setting its **type** attribute to **service**. Declare the Service ability in the **config.json** file by setting its **type** attribute to **service**.
......
...@@ -301,11 +301,13 @@ In the ability continuation scenario, the distributed data object is used to syn ...@@ -301,11 +301,13 @@ In the ability continuation scenario, the distributed data object is used to syn
### Restrictions ### Restrictions
1. The continuation must be performed between the same ability, which means the same bundle name, module name, and ability name. For details, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). 1. The continuation must be performed between the same ability, which means the same bundle name, module name, and ability name. For details, see [Application Package Structure Configuration File](../quick-start/module-configuration-file.md).
2. Currently, the application can only implement the continuation capability. The continuation action must be initiated by the system. 2. Currently, the application can only implement the continuation capability. The continuation action must be initiated by the system.
### Best Practice ### Best Practice
For better user experience, you are advised to use the **wantParam** parameter to transmit data smaller than 100 KB and use distributed objects to transmit data larger than 100 KB. For better user experience, you are advised to use the **wantParam** parameter to transmit data smaller than 100 KB and use distributed objects to transmit data larger than 100 KB.
<!--no_check-->
\ No newline at end of file
# Ability Development # Ability Development
## When to Use ## When to Use
Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the **module.json5** and **app.json5** files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic: Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the **module.json5** and **app.json5** files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/application-package-structure-stage.md). To develop an ability based on the stage model, implement the following logic:
- Create an ability that supports screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes. - Create an ability that supports screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes.
- Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page. - Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page.
- Call abilities. For details, see [Call Development](stage-call.md). - Call abilities. For details, see [Call Development](stage-call.md).
...@@ -30,7 +30,7 @@ By default, the singleton mode is used. The following is an example of the **mod ...@@ -30,7 +30,7 @@ By default, the singleton mode is used. The following is an example of the **mod
``` ```
## Creating an Ability ## Creating an Ability
### Available APIs ### Available APIs
The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md).
**Table 1** AbilityStage APIs **Table 1** AbilityStage APIs
|API|Description| |API|Description|
...@@ -321,3 +321,5 @@ struct Index { ...@@ -321,3 +321,5 @@ struct Index {
} }
} }
``` ```
<!--no_check-->
\ No newline at end of file
...@@ -12,15 +12,15 @@ The stage model is designed based on the following considerations: ...@@ -12,15 +12,15 @@ The stage model is designed based on the following considerations:
- Efficient management of application processes - Efficient management of application processes
As the device memory becomes larger, the number of processes concurrently running in the system increases. If the number of concurrent processes reaches several hundreds, the overall power consumption and performance of the system will be adversely affected without effective management measures. To restrict the behavior of background processes, the stage model uses four measures: transient task, continuous task, agent task, and Work Scheduler task. With these measures, foreground processes will obtain guaranteed resources, thereby delivering a better user experience. As the device memory becomes larger, the number of processes concurrently running in the system increases. If the number of concurrent processes reaches several hundreds, the overall power consumption and performance of the system will be adversely affected without effective management measures. To restrict the behavior of background processes, the stage model uses four measures: transient task, continuous task, agent task, and Work Scheduler task. With these measures, foreground processes will obtain guaranteed resources, thereby delivering a better user experience.
- Native support for cross-device migration and multi-device collaboration - Native support for cross-device migration and multi-device collaboration
OpenHarmony is a native distributed OS. Its application framework must be designed for easier component migration and collaboration across devices. The stage model achieves this design objective by providing features such as separation between ability and UI as well as integration of UI display and service capabilities. OpenHarmony is a native distributed OS. Its application framework must be designed for easier component migration and collaboration across devices. The stage model achieves this design objective by providing features such as separation between ability and UI as well as integration of UI display and service capabilities.
- Different window forms for various device types - Different window forms for various device types
The stage model redefines the ability lifecycle. In terms of architecture, the component manager and window manager are decoupled. This facilitates adaptation between window forms and device types. The stage model redefines the ability lifecycle. In terms of architecture, the component manager and window manager are decoupled. This facilitates adaptation between window forms and device types.
## Basic Concepts ## Basic Concepts
...@@ -103,8 +103,12 @@ The processes of an application can be classified into three types: ...@@ -103,8 +103,12 @@ The processes of an application can be classified into three types:
![stageprocessmodel](figures/stageprocessmodel.png) ![stageprocessmodel](figures/stageprocessmodel.png)
## Application Package Structure ## Application Package Structure
For details about the project directory structure of the stage model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section56487581904). For details about the project directory structure of the stage model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section56487581904).
For details about how to configure the application package structure of the stage model, see [Application Package Structure Configuration File (Stage Model)](../quick-start/stage-structure.md). For details about how to configure the application package structure of the stage model, see [Application Package Structure Configuration File](../quick-start/application-configuration-file-overview-stage.md).
<!--no_check-->
\ No newline at end of file
...@@ -34,7 +34,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r ...@@ -34,7 +34,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r
**Table 2** Ability call APIs **Table 2** Ability call APIs
|API|Description| |API|Description|
|:------|:------| |:------|:------|
|startAbilityByCall(want: Want): Promise\<Caller>|Starts an ability in the foreground (through the **want** configuration) or background (default) and obtains the **Caller** object for communication with the ability. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md#serviceextensioncontextstartabilitybycall).| |startAbilityByCall(want: Want): Promise\<Caller>|Starts an ability in the foreground (through the **want** configuration) or background (default) and obtains the **Caller** object for communication with the ability. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextstartabilitybycall).|
|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee ability registers a method.| |on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee ability registers a method.|
|off(method: string): void|Callback invoked when the callee ability deregisters a method.| |off(method: string): void|Callback invoked when the callee ability deregisters a method.|
|call(method: string, data: rpc.Sequenceable): Promise\<void>|Sends agreed sequenceable data to the callee ability.| |call(method: string, data: rpc.Sequenceable): Promise\<void>|Sends agreed sequenceable data to the callee ability.|
......
...@@ -31,7 +31,7 @@ Stage widget development refers to the development conducted by the widget provi ...@@ -31,7 +31,7 @@ Stage widget development refers to the development conducted by the widget provi
## Available APIs ## Available APIs
The **FormExtension** class has the following APIs. For details, see [FormExtension](../reference/apis/js-apis-formextension.md). The **FormExtension** class has the following APIs. For details, see [FormExtension](../reference/apis/js-apis-app-form-formExtensionAbility.md).
**Table 1** FormExtension APIs **Table 1** FormExtension APIs
...@@ -45,7 +45,7 @@ The **FormExtension** class has the following APIs. For details, see [FormExtens ...@@ -45,7 +45,7 @@ The **FormExtension** class has the following APIs. For details, see [FormExtens
| onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. | | onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. |
| onConfigurationUpdated(config: Configuration): void; | Called when the configuration of the environment where the widget is running is updated. | | onConfigurationUpdated(config: Configuration): void; | Called when the configuration of the environment where the widget is running is updated. |
The **FormExtension** class also has a member context, that is, the **FormExtensionContext** class. For details, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md). The **FormExtension** class also has a member context, that is, the **FormExtensionContext** class. For details, see [FormExtensionContext](../reference/apis/js-apis-inner-application-formExtensionContext.md).
**Table 2** FormExtensionContext APIs **Table 2** FormExtensionContext APIs
...@@ -54,7 +54,7 @@ The **FormExtension** class also has a member context, that is, the **FormExtens ...@@ -54,7 +54,7 @@ The **FormExtension** class also has a member context, that is, the **FormExtens
| startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void | Starts an ability. This API uses an asynchronous callback to return the result. (This is a system API and cannot be called by third-party applications.)| | startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void | Starts an ability. This API uses an asynchronous callback to return the result. (This is a system API and cannot be called by third-party applications.)|
| startAbility(want: Want): Promise&lt;void&gt; | Starts an ability. This API uses a promise to return the result. (This is a system API and cannot be called by third-party applications.)| | startAbility(want: Want): Promise&lt;void&gt; | Starts an ability. This API uses a promise to return the result. (This is a system API and cannot be called by third-party applications.)|
For details about the **FormProvider** APIs, see [FormProvider](../reference/apis/js-apis-formprovider.md). For details, see [FormProvider](../reference/apis/js-apis-application-formProvider.md).
**Table 3** FormProvider APIs **Table 3** FormProvider APIs
...@@ -412,4 +412,4 @@ The following is an example: ...@@ -412,4 +412,4 @@ The following is an example:
} }
} }
} }
``` ```
\ No newline at end of file
...@@ -71,4 +71,5 @@ OpenHarmony does not support creation of a Service Extension ability for third-p ...@@ -71,4 +71,5 @@ OpenHarmony does not support creation of a Service Extension ability for third-p
console.log('onDestroy'); console.log('onDestroy');
} }
} }
``` ```
\ No newline at end of file
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
## When to Use ## When to Use
The **WantAgent** class encapsulates want information that specifies a particular action, which can be starting an ability or publishing a common event. You can either call **wantAgent.trigger** to trigger a **WantAgent** directly or add a **WantAgent** to a notification so that it will be triggered when users tap the notification. The **WantAgent** class encapsulates want information that specifies a particular action, which can be starting an ability or publishing a common event. You can either call **wantAgent.trigger** to trigger a **WantAgent** directly or add a **WantAgent** to a notification so that it will be triggered when users tap the notification.
## Available APIs ## Available APIs
| API | Description| | API | Description|
| ---------------------------------------------------------------------------------------------- | ----------- | | ---------------------------------------------------------------------------------------------- | ----------- |
......
# Application Test
- [arkXtest User Guide](arkxtest-guidelines.md)
- [SmartPerf User Guide](smartperf-guidelines.md)
- [wukong User Guide](wukong-guidelines.md)
# arkXtest User Guide
## Overview
To accelerate test automation of OpenHarmony, arkXtest — an automated test framework that supports both the JavaScript (JS) and TypeScript (TS) programming languages — is provided.
In this document you will learn about the key functions of arkXtest and how to use it to perform unit testing on application or system APIs and to write UI automated test scripts.
### Introduction
arkXtest is part of the OpenHarmony toolkit and provides basic capabilities of writing and running OpenHarmony automated test scripts. In terms of test script writing, arkXtest offers a wide range of APIs, including basic process APIs, assertion APIs, and APIs related to UI operations. In terms of test script running, arkXtest offers such features as identifying, scheduling, and executing test scripts, as well as summarizing test script execution results.
### Principles
arkXtest is divided into two parts: unit test framework and UI test framework.
- Unit Test Framework
As the backbone of arkXtest, the unit test framework offers such features as identifying, scheduling, and executing test scripts, as well as summarizing test script execution results. The figure below shows the main functions of the unit test framework.
![](figures/UnitTest.PNG)
The following figure shows the basic unit test process. To start the unit test framework, run the **aa test** command.
![](figures/TestFlow.PNG)
- UI Testing Framework
The UI test framework provides [UiTest APIs](../reference/apis/js-apis-uitest.md) for you to call in different test scenarios. The test scripts are executed on top of the unit test framework mentioned above.
The figure below shows the main functions of the UI test framework.
![](figures/Uitest.PNG)
### Limitations and Constraints
- The features of the UI test framework are available only in OpenHarmony 3.1 and later versions.
- The feature availability of the unit test framework varies by version. For details about the mappings between the features and versions, see [arkXtest](https://gitee.com/openharmony/testfwk_arkxtest/blob/master/README_en.md).
## Environment preparations
### Environment Requirements
Software for writing test scripts: DevEco Studio 3.0 or later
Hardware for running test scripts: PC connected to a OpenHarmony device, such as the RK3568 development board
### Setting Up the Environment
[Download DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download) and set it up as instructed on the official website.
## Creating a Test Script
1. Open DevEco Studio and create a project, where the **ohos** directory is where the test script is located.
2. Open the .ets file of the module to be tested in the project directory. Move the cursor to any position in the code, and then right-click and choose **Show Context Actions** > **Create Ohos Test** or press **Alt+Enter** and choose **Create Ohos Test** to create a test class.
## Writing a Unit Test Script
```TS
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const delegator = abilityDelegatorRegistry.getAbilityDelegator()
export default function abilityTest() {
describe('ActsAbilityTest', function () {
it('testUiExample',0, async function (done) {
console.info("uitest: TestUiExample begin");
//start tested ability
await delegator.executeShellCommand('aa start -b com.ohos.uitest -a MainAbility').then(result =>{
console.info('Uitest, start ability finished:' + result)
}).catch(err => {
console.info('Uitest, start ability failed: ' + err)
})
await sleep(1000);
//check top display ability
await delegator.getCurrentTopAbility().then((Ability)=>{
console.info("get top ability");
expect(Ability.context.abilityInfo.name).assertEqual('MainAbility');
})
done();
})
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
})
}
```
The unit test script must contain the following basic elements:
1. Import of the dependency package so that the dependent test APIs can be used.
2. Test code, mainly about the related logic, such as API invoking.
3. Invoking of the assertion APIs and setting of checkpoints. If there is no checkpoint, the test script is considered as incomplete.
## Writing a UI Test Script
You write a UI test script based on the unit test framework, adding the invoking of APIs provided by the UI test framework to implement the corresponding test logic.
In this example, the UI test script is written based on the preceding unit test script. First, add the dependency package, as shown below:
```js
import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest'
```
Then, write specific test code. Specifically, implement the click action on the started application page and add checkpoint check cases.
```js
export default function abilityTest() {
describe('ActsAbilityTest', function () {
it('testUiExample',0, async function (done) {
console.info("uitest: TestUiExample begin");
//start tested ability
await delegator.executeShellCommand('aa start -b com.ohos.uitest -a MainAbility').then(result =>{
console.info('Uitest, start ability finished:' + result)
}).catch(err => {
console.info('Uitest, start ability failed: ' + err)
})
await sleep(1000);
//check top display ability
await delegator.getCurrentTopAbility().then((Ability)=>{
console.info("get top ability");
expect(Ability.context.abilityInfo.name).assertEqual('MainAbility');
})
//ui test code
//init uidriver
var driver = await UiDriver.create();
await driver.delayMs(1000);
//find button by text 'Next'
var button = await driver.findComponent(BY.text('Next'));
//click button
await button.click();
await driver.delayMs(1000);
//check text
await driver.assertComponentExist(BY.text('after click'));
await driver.pressBack();
done();
})
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
})
}
```
## Running the Test Script
You can run a test script in DevEco Studio in any of the following modes:
- Test package level: All test cases in the test package are executed.
- Test suite level: All test cases defined in the **describe** method are executed.
- Test method level: The specified **it** method, that is, a single test case, is executed.
![](figures/Execute.PNG)
## Viewing the Test Result
After the test is complete, you can view the test result in DevEco Studio, as shown in the following figure.
![](figures/TestResult.PNG)
## FAQs
### FAQs About Unit Test Cases
#### The logs in the test case are printed after the test case result
**Problem**
The logs added to the test case are displayed after the test case execution, rather than during the test case execution.
**Possible Causes**
More than one asynchronous interface is called in the test case.<br>In principle, logs in the test case are printed before the test case execution is complete.
**Solution**
If more than one asynchronous interface is called, you are advised to encapsulate the interface invoking into the promise mode
#### Error "fail to start ability" is reported during test case execution
**Problem**
When a test case is executed, the console returns the error message "fail to start ability".
**Possible Causes**
An error occurs during the packaging of the test package, and the test framework dependency file is not included in the test package.
**Solution**
Check whether the test package contains the **OpenHarmonyTestRunner.abc** file. If the file does not exist, rebuild and pack the file and perform the test again.
#### Test case execution timeout
**Problem**
After the test case execution is complete, the console displays the error message "execute time XXms", indicating that the case execution times out.
**Possible Causes**
1. The test case is executed through an asynchronous interface, but the **done** function is not executed during the execution. As a result, the test case execution does not end until it times out.
2. The time taken for API invocation is longer than the timeout interval set for test case execution.
**Solution**
1. Check the code logic of the test case to ensure that the **done** function is executed even if the assertion fails.
2. Modify the case execution timeout settings under **Run/Debug Configurations** in DevEco Studio.
### FAQs About UI Test Cases
#### The failure log contains "Get windows failed/GetRootByWindow failed"
**Problem**
The UI test case fails to be executed. The HiLog file contains the error message "Get windows failed/GetRootByWindow failed".
**Possible Causes**
The ArkUI feature is disabled. As a result, the control tree information on the test page is not generated.
**Solution**
Run the following command, restart the device, and execute the test case again:
```shell
hdc shell param set persist.ace.testmode.enabled 1
```
#### The failure log contains "uitest-api dose not allow calling concurrently"
**Problem**
The UI test case fails to be executed. The HiLog file contains the error message "uitest-api dose not allow calling concurrently".
**Possible Causes**
1. In the test case, the **await** operator is not added to the asynchronous interface provided by the UI test framework.
2. The UI test case is executed in multiple processes. As a result, multiple UI test processes are started. The framework does not support multi-process invoking.
**Solution**
1. Check the case implementation and add the **await** operator to the asynchronous interface invoking.
2. Do not execute UI test cases in multiple processes.
#### The failure log contains "dose not exist on current UI! Check if the UI has changed after you got the widget object"
**Problem**
The UI test case fails to be executed. The HiLog file contains the error message "dose not exist on current UI! Check if the UI has changed after you got the widget object".
**Possible Causes**
After the target component is found in the code of the test case, the device UI changes. As a result, the found component is lost and the emulation operation cannot be performed.
**Solution**
Run the UI test case again.
# SmartPerf User Guide
## Overview
Performance testing helps developers detect the performance bottlenecks and deliver quality applications that meet user expectations. For this reason, SmartPerf, a performance testing tool specially designed for OpenHarmony developers, is provided.
## Introduction
SmartPerf is a reliable, easy-to-use performance and power consumption test tool built for the OpenHarmony system. It provides KPIs with test value details that help you measure the performance and power consumption of your application, such as FPS, CPU, GPU, and Ftrace.
You can use SmartPerf in two modes: visualized operation mode (SmartPerf-Device) and command-line shell mode (SmartPerf-Daemon). SmartPerf-Device supports visualized operations and floating window based operations (such as data collection control and real-time data display). SmartPerf-Daemon is applicable to devices without screens and devices with high tolerance regarding performance, for example, Hi3568.
## Principles
SmartPerf come with SmartPerf-Device and SmartPerf-Daemon. SmartPerf-Device sends data requests for KPIs (such as FPS, RAM, and Trace) through messages to SmartPerf-Daemon, which then collects and sends back data as requested, and displays the received data. SmartPerf-Daemon also allows on-demand data collection through hell commands. The figure below demonstrates the main functions of SmartPerf.
![SmartPerf](figures/SmartPerfStru.png)
## Constraints
- SmartPerf-Device and SmartPerf-Daemon are pre-installed in version 3.2 and later versions.
- SmartPerf-Device requires a screen to work correctly.
## Environment Preparations
To run SmartPerf-Daemon, you must connect the PC to an OpenHarmony device, such as the RK3568 development board.
## Performing Performance Testing
**Using SmartPerf-Device**
In the screenshots below, the RK3568 development board is used as an example.
1. Set the application for which you want to collect data.
Start SmartPerf-Device. On the home screen, select the test application and test indicators, and touch **Start Test**.
2. Control the data collection process from the floating window.
To start collection, touch **Start** in the floating window. To pause, touch the timer in the floating window to pause data collection. To resume, touch the timer again. To view the collected data in real time, double-touch the timer. To stop, touch and hold the timer. You can drag the floating window to anywhere you like.
3. View the report.
Touch **Report** to view the test report list. Touch **Report List** to view details about test indicators.
**Using SmartPerf-Daemon**
1. Access the shell and run the following command to view the help information:
```
:# SP_daemon --help
```
2. Run the collection commands.
```
:# SP_daemon -N 2 -PKG com.ohos.contacts -c -g -t -p -r
```
**Collection Commands**
| Command | Function |Mandatory|
| :-----| :--------------------- |:-----|
| -N | Set the number of collection times. |Yes|
| -PKG | Set the package name. | No|
| -PID | Sets the PID of a process (applicable to RAM).|No|
| -c | Set whether to collect CPU data. | No|
| -g | Set whether to collect GPU data. |No|
| -f | Set whether to collect FPS data. |No|
| -t | Set whether to collect temperature data. |No|
| -p | Set whether to collect current data. |No|
| -r | Set whether to collect memory data. |No|
The default output path of the test result is as follows:
```
/data/local/tmp/data.csv
```
# wukong User Guide
## Overview
Stability testing is important in that it demonstrates how an application performs under stress. For this reason, wukong, a stability testing tool specially designed for OpenHarmony developers, is provided.
In this document you will learn about the key functions of wukong and how to use it to perform stability testing.
## Introduction
wukong is part of the OpenHarmony toolkit and implements basic application stability test capabilities such as random event injection, component injection, exception capture, report generation, and data traversal of abilities.
## Principles
wukong mainly provides two types of tests: random test and special test.
- Random test
The random test is the staple service of wukong. It provides the basic startup, running, and result summary features, as shown below.
![](figures/wukongRandomTest.png)
The following figure shows the basic running process of the random test, which depends on the **hdc** command.
![](figures/wukongRandomTestFlow.png)
- Special test
The special test provides a wide range of features: traversing the components of an application in sequence, recording and playback, and sleeping and waking up.
The following figure shows the main features of the special test.
![](figures/wukongSpecialTest.png)
For details about the test commands, see [wukong](https://gitee.com/openharmony/ostest_wukong/blob/master/README.md).
## Constraints
1. wukong is pre-installed in version 3.2 and later versions.
2. In versions earlier than 3.2, you must build wukong separately and push it to the tested OpenHarmony device. The procedure is as follows:
How to build:
```
./build.sh --product-name rk3568 --build-target wukong
```
How to push:
```
hdc_std shell mount -o rw,remount /
hdc_std file send wukong /
hdc_std shell chmod a+x /wukong
hdc_std shell mv /wukong /bin/
```
## Environment Preparations
To run commands, connect the PC to an OpenHarmony device, such as the RK3568 development board.
## Performing Stability Testing
**Using wukong exec for Random Test**
Access the shell and run the following random test command:
```
# wukong exec -s 10 -i 1000 -a 0.28 -t 0.72 -c 100
```
Random test commands
| Command | Value | Description |
| -------------- | -------------- | ---------------------------------------------- |
| wukong exec | - | Works as the main command. |
| -s | 10 | Sets the random seed. The value 10 is the seed value. |
| -i | 1000 | Sets the application startup interval to 1000 ms.|
| -a | 0.28 | Sets the proportion of the random application startup test to 28%. |
| -t | 0.72 | Sets the proportion of the random touch test to 72%. |
| -c | 100 | Sets the number of execution times to 100. |
**Using wukong special for Special Test**
Access the shell and run the following commands to perform the sequential traversal test:
```bash
# wukong special -C [bundlename] -p
```
Special test commands
| Command | Value | Description |
| -------------- |-------------- | ---------------------------------------------- |
| wukong special | - | Works as the main command. |
| -C [bundlename] |[bundlename] | Sets the bundle name of the application for the sequential traversal test. |
| -p | - | Indicates a screenshot. |
## Viewing the Test Result
After the test commands are executed, the test result is automatically generated.
You can obtain the test result in the following directory:
```
Before 2022/9/22: /data/local/wukong/report/xxxxxxxx_xxxxxx/
Since 2022/9/22: /data/local/tmp/wukong/report/xxxxxxxx_xxxxxx/
```
>**NOTE**
>
>The folder for test reports is automatically generated.
Content of the folder is described in the table below.
| Folder/File | Description |
| ------------------------------------ | ------------------ |
| exception/ | Stores exception files generated during the test.|
| screenshot/ | Stores screenshots of the sequential traversal test. |
| wukong_report.csv | Stores the test report summary. |
You can view the wukong execution log in the path below:
```
reports/xxxxxxxx_xxxxxx/wukong.log
```
# FAQs # FAQs
- [Ability Framework Development](faqs-ability.md) - [Ability Framework Development](faqs-ability.md)
- [Bundle Management Development](faqs-bundle.md)
- [ArkUI (eTS) Development](faqs-ui-ets.md) - [ArkUI (eTS) Development](faqs-ui-ets.md)
- [ArkUI (JavaScript) Development](faqs-ui-js.md) - [ArkUI (JavaScript) Development](faqs-ui-js.md)
- [Bundle Management Development](faqs-bundle.md)
- [Data Management Development](faqs-data-management.md)
- [Development Board](faqs-development-board.md)
- [Device Management Development](faqs-device-management.md)
- [DFX Development](faqs-dfx.md)
- [Graphics and Image Development](faqs-graphics.md) - [Graphics and Image Development](faqs-graphics.md)
- [hdc_std Command Usage](faqs-ide.md)
- [IDE Usage](faqs-hdc-std.md)
- [Intl Development](faqs-international.md)
- [File Management Development](faqs-file-management.md) - [File Management Development](faqs-file-management.md)
- [Media Development](faqs-media.md) - [Media Development](faqs-media.md)
- [Network and Connection Development](faqs-connectivity.md) - [Network and Connection Development](faqs-connectivity.md)
- [Data Management Development](faqs-data-management.md)
- [Device Management Development](faqs-device-management.md)
- [DFX Development](faqs-dfx.md)
- [Intl Development](faqs-international.md)
- [Native API Usage](faqs-native.md) - [Native API Usage](faqs-native.md)
- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md) - [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md)
- [IDE Usage](faqs-ide.md)
- [hdc_std Command Usage](faqs-hdc-std.md)
- [Development Board](faqs-development-board.md)
\ No newline at end of file
...@@ -21,7 +21,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 ...@@ -21,7 +21,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
Error code 28 refers to **CURLE_OPERATION_TIMEDOUT**, which means a cURL operation timeout. For details, see any HTTP status code description available. Error code 28 refers to **CURLE_OPERATION_TIMEDOUT**, which means a cURL operation timeout. For details, see any HTTP status code description available.
Reference: [Development Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-http.md#httpresponse) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html) Reference: [Response Codes](../reference/apis/js-apis-http.md#responsecode) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html)
## What does error code 6 mean for the response of \@ohos.net.http.d.ts? ## What does error code 6 mean for the response of \@ohos.net.http.d.ts?
...@@ -30,4 +30,4 @@ Applicable to: OpenHarmony SDK 3.2.3.5 ...@@ -30,4 +30,4 @@ Applicable to: OpenHarmony SDK 3.2.3.5
Error code 6 indicates a failure to resolve the host in the address. You can ping the URL carried in the request to check whether the host is accessible. Error code 6 indicates a failure to resolve the host in the address. You can ping the URL carried in the request to check whether the host is accessible.
Reference: [Development Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-http.md#httpresponse) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html) Reference: [Response Codes](../reference/apis/js-apis-http.md#responsecode) and [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html)
# Data Management Development # Data Management Development
## How Do I Save PixelMap Data to a Database?
## How Do I Save PixelMap data to a database?
Applicable to: OpenHarmony SDK 3.2.3.5 Applicable to: OpenHarmony SDK 3.2.3.5
You can convert a **PixelMap** into a **ArrayBuffer** and save the **ArrayBuffer** to your database. You can convert a **PixelMap** into an **ArrayBuffer** and save the **ArrayBuffer** to your database.
Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstobuffer7-1) Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstobuffer7-1)
...@@ -14,11 +12,65 @@ Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstob ...@@ -14,11 +12,65 @@ Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstob
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Run the hdc_std command to copy the .db, .db-shm, and .db-wal files from **/data/app/el2/100/database/Bundle name/entry/db/**, and then use the SQLite tool to open the files. Run the hdc_std command to copy the .db, .db-shm, and .db-wal files in **/data/app/el2/100/database/*bundleName*/entry/db/**, and then use the SQLite tool to open the files.
Example: Example:
``` ```
hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db
``` ```
## Does the Database Has a Lock Mechanism?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
The distributed data service (DDS), relational database (RDB) store, and preferences provided OpenHarmony have a lock mechanism. You do not need to bother with the lock mechanism during the development.
## What Is a Transaction in an RDB Store?
Applicable to: all versions
When a large number of operations are performed in an RDB store, an unexpected exception may cause a failure of some data operations and loss of certain data. As a result, the application may become abnormal or even crash.
A transaction is a group of tasks serving as a single logical unit. It eliminates the failure of some of the operations and loss of associated data.
## What Data Types Does an RDB Store Support?
Applicable to: OpenHarmony SDK 3.0 or later, stage model of API version 9
An RDB store supports data of the number, string, and Boolean types. The number array supports data of the Double, Long, Float, Int, or Int64 type, with a maximum precision of 17 decimal digits.
## How Do I View Database db Files?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
1. Run the **hdc_std shell** command.
2. Obtain the absolute path or sandbox path of the database.
The absolute path is **/data/app/el2/<userId>/database/<bundleName>**. The default **<userId>** is **100**.
To obtain the sandbox path, run the **ps -ef | grep hapName** command to obtain the process ID of the application.
The database sandbox path is **/proc/<Application process ID>/root/data/storage/el2/database/**.
3. Run the **find ./ -name "\*.db"** command in the absolute path or sandbox path of the database.
## How Do I Store Long Text Data?
Applicable to: OpenHarmony SDK 3.2.5.5, API version 9
- Preferences support a string of up to 8192 bytes.
- The KV store supports a value of up to 4 MB.
Reference: [Preference Overview](../database/database-preference-overview.md) and [Distributed Data Service Overview](../database/database-mdds-overview.md)
## How Do I Develop DataShare on the Stage Model
Applicable to: OpenHarmony SDK 3.2.5.5, API version 9
The DataShare on the stage model cannot be used with the **DataAbility** for the FA model. The connected server application must be implemented by using **DataShareExtensionAbility**.
Reference: [DataShare Development](../database/database-datashare-guidelines.md)
...@@ -19,7 +19,7 @@ Run **hdc\_std shell param get persist.ace.testmode.enabled**. ...@@ -19,7 +19,7 @@ Run **hdc\_std shell param get persist.ace.testmode.enabled**.
If the value is **0**, run the **hdc\_std shell param set persist.ace.testmode.enabled 1** to enable the test mode. If the value is **0**, run the **hdc\_std shell param set persist.ace.testmode.enabled 1** to enable the test mode.
## Why Is Private Displayed in Logs When the Format Parameter Type of hilog in C++ Code Is %d or %s? ## Why is private displayed in logs when the format parameter type of HiLog in C++ code is %d or %s?
When format parameters such as **%d** and **%s** are directly used, the standard system uses **private** to replace the actual data for printing by default to prevent data leakage. To print the actual data, replace **%d** with **%{public}d** or replace **%s** with **%{public}s**. When format parameters such as **%d** and **%s** are directly used, the standard system uses **private** to replace the actual data for printing by default to prevent data leakage. To print the actual data, replace **%d** with **%{public}d** or replace **%s** with **%{public}s**.
...@@ -35,7 +35,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5 ...@@ -35,7 +35,7 @@ Applicable to: OpenHarmony SDK 3.2.2.5
You are advised to use the [HiLog](../reference/apis/js-apis-hilog.md) for log printing. For details about how to set the **domain** parameter, see the [Development Guide](../reference/apis/js-apis-hilog.md#hilogisloggable). You are advised to use the [HiLog](../reference/apis/js-apis-hilog.md) for log printing. For details about how to set the **domain** parameter, see the [Development Guide](../reference/apis/js-apis-hilog.md#hilogisloggable).
## What is the maximum length of a log record when HiLog Is used? Is it configurable? ## What is the maximum length of a log record when HiLog is used? Is it configurable?
Applicable to: OpenHarmony SDK 3.2.2.5 Applicable to: OpenHarmony SDK 3.2.2.5
......
# File Management Development # File Management Development
## Does fileio.rmdir Delete Files Recursively?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
## What If There is No Return Value or Error Captured After getAlbums Is Called? Yes. **fileio.rmdir** deletes files recursively.
## How Do I Create a File That Does Not Exist?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
You can use **fileio.open(filePath, 0o100, 0o666)**. The second parameter **0o100** means to create a file if it does not exist. The third parameter **mode** must also be specified.
## What If "call fail callback fail, code: 202, data: json arguments illegal" Is Displayed?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
When the **fileio** module is used to copy files, the file path cannot start with "file:///".
## How Do I Read Files Outside the App Sandbox?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If the input parameter of the **fileio** API is **path**, only the sandbox directory of the current app obtained from the context can be accessed. To access data in other directories such as the user data, images, and videos, open the file as the data owner and operate with the file descriptor (FD) returned.
For example, to read or write a file in Media Library, perform the following steps:
1. Use **getFileAssets()** to obtain the **fileAsset** object.
2. Use **fileAsset.open()** to obtain the FD.
3. Use the obtained FD as the **fileIo** API parameter to read and write the file.
## What If the File Contains Garbled Characters?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Read the file content from the buffer, and decode the file content using **util.TextDecoder**.
Example:
```
import util from '@ohos.util'
async function readFile(path) {
let stream = fileio.createStreamSync(path, "r+");
let readOut = await stream.read(new ArrayBuffer(4096));
let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true });
let buffer = new Uint8Array(readOut.buffer)
let readString = textDecoder.decode(buffer, { stream: false });
console.log ("[Demo] File content read: "+ readString);
}
```
## What Should I Do If There Is No Return Value or Error Captured After getAlbums Is Called?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbums**, and this permission needs user authorization. For details, see OpenHarmony [Application Permission List](../security/permission-list.md). The **ohos.permission.READ_MEDIA** is required for using **getAlbums()**. In addition, this permission needs user authorization. For details, see [OpenHarmony Permission List](../security/permission-list.md).
1. Configure the required permission in the **module.json5** file. 1. Configure the required permission in the **module.json5** file.
``` ```
"requestPermissions": [ "requestPermissions": [
{ {
...@@ -19,7 +69,7 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum ...@@ -19,7 +69,7 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum
``` ```
2. Add the code for user authorization before the **MainAbility.ts -> onWindowStageCreate** page is loaded. 2. Add the code for user authorization before the **MainAbility.ts -> onWindowStageCreate** page is loaded.
``` ```
private requestPermissions() { private requestPermissions() {
let permissionList: Array<string> = [ let permissionList: Array<string> = [
...@@ -34,3 +84,21 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum ...@@ -34,3 +84,21 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum
}) })
} }
``` ```
## What Do I Do If the App Crashes When FetchFileResult() Is Called Multiple Times?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Each time after the **FetchFileResult** object is called, call **FetchFileResult.close()** to release and invalidate the **FetchFileResult** object .
## What If An Error Is Reported by IDE When mediaLibrary.getMediaLibrary() Is Called in the Stage Model?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
In the stage model, use **mediaLibrary.getMediaLibrary(context: Context)** to obtain the media library instance.
## How Do I Sort the Data Returned by mediaLibrary.getFileAssets()?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Use the **order** attribute in **[MediaFetchOptions](../reference/apis/js-apis-medialibrary.md#mediafetchoptions7)** to sort the data returned.
...@@ -24,7 +24,7 @@ APIs involved in MindSpore Lite model inference are categorized into context API ...@@ -24,7 +24,7 @@ APIs involved in MindSpore Lite model inference are categorized into context API
| ------------------ | ----------------- | | ------------------ | ----------------- |
|OH_AI_ContextHandle OH_AI_ContextCreate()|Creates a context object.| |OH_AI_ContextHandle OH_AI_ContextCreate()|Creates a context object.|
|void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num)|Sets the number of runtime threads.| |void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num)|Sets the number of runtime threads.|
| void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode)|Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency.| | void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode)|Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.|
|OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type)|Creates a runtime device information object.| |OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type)|Creates a runtime device information object.|
|void OH_AI_ContextDestroy(OH_AI_ContextHandle *context)|Destroys a context object.| |void OH_AI_ContextDestroy(OH_AI_ContextHandle *context)|Destroys a context object.|
|void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16)|Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.| |void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16)|Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.|
......
...@@ -203,15 +203,16 @@ ...@@ -203,15 +203,16 @@
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.md) - [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md) - [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md) - [@ohos.data.ValuesBucket](js-apis-data-valuesBucket.md)
- data/rdb/[resultSet](js-apis-data-resultset.md) - data/rdb
- [resultSet](js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.document](js-apis-document.md) - [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md) - [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md) - [@ohos.data.fileAccess](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md) - [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md)
- [@ohos.fileio](js-apis-fileio.md) - [@ohos.fileio](js-apis-fileio.md)
- [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md) - [@ohos.filemanagement.userFileManager](js-apis-userfilemanager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md) - [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md) - [@ohos.statfs](js-apis-statfs.md)
...@@ -240,10 +241,13 @@ ...@@ -240,10 +241,13 @@
- [@ohos.nfc.controller](js-apis-nfcController.md) - [@ohos.nfc.controller](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md) - [@ohos.nfc.tag](js-apis-nfcTag.md)
- [@ohos.rpc](js-apis-rpc.md) - [@ohos.rpc](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt](js-apis-wifiManagerExt.md)
- [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md) - [@ohos.wifiext](js-apis-wifiext.md)
- tag/[nfctech](js-apis-nfctech.md) - tag
- tag/[tagSession](js-apis-tagSession.md) - [nfctech](js-apis-nfctech.md)
- [tagSession](js-apis-tagSession.md)
- Basic Features - Basic Features
- [@ohos.accessibility](js-apis-accessibility.md) - [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md) - [@ohos.accessibility.config](js-apis-accessibility-config.md)
......
# @ohos.accessibility.GesturePath
The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import GesturePath from '@ohos.accessibility.GesturePath';
```
## GesturePath
Defines a gesture path.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| ------------ | ---------------------------------------- | ---- | ---- | ------ |
| points | Array&lt;[GesturePoint](js-apis-accessibility-GesturePoint.md#gesturepoint)&gt; | Yes | Yes | Gesture touch point. |
| durationTime | number | Yes | Yes | Total gesture duration, in milliseconds.|
### constructor
constructor(durationTime: number);
Constructor used to create a **GesturePath** object.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| durationTime | number | Yes| Total gesture duration, in milliseconds.|
**Example**
```ts
let gesturePath = new GesturePath.GesturePath(20);
```
# @ohos.accessibility.GesturePoint
The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import GesturePoint from '@ohos.accessibility.GesturePoint';
```
## GesturePoint
Defines a gesture touch point.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| positionX | number | Yes | Yes | X coordinate of the touch point.|
| positionY | number | Yes | Yes | Y coordinate of the touch point.|
### constructor
constructor(positionX: number, positionY: number);
Constructor used to create a **GesturePoint** object.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| positionX | number | Yes| X coordinate of the touch point.|
| positionY | number | Yes | Y coordinate of the touch point.|
**Example**
```ts
let gesturePoint = new GesturePoint.GesturePoint(1, 2);
```
# App Account Management # @ohos.account.appAccount
The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization. The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization.
...@@ -3173,7 +3173,7 @@ Set credentials for an app account. This API uses an asynchronous callback to re ...@@ -3173,7 +3173,7 @@ Set credentials for an app account. This API uses an asynchronous callback to re
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | ------------------------- | ---- | ------------- | | -------------- | ------------------------- | ---- | ------------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete. | | credentialType | string | Yes | Type of the credential to set. |
| credential | string | Yes | Credential value. | | credential | string | Yes | Credential value. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
...@@ -3203,7 +3203,7 @@ Set credentials for an app account. This API uses a promise to return the result ...@@ -3203,7 +3203,7 @@ Set credentials for an app account. This API uses a promise to return the result
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | ------ | ---- | ---------- | | -------------- | ------ | ---- | ---------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.| | credentialType | string | Yes | Type of the credential to set.|
| credential | string | Yes | Credential value.| | credential | string | Yes | Credential value.|
**Return value** **Return value**
...@@ -3576,7 +3576,7 @@ Obtains the credential of an app account. This API uses an asynchronous callback ...@@ -3576,7 +3576,7 @@ Obtains the credential of an app account. This API uses an asynchronous callback
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | --------------------------- | ---- | -------------- | | -------------- | --------------------------- | ---- | -------------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.| | credentialType | string | Yes | Type of the credential to obtain.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential obtained. Otherwise, **err** is an error object.|
**Example** **Example**
...@@ -3606,7 +3606,7 @@ Obtains the credential of an app account. This API uses a promise to return the ...@@ -3606,7 +3606,7 @@ Obtains the credential of an app account. This API uses a promise to return the
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | ------ | ---- | ---------- | | -------------- | ------ | ---- | ---------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.| | credentialType | string | Yes | Type of the credential to obtain.|
**Return value** **Return value**
......
# Accessibility Extension Ability # @ohos.application.AccessibilityExtensionAbility
The **AccessibilityExtensionAbility** module is based on the ExtensionAbility framework and provides the **AccessibilityExtensionAbility**. The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
>**NOTE** > **NOTE**
> >
>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>The APIs of this module can be used only in the stage model.
## Modules to Import ## Modules to Import
...@@ -18,9 +16,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens ...@@ -18,9 +16,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
| Name | Type | Readable | Writable | Description | | Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- | | --------- | -------- | ---- | ---- | ------------------------- |
| context | [AccessibilityExtensionContext](js-apis-accessibility-extension-context.md) | Yes | No | Context of the accessibility extension ability. | | context | [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md) | Yes| No| Context of the accessibility extension ability.|
## AccessibilityEvent ## AccessibilityEvent
...@@ -32,36 +30,10 @@ Defines an accessibility event. ...@@ -32,36 +30,10 @@ Defines an accessibility event.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| --------- | ---------------------------------------- | ---- | ---- | ---------- | | --------- | ---------------------------------------- | ---- | ---- | ---------- |
| eventType | [EventType](js-apis-accessibility.md#eventtype) \| [WindowUpdateType](js-apis-accessibility.md#windowupdatetype) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. | | eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. |
| target | AccessibilityElement | Yes | No | Target component where the event occurs.| | target | AccessibilityElement | Yes | No | Target component where the event occurs.|
| timeStamp | number | Yes | No | Timestamp of the event. | | timeStamp | number | Yes | No | Timestamp of the event. |
## GesturePath
Defines a gesture path.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| ------------ | ---------------------------------------- | ---- | ---- | ------ |
| points | Array&lt;[GesturePoint](gesturepoint)&gt; | Yes | Yes | An array of gesture touch points. |
| durationTime | number | Yes | Yes | Total time consumed by the gesture.|
## GesturePoint
Defines a gesture touch point.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| positionX | number | Yes | Yes | X-coordinate of the touch point.|
| positionY | number | Yes | Yes | Y-coordinate of the touch point.|
## GestureType ## GestureType
Enumerates gesture types. Enumerates gesture types.
...@@ -89,7 +61,7 @@ Enumerates gesture types. ...@@ -89,7 +61,7 @@ Enumerates gesture types.
## PageUpdateType ## PageUpdateType
Enumerates the page refresh types. Enumerates the page update types.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
...@@ -106,27 +78,25 @@ Enumerates the touch guide event types. ...@@ -106,27 +78,25 @@ Enumerates the touch guide event types.
| Name | Description | | Name | Description |
| ---------- | ------------ | | ---------- | ------------ |
| touchBegin | A touch starts in touch guide mode.| | touchBegin | Start of touch in touch guide mode. |
| touchEnd | A touch ends in touch guide mode.| | touchEnd | End of touch in touch guide mode. |
## AccessibilityExtensionAbility.onConnect ## AccessibilityExtensionAbility.onConnect
onConnect(): void; onConnect(): void;
Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can initialize service logic. This API can be overridden as required. Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can have the service logic initialized. This API can be overridden as required.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
None
**Example** **Example**
```ts ```ts
onConnect(): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onConnect"); onConnect() {
} console.log('AxExtensionAbility onConnect');
}
};
``` ```
## AccessibilityExtensionAbility.onDisconnect ## AccessibilityExtensionAbility.onDisconnect
...@@ -137,16 +107,14 @@ Called when the **AccessibilityExtensionAbility** is disabled and disconnected f ...@@ -137,16 +107,14 @@ Called when the **AccessibilityExtensionAbility** is disabled and disconnected f
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
None
**Example** **Example**
```ts ```ts
onDisconnect(): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onDisconnect"); onDisconnect() {
} console.log('AxExtensionAbility onDisconnect');
}
};
``` ```
## AccessibilityExtensionAbility.onAccessibilityEvent ## AccessibilityExtensionAbility.onAccessibilityEvent
...@@ -166,19 +134,21 @@ Called when an event that matches the specified bundle and event type occurs. In ...@@ -166,19 +134,21 @@ Called when an event that matches the specified bundle and event type occurs. In
**Example** **Example**
```ts ```ts
onAccessibilityEvent(event: AccessibilityEvent): void { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onAccessibilityEvent"); onAccessibilityEvent(event) {
if (event.eventType == 'click') { console.log('AxExtensionAbility onAccessibilityEvent');
console.log("AxExtensionAbility onAccessibilityEvent: click"); if (event.eventType == 'click') {
console.log('AxExtensionAbility onAccessibilityEvent: click');
}
} }
} };
``` ```
## AccessibilityExtensionAbility.onKeyEvent ## AccessibilityExtensionAbility.onKeyEvent
onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; onKeyEvent(keyEvent: KeyEvent): boolean;
Called when a physical key is pressed. In this API, you can determine whether to intercept the key event based on the service. Called when a physical key is pressed. In this API, you can determine whether to intercept an event based on the service.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
...@@ -191,12 +161,14 @@ Called when a physical key is pressed. In this API, you can determine whether to ...@@ -191,12 +161,14 @@ Called when a physical key is pressed. In this API, you can determine whether to
**Example** **Example**
```ts ```ts
onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
console.log("AxExtensionAbility onKeyEvent"); onKeyEvent(keyEvent) {
if (keyEvent.keyCode == 22) { console.log('AxExtensionAbility onKeyEvent');
console.log("AxExtensionAbility onKeyEvent: intercept 22"); if (keyEvent.keyCode == 22) {
return true; console.log('AxExtensionAbility onKeyEvent: intercept 22');
return true;
}
return false;
} }
return false; };
}
``` ```
# Battery Info # Battery Info
>**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 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.
> **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.
## Modules to Import ## Modules to Import
...@@ -13,67 +12,100 @@ The Battery Info module provides APIs for querying the charger type, battery hea ...@@ -13,67 +12,100 @@ The Battery Info module provides APIs for querying the charger type, battery hea
import batteryInfo from '@ohos.batteryInfo'; import batteryInfo from '@ohos.batteryInfo';
``` ```
## System Capabilities
SystemCapability.PowerManager.BatteryManager
## Attributes ## Attributes
Describes battery information. Describes battery information.
| Name | Type | Readable | Writable | Description | **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| ----------------------------- | ----------------------------------------- | -------- | -------- | ------------------------------------------------------------ |
| batterySOC | number | Yes | No | Battery state of charge (SoC) of the current device, in unit of percentage. | | Name | Type | Readable| Writable| Description |
| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the current device. | | --------------- | ------------------- | ---- | ---- | ---------------------|
| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the current device. | | batterySOC | number | Yes | No | Battery state of charge (SoC) of the device, in unit of percentage. |
| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the current device. | | chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the device. |
| voltage | number | Yes | No | Battery voltage of the current device, in unit of microvolt. | | healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the device. |
| technology | string | Yes | No | Battery technology of the current device. | | pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the device. |
| batteryTemperature | number | Yes | No | Battery temperature of the current device, in unit of 0.1°C. | | voltage | number | Yes | No | Battery voltage of the device, in unit of microvolt. |
| isBatteryPresent<sup>7+</sup> | boolean | Yes | No | Whether the battery is supported or present. | | technology | string | Yes | No | Battery technology of the device. |
| batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. |
**Example** | isBatteryPresent<sup>7+</sup> | boolean | Yes | No | Whether the battery is supported or present. |
| batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. |
```js | estimatedRemainingChargeTime<sup>9+</sup> | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. |
import batteryInfo from '@ohos.batteryInfo'; | totalEnergy<sup>9+</sup> | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. |
var batterySoc = batteryInfo.batterySOC; | nowCurrent<sup>9+</sup> | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. |
``` | remainingEnergy<sup>9+</sup> | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.|
## BatteryPluggedType ## BatteryPluggedType
Enumerates charger types. Enumerates charger types.
| Name | Default Value | Description | **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| -------- | ------------- | ----------------- |
| NONE | 0 | Unknown type. |
| AC | 1 | AC charger. |
| USB | 2 | USB charger. |
| WIRELESS | 3 | Wireless charger. |
| Name | Value | Description |
| -------- | ---- | ----------------- |
| NONE | 0 | Unknown type |
| AC | 1 | AC charger|
| USB | 2 | USB charger |
| WIRELESS | 3 | Wireless charger|
## BatteryChargeState ## BatteryChargeState
Enumerates charging states. Enumerates charging states.
| Name | Default Value | Description | **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| ------- | ------------- | --------------------------------- |
| NONE | 0 | Unknown state. |
| ENABLE | 1 | The battery is being charged. |
| DISABLE | 2 | The battery is not being charged. |
| FULL | 3 | The battery is fully charged. |
| Name | Value | Description |
| ------- | ---- | --------------- |
| NONE | 0 | Unknown state. |
| ENABLE | 1 | The battery is being charged. |
| DISABLE | 2 | The battery is not being charged. |
| FULL | 3 | The battery is fully charged.|
## BatteryHealthState ## BatteryHealthState
Enumerates battery health states. Enumerates battery health states.
| Name | Default Value | Description | **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| ----------- | ------------- | ------------------------------------ |
| UNKNOWN | 0 | Unknown state. | | Name | Value | Description |
| GOOD | 1 | The battery is in the healthy state. | | ----------- | ---- | -------------- |
| OVERHEAT | 2 | The battery is overheated. | | UNKNOWN | 0 | Unknown state. |
| OVERVOLTAGE | 3 | The battery voltage is over high. | | GOOD | 1 | The battery is in the healthy state. |
| COLD | 4 | The battery temperature is low. | | OVERHEAT | 2 | The battery is overheated. |
| DEAD | 5 | The battery is dead. | | OVERVOLTAGE | 3 | The battery voltage is over high. |
| COLD | 4 | The battery temperature is low. |
| DEAD | 5 | The battery is dead.|
## BatteryCapacityLevel<sup>9+</sup>
Enumerates battery levels.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
| Name | Value| Description |
| -------------- | ------ | ---------------------------- |
| LEVEL_NONE | 0 | Unknown battery level. |
| LEVEL_FULL | 1 | Full battery level. |
| LEVEL_HIGH | 2 | High battery level. |
| LEVEL_NORMAL | 3 | Normal battery level.|
| LEVEL_LOW | 4 | Low battery level. |
| LEVEL_CRITICAL | 5 | Ultra-low battery level.|
## CommonEventBatteryChangedCode<sup>9+</sup>
Enumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
| Name | Value| Description |
| -------------------- | ------ | -------------------------------------------------- |
| EXTRA_SOC | 0 | Remaining battery level in percentage. |
| EXTRA_VOLTAGE | 1 | Battery voltage of the device. |
| EXTRA_TEMPERATURE | 2 | Battery temperature of the device. |
| EXTRA_HEALTH_STATE | 3 | Battery health status of the device. |
| EXTRA_PLUGGED_TYPE | 4 | Type of the charger connected to the device. |
| EXTRA_MAX_CURRENT | 5 | Maximum battery current of the device. |
| EXTRA_MAX_VOLTAGE | 6 | Maximum battery voltage of the device. |
| EXTRA_CHARGE_STATE | 7 | Battery charging status of the device. |
| EXTRA_CHARGE_COUNTER | 8 | Number of battery charging times of the device. |
| EXTRA_PRESENT | 9 | Whether the battery is supported by the device or installed.|
| EXTRA_TECHNOLOGY | 10 | Battery technology of the device. |
# Battery Statistics
This module provides APIs for querying software and hardware power consumption statistics.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
```js
import batteryStats from '@ohos.batteryStatistics';
```
## batteryStats.getBatteryStats
getBatteryStats(): Promise<Array&lt;BatteryStatsInfo&gt;>
Obtains the power consumption information list, using a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Return value**
| Type | Description |
| ----------------------------------------------------- | ------------------------------- |
| Promise<Array<[BatteryStatsInfo](#batterystatsinfo)>> | Promise used to return the power consumption information list.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Obtains the power consumption information list. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<Array<[BatteryStatsInfo](#batterystatsinfo)>> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained. If the operation failed, **err** is an error object.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Obtains the power consumption of an application.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------- |
| uid | number | Yes | Application UID.|
**Return value**
| Type | Description |
| ------ | --------------------------------- |
| number | Power consumption of the application with this UID, in unit of mAh.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Obtains the proportion of the power consumption of an application.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------- |
| uid | number | Yes | Application UID.|
**Return value**
| Type | Description |
| ------ | ------------------------- |
| number | Proportion of the power consumption of an application with this UID.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Obtains the power consumption of a hardware unit according to the consumption type.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------------- | ---- | -------------- |
| type | [ConsumptionType](#consumptiontype) | Yes | Power consumption type.|
**Return value**
| Type | Description |
| ------ | ------------------------------------------ |
| number | Power consumption of the hardware unit corresponding to the power consumption type, in unit of mAh.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Obtains the proportion of the power consumption of a hardware unit according to the power consumption type.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------------- | ---- | -------------- |
| type | [ConsumptionType](#consumptiontype) | Yes | Power consumption type.|
**Return value**
| Type | Description |
| ------ | ---------------------------------- |
| number | Proportion of the power consumption of the hardware unit corresponding to the power consumption type.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```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
Describes the device power consumption information.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
### Attributes
| Name | Type | Readable| Writable| Description |
| ----- | ----------------------------------- | ---- | ---- | ---------------------- |
| uid | number | Yes | No | UID related to power consumption information. |
| type | [ConsumptionType](#consumptiontype) | Yes | No | Power consumption type. |
| power | number | Yes | No | Power consumption, in unit of mAh.|
## ConsumptionType
Enumerates power consumption types.
**System API**: This is a system API.
**System capability**: SystemCapability.PowerManager.BatteryStatistics
| Name | Value | Description |
| -------------------------- | ---- | ----------------------------- |
| CONSUMPTION_TYPE_INVALID | -17 | Unknown type. |
| CONSUMPTION_TYPE_APP | -16 | Power consumption of an application. |
| CONSUMPTION_TYPE_BLUETOOTH | -15 | Power consumption of Bluetooth. |
| CONSUMPTION_TYPE_IDLE | -14 | Power consumption when the CPU is idle.|
| CONSUMPTION_TYPE_PHONE | -13 | Power consumption of a phone call. |
| CONSUMPTION_TYPE_RADIO | -12 | Power consumption of wireless communication. |
| CONSUMPTION_TYPE_SCREEN | -11 | Power consumption of the screen. |
| CONSUMPTION_TYPE_USER | -10 | Power consumption of the user. |
| CONSUMPTION_TYPE_WIFI | -9 | Power consumption of Wi-Fi. |
# Bluetooth # @ohos.bluetooth
The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -202,7 +203,7 @@ Obtains the connection state of a profile. ...@@ -202,7 +203,7 @@ Obtains the connection state of a profile.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- | | --------- | --------- | ---- | ------------------------------------- |
| ProfileId | profileId | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.| | ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value** **Return value**
...@@ -1280,10 +1281,6 @@ Obtains the connected devices. ...@@ -1280,10 +1281,6 @@ Obtains the connected devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
No value is returned.
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2695,8 +2692,6 @@ Obtains all services of the remote BLE device. This API uses a promise to return ...@@ -2695,8 +2692,6 @@ Obtains all services of the remote BLE device. This API uses a promise to return
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2830,7 +2825,7 @@ Reads the descriptor contained in the specific characteristic of the remote BLE ...@@ -2830,7 +2825,7 @@ Reads the descriptor contained in the specific characteristic of the remote BLE
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ----------------------- | | ---------- | ---------------------------------------- | ---- | ----------------------- |
| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. | | descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. |
| callback | AsyncCallback&lt;[BLECharacteristic](#blecharacteristic)&gt; | Yes | Callback invoked to return the descriptor read.| | callback | AsyncCallback&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Callback invoked to return the descriptor read.|
**Return value** **Return value**
...@@ -3309,7 +3304,7 @@ Enumerates the scan modes. ...@@ -3309,7 +3304,7 @@ Enumerates the scan modes.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ---------------------------------------- | ---- | --------------- | | ---------------------------------------- | ---- | --------------- |
| SCAN_MODE_NONE | 0 | No scan mode. | | SCAN_MODE_NONE | 0 | No scan mode. |
| SCAN_MODE_CONNECTABLE | 1 | Connectable mode. | | SCAN_MODE_CONNECTABLE | 1 | Connectable mode. |
...@@ -3324,7 +3319,7 @@ Enumerates the pairing states. ...@@ -3324,7 +3319,7 @@ Enumerates the pairing states.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ------------------ | ---- | ------ | | ------------------ | ---- | ------ |
| BOND_STATE_INVALID | 0 | Invalid pairing.| | BOND_STATE_INVALID | 0 | Invalid pairing.|
| BOND_STATE_BONDING | 1 | Pairing. | | BOND_STATE_BONDING | 1 | Pairing. |
...@@ -3350,7 +3345,7 @@ Enumerates the SPP link types. ...@@ -3350,7 +3345,7 @@ Enumerates the SPP link types.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ---------- | ---- | ------------- | | ---------- | ---- | ------------- |
| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.| | SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.|
...@@ -3510,7 +3505,7 @@ Enumerates the profile connection states. ...@@ -3510,7 +3505,7 @@ Enumerates the profile connection states.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ------------------- | ---- | -------------- | | ------------------- | ---- | -------------- |
| STATE_DISCONNECTED | 0 | Disconnected. | | STATE_DISCONNECTED | 0 | Disconnected. |
| STATE_CONNECTING | 1 | Connecting.| | STATE_CONNECTING | 1 | Connecting.|
...@@ -3558,7 +3553,7 @@ Enumerates the scan duty options. ...@@ -3558,7 +3553,7 @@ Enumerates the scan duty options.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| --------------------- | ---- | ------------ | | --------------------- | ---- | ------------ |
| SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value.| | SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value.|
| SCAN_MODE_BALANCED | 1 | Balanced mode. | | SCAN_MODE_BALANCED | 1 | Balanced mode. |
...@@ -3571,7 +3566,7 @@ Enumerates the hardware match modes of BLE scan filters. ...@@ -3571,7 +3566,7 @@ Enumerates the hardware match modes of BLE scan filters.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| --------------------- | ---- | ---------------------------------------- | | --------------------- | ---- | ---------------------------------------- |
| MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.| | MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.|
| MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. | | MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. |
...@@ -3596,7 +3591,7 @@ Enumerates the Bluetooth states. ...@@ -3596,7 +3591,7 @@ Enumerates the Bluetooth states.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| --------------------- | ---- | ------------------ | | --------------------- | ---- | ------------------ |
| STATE_OFF | 0 | Bluetooth is turned off. | | STATE_OFF | 0 | Bluetooth is turned off. |
| STATE_TURNING_ON | 1 | Bluetooth is being turned on. | | STATE_TURNING_ON | 1 | Bluetooth is being turned on. |
...@@ -3641,7 +3636,7 @@ Defines the content of a BLE advertisement packet. ...@@ -3641,7 +3636,7 @@ Defines the content of a BLE advertisement packet.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ---------------- | ------------------- | ---- | ---- | ------------------ | | ---------------- | ------------------- | ---- | ---- | ------------------ |
| manufactureId | Array&lt;string&gt; | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG.| | manufactureId | number | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG.|
| manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. | | manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. |
...@@ -3713,7 +3708,7 @@ Enumerates the major classes of Bluetooth devices. ...@@ -3713,7 +3708,7 @@ Enumerates the major classes of Bluetooth devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ------------------- | ------ | ---------- | | ------------------- | ------ | ---------- |
| MAJOR_MISC | 0x0000 | Miscellaneous device. | | MAJOR_MISC | 0x0000 | Miscellaneous device. |
| MAJOR_COMPUTER | 0x0100 | Computer. | | MAJOR_COMPUTER | 0x0100 | Computer. |
...@@ -3734,7 +3729,7 @@ Enumerates the major and minor classes of Bluetooth devices. ...@@ -3734,7 +3729,7 @@ Enumerates the major and minor classes of Bluetooth devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ---------------------------------------- | ------ | --------------- | | ---------------------------------------- | ------ | --------------- |
| COMPUTER_UNCATEGORIZED | 0x0100 | Unclassified computer. | | COMPUTER_UNCATEGORIZED | 0x0100 | Unclassified computer. |
| COMPUTER_DESKTOP | 0x0104 | Desktop computer. | | COMPUTER_DESKTOP | 0x0104 | Desktop computer. |
...@@ -3830,7 +3825,7 @@ Enumerates the A2DP playing states. ...@@ -3830,7 +3825,7 @@ Enumerates the A2DP playing states.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| ----------------- | ------ | ------- | | ----------------- | ------ | ------- |
| STATE_NOT_PLAYING | 0x0000 | Not playing. | | STATE_NOT_PLAYING | 0x0000 | Not playing. |
| STATE_PLAYING | 0x0001 | Playing.| | STATE_PLAYING | 0x0001 | Playing.|
...@@ -3842,9 +3837,9 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS ...@@ -3842,9 +3837,9 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description | | Name | Value | Description |
| -------------------------------- | ------ | --------------- | | -------------------------------- | ------ | --------------- |
| PROFILE_A2DP_SOURCE | 0x0001 | A2DP profile.| | PROFILE_A2DP_SOURCE | 1 | A2DP profile.|
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | HFP profile. | | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
| PROFILE_HID_HOST<sup>9+</sup> | 0x0006 | Human Interface Device (HID) profile. | | PROFILE_HID_HOST<sup>9+</sup> | 6 | Human Interface Device (HID) profile. |
| PROFILE_PAN_NETWORK<sup>9+</sup> | 0x0007 | PAN profile. | | PROFILE_PAN_NETWORK<sup>9+</sup> | 7 | PAN profile. |
# Brightness # Screen Brightness
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Brightness module provides an API for setting the screen brightness. The Brightness module provides an API for setting the screen brightness.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -18,18 +20,30 @@ setValue(value: number): void ...@@ -18,18 +20,30 @@ setValue(value: number): void
Sets the screen brightness. Sets the screen brightness.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
**System capability:** SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ----- | ------ | ---- | ----------- | | ------ | ------ | ---- | ----------------------- |
| value | number | Yes | Brightness value, ranging from **0** to **255**.| | value | number | Yes | Brightness value. The value ranges from 0 to 255.|
**Error codes**
For details about the error codes, see [Screen Brightness Error Codes](../errorcodes/errorcode-brightness.md).
| Code | Error Message |
|---------|---------|
| 4700101 | Operation failed. Cannot connect to service.|
**Example** **Example**
```js ```js
brightness.setValue(128); try {
brightness.setValue(128);
} catch(err) {
console.error('set brightness failed, err: ' + err);
}
``` ```
# Standard NFC Card Emulation # @ohos.nfc.cardEmulation
The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. You can use the APIs provided by this module to determine the card emulation type supported and implement Host-based Card Emulation (HCE). The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. You can use the APIs provided by this module to determine the card emulation type supported and implement Host-based Card Emulation (HCE).
> **NOTE**<br> > **NOTE**
>
> 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.
## Modules to Import ## Modules to Import
``` ```
...@@ -18,7 +18,7 @@ Enumerates the NFC card emulation types. ...@@ -18,7 +18,7 @@ Enumerates the NFC card emulation types.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| HCE | 0 | HCE.| | HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.| | UICC | 1 | Subscriber identity module (SIM) card emulation.|
...@@ -30,8 +30,6 @@ isSupported(feature: number): boolean ...@@ -30,8 +30,6 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported. Checks whether a certain type of card emulation is supported.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Parameters**
...@@ -42,9 +40,9 @@ Checks whether a certain type of card emulation is supported. ...@@ -42,9 +40,9 @@ Checks whether a certain type of card emulation is supported.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.| | boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
## HceService<sup>8+</sup> ## HceService<sup>8+</sup>
......
# Active Tag # @ohos.connectedTag
The **connectedTag** module provides methods for using active tags. You can use the APIs provided by this module to initialize the active tag chip and read and write active tags. The **connectedTag** module provides APIs for using active tags. You can use the APIs to initialize the active tag chip and read and write active tags.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```js
import connectedTag from '@ohos.connectedTag'; import connectedTag from '@ohos.connectedTag';
``` ```
## connectedTag.init ## connectedTag.init
init(): boolean init(): boolean
...@@ -23,11 +22,11 @@ Initializes the active tag chip. ...@@ -23,11 +22,11 @@ Initializes the active tag chip.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value **Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the initialization is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.uninit ## connectedTag.uninit
...@@ -39,125 +38,136 @@ Uninitializes the active tag resources. ...@@ -39,125 +38,136 @@ Uninitializes the active tag resources.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value **Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.readNdefTag ## connectedTag.readNdefTag
readNdefTag(): Promise&lt;string&gt; readNdefTag(): Promise&lt;string&gt;
Reads the content of this active tag. This method uses a promise to return the result. Reads the content of this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value **Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the content of the active tag.|
- Example | **Type**| **Description**|
``` | -------- | -------- |
import connectedTag from '@ohos.connectedTag'; | Promise&lt;string&gt; | Promise used to return the content of the active tag.|
connectedTag.readNdefTag().then(result => { **Example**
console.log("promise recv ndef response: " + result);
}); ```js
``` import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag().then((data) => {
console.log("connectedTag readNdefTag Promise data = " + data);
}).catch((err)=> {
console.log("connectedTag readNdefTag Promise err: " + err);
});
```
## connectedTag.readNdefTag ## connectedTag.readNdefTag
readNdefTag(callback: AsyncCallback&lt;string&gt;): void readNdefTag(callback: AsyncCallback&lt;string&gt;): void
Reads the content of this active tag. This method uses an asynchronous callback to return the result. Reads the content of this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example | **Name**| **Type**| **Mandatory**| **Description**|
``` | -------- | -------- | -------- | -------- |
import connectedTag from '@ohos.connectedTag'; | callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
connectedTag.readNdefTag(result => { **Example**
console.log("callback recv ndef response: " + result);
}); ```js
``` import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag((err, data)=> {
if (err) {
console.log("connectedTag readNdefTag AsyncCallback err: " + err);
} else {
console.log("connectedTag readNdefTag AsyncCallback data: " + data);
}
});
```
## connectedTag.writeNdefTag ## connectedTag.writeNdefTag
writeNdefTag(data: string): Promise&lt;void&gt; writeNdefTag(data: string): Promise&lt;void&gt;
Writes data to this active tag. This method uses a promise to return the result. Writes data to this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | **Name**| **Type**| **Mandatory**| **Description**|
| data | string | Yes| Data to write. The maximum length is 1024 bytes.| | -------- | -------- | -------- | -------- |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
- Return value
| **Type**| **Description**| **Return value**
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. This method returns no value.| | **Type**| **Description**|
| -------- | -------- |
- Example | Promise&lt;void&gt; | Promise that returns no value.|
```
import connectedTag from '@ohos.connectedTag'; **Example**
writeNdefTag.write("010203") ```js
.then((value) => { import connectedTag from '@ohos.connectedTag';
// Data is written to the tag.
console.log(`success to write event: ${value}`); var rawData = "010203"; // change it tobe correct.
}).catch((err) => { connectedTag.writeNdefTag(rawData).then(() => {
// Failed to write data to the tag. console.log("connectedTag writeNdefTag Promise success.");
console.error(`failed to write event because ${err.code}`); }).catch((err)=> {
}); console.log("connectedTag writeNdefTag Promise err: " + err);
``` });
```
## connectedTag.writeNdefTag ## connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void
Writes data to this active tag. This method uses an asynchronous callback to return the result. Writes data to this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | **Name**| **Type**| **Mandatory**| **Description**|
| data | string | Yes| Data to write. The maximum length is 1024 bytes.| | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.| | data | string | Yes| Data to write. The maximum length is 1024 bytes.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example
``` **Example**
import connectedTag from '@ohos.connectedTag';
```js
connectedTag.writeNdefTag("010203", (err, value) => { import connectedTag from '@ohos.connectedTag';
if (err) {
// Failed to write data to the tag. var rawData = "010203"; // change it tobe correct.
console.error(`failed to write event because ${err.code}`); connectedTag.writeNdefTag(rawData, (err)=> {
return; if (err) {
} console.log("connectedTag writeNdefTag AsyncCallback err: " + err);
} else {
// Data is written to the tag. console.log("connectedTag writeNdefTag AsyncCallback success.");
console.log(`success to write event: ${value}`); }
}); });
``` ```
## connectedTag.on('notify') ## connectedTag.on('notify')
...@@ -169,18 +179,12 @@ Registers the NFC field strength state events. ...@@ -169,18 +179,12 @@ Registers the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the field strength state.|
- Enumerates the field strength states.
| **Value**| **Description**|
| -------- | -------- |
| 0 | Field off.|
| 1 | Field on.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the [NfcRfType](#nfcrftype).|
## connectedTag.off('notify') ## connectedTag.off('notify')
...@@ -192,36 +196,54 @@ Unregisters the NFC field strength state events. ...@@ -192,36 +196,54 @@ Unregisters the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | **Name**| **Type**| **Mandatory**| **Description**|
| type | string | Yes| Event type. The value is **notify**.| | -------- | -------- | -------- | -------- |
| callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
- Example
``` **Example**
import connectedTag from '@ohos.connectedTag';
```js
var NFC_RF_NOTIFY = "notify"; import connectedTag from '@ohos.connectedTag';
var recvNfcRfNotifyFunc = result => { // Register the event.
console.info("nfc rf receive state: " + result); connectedTag.on("notify", (err, rfState)=> {
} if (err) {
console.log("connectedTag on Callback err: " + err);
// Register event notification. } else {
connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); console.log("connectedTag on Callback rfState: " + rfState);
}
// Unregister event notification. });
connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
``` var initStatus = connectedTag.init();
console.log("connectedTag init status: " + initStatus);
// Add nfc connecected tag business oprations here...
// connectedTag.writeNdefTag(rawData)
// connectedTag.readNdefTag()
var uninitStatus = connectedTag.uninit();
console.log("connectedTag uninit status: " + uninitStatus);
// Unregister the event.
connectedTag.off("notify", (err, rfState)=> {
if (err) {
console.log("connectedTag off Callback err: " + err);
} else {
console.log("connectedTag off Callback rfState: " + rfState);
}
});
```
## NfcRfType ## NfcRfType
Enumerates the NFC states. Enumerates the NFC field strength states.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
| Name| Default Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field on.| | NFC_RF_LEAVE | 0 | Field off.|
| NFC_RF_ENTER | 1 | Field on.| | NFC_RF_ENTER | 1 | Field on.|
# XML-to-JavaScript Conversion # @ohos.convertxml (XML-to-JavaScript Conversion)
The **convertxml** module provides APIs for converting XML text into JavaScript objects. The **convertxml** module provides APIs for converting XML text into JavaScript objects.
...@@ -36,6 +36,14 @@ Converts an XML text into a JavaScript object. ...@@ -36,6 +36,14 @@ Converts an XML text into a JavaScript object.
| ------ | ---------------------------- | | ------ | ---------------------------- |
| Object | JavaScript object.| | Object | JavaScript object.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200002 | Invalid xml string. |
**Example** **Example**
```js ```js
...@@ -46,13 +54,13 @@ let xml = ...@@ -46,13 +54,13 @@ let xml =
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
let conv = new convertxml.convertToJSObject(); let conv = new convertxml.ConvertXML()
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = JSON.stringify(conv.convertToJSObject(xml, options));
console.log(result); console.log(result);
// Output (non-compact) // Output (non-compact)
// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]} // {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
...@@ -60,14 +68,14 @@ console.log(result); ...@@ -60,14 +68,14 @@ console.log(result);
### convert<sup>(deprecated)</sup> ### convert<sup>(deprecated)</sup>
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject9+](#converttojsobject9) instead.
convert(xml: string, options?: ConvertOptions) : Object convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object. Converts an XML text into a JavaScript object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject<sup>9+</sup>](#converttojsobject9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
......
# Value Bucket # @ohos.data.ValuesBucket
The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database. The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
......
# Device Usage Statistics # @ohos.deviceUsageStatistics (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage. This module provides APIs for collecting statistics on device usage.
...@@ -487,7 +487,7 @@ Enumerates the interval types for querying the application usage duration. ...@@ -487,7 +487,7 @@ Enumerates the interval types for querying the application usage duration.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name | Default Value | Description | | Name | Value | Description |
| ------------ | ---- | ---------------------------------------- | | ------------ | ---- | ---------------------------------------- |
| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.| | BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis. | | BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis. |
......
# Distributed Account Management # @ohos.account.distributedAccount
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login status. The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login states.
> **NOTE**<br> > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -49,7 +49,7 @@ Obtains distributed account information. This API uses an asynchronous callback ...@@ -49,7 +49,7 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the distributed account information obtained. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -124,7 +124,7 @@ Obtains distributed account information. This API uses an asynchronous callback ...@@ -124,7 +124,7 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the distributed account information obtained. Otherwise, **err** is an error object.|
**Example** **Example**
```js ```js
...@@ -181,7 +181,7 @@ Sets the distributed account information. This API uses an asynchronous callback ...@@ -181,7 +181,7 @@ Sets the distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.| | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -219,7 +219,7 @@ Sets the distributed account information. This API uses a promise to return the ...@@ -219,7 +219,7 @@ Sets the distributed account information. This API uses a promise to return the
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.| | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
**Return value** **Return value**
...@@ -322,7 +322,7 @@ Defines distributed OS account information. ...@@ -322,7 +322,7 @@ Defines distributed OS account information.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the distributed account. It must be a non-null string.| | name | string | Yes| Name of the distributed account. It must be a non-null string.|
| id | string | Yes| UID of the distributed account. It must be a non-null string.| | id | string | Yes| UID of the distributed account. It must be a non-null string.|
| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF | | event | string | Yes| Login state of the distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF |
| nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.| | nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.|
| avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.| | avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.|
| scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in query and update methods.| | scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in the setters and getters.|
# Image Processing # @ohos.multimedia.image (Image Processing)
The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read image pixel data (even in an area). The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read image pixel data (even in an area).
...@@ -22,7 +22,7 @@ Creates a **PixelMap** object with the default BGRA_8888 format and pixel proper ...@@ -22,7 +22,7 @@ Creates a **PixelMap** object with the default BGRA_8888 format and pixel proper
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- | | ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | | colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.| | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
...@@ -57,7 +57,7 @@ Creates a **PixelMap** object with the default BGRA_8888 format and pixel proper ...@@ -57,7 +57,7 @@ Creates a **PixelMap** object with the default BGRA_8888 format and pixel proper
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------- |
| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | | colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. | | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. |
...@@ -907,7 +907,7 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret ...@@ -907,7 +907,7 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------ | | -------- | -------------------- | ---- | ------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
...@@ -1077,9 +1077,9 @@ const data = new ArrayBuffer(112); ...@@ -1077,9 +1077,9 @@ const data = new ArrayBuffer(112);
const imageSourceApi = image.createImageSource(data); const imageSourceApi = image.createImageSource(data);
``` ```
## image.createIncrementalSource<sup>9+</sup> ## image.CreateIncrementalSource<sup>9+</sup>
createIncrementalSource(buf: ArrayBuffer): ImageSource CreateIncrementalSource(buf: ArrayBuffer): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers. Creates an **ImageSource** instance in incremental mode based on the buffers.
...@@ -1101,12 +1101,12 @@ Creates an **ImageSource** instance in incremental mode based on the buffers. ...@@ -1101,12 +1101,12 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js ```js
const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4.
const imageSourceIncrementalSApi = image.createIncrementalSource(buf); const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
``` ```
## image.createIncrementalSource<sup>9+</sup> ## image.CreateIncrementalSource<sup>9+</sup>
createIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers. Creates an **ImageSource** instance in incremental mode based on the buffers.
...@@ -1129,7 +1129,7 @@ Creates an **ImageSource** instance in incremental mode based on the buffers. ...@@ -1129,7 +1129,7 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js ```js
const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4.
const imageSourceIncrementalSApi = image.createIncrementalSource(buf); const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
``` ```
## ImageSource ## ImageSource
...@@ -1181,7 +1181,7 @@ Obtains information about this image. This API uses an asynchronous callback to ...@@ -1181,7 +1181,7 @@ Obtains information about this image. This API uses an asynchronous callback to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ---------------------------------------- | | -------- | -------------------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.| | callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.|
...@@ -1203,7 +1203,7 @@ Obtains information about an image with the specified index. This API uses a pro ...@@ -1203,7 +1203,7 @@ Obtains information about an image with the specified index. This API uses a pro
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ----- | ------ | ---- | ------------------------------------- | | ----- | ------ | ---- | ------------------------------------- |
| index | number | No | Index of the image. If this parameter is not set, the default value **0** is used.| | index | number | No | Index of the image. If this parameter is not set, the default value **0** is used.|
...@@ -1234,7 +1234,7 @@ Obtains the value of a property with the specified index in this image. This API ...@@ -1234,7 +1234,7 @@ Obtains the value of a property with the specified index in this image. This API
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------------------- | ---- | ------------------------------------ | | ------- | ---------------------------------------------------- | ---- | ------------------------------------ |
| key | string | Yes | Name of the property. | | key | string | Yes | Name of the property. |
| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | No | Image properties, including the image index and default property value.| | options | [GetImagePropertyOptions](#getimagepropertyoptions7) | No | Image properties, including the image index and default property value.|
...@@ -1372,12 +1372,12 @@ Updates incremental data. This API uses a promise to return the result. ...@@ -1372,12 +1372,12 @@ Updates incremental data. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ----------- | ---- | ------------ | | ---------- | ----------- | ---- | ------------ |
| buf | ArrayBuffer | Yes | Incremental data. | | buf | ArrayBuffer | Yes | Incremental data. |
| isFinished | boolean | Yes | Whether the update is complete.| | isFinished | boolean | Yes | Whether the update is complete.|
| value | number | No | Offset for data reading. | | value | number | Yes | Offset for data reading. |
| length | number | No | Array length. | | length | number | Yes | Array length. |
**Return value** **Return value**
...@@ -1405,12 +1405,12 @@ Updates incremental data. This API uses an asynchronous callback to return the r ...@@ -1405,12 +1405,12 @@ Updates incremental data. This API uses an asynchronous callback to return the r
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | -------------------- | | ---------- | ------------------- | ---- | -------------------- |
| buf | ArrayBuffer | Yes | Incremental data. | | buf | ArrayBuffer | Yes | Incremental data. |
| isFinished | boolean | Yes | Whether the update is complete. | | isFinished | boolean | Yes | Whether the update is complete. |
| value | number | No | Offset for data reading. | | value | number | Yes | Offset for data reading. |
| length | number | No | Array length. | | length | number | Yes | Array length. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1434,7 +1434,7 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -1434,7 +1434,7 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | ---------- | | ------- | ------------------------------------ | ---- | ---------- |
| options | [DecodingOptions](#decodingoptions7) | No | Image decoding parameters.| | options | [DecodingOptions](#decodingoptions7) | No | Image decoding parameters.|
...@@ -1486,7 +1486,7 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -1486,7 +1486,7 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------------- | | -------- | ------------------------------------- | ---- | -------------------------- |
| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. | | options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| | callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
...@@ -1518,7 +1518,7 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t ...@@ -1518,7 +1518,7 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------------- | | -------- | -------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.| | callback | AsyncCallback\<void> | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.|
...@@ -1768,11 +1768,11 @@ Creates an **ImageReceiver** instance by specifying the image width, height, for ...@@ -1768,11 +1768,11 @@ Creates an **ImageReceiver** instance by specifying the image width, height, for
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- | | -------- | ------ | ---- | ---------------------- |
| width | number | Yes | Default image width. | | width | number | Yes | Default image width. |
| height | number | Yes | Default image height. | | height | number | Yes | Default image height. |
| format | number | Yes | Image format, which is a constant of [ImageFormat](#imageformat9). (Currently, the value of this parameter is agreed between the user and camera. In the future, there may be other application scenarios. The receiver is used only for transfer. Currently, only **ImageFormat:JPEG** is supported.) | | format | number | Yes | Image format, which is a constant of [ImageFormat](#imageformat9). (Only ImageFormat:JPEG and 4 are supported.) |
| capacity | number | Yes | Maximum number of images that can be accessed at the same time.| | capacity | number | Yes | Maximum number of images that can be accessed at the same time.|
**Return value** **Return value**
...@@ -1813,7 +1813,7 @@ Obtains a surface ID for the camera or other components. This API uses an asynch ...@@ -1813,7 +1813,7 @@ Obtains a surface ID for the camera or other components. This API uses an asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------- | | -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the surface ID.| | callback | AsyncCallback\<string> | Yes | Callback used to return the surface ID.|
...@@ -1913,7 +1913,7 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async ...@@ -1913,7 +1913,7 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | -------------------------- | | -------- | ------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback<[Image](#image9)> | Yes | Callback used to return the next image.| | callback | AsyncCallback<[Image](#image9)> | Yes | Callback used to return the next image.|
...@@ -1963,7 +1963,7 @@ Listens for image arrival events. ...@@ -1963,7 +1963,7 @@ Listens for image arrival events.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------ | | -------- | -------------------- | ---- | ------------------------------------------------------ |
| type | string | Yes | Type of event to listen for. The value is fixed at **imageArrival**, which is triggered when an image is received.| | type | string | Yes | Type of event to listen for. The value is fixed at **imageArrival**, which is triggered when an image is received.|
| callback | AsyncCallback\<void> | Yes | Callback invoked for the event. | | callback | AsyncCallback\<void> | Yes | Callback invoked for the event. |
...@@ -1984,7 +1984,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback ...@@ -1984,7 +1984,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
...@@ -2028,7 +2028,7 @@ Creates an **ImageCreator** instance by specifying the image width, height, form ...@@ -2028,7 +2028,7 @@ Creates an **ImageCreator** instance by specifying the image width, height, form
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- | | -------- | ------ | ---- | ---------------------- |
| width | number | Yes | Default image width. | | width | number | Yes | Default image width. |
| height | number | Yes | Default image height. | | height | number | Yes | Default image height. |
...@@ -2071,7 +2071,7 @@ Obtains an image buffer from the idle queue and writes image data into it. This ...@@ -2071,7 +2071,7 @@ Obtains an image buffer from the idle queue and writes image data into it. This
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ---------------------------------------| ---- | -------------------- | | ------------- | ---------------------------------------| ---- | -------------------- |
| callback | AsyncCallback\<Image> | Yes | Callback used to return the drawn image.| | callback | AsyncCallback\<Image> | Yes | Callback used to return the drawn image.|
...@@ -2080,9 +2080,9 @@ Obtains an image buffer from the idle queue and writes image data into it. This ...@@ -2080,9 +2080,9 @@ Obtains an image buffer from the idle queue and writes image data into it. This
```js ```js
creator.dequeueImage((err, img) => { creator.dequeueImage((err, img) => {
if (err) { if (err) {
console.info('dequeueImage succeeded.'); console.info('dequeueImage failed.');
} }
console.info('dequeueImage failed.'); console.info('dequeueImage succeeded.');
}); });
``` ```
...@@ -2120,7 +2120,7 @@ Places the drawn image in the dirty queue. This API uses an asynchronous callbac ...@@ -2120,7 +2120,7 @@ Places the drawn image in the dirty queue. This API uses an asynchronous callbac
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | -------------------------| ---- | -------------------- | | ------------- | -------------------------| ---- | -------------------- |
| interface | Image | Yes | Drawn image.| | interface | Image | Yes | Drawn image.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.|
...@@ -2128,12 +2128,25 @@ Places the drawn image in the dirty queue. This API uses an asynchronous callbac ...@@ -2128,12 +2128,25 @@ Places the drawn image in the dirty queue. This API uses an asynchronous callbac
**Example** **Example**
```js ```js
creator.queueImage(img, (err) => { creator.dequeueImage().then(img => {
if (err) { // Draw the image.
console.info('dequeueImage failed: ' + err); img.getComponent(4).then(component => {
} var bufferArr = new Uint8Array(component.byteBuffer);
console.info('dequeueImage succeeded'); for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
bufferArr[i + 2] = 255; //R
bufferArr[i + 3] = 255; //A
}
})
creator.queueImage(img, (err) => {
if (err) {
console.info('queueImage failed: ' + err);
}
console.info('queueImage succeeded');
})
}) })
``` ```
### queueImage<sup>9+</sup> ### queueImage<sup>9+</sup>
...@@ -2159,11 +2172,24 @@ Places the drawn image in the dirty queue. This API uses a promise to return the ...@@ -2159,11 +2172,24 @@ Places the drawn image in the dirty queue. This API uses a promise to return the
**Example** **Example**
```js ```js
creator.queueImage(img).then(() => { creator.dequeueImage().then(img => {
console.info('dequeueImage succeeded.'); // Draw the image.
}).catch(error => { img.getComponent(4).then(component => {
console.info('dequeueImage failed: ' + error); var bufferArr = new Uint8Array(component.byteBuffer);
for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
bufferArr[i + 2] = 255; //R
bufferArr[i + 3] = 255; //A
}
})
creator.queueImage(img).then(() => {
console.info('queueImage succeeded.');
}).catch(error => {
console.info('queueImage failed: ' + error);
})
}) })
``` ```
### on<sup>9+</sup> ### on<sup>9+</sup>
...@@ -2176,7 +2202,7 @@ Listens for image release events. This API uses an asynchronous callback to retu ...@@ -2176,7 +2202,7 @@ Listens for image release events. This API uses an asynchronous callback to retu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | -------------------------| ---- | -------------------- | | ------------- | -------------------------| ---- | -------------------- |
| type | string | Yes | Type of event, which is **'imageRelease'**.| | type | string | Yes | Type of event, which is **'imageRelease'**.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.|
...@@ -2264,7 +2290,7 @@ Obtains the component buffer from the **Image** instance based on the color comp ...@@ -2264,7 +2290,7 @@ Obtains the component buffer from the **Image** instance based on the color comp
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | --------------------------------------- | ---- | -------------------- | | ------------- | --------------------------------------- | ---- | -------------------- |
| componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image. | | componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image. |
| callback | AsyncCallback<[Component](#component9)> | Yes | Callback used to return the component buffer.| | callback | AsyncCallback<[Component](#component9)> | Yes | Callback used to return the component buffer.|
...@@ -2291,7 +2317,7 @@ Obtains the component buffer from the **Image** instance based on the color comp ...@@ -2291,7 +2317,7 @@ Obtains the component buffer from the **Image** instance based on the color comp
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | -------------------------------- | ---- | ---------------- | | ------------- | -------------------------------- | ---- | ---------------- |
| componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image.| | componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image.|
...@@ -2319,7 +2345,7 @@ The corresponding resources must be released before another image arrives. ...@@ -2319,7 +2345,7 @@ The corresponding resources must be released before another image arrives.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------- | | -------- | -------------------- | ---- | -------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
...@@ -2398,7 +2424,7 @@ Enumerates the pixel formats of images. ...@@ -2398,7 +2424,7 @@ Enumerates the pixel formats of images.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description | | Name | Value | Description |
| ---------------------- | ------ | ----------------- | | ---------------------- | ------ | ----------------- |
| UNKNOWN | 0 | Unknown format. | | UNKNOWN | 0 | Unknown format. |
| RGB_565 | 2 | RGB_565. | | RGB_565 | 2 | RGB_565. |
...@@ -2416,7 +2442,7 @@ Enumerates the alpha types of images. ...@@ -2416,7 +2442,7 @@ Enumerates the alpha types of images.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description | | Name | Value | Description |
| -------- | ------ | ----------------------- | | -------- | ------ | ----------------------- |
| UNKNOWN | 0 | Unknown alpha type. | | UNKNOWN | 0 | Unknown alpha type. |
| OPAQUE | 1 | There is no alpha or the image is opaque.| | OPAQUE | 1 | There is no alpha or the image is opaque.|
...@@ -2429,7 +2455,7 @@ Enumerates the scale modes of images. ...@@ -2429,7 +2455,7 @@ Enumerates the scale modes of images.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description | | Name | Value | Description |
| --------------- | ------ | -------------------------------------------------- | | --------------- | ------ | -------------------------------------------------- |
| CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.| | CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.|
| FIT_TARGET_SIZE | 0 | Reduces the image size to the dimensions of the target. | | FIT_TARGET_SIZE | 0 | Reduces the image size to the dimensions of the target. |
...@@ -2519,7 +2545,7 @@ Describes the exchangeable image file format (EXIF) information of an image. ...@@ -2519,7 +2545,7 @@ Describes the exchangeable image file format (EXIF) information of an image.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value | Description | | Name | Value | Description |
| ----------------- | ----------------------- | ------------------------ | | ----------------- | ----------------------- | ------------------------ |
| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. | | BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. |
| ORIENTATION | "Orientation" | Image orientation. | | ORIENTATION | "Orientation" | Image orientation. |
...@@ -2542,7 +2568,7 @@ Enumerates the image formats. ...@@ -2542,7 +2568,7 @@ Enumerates the image formats.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description | | Name | Value | Description |
| ------------ | ------ | -------------------- | | ------------ | ------ | -------------------- |
| YCBCR_422_SP | 1000 | YCBCR422 semi-planar format.| | YCBCR_422_SP | 1000 | YCBCR422 semi-planar format.|
| JPEG | 2000 | JPEG encoding format. | | JPEG | 2000 | JPEG encoding format. |
...@@ -2553,7 +2579,7 @@ Enumerates the color component types of images. ...@@ -2553,7 +2579,7 @@ Enumerates the color component types of images.
**System capability**: SystemCapability.Multimedia.Image.ImageReceiver **System capability**: SystemCapability.Multimedia.Image.ImageReceiver
| Name | Default Value| Description | | Name | Value | Description |
| ----- | ------ | ----------- | | ----- | ------ | ----------- |
| YUV_Y | 1 | Luminance component. | | YUV_Y | 1 | Luminance component. |
| YUV_U | 2 | Chrominance component. | | YUV_U | 2 | Chrominance component. |
......
# OS Account Management # @ohos.account.osAccount
The **osAccount** module provides basic capabilities for managing OS accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account. The **osAccount** module provides basic capabilities for managing OS accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -2708,7 +2709,6 @@ Obtains the constraint source information of an OS account. This API uses a prom ...@@ -2708,7 +2709,6 @@ Obtains the constraint source information of an OS account. This API uses a prom
console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e)); console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
} }
``` ```
### isMultiOsAccountEnable<sup>(deprecated)</sup> ### isMultiOsAccountEnable<sup>(deprecated)</sup>
isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -4280,17 +4280,12 @@ Register a PIN inputer. ...@@ -4280,17 +4280,12 @@ Register a PIN inputer.
| ----------| ----------------------- | --- | -------------------------- | | ----------| ----------------------- | --- | -------------------------- |
| inputer | [IInputer](#iinputer8) | Yes | PIN inputer, which is used to obtain the PIN.| | inputer | [IInputer](#iinputer8) | Yes | PIN inputer, which is used to obtain the PIN.|
**Return value**
| Type | Description |
| :------ | :-------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | --------------------------- | | -------- | --------------------------- |
| 12300001 | System service exception. | | 12300001 | System service exception. |
| 12300102 | Invalid inputer. |
| 12300103 | Inputer already registered. | | 12300103 | Inputer already registered. |
**Example** **Example**
...@@ -4299,8 +4294,8 @@ Register a PIN inputer. ...@@ -4299,8 +4294,8 @@ Register a PIN inputer.
let password = new Uint8Array([0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0]);
try { try {
let result = pinAuth.registerInputer({ let result = pinAuth.registerInputer({
onGetData: (pinSubType, callback) => { onGetData: (authSubType, callback) => {
callback.onSetData(pinSubType, password); callback.onSetData(authSubType, password);
} }
}); });
console.log('registerInputer result = ' + result); console.log('registerInputer result = ' + result);
...@@ -4327,6 +4322,91 @@ Unregisters this PIN inputer. ...@@ -4327,6 +4322,91 @@ Unregisters this PIN inputer.
pinAuth.unregisterInputer(); pinAuth.unregisterInputer();
``` ```
### InputerManager <sup>10+</sup>
Provides APIs for managing credential inputers.
### registerInputer<sup>10+</sup>
registerInputer(authType: AuthType, inputer: IInputer): void;
Register a credential inputer.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| ----------| ----------------------- | --- | -------------------------- |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type.|
| inputer | [IInputer](#iinputer8) | Yes | Credential inputer to register.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300001 | System service exception. |
| 12300102 | Invalid authType or inputer. |
| 12300103 | The credential inputer has been registered. |
| 12300106 | Unsupported authType. |
**Example**
```js
let inputerMgr = new account_osAccount.InputerManager();
let authType = account_osAccount.AuthType.DOMAIN;
let password = new Uint8Array([0, 0, 0, 0, 0]);
try {
InputerMgr.registerInputer(authType, {
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
});
console.log('registerInputer success.');
} catch (e) {
console.log('registerInputer exception = ' + JSON.stringify(e));
}
```
### unregisterInputer<sup>10+</sup>
unregisterInputer(authType: AuthType): void;
Unregisters this credential inputer.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| ----------| ----------------------- | --- | -------------------------- |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300002 | Invalid authType. |
**Example**
```js
let inputerMgr = new account_osAccount.InputerManager();
let authType = account_osAccount.AuthType.DOMAIN;
try {
inputerMgr.unregisterInputer(authType);
console.log('unregisterInputer success.');
} catch(err) {
console.log("unregisterInputer err:" + JSON.stringify(err));
}
```
## UserIdentityManager<sup>8+</sup> ## UserIdentityManager<sup>8+</sup>
Provides APIs for user identity management (IDM). Provides APIs for user identity management (IDM).
...@@ -4456,8 +4536,8 @@ Adds credential information, including the credential type, subtype, and token ( ...@@ -4456,8 +4536,8 @@ Adds credential information, including the credential type, subtype, and token (
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let pinAuth = new account_osAccount.PINAuth(); let pinAuth = new account_osAccount.PINAuth();
pinAuth.registerInputer({ pinAuth.registerInputer({
onGetData: (pinSubType, callback) => { onGetData: (authSubType, callback) => {
callback.onSetData(pinSubType, password); callback.onSetData(authSubType, password);
} }
}); });
let credentialInfo = { let credentialInfo = {
...@@ -4470,12 +4550,12 @@ Adds credential information, including the credential type, subtype, and token ( ...@@ -4470,12 +4550,12 @@ Adds credential information, including the credential type, subtype, and token (
try { try {
userIDM.addCredential(credentialInfo, { userIDM.addCredential(credentialInfo, {
onResult: (result, extraInfo) => { onResult: (result, extraInfo) => {
console.log('updateCredential result = ' + result); console.log('addCredential result = ' + result);
console.log('updateCredential extraInfo = ' + extraInfo); console.log('addCredential extraInfo = ' + extraInfo);
} }
}); });
} catch (e) { } catch (e) {
console.log('updateCredential exception = ' + JSON.stringify(e)); console.log('addCredential exception = ' + JSON.stringify(e));
} }
}); });
``` ```
...@@ -4520,8 +4600,8 @@ Updates credential information. This API uses a callback to return the result. ...@@ -4520,8 +4600,8 @@ Updates credential information. This API uses a callback to return the result.
token: null token: null
}; };
pinAuth.registerInputer({ pinAuth.registerInputer({
onGetData: (pinSubType, callback) => { onGetData: (authSubType, callback) => {
callback.onSetData(pinSubType, password); callback.onSetData(authSubType, password);
} }
}); });
userIDM.openSession((err, challenge) => { userIDM.openSession((err, challenge) => {
...@@ -4820,7 +4900,7 @@ Provides callbacks for PIN operations. ...@@ -4820,7 +4900,7 @@ Provides callbacks for PIN operations.
### onSetData<sup>8+</sup> ### onSetData<sup>8+</sup>
onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
**System API**: This is a system API. **System API**: This is a system API.
...@@ -4832,7 +4912,7 @@ Called to set data in a PIN operation. ...@@ -4832,7 +4912,7 @@ Called to set data in a PIN operation.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- | | ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
| pinSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype. | | authSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype. |
| data | Uint8Array | Yes | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.| | data | Uint8Array | Yes | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.|
**Example** **Example**
...@@ -4840,11 +4920,11 @@ Called to set data in a PIN operation. ...@@ -4840,11 +4920,11 @@ Called to set data in a PIN operation.
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]); let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = { let inputer = {
onGetData: (pinSubType, callback) => { onGetData: (authSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) { if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber); callback.onSetData(authSubType, passwordNumber);
} else { } else {
callback.onSetData(pinSubType, password); callback.onSetData(authSubType, password);
} }
} }
}; };
...@@ -4852,13 +4932,13 @@ Called to set data in a PIN operation. ...@@ -4852,13 +4932,13 @@ Called to set data in a PIN operation.
## IInputer<sup>8+</sup> ## IInputer<sup>8+</sup>
Provides callbacks for the PIN input box. Provides callbacks for credential inputers.
**System API**: This is a system API. **System API**: This is a system API.
### onGetData<sup>8+</sup> ### onGetData<sup>8+</sup>
onGetData: (pinSubType: AuthSubType, callback: IInputData) => void; onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
Called to obtain data. Called to obtain data.
...@@ -4877,11 +4957,11 @@ Called to obtain data. ...@@ -4877,11 +4957,11 @@ Called to obtain data.
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]); let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = { let inputer = {
onGetData: (pinSubType, callback) => { onGetData: (authSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) { if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber); callback.onSetData(authSubType, passwordNumber);
} else { } else {
callback.onSetData(pinSubType, password); callback.onSetData(authSubType, password);
} }
} }
}; };
...@@ -5157,6 +5237,8 @@ Enumerates the authentication credential types. ...@@ -5157,6 +5237,8 @@ Enumerates the authentication credential types.
| ----- | ----- | ---------------- | | ----- | ----- | ---------------- |
| PIN | 1 | PIN authentication.| | PIN | 1 | PIN authentication.|
| FACE | 2 | Facial authentication.| | FACE | 2 | Facial authentication.|
| FINGERPRINT<sup>10+</sup> | 4 | Fingerprint authentication.|
| DOMAIN<sup>10+</sup> | 1024 | Domain authentication.|
## AuthSubType<sup>8+</sup> ## AuthSubType<sup>8+</sup>
...@@ -5170,9 +5252,10 @@ Enumerates the authentication credential subtypes. ...@@ -5170,9 +5252,10 @@ Enumerates the authentication credential subtypes.
| ---------- | ----- | ------------------ | | ---------- | ----- | ------------------ |
| PIN_SIX | 10000 | Six-digit PIN. | | PIN_SIX | 10000 | Six-digit PIN. |
| PIN_NUMBER | 10001 | Custom PIN.| | PIN_NUMBER | 10001 | Custom PIN.|
| PIN_MIXED | 10002 | Custom mixed credential.| | PIN_MIXED | 10002 | Custom mixed credentials.|
| FACE_2D | 20000 | 2D face credential. | | FACE_2D | 20000 | 2D face credential. |
| FACE_3D | 20001 | 3D face credential. | | FACE_3D | 20001 | 3D face credential. |
| DOMAIN_MIXED<sup>10+</sup> | 10240001 | Mixed domain authentication credentials. |
## AuthTrustLevel<sup>8+</sup> ## AuthTrustLevel<sup>8+</sup>
......
# Obtaining Process Information # @ohos.process (Obtaining Process Information)
> **NOTE** > **NOTE**
> >
...@@ -18,13 +18,13 @@ import process from '@ohos.process'; ...@@ -18,13 +18,13 @@ import process from '@ohos.process';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| egid | number | Yes| No| Effective group identifier (EGID) of a process. This is a system API and cannot be called by third-party applications.| | egid | number | Yes| No| Effective group identifier (EGID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process. This is a system API and cannot be called by third-party applications.| | euid | number | Yes| No| Effective user identifier (EUID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| gid | number | Yes| No| Group identifier (GID) of a process. This is a system API and cannot be called by third-party applications.| | gid | number | Yes| No| Group identifier (GID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| uid | number | Yes| No| User identifier (UID) of a process.| | uid | number | Yes| No| User identifier (UID) of a process.|
| groups | number[] | Yes| No| Array with supplementary group IDs. This is a system API and cannot be called by third-party applications.| | groups | number[] | Yes| No| Array with supplementary group IDs.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| pid | number | Yes| No| Process ID (PID) of a process.| | pid | number | Yes| No| Process ID (PID) of a process.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process. This is a system API and cannot be called by third-party applications.| | ppid | number | Yes| No| Parent process ID (PPID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.| | tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.|
...@@ -32,7 +32,7 @@ import process from '@ohos.process'; ...@@ -32,7 +32,7 @@ import process from '@ohos.process';
Provides APIs for throwing exceptions during the addition of a process. Provides APIs for throwing exceptions during the addition of a process.
### process.isAppUid<sup>9+</sup> ### isAppUid<sup>9+</sup>
isAppUid(v: number): boolean isAppUid(v: number): boolean
...@@ -60,7 +60,7 @@ let result = pro.isAppUid(688); ...@@ -60,7 +60,7 @@ let result = pro.isAppUid(688);
``` ```
### process.getUidForName<sup>9+</sup> ### getUidForName<sup>9+</sup>
getUidForName(v: string): number getUidForName(v: string): number
...@@ -88,7 +88,7 @@ let pres = pro .getUidForName("tool"); ...@@ -88,7 +88,7 @@ let pres = pro .getUidForName("tool");
``` ```
### process.getThreadPriority<sup>9+</sup> ### getThreadPriority<sup>9+</sup>
getThreadPriority(v: number): number getThreadPriority(v: number): number
...@@ -117,7 +117,7 @@ let pres = pro.getThreadPriority(tid); ...@@ -117,7 +117,7 @@ let pres = pro.getThreadPriority(tid);
``` ```
### process.getSystemConfig<sup>9+</sup> ### getSystemConfig<sup>9+</sup>
getSystemConfig(name: number): number getSystemConfig(name: number): number
...@@ -146,7 +146,7 @@ let pres = pro.getSystemConfig(_SC_ARG_MAX); ...@@ -146,7 +146,7 @@ let pres = pro.getSystemConfig(_SC_ARG_MAX);
``` ```
### process.getEnvironmentVar<sup>9+</sup> ### getEnvironmentVar<sup>9+</sup>
getEnvironmentVar(name: string): string getEnvironmentVar(name: string): string
...@@ -174,7 +174,7 @@ let pres = pro.getEnvironmentVar("PATH"); ...@@ -174,7 +174,7 @@ let pres = pro.getEnvironmentVar("PATH");
``` ```
### process.exit<sup>9+</sup> ### exit<sup>9+</sup>
exit(code: number): void exit(code: number): void
...@@ -198,7 +198,7 @@ pro.exit(0); ...@@ -198,7 +198,7 @@ pro.exit(0);
``` ```
### process.kill<sup>9+</sup> ### kill<sup>9+</sup>
kill(signal: number, pid: number): boolean kill(signal: number, pid: number): boolean
...@@ -238,10 +238,10 @@ Allows a process to obtain the standard input and output of its child processes, ...@@ -238,10 +238,10 @@ Allows a process to obtain the standard input and output of its child processes,
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| PID of the child process. This is a system API and cannot be called by third-party applications.| | pid | number | Yes| No| PID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| ppid | number | Yes| No| PPID of the child process. This is a system API and cannot be called by third-party applications.| | ppid | number | Yes| No| PPID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| exitCode | number | Yes| No| Exit code of the child process. This is a system API and cannot be called by third-party applications.| | exitCode | number | Yes| No| Exit code of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it. This is a system API and cannot be called by third-party applications.| | killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it.<br>**System API**: This is a system API.<br>It is used only to test applications.|
### wait ### wait
...@@ -250,7 +250,9 @@ wait(): Promise&lt;number&gt; ...@@ -250,7 +250,9 @@ wait(): Promise&lt;number&gt;
Waits until the child process ends. This method uses a promise to return the exit code of the child process. Waits until the child process ends. This method uses a promise to return the exit code of the child process.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -277,7 +279,9 @@ getOutput(): Promise&lt;Uint8Array&gt; ...@@ -277,7 +279,9 @@ getOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard output of the child process. Obtains the standard output of the child process.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -304,7 +308,9 @@ getErrorOutput(): Promise&lt;Uint8Array&gt; ...@@ -304,7 +308,9 @@ getErrorOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard error output of the child process. Obtains the standard error output of the child process.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -331,7 +337,9 @@ close(): void ...@@ -331,7 +337,9 @@ close(): void
Closes the child process in running. Closes the child process in running.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -349,7 +357,9 @@ kill(signal: number | string): void ...@@ -349,7 +357,9 @@ kill(signal: number | string): void
Sends a signal to the specified child process to terminate it. Sends a signal to the specified child process to terminate it.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -593,7 +603,9 @@ runCmd(command: string, options?: { timeout?: number, killSignal?: number | stri ...@@ -593,7 +603,9 @@ runCmd(command: string, options?: { timeout?: number, killSignal?: number | stri
Forks a new process to run a shell command and returns the **ChildProcess** object. Forks a new process to run a shell command and returns the **ChildProcess** object.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -609,7 +621,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -609,7 +621,7 @@ This is a system API and cannot be called by third-party applications.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| timeout | number | No| Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.| | timeout | number | No| Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.|
| killSignal | number \| string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.| | killSignal | number&nbsp;\|&nbsp;string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.|
| maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.| | maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.|
**Return value** **Return value**
...@@ -650,7 +662,9 @@ on(type: string, listener: EventListener): void ...@@ -650,7 +662,9 @@ on(type: string, listener: EventListener): void
Stores the events triggered by the user. Stores the events triggered by the user.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -682,7 +696,9 @@ off(type: string): boolean ...@@ -682,7 +696,9 @@ off(type: string): boolean
Deletes the event stored by the user. Deletes the event stored by the user.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -737,7 +753,9 @@ cwd(): string ...@@ -737,7 +753,9 @@ cwd(): string
Obtains the working directory of this process. Obtains the working directory of this process.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -754,7 +772,9 @@ chdir(dir: string): void ...@@ -754,7 +772,9 @@ chdir(dir: string): void
Changes the working directory of this process. Changes the working directory of this process.
This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
......
# Device Usage Statistics # @ohos.resourceschedule.usageStatistics (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage. This module provides APIs for collecting statistics on device usage.
...@@ -703,7 +703,7 @@ Queries FA usage records. This API uses an asynchronous callback to return a max ...@@ -703,7 +703,7 @@ Queries FA usage records. This API uses an asynchronous callback to return a max
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- | | -------- | ---------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | Yes | Callback used to return a maximum of 1000 FA usage records.| | callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | Yes | Callback used to return a maximum of **maxNum** FA usage records.|
**Error codes** **Error codes**
......
# RPC # @ohos.rpc
The **RPC** module implements communication between processes, including inter-process communication (IPC) on a single device and remote procedure call (RPC) between processes on difference devices. IPC is implemented based on the Binder driver, and RPC is based on the DSoftBus driver. The **RPC** module implements communication between processes, including inter-process communication (IPC) on a single device and remote procedure call (RPC) between processes on difference devices. IPC is implemented based on the Binder driver, and RPC is based on the DSoftBus driver.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> This module supports return of error codes since API version 9. > This module supports return of error codes since API version 9.
...@@ -24,7 +26,7 @@ The APIs of this module return exceptions since API version 9. The following tab ...@@ -24,7 +26,7 @@ The APIs of this module return exceptions since API version 9. The following tab
| ------------------------------------- | ------- | --------------------------------------------- | | ------------------------------------- | ------- | --------------------------------------------- |
| CHECK_PARAM_ERROR | 401 | Parameter check failed. | | CHECK_PARAM_ERROR | 401 | Parameter check failed. |
| OS_MMAP_ERROR | 1900001 | Failed to call mmap. | | OS_MMAP_ERROR | 1900001 | Failed to call mmap. |
| OS_IOCTL_ERROR | 1900002 | Failed to execute **ioctl** with the shared memory file descriptor.| | OS_IOCTL_ERROR | 1900002 | Failed to call **ioctl** with the shared memory file descriptor.|
| WRITE_TO_ASHMEM_ERROR | 1900003 | Failed to write data to the shared memory. | | WRITE_TO_ASHMEM_ERROR | 1900003 | Failed to write data to the shared memory. |
| READ_FROM_ASHMEM_ERROR | 1900004 | Failed to read data from the shared memory. | | READ_FROM_ASHMEM_ERROR | 1900004 | Failed to read data from the shared memory. |
| ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | This operation is allowed only on the proxy object. | | ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | This operation is allowed only on the proxy object. |
...@@ -123,7 +125,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -123,7 +125,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readRemoteObject(): IRemoteObject readRemoteObject(): IRemoteObject
Reads a remote object from **MessageSequence**. You can use this API to deserialize the **MessageSequence** object to generate an **IRemoteObject**. The remote object is read in the order in which it is written to this **MessageSequence** object. Reads the remote object from **MessageSequence**. You can use this API to deserialize the **MessageSequence** object to generate an **IRemoteObject**. The remote object is read in the order in which it is written to this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -405,7 +407,7 @@ Obtains the read position of this **MessageSequence** object. ...@@ -405,7 +407,7 @@ Obtains the read position of this **MessageSequence** object.
| Type| Description| | Type| Description|
| ------ | ------ | | ------ | ------ |
| number | Current read position of the **MessageSequence** object.| | number | Read position obtained.|
**Example** **Example**
...@@ -427,7 +429,7 @@ Obtains the write position of this **MessageSequence** object. ...@@ -427,7 +429,7 @@ Obtains the write position of this **MessageSequence** object.
| Type| Description| | Type| Description|
| ------ | ----- | | ------ | ----- |
| number | Current write position of the **MessageSequence** object.| | number | Write position obtained.|
**Example** **Example**
...@@ -504,7 +506,7 @@ Moves the write pointer to the specified position. ...@@ -504,7 +506,7 @@ Moves the write pointer to the specified position.
writeByte(val: number): void writeByte(val: number): void
Writes a Byte value to this **MessageSequence** object. Writes a byte value to this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -538,7 +540,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -538,7 +540,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readByte(): number readByte(): number
Reads the Byte value from this **MessageSequence** object. Reads the byte value from this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -2856,7 +2858,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2856,7 +2858,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readFileDescriptor(): number readFileDescriptor(): number
Reads a file descriptor from this **MessageSequence** object. Reads the file descriptor from this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -4017,7 +4019,7 @@ Writes a string to this **MessageParcel** object. ...@@ -4017,7 +4019,7 @@ Writes a string to this **MessageParcel** object.
readString(): string readString(): string
Reads a string from this **MessageParcel** object. Reads the string from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册