提交 d08b2a7b 编写于 作者: X xsz233

Merge remote-tracking branch 'upstream/master'

......@@ -554,3 +554,4 @@ zh-cn/application-dev/reference/errorcodes/errorcode-webview.md @HelloCrease
zh-cn/application-dev/reference/errorcodes/errorcode-window.md @ge-yafang
zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-calendarManager.md @ge-yafang @jt_123456 @edollar
\ No newline at end of file
......@@ -2,7 +2,7 @@
## Introduction
The Socket Connection module allows an application to transmit data over a Socket connection through the TCP, UDP, or TLS protocol.
The Socket Connection module allows an application to transmit data over a socket connection through the TCP, UDP, or TLS protocol.
## Basic Concepts
......@@ -13,10 +13,11 @@ The Socket Connection module allows an application to transmit data over a Socke
## When to Use
Applications transmit data over TCP, UDP, or TLS Socket connections. The main application scenarios are as follows:
Applications transmit data over TCP, UDP, or TLS socket connections. The main application scenarios are as follows:
- Implementing data transmission over TCP/UDP Socket connections
- Implementing encrypted data transmission over TLS Socket connections
- Implementing data transmission over TCP socket or UDP socket connections
- Implementing data transmission over TCP socket server connections
- Implementing encrypted data transmission over TLS socket connections
## Available APIs
......@@ -28,72 +29,75 @@ Socket connection functions are mainly implemented by the **socket** module. The
| -------- | -------- |
| constructUDPSocketInstance() | Creates a **UDPSocket** object.|
| constructTCPSocketInstance() | Creates a **TCPSocket** object.|
| constructTCPSocketServerInstance() | Creates a **TCPSocketServer** object.|
| listen() | Listens for and accepts TCP socket connections established over the socket. (This API is applicable only to TCP.)|
| bind() | Binds the IP address and port number.|
| send() | Sends data.|
| close() | Closes a Socket connection.|
| getState() | Obtains the Socket connection status.|
| 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') | Subscribes to **message** events of the Socket connection.|
| off(type: 'message') | Unsubscribes from **message** events of the Socket connection.|
| on(type: 'close') | Subscribes to **close** events of the Socket connection.|
| off(type: 'close') | Unsubscribes from **close** events of the Socket connection.|
| on(type: 'error') | Subscribes to **error** events of the Socket connection.|
| off(type: 'error') | Unsubscribes from **error** events of the Socket connection.|
| on(type: 'listening') | Subscribes to **listening** events of the UDP Socket connection. |
| off(type: 'listening') | Unsubscribes from **listening** events of the UDP Socket connection. |
| on(type: 'connect') | Subscribes to **connect** events of the TCP Socket connection. |
| off(type: 'connect') | Unsubscribes from **connect** events of the TCP Socket connection.|
TLS Socket connection functions are mainly provided by the **tls_socket** module. The following table describes the related APIs.
| 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.|
| setExtraOptions() | Sets other properties of the socket connection.|
| on(type: 'message') | Subscribes to **message** events of the socket connection.|
| off(type: 'message') | Unsubscribes from **message** events of the socket connection.|
| on(type: 'close') | Subscribes to **close** events of the socket connection.|
| off(type: 'close') | Unsubscribes from **close** events of the socket connection.|
| on(type: 'error') | Subscribes to **error** events of the socket connection.|
| off(type: 'error') | Unsubscribes from **error** events of the socket connection.|
| on(type: 'listening') | Subscribes to **listening** events of the UDP socket connection. |
| off(type: 'listening') | Unsubscribes from **listening** events of the UDP socket connection. |
| on(type: 'connect') | Subscribes to **connect** events of the TCP socket connection. |
| off(type: 'connect') | Unsubscribes from **connect** events of the TCP socket connection.|
TLS socket connection functions are mainly provided by the **tls_socket** module. The following table describes the related APIs.
| API| Description|
| -------- | -------- |
| constructTLSSocketInstance() | Creates a **TLSSocket** object.|
| bind() | Binds the IP address and port number.|
| close(type: 'error') | Closes a Socket connection.|
| close(type: 'error') | Closes a socket connection.|
| connect() | Sets up a connection to the specified IP address and port number.|
| getCertificate() | Obtains an object representing the local certificate.|
| getCipherSuite() | Obtains a list containing information about the negotiated cipher suite.|
| getProtocol() | Obtains a string containing the SSL/TLS protocol version negotiated for the current connection.|
| getRemoteAddress() | Obtains the peer address of the TLS Socket connection.|
| getRemoteAddress() | Obtains the peer address of the TLS socket connection.|
| getRemoteCertificate() | Obtains an object representing a peer certificate.|
| getSignatureAlgorithms() | Obtains a list containing signature algorithms shared between the server and client, in descending order of priority.|
| getState() | Obtains the TLS Socket connection status.|
| off(type: 'close') | Unsubscribes from **close** events of the TLS Socket connection.|
| off(type: 'error') | Unsubscribes from **error** events of the TLS Socket connection.|
| off(type: 'message') | Unsubscribes from **message** events of the TLS Socket connection.|
| on(type: 'close') | Subscribes to **close** events of the TLS Socket connection.|
| on(type: 'error') | Subscribes to **error** events of the TLS Socket connection.|
| on(type: 'message') | Subscribes to **message** events of the TLS Socket connection.|
| getState() | Obtains the TLS socket connection status.|
| off(type: 'close') | Unsubscribes from **close** events of the TLS socket connection.|
| off(type: 'error') | Unsubscribes from **error** events of the TLS socket connection.|
| off(type: 'message') | Unsubscribes from **message** events of the TLS socket connection.|
| on(type: 'close') | Subscribes to **close** events of the TLS socket connection.|
| on(type: 'error') | Subscribes to **error** events of the TLS socket connection.|
| on(type: 'message') | Subscribes to **message** events of the TLS socket connection.|
| send() | Sends data.|
| setExtraOptions() | Sets other properties of the TLS Socket connection.|
| setExtraOptions() | Sets other properties of the TLS socket connection.|
## Transmitting Data over TCP/UDP Socket Connections
## Transmitting Data over TCP Socket or UDP Socket Connections
The implementation is similar for UDP Socket and TCP Socket connections. The following uses data transmission over a TCP Socket connection as an example.
The implementation is similar for UDP socket and TCP socket connections. The following uses data transmission over a TCP socket connection as an example.
1. Import the required **socket** module.
2. Create a **TCPSocket** object.
2. Create a TCP socket connection. A **TCPSocket** object is returned.
3. (Optional) Subscribe to TCP Socket connection events.
3. (Optional) Subscribe to TCP socket connection 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.
6. Send data over the connection.
7. Enable the TCP Socket connection to be automatically closed after use.
7. Enable the TCP socket connection to be automatically closed after use.
```js
import socket from '@ohos.net.socket'
// Create a TCPSocket object.
// Create a TCP socket connection. A TCPSocket object is returned.
let tcp = socket.constructTCPSocketInstance();
// Subscribe to TCP Socket connection events.
// Subscribe to events of the TCPSocket object.
tcp.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -139,7 +143,7 @@ tcp.bind(bindAddress, err => {
}
console.log('connect success');
// Send data.
// Send data over the connection.
tcp.send({
data: 'Hello, server!'
}, err => {
......@@ -152,7 +156,7 @@ tcp.bind(bindAddress, err => {
});
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
setTimeout(() => {
tcp.close((err) => {
console.log('close socket.')
......@@ -163,11 +167,92 @@ setTimeout(() => {
}, 30 * 1000);
```
## Implementing Data Transmission over TCP Socket Server Connections
### How to Develop
The TCP socket server connection process is described as follows:
1. Import the required **socket** module.
2. Create a TCP socket server connection. A **TCPSocketServer** object is returned.
3. Bind the local IP address and port, and listen for and accept TCP socket connections established over the socket.
4. Subscribe to **connect** events of the **TCPSocketServer** object to listen for client connection status changes.
5. Set up a connection between the client and the server. A **TCPSocketConnection** object is returned.
6. Subscribe to events of the **TCPSocketConnection** object, and send data to the client through the **TCPSocketConnection** object.
7. Close the connection between the client and the server.
8. Unsubscribe from events of the **TCPSocketConnection** and **TCPSocketServer** objects.
```js
import socket from '@ohos.net.socket'
// Create a TCP socket server connection. A TCPSocketServer object is returned.
let tcpServer = socket.constructTCPSocketServerInstance();
// Bind the local IP address and port number for listening.
tcpServer.listen({ address: "192.168.xx.xxx", port: xxxx, family: 1 }, err => {
if (err) {
console.log("listen fail");
return;
}
console.log("listen success");
})
// Subscribe to connect events of the TCPSocketServer object.
tcpServer.on('connect', function(client) {
// Subscribe to events of the TCPSocketConnection object.
client.on('close', () => {
console.log("on close success");
});
client.on('message', function(value) {
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("received message--:" + str);
console.log("received address--:" + value.remoteInfo.address);
console.log("received family--:" + value.remoteInfo.family);
console.log("received port--:" + value.remoteInfo.port);
console.log("received size--:" + value.remoteInfo.size);
});
// Send data to the client.
client.send({data: 'Hello, client!'}, err => {
if (err) {
console.log('send fail');
return;
}
console.log('send success');
});
// Close the connection between the client and the server.
client.close(err => {
if (err) {
console.log('close fail');
return;
}
console.log('close success');
});
// Unsubscribe from events of the TCPSocketConnection object.
setTimeout(() => {
client.off('message');
client.off('close');
}, 10 * 1000);
});
// Unsubscribe from events of the TCPSocketServer object.
setTimeout(() => {
tcpServer.off('connect');
}, 30 * 1000);
```
## Implementing Encrypted Data Transmission over TLS Socket Connections
### How to Develop
TLS Socket connection process on the client:
The TLSsocket connection process on the client is described as follows:
1. Import the required **socket** module.
......@@ -175,21 +260,21 @@ TLS Socket connection process on the client:
3. For two-way authentication, upload the client CA certificate and digital certificate. For one-way authentication, upload the client CA certificate.
4. Create a **TLSSocket** object.
4. Create a TLS socket connection. A **TLSsocket** object is returned.
5. (Optional) Subscribe to TLS Socket connection events.
5. (Optional) Subscribe to TLS socket connection events.
6. Send data.
6. Send data over the connection.
7. Enable the TLS Socket connection to be automatically closed after use.
7. Enable the TLS socket connection to be automatically closed after use.
```js
import socket from '@ohos.net.socket'
// Create a TLS Socket connection (for two-way authentication).
// Create a TLS socket connection (for two-way authentication). A TLSSocket object is returned.
let tlsTwoWay = socket.constructTLSSocketInstance();
// Subscribe to TLS Socket connection events.
// Subscribe to TLS socket connection events.
tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -246,7 +331,7 @@ tlsTwoWay.connect(options, (err, data) => {
console.log(data);
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
......@@ -258,10 +343,10 @@ tlsTwoWay.close((err) => {
tlsTwoWay.off('close');
});
// Create a TLS Socket connection (for one-way authentication).
// Create a TLS socket connection (for one-way authentication). A TLSsocket object is returned.
let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication
// Subscribe to TLS Socket connection events.
// Subscribe to TLS socket connection events.
tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -307,7 +392,7 @@ tlsOneWay.connect(oneWayOptions, (err, data) => {
console.log(data);
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
......@@ -319,11 +404,3 @@ tlsTwoWay.close((err) => {
tlsTwoWay.off('close');
});
```
## Samples
The following samples are provided to help you better understand how to develop Socket connection features:
- [`Socket`: Socket Connection (ArkTS) (API9)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Socket)
- [UDP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH)
- [TCP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo)
......@@ -2,7 +2,7 @@
- [Full SDK Compilation](full-sdk-compile-guide.md)
- [Switching to Full SDK](full-sdk-switch-guide.md)
- [Using Native APIs (NDK) of the OpenHarmony SDK in a CMake Project](cmake-with-ndk.md)
- [Using NDK in a CMake Project](cmake-with-ndk.md)
- [Application Model Development](faqs-ability.md)
- ArkUI Development (ArkTS)
- [ArkTS Syntax Usage](faqs-arkui-arkts.md)
......
# Using Native APIs (NDK) of the OpenHarmony SDK in a CMake Project
# Using NDK in a CMake Project
## What Is Native API
......@@ -10,34 +10,34 @@ You download the Native API Development Kit (NDK) by downloading the OHOS SDK, w
- (Recommended) Acquire source code from mirrors for an officially released version. For details, see [release notes](../../release-notes/OpenHarmony-v3.2-release.md).
- Download the SDK from the SDK Manager in DevEco Studio.
- Download the SDK from the [daily build](http://ci.openharmony.cn/dailys/dailybuilds), by clicking the download link to the **ohos-sdk-full** component.
- Download the SDK from the [daily build](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist), by clicking the download link to the **ohos-sdk-full** component.
![Download from Daily Build](figures/ci_download.png)
![](figures/ci_download.png)
## Decompressing the NDK
Place the downloaded NDK in a folder you prefer and decompress it. Below shows the directory structure after decompression.
![SDK Directory Structure](figures/sdk-structure.png)
![](figures/sdk-structure.png)
Configure the Linux environment as follows: (Skip them if the NDK is downloaded from DevEco Studio.)
1. Add the CMake tool that comes with the NDK to the environment variables.
Add the CMake tool that comes with the NDK to the environment variables.
```
# Open the .bashrc file.
vim ~/.bashrc
# Append the custom CMake path to the file. Save the file and exit.
# Append the custom CMake path to the file.
export PATH=~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin:$PATH
# Run the source ~/.bashrc command to make the environment variables take effect.
source ~/.bashrc
```
2. Check the default CMake path.
Check the default CMake path.
```
# Run the which cmake command.
which cmake
# The result should be the same as the custom path previously appended to the file.
# The result should be the same as the custom path previously appended to the .bashrc file.
~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin/cmake
```
......
......@@ -238,7 +238,7 @@ The **abilities** tag represents the UIAbility configuration of the module, whic
| description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages.| String| Yes (initial value: left empty)|
| icon | Icon of the UIAbility component. The value is an icon resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| label | Name of the UIAbility component displayed to users. The value is a string resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| permissions | Permissions required for another application to access the UIAbility component.<br>The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)|
| permissions | Permissions required for another application to access the UIAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of predefined permission names.| String array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
......@@ -377,7 +377,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| icon | Icon of the ExtensionAbility component. The value is an icon resource index. If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| Yes (initial value: left empty)|
| label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.<br>**NOTE**<br>If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.<br>- **print**: ExtensionAbility for the print framework.<br>- **push**: ExtensionAbility to be pushed.<br>- **driver**: ExtensionAbility for the driver framework.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
| permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of [predefined permission names](../security/permission-list.md).| String array| Yes (initial value: left empty)|
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
......
......@@ -265,7 +265,7 @@ Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello'))
// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d.
// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, one indicates singular and is represented by 1, and other indicates plural and is represented by an integer greater than or equal to 1; for Chinese, other indicates both singular and plural), and the third parameter is used to replace %d.
// In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world'))
......
......@@ -441,6 +441,7 @@
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.restrictions (Restrictions)](js-apis-enterprise-restrictions.md)
- [@ohos.enterprise.usbManager (USB Management)](js-apis-enterprise-usbManager.md)
- [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md)
- Common Library
......
......@@ -204,8 +204,8 @@ Indicates that user switching is in progress.
- Value: **usual.event.USER_STARTING**
- Required subscriber permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
## COMMON_EVENT_USER_UNLOCKED
(Reserved, not supported yet) Indicates that the credential-encrypted storage has been unlocked for the current user after the device is restarted.
## [COMMON_EVENT_USER_UNLOCKED](./common_event/commonEvent-account.md)
Indicates that the credential-encrypted storage has been unlocked for the current user after the device is restarted.
- Value: **usual.event.USER_UNLOCKED**
- Required subscriber permissions: none
......
......@@ -44,33 +44,43 @@ APIs related to this event: **activateOsAccount**. This API is a system API. For
## COMMON_EVENT_USER_INFO_UPDATED<sup>9+<sup>
Indicates that the user information has been updated.
- Value: **usual.event.USER_INFO_UPDATED**
- Value: usual.event.USER_INFO_UPDATED
- Required subscriber permissions: none
When the distributed account information, system account profile picture, or system account name is changed, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **setOsAccountName**, **setOsAccountProfilePhoto**, and **setOsAccountDistributedInfon**. The first two are system APIs, and the last is a public API. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_USER_UNLOCKED
Indicates that the credential-encrypted storage has been unlocked for the current user after the device is restarted.
- Value: usual.event.USER_UNLOCKED
- Required subscriber permissions: none
When the device is unlocked with the lock screen password the first time after user switching, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **auth**. This API is a system API. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN
(Reserved, not supported yet) Indicates a successful login to a distributed account.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGIN
- Value: common.event.DISTRIBUTED_ACCOUNT_LOGIN
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT
(Reserved, not supported yet) Indicates a successful logout of a distributed account.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGOUT
- Value: common.event.DISTRIBUTED_ACCOUNT_LOGOUT
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID
(Reserved, not supported yet) Indicates the token of a distributed account is invalid.
- Value: usual.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID
- Value: common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF
(Reserved, not supported yet) Indicates that a distributed account is deregistered.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGOFF
- Value: common.event.DISTRIBUTED_ACCOUNT_LOGOFF
- Required subscriber permissions: none
......@@ -12,12 +12,12 @@ OpenHarmony provides Enterprise Device Management APIs to support enterprise API
- Only the stage model is supported.
### Environment Setup
- [Download DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio#download) and set it up as instructed on the official website.
- [Download ohos-sdk-full](../../../release-notes/OpenHarmony-v3.2-beta2.md#acquiring-source-code-from-mirrors).
- DevEco Studio: Download DevEco Studio from its official website and perform related configuration.
- ohos-sdk-full: Obtain ohos-sdk-full. For details, see [Replacing Full SDK](../../faqs/full-sdk-switch-guide.md).
### How to Develop
1. Use DevEco Studio to create a project and [switch to full-sdk](../../faqs/full-sdk-switch-guide.md).
1. Use DevEco Studio to create a project and replace the full SDK.
2. In the [HarmonyAppProvision file](../../security/accesstoken-overview.md#application-apls), set the **app-feature** field to **hos_system_app**.
......@@ -27,11 +27,13 @@ OpenHarmony provides Enterprise Device Management APIs to support enterprise API
### API Reference
To implement network management and Wi-Fi management, see:
> **NOTE**
>
> - For details about the APIs, see:
- [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.applicationManager (Application Management)](js-apis-enterprise-applicationManager.md)
- [@ohos.enterprise.browser (Browser Management)](js-apis-enterprise-browser.md)
- [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md)
......@@ -40,4 +42,5 @@ To implement network management and Wi-Fi management, see:
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.restrictions (Restrictions)](js-apis-enterprise-restrictions.md)
- [@ohos.enterprise.usbManager (USB Management)](js-apis-enterprise-usbManager.md)
- [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md)
......@@ -31,8 +31,8 @@ import config from '@ohos.accessibility.config';
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
| audioMono| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.|
| audioBalance| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.|
| audioMono<sup>10+</sup>| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.|
| audioBalance<sup>10+</sup>| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.|
## enableAbility
......
# @ohos.bluetooth.ble (Bluetooth BLE Module)
The **ble** module provides APIs for accessing the Bluetooth personal area network.
The **ble** module provides APIs for operating and managing Bluetooth.
> **NOTE**
>
......
......@@ -3,8 +3,9 @@
The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [bluetoothManager](js-apis-bluetoothManager.md).
>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use profile APIs of [@ohos.bluetooth.ble](js-apis-bluetooth-ble.md).
......
......@@ -4,7 +4,9 @@ The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth L
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - This APIs provided by this module are no longer maintained since API version 10. You are advised to use profile APIs of [@ohos.bluetooth.ble](js-apis-bluetooth-ble.md).
......
......@@ -6,6 +6,8 @@ The **accountManager** module provides APIs for account management of enterprise
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -18,7 +20,7 @@ import accountManager from '@ohos.enterprise.accountManager';
disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback&lt;void&gt;): void
Forbids a device administrator application to create local user accounts. This API uses an asynchronous callback to return the result.
Disallows a device administrator application to create local user accounts. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY
......@@ -30,8 +32,8 @@ Forbids a device administrator application to create local user accounts. This A
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Enterprise device administrator application. |
| disallow | boolean | Yes | Whether to forbid the creation of local user accounts. The value **true** means that local user accounts cannot be created; the value **false** means the opposite. |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| disallow | boolean | Yes | Whether to forbid the creation of local user accounts. The value **true** means to disallow the creation of local user accounts, and the value **false** means the opposite. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
......@@ -64,7 +66,7 @@ accountManager.disallowAddLocalAccount(wantTemp, true, (err) => {
disallowAddLocalAccount(admin: Want, disallow: boolean): Promise&lt;void&gt;
Forbids a device administrator application to create local user accounts. This API uses a promise to return the result.
Disallows a device administrator application to create local user accounts. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY
......@@ -76,14 +78,14 @@ Forbids a device administrator application to create local user accounts. This A
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Enterprise device administrator application.|
| disallow | boolean | Yes | Whether to forbid the creation of local user accounts. The value **true** means that local user accounts cannot be created; the value **false** means the opposite. |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| disallow | boolean | Yes | Whether to forbid the creation of local user accounts. The value **true** means to disallow the creation of local user accounts, and the value **false** means the opposite. |
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. An error object will be thrown if the operation fails.|
| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown.|
**Error codes**
......
......@@ -6,6 +6,8 @@ The **applicationManager** module provides application management capabilities,
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -18,7 +20,7 @@ import applicationManager from '@ohos.enterprise.applicationManager';
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
Adds a list of applications that are forbidden to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Adds the applications that are not allowed to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -66,7 +68,7 @@ applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (err) => {
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
Adds a list of applications that are forbidden to run by a given user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Adds the applications that are not allowed to run by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -80,7 +82,7 @@ Adds a list of applications that are forbidden to run by a given user through th
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| appIds | Array&lt;string&gt; | Yes | IDs of the applications to add. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | Yes | User ID, which must be greater than or equal to 0.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -114,7 +116,7 @@ applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (err) => {
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
Adds a list of applications that are forbiddedn to run by the specified user (if **userId** is passed in) or current user (if **userId** is not passed in) through the specified device administrator application.
Adds the applications that are not allowed to run by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -128,13 +130,13 @@ Adds a list of applications that are forbiddedn to run by the specified user (if
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| appIds | Array&lt;string&gt; | Yes | IDs of the applications to add. |
| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | No | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be run by the specified user.<br> - If **userId** is not passed in, the applications cannot be run by the current user.|
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. An error object is thrown when the applications fail to be added. |
| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
**Error codes**
......@@ -165,7 +167,7 @@ applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() =>
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
Removes a list of applications that are forbiddedn to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Removes the applications that are not allowed to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -212,7 +214,7 @@ applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (err) => {
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
Removes a list of applications that are forbiddedn to run by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Removes the applications that are not allowed to run by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -226,7 +228,7 @@ Removes a list of applications that are forbiddedn to run by the specified user
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| appIds | Array&lt;string&gt; | Yes | IDs of the applications to remove. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | Yes | User ID, which must be greater than or equal to 0.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -260,7 +262,7 @@ applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (err) =
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
Removes a list of applications that are forbiddedn to run by the specified user (if **userId** is passed in) or current user (if **userId** is not passed in) through the specified device administrator application. This API uses a promise to return the result.
Removes the applications that are not allowed to run by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -274,13 +276,13 @@ Removes a list of applications that are forbiddedn to run by the specified user
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| appIds | Array&lt;string&gt; | Yes | IDs of the applications to remove. |
| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | No | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be run by the specified user.<br> - If **userId** is not passed in, the applications cannot be run by the current user.|
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. An error object is thrown when the applications fail to be removed. |
| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
**Error codes**
......@@ -311,7 +313,7 @@ applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(()
getDisallowedRunningBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
Obtains the list of applications that are firbidded to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Obtains the applications that are not allowed to run by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -356,7 +358,7 @@ applicationManager.getDisallowedRunningBundles(wantTemp, (err, result) => {
getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
Obtains the list of applications that are firbidded to run by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
Obtains the applications that are not allowed to run by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -369,7 +371,7 @@ Obtains the list of applications that are firbidded to run by the specified user
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | Yes | User ID, which must be greater than or equal to 0.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
......@@ -402,7 +404,7 @@ applicationManager.getDisallowedRunningBundles(wantTemp, 100, (err, result) => {
getDisallowedRunningBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;;
Obtains the list of applications that are firbidded to run by the specified user (if **userId** is passed in) or current user (if **userId** is not passed in) through the specified device administrator application. This API uses a promise to return the result.
Obtains the applications that are not allowed to run by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
......@@ -415,7 +417,7 @@ Obtains the list of applications that are firbidded to run by the specified user
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
| userId | number | No | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be run by the specified user.<br> - If **userId** is not passed in, the applications cannot be run by the current user.|
**Return value**
......
......@@ -6,6 +6,8 @@ The **dateTimeManager** module provides APIs for system time management.
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -113,7 +115,7 @@ dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => {
disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\<void>): void
Disallows modification of the system time through the specified device administrator application. This API uses an asynchronous callback to return the result.
Forbids the specified device administrator application to modify the system time. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
......@@ -126,7 +128,7 @@ Disallows modification of the system time through the specified device administr
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| disallow | boolean | Yes| Whether to disable modification of the system time. The value **true** means to disable modification of the system time, and **false** means the opposite.|
| disallow | boolean | Yes| Whether to disallow modification of the system time. The value **true** means to disallow modification of the system time, and **false** means the opposite.|
| callback | AsyncCallback\<void> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -159,7 +161,7 @@ dateTimeManager.disallowModifyDateTime(wantTemp, true, (err) => {
disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void>
Disallows modification of the system time through the specified device administrator application. This API uses a promise to return the result.
Forbids the specified device administrator application to modify the system time. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
......@@ -172,13 +174,13 @@ Disallows modification of the system time through the specified device administr
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| disallow | boolean | Yes| Whether to disable modification of the system time. The value **true** means to disable modification of the system time, and **false** means the opposite.|
| disallow | boolean | Yes| Whether to disallow modification of the system time. The value **true** means to disallow modification of the system time, and **false** means the opposite.|
**Return value**
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<void> | Promise that returns no value. An error object is thrown if the operation fails.|
| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.|
**Error codes**
......@@ -208,7 +210,7 @@ dateTimeManager.disallowModifyDateTime(wantTemp, true).then(() => {
isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void
Checks whether the modification of the system time is disallowed through the specified device administrator application. This API uses an asynchronous callback to return the result.
Checks whether the system time modification is disallowed through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
......@@ -221,7 +223,7 @@ Checks whether the modification of the system time is disallowed through the spe
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| callback | AsyncCallback\<boolean> | Yes| Callback invoked to return the result. The value **true** means that modification of the system time is disallowed, and **false** means the opposite.|
| callback | AsyncCallback\<boolean> | Yes| Callback invoked to return the result. The value **true** means the system time modification is disallowed, and **false** means the opposite.|
**Error codes**
......@@ -253,7 +255,7 @@ dateTimeManager.isModifyDateTimeDisallowed(wantTemp, (err, result) => {
isModifyDateTimeDisallowed(admin: Want): Promise\<boolean>
Checks whether the modification of the system time is disallowed through the specified device administrator application. This API uses a promise to return the result.
Checks whether the system time modification is disallowed through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
......@@ -271,7 +273,7 @@ Checks whether the modification of the system time is disallowed through the spe
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that modification of the system time is disallowed, and **false** means the opposite.|
| Promise\<boolean> | Promise used to return the result. The value **true** means the system time modification is disallowed, and **false** means the opposite.|
**Error codes**
......
# @ohos.enterprise.deviceControl (Device Control)
The **deviceControl** module provides APIs for device control, which can be called only by device administrator applications.
The **deviceControl** module provides APIs for device control.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
......@@ -19,7 +20,7 @@ import deviceControl from '@ohos.enterprise.deviceControl'
resetFactory(admin: Want, callback: AsyncCallback\<void>): void
Restores factory settings through the specified device administrator application. This API uses an asynchronous callback to return the result.
Restores device factory settings through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_RESET_DEVICE
......@@ -31,7 +32,7 @@ Restores factory settings through the specified device administrator application
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application used to restore the factory settings.|
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| callback | AsyncCallback\<void> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -64,7 +65,7 @@ deviceControl.resetFactory(wantTemp, (err) => {
resetFactory(admin: Want): Promise\<void>
Restores factory settings. This API uses a promise to return the result.
Restores device factory settings through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_RESET_DEVICE
......@@ -76,7 +77,7 @@ Restores factory settings. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application used to restore the factory settings.|
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
**Return value**
......
......@@ -6,6 +6,8 @@ The **deviceInfo** module provides APIs for enterprise device information manage
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -111,7 +113,7 @@ deviceInfo.getDeviceSerial(wantTemp).then((result) => {
getDisplayVersion(admin: Want, callback: AsyncCallback&lt;string&gt;): void;
Obtains the device version number through the specified device administrator application. This API uses an asynchronous callback to return the result.
Obtains the device version through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_GET_DEVICE_INFO
......@@ -124,7 +126,7 @@ Obtains the device version number through the specified device administrator app
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the device version number obtained. If the operation fails, **err** is an error object. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the device version obtained. If the operation fails, **err** is an error object. |
**Error codes**
......@@ -156,7 +158,7 @@ deviceInfo.getDisplayVersion(wantTemp, (err, result) => {
getDisplayVersion(admin: Want): Promise&lt;string&gt;
Obtains the device version number through the specified device administrator application. This API uses a promise to return the result.
Obtains the device version through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_GET_DEVICE_INFO
......@@ -174,7 +176,7 @@ Obtains the device version number through the specified device administrator app
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise used to return the device version number.|
| Promise&lt;string&gt; | Promise used to return the device version obtained.|
**Error codes**
......
......@@ -6,7 +6,9 @@ The **deviceSettings** module provides APIs for setting enterprise devices, incl
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module apply only to the [device administrator applications](enterpriseDeviceManagement-overview.md#basic-concepts). Before calling the APIs, you must enable the device administrator application(js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
> The APIs of this module can be used only in the stage model.
>
> The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -18,7 +20,7 @@ import deviceSettings from '@ohos.enterprise.deviceSettings';
getScreenOffTime(admin: Want, callback: AsyncCallback&lt;number&gt;): void
Obtains the screen-off time of a device through the specified device administrator application. This API uses an asynchronous callback to return the result.
Obtains the device screen-off time through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_GET_SETTINGS
......@@ -63,7 +65,7 @@ deviceSettings.getScreenOffTime(wantTemp, (err, result) => {
getScreenOffTime(admin: Want): Promise&lt;number&gt;
Obtains the screen-off time of a device through the specified device administrator application. This API uses a promise to return the result.
Obtains the device screen-off time through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_GET_SETTINGS
......@@ -106,3 +108,232 @@ deviceSettings.getScreenOffTime(wantTemp).then((result) => {
console.error(`Failed to get screen off time. Code: ${err.code}, message: ${err.message}`);
});
```
## deviceSettings.installUserCertificate
installUserCertificate(admin: Want, certificate: CertBlob, callback: AsyncCallback&lt;string&gt;): void
Installs a user certificate through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| certificate | [CertBlob](#certblob) | Yes | Information about the certificate to install. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**Example**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
var certFileArray: Uint8Array;
// The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory
await globalThis.context.resourceManager.getRawFileContent("test.cer")
.then(value => {
certFileArray = value
})
.catch(error => {
console.error(`Failed to get row file content. message: ${error.message}`);
return
});
new Promise((resolve, reject) => {
deviceSettings.installUserCertificate(wantTemp, {inData: certFileArray, alias: "cert_alias_xts"}, (err, result) => {
if (err) {
console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
} else{
console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}
});
});
```
## deviceSettings.installUserCertificate
installUserCertificate(admin: Want, certificate: CertBlob): Promise&lt;string&gt;
Installs a user certificate through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| certificate | [CertBlob](#certblob) | Yes | Information about the certificate to install. |
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise used to return the URI of the installed certificate. This URI can be used to uninstall the certificate.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**Example**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
var certFileArray: Uint8Array
// The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory
await globalThis.context.resourceManager.getRawFileContent("test.cer")
.then(data => {
certFileArray = data
}).catch(error => {
console.log('getRawFileContent error' + error)
return
})
deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" })
.then((result) => {
console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}).catch(err => {
console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
})
```
## CertBlob
Represents the certificate information.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name | Type | Mandatory| Description |
| ----------- | --------| ----- | ------------------------------- |
| inData | Uint8Array | Yes| Binary content of the certificate.|
| alias | string | Yes| Certificate alias.|
## deviceSettings.uninstallUserCertificate
uninstallUserCertificate(admin: Want, certUri: string, callback: AsyncCallback&lt;void&gt;): void
Uninstalls a user certificate through the specified device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| certUri | string | Yes | Certificate URI, which is returned by **installUserCertificate()**. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**Example**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let aliasStr = "certName"
deviceSettings.uninstallUserCertificate(wantTemp, aliasStr, (err) => {
if (err) {
console.error(`Failed to uninstall user certificate. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info(`Succeeded in uninstalling user certificate`);
});
```
## deviceSettings.uninstallUserCertificate
uninstallUserCertificate(admin: Want, certUri: string): Promise&lt;void&gt;
Uninstalls a user certificate through the specified device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| certUri | string | Yes | Certificate URI, which is returned by **installUserCertificate()**. |
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. An error object will be thrown if the operation fails.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**Example**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let aliasStr = "certName"
deviceSettings.uninstallUserCertificate(wantTemp, aliasStr).then(() => {
console.info(`Succeeded in uninstalling user certificate`);
}).catch((err) => {
console.error(`Failed to uninstall user certificate. Code is ${err.code}, message is ${err.message}`);
});
```
# @ohos.enterprise.usbManager (USB Management)
The **usbManager** module provides APIs for USB management.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
>
> The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
```js
import usbManager from '@ohos.enterprise.usbManager'
```
## usbManager.setUsbPolicy
setUsbPolicy(admin: Want, usbPolicy: UsbPolicy, callback: AsyncCallback\<void>): void
Sets the USB read/write policy through the specified device administrator application. This API uses an asynchronous callback to return the result.
Required permissions: ohos.permission.ENTERPRISE_MANAGE_USB
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| usbPolicy | [UsbPolicy](#usbpolicy) | Yes| USB read/write policy to set.|
| callback | AsyncCallback\<void> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**Example**
```js
let wantTemp = {
bundleName: 'bundleName',
abilityName: 'abilityName',
};
let policy = usbManager.UsbPolicy.READ_WRITE
usbManager.setUsbPolicy(wantTemp, policy, (err) => {
if (err) {
console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in setting usb policy');
})
```
## usbManager.setUsbPolicy
setUsbPolicy(admin: Want, usbPolicy: UsbPolicy): Promise\<void>
Sets the USB read/write policy through the specified device administrator application. This API uses a promise to return the result.
Required permissions: ohos.permission.ENTERPRISE_MANAGE_USB
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| usbPolicy | [UsbPolicy](#usbpolicy) | Yes| USB read/write policy to set.|
**Return value**
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<void> | Promise that returns no value. An error object will be thrown if the operation fails.|
**Error codes**
For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
| ID| Error Message |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**Example**
```js
let wantTemp = {
bundleName: 'bundleName',
abilityName: 'abilityName',
};
let policy = usbManager.UsbPolicy.READ_WRITE
usbManager.setUsbPolicy(wantTemp, policy).then(() => {
console.info('Succeeded in setting usb policy');
}).catch((err) => {
console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`);
})
```
## UsbPolicy
Enumerates the USB read/write policies.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
| Name| Value| Description|
| -------- | -------- | -------- |
| READ_WRITE | 0 | The USB is readable and writable.|
| READ_ONLY | 1 | The USB is read-only.|
......@@ -4,9 +4,11 @@ The **wifiManager** module provides APIs for Wi-Fi management of enterprise devi
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. 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 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
> - The APIs of this module can be used only in the stage model.
>
> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
## Modules to Import
......@@ -111,7 +113,7 @@ wifiManager.isWifiActive(wantTemp).then((result) => {
setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback&lt;void&gt;): void
Sets Wi-Fi to connect to the specified network. This API uses an asynchronous callback to return the result.
Sets Wi-Fi profile through the specified device administrator application to enable the device to connect to the specified network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI
......@@ -124,7 +126,7 @@ Sets Wi-Fi to connect to the specified network. This API uses an asynchronous ca
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
| profile | [WifiProfile](#wifiprofile) | Yes | WLAN configuration. |
| profile | [WifiProfile](#wifiprofile) | Yes | Wi-Fi profile information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
......@@ -162,7 +164,7 @@ wifiManager.setWifiProfile(wantTemp, profile, (err) => {
setWifiProfile(admin: Want, profile: WifiProfile): Promise&lt;void&gt;
Sets Wi-Fi to connect to the specified network. This API uses a promise to return the result.
Sets Wi-Fi profile through the specified device administrator application to enable the device to connect to the specified network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SET_WIFI
......@@ -175,7 +177,7 @@ Sets Wi-Fi to connect to the specified network. This API uses a promise to retur
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
| profile | [WifiProfile](#wifiprofile) | Yes | WLAN configuration. |
| profile | [WifiProfile](#wifiprofile) | Yes | Wi-Fi profile information. |
**Return value**
......@@ -214,7 +216,7 @@ wifiManager.setWifiProfile(wantTemp, profile).then(() => {
## WifiProfile
Represents the WLAN configuration.
Represents the Wi-Fi profile information.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
......
......@@ -116,8 +116,8 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let gallerySync = new cloudSync.GallerySync();
gallerySync.on('progress', (pg: SyncProgress) => {
console.info("syncState: " + pg.syncState);
gallerySync.on('progress', (pg: cloudSync.SyncProgress) => {
console.info("syncState: " + pg.state);
});
```
......@@ -153,8 +153,8 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let gallerySync = new cloudSync.GallerySync();
gallerySync.on('progress', (pg: SyncProgress) => {
console.info("syncState: " + pg.syncState);
gallerySync.on('progress', (pg: cloudSync.SyncProgress) => {
console.info("syncState: " + pg.state);
});
gallerySync.off('progress');
......@@ -194,8 +194,8 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let gallerySync = new cloudSync.GallerySync();
gallerySync.on('progress', (pg: SyncProgress) => {
console.info("syncState: " + pg.syncState);
gallerySync.on('progress', (pg: cloudSync.SyncProgress) => {
console.info("syncState: " + pg.state);
});
gallerySync.start().then(function() {
......@@ -411,7 +411,7 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let download = new cloudSync.Download();
download.on('progress', (pg: DownloadProgress) => {
download.on('progress', (pg: cloudSync.DownloadProgress) => {
console.info("download state: " + pg.state);
});
```
......@@ -448,7 +448,7 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let download = new cloudSync.Download();
download.on('progress', (pg: DownloadProgress) => {
download.on('progress', (pg: cloudSync.DownloadProgress) => {
console.info("download state:" + pg.state);
});
......@@ -481,12 +481,13 @@ Starts to download a cloud file. This API uses a promise to return the result.
```js
let download = new cloudSync.Download();
let uri: string = "file:///media/Photo/1";
download.on('progress', (pg: DownloadProgress) => {
download.on('progress', (pg: cloudSync.DownloadProgress) => {
console.info("download state:" + pg.state);
});
download.start().then(function() {
download.start(uri).then(function() {
console.info("start download successfully");
}).catch(function(err) {
console.info("start download failed with error message: " + err.message + ", error code: " + err.code);
......@@ -538,8 +539,9 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let download = new cloudSync.Download();
let uri: string = "file:///media/Photo/1";
download.start((err) => {
download.start(uri, (err) => {
if (err) {
console.info("start download failed with error message: " + err.message + ", error code: " + err.code);
} else {
......@@ -588,8 +590,9 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let download = new cloudSync.Download();
let uri: string = "file:///media/Photo/1";
download.stop().then(function() {
download.stop(uri).then(function() {
console.info("stop download successfully");
}).catch(function(err) {
console.info("stop download failed with error message: " + err.message + ", error code: " + err.code);
......@@ -631,8 +634,9 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let download = new cloudSync.Download();
let uri: string = "file:///media/Photo/1";
download.stop((err) => {
download.stop(uri, (err) => {
if (err) {
console.info("stop download failed with error message: " + err.message + ", error code: " + err.code);
} else {
......
......@@ -426,7 +426,7 @@ Clears the cloud data locally. This API uses an asynchronous callback to return
| ---------- | ------ | ---- | ---- |
| accountId | string | Yes | Account ID.|
| appActions | object | Yes | Action to take. **bundleName** indicates the application bundle to clear, and [Action](#action) indicates the action to take.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to clear the cloud data locally.|
**Error codes**
......
......@@ -18,15 +18,15 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype';
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| No| Label of the input method subtype.|
| labelId<sup>10+</sup> | string | Yes| No| No| Label ID of the input method subtype.|
| name | string | Yes| No| Yes| Bundle name of the input method.|
| id | string | Yes| No| Yes| ID of the input method subtype.|
| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Yes| Locale of the input method subtype.|
| language | string | Yes| No| Yes| Language of the input method subtype.|
| icon | string | Yes| No| No| Icon of the input method subtype.|
| iconId | number | Yes| No| No| Icon ID of the input method subtype.|
| extra | object | Yes| Yes| No| Extra information of the input method subtype.<br>**NOTE**<br>This parameter is optional since API version 10.|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| Optional. Label of the input method subtype.|
| labelId<sup>10+</sup> | string | Yes| No| Optional. Label ID of the input method subtype.|
| name | string | Yes| No| Mandatory. Bundle name of the input method.|
| id | string | Yes| No| Mandatory. ID of the input method subtype.|
| mode | string | Yes| No| Optional. Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Mandatory. Locale of the input method subtype.|
| language | string | Yes| No| Mandatory. Language of the input method subtype.|
| icon | string | Yes| No| Optional. Icon of the input method subtype. It can be obtained by using **iconId**. This parameter is reserved.|
| iconId | number | Yes| No| Optional. Icon ID of the input method subtype.|
| extra | object | Yes| Yes| Optional. Extra information of the input method subtype. This parameter is reserved and currently has no specific meaning.<br>**NOTE**<br>This parameter is optional since API version 10.|
......@@ -923,6 +923,50 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
});
```
### on('editorAttributeChanged')<sup>10+</sup>
on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void
Enables listening for the edit box attribute change event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | Yes | Callback used to return the edit box attribute change.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().on('editorAttributeChanged', (attr) => {
console.log(`Succeeded in receiving attribute of editor, inputPattern = ${attr.inputPattern}, enterKeyType = ${attr.enterKeyType}`);
});
```
### off('editorAttributeChanged')<sup>10+</sup>
off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void
Cancels listening for the edit box attribute change event.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | No | Callback for the edit box attribute change event. It must correspond to the one in the **on** API.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().off('editorAttributeChanged');
```
## Panel<sup>10+</sup>
In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance.
......
# @ohos.ai.mindSporeLite (Inference)
MindSpore Lite is an AI engine that implements AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition.
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference.
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implement model inference.
> **NOTE**
>
......@@ -48,7 +48,7 @@ Defines the CPU backend device option.
| threadNum | number | Yes | Yes | Number of runtime threads. The default value is **2**. |
| threadAffinityMode | [ThreadAffinityMode](#threadaffinitymode) | Yes | Yes | Affinity mode for binding runtime threads to CPU cores. The default value is **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**.|
| threadAffinityCoreList | number[] | Yes | Yes | List of CPU cores bound to runtime threads. Set this parameter only when **threadAffinityMode** is set. If **threadAffinityMode** is set to **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**, this parameter is empty. The number in the list indicates the SN of the CPU core. The default value is **[]**.|
| precisionMode | string | Yes | Yes | Whether to enable the Float16 inference mode. The value **preferred_fp16** means to enable half-precision inference and the default value **force_fp32** means to disable half-precision inference. Other settings are not supported.|
| precisionMode | string | Yes | Yes | Whether to enable the Float16 inference mode. The value **preferred_fp16** means to enable half-precision inference and the default value **enforce_fp32** means to disable half-precision inference. Other settings are not supported.|
**Float16 inference mode**: a mode that uses half-precision inference. Float16 uses 16 bits to represent a number and therefore it is also called half-precision.
......@@ -125,7 +125,7 @@ Loads the input model from the full path for model inference. This API uses an a
```js
let context: mindSporeLite.Context = {};
let context = {'target': ['cpu']};
context = {'target': ['cpu']};
let model_file = '/path/to/xxx.ms';
mindSporeLite.loadModelFromFile(model_file, context, (result) => {
const modelInputs = result.getInputs();
......@@ -181,16 +181,16 @@ Loads the input model from the memory for inference. This API uses an asynchrono
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => {
this.modelBuffer = buffer;
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, (result) => {
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
```
## mindSporeLite.loadModelFromBuffer
......@@ -213,18 +213,18 @@ Loads the input model from the memory for inference. This API uses an asynchrono
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((error,buffer) => {
this.modelBuffer = buffer;
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
let context: mindSporeLite.Context = {};
context = {'target': ['cpu']};
mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, context, (result) => {
syscontext.resourceManager.getRawFileContent(modelName).then((error,buffer) => {
let modelBuffer = buffer;
let context: mindSporeLite.Context = {};
context = {'target': ['cpu']};
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer, context, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
```
## mindSporeLite.loadModelFromBuffer
......@@ -252,16 +252,16 @@ Loads the input model from the memory for inference. This API uses a promise to
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => {
this.modelBuffer = buffer;
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(model_file).then((result) => {
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer).then((result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
```
## mindSporeLite.loadModelFromFd
......@@ -284,7 +284,7 @@ Loads the input model based on the specified file descriptor for inference. This
```js
import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
mindSporeLite.loadModelFromFd(file.fd, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
......@@ -313,7 +313,7 @@ import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let context : mindSporeLite.Context = {};
context = {'target': ['cpu']};
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
mindSporeLite.loadModelFromFd(file.fd, context, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
......@@ -345,7 +345,7 @@ Loads the input model based on the specified file descriptor for inference. This
```js
import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
let mindSporeLiteModel = await mindSporeLite.loadModelFromFd(file.fd);
mindSporeLite.loadModelFromFd(file.fd).then((result) => {
const modelInputs = result.getInputs();
......@@ -383,9 +383,9 @@ mindSporeLite.loadModelFromFile(model_file).then((result) => {
```
### predict
predict(inputs: MSTensor[], callback: Callback&lt;Model&gt;): void
predict(inputs: MSTensor[], callback: Callback&lt;MSTensor[]&gt;): void
Executes the inference model. This API uses an asynchronous callback to return the result.
Executes the inference model. This API uses an asynchronous callback to return the result. Ensure that the model object is not reclaimed when being invoked.
**System capability**: SystemCapability.AI.MindSporeLite
......@@ -394,20 +394,20 @@ Executes the inference model. This API uses an asynchronous callback to return t
| Name| Type | Mandatory| Description |
| ------ | ----------------------- | ---- | -------------------------- |
| inputs | [MSTensor](#mstensor)[] | Yes | Model input, which is an **MSTensor** object.|
| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.|
| callback | Callback<[MSTensor](#mstensor)[]> | Yes | Callback used to return the result, **MSTensor** object.|
**Example**
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs, (result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -420,7 +420,7 @@ syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
predict(inputs: MSTensor[]): Promise&lt;MSTensor[]&gt;
Executes the inference model. This API uses a promise to return the result.
Executes the inference model. This API uses a promise to return the result. Ensure that the model object is not reclaimed when being invoked.
**System capability**: SystemCapability.AI.MindSporeLite
......@@ -440,14 +440,14 @@ Executes the inference model. This API uses a promise to return the result.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -541,14 +541,14 @@ Obtains tensor data.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -576,15 +576,15 @@ Sets the tensor data.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(inputBuffer.buffer);
})
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
```
## DataType
......
......@@ -482,6 +482,96 @@ Obtains **TagInfo** from **Want**, which is initialized by the NFC service and c
| ------------------- | -------------------------------------------- |
| [TagInfo](#taginfo) | **TagInfo** object obtained.|
## tag.registerForegroundDispatch<sup>10+</sup>
registerForegroundDispatch(elementName: [ElementName](js-apis-bundleManager-elementName.md), discTech: number[], callback: AsyncCallback&lt;[TagInfo](#taginfo)&gt;): void;
Registers listening for the card reading events of an NFC tag foreground application. You can set the supported tag technologies in **discTech**, and obtain the [TagInfo](#taginfo) read in a callback. <br>This API must be used with [tag.unregisterForegroundDispatch](#tagunregisterforegrounddispatch10) in pairs. The registered event listening must be unregistered before the page exits the foreground or the page is destroyed.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | -------- | ---- | ------------------------------------------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Information about the application page. It must contain at least the **bundleName**, **abilityName**, and **moduleName**. |
| discTech | number[] | Yes | Technologies supported by the foreground dispatch system. Each number indicates the constant value of the supported technology. Based on the value of **number**, the system sets tag technologies ([NFC_A](#technology-type-definition), [NFC_B](#technology-type-definition), and [NFC_F](#technology-type-definition), and [NFC_V](#technology-type-definition)) for NFC card read polling and disable card emulation. If the **number** length is 0, both card read polling and card emulation will be disabled.|
| callback | AsyncCallback&lt;[TagInfo](#taginfo)&gt; | Yes | Callback invoked to return the card read event in the foreground.|
**Example**
See the example of [tag.unregisterForegroundDispatch](#tagunregisterforegrounddispatch10).
## tag.unregisterForegroundDispatch<sup>10+</sup>
unregisterForegroundDispatch(elementName: [ElementName](js-apis-bundleManager-elementName.md)): void;
Unregisters the listening for card reading events of an NFC tag foreground application. The registered event listening must be unregistered before the page exits the foreground or the page is destroyed.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | -------- | ---- | ------------------------------------------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Information about the application page. It must contain at least the **bundleName**, **abilityName**, and **moduleName**. |
**Example**
```js
import UIAbility from '@ohos.app.ability.UIAbility'
import tag from '@ohos.nfc.tag';
let elementName = null;
let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability
function foregroundCb(tagInfo: any) {
console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo));
}
export default class MainAbility extends UIAbility {
OnCreate(want, launchParam) {
console.log("OnCreate");
elementName = {
bundleName: want.bundleName,
abilityName: want.abilityName,
moduleName: want.moduleName
}
}
onForeground() {
console.log("onForeground");
try {
tag.registerForegroundDispatch(elementName, discTech, foregroundCb);
} catch (e) {
console.log("registerForegroundDispatch error: " + e.message);
}
}
onBackground() {
console.log("onBackground");
try {
tag.unregisterForegroundDispatch(elementName);
} catch (e) {
console.log("registerForegroundDispatch error: " + e.message);
}
}
onWindowStageDestroy() {
console.log("onWindowStageDestroy");
try {
tag.unregisterForegroundDispatch(elementName);
} catch (e) {
console.log("registerForegroundDispatch error: " + e.message);
}
}
// override other lifecycle functions
}
```
## tag.ndef.makeUriRecord<sup>9+</sup>
......
......@@ -16,7 +16,7 @@ import runningLock from '@ohos.runningLock';
isSupported(type: RunningLockType): boolean;
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result.
Checks whether the specified type of **RunningLock** is supported.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -26,7 +26,7 @@ Checks whether the specified type of **RunningLock** is supported. This API uses
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
**Return Value**
**Return value**
| Type | Description |
| ------- | --------------------------------------- |
......@@ -69,14 +69,6 @@ Creates a **RunningLock** object.
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created. |
| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes | Callback used to return the result. If a lock is successfully created, **err** is **undefined** and **data** is the created **RunningLock**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
| ID | Error Message |
|---------|----------|
| 4900101 | If connecting to the service failed. |
**Example**
```js
......@@ -106,20 +98,12 @@ Creates a **RunningLock** object.
| name | string | Yes | Name of the **RunningLock** object. |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------ | ------------------------------------ |
| Promise&lt;[RunningLock](#runninglock)&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
| ID | Error Message |
|---------|----------|
| 4900101 | If connecting to the service failed. |
**Example**
```js
......@@ -138,7 +122,7 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boo
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9).
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result. This API uses an asynchronous callback to return the result.
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -167,7 +151,7 @@ isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean>
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9).
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result. This API uses a promise to return the result.
Checks whether the specified type of **RunningLock** is supported. This API uses a promise to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -177,7 +161,7 @@ Checks whether the specified type of **RunningLock** is supported. This API uses
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
**Return Value**
**Return value**
| Type | Description |
| ---------------------- | ---------------------------------------------------- |
......@@ -246,7 +230,7 @@ Creates a **RunningLock** object.
| name | string | Yes | Name of the **RunningLock** object. |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------ | ------------------------------------ |
......@@ -354,7 +338,7 @@ Checks the hold status of the **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return Value**
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
......@@ -452,7 +436,7 @@ Checks the hold status of the **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return Value**
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | The value **true** indicates that the **Runninglock** object is held; and the value **false** indicates that the **Runninglock** object is released.|
......@@ -478,5 +462,5 @@ Enumerates the types of **RunningLock** objects.
| Name | Value | Description |
| --------------------------------- | ---- | ------------------------------------------------------------ |
| BACKGROUND<sup>(deprecated)</sup> | 1 | A lock that prevents the system from hibernating when the screen is off.<br>**NOTE**<br>This parameter is supported since API version 7 and deprecated since API version 10.|
| BACKGROUND<sup>(deprecated)</sup> | 1 | A lock that prevents the system from hibernating when the screen is off.<br>**NOTE**<br/>This parameter is supported since API version 7 and deprecated since API version 10.|
| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen. |
......@@ -3,9 +3,9 @@
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md).
>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are no longer maintained since API version 7. You are advised to use profile APIs of [@ohos.bluetooth.ble](js-apis-bluetooth-ble.md).
## Modules to Import
......
......@@ -137,7 +137,7 @@ Checks whether the application has the permission to access the device.
**Example**
```js
let devicesName="1-1";
let devicesName= "1-1";
let bool = usb.hasRight(devicesName);
console.log(bool);
```
......@@ -165,7 +165,7 @@ Requests the temporary permission for the application to access a USB device. Th
**Example**
```js
let devicesName="1-1";
let devicesName= "1-1";
usb.requestRight(devicesName).then((ret) => {
console.log(`requestRight = ${ret}`);
});
......@@ -375,7 +375,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example**
```js
let param = new usb.USBControlParams();
let param = {
request: 0,
reqType: 0,
target:0,
value: 0,
index: 0,
data: null
};
usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`);
})
......@@ -500,7 +507,7 @@ Converts the USB function list in the numeric mask format to a string in Device
**Example**
```js
let funcs = usb.ACM | usb.ECM;
let funcs = usb.FunctionType.ACM | usb.FunctionType.ECM;
let ret = usb.usbFunctionsToString(funcs);
```
......@@ -529,8 +536,12 @@ Sets the current USB function list in Device mode.
**Example**
```js
let funcs = usb.HDC;
let ret = usb.setCurrentFunctions(funcs);
let funcs = usb.FunctionType.HDC;
usb.setCurrentFunctions(funcs).then(() => {
console.info('usb setCurrentFunctions successfully.');
}).catch(err => {
console.error('usb setCurrentFunctions failed: ' + err.code + ' message: ' + err.message);
});
```
## usb.getCurrentFunctions<sup>9+</sup>
......@@ -848,7 +859,7 @@ Enumerates power role types.
| Name | Value | Description |
| ------ | ---- | ---------- |
| NONE | 0 | None |
| NONE | 0 | None. |
| SOURCE | 1 | External power supply.|
| SINK | 2 | Internal power supply.|
......@@ -862,6 +873,6 @@ Enumerates data role types.
| Name | Value | Description |
| ------ | ---- | ------------ |
| NONE | 0 | None |
| NONE | 0 | None. |
| HOST | 1 | USB host.|
| DEVICE | 2 | USB device.|
......@@ -208,7 +208,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100010 | Can not post message using this port. |
### onMessageEventExt<sup>10+</sup>
onMessageEventExt(callback: (result: WebMessageExt) => void): void
......@@ -358,7 +357,7 @@ window.addEventListener('message', function(event) {
h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function(event) {
console.log("hwd In html got message");
// 2. Receive the message sent from the ArkTS side.
// 2. Receive the message sent from the eTS side.
var result = event.data;
console.log("In html got message, typeof: ", typeof(result));
console.log("In html got message, result: ", (result));
......@@ -401,7 +400,7 @@ window.addEventListener('message', function(event) {
}
})
// Use h5Port to send a message of the string type to the ArkTS side.
// Use h5Port to send a message of the string type to the ets side.
function postStringToApp() {
if (h5Port) {
console.log("In html send string message");
......@@ -638,7 +637,7 @@ struct WebComponent {
Button('loadUrl')
.onClick(() => {
try {
// The headers parameter is carried.
// The headers parameter is passed.
this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
......@@ -999,7 +998,7 @@ struct WebComponent {
onActive(): void
Invoked to instruct the **\<Web>** component to enter the foreground, active state.
Invoked to instruct the **\<Web>** component to enter the active foreground state.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -1348,11 +1347,13 @@ HTML file to be loaded:
<html>
<meta charset="utf-8">
<body>
Hello world!
<button type="button" onclick="htmlTest()">Click Me!</button>
<p id="demo"></p>
</body>
<script type="text/javascript">
function htmlTest() {
str = objName.test("test function")
let str=objName.test();
document.getElementById("demo").innerHTML=str;
console.log('objName.test result:'+ str)
}
</script>
......@@ -3866,7 +3867,7 @@ struct WebComponent {
getCertificate(): Promise<Array<cert.X509Cert>>
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -3943,7 +3944,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
//Load an HTTPS website and view the certificate information of the website.
// Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
......@@ -4023,7 +4024,7 @@ struct Index {
getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the website.
**System capability**: SystemCapability.Web.Webview.Core
......@@ -4031,7 +4032,7 @@ Obtains the certificate information of the current website. When the \<Web> comp
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current HTTPS website.|
| callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current website.|
**Error codes**
......@@ -4100,7 +4101,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
//Load an HTTPS website and view the certificate information of the website.
// Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
......@@ -4222,10 +4223,111 @@ struct WebComponent {
}
```
### prefetchPage<sup>10+</sup>
prefetchPage(url: string, additionalHeaders?: Array\<WebHeader>): void
Prefetches resources in the background for a page that is likely to be accessed in the near future, without executing the page JavaScript code or presenting the page. This can significantly reduce the load time for the prefetched page.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------| --------------------------------| ---- | ------------- |
| url | string | Yes | URL to be preloaded.|
| additionalHeaders | Array\<[WebHeader](#webheader)> | No | Additional HTTP headers of the URL.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
| 17100002 | Invalid url. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('prefetchPopularPage')
.onClick(() => {
try {
// Replace 'https://www.example.com' with a real URL for the API to work.
this.controller.prefetchPage('https://www.example.com');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// Replace ''www.example1.com' with a real URL for the API to work.
Web({ src: 'www.example1.com', controller: this.controller })
}
}
}
```
### prepareForPageLoad<sup>10+</sup>
static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void
Preconnects to a URL. This API can be called before the URL is loaded, to resolve the DNS and establish a socket connection, without obtaining the resources.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---------------| ------- | ---- | ------------- |
| url | string | Yes | URL to be preconnected.|
| preconnectable | boolean | Yes | Whether to perform preconnection, which involves DNS resolution and socket connection establishment. The value **true** means to perform preconnection, and **false** means the opposite.|
| numSockets | number | Yes | Number of sockets to be preconnected. The value must be greater than 0. A maximum of six socket connections are allowed.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100002 | Invalid url. |
| 171000013| The number of preconnect sockets is invalid. |
**Example**
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("EntryAbility onCreate")
web_webview.WebviewController.initializeWebEngine()
// Replace 'https://www.example.com' with a real URL for the API to work.
web_webview.WebviewController.prepareForPageLoad("https://www.example.com", true, 2);
globalThis.abilityWant = want
console.log("EntryAbility onCreate done")
}
}
```
## WebCookieManager
Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance.
> **NOTE**
>
> You must load the **\<Web>** component before calling APIs in **WebCookieManager**.
### getCookie
static getCookie(url: string): string
......@@ -4347,7 +4449,6 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call
| -------- | ---------------------- | ---- | :------------------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return whether the cookies are successfully saved.|
**Example**
```ts
......@@ -4688,6 +4789,10 @@ struct WebComponent {
Implements a **WebStorage** object to manage the Web SQL database and HTML5 Web Storage APIs. All **\<Web>** components in an application share a **WebStorage** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebStorage**.
### deleteOrigin
static deleteOrigin(origin : string): void
......@@ -5148,6 +5253,10 @@ struct WebComponent {
Implements a **WebDataBase** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebDataBase**.
### getHttpAuthCredentials
static getHttpAuthCredentials(host: string, realm: string): Array\<string>
......@@ -5326,6 +5435,10 @@ struct WebComponent {
Implements a **GeolocationPermissions** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **GeolocationPermissions**.
### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
......@@ -5739,7 +5852,6 @@ Describes the type of the returned result of script execution using [runJavaScir
| ARRAY_BUFFER | 4 |Raw binary data buffer.|
| ARRAY | 5 |Array type.|
## WebMessageType<sup>10+</sup>
Describes the data type supported by the [webMessagePort](#webmessageport) API.
......@@ -5796,7 +5908,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
### getNumber<sup>10+</sup>
getNumber(): number
......@@ -5841,7 +5952,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer
......@@ -5885,7 +5995,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
## WebMessageExt<sup>10+</sup>
Data object received and sent by the [webMessagePort](#webmessageport) interface.
......@@ -5904,7 +6013,6 @@ Obtains the type of the data object.
| --------------| --------------------------------------------------------- |
| [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.|
### getString<sup>10+</sup>
getString(): string
......@@ -5927,7 +6035,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getNumber<sup>10+</sup>
getNumber(): number
......@@ -5950,7 +6057,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getBoolean<sup>10+</sup>
getBoolean(): boolean
......@@ -5973,7 +6079,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer
......@@ -6039,7 +6144,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
### setType<sup>10+</sup>
setType(type: WebMessageType): void
......@@ -6180,7 +6284,6 @@ Sets the error-object-type data for the data object. For the complete sample cod
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
## WebStorageOrigin
Provides usage information of the Web SQL Database.
......
......@@ -204,4 +204,4 @@ export default {
};
```
![image-animator](figures/image-animator.gif)
![image-animator](figures/image-animator-lite.gif)
......@@ -71,4 +71,4 @@ Not supported
}
```
![image](figures/image.png)
![image](figures/image-lite.png)
......@@ -115,4 +115,4 @@ export default {
}
```
![marquee](figures/marquee.gif)
![marquee](figures/marquee-lite.gif)
......@@ -142,4 +142,4 @@ export default {
}
```
![picker-view](figures/picker-view.png)
![picker-view](figures/picker-view-lite.png)
......@@ -122,4 +122,4 @@ export default {
}
```
![progress](figures/progress.png)
![progress](figures/progress-lite.png)
......@@ -122,4 +122,4 @@ export default {
}
```
![qrcode](figures/qrcode.gif)
![qrcode](figures/qrcode-lite.gif)
......@@ -99,4 +99,4 @@ export default {
}
```
![slider](figures/slider.png)
![slider](figures/slider-lite.png)
......@@ -96,4 +96,4 @@ export default {
}
```
![switch](figures/switch.gif)
![switch](figures/switch-lite.gif)
......@@ -96,4 +96,4 @@ export default {
}
```
![text](figures/text.png)
![text](figures/text-lite.png)
......@@ -120,4 +120,4 @@ export default {
}
```
![list](figures/list.png)
![list](figures/list-lite.png)
......@@ -109,4 +109,4 @@ export default {
}
```
![swiper](figures/swiper.gif)
![swiper](figures/swiper-lite.gif)
......@@ -169,3 +169,41 @@ struct SwipeGestureExample {
```
![ifButton](figures/ifButton.gif)
### Example 3
```ts
// xxx.ets
@Entry
@Component
struct buttonTestDemo {
@State txt: string = 'overflowTextOverlengthTextOverflow.Clip';
@State widthShortSize: number = 200;
build() {
Row() {
Column() {
Button(this.txt)
.width(this.widthShortSize)
.height(100)
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1,
minFontSize: 20,
maxFontSize: 20,
font: {
size: 20,
weight: FontWeight.Bolder,
family: 'cursive',
style: FontStyle.Italic
}
})
.fontSize(40)
}
.width('100%')
}
.height('100%')
}
}
```
![image-20230711171138661](figures/imageButtonLabelStyle.png)
......@@ -41,7 +41,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
| Name | Description |
| -------------------------------------------- | ------------------------------------------------------------ |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets. |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets.|
## MarkStyle<sup>10+</sup>
......@@ -53,6 +53,8 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
## Example
### Example 1
```ts
// xxx.ets
@Entry
......@@ -80,3 +82,51 @@ struct CheckboxExample {
![](figures/checkbox.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
.mark({
strokeColor:Color.Black,
size: 50,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox2').fontSize(20)
}
}
.width('100%')
}
.height('100%')
}
}
```
![](figures/checkbox2.gif)
......@@ -42,7 +42,7 @@ Creates a **FormComponent** instance to display the provided widget.
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ----------------------------------------------------------------------- |
| id | number | Yes | Widget ID. Set this parameter to **0** for a new widget. |
| id | number | Yes | Widget ID. Set this parameter to **0** for a new widget.<br>**NOTE**<br>Different widget hosts cannot use the same ID.<br>If a widget host uses the same ID for two widgets, the one added later is displayed. |
| name | string | Yes | Widget name. |
| bundle | string | Yes | Bundle name of the widget. |
| ability | string | Yes | Ability name of the widget. |
......
......@@ -68,7 +68,7 @@ struct GaugeExample {
// Set the value parameter to 75 and the value attribute to 25. The attribute setting is used.
Gauge({ value: 75 })
.value(25) // If both the attribute and parameter are set, the parameter setting is used.
.value(25) // If both the attribute and parameter are set, the attribute setting is used.
.width(200).height(200)
.colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]])
......
......@@ -45,13 +45,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| showSideBar | boolean | Whether to display the sidebar.<br>Default value: **true**<br>Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.|
| controlButton | [ButtonStyle](#buttonstyle) | Attributes of the sidebar control button.|
| showControlButton | boolean | Whether to display the sidebar control button.<br>Default value: **true**|
| sideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.<br>The width of the sidebar, whether it is specified or kept at the default, takes precedence over that of the sidebar child components.|
| minSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Minimum width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>When set, the minimum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the minimum width of the sidebar child component takes precedence.|
| maxSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Maximum width of the sidebar.<br>Default value: **280vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>When set, the maximum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the maximum width of the sidebar child component takes precedence.|
| sideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.<br>The width of the sidebar, whether it is specified or kept at the default value, takes precedence over that of the sidebar child components.|
| minSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Minimum width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>**minSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **minWidth** of the sidebar child components.|
| maxSideBarWidth | number \| [Length](ts-types.md#length)<sup>9+</sup> | Maximum width of the sidebar.<br>Default value: **280vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.<br>**maxSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **maxWidth** of the sidebar child components.|
| autoHide<sup>9+</sup> | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.<br>Default value: **true**<br>**NOTE**<br>The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.<br>Whether the sidebar should be hidden is determined when it is being dragged. When its width is less than the minimum width, the damping effect is required to trigger hiding (a distance out of range).|
| sideBarPosition<sup>9+</sup> | [SideBarPosition](#sidebarposition9) | Position of the sidebar.<br>Default value: **SideBarPosition.Start**|
| divider<sup>10+</sup> | [DividerStyle](#dividerstyle10) \| null | Divider style.<br>- **DividerStyle** (default): The divider is displayed.<br>- **null**: The divider is not displayed.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the content area of the sidebar container.<br>Default value: **360vp**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.<br>In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk until it is 0 vp large.<br>minContentWidth takes precedence over maxSideBarWidth and sideBarWidth of the sidebar. If minContentWidth is not set, the priority of the default value is lower than that of minSideBarWidth and maxSideBarWidth.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the content area of the sidebar container.<br>Default value: **360vp**<br>Unit: vp<br>**NOTE**<br>If this attribute is set to a value less than 0, the default value is used. If this attribute is not set, the value **0vp** is used.<br>In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk, with the content clipped, until it is 0 vp large.<br>**minContentWidth**, whether it is specified or kept at the default value, takes precedence over **minSideBarWidth** and **sideBarWidth** of the sidebar. |
## ButtonStyle
......@@ -83,7 +83,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
> The settings of the [universal size attributes](ts-universal-attributes-size.md) **width** and **height** do not take effect for the sidebar child component.
> The settings do not take effect for the sidebar content area either. By default, the sidebar content area takes up the remaining space of the sidebar container.
>
> If the attribute method is not used, the sidebar is displayed depending on the size.
> If the **showSideBar** attribute is not set, the sidebar's visibility is subject to its size.
>
> - If the size is less than 520 vp, the sidebar is not displayed by default.
> - If the size is greater than or equal to 520 vp, the sidebar is displayed by default.
......@@ -127,8 +127,6 @@ struct SideBarContainerExample {
}.width('100%')
.justifyContent(FlexAlign.SpaceEvenly)
.backgroundColor('#19000000')
Column() {
Text('SideBarContainer content text1').fontSize(25)
Text('SideBarContainer content text2').fontSize(25)
......@@ -148,6 +146,7 @@ struct SideBarContainerExample {
.onChange((value: boolean) => {
console.info('status:' + value)
})
.divider({strokeWidth: '1vp', color: Color.Gray, startMargin: '4vp', endMargin: '4vp'})
}
}
```
......
......@@ -22,7 +22,7 @@ Defines and shows the action sheet.
| ---------- | -------------------------- | ------- | ----------------------------- |
| title | [Resource](ts-types.md#resource) \| string | Yes | Title of the dialog box.|
| message | [Resource](ts-types.md#resource) \| string | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**|
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**<br>The value **true** means to close the dialog box when the overlay is clicked, and **false** means the opposite.|
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>action: () =&gt; void<br>} | No | Text content of the confirm button and callback upon button clicking.<br>Default value:<br>**value**: button text.<br>**action**: callback upon button clicking.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Bottom**|
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册