提交 776a3088 编写于 作者: L luoying_ace 提交者: Gitee

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

...@@ -23,11 +23,17 @@ zh-cn/device-dev/quick-start/ @li-yan339 ...@@ -23,11 +23,17 @@ zh-cn/device-dev/quick-start/ @li-yan339
zh-cn/device-dev/driver/ @li-yan339 zh-cn/device-dev/driver/ @li-yan339
zh-cn/device-dev/get-code/ @li-yan339 zh-cn/device-dev/get-code/ @li-yan339
zh-cn/device-dev/hpm-part/ @duangavin123_admin zh-cn/device-dev/hpm-part/ @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 zh-cn/device-dev/reference/hdi-apis/ @li-yan339
zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md @li-yan339 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @li-yan339 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 zh-cn/device-dev/porting/porting-thirdparty-overview.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 zh-cn/device-dev/porting/porting-thirdparty-makefile.md @Austin23 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-cmake.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin
...@@ -45,7 +51,7 @@ zh-cn/device-dev/subsystems/subsys-utils-overview.md @Austin23 ...@@ -45,7 +51,7 @@ zh-cn/device-dev/subsystems/subsys-utils-overview.md @Austin23
zh-cn/device-dev/subsystems/subsys-utils-guide.md @Austin23 zh-cn/device-dev/subsystems/subsys-utils-guide.md @Austin23
zh-cn/device-dev/subsystems/subsys-utils-faqs.md @Austin23 zh-cn/device-dev/subsystems/subsys-utils-faqs.md @Austin23
zh-cn/device-dev/subsystems/subsys-aiframework-guide.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-guide.md @Austin23
zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md @Austin23
zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @Austin23
zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md @Austin23
zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md @Austin23
...@@ -79,14 +85,19 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin ...@@ -79,14 +85,19 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-syspara.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-cfg.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-sandbox.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-service.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot.md @Austin23
zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23 zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23
zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- master:最新开发版本。 - master:最新开发版本。
- OpenHarmony 3.2 Beta1版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta1.md)了解版本详情。 - OpenHarmony 3.2 Beta2版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta2.md)了解版本详情。
- OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。 - OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。
......
此差异已折叠。
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
- Development Fundamentals - Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md)
- [Resource File Categories](quick-start/basic-resource-file-categories.md)
- [SysCap](quick-start/syscap.md) - [SysCap](quick-start/syscap.md)
- Development - Development
- [Ability Development](ability/Readme-EN.md) - [Ability Development](ability/Readme-EN.md)
...@@ -45,8 +44,5 @@ ...@@ -45,8 +44,5 @@
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs - APIs
- [JS and TS APIs](reference/apis/Readme-EN.md) - [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
- Contribution - Contribution
- [How to Contribute](../contribute/documentation-contribution.md) - [How to Contribute](../contribute/documentation-contribution.md)
...@@ -4,8 +4,8 @@ An ability is the abstraction of a functionality that an application can provide ...@@ -4,8 +4,8 @@ An ability is the abstraction of a functionality that an application can provide
The ability framework model has two forms. The ability framework model has two forms.
- FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. - FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there is Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities.
- Stage model, which is introduced since API version 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more. - Stage model, which is introduced since API version 9. In the stage model, there is `Ability` and `ExtensionAbility`. `ExtensionAbility` is further extended to `ServiceExtensionAbility`, `FormExtensionAbility`, `DataShareExtensionAbility`, and more.
The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models. The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models.
......
...@@ -78,29 +78,29 @@ To create Page abilities for an application in the stage model, you must impleme ...@@ -78,29 +78,29 @@ To create Page abilities for an application in the stage model, you must impleme
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("MainAbility onCreate") console.log("MainAbility onCreate")
} }
onDestroy() { onDestroy() {
console.log("MainAbility onDestroy") console.log("MainAbility onDestroy")
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log("MainAbility onWindowStageCreate") console.log("MainAbility onWindowStageCreate")
windowStage.loadContent("pages/index").then((data) => { windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data)) console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.error("MainAbility load content failed with error: " + JSON.stringify(error)) console.error("MainAbility load content failed with error: " + JSON.stringify(error))
}) })
} }
onWindowStageDestroy() { onWindowStageDestroy() {
console.log("MainAbility onWindowStageDestroy") console.log("MainAbility onWindowStageDestroy")
} }
onForeground() { onForeground() {
console.log("MainAbility onForeground") console.log("MainAbility onForeground")
} }
onBackground() { onBackground() {
console.log("MainAbility onBackground") console.log("MainAbility onBackground")
} }
...@@ -300,7 +300,7 @@ export default class MainAbility extends Ability { ...@@ -300,7 +300,7 @@ export default class MainAbility extends Ability {
Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI. Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI.
```ts ```ts
import router from '@system.router' import router from '@ohos.router'
@Entry @Entry
@Component @Component
......
...@@ -54,8 +54,10 @@ To make you better understand how functions work together and jumpstart your app ...@@ -54,8 +54,10 @@ To make you better understand how functions work together and jumpstart your app
API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively. API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively.
They are organized as follows: They are organized as follows:
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md) - [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs - APIs
- [JS and TS APIs](reference/apis/Readme-EN.md) - [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs - Native APIs
......
...@@ -54,8 +54,14 @@ To make you better understand how functions work together and jumpstart your app ...@@ -54,8 +54,14 @@ To make you better understand how functions work together and jumpstart your app
API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively. API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively.
They are organized as follows: They are organized as follows:
- [JS and TS APIs](reference/apis/js-apis-DataUriUtils.md)
- Native APIs - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md) - [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [JS and TS APIs](reference/apis/js-apis-DataUriUtils.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
...@@ -8,37 +8,11 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat ...@@ -8,37 +8,11 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
**Table 1** Native IPC APIs **Table 1** Native IPC APIs
<a name="table178849240013"></a> | Class/Interface | Function | Description |
<table><thead align="left"><tr id="row6884924608"><th class="cellrowborder" valign="top" width="14.12141214121412%" id="mcps1.2.4.1.1"><p id="p98846241706"><a name="p98846241706"></a><a name="p98846241706"></a>Class/Interface</p> | --------------- | -------- | ----------- |
</th> | IRemoteBroker | sptr<IRemoteObject> AsObject() | Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of **IRemoteBroker**. If you call this method on the stub, the **RemoteObject** is returned; if you call this method on the proxy, the proxy object is returned. |
<th class="cellrowborder" valign="top" width="52.54525452545254%" id="mcps1.2.4.1.2"><p id="p1488482414020"><a name="p1488482414020"></a><a name="p1488482414020"></a>Function</p> | IRemoteStub | virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) | Called to process a request from the proxy and return the result. Derived classes need to override this method. |
</th> | IRemoteProxy | | Service proxy classes are derived from the **IRemoteProxy** class. |
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p388516244016"><a name="p388516244016"></a><a name="p388516244016"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row15885824402"><td class="cellrowborder" valign="top" width="14.12141214121412%" headers="mcps1.2.4.1.1 "><p id="p08859241008"><a name="p08859241008"></a><a name="p08859241008"></a>IRemoteBroker</p>
</td>
<td class="cellrowborder" valign="top" width="52.54525452545254%" headers="mcps1.2.4.1.2 "><p id="p388572412010"><a name="p388572412010"></a><a name="p388572412010"></a>sptr&lt;IRemoteObject&gt; AsObject()</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p13885724405"><a name="p13885724405"></a><a name="p13885724405"></a>Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of <strong id="b18927631105113"><a name="b18927631105113"></a><a name="b18927631105113"></a>IRemoteBroker</strong>. If you call this method on the stub, the <strong id="b7932163110519"><a name="b7932163110519"></a><a name="b7932163110519"></a>RemoteObject</strong> is returned; if you call this method on the proxy, the proxy object is returned.</p>
</td>
</tr>
<tr id="row138859241808"><td class="cellrowborder" valign="top" width="14.12141214121412%" headers="mcps1.2.4.1.1 "><p id="p1888515245012"><a name="p1888515245012"></a><a name="p1888515245012"></a>IRemoteStub</p>
</td>
<td class="cellrowborder" valign="top" width="52.54525452545254%" headers="mcps1.2.4.1.2 "><p id="p1388516240011"><a name="p1388516240011"></a><a name="p1388516240011"></a>virtual int OnRemoteRequest(uint32_t code, MessageParcel &amp;data, MessageParcel &amp;reply, MessageOption &amp;option)</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1188582414016"><a name="p1188582414016"></a><a name="p1188582414016"></a>Called to process a request from the proxy and return the result. Derived classes need to override this method.</p>
</td>
</tr>
<tr id="row108856241904"><td class="cellrowborder" valign="top" width="14.12141214121412%" headers="mcps1.2.4.1.1 "><p id="p6885924609"><a name="p6885924609"></a><a name="p6885924609"></a>IRemoteProxy</p>
</td>
<td class="cellrowborder" valign="top" width="52.54525452545254%" headers="mcps1.2.4.1.2 ">&nbsp;&nbsp;</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p688592413018"><a name="p688592413018"></a><a name="p688592413018"></a>Service proxy classes are derived from the <strong id="b169739356519"><a name="b169739356519"></a><a name="b169739356519"></a>IRemoteProxy</strong> class.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section4207112818418"></a> ## How to Develop<a name="section4207112818418"></a>
......
...@@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre ...@@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre
## Related Modules ## Related Modules
[Distributed Scheduler](https://gitee.com/openharmony/distributedschedule_dms_fwk) [Distributed Scheduler](https://gitee.com/openharmony/ability_dmsfwk)
# Subscribing to State Changes of a Remote Object<a name="EN-US_TOPIC_0000001104030756"></a> # Subscribing to State Changes of a Remote Object
IPC/RPC allows you to subscribe to the state changes of a remote stub object. When the remote stub object dies, a death notification will be sent to your local proxy object. You can also unsubscribe from the state changes if they are no longer needed. Such subscription and unsubscription are controlled by APIs. To be specific, you need to implement the **IRemoteObject.DeathRecipient** interface and the **onRemoteDied** method to clear resources. This callback is invoked when the process accommodating the remote stub object dies, or the device accommodating the remote stub object leaves the network. It is worth noting that these APIs should be called in the following order: The proxy object must first subscribe to death notifications of the stub object. If the stub object is in the normal state, the proxy object can cancel the subscription as required. If the process of the stub object exits or the device hosting the stub object goes offline, subsequent operations customized by the proxy object will be automatically triggered. IPC/RPC allows you to subscribe to the state changes of a remote stub object. When the remote stub object dies, a death notification will be sent to your local proxy object. Such subscription and unsubscription are controlled by APIs. To be specific, you need to implement the **DeathRecipient** callback and the **onRemoteDied** method to clear resources. This callback is invoked when the process accommodating the remote stub object dies, or the device accommodating the remote stub object leaves the network.
**Development Using Native APIs** Note that the proxy object must first subscribe to death notifications of the stub object. If the stub object is in the normal state, the proxy object can cancel the subscription as required. If the process of the stub object exits or the device hosting the stub object goes offline, subsequent operations customized by the proxy object will be automatically triggered.
The following APIs are used to add a recipient for death notifications of a remote stub object, remove such a recipient, and perform subsequent operations upon receiving a death notification of the remote stub object:
```
bool AddDeathRecipient(const sptr<DeathRecipient> &recipient);
bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient);
void OnRemoteDied(const wptr<IRemoteObject> &object);
```
The sample code is as follows:
## **Development Using Native APIs**
| API| Description|
| -------- | -------- |
| AddDeathRecipient(const sptr\<DeathRecipient> &recipient); | Adds a recipient for death notifications of a remote stub object.|
| RemoveDeathRecipient(const sptr\<DeathRecipient> &recipient); | Removes the recipient for death notifications of a remote stub object.|
| OnRemoteDied(const wptr\<IRemoteObject> &object); | Called when the remote stub object dies.|
## Sample Code
``` ```
class TestDeathRecipient : public IRemoteObject::DeathRecipient { class TestDeathRecipient : public IRemoteObject::DeathRecipient {
public: public:
virtual void OnRemoteDied(const wptr<IRemoteObject>& remoteObject); virtual void OnRemoteDied(const wptr<IRemoteObject>& remoteObject);
} }
sptr<IRemoteObject::DeathRecipient> deathRecipient (new TestDeathRecipient()); // Construct a death notification recipient. sptr<IRemoteObject::DeathRecipient> deathRecipient (new TestDeathRecipient());// Construct a death notification recipient.
bool result = proxy->AddDeathRecipient(deathRecipient); // Add the recipient to the proxy. bool result = proxy->AddDeathRecipient(deathRecipient); // Add a recipient for death notifications.
result = proxy->RemoveDeathRecipient(deathRecipient); // Remove the recipient. result = proxy->RemoveDeathRecipient(deathRecipient); // Remove the recipient for death notifications.
``` ```
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## Use Cases ## Use Cases
You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the **createWebSocket** API to create a **WebSocket** object and then use the **connect** API to connect to the server. If the connection is successful, the client will receive a callback of the **open** event. Then, the client can communicate with the server using the **send** API. When the server sends a message to the client, the client will receive a callback of the **message** event. If the client no longer needs this connection, it can call the **close** API to disconnect from the server. Then, the client will receive a callback of the **close** event. You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the **createWebSocket()** API to create a **WebSocket** object and then use the **connect()** API to connect to the server. If the connection is successful, the client will receive a callback of the **open** event. Then, the client can communicate with the server using the **send()** API. When the server sends a message to the client, the client will receive a callback of the **message** event. If the client no longer needs this connection, it can call the **close()** API to disconnect from the server. Then, the client will receive a callback of the **close** event.
If an error occurs in any of the preceding processes, the client will receive a callback of the **error** event. If an error occurs in any of the preceding processes, the client will receive a callback of the **error** event.
...@@ -18,14 +18,14 @@ The WebSocket connection function is mainly implemented by the WebSocket module. ...@@ -18,14 +18,14 @@ The WebSocket connection function is mainly implemented by the WebSocket module.
| connect() | Establishes a WebSocket connection to a given URL. | | connect() | Establishes a WebSocket connection to a given URL. |
| send() | Sends data through the WebSocket connection. | | send() | Sends data through the WebSocket connection. |
| close() | Closes a WebSocket connection. | | close() | Closes a WebSocket connection. |
| on(type:&nbsp;'open') | Enables listening for **open** events of a WebSocket connection. | | on(type: 'open') | Enables listening for **open** events of a WebSocket connection. |
| off(type:&nbsp;'open') | Disables listening for **open** events of a WebSocket connection. | | off(type: 'open') | Disables listening for **open** events of a WebSocket connection. |
| on(type:&nbsp;'message') | Enables listening for **message** events of a WebSocket connection. | | on(type: 'message') | Enables listening for **message** events of a WebSocket connection. |
| off(type:&nbsp;'message') | Disables listening for **message** events of a WebSocket connection. | | off(type: 'message') | Disables listening for **message** events of a WebSocket connection. |
| on(type:&nbsp;'close') | Enables listening for **close** events of a WebSocket connection. | | on(type: 'close') | Enables listening for **close** events of a WebSocket connection. |
| off(type:&nbsp;'close') | Disables listening for **close** events of a WebSocket connection. | | off(type: 'close') | Disables listening for **close** events of a WebSocket connection. |
| on(type:&nbsp;'error') | Enables listening for **error** events of a WebSocket connection. | | on(type: 'error') | Enables listening for **error** events of a WebSocket connection. |
| off(type:&nbsp;'error') | Disables listening for **error** events of a WebSocket connection. | | off(type: 'error') | Disables listening for **error** events of a WebSocket connection. |
## How to Develop ## How to Develop
...@@ -50,9 +50,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. ...@@ -50,9 +50,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module.
// When receiving the on('open') event, the client can use the send() API to communicate with the server. // When receiving the on('open') event, the client can use the send() API to communicate with the server.
ws.send("Hello, server!", (err, value) => { ws.send("Hello, server!", (err, value) => {
if (!err) { if (!err) {
console.log("send success"); console.log("Message sent successfully");
} else { } else {
console.log("send fail, err:" + JSON.stringify(err)); console.log("Failed to send the message. Err:" + JSON.stringify(err));
} }
}); });
}); });
...@@ -62,9 +62,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. ...@@ -62,9 +62,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module.
if (value === 'bye') { if (value === 'bye') {
ws.close((err, value) => { ws.close((err, value) => {
if (!err) { if (!err) {
console.log("close success"); console.log("Connection closed successfully");
} else { } else {
console.log("close fail, err is " + JSON.stringify(err)); console.log("Failed to close the connection. Err: " + JSON.stringify(err));
} }
}); });
} }
...@@ -77,9 +77,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. ...@@ -77,9 +77,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module.
}); });
ws.connect(defaultIpAddress, (err, value) => { ws.connect(defaultIpAddress, (err, value) => {
if (!err) { if (!err) {
console.log("connect success"); console.log("Connected successfully");
} else { } else {
console.log("connect fail, err:" + JSON.stringify(err)); console.log("Connection failed. Err:" + JSON.stringify(err));
} }
}); });
``` ```
...@@ -100,7 +100,7 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. ...@@ -100,7 +100,7 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.<br>- **field**: column name in the database table.<br>- **low**: minimum value that matches the **RdbPredicates**.<br>- **high**: maximum value that matches the **RdbPredicates**.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.<br>- **field**: column name in the database table.<br>- **low**: minimum value that matches the **RdbPredicates**.<br>- **high**: maximum value that matches the **RdbPredicates**.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.<br>- **field**: column name in the database table.<br>- **low**: minimum value that matches the **RdbPredicates**.<br>- **high**: maximum value that matches the **RdbPredicates**.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.<br>- **field**: column name in the database table.<br>- **low**: minimum value that matches the **RdbPredicates**.<br>- **high**: maximum value that matches the **RdbPredicates**.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value specified.<br>- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
## When to Use ## When to Use
The event logging function helps applications log various information generated during running. The event logging function helps applications to log various information generated during running.
## Available APIs ## Available APIs
JS application event logging APIs are provided by the **hiAppEvent** module. JS application event logging APIs are provided by the **hiAppEvent** module.
**APIs for Event Logging** **Table 1** APIs for event logging
| API | Return Value | Description | | API | Return Value | Description |
| ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ |
...@@ -17,7 +17,7 @@ JS application event logging APIs are provided by the **hiAppEvent** module. ...@@ -17,7 +17,7 @@ JS application event logging APIs are provided by the **hiAppEvent** module.
When an asynchronous callback is used, the return value can be processed directly in the callback. When a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Event Verification Result Codes](#event-verification-result-codes). When an asynchronous callback is used, the return value can be processed directly in the callback. When a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Event Verification Result Codes](#event-verification-result-codes).
**APIs for Event Logging Configuration** **Table 2** APIs for event logging configuration
| API | Return Value | Description | | API | Return Value | Description |
| ------------------------------ | ------------ | ------------------------------------------------------------ | | ------------------------------ | ------------ | ------------------------------------------------------------ |
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
HiAppEvent provides event logging APIs for applications to log the fault, statistical, security, and user behavior events reported during running. Based on event information, you will be able to analyze the running status of your application. HiAppEvent provides event logging APIs for applications to log the fault, statistical, security, and user behavior events reported during running. Based on event information, you will be able to analyze the running status of your application.
The HiAppEvent module of OpenHarmony can be used to develop application event services and provide functions related to application events, including flushing application events to a disk and querying historical application event data.
## Basic Concepts ## Basic Concepts
The HiAppEvent module of OpenHarmony can be used to develop application event services and provide functions related to application events, including flushing application events to a disk and querying historical application event data. - **Logging**
**Logging**: Logs changes caused by user operations to provide service data for development, product, and O&M analysis. Logs changes caused by user operations to provide service data for development, product, and O&M analysis.
...@@ -6,9 +6,9 @@ HiTraceMeter provides APIs for system performance tracing. You can call the APIs ...@@ -6,9 +6,9 @@ HiTraceMeter provides APIs for system performance tracing. You can call the APIs
## Available APIs ## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing** **Table 1** APIs for performance tracing
| API| Return Value| Description| | API| Return Value| Description|
| ---------------------------------------------------------------------------- | --------- | ------------ | | ---------------------------------------------------------------------------- | --------- | ------------ |
......
...@@ -15,4 +15,4 @@ hiTraceMeter is a tool for you to trace service processes and monitor system per ...@@ -15,4 +15,4 @@ hiTraceMeter is a tool for you to trace service processes and monitor system per
## Constraints ## Constraints
- Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs.
...@@ -23,57 +23,64 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -23,57 +23,64 @@ You can use APIs provided in the following table to obtain the system language a
### How to Develop ### How to Develop
1. Obtain the system language.<br> 1. Obtain the system language.
Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module). Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module).
``` ```js
var language = i18n.getSystemLanguage(); var language = i18n.getSystemLanguage();
``` ```
2. Obtain the system region.<br> 2. Obtain the system region.
Call the **getSystemRegion** method to obtain the system region. Call the **getSystemRegion** method to obtain the system region.
``` ```js
var region = i18n.getSystemRegion(); var region = i18n.getSystemRegion();
``` ```
3. Obtain the system locale.<br> 3. Obtain the system locale.
Call the **getSystemLocale** method to obtain the system locale. Call the **getSystemLocale** method to obtain the system locale.
``` ```js
var locale = i18n.getSystemLocale(); var locale = i18n.getSystemLocale();
``` ```
4. Check whether the locale's language is RTL.<br> 4. Check whether the locale's language is RTL.
Call the **isRTL** method to check whether the locale's language is RTL. Call the **isRTL** method to check whether the locale's language is RTL.
``` ```js
var rtl = i18n.isRTL("zh-CN"); var rtl = i18n.isRTL("zh-CN");
``` ```
5. Check whether the system uses a 24-hour clock.<br> 5. Check whether the system uses a 24-hour clock.
Call the **is24HourClock** method to check whether the system uses a 24-hour clock. Call the **is24HourClock** method to check whether the system uses a 24-hour clock.
``` ```js
var hourClock = i18n.is24HourClock(); var hourClock = i18n.is24HourClock();
``` ```
6. Obtain the localized display of a language.<br> 6. Obtain the localized display of a language.
Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
``` ```js
var language = "en"; var language = "en";
var locale = "zh-CN"; var locale = "zh-CN";
var sentenceCase = false; var sentenceCase = false;
var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase); var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase);
``` ```
7. Obtain the localized display of a country.<br> 7. Obtain the localized display of a country.
Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
``` ```js
var country = "US"; var country = "US";
var locale = "zh-CN"; var locale = "zh-CN";
var sentenceCase = false; var sentenceCase = false;
...@@ -106,70 +113,78 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -106,70 +113,78 @@ You can use APIs provided in the following table to obtain the system language a
### How to Develop ### How to Develop
1. Instantiate a **Calendar** object.<br> 1. Instantiate a **Calendar** object.
Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used. Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used.
``` ```js
var calendar = i18n.getCalendar("zh-CN", "gregory); var calendar = i18n.getCalendar("zh-CN", "gregory);
``` ```
2. Set the time for the **Calendar** object.<br> 2. Set the time for the **Calendar** object.
Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT. Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT.
``` ```js
var date1 = new Date(); var date1 = new Date();
calendar.setTime(date1); calendar.setTime(date1);
var date2 = 1000; var date2 = 1000;
calendar.setTime(date2); calendar.setTime(date2);
``` ```
3. Set the year, month, day, hour, minute, and second for the **Calendar** object.<br> 3. Set the year, month, day, hour, minute, and second for the **Calendar** object.
Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object.
``` ```js
calendar.set(2021, 12, 21, 6, 0, 0) calendar.set(2021, 12, 21, 6, 0, 0)
``` ```
4. Set and obtain the time zone for the **Calendar** object.<br> 4. Set and obtain the time zone for the **Calendar** object.
Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set. Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set.
``` ```js
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
var timezone = calendar.getTimeZone(); var timezone = calendar.getTimeZone();
``` ```
5. Set and obtain the first day of a week for the **Calendar** object.<br> 5. Set and obtain the first day of a week for the **Calendar** object.
Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday. Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.
``` ```js
calendar.setFirstDayOfWeek(1); calendar.setFirstDayOfWeek(1);
var firstDayOfWeek = calendar.getFirstDayOfWeek(); var firstDayOfWeek = calendar.getFirstDayOfWeek();
``` ```
6. Set and obtain the minimum count of days in the first week for the **Calendar** object.<br> 6. Set and obtain the minimum count of days in the first week for the **Calendar** object.
Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object.
``` ```js
calendar.setMinimalDaysInFirstWeek(3); calendar.setMinimalDaysInFirstWeek(3);
var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
``` ```
7. Obtain the localized display of the **Calendar** object.<br> 7. Obtain the localized display of the **Calendar** object.
Call the **getDisplayName** method to obtain the localized display of the **Calendar** object. Call the **getDisplayName** method to obtain the localized display of the **Calendar** object.
``` ```js
var localizedName = calendar.getDisplayName("zh-CN"); var localizedName = calendar.getDisplayName("zh-CN");
``` ```
8. Check whether a date is a weekend.<br> 8. Check whether a date is a weekend.
Call the **isWeekend** method to determine whether the input date is a weekend. Call the **isWeekend** method to determine whether the input date is a weekend.
``` ```js
var date = new Date(); var date = new Date();
var weekend = calendar.isWeekend(date); var weekend = calendar.isWeekend(date);
``` ```
...@@ -191,25 +206,26 @@ You can use APIs provided in the following table to obtain the system language a ...@@ -191,25 +206,26 @@ You can use APIs provided in the following table to obtain the system language a
### How to Develop ### How to Develop
1. Instantiate a **PhoneNumberFormat** object.<br> 1. Instantiate a **PhoneNumberFormat** object.
Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**. Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**.
``` ```js
var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"}); var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"});
``` ```
2. Check whether the phone number format is correct. 2. Check whether the phone number format is correct.
Call the **isValidNumber** method to check whether the format of the input phone number is correct. Call the **isValidNumber** method to check whether the format of the input phone number is correct.
``` ```js
var validNumber = phoneNumberFormat.isValidNumber("15812341234"); var validNumber = phoneNumberFormat.isValidNumber("15812341234");
``` ```
3. Format a phone number. 3. Format a phone number.
Call the **format** method of **PhoneNumberFormat** to format the input phone number. Call the **format** method of **PhoneNumberFormat** to format the input phone number.
``` ```js
var formattedNumber = phoneNumberFormat.format("15812341234"); var formattedNumber = phoneNumberFormat.format("15812341234");
``` ```
...@@ -232,7 +248,7 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -232,7 +248,7 @@ The **unitConvert** API is provided to help you implement measurement conversion
Call the [unitConvert](../reference/apis/js-apis-intl.md) method to convert a measurement unit and format the display result. Call the [unitConvert](../reference/apis/js-apis-intl.md) method to convert a measurement unit and format the display result.
``` ```js
var fromUnit = {unit: "cup", measureSystem: "US"}; var fromUnit = {unit: "cup", measureSystem: "US"};
var toUnit = {unit: "liter", measureSystem: "SI"}; var toUnit = {unit: "liter", measureSystem: "SI"};
var number = 1000; var number = 1000;
...@@ -259,32 +275,36 @@ The **unitConvert** API is provided to help you implement measurement conversion ...@@ -259,32 +275,36 @@ The **unitConvert** API is provided to help you implement measurement conversion
### How to Develop ### How to Develop
1. Instantiate an **IndexUtil** object.<br> 1. Instantiate an **IndexUtil** object.
Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale. Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale.
``` ```js
var indexUtil = getInstance("zh-CN"); var indexUtil = getInstance("zh-CN");
``` ```
2. Obtain the index list.<br> 2. Obtain the index list.
Call the **getIndexList** method to obtain the alphabet index list of the current locale. Call the **getIndexList** method to obtain the alphabet index list of the current locale.
``` ```js
var indexList = indexUtil.getIndexList(); var indexList = indexUtil.getIndexList();
``` ```
3. Add an index.<br> 3. Add an index.
Call the **addLocale** method to add the alphabet index of a new locale to the current index list. Call the **addLocale** method to add the alphabet index of a new locale to the current index list.
``` ```js
indexUtil.addLocale("ar") indexUtil.addLocale("ar")
``` ```
4. Obtain the index of a string.<br> 4. Obtain the index of a string.
Call the **getIndex** method to obtain the alphabet index of a string. Call the **getIndex** method to obtain the alphabet index of a string.
``` ```js
var text = "access index"; var text = "access index";
indexUtil.getIndex(text); indexUtil.getIndex(text);
``` ```
...@@ -313,38 +333,42 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api ...@@ -313,38 +333,42 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
### How to Develop ### How to Develop
1. Instantiate a **BreakIterator** object.<br> 1. Instantiate a **BreakIterator** object.
Call the **getLineInstance** method to instantiate a **BreakIterator** object. Call the **getLineInstance** method to instantiate a **BreakIterator** object.
``` ```js
var locale = "en-US" var locale = "en-US"
var breakIterator = i18n.getLineInstance(locale); var breakIterator = i18n.getLineInstance(locale);
``` ```
2. Set and access the text that requires line breaking.<br> 2. Set and access the text that requires line breaking.
Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking. Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking.
``` ```js
var text = "Apple is my favorite fruit"; var text = "Apple is my favorite fruit";
breakIterator.setLineBreakText(text); breakIterator.setLineBreakText(text);
var breakText = breakIterator.getLineBreakText(); var breakText = breakIterator.getLineBreakText();
``` ```
3. Obtain the current position of the **BreakIterator** object.<br> 3. Obtain the current position of the **BreakIterator** object.
Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed. Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed.
``` ```js
var pos = breakIterator.current(); var pos = breakIterator.current();
``` ```
4. Set the position of a **BreakIterator** object.<br> 4. Set the position of a **BreakIterator** object.
The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed. The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed.
``` ```js
var firstPos = breakIterator.first(); // Set a BreakIterator object to the first break point, that is, the start position of the text. var firstPos = breakIterator.first(); // Set a BreakIterator object to the first break point, that is, the start position of the text.
var lastPos = breakIterator.last(); // Set a BreakIterator object to the last break point, that is, the position after the text end. var lastPos = breakIterator.last(); // Set a BreakIterator object to the last break point, that is, the position after the text end.
// Move a BreakIterator object forward or backward by a certain number of break points. // Move a BreakIterator object forward or backward by a certain number of break points.
...@@ -356,10 +380,11 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api ...@@ -356,10 +380,11 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
var followingPos = breakIterator.following(10); var followingPos = breakIterator.following(10);
``` ```
5. Determine whether a position is a break point.<br> 5. Determine whether a position is a break point.
Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position. Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position.
``` ```js
var isboundary = breakIterator.isBoundary(5); var isboundary = breakIterator.isBoundary(5);
``` ```
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N interfaces defined in ECMA 402. This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N interfaces defined in ECMA 402.
The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities. The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
> **NOTE**<br> > **NOTE**
>
> In the code snippets in this document, **intl** refers to the name of the imported module. > In the code snippets in this document, **intl** refers to the name of the imported module.
## Setting Locale Information ## Setting Locale Information
...@@ -24,7 +25,8 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc ...@@ -24,7 +25,8 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc
### How to Develop ### How to Develop
1. Instantiate a **Locale** object.<br> 1. Instantiate a **Locale** object.
Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list. Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list.
A **Locale** object consists of four parts: language, script, region, and extension, which are separated by using a hyphen (-). A **Locale** object consists of four parts: language, script, region, and extension, which are separated by using a hyphen (-).
...@@ -42,30 +44,33 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc ...@@ -42,30 +44,33 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc
| kf | Whether upper case or lower case is considered when sorting or comparing strings.| | kf | Whether upper case or lower case is considered when sorting or comparing strings.|
``` ```js
var locale = "zh-CN"; var locale = "zh-CN";
var options = {caseFirst: false, calendar: "chinese", collation: pinyin}; var options = {caseFirst: false, calendar: "chinese", collation: pinyin};
var localeObj = new intl.Locale(locale, options); var localeObj = new intl.Locale(locale, options);
``` ```
2. Obtain the string representing a **Locale** object.<br> 2. Obtain the string representing a **Locale** object.
Call the **toString** method to obtain the string representing a **Locale** object, which includes the language, region, and other options. Call the **toString** method to obtain the string representing a **Locale** object, which includes the language, region, and other options.
``` ```js
var localeStr = localeObj.toString(); var localeStr = localeObj.toString();
``` ```
3. Maximize locale information.<br> 3. Maximize locale information.
Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information.
``` ```js
var maximizedLocale = localeObj.maximize(); var maximizedLocale = localeObj.maximize();
``` ```
4. Minimize locale information.<br> 4. Minimize locale information.
Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information.
``` ```js
var minimizedLocale = localeObj.minimize(); var minimizedLocale = localeObj.minimize();
``` ```
...@@ -88,42 +93,46 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date ...@@ -88,42 +93,46 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date
### How to Develop ### How to Develop
1. Instantiate a **DateTimeFormat** object.<br> 1. Instantiate a **DateTimeFormat** object.
Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object. Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object.
``` ```js
var dateTimeFormat = new intl.DateTimeFormat(); var dateTimeFormat = new intl.DateTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md).
``` ```js
var options = {dateStyle: "full", timeStyle: "full"}; var options = {dateStyle: "full", timeStyle: "full"};
var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options); var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options);
``` ```
2. Format the date and time.<br> 2. Format the date and time.
Call the **format** method to format the date and time in the **DateTimeFormat** object. This method returns a string representing the formatting result. Call the **format** method to format the date and time in the **DateTimeFormat** object. This method returns a string representing the formatting result.
``` ```js
Date date = new Date(); Date date = new Date();
var formatResult = dateTimeFormat.format(date); var formatResult = dateTimeFormat.format(date);
``` ```
3. Format a period.<br> 3. Format a period.
Call the **formatRange** method to format the period in the **DateTimeFormat** object. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result. Call the **formatRange** method to format the period in the **DateTimeFormat** object. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result.
``` ```js
Date startDate = new Date(); Date startDate = new Date();
Date endDate = new Date(); Date endDate = new Date();
var formatResult = dateTimeFormat.formatRange(startDate, endDate); var formatResult = dateTimeFormat.formatRange(startDate, endDate);
``` ```
4. Obtain attributes of the **DateTimeFormat** object.<br> 4. Obtain attributes of the **DateTimeFormat** object.
Call the **resolvedOptions** method to obtain attributes of the **DateTimeFormat** object. This method will return an array that contains all attributes and values of the object. Call the **resolvedOptions** method to obtain attributes of the **DateTimeFormat** object. This method will return an array that contains all attributes and values of the object.
``` ```js
var options = dateTimeFormat.resolvedOptions(); var options = dateTimeFormat.resolvedOptions();
``` ```
...@@ -145,33 +154,36 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format numbers for ...@@ -145,33 +154,36 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format numbers for
### How to Develop ### How to Develop
1. Instantiate a **NumberFormat** object.<br> 1. Instantiate a **NumberFormat** object.
Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **NumberFormat** object. Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **NumberFormat** object.
``` ```js
var numberFormat = new intl.NumberFormat(); var numberFormat = new intl.NumberFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md).
``` ```js
var options = {compactDisplay: "short", notation: "compact"}; var options = {compactDisplay: "short", notation: "compact"};
var numberFormat = new intl.NumberFormat("zh-CN", options); var numberFormat = new intl.NumberFormat("zh-CN", options);
``` ```
2. Format a number.<br> 2. Format a number.
Call the **format** method to format a number. A string is returned as the formatting result. Call the **format** method to format a number. A string is returned as the formatting result.
``` ```js
var number = 1234.5678 var number = 1234.5678
var formatResult = numberFormat.format(number); var formatResult = numberFormat.format(number);
``` ```
3. Obtain attributes of the **NumberFormat** object.<br> 3. Obtain attributes of the **NumberFormat** object.
Call the **resolvedOptions** method to obtain attributes of the **NumberFormat** object. This method will return an array that contains all attributes and values of the object. Call the **resolvedOptions** method to obtain attributes of the **NumberFormat** object. This method will return an array that contains all attributes and values of the object.
``` ```js
var options = numberFormat.resolvedOptions(); var options = numberFormat.resolvedOptions();
``` ```
...@@ -193,33 +205,36 @@ Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on ...@@ -193,33 +205,36 @@ Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on
### How to Develop ### How to Develop
1. Instantiate a **Collator** object.<br> 1. Instantiate a **Collator** object.
Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **Collator** object. Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **Collator** object.
``` ```js
var collator = new intl.Collator(); var collator = new intl.Collator();
``` ```
Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md).
```js
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"});
``` ```
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"};
```
2. Compare two strings.<br> 2. Compare two strings.
Call the **compare** method to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. Call the **compare** method to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths.
``` ```js
var str1 = "first string"; var str1 = "first string";
var str2 = "second string"; var str2 = "second string";
var compareResult = collator.compare(str1, str2); var compareResult = collator.compare(str1, str2);
``` ```
3. Obtain attributes of the **Collator** object.<br> 3. Obtain attributes of the **Collator** object.
Call the **resolvedOptions** method to obtain attributes of the **Collator** object. This method will return an array that contains all attributes and values of the object. Call the **resolvedOptions** method to obtain attributes of the **Collator** object. This method will return an array that contains all attributes and values of the object.
``` ```js
var options = collator.resolvedOptions(); var options = collator.resolvedOptions();
``` ```
...@@ -240,24 +255,26 @@ Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singu ...@@ -240,24 +255,26 @@ Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singu
### How to Develop ### How to Develop
1. Instantiate a **PluralRules** object.<br> 1. Instantiate a **PluralRules** object.
Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **PluralRules** object. Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **PluralRules** object.
``` ```js
var pluralRules = new intl.PluralRules(); var pluralRules = new intl.PluralRules();
``` ```
Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md).
``` ```js
var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}; var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
``` ```
2. Determine the singular-plural type.<br> 2. Determine the singular-plural type.
Call the **select** method to determine the singular-plural type of an input number. This method will return a string representing the singular-plural type, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. Call the **select** method to determine the singular-plural type of an input number. This method will return a string representing the singular-plural type, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**.
``` ```js
var number = 1234.5678 var number = 1234.5678
var categoryResult = plurals.select(number); var categoryResult = plurals.select(number);
``` ```
...@@ -281,41 +298,45 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the r ...@@ -281,41 +298,45 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the r
### How to Develop ### How to Develop
1. Instantiate a **RelativeTimeFormat** object.<br> 1. Instantiate a **RelativeTimeFormat** object.
Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **RelativeTimeFormat** object. Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **RelativeTimeFormat** object.
``` ```js
var relativeTimeFormat = new intl.RelativeTimeFormat(); var relativeTimeFormat = new intl.RelativeTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md).
```js
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
``` ```
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"};
```
2. Format the relative time.<br> 2. Format the relative time.
Call the **format** method to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. This method returns a string representing the formatting result. Call the **format** method to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. This method returns a string representing the formatting result.
``` ```js
var number = 2; var number = 2;
var unit = "year" var unit = "year"
var formatResult = relativeTimeFormat.format(number, unit); var formatResult = relativeTimeFormat.format(number, unit);
``` ```
3. Obtain each part of the relative time format.<br> 3. Obtain each part of the relative time format.
Upon obtaining each part of the relative time format, customize the relative time formatting result. Upon obtaining each part of the relative time format, customize the relative time formatting result.
``` ```js
var number = 2; var number = 2;
var unit = "year" var unit = "year"
var formatResult = relativeTimeFormat.formatToParts(number, unit); var formatResult = relativeTimeFormat.formatToParts(number, unit);
``` ```
4. Obtain attributes of the **RelativeTimeFormat** object.<br> 4. Obtain attributes of the **RelativeTimeFormat** object.
Call the **resolvedOptions** method to obtain attributes of the **RelativeTimeFormat** object. This method will return an array that contains all attributes and values of the object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). Call the **resolvedOptions** method to obtain attributes of the **RelativeTimeFormat** object. This method will return an array that contains all attributes and values of the object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md).
``` ```js
var options = numberFormat.resolvedOptions(); var options = numberFormat.resolvedOptions();
``` ```
# Media # Media
- Audio - Audio
- [Audio Overview](audio-overview.md) - [Audio Overview](audio-overview.md)
- [Audio Playback Development](audio-playback.md) - [Audio Playback Development](audio-playback.md)
- [Audio Recording Development](audio-recorder.md) - [Audio Recording Development](audio-recorder.md)
...@@ -15,9 +14,9 @@ ...@@ -15,9 +14,9 @@
- [Video Playback Development](video-playback.md) - [Video Playback Development](video-playback.md)
- [Video Recording Development](video-recorder.md) - [Video Recording Development](video-recorder.md)
- Image - Image
- [Image Development](image.md) - [Image Development](image.md)
- Camera - Camera
- [Camera Development](camera.md) - [Camera Development](camera.md)
...@@ -48,7 +48,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference ...@@ -48,7 +48,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
```js ```js
var mode_ = audio.InterruptMode.SHARE_MODE; var mode_ = audio.InterruptMode.SHARE_MODE;
await this.audioRenderer.setInterruptMode(mode_).then(()=>{ await this.audioRenderer.setInterruptMode(mode_).then(() => {
console.log('[JSAR] [SetInterruptMode] Setting: '+ (mode_ == 0? " share mode":"independent mode") + "success"); console.log('[JSAR] [SetInterruptMode] Setting: '+ (mode_ == 0? " share mode":"independent mode") + "success");
}); });
``` ```
...@@ -39,38 +39,38 @@ function printfDescription(obj) { ...@@ -39,38 +39,38 @@ function printfDescription(obj) {
// Set the player callbacks. // Set the player callbacks.
function setCallBack(audioPlayer) { function setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered.
}); });
audioPlayer.on('play', () => { // Set the 'play' event callback. audioPlayer.on('play', () => { // Set the `play` event callback.
console.info('audio play success'); console.info('audio play success');
audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback.
}); });
audioPlayer.on('pause', () => { // Set the 'pause' event callback. audioPlayer.on('pause', () => { // Set the `pause` event callback.
console.info('audio pause success'); console.info('audio pause success');
audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback.
}); });
audioPlayer.on('stop', () => { // Set the 'stop' event callback. audioPlayer.on('stop', () => { // Set the `stop` event callback.
console.info('audio stop success'); console.info('audio stop success');
audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song.
}); });
audioPlayer.on('reset', () => { // Set the 'reset' event callback. audioPlayer.on('reset', () => { // Set the `reset` event callback.
console.info('audio reset success'); console.info('audio reset success');
audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the `timeUpdate` event callback.
if (typeof(seekDoneTime) == 'undefined') { if (typeof(seekDoneTime) == 'undefined') {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
console.info('audio seek success, and seek time is ' + seekDoneTime); console.info('audio seek success, and seek time is ' + seekDoneTime);
audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback.
}); });
audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback. audioPlayer.on('volumeChange', () => { // Set the `volumeChange` event callback.
console.info('audio volumeChange success'); console.info('audio volumeChange success');
audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode.
if (typeof (arrlist) != 'undefined') { if (typeof (arrlist) != 'undefined') {
for (let i = 0; i < arrlist.length; i++) { for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]); printfDescription(arrlist[i]);
...@@ -78,13 +78,13 @@ function setCallBack(audioPlayer) { ...@@ -78,13 +78,13 @@ function setCallBack(audioPlayer) {
} else { } else {
console.log(`audio getTrackDescription fail, error:${error.message}`); console.log(`audio getTrackDescription fail, error:${error.message}`);
} }
audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback.
}); });
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish'); console.info('audio play finish');
}); });
audioPlayer.on('error', (error) => { // Set the 'error' event callback. audioPlayer.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`); console.info(`audio error called, errMessage is ${error.message}`);
...@@ -94,7 +94,7 @@ function setCallBack(audioPlayer) { ...@@ -94,7 +94,7 @@ function setCallBack(audioPlayer) {
async function audioPlayerDemo() { async function audioPlayerDemo() {
// 1. Create an AudioPlayer instance. // 1. Create an AudioPlayer instance.
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
setCallBack(audioPlayer); // Set the event callbacks. setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file. // 2. Set the URI of the audio file.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
...@@ -107,7 +107,7 @@ async function audioPlayerDemo() { ...@@ -107,7 +107,7 @@ async function audioPlayerDemo() {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
} }
``` ```
...@@ -119,23 +119,23 @@ import fileIO from '@ohos.fileio' ...@@ -119,23 +119,23 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Set the 'play' event callback. audioPlayer.on('play', () => { // Set the `play` event callback.
console.info('audio play success'); console.info('audio play success');
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish'); console.info('audio play finish');
audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
}); });
} }
async audioPlayerDemo() { async audioPlayerDemo() {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks. this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
...@@ -147,7 +147,7 @@ export class AudioDemo { ...@@ -147,7 +147,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
} }
} }
``` ```
...@@ -161,20 +161,20 @@ export class AudioDemo { ...@@ -161,20 +161,20 @@ export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
private isNextMusic = false; private isNextMusic = false;
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Set the 'play' event callback. audioPlayer.on('play', () => { // Set the `play` event callback.
console.info('audio play success'); console.info('audio play success');
audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback.
}); });
audioPlayer.on('reset', () => { // Set the 'reset' event callback. audioPlayer.on('reset', () => { // Set the `reset` event callback.
console.info('audio play success'); console.info('audio play success');
if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented.
this.nextMusic(audioPlayer); // Changing songs is implemented. this.nextMusic(audioPlayer); // Changing songs is implemented.
} else { } else {
audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
} }
}); });
...@@ -197,8 +197,8 @@ export class AudioDemo { ...@@ -197,8 +197,8 @@ export class AudioDemo {
} }
async audioPlayerDemo() { async audioPlayerDemo() {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks. this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
...@@ -223,19 +223,19 @@ import fileIO from '@ohos.fileio' ...@@ -223,19 +223,19 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.loop = true; // Set the loop playback attribute.
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Set the 'play' event callback to start loop playback. audioPlayer.on('play', () => { // Set the 'play' event callback to start loop playback.
console.info('audio play success'); console.info('audio play success');
}); });
} }
async audioPlayerDemo() { async audioPlayerDemo() {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks. this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
...@@ -247,7 +247,7 @@ export class AudioDemo { ...@@ -247,7 +247,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
} }
} }
``` ```
...@@ -9,6 +9,5 @@ ...@@ -9,6 +9,5 @@
- Development Fundamentals - Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](package-structure.md) - [Application Package Structure Configuration File (FA Model)](package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](stage-structure.md) - [Application Package Structure Configuration File (Stage Model)](stage-structure.md)
- [Resource File Categories](basic-resource-file-categories.md)
- [SysCap](syscap.md) - [SysCap](syscap.md)
- [HarmonyAppProvision Configuration File](app-provision-structure.md) - [HarmonyAppProvision Configuration File](app-provision-structure.md)
# Guide to Switching to Full SDK
Both the public SDK and full SDK are toolkits for application development.
The public SDK is intended for application developers and provided as standard in DevEco Studio. It does not contain system APIs – APIs required by system applications.
The full SDK is intended for original equipment manufacturers (OEMs) and provided separately. It contains system APIs.
The SDK of API version 8 provided in DevEco Studio is a public SDK. If your project depends on any system API, such as the **animator** component, **xcomponent** component, or APIs in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, or **@ohos.bluetooth.d.ts**, switch to the full SDK by performing the following steps.
## Downloading the Full SDK (of 3.1.1 Release in this example)
Manually download the full SDK. For details, see the source code acquisition section in [OpenHarmony 3.1.1 Release](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.1.1-release.md).
![image-20220613161049897](figures/en-us_image_0000001655128646.png)
## Checking the Local SDK Location<br>In this example, an eTS project is used. For a JS project, replace **ets** with **js**.
In DevEco Studio, choose **Tools** > **OpenHarmony SDK Manager** to check the location of the local SDK.
![](figures/en-us_image_0000001655128939.png)
![image-20220613160524053](figures/en-us_image_0000001655128998.png)
## Replacing the SDK
1. Make sure the downloaded SDK is a full SDK.
a. Verify that the name of the downloaded file contains **sdk-full**.
![image-20220613220702504](figures/en-us_image_0000001655129232.png)
b. Verify that the SDK contains system APIs (such as APIs defined in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, and **@ohos.bluetooth.d.ts**).
Note: The criteria for identifying system APIs are subject to the released API documentation.
2. Replace the SDK. The following uses full SDK 3.1.6.6 for Windows as an example.
a. Decompress the downloaded full SDK file: `ets-windows-3.1.6.5-Release.zip`
![image-20220613165018184](figures/en-us_image_0000001655129264.png)
b. Replace the SDK files.
Back up the local SDK files. (Copy and rename the version number directory in the **ets** directory, or copy the entire **ets** directory to another local path.)
Go to the obtained location of the local installed SDK and back up the files therein.
![image-20220613161352157](figures/en-us_image_0000001655129041.png)
Note: The name of the backup version number directory must be different from the value of **version** field in the **oh-uni-package.json** file. In the example below, the name of the backup version number directory is **3.1.6.6_backup**.
![image-20220613165018184](figures/en-us_image_0000001655129398.png)
The configuration in the **oh-uni-package.json** file is as follows:
```
{
"apiVersion": "8",
"displayName": "Ets",
"meta": {
"metaVersion": "3.0.0"
},
"path": "ets",
"releaseType": "Release",
"version": "3.1.6.6"
}
```
**Delete all files in the original SDK (3.1.6.6) directory.** Failure to do so may result in some files being unable to be overwritten.
Copy the full SDK to the location of the local SDK.
Copy all files in the **ets** directory in the full SDK to the **ets\3.1.6.6** directory in the location of the local SDK.
Change the value of **version** in the **oh-uni-package.json** file to the current SDK version number.
In the **3.1.6.6\build-tools\ets-loader** directory, open the **cmd/powerShell** window and run the **npm install** command to download the **node_modules** dependency package.
![image-20220613171111405](figures/en-us_image_0000001655129333.png)
c. Check for system APIs.
![image-20220613213038104](figures/en-us_image_0000001655129372.png)
# Development References # Development References
- [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md) - [Component Reference(TypeScript-based Declarative Development Paradigm)](arkui-ts/Readme-EN.md)
- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) - [Component Reference(JavaScript-based Web-like Development Paradigm)](arkui-js/Readme-EN.md)
- [APIs](apis/Readme-EN.md) - [APIs](apis/Readme-EN.md)
- [JS (eTS Included) APIs](apis/Readme-EN.md) - [JS (eTS Included) APIs](apis/Readme-EN.md)
- Native APIs - Native APIs
- [Standard Library](native-lib/third_party_libc/musl.md) - [Standard Library](native-lib/third_party_libc/musl.md)
......
...@@ -4,53 +4,58 @@ ...@@ -4,53 +4,58 @@
- Ability Framework - Ability Framework
- [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md) - FA Model
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md) - [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md) - [@ohos.ability.particleAbility](js-apis-particleAbility.md)
- [@ohos.application.Ability](js-apis-application-ability.md) - ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md) - app/[context](js-apis-Context.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md) - Stage Model
- [@ohos.application.AbilityStage ](js-apis-application-abilitystage.md) - [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.appManager](js-apis-appmanager.md) - [@ohos.application.AbilityStage](js-apis-application-abilitystage.md)
- [@ohos.application.Configuration](js-apis-configuration.md) - [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) - [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md)
- [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md) - [@ohos.application.FormExtension](js-apis-formextension.md)
- [@ohos.ability.featureAbility](js-apis-featureAbility.md) - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- [@ohos.application.formBindingData](js-apis-formbindingdata.md) - [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
- [@ohos.application.FormExtension](js-apis-formextension.md) - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
- [@ohos.application.formError](js-apis-formerror.md) - application/[AbilityContext](js-apis-ability-context.md)
- [@ohos.application.formHost](js-apis-formhost.md) - application/[ApplicationContext](js-apis-application-applicationContext.md)
- [@ohos.application.formInfo](js-apis-formInfo.md) - application/[AbilityStageContext](js-apis-abilitystagecontext.md)
- [@ohos.application.missionManager](js-apis-missionManager.md) - application/[Context](js-apis-application-context.md)
- [@ohos.application.formProvider](js-apis-formprovider.md) - application/[ExtensionContext](js-apis-extension-context.md)
- [@ohos.ability.particleAbility](js-apis-particleAbility.md) - application/[FormExtensionContext](js-apis-formextensioncontext.md)
- [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) - application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- [@ohos.application.StartOptions](js-apis-application-StartOptions.md) - application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) - FA and Stage Models
- [@ohos.application.uriPermissionManager](js-apis-uripermissionmanager.md) - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
- [@ohos.application.Want](js-apis-application-Want.md) - [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.wantAgent](js-apis-wantAgent.md) - [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md) - [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- app/[context](js-apis-Context.md) - [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- application/[AbilityContext](js-apis-ability-context.md) - [@ohos.application.appManager](js-apis-appmanager.md)
- application/[ApplicationContext](js-apis-application-applicationContext.md) - [@ohos.application.Configuration](js-apis-configuration.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md) - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
- application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md) - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- application/[abilityMonitor](js-apis-application-abilityMonitor.md) - [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md) - [@ohos.application.formError](js-apis-formerror.md)
- application/[AbilityStageContext](js-apis-abilitystagecontext.md) - [@ohos.application.formHost](js-apis-formhost.md)
- application/[Context](js-apis-application-context.md) - [@ohos.application.formInfo](js-apis-formInfo.md)
- application/[ExtensionContext](js-apis-extension-context.md) - [@ohos.application.formProvider](js-apis-formprovider.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md) - [@ohos.application.missionManager](js-apis-missionManager.md)
- application/[FormExtensionContext](js-apis-formextensioncontext.md) - [@ohos.application.Want](js-apis-application-Want.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) - [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md)
- application/[PermissionRequestResult](js-apis-permissionrequestresult.md) - [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md) - [@ohos.wantAgent](js-apis-wantAgent.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md) - application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md) - application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
- application/[MissionInfo](js-apis-application-missionInfo.md) - application/[abilityMonitor](js-apis-application-abilityMonitor.md)
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](js-apis-commonEvent.md) - [@ohos.commonEvent](js-apis-commonEvent.md)
...@@ -58,7 +63,7 @@ ...@@ -58,7 +63,7 @@
- [@ohos.notification](js-apis-notification.md) - [@ohos.notification](js-apis-notification.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md) - [@ohos.reminderAgent](js-apis-reminderAgent.md)
- application/[EventHub](js-apis-eventhub.md) - application/[EventHub](js-apis-eventhub.md)
- Bundle Management - Bundle Management
- [@ohos.bundle](js-apis-Bundle.md) - [@ohos.bundle](js-apis-Bundle.md)
...@@ -69,26 +74,30 @@ ...@@ -69,26 +74,30 @@
- bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md) - bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo](js-apis-bundle-BundleInfo.md) - bundle/[BundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[CustomizeData](js-apis-bundle-CustomizeData.md) - bundle/[CustomizeData](js-apis-bundle-CustomizeData.md)
- bundle/[ElementName](js-apis-bundle-ElementName.md)
- bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) - bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md) - bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[Metadata](js-apis-bundle-Metadata.md) - bundle/[Metadata](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md) - bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- UI Page - UI Page
- [@ohos.animator](js-apis-animator.md) - [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md) - [@ohos.mediaquery](js-apis-mediaquery.md)
- [@ohos.prompt](js-apis-prompt.md) - [@ohos.prompt](js-apis-prompt.md)
- [@ohos.router](js-apis-router.md) - [@ohos.router](js-apis-router.md)
- [@ohos.uiAppearance](js-apis-uiappearance.md)
- Graphics - Graphics
- [@ohos.display ](js-apis-display.md) - [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md)
- [@ohos.screen](js-apis-screen.md)
- [@ohos.screenshot](js-apis-screenshot.md) - [@ohos.screenshot](js-apis-screenshot.md)
- [@ohos.window](js-apis-window.md) - [@ohos.window](js-apis-window.md)
- [webgl](js-apis-webgl.md) - [webgl](js-apis-webgl.md)
- [webgl2](js-apis-webgl2.md) - [webgl2](js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio](js-apis-audio.md) - [@ohos.multimedia.audio](js-apis-audio.md)
...@@ -96,32 +105,33 @@ ...@@ -96,32 +105,33 @@
- [@ohos.multimedia.image](js-apis-image.md) - [@ohos.multimedia.image](js-apis-image.md)
- [@ohos.multimedia.media](js-apis-media.md) - [@ohos.multimedia.media](js-apis-media.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- Resource Management - Resource Management
- [@ohos.i18n](js-apis-i18n.md) - [@ohos.i18n](js-apis-i18n.md)
- [@ohos.intl](js-apis-intl.md) - [@ohos.intl](js-apis-intl.md)
- [@ohos.resourceManager](js-apis-resource-manager.md) - [@ohos.resourceManager](js-apis-resource-manager.md)
- Resource Scheduling - Resource Scheduling
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.workScheduler ](js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](js-apis-config-policy.md) - [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md) - [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- Security - Security
- [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager](js-apis-privacyManager.md)
- [@ohos.security.huks ](js-apis-huks.md) - [@ohos.security.huks ](js-apis-huks.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md) - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- [@system.cipher](js-apis-system-cipher.md) - [@system.cipher](js-apis-system-cipher.md)
- Data Management - Data Management
- [@ohos.data.dataAbility ](js-apis-data-ability.md) - [@ohos.data.dataAbility ](js-apis-data-ability.md)
...@@ -134,7 +144,7 @@ ...@@ -134,7 +144,7 @@
- [@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)
...@@ -145,7 +155,7 @@ ...@@ -145,7 +155,7 @@
- [@ohos.storageStatistics](js-apis-storage-statistics.md) - [@ohos.storageStatistics](js-apis-storage-statistics.md)
- [@ohos.volumeManager](js-apis-volumemanager.md) - [@ohos.volumeManager](js-apis-volumemanager.md)
- [@ohos.securityLabel](js-apis-securityLabel.md) - [@ohos.securityLabel](js-apis-securityLabel.md)
- Telephony Service - Telephony Service
- [@ohos.contact](js-apis-contact.md) - [@ohos.contact](js-apis-contact.md)
...@@ -155,7 +165,7 @@ ...@@ -155,7 +165,7 @@
- [@ohos.telephony.sim](js-apis-sim.md) - [@ohos.telephony.sim](js-apis-sim.md)
- [@ohos.telephony.sms](js-apis-sms.md) - [@ohos.telephony.sms](js-apis-sms.md)
- [@ohos.telephony.data](js-apis-telephony-data.md) - [@ohos.telephony.data](js-apis-telephony-data.md)
- Network Management - Network Management
- [@ohos.net.connection](js-apis-net-connection.md) - [@ohos.net.connection](js-apis-net-connection.md)
...@@ -163,7 +173,7 @@ ...@@ -163,7 +173,7 @@
- [@ohos.request](js-apis-request.md) - [@ohos.request](js-apis-request.md)
- [@ohos.net.socket](js-apis-socket.md) - [@ohos.net.socket](js-apis-socket.md)
- [@ohos.net.webSocket](js-apis-webSocket.md) - [@ohos.net.webSocket](js-apis-webSocket.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](js-apis-bluetooth.md) - [@ohos.bluetooth](js-apis-bluetooth.md)
...@@ -174,7 +184,7 @@ ...@@ -174,7 +184,7 @@
- [@ohos.rpc](js-apis-rpc.md) - [@ohos.rpc](js-apis-rpc.md)
- [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md) - [@ohos.wifiext](js-apis-wifiext.md)
- Basic Features - Basic Features
- [@ohos.accessibility](js-apis-accessibility.md) - [@ohos.accessibility](js-apis-accessibility.md)
...@@ -193,7 +203,7 @@ ...@@ -193,7 +203,7 @@
- [@ohos.systemTime](js-apis-system-time.md) - [@ohos.systemTime](js-apis-system-time.md)
- [@ohos.wallpaper](js-apis-wallpaper.md) - [@ohos.wallpaper](js-apis-wallpaper.md)
- [Timer](js-apis-timer.md) - [Timer](js-apis-timer.md)
- Device Management - Device Management
- [@ohos.batteryInfo ](js-apis-battery-info.md) - [@ohos.batteryInfo ](js-apis-battery-info.md)
...@@ -219,13 +229,13 @@ ...@@ -219,13 +229,13 @@
- [@ohos.update](js-apis-update.md) - [@ohos.update](js-apis-update.md)
- [@ohos.usb](js-apis-usb.md) - [@ohos.usb](js-apis-usb.md)
- [@ohos.vibrator](js-apis-vibrator.md) - [@ohos.vibrator](js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.appAccount](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.distributedAccount](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md) - [@ohos.account.osAccount](js-apis-osAccount.md)
- Language Base Class Library - Language Base Class Library
- [@ohos.convertxml](js-apis-convertxml.md) - [@ohos.convertxml](js-apis-convertxml.md)
...@@ -249,12 +259,12 @@ ...@@ -249,12 +259,12 @@
- [@ohos.util.Vector](js-apis-vector.md) - [@ohos.util.Vector](js-apis-vector.md)
- [@ohos.worker](js-apis-worker.md) - [@ohos.worker](js-apis-worker.md)
- [@ohos.xml](js-apis-xml.md) - [@ohos.xml](js-apis-xml.md)
- Test - Test
- [@ohos.application.testRunner](js-apis-testRunner.md) - [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md) - [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.bytrace](js-apis-bytrace.md) - [@ohos.bytrace](js-apis-bytrace.md)
......
# DataUriUtils Module # DataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
> **NOTE** > **NOTE**
> >
......
# EnterpriseAdminExtentionAbility # EnterpriseAdminExtensionAbility
The **EnterpriseAdminExtentionAbility** module provides APIs for Extension abilities of enterprise administrators. The **EnterpriseAdminExtensionAbility** module provides Extension abilities for enterprise administrators.
To have the capabilities provided by the module, for example, receiving the application activation or deactivation notification sent by the system, an enterprise administrator application must have an **EnterpriseAdminExtensionAbility** instance and override the APIs in it.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
## Modules to Import ## Modules to Import
```ts ```ts
import EnterpriseAdminExtentionAbility from '@ohos.EnterpriseAdminExtentionAbility' import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility'
``` ```
## EnterpriseAdminExtentionAbility.onAdminEnabled ## EnterpriseAdminExtensionAbility.onAdminEnabled
onAdminEnabled(): void onAdminEnabled(): void
...@@ -22,14 +26,14 @@ Called when an enterprise administrator is enabled. ...@@ -22,14 +26,14 @@ Called when an enterprise administrator is enabled.
**Example** **Example**
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() { onAdminEnabled() {
} }
}; };
``` ```
## EnterpriseAdminExtentionAbility.onAdminDisabled ## EnterpriseAdminExtensionAbility.onAdminDisabled
onAdminDisabled(): void onAdminDisabled(): void
...@@ -38,11 +42,10 @@ Called when an enterprise administrator is disabled. ...@@ -38,11 +42,10 @@ Called when an enterprise administrator is disabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**Example** **Example**
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminDisabled() { onAdminDisabled() {
} }
}; };
``` ```
# ErrorCode # ErrorCode
The **ErrorCode** module defines the error codes that can be used when the ability is started.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API 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
...@@ -12,7 +14,7 @@ import errorCode from '@ohos.ability.errorCode' ...@@ -12,7 +14,7 @@ import errorCode from '@ohos.ability.errorCode'
## ErrorCode ## ErrorCode
Defines the error code used when the ability is started. Defines the error codes used when the ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
# wantConstant # wantConstant
The **wantConstant** module provides the action, entity, and flags used in **Want** objects.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -12,73 +14,75 @@ import wantConstant from '@ohos.ability.wantConstant' ...@@ -12,73 +14,75 @@ import wantConstant from '@ohos.ability.wantConstant'
## wantConstant.Action ## wantConstant.Action
**System capability**: SystemCapability.Ability.AbilityBase Enumerates the action constants of the **Want** object.
Lists the permissions. **System capability**: SystemCapability.Ability.AbilityBase
| Common Event Macro | Common Event Name | Subscriber Permission | | Name | Value | Description |
| ------------ | ------------------ | ---------------------- | | ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | None | | ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | None | | ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | None | | ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None | | ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None | | ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | | ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | None | | ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None | | ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None | | ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None | | ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None | | ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | None | | ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. |
| ACTION_CHOOSE | ohos.want.action.choose | None | | ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | None | | ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTUR<sup>8+</sup> | ohos.want.action.videoCapture | None | | ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | None | | ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
| ACTION_SEND_DATA | ohos.want.action.sendData | None | | ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None | | ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None | | ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
| ACTION_VIEW_DATA | ohos.want.action.viewData | None | | ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
| ACTION_EDIT_DATA | ohos.want.action.editData | None | | ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None | | INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None | | INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | None | | ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | None | | PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | None | | ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_MARKER_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity ## wantConstant.Entity
**System capability**: SystemCapability.Ability.AbilityBase Enumerates the entity constants of the **Want** object.
Lists the permissions. **System capability**: SystemCapability.Ability.AbilityBase
| Common Event Macro | Common Event Name | Subscriber Permission | | Name | Value | Description |
| ------------ | ------------------ | ---------------------- | | ------------ | ------------------ | ---------------------- |
| ENTITY_DEFAULT | entity.system.default | None | | ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. |
| ENTITY_HOME | entity.system.homel | None | | ENTITY_HOME | entity.system.home | Home screen entity. |
| ENTITY_VOICE | ENTITY_VOICE | None | | ENTITY_VOICE | entity.system.voice | Voice interaction entity. |
| ENTITY_BROWSABLE | entity.system.browsable | None | | ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. |
| ENTITY_VIDEO | entity.system.video | None | | ENTITY_VIDEO | entity.system.video | Video type entity. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
## wantConstant.Flags
## flags Describes flags.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description | | Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. | | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. | | FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. | | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. | | FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. | | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.| | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
......
# Ability Access Control # Ability Access Control
Provides program permission management capabilities, including authentication, authorization, and revocation. The **AbilityAccessCtrl** module provides APIs for application permission management, including authentication, authorization, and revocation.
> **NOTE** > **NOTE**
> >
...@@ -69,6 +69,36 @@ promise.then(data => { ...@@ -69,6 +69,36 @@ promise.then(data => {
}); });
``` ```
### verifyAccessTokenSync<sup>9+</sup>
verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus
Checks whether an application has been granted the specified permission. This API synchronously returns the result.
**System capability**: SystemCapability.Security.AccessToken
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| [GrantStatus](#grantstatus) | Permission grant state.|
**Example**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let data = verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
console.log(`data->${JSON.stringify(data)}`);
```
### grantUserGrantedPermission ### grantUserGrantedPermission
grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise&lt;number&gt; grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise&lt;number&gt;
......
# AbilityDelegatorRegistry # AbilityDelegatorRegistry
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
> **NOTE** > **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.
...@@ -24,8 +26,6 @@ Enumerates the ability lifecycle states. ...@@ -24,8 +26,6 @@ Enumerates the ability lifecycle states.
| BACKGROUND | 3 | The ability is running in the background. | | BACKGROUND | 3 | The ability is running in the background. |
| DESTROY | 4 | The ability is destroyed.| | DESTROY | 4 | The ability is destroyed.|
## AbilityDelegatorRegistry.getAbilityDelegator ## AbilityDelegatorRegistry.getAbilityDelegator
getAbilityDelegator(): AbilityDelegator getAbilityDelegator(): AbilityDelegator
......
# AbilityRunningInfo # AbilityRunningInfo
The **AbilityRunningInfo** module implements ability running information and ability states.
> **NOTE** > **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.
Provides ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage ## Usage
The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**. The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
...@@ -27,26 +21,13 @@ abilitymanager.getAbilityRunningInfos((err,data) => { ...@@ -27,26 +21,13 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. | | ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.| | pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. | | uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. | | processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. | | startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. | | abilityState | [abilityManager.AbilityState](js-apis-application-abilityManager.md#abilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
# AbilityStageContext # AbilityStageContext
The **AbilityStageContext** module, inherited from [Context](js-apis-application-context.md), implements the context of an ability stage.
This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the **ModuleInfo** object and environment configuration of an ability stage.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage ## Usage
The ability stage context is obtained through an **AbilityStage** instance. The ability stage context is obtained through an **AbilityStage** instance.
......
...@@ -1956,6 +1956,7 @@ Defines OAuth token information. ...@@ -1956,6 +1956,7 @@ Defines OAuth token information.
| -------- | ------ | ---- | -------- | | -------- | ------ | ---- | -------- |
| authType | string | Yes | Authentication type.| | authType | string | Yes | Authentication type.|
| token | string | Yes | Value of the token. | | token | string | Yes | Value of the token. |
| account<sup>9+</sup> | AppAccountInfo | No | Account information of the token. |
## AuthenticatorInfo<sup>8+</sup> ## AuthenticatorInfo<sup>8+</sup>
......
# Data Share Extension Ability # Data Share Extension Ability
**DataShareExtensionAbility** provides extension abilities for data share services based on the ExtensionAbility framework. The **DataShareExtensionAbility** module provides Extension abilities for data share services.
>**NOTE** >**NOTE**
> >
...@@ -17,11 +17,19 @@ ...@@ -17,11 +17,19 @@
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility' import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'
``` ```
## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [ExtensionContext](js-apis-extension-context.md) | Yes| No|Context of the DataShare Extension ability.|
## onCreate ## onCreate
onCreate?(want: Want, callback: AsyncCallback&lt;void&gt;): void onCreate?(want: Want, callback: AsyncCallback&lt;void&gt;): void
Called to initialize service logic of the server when the DataShare client connects to the DataShareExtensionAbility server. This API can be overridden as required. Called by the server to initialize service logic when the DataShare client connects to the DataShareExtensionAbility server. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -45,7 +53,7 @@ let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ...@@ -45,7 +53,7 @@ let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
let rdbStore; let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want: Want, callback: AsyncCallback<void>) { onCreate(want, callback) {
rdb.getRdbStore(this.context, { rdb.getRdbStore(this.context, {
name: DB_NAME name: DB_NAME
}, 1, function (err, data) { }, 1, function (err, data) {
...@@ -66,7 +74,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -66,7 +74,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Called by the server to obtain the Multipurpose Internet Mail Extensions (MIME) types supported by a file. This API can be overridden as required. Obtains the Multipurpose Internet Mail Extensions (MIME) types supported by a file. This API is called by the server and can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -82,7 +90,7 @@ Called by the server to obtain the Multipurpose Internet Mail Extensions (MIME) ...@@ -82,7 +90,7 @@ Called by the server to obtain the Multipurpose Internet Mail Extensions (MIME)
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>) { getFileTypes(uri, mimeTypeFilter, callback) {
let err = {"code":0}; let err = {"code":0};
let ret = new Array("type01", "type02", "type03"); let ret = new Array("type01", "type02", "type03");
callback(err, ret); callback(err, ret);
...@@ -94,7 +102,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -94,7 +102,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
openFile?(uri: string, mode: string, callback: AsyncCallback&lt;number&gt;): void openFile?(uri: string, mode: string, callback: AsyncCallback&lt;number&gt;): void
Called by the server to open a file. This method can be overridden as required. Opens a file. This API is called by the server and can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -103,14 +111,14 @@ Called by the server to open a file. This method can be overridden as required. ...@@ -103,14 +111,14 @@ Called by the server to open a file. This method can be overridden as required.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------ | | -------- | --------------------- | ---- | ------------------------------------------ |
| uri | string | Yes | URI of the file to open. | | uri | string | Yes | URI of the file to open. |
| mode | string | Yes | File open mode, including read-only mode and read/write mode.| | mode | string | Yes | File open mode, which can be read-only or read/write.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the file descriptor. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the file descriptor. |
**Example** **Example**
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
openFile(uri: string, mode: string, callback: AsyncCallback<number>) { openFile(uri, mode, callback) {
let err = {"code":0}; let err = {"code":0};
let fd = 0; let fd = 0;
callback(err,fd); callback(err,fd);
...@@ -122,7 +130,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -122,7 +130,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void
Called to insert data into the database. This API can be overridden as required. Inserts data into the database. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -137,13 +145,22 @@ Called to insert data into the database. This API can be overridden as required. ...@@ -137,13 +145,22 @@ Called to insert data into the database. This API can be overridden as required.
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
insert(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<number>) { insert(uri, valueBucket, callback) {
if (value == null) { if (valueBucket == null) {
console.info('invalid valueBuckets'); console.info('invalid valueBuckets');
return; return;
} }
rdbStore.insert(TBL_NAME, value, function (err, ret) { rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) {
console.info('callback ret:' + ret); console.info('callback ret:' + ret);
if (callback != undefined) { if (callback != undefined) {
callback(err, ret); callback(err, ret);
...@@ -157,7 +174,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -157,7 +174,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback&lt;number&gt;): void
Called by the server to update data in the database. This API can be overridden as required. Updates data in the database. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -166,19 +183,28 @@ Called by the server to update data in the database. This API can be overridden ...@@ -166,19 +183,28 @@ Called by the server to update data in the database. This API can be overridden
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ | | ----- | ------ | ------ | ------ |
| uri | string | Yes | URI of the data to update.| | uri | string | Yes | URI of the data to update.|
| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for updating data.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for updating data.|
| valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| New data.| | valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| New data.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of updated data records.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of updated data records.|
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
update(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback<number>) { update(uri, predicates, valueBucket, callback) {
if (predicates == null || predicates == undefined) { if (predicates == null || predicates == undefined) {
return; return;
} }
rdbStore.update(TBL_NAME, value, predicates, function (err, ret) { rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) {
if (callback != undefined) { if (callback != undefined) {
callback(err, ret); callback(err, ret);
} }
...@@ -191,7 +217,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -191,7 +217,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void
Called by the server to delete data from the database. This API can be overridden as required. Deletes data from the database. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -200,14 +226,23 @@ Called by the server to delete data from the database. This API can be overridde ...@@ -200,14 +226,23 @@ Called by the server to delete data from the database. This API can be overridde
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
| uri | string | Yes | URI of the data to delete. | | uri | string | Yes | URI of the data to delete. |
| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for deleting data. | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for deleting data. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of data records deleted.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of data records deleted.|
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>) { delete(uri, predicates, callback) {
if (predicates == null || predicates == undefined) { if (predicates == null || predicates == undefined) {
return; return;
} }
...@@ -224,7 +259,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -224,7 +259,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;Object&gt;): void query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;Object&gt;): void
Called by the server to query data from the database. This API can be overridden as required. Queries data from the database. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -233,15 +268,24 @@ Called by the server to query data from the database. This API can be overridden ...@@ -233,15 +268,24 @@ Called by the server to query data from the database. This API can be overridden
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ | | ----- | ------ | ------ | ------ |
| uri | string | Yes | URI of the data to query.| | uri | string | Yes | URI of the data to query.|
| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.|
| columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is empty, all columns will be queried.| | columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is empty, all columns will be queried.|
| callback | AsyncCallback&lt;Object&gt; | Yes| Callback invoked to return the result set.| | callback | AsyncCallback&lt;Object&gt; | Yes| Callback invoked to return the result set.|
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>) { query(uri, predicates, columns, callback) {
if (predicates == null || predicates == undefined) { if (predicates == null || predicates == undefined) {
return; return;
} }
...@@ -261,7 +305,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -261,7 +305,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
getType?(uri: string, callback: AsyncCallback&lt;string&gt;): void getType?(uri: string, callback: AsyncCallback&lt;string&gt;): void
Called by the server to obtain the MIME type corresponding to the given URI. This API can be overridden as required. Obtains the MIME type corresponding to the given URI. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -276,7 +320,7 @@ Called by the server to obtain the MIME type corresponding to the given URI. Thi ...@@ -276,7 +320,7 @@ Called by the server to obtain the MIME type corresponding to the given URI. Thi
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
getType(uri: string, callback: AsyncCallback<string>) { getType(uri, callback) {
let err = {"code":0}; let err = {"code":0};
let ret = "image"; let ret = "image";
callback(err, ret); callback(err, ret);
...@@ -284,11 +328,11 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -284,11 +328,11 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
}; };
``` ```
## BatchInsert ## batchInsert
BatchInsert?(uri: string, valueBuckets: Array&lt;ValuesBucket&gt;, callback: AsyncCallback&lt;number&gt;): void batchInsert?(uri: string, valueBuckets: Array&lt;ValuesBucket&gt;, callback: AsyncCallback&lt;number&gt;): void
Called by the server to insert batch data into the database. This API can be overridden as required. Batch inserts data into the database. This API is called by the server and can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -303,8 +347,17 @@ Called by the server to insert batch data into the database. This API can be ove ...@@ -303,8 +347,17 @@ Called by the server to insert batch data into the database. This API can be ove
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
batchInsert(uri: string, valueBuckets: Array<ValuesBucket>, callback: AsyncCallback<number>) { batchInsert(uri, valueBuckets, callback) {
if (valueBuckets == null || valueBuckets.length == undefined) { if (valueBuckets == null || valueBuckets.length == undefined) {
console.info('invalid valueBuckets'); console.info('invalid valueBuckets');
return; return;
...@@ -325,7 +378,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -325,7 +378,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
normalizeUri?(uri: string, callback: AsyncCallback&lt;string&gt;): void normalizeUri?(uri: string, callback: AsyncCallback&lt;string&gt;): void
Called by the server to normalize the specified URI. This API can be overridden as required. Normalizes a URI. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -340,7 +393,7 @@ Called by the server to normalize the specified URI. This API can be overridden ...@@ -340,7 +393,7 @@ Called by the server to normalize the specified URI. This API can be overridden
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
normalizeUri(uri: string, callback: AsyncCallback<string>) { normalizeUri(uri, callback) {
let err = {"code":0}; let err = {"code":0};
let ret = "normalize+" + uri; let ret = "normalize+" + uri;
callback(err, ret); callback(err, ret);
...@@ -352,7 +405,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -352,7 +405,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
denormalizeUri?(uri: string, callback: AsyncCallback&lt;string&gt;): void denormalizeUri?(uri: string, callback: AsyncCallback&lt;string&gt;): void
Called by the server to denormalize the specified URI. This method can be overridden as required. Denormalizes a URI. This API can be overridden as required.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
...@@ -361,13 +414,13 @@ Called by the server to denormalize the specified URI. This method can be overri ...@@ -361,13 +414,13 @@ Called by the server to denormalize the specified URI. This method can be overri
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ----------------------- | | -------- | --------------------- | ---- | ----------------------- |
| uri | string | Yes | [URI](js-apis-uri.md#uri) to denormalize.| | uri | string | Yes | [URI](js-apis-uri.md#uri) to denormalize.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. If the operation is successful, the URI obtained is returned. If the URI passed in is returned, denormalization is not required. If denormalization is not supported, **null** is returned.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. If the operation is successful, the denormalized URI is returned. If the URI passed in is returned, denormalization is not required. If denormalization is not supported, **null** is returned.|
**Example** **Example**
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
denormalizeUri(uri: string, callback: AsyncCallback<string>) { denormalizeUri(uri, callback) {
let err = {"code":0}; let err = {"code":0};
let ret = "denormalize+" + uri; let ret = "denormalize+" + uri;
callback(err, ret); callback(err, ret);
......
# EnvironmentCallback
The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes.
> **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 APIs of this module can be used only in the stage model.
## Modules to Import
```js
import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
```
## EnvironmentCallback.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
Called when the system environment changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| **Configuration** object after the change.|
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
var callbackId;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
},
}
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
});
}
}
```
# AbilityStage # AbilityStage
**AbilityStage** is a runtime class for HAP files.
The **AbilityStage** module notifies you of when you can perform HAP initialization such as resource pre-loading and thread creation during the HAP loading.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
Runtime class for HAP files. It provides APIs to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads.
## Modules to Import ## Modules to Import
```js ```js
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册