提交 1c9674f6 编写于 作者: A Annie_wang

Merge branch 'OpenHarmony-3.1-Release' of gitee.com:Annie_wang/docs into OpenHarmony-3.1-Release

......@@ -93,7 +93,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
1. Obtain the USB device list.
```
```js
// Import the USB API package.
import usb from '@ohos.usb';
// Obtain the USB device list.
......@@ -153,7 +153,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
2. Obtain the device operation permissions.
```
```js
var deviceName = deviceList[0].name;
// Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => {
......@@ -165,7 +165,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
3. Open the device.
```
```js
// Open the device, and obtain the USB device pipe for data transfer.
var pipe = usb.connectDevice(deviceList[0]);
/*
......@@ -177,7 +177,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
4. Perform data transfer.
```
```js
/*
Read data. Select the corresponding RX endpoint from deviceList for data transfer.
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
......@@ -208,7 +208,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
5. Release the USB interface, and close the USB device.
```
```js
usb.releaseInterface(pipe, interface);
usb.closePipe(pipe);
```
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import account_appAccount from '@ohos.account.appAccount';
```
......@@ -25,7 +25,7 @@ Creates an **AppAccountManager** instance.
| AppAccountManager | **AppAccountManager** instance created.|
**Example**
```
```js
var appAccountManager = account.createAppAccountManager();
```
......@@ -50,7 +50,7 @@ Adds an app account to the account management service. This method uses an async
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("WangWu", (err) => {
console.log("addAccount err: " + JSON.stringify(err));
......@@ -75,7 +75,7 @@ Adds an app account and its additional information to the account management ser
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101", (err) => {
console.log("addAccount err: " + JSON.stringify(err));
......@@ -107,7 +107,7 @@ Adds an app account and its additional information to the account management ser
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101").then(()=> {
console.log('addAccount Success');
......@@ -135,7 +135,7 @@ Implicitly adds an app account based on the specified account owner, authenticat
**Example**
```
```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) {
......@@ -174,7 +174,7 @@ Deletes an app account from the account management service. This method uses an
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu", (err) => {
console.log("deleteAccount err: " + JSON.stringify(err));
......@@ -203,7 +203,7 @@ Deletes an app account from the account management service. This method uses a p
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu").then(() => {
console.log('deleteAccount Success');
......@@ -230,7 +230,7 @@ Disables an app account from accessing an application with the given bundle name
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("disableAppAccess err: " + JSON.stringify(err));
......@@ -260,7 +260,7 @@ Disables an app account from accessing an application with the given bundle name
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('disableAppAccess Success');
......@@ -287,7 +287,7 @@ Enables an app account to access an application with the given bundle name. This
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("enableAppAccess: " + JSON.stringify(err));
......@@ -317,7 +317,7 @@ Enables an app account to access an application with the given bundle name. This
**Example**
```
```js
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success');
}).catch((err) => {
......@@ -344,7 +344,7 @@ Checks whether an app account allows application data synchronization. This meth
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
......@@ -376,7 +376,7 @@ Checks whether an app account allows application data synchronization. This meth
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data);
......@@ -404,7 +404,7 @@ Sets a credential for an app account. This method uses an asynchronous callback
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
console.log("setAccountCredential err: " + JSON.stringify(err));
......@@ -435,7 +435,7 @@ Sets a credential for an app account. This method uses a promise to return the r
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
console.log('setAccountCredential Success');
......@@ -462,7 +462,7 @@ Sets additional information for an app account. This method uses an asynchronous
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(err));
......@@ -492,7 +492,7 @@ Sets additional information for an app account. This method uses a promise to re
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
console.log('setAccountExtraInfo Success');
......@@ -521,7 +521,7 @@ Sets whether to enable application data synchronization for an app account. This
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
......@@ -553,7 +553,7 @@ Sets whether to enable application data synchronization for an app account. This
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
console.log('setAppAccountSyncEnable Success');
......@@ -581,7 +581,7 @@ Sets data to be associated with an app account. This method uses an asynchronous
**Example**
```
```js
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err));
});
......@@ -611,7 +611,7 @@ Sets data to be associated with an app account. This method uses a promise to re
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
console.log('setAssociatedData Success');
......@@ -638,7 +638,7 @@ Obtains the credential of an app account. This method uses an asynchronous callb
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
console.log("getAccountCredential err: " + JSON.stringify(err));
......@@ -669,7 +669,7 @@ Obtains the credential of an app account. This method uses a promise to return t
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
console.log('getAccountCredential, result: ' + data);
......@@ -695,7 +695,7 @@ Obtains additional information of an app account. This method uses an asynchrono
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err));
......@@ -725,7 +725,7 @@ Obtains additional information of an app account. This method uses a promise to
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
console.log('getAccountExtraInfo, result: ' + data);
......@@ -752,7 +752,7 @@ Obtains data associated with an app account. This method uses an asynchronous ca
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
console.log("getAssociatedData err: " + JSON.stringify(err));
......@@ -783,7 +783,7 @@ Obtains data associated with an app account. This method uses a promise to retur
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
console.log('getAssociatedData: ' + data);
......@@ -810,7 +810,7 @@ Obtains information about all accessible app accounts. This method uses an async
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
......@@ -836,7 +836,7 @@ Obtains information about all accessible app accounts. This method uses an async
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data);
......@@ -864,7 +864,7 @@ Obtains information about all app accounts of the specified app. This method use
**Example**
```
```js
const appAccountManager = account.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
......@@ -897,7 +897,7 @@ Obtains information about all app accounts of the specified app. This method use
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle).then((data) => {
......@@ -925,7 +925,7 @@ Subscribes to the account change event of the specified account owners. This met
**Example**
```
```js
const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
......@@ -955,7 +955,7 @@ Unsubscribes from the account change event. This method uses an asynchronous cal
**Example**
```
```js
const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
......@@ -991,7 +991,7 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok
**Example**
```
```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) {
......@@ -1032,7 +1032,7 @@ Obtains the OAuth access token of an app account based on the specified authenti
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err));
......@@ -1064,7 +1064,7 @@ Obtains the OAuth access token of an app account based on the specified authenti
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthToken token: ' + data);
......@@ -1092,7 +1092,7 @@ Sets an OAuth access token for an app account. This method uses an asynchronous
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
......@@ -1123,7 +1123,7 @@ Sets an OAuth access token for an app account. This method uses a promise to ret
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
console.log('setOAuthToken successfully');
......@@ -1152,7 +1152,7 @@ Deletes the specified OAuth access token for an app account. This method uses an
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err));
......@@ -1184,7 +1184,7 @@ Deletes the specified OAuth access token for an app account. This method uses a
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully');
......@@ -1213,7 +1213,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
......@@ -1245,7 +1245,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully');
......@@ -1273,7 +1273,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
......@@ -1305,7 +1305,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data);
......@@ -1332,7 +1332,7 @@ Obtains information about all OAuth access tokens of an app account visible to t
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err));
......@@ -1363,7 +1363,7 @@ Obtains information about all OAuth access tokens of an app account visible to t
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
......@@ -1390,7 +1390,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err));
......@@ -1421,7 +1421,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data));
......@@ -1447,7 +1447,7 @@ Obtains the authenticator callback for a session. This method uses an asynchrono
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
......@@ -1487,7 +1487,7 @@ Obtains the authenticator callback for a session. This method uses a promise to
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
......@@ -1522,7 +1522,7 @@ Obtains authenticator information of an app account. This method uses an asynchr
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
......@@ -1552,7 +1552,7 @@ Obtains authenticator information of an app account. This method uses a promise
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
......@@ -1663,7 +1663,7 @@ Called back to send the authentication result.
**Example**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
......@@ -1692,7 +1692,7 @@ Called back to redirect an authentication request.
**Example**
```
```js
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
......@@ -1749,7 +1749,7 @@ Authenticates an app account to obtain the OAuth access token. This method uses
**Example**
```
```js
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import account_distributedAccount from '@ohos.account.distributedAccount';
```
......@@ -28,7 +28,7 @@ Obtains a **DistributedAccountAbility** instance.
| [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.|
- Example
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
```
......@@ -50,7 +50,7 @@ Obtains distributed account information. This method uses an asynchronous callba
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.|
- Example
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
......@@ -73,7 +73,7 @@ Obtains distributed account information. This method uses a promise to return th
| Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.|
- Example
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name);
......@@ -98,7 +98,7 @@ Updates distributed account information. This method uses an asynchronous callba
| callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.|
- Example
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
......@@ -125,7 +125,7 @@ Updates distributed account information. This method uses a promise to return th
| Promise<void> | Promise used to return the result.|
- Example
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
......
# USB Usage Demo<a name="EN-US_TOPIC_0000001092792986"></a>
```
```cpp
#include <cstdio>
#include <iostream>
#include <map>
......
......@@ -7,40 +7,40 @@ The following procedure uses bulk transfer as an example.
1. Obtain a USB service instance.
```
```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
```
2. Obtain the USB device list.
```
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
3. Apply for device access permissions.
```
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
4. Open the USB device.
```
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
5. Configure the USB interface.
```
```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true);
**interface** indicates an interface of the USB device in **deviceList**.
```
6. Transfer data.
```
```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
- **pipe** indicates the pipe for data transfer of the USB device opened.
......@@ -50,6 +50,6 @@ srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
7. Close the USB device.
```
```cpp
ret = g_usbClient.Close(pip);
```
......@@ -38,7 +38,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
1. 获取设备列表。
```
```js
// 导入usb接口api包。
import usb from '@ohos.usb';
// 获取设备列表。
......@@ -97,7 +97,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
```
2. 获取设备操作权限。
```
```js
var deviceName = deviceList[0].name;
// 申请操作指定的device的操作权限。
usb.requestRight(deviceName).then(hasRight => {
......@@ -108,7 +108,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
```
3. 打开Device设备。
```
```js
// 打开设备,获取数据传输通道。
var pipe = usb.connectDevice(deviceList[0]);
/*
......@@ -119,7 +119,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
```
4. 数据传输。
```
```js
/*
读取数据,在device信息中选取对应数据接收的endpoint来做数据传输
(endpoint.direction == 0x80);dataUint8Array是要读取的数据,类型为Uint8Array。
......@@ -149,7 +149,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
```
5. 释放接口,关闭设备。
```
```js
usb.releaseInterface(pipe, interface1);
usb.closePipe(pipe);
```
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import account_appAccount from '@ohos.account.appAccount';
```
......@@ -25,7 +25,7 @@ createAppAccountManager(): AppAccountManager
| AppAccountManager | 获取应用帐号模块的实例。 |
**示例:**
```
```js
var appAccountManager = account.createAppAccountManager();
```
......@@ -50,7 +50,7 @@ addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("WangWu", (err) => {
console.log("addAccount err: " + JSON.stringify(err));
......@@ -75,7 +75,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;)
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101", (err) => {
console.log("addAccount err: " + JSON.stringify(err));
......@@ -107,7 +107,7 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101").then(()=> {
console.log('addAccount Success');
......@@ -135,7 +135,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
**示例:**
```
```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) {
......@@ -174,7 +174,7 @@ deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu", (err) => {
console.log("deleteAccount err: " + JSON.stringify(err));
......@@ -203,7 +203,7 @@ deleteAccount(name: string): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu").then(() => {
console.log('deleteAccount Success');
......@@ -230,7 +230,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;vo
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("disableAppAccess err: " + JSON.stringify(err));
......@@ -260,7 +260,7 @@ disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('disableAppAccess Success');
......@@ -287,7 +287,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;voi
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("enableAppAccess: " + JSON.stringify(err));
......@@ -317,7 +317,7 @@ enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**示例:**
```
```js
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success');
}).catch((err) => {
......@@ -344,7 +344,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;):
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
......@@ -376,7 +376,7 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data);
......@@ -404,7 +404,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
console.log("setAccountCredential err: " + JSON.stringify(err));
......@@ -435,7 +435,7 @@ setAccountCredential(name: string, credentialType: string, credential: string):
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
console.log('setAccountCredential Success');
......@@ -462,7 +462,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(err));
......@@ -492,7 +492,7 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
console.log('setAccountExtraInfo Success');
......@@ -521,7 +521,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
......@@ -553,7 +553,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
console.log('setAppAccountSyncEnable Success');
......@@ -581,7 +581,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
**示例:**
```
```js
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err));
});
......@@ -611,7 +611,7 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
console.log('setAssociatedData Success');
......@@ -638,7 +638,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
console.log("getAccountCredential err: " + JSON.stringify(err));
......@@ -669,7 +669,7 @@ getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
console.log('getAccountCredential, result: ' + data);
......@@ -695,7 +695,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err));
......@@ -725,7 +725,7 @@ getAccountExtraInfo(name: string): Promise&lt;string&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
console.log('getAccountExtraInfo, result: ' + data);
......@@ -752,7 +752,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&g
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
console.log("getAssociatedData err: " + JSON.stringify(err));
......@@ -783,7 +783,7 @@ getAssociatedData(name: string, key: string): Promise&lt;string&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
console.log('getAssociatedData: ' + data);
......@@ -810,7 +810,7 @@ getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
......@@ -836,7 +836,7 @@ getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data);
......@@ -864,7 +864,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo
**示例:**
```
```js
const appAccountManager = account.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
......@@ -897,7 +897,7 @@ getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle).then((data) => {
......@@ -925,7 +925,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A
**示例:**
```
```js
const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
......@@ -955,7 +955,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
**示例:**
```
```js
const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
......@@ -991,7 +991,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
**示例:**
```
```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) {
......@@ -1032,7 +1032,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err));
......@@ -1064,7 +1064,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthToken token: ' + data);
......@@ -1092,7 +1092,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
......@@ -1123,7 +1123,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
console.log('setOAuthToken successfully');
......@@ -1152,7 +1152,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err));
......@@ -1184,7 +1184,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully');
......@@ -1213,7 +1213,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
......@@ -1245,7 +1245,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully');
......@@ -1273,7 +1273,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
......@@ -1305,7 +1305,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data);
......@@ -1332,7 +1332,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err));
......@@ -1363,7 +1363,7 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
......@@ -1390,7 +1390,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err));
......@@ -1421,7 +1421,7 @@ getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data));
......@@ -1447,7 +1447,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
......@@ -1487,7 +1487,7 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
......@@ -1522,7 +1522,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
......@@ -1552,7 +1552,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
......@@ -1663,7 +1663,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void
**示例:**
```
```js
const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
......@@ -1692,7 +1692,7 @@ onRequestRedirected: (request: Want) =&gt; void
**示例:**
```
```js
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
......@@ -1749,7 +1749,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options:
**示例:**
```
```js
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
......
......@@ -8,7 +8,7 @@
## 导入模块
```
```js
import bluetooth from '@ohos.bluetooth';
```
......
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import account_distributedAccount from '@ohos.account.distributedAccount';
```
......@@ -28,7 +28,7 @@ getDistributedAccountAbility(): DistributedAccountAbility
| [DistributedAccountAbility](#distributedaccountability) | 返回一个实例,实例提供查询和更新分布式帐号登录状态方法。 |
- 示例:
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
```
......@@ -50,7 +50,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): v
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | 是 | 获取分布式帐号信息的回调。 |
- 示例:
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
......@@ -73,7 +73,7 @@ queryOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt;
| Promise&lt;[DistributedInfo](#distributedinfo)&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name);
......@@ -98,7 +98,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall
| callback | AsyncCallback&lt;void&gt; | 是 | 更新分布式帐号信息的回调。 |
- 示例:
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
......@@ -125,7 +125,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
```
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
......
......@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController
| [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 |
- 示例
```
```js
var InputMethodController = inputMethod.getInputMethodController();
```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
......@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting
- 示例
```
```js
var InputMethodSetting = inputMethod.getInputMethodSetting();
```
......@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
- 示例
```
```js
InputMethodController.stopInput((error)=>{
console.info('stopInput');
});
......@@ -113,7 +113,7 @@ stopInput(): Promise&lt;boolean&gt;
- 示例
```
```js
var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess);
```
......@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 |
- 示例
```
```js
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
......@@ -159,7 +159,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 |
- 示例
```
```js
var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
......@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
- 示例
```
```js
InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called');
});
......@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| Promise&lt;void&gt; | 回调函数。 |
- 示例
```
```js
InputMethodSetting.displayOptionalInputMethod();
```
\ No newline at end of file
......@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine
- 示例
```
```js
var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
```
......@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate
- 示例
```
```js
var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
```
......@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
- 示例:
```
```js
InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
KeyboardController = kbController;
TextInputClient = textInputClient;
......@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
- 示例:
```
```js
InputMethodEngine.off('inputStart');
```
......@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
- 示例:
```
```js
InputMethodEngine.on('keyboardShow', (err) => {
console.info('keyboardShow');
});
......@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
- 示例:
```
```js
InputMethodEngine.off('keyboardShow');
```
......@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
- 示例:
```
```js
KeyboardDelegate.on('keyDown', (event) => {
console.info('keyDown');
});
......@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
- 示例:
```
```js
KeyboardDelegate.off('keyDown');
```
......@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
- 示例:
```
```js
KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info('cursorContextChange');
});
......@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
- 示例:
```
```js
KeyboardDelegate.off('cursorContextChange');
```
### on('selectionChange')
......@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
- 示例:
```
```js
KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info('selectionChange');
});
......@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
- 示例:
```
```js
KeyboardDelegate.off('selectionChange');
```
......@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void
- 示例:
```
```js
KeyboardDelegate.on('textChange', (text) => {
console.info('textChange');
});
......@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
- 示例:
```
```js
KeyboardDelegate.off('textChange');
```
......@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
- 示例
```
```js
KeyboardController.hideKeyboard(()=>{
});
```
......@@ -408,7 +408,7 @@ hideKeyboard(): Promise&lt;void&gt;
- 示例
```
```js
KeyboardController.hideKeyboard();
```
......@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例
```
```js
TextInputClient.getForward(5,(text) =>{
console.info("text = " + text);
});
......@@ -458,7 +458,7 @@ getForward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 |
- 示例
```
```js
var text = TextInputClient.getForward(5);
console.info("text = " + text);
```
......@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例
```
```js
TextInputClient.getBackward(5,(text)=>{
console.info("text = " + text);
});
......@@ -505,7 +505,7 @@ getBackward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 |
- 示例
```
```js
var text = TextInputClient.getBackward(5);
console.info("text = " + text);
```
......@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例
```
```js
TextInputClient.deleteForward(5,(isSuccess)=>{
console.info("isSuccess = " + isSuccess);
});
......@@ -551,7 +551,7 @@ deleteForward(length:number): Promise&lt;boolean&gt;
| Promise&lt;boolean&gt; | 操作成功与否。 |
- 示例
```
```js
var isSuccess = TextInputClient.deleteForward(5);
console.info("isSuccess = " + isSuccess);
```
......@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例
```
```js
TextInputClient.deleteBackward(5, (isSuccess)=>{
console.info("isSuccess = " + isSuccess);
});
......@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
- 示例
```
```js
var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess);
```
......@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例
```
```js
TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
console.info("isSuccess = " + isSuccess);
});
......@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
- 示例
```
```js
var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
console.info("isSuccess = " + isSuccess);
```
......@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例
```
```js
TextInputClient.insertText("test", (isSuccess)=>{
console.info("isSuccess = " + isSuccess);
});
......@@ -691,7 +691,7 @@ insertText(text:string): Promise&lt;boolean&gt;
- 示例
```
```js
var isSuccess = TextInputClient.insertText("test");
console.info("isSuccess = " + isSuccess);
```
......@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 编辑框属性值。 |
- 示例
```
```js
TextInputClient.getEditorAttribute((EditorAttribute)=>{
});
```
......@@ -729,7 +729,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
| Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | 返回编辑框属性值。 |
- 示例
```
```js
var EditorAttribute = TextInputClient.getEditorAttribute();
```
......
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import account_osAccount from '@ohos.account.osAccount';
```
......@@ -24,7 +24,7 @@ getAccountManager(): AccountManager
| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 |
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
```
......@@ -64,7 +64,7 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**示例:**激活ID为100的系统帐号
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.activateOsAccount(localId, (err)=>{
......@@ -97,7 +97,7 @@ activateOsAccount(localId: number): Promise&lt;void&gt;
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**激活ID为100的系统帐号
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.activateOsAccount(localId).then(() => {
......@@ -123,7 +123,7 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => {
console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
......@@ -147,7 +147,7 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled) => {
console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
......@@ -175,7 +175,7 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi
**示例:**判断ID为100的系统帐号是否处于激活状态
```
```js
const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
......@@ -208,7 +208,7 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt;
**示例:**判断ID为100的系统帐号是否处于激活状态
```
```js
const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId).then((isActive) => {
......@@ -238,7 +238,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{
......@@ -272,7 +272,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boo
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => {
......@@ -298,7 +298,7 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTest) => {
console.log("isTestOsAccount err: " + JSON.stringify(err));
......@@ -322,7 +322,7 @@ isTestOsAccount(): Promise&lt;boolean&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTest) => {
console.log('isTestOsAccount, isTest: ' + isTest);
......@@ -347,7 +347,7 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err));
......@@ -374,7 +374,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err));
......@@ -406,7 +406,7 @@ isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified().then((isVerified) => {
console.log('isOsAccountVerified, isVerified: ' + isVerified);
......@@ -436,7 +436,7 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
......@@ -473,7 +473,7 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
......@@ -510,7 +510,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
**示例:**给ID为100的系统帐号设置禁止使用wifi的约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{
......@@ -546,7 +546,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
**示例:**删除ID为100的系统帐号的禁止使用wifi的约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => {
......@@ -578,7 +578,7 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;
**示例:**将ID为100的系统帐号的帐号名设置成demoName
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var newName = "demoName";
......@@ -614,7 +614,7 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
**示例:**将ID为100的系统帐号的帐号名设置成demoName
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var nameLimit = "demoName";
......@@ -643,7 +643,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
console.log("obtains the number of all os accounts created err:" + JSON.stringify(err));
......@@ -669,7 +669,7 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
......@@ -694,7 +694,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
......@@ -718,7 +718,7 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
......@@ -744,7 +744,7 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;):
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID
```
```js
const accountManager = account_osAccount.getAccountManager();
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
......@@ -775,7 +775,7 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID
```
```js
const accountManager = account_osAccount.getAccountManager();
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
......@@ -804,7 +804,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
**示例:**
```
```js
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
......@@ -837,7 +837,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
......@@ -865,7 +865,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err));
......@@ -891,7 +891,7 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
......@@ -919,7 +919,7 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;
**示例:**获取ID为100的系统帐号的全部约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
......@@ -952,7 +952,7 @@ getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
**示例:**获取ID为100的系统帐号的全部约束
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
......@@ -980,7 +980,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err));
......@@ -1006,7 +1006,7 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
......@@ -1031,7 +1031,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;):
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err, idArray)=>{
console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err));
......@@ -1058,7 +1058,7 @@ queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
......@@ -1089,7 +1089,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.log("createOsAccount err:" + JSON.stringify(err));
......@@ -1124,7 +1124,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
......@@ -1155,7 +1155,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
......@@ -1191,7 +1191,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
......@@ -1219,7 +1219,7 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
console.log("queryCurrentOsAccount err:" + JSON.stringify(err));
......@@ -1245,7 +1245,7 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo) => {
console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo));
......@@ -1275,7 +1275,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;
**示例:**查询ID为100的系统帐号信息
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
......@@ -1310,7 +1310,7 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
**示例:**查询ID为100的系统帐号信息
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.queryOsAccountById(localId).then((accountInfo) => {
......@@ -1336,7 +1336,7 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err, accountType) => {
console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
......@@ -1360,7 +1360,7 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
......@@ -1387,7 +1387,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
......@@ -1413,7 +1413,7 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt;
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
......@@ -1443,7 +1443,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;)
**示例:**获取ID为100的系统帐号的头像
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
......@@ -1478,7 +1478,7 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
**示例:**获取ID为100的系统帐号的头像
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
......@@ -1510,7 +1510,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
**示例:**给ID为100的系统帐号设置头像
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
......@@ -1549,7 +1549,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
**示例:**给ID为100的系统帐号设置头像
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
......@@ -1580,7 +1580,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&
**示例:**查询与SN码12345关联的系统帐号的ID
```
```js
const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
......@@ -1611,7 +1611,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
**示例:**查询与SN码12345关联的系统帐号的ID
```
```js
const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
......@@ -1638,7 +1638,7 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;nu
**示例:**获取ID为100的系统帐号关联的SN码
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
......@@ -1669,7 +1669,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
**示例:**获取ID为100的系统帐号关联的SN码
```
```js
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
......@@ -1701,7 +1701,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
function onCallback(receiveLocalId){
console.log("receive localId:" + receiveLocalId);
......@@ -1731,7 +1731,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
**示例:**
```
```js
const accountManager = account_osAccount.getAccountManager();
function offCallback(){
console.log("off enter")
......
......@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("content");
```
......@@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData
**示例**
```
```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html);
```
......@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData
**示例**
```
```js
var object = {
bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility"
......@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData
**示例**
```
```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
```
......@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord
**示例**
```
```js
var record = pasteboard.createPlainTextRecord("hello");
```
......@@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord
**示例**
```
```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html);
```
......@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord
**示例**
```
```js
var object = {
bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility"
......@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord
**示例**
```
```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
```
......@@ -284,7 +284,7 @@ convertToText(): Promise&lt;string&gt;
**示例**
```
```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => {
console.info('convertToText success data : ' + JSON.stringify(data));
......@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void
**示例**
```
```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => {
if (err) {
......@@ -346,7 +346,7 @@ getPrimaryText(): string
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var plainText = pasteData.getPrimaryText();
```
......@@ -367,7 +367,7 @@ getPrimaryHtml(): string
**示例**
```
```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml();
......@@ -389,7 +389,7 @@ getPrimaryWant(): Want
**示例**
```
```js
var object = {
bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility"
......@@ -414,7 +414,7 @@ getPrimaryUri(): string
**示例**
```
```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri();
```
......@@ -437,7 +437,7 @@ addTextRecord(text: string): void
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addTextRecord("good");
```
......@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
pasteData.addHtmlRecord(html);
......@@ -484,7 +484,7 @@ addWantRecord(want: Want): void
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var object = {
bundleName: "com.example.aafwk.test",
......@@ -511,7 +511,7 @@ addUriRecord(uri: string): void
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt");
```
......@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void
**示例**
```
```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var textRecord = pasteboard.createPlainTextRecord("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
......@@ -559,7 +559,7 @@ getMimeTypes(): Array&lt;string&gt;
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes();
```
......@@ -580,7 +580,7 @@ getPrimaryMimeType(): string
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType();
```
......@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var property = pasteData.getProperty();
```
......@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteData.getRecordAt(0);
```
......@@ -648,7 +648,7 @@ getRecordCount(): number
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount();
```
......@@ -669,7 +669,7 @@ getTag(): string
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var tag = pasteData.getTag();
```
......@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
```
......@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var isRemove = pasteData.removeRecordAt(0);
```
......@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
var isReplace = pasteData.replaceRecordAt(0, record);
......@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard
**示例**
```
```js
var systemPasteboard = pasteboard.getSystemPasteboard();
```
......@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (error, data) => {
......@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise&lt;void&gt;
**示例**
```
```js
var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => {
......@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void
**示例**
```
```js
var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((error, pasteData) => {
if (error) {
......@@ -886,7 +886,7 @@ getPasteData(): Promise&lt;PasteData&gt;
**示例**
```
```js
var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText();
......@@ -912,7 +912,7 @@ on(type: 'update', callback: () =&gt;void ): void
**示例**
```
```js
var systemPasteboard = pasteboard.getSystemPasteboard();
var listener = ()=>{
console.info('The system pasteboard has changed');
......@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =&gt;void ): void
**示例**
```
```js
systemPasteboard.off('update', listener);
```
......@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void
**示例**
```
```js
systemPasteboard.hasPasteData((err, data) => {
if (err) {
console.error('failed to hasPasteData because ' + JSON.stringify(err));
......@@ -983,7 +983,7 @@ hasPasteData(): Promise&lt;boolean&gt;
**示例**
```
```js
systemPasteboard.hasPasteData().then((data) => {
console.info('success hasPasteData : ' + JSON.stringify(data));
}).catch((error) => {
......@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void
**示例**
```
```js
systemPasteboard.clear((err, data) => {
if (err) {
console.error('failed to clear because ' + JSON.stringify(err));
......@@ -1034,7 +1034,7 @@ clear(): Promise&lt;void&gt;
**示例**
```
```js
systemPasteboard.clear().then((data) => {
console.info('success clear');
}).catch((error) => {
......
......@@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise&lt;UploadTask&gt;
- 示例:
```
```js
request.upload({ url: 'https://patch' }).then((data) => {
uploadTask = data;
}).catch((err) => {
......@@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void
- 示例:
```
```js
request.upload({ url: 'https://patch' }, (err, data) => {
if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
......@@ -142,14 +142,14 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; vo
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
- 示例:
```
```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
}
......@@ -175,13 +175,13 @@ on(type: 'headerReceive', callback: (header: object) =&gt; void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP&nbsp;Response&nbsp;Header。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP&nbsp;Response&nbsp;Header。 |
- 示例:
```
```js
uploadTask.on('headerReceive', function callback(headers){
console.info("upOnHeader headers:" + JSON.stringify(headers));
}
......@@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
- 示例:
```
```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
}
......@@ -240,13 +240,13 @@ off(type: 'headerReceive', callback?: (header: object) =&gt; void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP&nbsp;Response&nbsp;Header。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP&nbsp;Response&nbsp;Header。 |
- 示例:
```
```js
uploadTask.off('headerReceive', function callback(headers) {
console.info("upOnHeader headers:" + JSON.stringify(headers));
}
......@@ -271,7 +271,7 @@ remove(): Promise&lt;boolean&gt;
- 示例
```
```js
uploadTask.remove().then((result) => {
if (result) {
console.info('Upload task removed successfully. ');
......@@ -301,7 +301,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
- 示例
```
```js
uploadTask.remove((err, result) => {
if (err) {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
......@@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise&lt;DownloadTask&gt;
- 示例
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
downloadTask = data;
}).catch((err) => {
......@@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): v
- 示例
```
```js
request.download({ url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
......@@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; vo
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
- 示例:
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
......@@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt;
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
- 示例:
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
......@@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void
- 示例:
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
......@@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void
- 示例:
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + JSON.stringify(err));
......@@ -581,13 +581,13 @@ on(type: 'fail', callback: (err: number) =&gt; void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 |
- 示例
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
......@@ -620,13 +620,13 @@ off(type: 'fail', callback?: (err: number) =&gt; void): void
回调函数的参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 |
- 示例
```
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
......@@ -658,7 +658,7 @@ remove(): Promise&lt;boolean&gt;
- 示例
```
```js
downloadTask.remove().then((result) => {
if (result) {
console.info('Download task removed.');
......@@ -688,7 +688,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
- 示例
```
```js
downloadTask.remove((err, result)=>{
if(err) {
console.error('Failed to remove the download task.');
......@@ -720,7 +720,7 @@ query(): Promise&lt;DownloadInfo&gt;
- 示例
```
```js
downloadTask.query().then((downloadInfo) => {
console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
}) .catch((err) => {
......@@ -746,7 +746,7 @@ query(callback: AsyncCallback&lt;DownloadInfo&gt;): void
- 示例:
```
```js
downloadTask.query((err, downloadInfo)=>{
if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
......@@ -774,7 +774,7 @@ queryMimeType(): Promise&lt;string&gt;
- 示例
```
```js
downloadTask.queryMimeType().then((data) => {
console.info('Download task queried. Data:' + JSON.stringify(data));
}).catch((err) => {
......@@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback&lt;string&gt;): void;
- 示例
```
```js
downloadTask.queryMimeType((err, data)=>{
if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
......@@ -828,7 +828,7 @@ pause(): Promise&lt;void&gt;
- 示例
```
```js
downloadTask.pause().then((result) => {
if (result) {
console.info('Download task paused. ');
......@@ -858,7 +858,7 @@ pause(callback: AsyncCallback&lt;void&gt;): void
- 示例
```
```js
downloadTask.pause((err, result)=>{
if(err) {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
......@@ -890,7 +890,7 @@ resume(): Promise&lt;void&gt;
- 示例
```
```js
downloadTask.resume().then((result) => {
if (result) {
console.info('Download task resumed.')
......@@ -921,7 +921,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void
- 示例
```
```js
downloadTask.resume((err, result)=>{
if (err) {
console.error('Failed to resume the download task. Cause:' + err);
......
......@@ -6,7 +6,7 @@
## 导入模块
```
import systemTime from '@ohos.systemTime';
```
......@@ -23,14 +23,14 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void
**系统能力**: SystemCapability.Miscservices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| time | number | 是 | 目标时间戳(毫秒)。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
| time | number | 是 | 目标时间戳(毫秒)。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例:
```
```js
// time对应的时间为2021-01-20 02:36:25
var time = 1611081385000;
systemTime.setTime(time, (error, data) => {
......@@ -54,18 +54,18 @@ setTime(time : number) : Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| time | number | 是 | 目标时间戳(毫秒)。 |
| time | number | 是 | 目标时间戳(毫秒)。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例:
```
```js
// time对应的时间为2021-01-20 02:36:25
var time = 1611081385000;
systemTime.setTime(time).then((data) => {
......@@ -85,14 +85,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例:
```
```js
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
......@@ -112,18 +112,18 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例:
```
```js
systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => {
......@@ -141,14 +141,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例:
```
```js
systemTime.getRealActiveTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));
......@@ -168,18 +168,18 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例:
```
```js
systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => {
......@@ -197,14 +197,14 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 |
- 示例:
```
```js
systemTime.getRealTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
......@@ -224,18 +224,18 @@ getRealTime(): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 |
- 示例:
```
```js
systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -255,14 +255,14 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| date | Date | 是 | 目标日期。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
| date | Date | 是 | 目标日期。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例:
```
```js
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => {
if (error) {
......@@ -285,18 +285,18 @@ setDate(date: Date): Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| date | Date | 是 | 目标日期。 |
| date | Date | 是 | 目标日期。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例:
```
```js
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value));
......@@ -315,13 +315,13 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 |
| callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 |
- 示例:
```
```js
systemTime.getDate((error, data) => {
if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
......@@ -341,13 +341,13 @@ getDate(): Promise&lt;Date&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 |
| Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 |
- 示例:
```
```js
systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => {
......@@ -367,14 +367,14 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| timezone | string | 是 | 系统时区。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
| timezone | string | 是 | 系统时区。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例:
```
```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));
......@@ -396,18 +396,18 @@ setTimezone(timezone: string): Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| timezone | string | 是 | 系统时区。 |
| timezone | string | 是 | 系统时区。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
| Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例:
```
```js
systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {
......@@ -425,13 +425,13 @@ getTimezone(callback: AsyncCallback&lt;string&gt;): void
**系统能力**: SystemCapability.MiscServices.Time
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 |
- 示例:
```
```js
systemTime.getTimezone((error, data) => {
if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
......@@ -451,13 +451,13 @@ getTimezone(): Promise&lt;string&gt;
**系统能力**: SystemCapability.MiscServices.Time
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 |
| Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 |
- 示例:
```
```js
systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {
......
......@@ -18,10 +18,10 @@ import wallpaper from '@ohos.wallpaper';
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 说明 |
| 名称 | 说明 |
| -------- | -------- |
| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 |
| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 |
| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 |
| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 |
## wallpaper.getColors
......@@ -33,14 +33,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;Rgba
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 是 | 回调函数,返回壁纸的主要颜色信息。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 是 | 回调函数,返回壁纸的主要颜色信息。 |
- 示例:
```
```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to getColors because: ` + JSON.stringify(error));
......@@ -60,18 +60,18 @@ getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 返回壁纸的主要颜色信息。 |
| Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 返回壁纸的主要颜色信息。 |
- 示例:
```
```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getColors.`);
}).catch((error) => {
......@@ -89,14 +89,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
- 示例:
```
```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to getId because: ` + JSON.stringify(error));
......@@ -117,18 +117,18 @@ getId(wallpaperType: WallpaperType): Promise&lt;number&gt;
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
| Promise&lt;number&gt; | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
- 示例:
```
```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getId: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -146,13 +146,13 @@ getMinHeight(callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
- 示例:
```
```js
wallpaper.getMinHeight((error, data) => {
if (error) {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
......@@ -173,13 +173,13 @@ getMinHeight(): Promise&lt;number&gt;
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
| Promise&lt;number&gt; | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
- 示例:
```
```js
wallpaper.getMinHeight().then((data) => {
console.log(`success to getMinHeight: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -198,13 +198,13 @@ getMinWidth(callback: AsyncCallback&lt;number&gt;): void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
- 示例:
```
```js
wallpaper.getMinWidth((error, data) => {
if (error) {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
......@@ -224,13 +224,13 @@ getMinWidth(): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
| Promise&lt;number&gt; | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
- 示例:
```
```js
wallpaper.getMinWidth().then((data) => {
console.log(`success to getMinWidth: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -248,13 +248,13 @@ isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
- 示例:
```
```js
wallpaper.isChangePermitted((error, data) => {
if (error) {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
......@@ -274,13 +274,13 @@ isChangePermitted(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
| Promise&lt;boolean&gt; | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
- 示例:
```
```js
wallpaper.isChangePermitted().then((data) => {
console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -298,13 +298,13 @@ isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
- 示例:
```
```js
wallpaper.isOperationAllowed((error, data) => {
if (error) {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
......@@ -324,13 +324,13 @@ isOperationAllowed(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
| Promise&lt;boolean&gt; | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
- 示例:
```
```js
wallpaper.isOperationAllowed().then((data) => {
console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -350,14 +350,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
- 示例:
```
```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error));
......@@ -379,18 +379,18 @@ reset(wallpaperType: WallpaperType): Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
| Promise&lt;void&gt; | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
- 示例:
```
```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`);
}).catch((error) => {
......@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call
- 示例:
```
```js
// source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
......@@ -469,13 +469,13 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 |
| Promise&lt;void&gt; | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 |
- 示例:
```
```js
// source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
......@@ -515,14 +515,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
- 示例:
```
```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error));
......@@ -543,18 +543,18 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值:
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;number&gt; | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
| Promise&lt;number&gt; | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
- 示例:
```
```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => {
......@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType
- 示例:
```
```js
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`);
};
......@@ -596,14 +596,14 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
**系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 |
| callback | function | 否 | &nbsp;&nbsp;表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。<br/>-&nbsp;colors<br/>&nbsp;&nbsp;壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;壁纸类型。 |
| type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 |
| callback | function | 否 | &nbsp;&nbsp;表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。<br/>-&nbsp;colors<br/>&nbsp;&nbsp;壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;壁纸类型。 |
- 示例:
```
```js
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`);
};
......@@ -619,9 +619,9 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| blue | number | 是 | 是 | 表示蓝色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| alpha | number | 是 | 是 | 表示&nbsp;alpha&nbsp;值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| blue | number | 是 | 是 | 表示蓝色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| alpha | number | 是 | 是 | 表示&nbsp;alpha&nbsp;值,范围为&nbsp;0&nbsp;&nbsp;255。 |
......@@ -3,9 +3,7 @@
## 概述
HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。
本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。
HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。本章节内容适用于标准系统。
## 开发指导
......
......@@ -6,9 +6,7 @@
### 功能简介
HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。
本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。
HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。本章节内容适用于标准系统。
### 源码目录说明
......
......@@ -6,11 +6,19 @@
提供以下功能:
- HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。
- HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。
- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。
- HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。
- HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。
- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。
- HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。
- HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。
- HiChecker缺陷扫描,标准系统类设备(参考内存≥128MB)适用。
- HiDumper信息导出,标准系统类设备(参考内存≥128MB)适用。
- Faultlogger崩溃故障检测,标准系统类设备(参考内存≥128MB)适用。
## 基本概念<a name="section5635178134811"></a>
......
# USB服务子系使用实例<a name="ZH-CN_TOPIC_0000001092792986"></a>
```
```cpp
#include <cstdio>
#include <iostream>
#include <map>
......
......@@ -8,46 +8,46 @@
1. 获取usb service实例
```
```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
```
2. 获取usb设备列表
```
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
3. 申请设备权限
```
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
4. 打开设备
```
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
5. 配置设备接口
```
```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true);
interfacedeviceListdeviceinterface
```
6. 数据传输
```
```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长.
7. 关闭设备
```
```cpp
ret = g_usbClient.Close(pip);
```
......@@ -398,12 +398,12 @@
- [普通组件开发指导](subsystems/subsys-graphics-common-guide.md)
- [动画开发指导](subsystems/subsys-graphics-animation-guide.md)
- 媒体
- [相机](subsystems/subsys-multimedia-camera.md)
- 相机
- [相机开发概述](subsystems/subsys-multimedia-camera-overview.md)
- [拍照开发指导](subsystems/subsys-multimedia-camera-photo-guide.md)
- [录像开发指导](subsystems/subsys-multimedia-camera-record-guide.md)
- [预览开发指导](subsystems/subsys-multimedia-camera-preview-guide.md)
- [音视频](subsystems/subsys-multimedia-video.md)
- 音视频
- [音视频开发概述](subsystems/subsys-multimedia-video-overview.md)
- [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md)
- [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md)
......@@ -427,10 +427,10 @@
- [唤醒词识别插件的开发示例](subsystems/subsys-aiframework-demo-plugin.md)
- [唤醒词识别配置文件的开发示例](subsystems/subsys-aiframework-demo-conf.md)
- 数据管理
- [关系型数据库](subsystems/subsys-data-relational-database.md)
- 关系型数据库
- [关系型数据库概述](subsystems/subsys-data-relational-database-overview.md)
- [关系型数据库开发指导](subsystems/subsys-data-relational-database-guide.md)
- [轻量级数据存储](subsystems/subsys-data-storage.md)
- 轻量级数据存储
- [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md)
- [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md)
- Sensor服务
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册