提交 072cb2cb 编写于 作者: L liuyuehua 提交者: Gitee

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

...@@ -35,12 +35,12 @@ OpenHarmony_v1.x_release: OpenHarmony v1.1.4 LTS. [Learn more](en/release-notes/ ...@@ -35,12 +35,12 @@ OpenHarmony_v1.x_release: OpenHarmony v1.1.4 LTS. [Learn more](en/release-notes/
## Third-Party Open-Source Software and License Notice ## Third-Party Open-Source Software and License Notice
3rd-Party-License: [Third-Party Open-Source Software and License Notice](en/contribute/third-party-open-source-software-and-license-notice.md) Third-party license: [Third-Party Open-Source Software and License Notice](en/contribute/third-party-open-source-software-and-license-notice.md)
## How to Contribute ## How to Contribute
A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to [participate](contribute/contribution.md) in this exciting journey, and we're grateful for your time, passion, and efforts! A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to [participate](en/contribute/how-to-contribute.md) in this exciting journey, and we're grateful for your time, passion, and efforts!
You can evaluate available documents, make simple modifications, provide feedback on document quality, and contribute your original content. For details, see [Documentation Contribution](contribute/documentation-contribution.md). You can evaluate available documents, make simple modifications, provide feedback on document quality, and contribute your original content. For details, see [Documentation Contribution](en/contribute/documentation-contribution.md).
Excellent contributors will be awarded and the contributions will be publicized in the developer community. Excellent contributors will be awarded and the contributions will be publicized in the developer community.
...@@ -18,19 +18,19 @@ ...@@ -18,19 +18,19 @@
master:最新开发版本。 master:最新开发版本。
发布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)了解版本详情
发布OpenHarmony 3.0 LTS版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)。该版本已更新至OpenHarmony 3.0.3 LTS,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md) OpenHarmony 3.0 LTS版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)了解版本详情。该版本已更新至OpenHarmony 3.0.3 LTS,点击[此处](zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md)了解版本详情
发布 OpenHarmony v2.2 Beta2版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v2.2-beta2.md) OpenHarmony v2.2 Beta2版本:点击[此处](zh-cn/release-notes/OpenHarmony-v2.2-beta2.md)了解版本详情
发布OpenHarmony 2.0 Canary预览版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-2-0-Canary.md) OpenHarmony 2.0 Canary预览版本:点击[此处](zh-cn/release-notes/OpenHarmony-2-0-Canary.md)了解版本详情
### 历史稳定版本 ### 历史稳定版本
OpenHarmony_v1.x_release:OpenHarmony 1.1.4 LTS稳定版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md) OpenHarmony_v1.x_release:OpenHarmony 1.1.4 LTS稳定版本,点击[此处](zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md)了解版本详情
[了解更多版本详情](zh-cn/release-notes/) 如需了解更多版本详情,点击[此处](zh-cn/release-notes/)
## 第三方开源软件及许可说明 ## 第三方开源软件及许可说明
...@@ -39,7 +39,7 @@ OpenHarmony_v1.x_release:OpenHarmony 1.1.4 LTS稳定版本,[了解版本详 ...@@ -39,7 +39,7 @@ OpenHarmony_v1.x_release:OpenHarmony 1.1.4 LTS稳定版本,[了解版本详
## 贡献 ## 贡献
非常欢迎您参与[贡献](zh-cn/contribute/参与贡献.md),我们鼓励开发者以各种方式参与文档反馈和贡献。 欢迎您参与[贡献](zh-cn/contribute/参与贡献.md),我们鼓励开发者以各种方式参与文档反馈和贡献。
您可以对现有文档进行评价、简单更改、反馈文档质量问题、贡献您的原创内容,详细请参考[贡献文档](zh-cn/contribute/贡献文档.md) 您可以对现有文档进行评价、简单更改、反馈文档质量问题、贡献您的原创内容,详细请参考[贡献文档](zh-cn/contribute/贡献文档.md)
......
此差异已折叠。
...@@ -24,16 +24,16 @@ A Service ability is used to run tasks in the background, such as playing music ...@@ -24,16 +24,16 @@ A Service ability is used to run tasks in the background, such as playing music
```javascript ```javascript
export default { export default {
onStart(want) { onStart() {
console.log('ServiceAbility onStart'); console.log('ServiceAbility onStart');
}, },
onCommand(want, restart, startId) { onCommand(want, startId) {
console.log('ServiceAbility onCommand'); console.log('ServiceAbility onCommand');
}, },
onConnect(want) { onConnect(want) {
console.log('ServiceAbility OnConnect'); console.log('ServiceAbility OnConnect');
}, },
onDisconnect() { onDisconnect(want) {
console.log('ServiceAbility OnDisConnect'); console.log('ServiceAbility OnDisConnect');
}, },
onStop() { onStop() {
...@@ -174,7 +174,7 @@ import rpc from "@ohos.rpc"; ...@@ -174,7 +174,7 @@ import rpc from "@ohos.rpc";
let mMyStub; let mMyStub;
export default { export default {
onStart(want) { onStart() {
class MyStub extends rpc.RemoteObject{ class MyStub extends rpc.RemoteObject{
constructor(des) { constructor(des) {
if (typeof des === 'string') { if (typeof des === 'string') {
...@@ -182,7 +182,7 @@ export default { ...@@ -182,7 +182,7 @@ export default {
} }
return null; return null;
} }
onRemoteRequest(code, message, reply, option) { onRemoteRequest(code, data, reply, option) {
console.log("ServiceAbility onRemoteRequest called"); console.log("ServiceAbility onRemoteRequest called");
if (code === 1) { if (code === 1) {
let op1 = data.readInt(); let op1 = data.readInt();
...@@ -197,14 +197,14 @@ export default { ...@@ -197,14 +197,14 @@ export default {
} }
mMyStub = new MyStub("ServiceAbility-test"); mMyStub = new MyStub("ServiceAbility-test");
}, },
onCommand(want, restart, startId) { onCommand(want, startId) {
console.log('ServiceAbility onCommand'); console.log('ServiceAbility onCommand');
}, },
onConnect(want) { onConnect(want) {
console.log('ServiceAbility OnConnect'); console.log('ServiceAbility OnConnect');
return mMyStub; return mMyStub;
}, },
onDisconnect() { onDisconnect(want) {
console.log('ServiceAbility OnDisConnect'); console.log('ServiceAbility OnDisConnect');
}, },
onStop() { onStop() {
...@@ -225,12 +225,12 @@ The following code snippet shows how to implement the callbacks: ...@@ -225,12 +225,12 @@ The following code snippet shows how to implement the callbacks:
```ts ```ts
let mRemote; let mRemote;
function onConnectCallback(element, remote){ function onConnectCallback(element, remote){
console.log('onConnectLocalService onConnectDone element: ' + element); console.log('onConnectRemoteService onConnectDone element: ' + element);
console.log('onConnectLocalService onConnectDone remote: ' + remote); console.log('onConnectRemotelService onConnectDone remote: ' + remote);
mRemote = remote; mRemote = remote;
if (mRemote == null) { if (mRemote == null) {
prompt.showToast({ prompt.showToast({
message: "onConnectLocalService not connected yet" message: "onConnectRemoteService not connected yet"
}); });
return; return;
} }
...@@ -243,7 +243,7 @@ function onConnectCallback(element, remote){ ...@@ -243,7 +243,7 @@ function onConnectCallback(element, remote){
console.log('sendRequest success'); console.log('sendRequest success');
let msg = reply.readInt(); let msg = reply.readInt();
prompt.showToast({ prompt.showToast({
message: "onConnectLocalService connect result: " + msg, message: "onConnectRemoteService connect result: " + msg,
duration: 3000 duration: 3000
}); });
}).catch((e) => { }).catch((e) => {
......
此差异已折叠。
# Connectivity # Network and Connectivity
- [IPC & RPC] - Network Management
- [Network Management Overview](net-mgmt-overview.md)
- [HTTP Data Request](http-request.md)
- [WebSocket Connection](websocket-connection.md)
- [Socket Connection](socket-connection.md)
- IPC & RPC
- [IPC & RPC Overview](ipc-rpc-overview.md) - [IPC & RPC Overview](ipc-rpc-overview.md)
- [IPC & RPC Development Guidelines](ipc-rpc-development-guideline.md)
- [IPC & RPC Development](ipc-rpc-development-guideline.md)
- [Subscribing to State Changes of a Remote Object](subscribe-remote-state.md) - [Subscribing to State Changes of a Remote Object](subscribe-remote-state.md)
# HTTP Data Request
## Use Cases
An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
## Available APIs
The HTTP request function is mainly implemented by the HTTP module.
To use related APIs, you must declare the **ohos.permission.INTERNET** permission.
The following table describes the related APIs.
| API | Description |
| ----------------------------------------- | ----------------------------------- |
| createHttp() | Creates an HTTP request. |
| request() | Initiates an HTTP request to a given URL. |
| destroy() | Destroys an HTTP request. |
| on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. |
| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.|
## How to Develop
1. Import the required HTTP module.
2. Create an **HttpRequest** object.
3. (Optional) Listen for HTTP Response Header events.
4. Initiates an HTTP request to a given URL.
5. (Optional) Process the HTTP Response Header event and the return result of the HTTP request.
```js
import http from '@ohos.net.http';
// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused.
let httpRequest = http.createHttp();
// Subscribe to the HTTP response header, which is returned earlier than HttpRequest. You can subscribe to HTTP Response Header events based on service requirements.
// on('headerReceive', AsyncCallback) will be replaced by on('headersReceive', Callback) in API version 8. 8+
httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
httpRequest.request(
// Set the URL of the HTTP request. You need to define the URL. Set the parameters of the request in extraData.
"EXAMPLE_URL",
{
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
// You can add the header field based on service requirements.
header: {
'Content-Type': 'application/json'
},
// This field is used to transfer data when the POST request is used.
extraData: {
"data": "data to send",
},
connectTimeout: 60000, // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms.
}, (err, data) => {
if (!err) {
// data.result contains the HTTP response. Parse the response based on service requirements.
console.info('Result:' + data.result);
console.info('code:' + data.responseCode);
// data.header contains the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + data.cookies); // 8+
} else {
console.info('error:' + JSON.stringify(err));
// Call the destroy() method to release resources after the call is complete.
httpRequest.destroy();
}
}
);
```
# Network Management Overview
Network management functions include:
- [HTTP Data Request](http-request.md): Initiates a data request through HTTP.
- [WebSocket Connection](websocket-connection.md): Establishes a bidirectional connection between the server and client through WebSocket.
- [Socket Connection](socket-connection.md): Transmits data through Socket.
## Constraints
To use the functions of the network management module, you must obtain the permissions listed in the following table.
| Permission | Description |
| -------------------------------- | -------------------------------------- |
| ohos.permission.GET_NETWORK_INFO | Allows an application to obtain the network connection information. |
| ohos.permission.SET_NETWORK_INFO | Allows an application to modify the network connection state. |
| ohos.permission.INTERNET | Allows an application to open network sockets to connect to the network.|
# Socket Connection
## Use Cases
Your application can transmit data through Socket connections. Currently, the TCP and UDP protocols are supported.
## Available APIs
The Socket connection function is mainly implemented by the Socket module. The following table describes the related APIs.
| API| Description|
| -------- | -------- |
| constructUDPSocketInstance() | Creates a **UDPSocket** object.|
| constructTCPSocketInstance() | Creates a **TCPSocket** object.|
| bind() | Binds the IP address and port number.|
| send() | Sends data.|
| close() | Closes a Socket connection.|
| getState() | Obtains the Socket connection status.|
| connect() | Connects to the specified IP address and port. This function is supported only for TCP.|
| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API.|
| on(type: 'message') | Enables listening for **message** events of the Socket connection.|
| off(type: 'message') | Disables listening for **message** events of the Socket connection.|
| on(type: 'close') | Enables listening for **close** events of the Socket connection.|
| off(type: 'close') | Disables listening for **close** events of the Socket connection.|
| on(type: 'error') | Enables listening for **error** events of the Socket connection.|
| off(type: 'error') | Disables listening for **error** events of the Socket connection.|
| on(type: 'listening') | Enables listening for **listening** events of the UDPSocket connection. |
| off(type: 'listening') | Disables listening for **listening** events of the UDPSocket connection. |
| on(type: 'connect') | Enables listening for **connect** events of the TCPSocket connection. |
| off(type: 'connect') | Disables listening for **connect** events of the TCPSocket connection.|
## How to Develop
The implementation is similar for UDPSocket and TCPSocket. The following uses the TCPSocket as an example.
1. Import the required Socket module.
2. Create a **TCPSocket** object.
3. (Optional) Enable listening for TCPSocket events.
4. Bind the IP address and port number. The port number can be specified or randomly allocated by the system.
5. Set up a connection to the specified IP address and port number.
6. Send data.
7. Enable the TCPSocket connection to be automatically closed after use.
```js
import socket from '@ohos.net.socket'
// Create a TCPSocket object.
let tcp = socket.constructTCPSocketInstance();
// Enable listening for TCPSocket events.
tcp.on('message', value => {
console.log("on message")
let buffer = value.message
let dataView = new DataView(buffer)
let str = ""
for (let i = 0;i < dataView.byteLength; ++i) {
str += String.fromCharCode(dataView.getUint8(i))
}
console.log("on connect recevied:" + str)
});
tcp.on('connect', () => {
console.log("on connect")
});
tcp.on('close', () => {
console.log("on close")
});
// Bind the IP address and port number.
let bindAddress = {
address: '192.168.xx.xx',
port: 1234, // Bound port, for example, 1234.
family: 1
};
tcp.bind(bindAddress, err => {
if (err) {
console.log('bind fail');
return;
}
console.log('bind success');
// Set up a connection to the specified IP address and port number.
let connectAddress = {
address: '192.168.xx.xx',
port: 5678, // Connection port, for example, 5678.
family: 1
};
tcp.connect({
address: connectAddress, timeout: 6000
}, err => {
if (err) {
console.log('connect fail');
return;
}
console.log('connect success');
// Send data.
tcp.send({
data: 'Hello, server!'
}, err => {
if (err) {
console.log('send fail');
return;
}
console.log('send success');
})
});
});
// Enable the TCPSocket connection to be automatically closed after use. Then, disable listening for TCPSocket events.
setTimeout(() => {
tcp.close((err) => {
console.log('close socket.')
});
tcp.off('message');
tcp.off('connect');
tcp.off('close');
}, 30 * 1000);
```
# WebSocket Connection
## 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.
If an error occurs in any of the preceding processes, the client will receive a callback of the **error** event.
## Available APIs
The WebSocket connection function is mainly implemented by the WebSocket module. To use related APIs, you must declare the **ohos.permission.INTERNET** permission. The following table describes the related APIs.
| API| Description|
| -------- | -------- |
| createWebSocket() | Creates a WebSocket connection.|
| connect() | Establishes a WebSocket connection to a given URL.|
| send() | Sends data through the WebSocket connection.|
| close() | Closes a WebSocket connection.|
| on(type:&nbsp;'open') | Enables listening for **open** events of a WebSocket connection.|
| off(type:&nbsp;'open') | Disables listening for **open** events of a WebSocket connection.|
| on(type:&nbsp;'message') | Enables listening for **message** events of a WebSocket connection.|
| off(type:&nbsp;'message') | Disables listening for **message** events of a WebSocket connection.|
| on(type:&nbsp;'close') | Enables listening for **close** events of a WebSocket connection.|
| off(type:&nbsp;'close') | Disables listening for **close** events of a WebSocket connection.|
| on(type:&nbsp;'error') | Enables listening for **error** events of a WebSocket connection.|
| off(type:&nbsp;'error') | Disables listening for **error** events of a WebSocket connection.|
## How to Develop
1. Import the required WebSocket module.
2. Create a **WebSocket** object.
3. (Optional) Subscribe to WebSocket open, message, close, and error events.
4. Establish a WebSocket connection to a given URL.
5. Close the WebSocket connection if it is no longer needed.
```js
import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + JSON.stringify(value));
// When receiving the on('open') event, the client can use the send() API to communicate with the server.
ws.send("Hello, server!", (err, value) => {
if (!err) {
console.log("send success");
} else {
console.log("send fail, err:" + JSON.stringify(err));
}
});
});
ws.on('message', (err, value) => {
console.log("on message, message:" + value);
// When receiving the `bye` message (the actual message name may differ) from the server, the client proactively disconnects from the server.
if (value === 'bye') {
ws.close((err, value) => {
if (!err) {
console.log("close success");
} else {
console.log("close fail, err is " + JSON.stringify(err));
}
});
}
});
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
});
ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err));
});
ws.connect(defaultIpAddress, (err, value) => {
if (!err) {
console.log("connect success");
} else {
console.log("connect fail, err:" + JSON.stringify(err));
}
});
```
## Device Usage Statistics Development # Device Usage Statistics Development
## When to Use ## When to Use
...@@ -21,6 +21,7 @@ import stats from '@ohos.bundleState'; ...@@ -21,6 +21,7 @@ import stats from '@ohos.bundleState';
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleStateInfo&gt;&gt;): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).| | function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleStateInfo&gt;&gt;): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).|
| function queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of the current invoker application.| | function queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of the current invoker application.|
| function isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the application specified by **bundleName** is in the idle state. | | function isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the application specified by **bundleName** is in the idle state. |
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **maxNum**.|
## How to Develop ## How to Develop
...@@ -205,3 +206,57 @@ import stats from '@ohos.bundleState'; ...@@ -205,3 +206,57 @@ import stats from '@ohos.bundleState';
} }
}); });
``` ```
8. Obtain the number of FA usage records specified by **maxNum**. If **maxNum** is not specified, the default value **1000** is used. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
```js
import stats from '@ohos.bundleState'
// Use a promise to return the result.
stats.getRecentlyUsedModules(1000).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
// Use a promise to return the result when maxNum is not specified.
stats.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
// Use an asynchronous callback to return the result.
stats.getRecentlyUsedModules(1000,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
// Use an asynchronous callback to return the result when maxNum is not specified.
stats.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
```
...@@ -7,17 +7,26 @@ With device usage statistics APIs, you can have a better understanding of the ap ...@@ -7,17 +7,26 @@ With device usage statistics APIs, you can have a better understanding of the ap
Currently you can have access to statistics on the application usage, and notification and system usage statistics feature will be available for use in later versions. Currently you can have access to statistics on the application usage, and notification and system usage statistics feature will be available for use in later versions.
- **The application usage statistics is updated**: - **The application usage statistics is updated**:
>1. Every 30 minutes 1. Every 30 minutes
>2. Upon system time change 2. Upon system time change
>3. Upon start of a new day 3. Upon start of a new day
- **The application usage statistics can include the following**: - **The application usage statistics can include the following**:
>1. Events of all applications based on the specified start time and end time 1. Events of all applications based on the specified start time and end time
>2. Application usage duration statistics based on the specified start time and end time
>3. Events of the current application based on the specified start time and end time 2. Application usage duration statistics based on the specified start time and end time
>4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
>5. Priority group of the current invoker application 3. Events of the current application based on the specified start time and end time
>6. Whether a specific application is in the idle state
4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
5. Priority group of the current invoker application
6. Whether a specific application is in the idle state
7. The number of FA usage records specified by **maxNum**, sorted by time (most recent first)
If **maxNum** is not specified, the default value **1000** will be used.
### Required Permissions ### Required Permissions
- The **queryBundleActiveStates**, **queryBundleStateInfos**, and **queryBundleStateInfoByInterval** APIs used for device usage statistics are system APIs. Before calling these APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission. - The **queryBundleActiveStates**, **queryBundleStateInfos**, and **queryBundleStateInfoByInterval** APIs used for device usage statistics are system APIs. Before calling these APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission.
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
- Data provided by the Hall effect sensor implements the smart cover mode of your device. - Data provided by the Hall effect sensor implements the smart cover mode of your device.
- Data provided by the heart rate sensor helps your application track the health of a user. - Data provided by the heart rate sensor helps your application track the heart health of a user.
- Data provided by the pedometer sensor helps your application obtain the number steps a user has walked. - Data provided by the pedometer sensor helps your application obtain the number of steps a user has walked.
- Data provided by the wear detection sensor helps your application detect whether a user is wearing a wearable device. - Data provided by the wear detection sensor helps your application detect whether a user is wearing a wearable device.
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
## How to Develop ## How to Develop
1. To obtain data from a type of sensor, configure the request permissions in the **config.json** file. 1. To obtain data from a type of sensor, configure the requested permissions in the **config.json** file.
``` ```
"reqPermissions":[ "reqPermissions":[
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
``` ```
import sensor from "@ohos.sensor" import sensor from "@ohos.sensor"
sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){ sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){
console.info("Subscription succeeded. data = "+ data);// The call is successful, and the obtained sensor data is printed. console.info("Subscription succeeded. data = "+ data); // The call is successful, and the obtained sensor data is printed.
} }
); );
``` ```
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
``` ```
import sensor from "@ohos.sensor" import sensor from "@ohos.sensor"
sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() { sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() {
console.info("Succeeded in unsubscribing from acceleration sensor data.");// The unsubscription is successful, and the result is printed. console.info("Succeeded in unsubscribing from acceleration sensor data."); // The unsubscription is successful, and the result is printed.
} }
); );
``` ```
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
``` ```
import sensor from "@ohos.sensor" import sensor from "@ohos.sensor"
sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) {
console.info("Data obtained successfully. data=" + data);// The call is successful, and the obtained sensor data is printed. console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed.
} }
); );
``` ```
...@@ -117,9 +117,14 @@ ...@@ -117,9 +117,14 @@
``` ```
try { try {
sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) {
console.info("Data obtained successfully. data=" + data);// The call is successful, and the obtained sensor data is printed. console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed.
}); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
``` ```
## Samples
The following sample is provided to help you better understand how to develop sensors:
- [`Sensor`: sensor (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor)
# Sensor Overview # Sensor Overview
Sensors in OpenHarmony are an abstraction of underlying hardware-based sensors. Your application can access the underlying sensors via the sensors. Using the APIs provided by sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, fitness and health, and games applications. Sensors in OpenHarmony are an abstraction of underlying sensor hardware. Your application can access the underlying sensor hardware via the sensors. Using the APIs provided by sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, motion-controlled games, and fitness and health applications.
A sensor is a device to detect events or changes in an environment and send messages about the events or changes to another device (for example, a CPU). Generally, a sensor is composed of sensitive components and conversion components. Sensors are the cornerstone of the IoT. A unified sensor management framework is required to achieve data sensing at a low latency and low power consumption, thereby keeping up with requirements of "1+8+N" products or business in the Seamless AI Life Strategy. The sensor list is as follows: A sensor is a device to detect events or changes in an environment and send messages about the events or changes to another device (for example, a CPU). Generally, a sensor is composed of sensitive components and conversion components. Sensors are the cornerstone of the IoT. A unified sensor management framework is required to achieve data sensing at a low latency and low power consumption, thereby keeping up with requirements of "1+8+N" products or business in the Seamless AI Life Strategy. The sensor list is as follows:
| Sensor Type | Sensor Name | Description | Usage | | Type | Name | Description | Usage |
| --------------------------------------- | ------------------ | ------------------------------------------------------------ | ---------------------------------------- | | --------------------------------------- | ------------------ | ------------------------------------------------------------ | ---------------------------------------- |
| SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>.| Detecting the motion status | | SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>.| Detecting the motion status |
| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor| Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>.| Measuring the acceleration bias estimation | | SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor| Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>.| Measuring the acceleration bias estimation |
...@@ -56,7 +56,7 @@ The following modules work cooperatively to implement OpenHarmony sensors: Senso ...@@ -56,7 +56,7 @@ The following modules work cooperatively to implement OpenHarmony sensors: Senso
| Sensor | Permission | Sensitivity | Permission Description | | Sensor | Permission | Sensitivity | Permission Description |
| ------------------------- | -------------------------------- | ------------ | ----------------------- | | ------------------------- | -------------------------------- | ------------ | ----------------------- |
| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows your application to subscribe to data of these acceleration-related sensors in the motion category.| | Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows an application to subscribe to data of these acceleration-related sensors in the motion category.|
| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows an application to subscribe to data of the gyroscope-related sensors in the motion category.| | Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows an application to subscribe to data of the gyroscope-related sensors in the motion category.|
| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. | | Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. |
| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. | | Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. |
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## When to Use ## When to Use
You can set different vibration effects as needed, for example, customizing vibration effects with different intensities and durations for buttons on the device, and customizing one-shot or periodic vibration effects with different intensities and durations for alarm clocks and incoming calls. You can set different vibration effects as needed, for example, customizing the vibration intensity, frequency, and duration for button touches, alarm clocks, and incoming calls.
## Available APIs ## Available APIs
...@@ -62,9 +62,9 @@ You can set different vibration effects as needed, for example, customizing vibr ...@@ -62,9 +62,9 @@ You can set different vibration effects as needed, for example, customizing vibr
``` ```
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.vibrate(1000).then((error)=>{ vibrator.vibrate(1000).then((error)=>{
if (error) {// The call fails, and error.code and error.message are printed. if (error){ // The call fails, and error.code and error.message are printed.
Console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); Console.log("Promise return failed.error.code"+error.code+"error.message"+error.message);
}else{// The call is successful, and the device starts to vibrate. }else{ // The call is successful, and the device starts to vibrate.
Console.log("Promise returned to indicate a successful vibration.") Console.log("Promise returned to indicate a successful vibration.")
}; };
}) })
...@@ -75,10 +75,16 @@ You can set different vibration effects as needed, for example, customizing vibr ...@@ -75,10 +75,16 @@ You can set different vibration effects as needed, for example, customizing vibr
``` ```
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{
if (error) {// The call fails, and error.code and error.message are printed. if(error){ // The call fails, and error.code and error.message are printed.
Console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); Console.log("Promise return failed.error.code"+error.code+"error.message"+error.message);
}else{// The call is successful, and the device stops vibration. }else{ // The call is successful, and the device stops vibration.
Console.log("Promise returned to indicate a successful stop."); Console.log("Promise returned to indicate a successful stop.");
}; };
}) })
``` ```
## Samples
The following sample is provided to help you better understand how to develop vibrators:
- [`Vibrator`: vibrator (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Vibrator)
# Vibrator Overview # Vibrator Overview
The vibrator service opens up the latest capabilities of the vibrator hardware to the maximum extent. By expanding the native vibrator service to implement integrated vibration and interaction design, the service delivers an exquisite integrated vibration experience and differentiated experience, and improves user interaction efficiency and usability. The vibrator service is built on the native vibrator service, bolstered by the latest capabilities of the vibrator hardware. By innovatively integrating vibration and interaction, the service takes user interaction efficiency and usability to the next level.
## Working Principles ## Working Principles
...@@ -12,7 +12,7 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra ...@@ -12,7 +12,7 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra
![0752d302-aeb9-481a-bb8f-e5524eb61eeb](figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png) ![0752d302-aeb9-481a-bb8f-e5524eb61eeb](figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png)
- Vibrator API: provides basic vibrator APIs, including the APIs for querying the vibrator list, querying the vibrator by effect, and triggering and stopping vibration. - Vibrator API: provides basic vibrator APIs, including the APIs for obtaining the vibrator list, querying the vibrator by effect, and triggering and stopping vibration.
- Vibrator Framework: manages the framework layer of the vibrator and communicates with the Misc Device Service. - Vibrator Framework: manages the framework layer of the vibrator and communicates with the Misc Device Service.
......
# Internationalization Development (i18n) # Internationalization Development (i18n)
This development guide describes how to use i18n APIs that are not defined in ECMA 402.
## Obtaining System Language and Region Information ## Obtaining System Language and Region Information
......
# Internationalization Development (intl) # Internationalization Development (intl)
This development guide describes how to use i18n APIs that are defined in ECMA 402.
## Setting Locale Information ## Setting Locale Information
......
此差异已折叠。
...@@ -170,10 +170,8 @@ if (this.subscriber != null) { ...@@ -170,10 +170,8 @@ if (this.subscriber != null) {
} }
``` ```
## Development Example ## Samples
The following sample is provided to help you better understand how to use the common event functionality: The following sample is provided to help you better understand how to use the common event functionality:
- [CommonEvent](https://gitee.com/openharmony/app_samples/tree/master/ability/CommonEvent) - [`CommonEvent`: eTS Common Event (API 7)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent)
This sample shows how to use **CommonEvent** APIs in Extended TypeScript (eTS) to create subscribers and subscribe to, publish, and unsubscribe from common events.
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
### System Capabilities and APIs ### System Capabilities and APIs
SysCap is short for System Capability. It refers to each independent feature in the operating system, such as Bluetooth, Wi-Fi, NFC, and camera. Each system capability corresponds to multiple APIs. These APIs are bound together and their availability depends on the support on the target device. They can also be provided together with the IDE for association. SysCap is short for System Capability. It refers to a standalone feature in the operating system, for example, Bluetooth, Wi-Fi, NFC, or camera. Each system capability corresponds to a set of bound APIs, whose availability depends on the support of the target device. Such a set of APIs can be provided in the IDE for association.
![image-20220326064841782](figures/image-20220326064841782.png) ![image-20220326064841782](figures/image-20220326064841782.png)
### Supported Capability Set, Association Capability Set, and Required Capability Set ### Supported Capability Set, Associated Capability Set, and Required Capability Set
The supported capability set, association capability set, and required capability set are collections of system capabilities. The supported capability set, associated capability set, and required capability set are collections of system capabilities.
The supported capability set covers the device capabilities, and the required capability set covers the application capabilities. If the capability set required by application A is a subset of the capability set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed. The supported capability set covers the device capabilities, and the required capability set covers the application capabilities. If the capability set required by application A is a subset of the capability set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed.
The association capability set covers the system capabilities of APIs that can be associated by the IDE during application development. The associated capability set covers the system capabilities of associated APIs that the IDE offers during application development.
![image-20220326064913834](figures/image-20220326064913834.png) ![image-20220326064913834](figures/image-20220326064913834.png)
...@@ -22,7 +22,7 @@ The association capability set covers the system capabilities of APIs that can b ...@@ -22,7 +22,7 @@ The association capability set covers the system capabilities of APIs that can b
### Devices and Supported Capability Sets ### Devices and Supported Capability Sets
Each device provides a capability set according to its hardware capability. Each device provides a capability set that matches its hardware capability.
The SDK classifies devices into general devices and custom devices. The general devices' supported capability set is defined by OpenHarmony, and the custom devices' is defined by device vendors. The SDK classifies devices into general devices and custom devices. The general devices' supported capability set is defined by OpenHarmony, and the custom devices' is defined by device vendors.
![image-20220326064955505](figures/image-20220326064955505.png) ![image-20220326064955505](figures/image-20220326064955505.png)
...@@ -31,7 +31,7 @@ The SDK classifies devices into general devices and custom devices. The general ...@@ -31,7 +31,7 @@ The SDK classifies devices into general devices and custom devices. The general
### Mapping Between Devices and SDK Capabilities ### Mapping Between Devices and SDK Capabilities
The SDK provides full APIs for the IDE. The IDE identifies the supported capability set based on the devices supported by the project, filters the APIs contained in the capability set, and provides the supported APIs for association (to autocomplete input). The SDK provides a full set of APIs for the IDE. The IDE identifies the supported capability set based on the devices supported by the project, filters the APIs contained in the capability set, and provides the supported APIs for association (to autocomplete input).
![image-20220326065043006](figures/image-20220326065043006.png) ![image-20220326065043006](figures/image-20220326065043006.png)
...@@ -41,7 +41,7 @@ The SDK provides full APIs for the IDE. The IDE identifies the supported capabil ...@@ -41,7 +41,7 @@ The SDK provides full APIs for the IDE. The IDE identifies the supported capabil
### Importing the PCID ### Importing the PCID
DevEco Studio allows PCID imports for projects. After the imported PCID file is decoded, the output SysCap is written into the **syscap.json** file. DevEco Studio allows Product Compatibility ID (PCID) imports for projects. After the imported PCID file is decoded, the SysCap is output and written into the **syscap.json** file.
Right-click the project directory and choose **Import Product Compatibility ID** from the shortcut menu to upload the PCID file and import it to the **syscap.json** file. Right-click the project directory and choose **Import Product Compatibility ID** from the shortcut menu to upload the PCID file and import it to the **syscap.json** file.
...@@ -49,21 +49,22 @@ Right-click the project directory and choose **Import Product Compatibility ID** ...@@ -49,21 +49,22 @@ Right-click the project directory and choose **Import Product Compatibility ID**
### Configuring the Association Capability Set and Required Capability Set ### Configuring the Associated Capability Set and Required Capability Set
The IDE automatically configures the association capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary. The IDE automatically configures the associated capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary.
For the association capability set, you can use more APIs in the IDE by adding more system capabilities. Note that these APIs may not be supported on the device. Therefore, you need to check whether these APIs are supported before using them. You can add APIs to the associated capability set in the IDE by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
Exercise caution when modifying the required capability set. Incorrect modifications may cause the application to unable to be distributed to the target device. Exercise caution when modifying the required capability set. Incorrect modifications may cause the application to unable to be distributed to the target device.
``` ```
/* syscap.json */ /* syscap.json */
{ {
devices: { devices: {
general: [ /* Each general device corresponds to a SysCap capability set. Multiple general devices can be configured.*/ general: [ /* General devices. Each general device supports a SysCap set. Multiple general devices can be configured. */
"default",
"car, "car,
... ...
], ],
custom: [ /* Vendor-defined device*/ custom: [ /* Custom devices. */
{ {
"Custom device": [ "Custom device": [
"SystemCapability.Communication.SoftBus.Core", "SystemCapability.Communication.SoftBus.Core",
...@@ -73,13 +74,13 @@ Exercise caution when modifying the required capability set. Incorrect modificat ...@@ -73,13 +74,13 @@ Exercise caution when modifying the required capability set. Incorrect modificat
... ...
] ]
}, },
development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the association capability set.*/ development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated capability set. */
addedSysCaps: [ addedSysCaps: [
"SystemCapability.Location.Location.Lite", "SystemCapability.Location.Location.Lite",
... ...
] ]
}, },
production: { /* Used to generate the RPCID. Exercise caution when adding this parameter. Under incorrect settings, applications may fail to be distributed to target devices.*/ production: { /* Used to generate the RPCID. Exercise caution when adding this parameter. Under incorrect settings, applications may fail to be distributed to target devices. */
addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required capability set with addedSysCaps set and removedSysCaps set. addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required capability set with addedSysCaps set and removedSysCaps set.
removedSysCaps: [] // When the required capability set is a capability subset of a device, the application can be distributed to the device. removedSysCaps: [] // When the required capability set is a capability subset of a device, the application can be distributed to the device.
} }
...@@ -98,7 +99,7 @@ By default, the association capability set and required system capability set of ...@@ -98,7 +99,7 @@ By default, the association capability set and required system capability set of
### Cross-Device Application Development ### Cross-Device Application Development
By default, the association capability set of the application is the union of multiple devices' supported capability sets. The capability sets must be the intersection. By default, the associated capability set of the application is the union of multiple devices' supported capability sets. The capability sets must be the intersection.
![image-20220326065201867](figures/image-20220326065201867.png) ![image-20220326065201867](figures/image-20220326065201867.png)
...@@ -106,17 +107,17 @@ By default, the association capability set of the application is the union of mu ...@@ -106,17 +107,17 @@ By default, the association capability set of the application is the union of mu
### Checking Whether an API Is Available ### Checking Whether an API Is Available
To check whether a project supports a specific SysCap, you can use **canIUse**. Use **canIUse** if you want to check whether a project supports a specific SysCap.
``` ```
if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) {
console.log("The application supports SystemCapability.ArkUI.ArkUI.Full."); console.log("This application supports SystemCapability.ArkUI.ArkUI.Full.");
} else { } else {
Console.log("The application does not support SystemCapability.ArkUI.ArkUI.Full".); Console.log("This application does not support SystemCapability.ArkUI.ArkUI.Full".);
} }
``` ```
You can import a module. If the current device does not support the module, the import result is **undefined**. When using an API, you need to check whether the API is available. You can import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available.
``` ```
import geolocation from '@ohos.geolocation'; import geolocation from '@ohos.geolocation';
...@@ -126,7 +127,7 @@ if (geolocation) { ...@@ -126,7 +127,7 @@ if (geolocation) {
console.log(location.latitude, location.longitude); console.log(location.latitude, location.longitude);
}); });
} else { } else {
Console.log('The device does not support location information.'); Console.log('This device does not support location information.');
} }
``` ```
...@@ -143,7 +144,7 @@ const authenticator = userAuth.getAuthenticator(); ...@@ -143,7 +144,7 @@ const authenticator = userAuth.getAuthenticator();
const result = authenticator.checkAbility('FACE_ONLY', 'S1'); const result = authenticator.checkAbility('FACE_ONLY', 'S1');
if (result == authenticator.CheckAvailabilityResult.AUTH_NOT_SUPPORT) { if (result == authenticator.CheckAvailabilityResult.AUTH_NOT_SUPPORT) {
Console.log('The device does not support facial recognition.'); Console.log('This device does not support facial recognition.');
} }
// If an unsupported API is forcibly called, an error message is returned, but no syntax error occurs. // If an unsupported API is forcibly called, an error message is returned, but no syntax error occurs.
authenticator.execute('FACE_ONLY', 'S1', (err, result) => { authenticator.execute('FACE_ONLY', 'S1', (err, result) => {
...@@ -155,24 +156,24 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => { ...@@ -155,24 +156,24 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => {
``` ```
### How Are the SysCap Differences Between Devices Generated ### How Do SysCap Differences Arise Between Devices
The SysCap of devices varies according to the component combination assembled by the product solution vendor. The following figure shows the overall process. The SysCap of devices varies according to the component combination defined by the product solution vendor. The following figure shows the overall process.
![image-20220326072448840](figures/image-20220326072448840.png) ![image-20220326072448840](figures/image-20220326072448840.png)
1. A set of OpenHarmony source code consists of optional and mandatory components. Different components have different system capabilities. In other words, different components represent different SysCaps. 1. A set of OpenHarmony source code consists of optional and mandatory components. Different components have different system capabilities. In other words, different components represent different SysCaps.
2. In a normalized released SDK, the mapping exists between APIs and SysCap. 2. In a normalized released SDK, APIs are mapped to SysCap sets.
3. Product solution vendors can assemble components based on hardware capabilities and product requirements. 3. Product solution vendors can assemble components based on hardware capabilities and product requirements.
4. The components configured for a product can be OpenHarmony components or private components developed by a third party. Because there is mapping between components and SysCap, the SysCap set of the product can be obtained after all components are assembled. 4. The components configured for a product can be OpenHarmony components or proprietary components developed by a third party. Since there is mapping between components and SysCap, the SysCap set of the product can be obtained after all components are assembled.
5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed on the SysCap differences of devices. 5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications in the system to check whether a SysCap set is available. 6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a SysCap set is available.
7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application is successfully installed. 7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application can be installed.
8. When an application is running, the **canIUse** API can be used to query the SysCap of a device to ensure compatibility on different devices. 8. When an application is running, the **canIUse** API can be used to query whether the SysCap is compatible with the device.
# Context Module # Context Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js ```js
...@@ -15,7 +18,7 @@ var context = featureAbility.getContext(); ...@@ -15,7 +18,7 @@ var context = featureAbility.getContext();
context.getOrCreateLocalDir() context.getOrCreateLocalDir()
``` ```
## Context.getOrCreateLocalDir ## Context.getOrCreateLocalDir<sup>7+</sup>
getOrCreateLocalDir(callback: AsyncCallback\<string>): void getOrCreateLocalDir(callback: AsyncCallback\<string>): void
...@@ -43,7 +46,7 @@ context.getOrCreateLocalDir((err, data)=>{ ...@@ -43,7 +46,7 @@ context.getOrCreateLocalDir((err, data)=>{
## Context.getOrCreateLocalDir ## Context.getOrCreateLocalDir<sup>7+</sup>
getOrCreateLocalDir(): Promise\<string> getOrCreateLocalDir(): Promise\<string>
...@@ -71,7 +74,7 @@ context.getOrCreateLocalDir().then((data) => { ...@@ -71,7 +74,7 @@ context.getOrCreateLocalDir().then((data) => {
## Context.verifyPermission ## Context.verifyPermission<sup>7+</sup>
verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void
...@@ -100,7 +103,7 @@ bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{ ...@@ -100,7 +103,7 @@ bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{
## Context.verifyPermission ## Context.verifyPermission<sup>7+</sup>
verifyPermission(permission: string, callback: AsyncCallback\<number>): void verifyPermission(permission: string, callback: AsyncCallback\<number>): void
...@@ -123,7 +126,7 @@ var context = featureAbility.getContext(); ...@@ -123,7 +126,7 @@ var context = featureAbility.getContext();
context.verifyPermission("com.example.permission") context.verifyPermission("com.example.permission")
``` ```
## Context.verifyPermission ## Context.verifyPermission<sup>7+</sup>
verifyPermission(permission: string, options?: PermissionOptions): Promise\<number> verifyPermission(permission: string, options?: PermissionOptions): Promise\<number>
...@@ -158,7 +161,7 @@ context.verifyPermission('com.context.permission',Permission).then((data) => { ...@@ -158,7 +161,7 @@ context.verifyPermission('com.context.permission',Permission).then((data) => {
## Context.requestPermissionsFromUser ## Context.requestPermissionsFromUser<sup>7+</sup>
requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>): void requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>): void
...@@ -194,7 +197,7 @@ context.requestPermissionsFromUser( ...@@ -194,7 +197,7 @@ context.requestPermissionsFromUser(
## Context.getApplicationInfo ## Context.getApplicationInfo<sup>7+</sup>
getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void
...@@ -218,7 +221,7 @@ context.getApplicationInfo() ...@@ -218,7 +221,7 @@ context.getApplicationInfo()
## Context.getApplicationInfo ## Context.getApplicationInfo<sup>7+</sup>
getApplicationInfo(): Promise\<ApplicationInfo> getApplicationInfo(): Promise\<ApplicationInfo>
...@@ -245,7 +248,7 @@ context.getApplicationInfo().then((data) => { ...@@ -245,7 +248,7 @@ context.getApplicationInfo().then((data) => {
## Context.getBundleName ## Context.getBundleName<sup>7+</sup>
getBundleName(callback: AsyncCallback\<string>): void getBundleName(callback: AsyncCallback\<string>): void
...@@ -269,7 +272,7 @@ context.getBundleName() ...@@ -269,7 +272,7 @@ context.getBundleName()
## Context.getBundleName ## Context.getBundleName<sup>7+</sup>
getBundleName(): Promise\<string> getBundleName(): Promise\<string>
...@@ -296,7 +299,7 @@ context.getBundleName().then((data) => { ...@@ -296,7 +299,7 @@ context.getBundleName().then((data) => {
## Context.getProcessInfo ## Context.getProcessInfo<sup>7+</sup>
getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void
...@@ -320,7 +323,7 @@ context.getProcessInfo() ...@@ -320,7 +323,7 @@ context.getProcessInfo()
## Context.getProcessInfo ## Context.getProcessInfo<sup>7+</sup>
getProcessInfo(): Promise\<ProcessInfo> getProcessInfo(): Promise\<ProcessInfo>
...@@ -347,7 +350,7 @@ context.getProcessInfo().then((data) => { ...@@ -347,7 +350,7 @@ context.getProcessInfo().then((data) => {
## Context.getElementName ## Context.getElementName<sup>7+</sup>
getElementName(callback: AsyncCallback\<ElementName>): void getElementName(callback: AsyncCallback\<ElementName>): void
...@@ -373,7 +376,7 @@ context.getElementName() ...@@ -373,7 +376,7 @@ context.getElementName()
## Context.getElementName ## Context.getElementName<sup>7+</sup>
getElementName(): Promise\<ElementName> getElementName(): Promise\<ElementName>
...@@ -400,7 +403,7 @@ context.getElementName().then((data) => { ...@@ -400,7 +403,7 @@ context.getElementName().then((data) => {
}); });
``` ```
## Context.getProcessName ## Context.getProcessName<sup>7+</sup>
getProcessName(callback: AsyncCallback\<string>): void getProcessName(callback: AsyncCallback\<string>): void
...@@ -424,7 +427,7 @@ context.getProcessName() ...@@ -424,7 +427,7 @@ context.getProcessName()
## Context.getProcessName ## Context.getProcessName<sup>7+</sup>
getProcessName(): Promise\<string> getProcessName(): Promise\<string>
...@@ -451,7 +454,7 @@ context.getProcessName().then((data) => { ...@@ -451,7 +454,7 @@ context.getProcessName().then((data) => {
## Context.getCallingBundle ## Context.getCallingBundle<sup>7+</sup>
getCallingBundle(callback: AsyncCallback\<string>): void getCallingBundle(callback: AsyncCallback\<string>): void
...@@ -475,7 +478,7 @@ context.getCallingBundle() ...@@ -475,7 +478,7 @@ context.getCallingBundle()
## Context.getCallingBundle ## Context.getCallingBundle<sup>7+</sup>
getCallingBundle(): Promise\<string> getCallingBundle(): Promise\<string>
...@@ -606,7 +609,7 @@ context.getFilesDir().then((data) => { ...@@ -606,7 +609,7 @@ context.getFilesDir().then((data) => {
}); });
``` ```
## Context.getOrCreateDistributedDir ## Context.getOrCreateDistributedDir<sup>7+</sup>
getOrCreateDistributedDir(callback: AsyncCallback\<string>): void getOrCreateDistributedDir(callback: AsyncCallback\<string>): void
...@@ -636,7 +639,7 @@ context.getOrCreateDistributedDir((err, data) => { ...@@ -636,7 +639,7 @@ context.getOrCreateDistributedDir((err, data) => {
}); });
``` ```
## Context.getOrCreateDistributedDir ## Context.getOrCreateDistributedDir<sup>7+</sup>
getOrCreateDistributedDir(): Promise\<string> getOrCreateDistributedDir(): Promise\<string>
...@@ -662,7 +665,7 @@ context.getOrCreateDistributedDir().then((data) => { ...@@ -662,7 +665,7 @@ context.getOrCreateDistributedDir().then((data) => {
}); });
``` ```
## Context.getAppType ## Context.getAppType<sup>7+</sup>
getAppType(callback: AsyncCallback\<string>): void getAppType(callback: AsyncCallback\<string>): void
...@@ -690,7 +693,7 @@ context.getAppType((err, data) => { ...@@ -690,7 +693,7 @@ context.getAppType((err, data) => {
}); });
``` ```
## Context.getAppType ## Context.getAppType<sup>7+</sup>
getAppType(): Promise\<string> getAppType(): Promise\<string>
...@@ -714,7 +717,7 @@ context.getAppType().then((data) => { ...@@ -714,7 +717,7 @@ context.getAppType().then((data) => {
}); });
``` ```
## Context.getHapModuleInfo ## Context.getHapModuleInfo<sup>7+</sup>
getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void
...@@ -742,7 +745,7 @@ context.getHapModuleInfo((err, data) => { ...@@ -742,7 +745,7 @@ context.getHapModuleInfo((err, data) => {
}); });
``` ```
## Context.getHapModuleInfo ## Context.getHapModuleInfo<sup>7+</sup>
getHapModuleInfo(): Promise\<HapModuleInfo> getHapModuleInfo(): Promise\<HapModuleInfo>
...@@ -766,7 +769,7 @@ context.getHapModuleInfo().then((data) => { ...@@ -766,7 +769,7 @@ context.getHapModuleInfo().then((data) => {
}); });
``` ```
## Context.getAppVersionInfo ## Context.getAppVersionInfo<sup>7+</sup>
getAppVersionInfo(callback: AsyncCallback\<HapModuleInfo>): void getAppVersionInfo(callback: AsyncCallback\<HapModuleInfo>): void
...@@ -794,7 +797,7 @@ context.getAppVersionInfo((err, data) => { ...@@ -794,7 +797,7 @@ context.getAppVersionInfo((err, data) => {
}); });
``` ```
## Context.getAppVersionInfo ## Context.getAppVersionInfo<sup>7+</sup>
getAppVersionInfo(): Promise\<AppVersionInfo> getAppVersionInfo(): Promise\<AppVersionInfo>
...@@ -818,7 +821,7 @@ context.getAppVersionInfo().then((data) => { ...@@ -818,7 +821,7 @@ context.getAppVersionInfo().then((data) => {
}); });
``` ```
## Context.getAbilityInfo ## Context.getAbilityInfo<sup>7+</sup>
getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void
...@@ -846,7 +849,7 @@ context.getAbilityInfo((err, data) => { ...@@ -846,7 +849,7 @@ context.getAbilityInfo((err, data) => {
}); });
``` ```
## Context.getAbilityInfo ## Context.getAbilityInfo<sup>7+</sup>
getAbilityInfo(): Promise\<AbilityInfo> getAbilityInfo(): Promise\<AbilityInfo>
...@@ -870,7 +873,7 @@ context.getAbilityInfo().then((data) => { ...@@ -870,7 +873,7 @@ context.getAbilityInfo().then((data) => {
}); });
``` ```
## Context.getApplicationContext ## Context.getApplicationContext<sup>7+</sup>
getApplicationContext(): Context getApplicationContext(): Context
...@@ -891,7 +894,7 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -891,7 +894,7 @@ import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext().getApplicationContext(); var context = featureAbility.getContext().getApplicationContext();
``` ```
## PermissionOptions ## PermissionOptions<sup>7+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -900,7 +903,7 @@ var context = featureAbility.getContext().getApplicationContext(); ...@@ -900,7 +903,7 @@ var context = featureAbility.getContext().getApplicationContext();
| pid | Read-only | number | No | Process ID.| | pid | Read-only | number | No | Process ID.|
| uid | Read-only | number | No | User ID.| | uid | Read-only | number | No | User ID.|
## PermissionRequestResult ## PermissionRequestResult<sup>7+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -910,7 +913,7 @@ var context = featureAbility.getContext().getApplicationContext(); ...@@ -910,7 +913,7 @@ var context = featureAbility.getContext().getApplicationContext();
| permissions | Read-only | Array\<string> | Yes | Permissions requested. | | permissions | Read-only | Array\<string> | Yes | Permissions requested. |
| authResults | Read-only | Array\<number> | Yes | Permission request result. | | authResults | Read-only | Array\<number> | Yes | Permission request result. |
## HapModuleInfo ## HapModuleInfo<sup>7+</sup>
Describes the HAP module information. Describes the HAP module information.
...@@ -933,7 +936,7 @@ Describes the HAP module information. ...@@ -933,7 +936,7 @@ Describes the HAP module information.
| installationFree | boolean | Yes | No | When installation-free is supported. | | installationFree | boolean | Yes | No | When installation-free is supported. |
| mainElementName | string | Yes| No| Information about the entry ability.| | mainElementName | string | Yes| No| Information about the entry ability.|
## AppVersionInfo ## AppVersionInfo<sup>7+</sup>
| Name | Type| Readable | Writable | Description| | Name | Type| Readable | Writable | Description|
| ------ | ------ | ------| ------ | ------ | | ------ | ------ | ------| ------ | ------ |
......
# AbilityContext # AbilityContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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.
...@@ -46,7 +46,7 @@ Starts an ability. This API uses a callback to return the result. ...@@ -46,7 +46,7 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -75,7 +75,7 @@ Starts an ability. This API uses a callback to return the result. ...@@ -75,7 +75,7 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.| | options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
...@@ -108,7 +108,7 @@ Starts an ability. This API uses a promise to return the result. ...@@ -108,7 +108,7 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.| | options | StartOptions | No| Parameters used for starting the ability.|
**Return value** **Return value**
...@@ -149,7 +149,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -149,7 +149,7 @@ Starts an ability. This API uses a callback to return the execution result when
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
...@@ -177,7 +177,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -177,7 +177,7 @@ Starts an ability. This API uses a callback to return the execution result when
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.| | options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
...@@ -210,7 +210,7 @@ Starts an ability. This API uses a promise to return the execution result when t ...@@ -210,7 +210,7 @@ Starts an ability. This API uses a promise to return the execution result when t
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.| | options | StartOptions | No| Parameters used for starting the ability.|
...@@ -357,7 +357,7 @@ Obtains the caller interface of the specified ability, and if the specified abil ...@@ -357,7 +357,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value** **Return value**
......
# Want # Want
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
**Want** is the basic communication component of the system. **Want** is the basic communication component of the system.
...@@ -21,7 +21,7 @@ import Want from '@ohos.application.Want'; ...@@ -21,7 +21,7 @@ import Want from '@ohos.application.Want';
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read only | string | No | ID of the device running the ability. | | deviceId | Read only | string | No | ID of the device running the ability. |
| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName | Read only | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | abilityName | Read only | string | No | Name of the ability. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability.|
| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).| | flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
......
# Ability # Ability
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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.
...@@ -21,8 +21,8 @@ import Ability from '@ohos.application.Ability'; ...@@ -21,8 +21,8 @@ import Ability from '@ohos.application.Ability';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| | context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.| | launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.| | lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
## Ability.onCreate ## Ability.onCreate
...@@ -37,7 +37,7 @@ Called to initialize the service logic when an ability is created. ...@@ -37,7 +37,7 @@ Called to initialize the service logic when an ability is created.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this ability, including the ability name and bundle name.| | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example** **Example**
...@@ -222,7 +222,7 @@ Called when the ability startup mode is set to singleton. ...@@ -222,7 +222,7 @@ Called when the ability startup mode is set to singleton.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Want parameters, such as the ability name and bundle name.| | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
**Example** **Example**
......
# AbilityStage # AbilityStage
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -47,7 +47,7 @@ Called when a specified ability is started. ...@@ -47,7 +47,7 @@ Called when a specified ability is started.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value** **Return value**
......
# Linear Container ArrayList # Linear Container ArrayList
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```ts
import ArrayList from '@ohos.util.ArrayList' import ArrayList from '@ohos.util.ArrayList'
``` ```
...@@ -30,7 +30,7 @@ A constructor used to create an **ArrayList** instance. ...@@ -30,7 +30,7 @@ A constructor used to create an **ArrayList** instance.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
``` ```
...@@ -55,7 +55,7 @@ Adds an entry at the end of this container. ...@@ -55,7 +55,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
let result = arrayList.add("a"); let result = arrayList.add("a");
let result1 = arrayList.add(1); let result1 = arrayList.add(1);
...@@ -80,7 +80,7 @@ Inserts an entry at the specified position in this container. ...@@ -80,7 +80,7 @@ Inserts an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.insert("A", 0); arrayList.insert("A", 0);
arrayList.insert(0, 1); arrayList.insert(0, 1);
...@@ -107,7 +107,7 @@ Checks whether this container has the specified entry. ...@@ -107,7 +107,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -134,7 +134,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -134,7 +134,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -166,7 +166,7 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -166,7 +166,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -198,7 +198,7 @@ Removes an entry with the specified position from this container. ...@@ -198,7 +198,7 @@ Removes an entry with the specified position from this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -228,7 +228,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -228,7 +228,7 @@ Removes the first occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -252,7 +252,7 @@ Removes from this container all of the entries within a range, including the ent ...@@ -252,7 +252,7 @@ Removes from this container all of the entries within a range, including the ent
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -287,7 +287,7 @@ callbackfn ...@@ -287,7 +287,7 @@ callbackfn
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -325,7 +325,7 @@ callbackfn ...@@ -325,7 +325,7 @@ callbackfn
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -357,7 +357,7 @@ comparator ...@@ -357,7 +357,7 @@ comparator
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -389,7 +389,7 @@ Obtains entries within a range in this container, including the entry at the sta ...@@ -389,7 +389,7 @@ Obtains entries within a range in this container, including the entry at the sta
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -408,7 +408,7 @@ Clears this container and sets its length to **0**. ...@@ -408,7 +408,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -432,7 +432,7 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -432,7 +432,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -455,7 +455,7 @@ Obtains the capacity of this container. ...@@ -455,7 +455,7 @@ Obtains the capacity of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -478,7 +478,7 @@ Converts this container into an array. ...@@ -478,7 +478,7 @@ Converts this container into an array.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -501,7 +501,7 @@ Checks whether this container is empty (contains no entry). ...@@ -501,7 +501,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -524,7 +524,7 @@ Increases the capacity of this container. ...@@ -524,7 +524,7 @@ Increases the capacity of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -542,7 +542,7 @@ Trims the capacity of this container to its current length. ...@@ -542,7 +542,7 @@ Trims the capacity of this container to its current length.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -565,7 +565,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -565,7 +565,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
......
# ConfigurationConstant # ConfigurationConstant
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
...@@ -34,7 +34,7 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ...@@ -34,7 +34,7 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
| COLOR_MODE_LIGHT | 1 | Light mode.| | COLOR_MODE_LIGHT | 1 | Light mode.|
## ConfigurationConstant.Direction ## ConfigurationConstant.Direction<sup>9+</sup>
The value is obtained through the **ConfigurationConstant.Direction** API. The value is obtained through the **ConfigurationConstant.Direction** API.
...@@ -48,12 +48,12 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL ...@@ -48,12 +48,12 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DIRECTION_NOT_SET<sup>9+</sup> | -1 | Unspecified direction.| | DIRECTION_NOT_SET | -1 | Unspecified direction.|
| DIRECTION_VERTICAL<sup>9+</sup> | 0 | Vertical direction.| | DIRECTION_VERTICAL | 0 | Vertical direction.|
| DIRECTION_HORIZONTAL<sup>9+</sup> | 1 | Horizontal direction.| | DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
## ConfigurationConstant.ScreenDensity ## ConfigurationConstant.ScreenDensity<sup>9+</sup>
The value is obtained through the **ConfigurationConstant.ScreenDensity** API. The value is obtained through the **ConfigurationConstant.ScreenDensity** API.
...@@ -67,10 +67,10 @@ ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET ...@@ -67,10 +67,10 @@ ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET<sup>9+</sup> | 0 | Unspecified screen resolution.| | SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI<sup>9+</sup> | 120 | The screen resolution is sdpi.| | SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI<sup>9+</sup> | 160 | The screen resolution is mdpi.| | SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI<sup>9+</sup> | 240 | The screen resolution is ldpi.| | SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI<sup>9+</sup> | 320 | The screen resolution is xldpi.| | SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI<sup>9+</sup> | 480 | The screen resolution is xxldpi.| | SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI<sup>9+</sup> | 640 | The screen resolution is xxxldpi.| | SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
# Linear Container Deque # Linear Container Deque
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```ts
import Deque from '@ohos.util.Deque' import Deque from '@ohos.util.Deque'
``` ```
...@@ -30,7 +30,7 @@ A constructor used to create a **Deque** instance. ...@@ -30,7 +30,7 @@ A constructor used to create a **Deque** instance.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
``` ```
...@@ -48,7 +48,7 @@ Inserts an entry at the front of this container. ...@@ -48,7 +48,7 @@ Inserts an entry at the front of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront("a"); deque.insertFront("a");
deque.insertFront(1); deque.insertFront(1);
...@@ -72,7 +72,7 @@ Inserts an entry at the end of this container. ...@@ -72,7 +72,7 @@ Inserts an entry at the end of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertEnd("a"); deque.insertEnd("a");
deque.insertEnd(1); deque.insertEnd(1);
...@@ -102,7 +102,7 @@ Checks whether this container has the specified entry. ...@@ -102,7 +102,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); let result = deque.has("Ahfbrgrbgnutfodgorrogorg");
deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); deque.insertFront("Ahfbrgrbgnutfodgorrogorg");
...@@ -123,7 +123,7 @@ Removes the first entry of this container. ...@@ -123,7 +123,7 @@ Removes the first entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
...@@ -147,7 +147,7 @@ Removes the last entry of this container. ...@@ -147,7 +147,7 @@ Removes the last entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertEnd(4); deque.insertEnd(4);
...@@ -181,7 +181,7 @@ callbackfn ...@@ -181,7 +181,7 @@ callbackfn
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertEnd(4); deque.insertEnd(4);
...@@ -206,7 +206,7 @@ Obtains the first entry of this container. ...@@ -206,7 +206,7 @@ Obtains the first entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertEnd(2); deque.insertEnd(2);
deque.insertEnd(4); deque.insertEnd(4);
...@@ -229,7 +229,7 @@ Obtains the last entry of this container. ...@@ -229,7 +229,7 @@ Obtains the last entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
...@@ -252,7 +252,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -252,7 +252,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator&lt;T&gt; | Iterator obtained.| | IterableIterator&lt;T&gt; | Iterator obtained.|
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## Modules to Import ## Modules to Import
``` ```ts
import deviceInfo from '@ohos.deviceInfo' import deviceInfo from '@ohos.deviceInfo'
``` ```
......
# Device Usage Statistics # Device Usage Statistics
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -20,10 +21,10 @@ Checks whether the application specified by **bundleName** is in the idle state. ...@@ -20,10 +21,10 @@ Checks whether the application specified by **bundleName** is in the idle state.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
**Example** **Example**
...@@ -47,19 +48,19 @@ Checks whether the application specified by **bundleName** is in the idle state. ...@@ -47,19 +48,19 @@ Checks whether the application specified by **bundleName** is in the idle state.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.| | Promise&lt;boolean&gt; | Promise used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
**Example** **Example**
``` ```js
bundleState.isIdleState("com.ohos.camera").then( res => { bundleState.isIdleState("com.ohos.camera").then( res => {
console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
...@@ -77,13 +78,13 @@ Queries the priority group of the current invoker application. This API uses an ...@@ -77,13 +78,13 @@ Queries the priority group of the current invoker application. This API uses an
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryAppUsagePriorityGroup((err, res) => { bundleState.queryAppUsagePriorityGroup((err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
...@@ -103,13 +104,13 @@ Queries the priority group of the current invoker application. This API uses a p ...@@ -103,13 +104,13 @@ Queries the priority group of the current invoker application. This API uses a p
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result.| | Promise&lt;number&gt; | Promise used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryAppUsagePriorityGroup().then( res => { bundleState.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
...@@ -129,15 +130,15 @@ Queries the application usage duration statistics based on the specified start t ...@@ -129,15 +130,15 @@ Queries the application usage duration statistics based on the specified start t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
| callback | AsyncCallback&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Yes| Callback used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleStateInfos(0, 20000000000000, (err, res) => { bundleState.queryBundleStateInfos(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
...@@ -165,20 +166,20 @@ Queries the application usage duration statistics based on the specified start t ...@@ -165,20 +166,20 @@ Queries the application usage duration statistics based on the specified start t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Promise used to return the result.| | Promise&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Promise used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleStateInfos(0, 20000000000000).then( res => { bundleState.queryBundleStateInfos(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1; let i = 1;
...@@ -204,16 +205,16 @@ Queries the application usage duration statistics in the specified time frame at ...@@ -204,16 +205,16 @@ Queries the application usage duration statistics in the specified time frame at
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.| | byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
| callback | AsyncCallback&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Yes| Callback used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
...@@ -239,21 +240,21 @@ Queries the application usage duration statistics in the specified time frame at ...@@ -239,21 +240,21 @@ Queries the application usage duration statistics in the specified time frame at
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.| | byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -277,15 +278,15 @@ Queries events of all applications based on the specified start time and end tim ...@@ -277,15 +278,15 @@ Queries events of all applications based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleActiveStates(0, 20000000000000, (err, res) => { bundleState.queryBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
...@@ -311,20 +312,20 @@ Queries events of all applications based on the specified start time and end tim ...@@ -311,20 +312,20 @@ Queries events of all applications based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryBundleActiveStates(0, 20000000000000).then( res => { bundleState.queryBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -346,15 +347,15 @@ Queries events of this application based on the specified start time and end tim ...@@ -346,15 +347,15 @@ Queries events of this application based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { bundleState.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
...@@ -378,20 +379,20 @@ Queries events of this application based on the specified start time and end tim ...@@ -378,20 +379,20 @@ Queries events of this application based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| begin | number | Yes| Start time.| | begin | number | Yes| Start time.|
| end | number | Yes| End time.| | end | number | Yes| End time.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
``` ```js
bundleState.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { bundleState.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -403,6 +404,133 @@ Queries events of this application based on the specified start time and end tim ...@@ -403,6 +404,133 @@ Queries events of this application based on the specified start time and end tim
}); });
``` ```
## bundleState.getRecentlyUsedModules<sup>9+</sup>
getRecentlyUsedModules(maxNum: number): Promise&lt;Array&lt;BundleActiveModuleInfo&gt;&gt;
Obtains the number of FA usage records specified by **maxNum**. This API uses a promise to return the records sorted by time (most recent first).
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result.|
**Example**
```js
bundleState.getRecentlyUsedModules(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
// Invocation when maxNum is not passed
bundleState.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
```
## bundleState.getRecentlyUsedModules<sup>9+</sup>
getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;Array&lt;BundleActiveModuleInfo&gt;&gt;): void
Obtains the number of FA usage records specified by **maxNum**. This API uses an asynchronous callback to return the records sorted by time (most recent first).
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes| Callback used to return the result.|
**Example**
```js
bundleState.getRecentlyUsedModules(this.maxNum,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
// Invocation when maxNum is not passed
stats.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
```
## BundleActiveModuleInfo<sup>9+</sup>
Provides the information about the FA usage.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | No| ID of the device to which the FA belongs.|
| bundleName | string | Yes| Name of the application bundle to which the FA belongs.|
| moduleName | string | Yes| Name of the module to which the FA belongs.|
| abilityName | string | No| **MainAbility** name of the FA.|
| appLabelId | number | No| Application label ID of the FA.|
| labelId | number | No| Label ID of the module to which the FA belongs.|
| descriptionId | number | No| Description ID of the application to which the FA belongs.|
| abilityLableId | number | No| **MainAbility** label ID of the FA.|
| abilityDescriptionId | number | No| **MainAbility** description ID of the FA.|
| abilityIconId | number | No| **MainAbility** icon ID of the FA.|
| launchedCount | number | Yes| Number of FA startup times.|
| lastModuleUsedTime | number | Yes| Last time when the FA is used.|
| formRecords | Array&lt;[BundleActiveFormInfo](#bundleactiveforminfo9)&gt; | Yes| Array of widget usage records in the FA.|
## BundleActiveFormInfo<sup>9+</sup>
Provides the FA widget usage information.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| formName | number | Yes| Widget name.|
| formDimension | number | Yes| Widget dimensions.|
| formId | number | Yes| Widget ID.|
| formLastUsedTime | number | Yes| Last time when the widget was clicked.|
| count | number | Yes| Number of clicks on the widget.|
## BundleStateInfo ## BundleStateInfo
Provides the usage duration information of an application. Provides the usage duration information of an application.
...@@ -435,9 +563,9 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -435,9 +563,9 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Application usage information to merge.| | toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Application usage information to merge.|
## BundleActiveState ## BundleActiveState
......
# ExtensionContext # ExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the extension context. This module is inherited from **Context**. Implements the extension context. This module is inherited from **Context**.
...@@ -14,3 +14,4 @@ Implements the extension context. This module is inherited from **Context**. ...@@ -14,3 +14,4 @@ Implements the extension context. This module is inherited from **Context**.
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. | | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
| config | Configuration | Yes| No| Module configuration information.|
# ExtensionRunningInfo # ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides extension running information. Provides extension running information.
......
# Public File Access and Management # User File Access and Management
>![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** >![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> >
>- 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.
>- The APIs of this module are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**. >- The APIs of this module are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**.
## Modules to Import ## Modules to Import
```js ```js
...@@ -13,40 +14,40 @@ import filemanager from '@ohos.fileManager'; ...@@ -13,40 +14,40 @@ import filemanager from '@ohos.fileManager';
getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt; getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt;
Obtains information about the files in the first-level directory in asynchronous mode. This method uses a promise to return the result. Obtains information about the root album or directory in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value - Return value
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| Promise&lt;[FileInfo](#fileinfo)[]&gt; | Promise used to return the file information obtained.| | Promise&lt;[FileInfo](#fileinfo)[]&gt; | Promise used to return the root album or directory information obtained.|
- Example - Example
```js ```js
filemanager.getRoot().then((fileInfo) => { filemanager.getRoot().then((fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo)) console.log("file:"+JSON.stringify(fileInfo));
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
}); });
``` ```
## filemanager.getRoot ## filemanager.getRoot
getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
Obtains information about the files in the first-level directory in asynchronous mode. This method uses a callback to return the result. Obtains information about the root album or directory in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
...@@ -54,71 +55,72 @@ Obtains information about the files in the first-level directory in asynchronous ...@@ -54,71 +55,72 @@ Obtains information about the files in the first-level directory in asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| dev | [DevInfo](#devinfo) | No | Device name. The default value is **local**, which is the only value supported.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. | | callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the root album or directory information obtained. |
- Example - Example
```js ```js
filemanager.getRoot((err, fileInfo) => { filemanager.getRoot((err, fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo)) console.log("file:"+JSON.stringify(fileInfo));
} }
} }
}) });
``` ```
## filemanager.listFile ## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise&lt;FileInfo[]&gt; listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise&lt;FileInfo[]&gt;
Obtains information about the files in the second-level directory in asynchronous mode. This method uses a promise to return the result. Obtains information about the second-level album or files in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --- | --- | --- | -- | | --- | --- | --- | -- |
| type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | string | Yes| URI of the directory to query.| | path | string | Yes| URI of the directory to query.|
| dev | [DevInfo](#devinfo) | Yes| Device name. The default value is **local**, which is the only value supported.| | type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| offset | number | No| Start position from which the files are to query.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| count | number | No| Number of files to query.|
- Return value - Return value
| Type| Description| | Type| Description|
| --- | -- | | --- | -- |
| Promise&lt;FileInfo[]&gt; | Promise used to return the file information obtained.| | Promise&lt;FileInfo[]&gt; | Promise used to return the album or file information obtained.|
- Error - Error
| Error Info| Error Code|Description| | Error Info| Error Code|Description|
| -- | --- | -- | | -- | --- | -- |
|No such file or directory | 2 | The directory or file of the specified URI does not exist.| | No such file or directory | 2 | The directory or album of the specified URI does not exist.|
|No such process | 3 | Failed to obtain the FMS service.| | No such process | 3 | Failed to obtain the FMS service.|
|Not a directory | 20 | The object specified by the URI is not a directory.| | Not a directory | 20 | The object specified by the URI is not a directory or album.|
```js - Example
// Obtain all files in the directory.
// Call listFile() and getRoot() to obtain file URIs. ```js
let media_path = file.uri // Obtain all files in the directory.
filemanager.listFile(media_path, "file") // Call listFile() and getRoot() to obtain the file URI.
.then((fileInfo) => { let media_path = file.uri
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo)) console.log("file:"+JSON.stringify(fileInfo));
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
}) });
``` ```
## filemanager.listFile ## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
Obtains information about the files in the second-level directory in asynchronous mode. This method uses a callback to return the result. Obtains information about the second-level album or files in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
...@@ -126,37 +128,37 @@ Obtains information about the files in the second-level directory in asynchronou ...@@ -126,37 +128,37 @@ Obtains information about the files in the second-level directory in asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | string | Yes | URI of the directory to query. | | path | string | Yes | URI of the directory to query. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.| | type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| offset | number | No| Start position from which the files are to query.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| count | number | No| Number of files to query.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. | | callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
- Error - Error
| Error Info | Error Code| Description | | Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- | | ------------------------- | ------ | ------------------------- |
|No such file or directory | 2 | The directory or file of the specified URI does not exist.| | No such file or directory | 2 | The directory or album of the specified URI does not exist.|
|No such process | 3 | Failed to obtain the FMS service. | | No such process | 3 | Failed to obtain the FMS service. |
|Not a directory | 20 | The object specified by the URI is not a directory.| | Not a directory | 20 | The object specified by the URI is not a directory or album.|
```js - Example
// Call listFile() and getRoot() to obtain the file URIs.
let media_path = file.uri ```js
filemanager.listFile(media_path, "file", (err, fileInfo) => { // Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri
filemanager.listFile(media_path, "file", (err, fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo)) console.log("file:"+JSON.stringify(fileInfo));
} }
} }
}) });
``` ```
## filemanager.createFile ## filemanager.createFile
filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : promise&lt;string&gt; filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
Creates a file in the specified path in asynchronous mode. This method uses a promise to return the result. Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
...@@ -165,7 +167,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr ...@@ -165,7 +167,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
| --- | --- | --- | -- | | --- | --- | --- | -- |
| filename | string | Yes| Name of the file to create.| | filename | string | Yes| Name of the file to create.|
| path | string | Yes| URI of the file to create.| | path | string | Yes| URI of the file to create.|
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value - Return value
...@@ -177,28 +179,29 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr ...@@ -177,28 +179,29 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
| Error Info| Error Code|Description| | Error Info| Error Code|Description|
| -- | --- | -- | | -- | --- | -- |
| Operation not permitted | 1 | A file with the same name already exists.| | Operation not permitted | 1 | A file with the same name already exists.|
| No such file or directory | 2 | The directory or file of the specified URI does not exist.| | No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service.| | No such process | 3 | Failed to obtain the FMS service.|
| Not a directory | 20 | The object specified by the URI is not a directory.| | Not a directory | 20 | The object specified by the URI is not a directory or album.|
```js - Example
// Create a file.
let media_path = file.uri // Obtain the file URI using listFile() and getRoot(). ```js
let name = "xxx.jpg" // File to be saved. // Create a file.
filemanager.createFile(media_path, name) let media_path = file.uri // Obtain the file URI using listFile() and getRoot().
.then((uri) => { let name = "xxx.jpg" // File to be saved.
// The URI of the file created is returned. filemanager.createFile(media_path, name).then((uri) => {
}) // The URI of the file created is returned.
.catch((err) => { console.log("file uri:"+uri);
console.log(err) }).catch((err) => {
}) console.log(err);
``` });
```
## filemanager.createFile ## filemanager.createFile
createFile(path : string, filename: string, options? : {dev? : DevInfo}, callback : AsyncCallback&lt;string&gt;) : void createFile(path : string, filename: string, options? : {dev? : DevInfo}, callback : AsyncCallback&lt;string&gt;) : void
Creates a file in the specified path in asynchronous mode. This method uses a callback to return the result. Creates a file in the specified path in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
...@@ -208,7 +211,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca ...@@ -208,7 +211,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | Yes | Name of the file to create. | | filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. | | path | string | Yes | URI of the file to create. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. | | callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
- Error - Error
...@@ -216,20 +219,23 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca ...@@ -216,20 +219,23 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
| Error Info | Error Code| Description | | Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- | | ------------------------- | ------ | ------------------------- |
| Operation not permitted | 1 | A file with the same name already exists. | | Operation not permitted | 1 | A file with the same name already exists. |
| No such file or directory | 2 | The directory or file of the specified URI does not exist.| | No such file or directory | 2 | The directory or album of the specified URI does not exist.|
| No such process | 3 | Failed to obtain the FMS service. | | No such process | 3 | Failed to obtain the FMS service. |
| Not a directory | 20 | The object specified by the URI is not a directory.| | Not a directory | 20 | The object specified by the URI is not a directory or album.|
```js - Example
// Create a file.
// Call listFile() and getRoot() to obtain the file URI. ```js
let media_path = file.uri // Create a file.
// File to be saved. // Call listFile() and getRoot() to obtain the file URI.
let name = "xxx.jpg" let media_path = file.uri
filemanager.createFile(media_path, name, (err, uri) => { // File to be saved.
// The URI of the file created is returned. let name = "xxx.jpg"
}) filemanager.createFile(media_path, name, (err, uri) => {
``` // The URI of the file created is returned.
console.log("file uri:"+uri);
});
```
## FileInfo ## FileInfo
Defines the file information returned by **getRoot()** or **listFile()**. Defines the file information returned by **getRoot()** or **listFile()**.
...@@ -248,12 +254,13 @@ Defines the file information returned by **getRoot()** or **listFile()**. ...@@ -248,12 +254,13 @@ Defines the file information returned by **getRoot()** or **listFile()**.
| modifiedTime | number | Yes| No| Time when the file was modified.| | modifiedTime | number | Yes| No| Time when the file was modified.|
## DevInfo ## DevInfo
Defines the device type. Defines the device type.
**System capability**: SystemCapability.FileManagement.FileManagerService **System capability**: SystemCapability.FileManagement.FileManagerService
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name| Type | Readable| Writable| Description |
| --- | -- | -- | -- | -- | | ------ | ------ | ---- | ---- | -------- |
| name | string | Yes| Yes| Device name.| | name | string | Yes | Yes | Device name.|
# FormExtensionContext # FormExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**. Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
......
# Nonlinear Container HashMap # Nonlinear Container HashMap
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```ts
import HashMap from '@ohos.util.HashMap' import HashMap from '@ohos.util.HashMap'
``` ```
...@@ -32,7 +32,7 @@ A constructor used to create a **HashMap** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **HashMap** instance.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
``` ```
...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry). ...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const hashMap = new HashMap(); const hashMap = new HashMap();
let result = hashMap.isEmpty(); let result = hashMap.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key. ...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -105,7 +105,7 @@ Checks whether this container contains the specified value. ...@@ -105,7 +105,7 @@ Checks whether this container contains the specified value.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasValue(123); let result = hashMap.hasValue(123);
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -133,7 +133,7 @@ Obtains the value of the specified key in this container. ...@@ -133,7 +133,7 @@ Obtains the value of the specified key in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -155,7 +155,7 @@ Adds all entries in a **HashMap** instance to this container. ...@@ -155,7 +155,7 @@ Adds all entries in a **HashMap** instance to this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -185,7 +185,7 @@ Adds an entry to this container. ...@@ -185,7 +185,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
``` ```
...@@ -211,7 +211,7 @@ Removes an entry with the specified key from this container. ...@@ -211,7 +211,7 @@ Removes an entry with the specified key from this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -227,7 +227,7 @@ Clears this container and sets its length to **0**. ...@@ -227,7 +227,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -249,7 +249,7 @@ Obtains an iterator that contains all the entries in this container. ...@@ -249,7 +249,7 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -276,7 +276,7 @@ Obtains an iterator that contains all the values in this container. ...@@ -276,7 +276,7 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -310,7 +310,7 @@ Replaces an entry in this container. ...@@ -310,7 +310,7 @@ Replaces an entry in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("sdfs", 123); hashMap.set("sdfs", 123);
let result = hashMap.replace("sdfs", 357); let result = hashMap.replace("sdfs", 357);
...@@ -339,7 +339,7 @@ callbackfn ...@@ -339,7 +339,7 @@ callbackfn
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("sdfs", 123); hashMap.set("sdfs", 123);
hashMap.set("dfsghsf", 357); hashMap.set("dfsghsf", 357);
...@@ -363,7 +363,7 @@ Obtains an iterator that contains all the entries in this container. ...@@ -363,7 +363,7 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -390,7 +390,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -390,7 +390,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator&lt;[K, V]&gt; | Iterator obtained.| | IterableIterator&lt;[K, V]&gt; | Iterator obtained.|
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
......
# Nonlinear Container HashSet # Nonlinear Container HashSet
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```ts
import HashSet from '@ohos.util.HashSet'; import HashSet from '@ohos.util.HashSet';
``` ```
...@@ -32,7 +32,7 @@ A constructor used to create a **HashSet** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **HashSet** instance.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
``` ```
...@@ -51,9 +51,9 @@ Checks whether this container is empty (contains no entry). ...@@ -51,9 +51,9 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const hashSet = new HashSet(); const hashSet = new HashSet();
hashSet.isEmpty(); let result = hashSet.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains the specified entry. ...@@ -77,7 +77,7 @@ Checks whether this container contains the specified entry.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -105,7 +105,7 @@ Adds an entry to this container. ...@@ -105,7 +105,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
``` ```
...@@ -131,7 +131,7 @@ Removes an entry from this container. ...@@ -131,7 +131,7 @@ Removes an entry from this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -147,7 +147,7 @@ Clears this container and sets its length to **0**. ...@@ -147,7 +147,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -169,7 +169,7 @@ Obtains an iterator that contains all the values in this container. ...@@ -169,7 +169,7 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -204,7 +204,7 @@ callbackfn ...@@ -204,7 +204,7 @@ callbackfn
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("sdfs"); hashSet.add("sdfs");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -227,7 +227,7 @@ Obtains an iterator that contains all the entries in this container. ...@@ -227,7 +227,7 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -255,7 +255,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -255,7 +255,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
......
...@@ -7,7 +7,7 @@ You can run the hidebug command to obtain the memory usage of an application, in ...@@ -7,7 +7,7 @@ You can run the hidebug command to obtain the memory usage of an application, in
## Modules to Import ## Modules to Import
``` ```js
import hidebug from '@ohos.hidebug'; import hidebug from '@ohos.hidebug';
``` ```
...@@ -28,7 +28,7 @@ Obtains the total size of the native heap memory. ...@@ -28,7 +28,7 @@ Obtains the total size of the native heap memory.
**Example** **Example**
``` ```js
let nativeHeapSize = hidebug.getNativeHeapSize(); let nativeHeapSize = hidebug.getNativeHeapSize();
``` ```
...@@ -49,7 +49,7 @@ Obtains the size of the allocated native heap memory. ...@@ -49,7 +49,7 @@ Obtains the size of the allocated native heap memory.
**Example** **Example**
``` ```js
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
``` ```
...@@ -70,7 +70,7 @@ Obtains the size of the free native heap memory. ...@@ -70,7 +70,7 @@ Obtains the size of the free native heap memory.
**Example** **Example**
``` ```js
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize();
``` ```
...@@ -91,7 +91,7 @@ Obtains the PSS of this process. ...@@ -91,7 +91,7 @@ Obtains the PSS of this process.
**Example** **Example**
``` ```js
let pss = hidebug.getPss(); let pss = hidebug.getPss();
``` ```
...@@ -112,7 +112,7 @@ Obtains the size of the shared dirty memory of this process. ...@@ -112,7 +112,7 @@ Obtains the size of the shared dirty memory of this process.
**Example** **Example**
``` ```js
let sharedDirty = hidebug.getSharedDirty(); let sharedDirty = hidebug.getSharedDirty();
``` ```
......
# Linear Container Queue # Linear Container Queue
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```ts
import Queue from '@ohos.util.Queue' import Queue from '@ohos.util.Queue'
``` ```
...@@ -33,7 +33,7 @@ A constructor used to create a **Queue** instance. ...@@ -33,7 +33,7 @@ A constructor used to create a **Queue** instance.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
``` ```
...@@ -58,7 +58,7 @@ Adds an entry at the end of this container. ...@@ -58,7 +58,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
let result = queue.add("a"); let result = queue.add("a");
let result1 = queue.add(1); let result1 = queue.add(1);
...@@ -83,7 +83,7 @@ Removes the first entry from this container. ...@@ -83,7 +83,7 @@ Removes the first entry from this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -107,7 +107,7 @@ Obtains the first entry of this container. ...@@ -107,7 +107,7 @@ Obtains the first entry of this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -140,7 +140,7 @@ callbackfn ...@@ -140,7 +140,7 @@ callbackfn
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -161,12 +161,12 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -161,12 +161,12 @@ Obtains an iterator, each item of which is a JavaScript object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;T&gt; | Iterator obtained.| | IterableIterator&lt;T&gt; | Iterator obtained. |
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
......
# ServiceExtensionAbility # ServiceExtensionAbility
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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.
...@@ -40,7 +40,7 @@ Called when an extension is created to initialize the service logic. ...@@ -40,7 +40,7 @@ Called when an extension is created to initialize the service logic.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this extension, including the ability name and bundle name.| | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
**Example** **Example**
...@@ -84,7 +84,7 @@ Called after **onCreate** is invoked when an ability is started by calling **sta ...@@ -84,7 +84,7 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this extension, including the ability name and bundle name.| | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example** **Example**
...@@ -110,7 +110,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con ...@@ -110,7 +110,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this extension, including the ability name and bundle name.| | want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
**Return value** **Return value**
...@@ -150,7 +150,7 @@ Called when the ability is disconnected. ...@@ -150,7 +150,7 @@ Called when the ability is disconnected.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#Want)| Yes| Information related to this extension, including the ability name and bundle name.| | want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
**Example** **Example**
......
# Telephony
- [Telephony Service Overview](telephony-overview.md)
- [Redirecting to the Dial Screen](jumping-to-the-dial-screen.md)
- [Obtaining Current Cellular Network Signal Information](cellular-network-signal-info.md)
此差异已折叠。
...@@ -12,7 +12,7 @@ For details about the APIs, see [Window](../reference/apis/js-apis-window.md). ...@@ -12,7 +12,7 @@ For details about the APIs, see [Window](../reference/apis/js-apis-window.md).
| API | Description | | API | Description |
| :----------------------------------------------------------- | :--------------------------------------------- | | :----------------------------------------------------------- | :--------------------------------------------- |
| create(id: string, type: WindowType, callback: AsyncCallback\<Window>): void | Creates a subwindow. | | create(id: string, type: WindowType, callback: AsyncCallback\<Window>): void | Creates a subwindow. |
| moveTo(x: number, y: number): Promise\<void> | Moves the window position. A positive value of **x** indicates that the window moves to the right, and a positive value of **y** indicates that the window moves downwards.| | moveTo(x: number, y: number): Promise\<void> | Moves the window. A positive value of **x** indicates that the window moves to the right, and a positive value of **y** indicates that the window moves downwards.|
| resetSize(width: number, height: number): Promise\<void> | Changes the window size. | | resetSize(width: number, height: number): Promise\<void> | Changes the window size. |
| hide(): Promise\<void> | Hides the window. | | hide(): Promise\<void> | Hides the window. |
| destroy(): Promise\<void> | Destroys the window. | | destroy(): Promise\<void> | Destroys the window. |
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册