提交 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 ...@@ -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. 1. Obtain the USB device list.
``` ```js
// Import the USB API package. // Import the USB API package.
import usb from '@ohos.usb'; import usb from '@ohos.usb';
// Obtain the USB device list. // 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 ...@@ -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. 2. Obtain the device operation permissions.
``` ```js
var deviceName = deviceList[0].name; var deviceName = deviceList[0].name;
// Request the permissions to operate a specified device. // Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => { 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 ...@@ -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. 3. Open the device.
``` ```js
// Open the device, and obtain the USB device pipe for data transfer. // Open the device, and obtain the USB device pipe for data transfer.
var pipe = usb.connectDevice(deviceList[0]); 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 ...@@ -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. 4. Perform data transfer.
``` ```js
/* /*
Read data. Select the corresponding RX endpoint from deviceList for data transfer. 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. (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 ...@@ -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. 5. Release the USB interface, and close the USB device.
``` ```js
usb.releaseInterface(pipe, interface); usb.releaseInterface(pipe, interface);
usb.closePipe(pipe); usb.closePipe(pipe);
``` ```
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```js
import account_appAccount from '@ohos.account.appAccount'; import account_appAccount from '@ohos.account.appAccount';
``` ```
...@@ -25,7 +25,7 @@ Creates an **AppAccountManager** instance. ...@@ -25,7 +25,7 @@ Creates an **AppAccountManager** instance.
| AppAccountManager | **AppAccountManager** instance created.| | AppAccountManager | **AppAccountManager** instance created.|
**Example** **Example**
``` ```js
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
``` ```
...@@ -50,7 +50,7 @@ Adds an app account to the account management service. This method uses an async ...@@ -50,7 +50,7 @@ Adds an app account to the account management service. This method uses an async
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("WangWu", (err) => { appAccountManager.addAccount("WangWu", (err) => {
console.log("addAccount err: " + JSON.stringify(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 ...@@ -75,7 +75,7 @@ Adds an app account and its additional information to the account management ser
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101", (err) => { appAccountManager.addAccount("LiSi", "token101", (err) => {
console.log("addAccount err: " + JSON.stringify(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 ...@@ -107,7 +107,7 @@ Adds an app account and its additional information to the account management ser
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101").then(()=> { appAccountManager.addAccount("LiSi", "token101").then(()=> {
console.log('addAccount Success'); console.log('addAccount Success');
...@@ -135,7 +135,7 @@ Implicitly adds an app account based on the specified account owner, authenticat ...@@ -135,7 +135,7 @@ Implicitly adds an app account based on the specified account owner, authenticat
**Example** **Example**
``` ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
...@@ -174,7 +174,7 @@ Deletes an app account from the account management service. This method uses an ...@@ -174,7 +174,7 @@ Deletes an app account from the account management service. This method uses an
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu", (err) => { appAccountManager.deleteAccount("ZhaoLiu", (err) => {
console.log("deleteAccount err: " + JSON.stringify(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 ...@@ -203,7 +203,7 @@ Deletes an app account from the account management service. This method uses a p
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu").then(() => { appAccountManager.deleteAccount("ZhaoLiu").then(() => {
console.log('deleteAccount Success'); console.log('deleteAccount Success');
...@@ -230,7 +230,7 @@ Disables an app account from accessing an application with the given bundle name ...@@ -230,7 +230,7 @@ Disables an app account from accessing an application with the given bundle name
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("disableAppAccess err: " + JSON.stringify(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 ...@@ -260,7 +260,7 @@ Disables an app account from accessing an application with the given bundle name
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('disableAppAccess Success'); console.log('disableAppAccess Success');
...@@ -287,7 +287,7 @@ Enables an app account to access an application with the given bundle name. This ...@@ -287,7 +287,7 @@ Enables an app account to access an application with the given bundle name. This
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("enableAppAccess: " + JSON.stringify(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 ...@@ -317,7 +317,7 @@ Enables an app account to access an application with the given bundle name. This
**Example** **Example**
``` ```js
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success'); console.log('enableAppAccess Success');
}).catch((err) => { }).catch((err) => {
...@@ -344,7 +344,7 @@ Checks whether an app account allows application data synchronization. This meth ...@@ -344,7 +344,7 @@ Checks whether an app account allows application data synchronization. This meth
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
...@@ -376,7 +376,7 @@ Checks whether an app account allows application data synchronization. This meth ...@@ -376,7 +376,7 @@ Checks whether an app account allows application data synchronization. This meth
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data); console.log('checkAppAccountSyncEnable, result: ' + data);
...@@ -404,7 +404,7 @@ Sets a credential for an app account. This method uses an asynchronous callback ...@@ -404,7 +404,7 @@ Sets a credential for an app account. This method uses an asynchronous callback
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
console.log("setAccountCredential err: " + JSON.stringify(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 ...@@ -435,7 +435,7 @@ Sets a credential for an app account. This method uses a promise to return the r
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
console.log('setAccountCredential Success'); console.log('setAccountCredential Success');
...@@ -462,7 +462,7 @@ Sets additional information for an app account. This method uses an asynchronous ...@@ -462,7 +462,7 @@ Sets additional information for an app account. This method uses an asynchronous
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(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 ...@@ -492,7 +492,7 @@ Sets additional information for an app account. This method uses a promise to re
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
console.log('setAccountExtraInfo Success'); console.log('setAccountExtraInfo Success');
...@@ -521,7 +521,7 @@ Sets whether to enable application data synchronization for an app account. This ...@@ -521,7 +521,7 @@ Sets whether to enable application data synchronization for an app account. This
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
...@@ -553,7 +553,7 @@ Sets whether to enable application data synchronization for an app account. This ...@@ -553,7 +553,7 @@ Sets whether to enable application data synchronization for an app account. This
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
console.log('setAppAccountSyncEnable Success'); console.log('setAppAccountSyncEnable Success');
...@@ -581,7 +581,7 @@ Sets data to be associated with an app account. This method uses an asynchronous ...@@ -581,7 +581,7 @@ Sets data to be associated with an app account. This method uses an asynchronous
**Example** **Example**
``` ```js
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(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 ...@@ -611,7 +611,7 @@ Sets data to be associated with an app account. This method uses a promise to re
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
console.log('setAssociatedData Success'); console.log('setAssociatedData Success');
...@@ -638,7 +638,7 @@ Obtains the credential of an app account. This method uses an asynchronous callb ...@@ -638,7 +638,7 @@ Obtains the credential of an app account. This method uses an asynchronous callb
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
console.log("getAccountCredential err: " + JSON.stringify(err)); 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 ...@@ -669,7 +669,7 @@ Obtains the credential of an app account. This method uses a promise to return t
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
console.log('getAccountCredential, result: ' + data); console.log('getAccountCredential, result: ' + data);
...@@ -695,7 +695,7 @@ Obtains additional information of an app account. This method uses an asynchrono ...@@ -695,7 +695,7 @@ Obtains additional information of an app account. This method uses an asynchrono
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err)); console.log("getAccountExtraInfo err: " + JSON.stringify(err));
...@@ -725,7 +725,7 @@ Obtains additional information of an app account. This method uses a promise to ...@@ -725,7 +725,7 @@ Obtains additional information of an app account. This method uses a promise to
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
console.log('getAccountExtraInfo, result: ' + data); console.log('getAccountExtraInfo, result: ' + data);
...@@ -752,7 +752,7 @@ Obtains data associated with an app account. This method uses an asynchronous ca ...@@ -752,7 +752,7 @@ Obtains data associated with an app account. This method uses an asynchronous ca
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
console.log("getAssociatedData err: " + JSON.stringify(err)); 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 ...@@ -783,7 +783,7 @@ Obtains data associated with an app account. This method uses a promise to retur
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
console.log('getAssociatedData: ' + data); console.log('getAssociatedData: ' + data);
...@@ -810,7 +810,7 @@ Obtains information about all accessible app accounts. This method uses an async ...@@ -810,7 +810,7 @@ Obtains information about all accessible app accounts. This method uses an async
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts((err, data)=>{ appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
...@@ -836,7 +836,7 @@ Obtains information about all accessible app accounts. This method uses an async ...@@ -836,7 +836,7 @@ Obtains information about all accessible app accounts. This method uses an async
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts().then((data) => { appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data); console.log('getAllAccessibleAccounts: ' + data);
...@@ -864,7 +864,7 @@ Obtains information about all app accounts of the specified app. This method use ...@@ -864,7 +864,7 @@ Obtains information about all app accounts of the specified app. This method use
**Example** **Example**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
...@@ -897,7 +897,7 @@ Obtains information about all app accounts of the specified app. This method use ...@@ -897,7 +897,7 @@ Obtains information about all app accounts of the specified app. This method use
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle).then((data) => { appAccountManager.getAllAccounts(selfBundle).then((data) => {
...@@ -925,7 +925,7 @@ Subscribes to the account change event of the specified account owners. This met ...@@ -925,7 +925,7 @@ Subscribes to the account change event of the specified account owners. This met
**Example** **Example**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(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 ...@@ -955,7 +955,7 @@ Unsubscribes from the account change event. This method uses an asynchronous cal
**Example** **Example**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(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 ...@@ -991,7 +991,7 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok
**Example** **Example**
``` ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
...@@ -1032,7 +1032,7 @@ Obtains the OAuth access token of an app account based on the specified authenti ...@@ -1032,7 +1032,7 @@ Obtains the OAuth access token of an app account based on the specified authenti
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err)); 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 ...@@ -1064,7 +1064,7 @@ Obtains the OAuth access token of an app account based on the specified authenti
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
...@@ -1092,7 +1092,7 @@ Sets an OAuth access token for an app account. This method uses an asynchronous ...@@ -1092,7 +1092,7 @@ Sets an OAuth access token for an app account. This method uses an asynchronous
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(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 ...@@ -1123,7 +1123,7 @@ Sets an OAuth access token for an app account. This method uses a promise to ret
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
console.log('setOAuthToken successfully'); console.log('setOAuthToken successfully');
...@@ -1152,7 +1152,7 @@ Deletes the specified OAuth access token for an app account. This method uses an ...@@ -1152,7 +1152,7 @@ Deletes the specified OAuth access token for an app account. This method uses an
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(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 ...@@ -1184,7 +1184,7 @@ Deletes the specified OAuth access token for an app account. This method uses a
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully'); console.log('deleteOAuthToken successfully');
...@@ -1213,7 +1213,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u ...@@ -1213,7 +1213,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(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 ...@@ -1245,7 +1245,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully'); console.log('setOAuthTokenVisibility successfully');
...@@ -1273,7 +1273,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses ...@@ -1273,7 +1273,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); 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 ...@@ -1305,7 +1305,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
...@@ -1332,7 +1332,7 @@ Obtains information about all OAuth access tokens of an app account visible to t ...@@ -1332,7 +1332,7 @@ Obtains information about all OAuth access tokens of an app account visible to t
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); 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 ...@@ -1363,7 +1363,7 @@ Obtains information about all OAuth access tokens of an app account visible to t
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(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 ...@@ -1390,7 +1390,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err)); 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 ...@@ -1421,7 +1421,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
...@@ -1447,7 +1447,7 @@ Obtains the authenticator callback for a session. This method uses an asynchrono ...@@ -1447,7 +1447,7 @@ Obtains the authenticator callback for a session. This method uses an asynchrono
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => { featureAbility.getWant((err, want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; 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 ...@@ -1487,7 +1487,7 @@ Obtains the authenticator callback for a session. This method uses a promise to
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => { featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; 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 ...@@ -1522,7 +1522,7 @@ Obtains authenticator information of an app account. This method uses an asynchr
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
...@@ -1552,7 +1552,7 @@ Obtains authenticator information of an app account. This method uses a promise ...@@ -1552,7 +1552,7 @@ Obtains authenticator information of an app account. This method uses a promise
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
...@@ -1663,7 +1663,7 @@ Called back to send the authentication result. ...@@ -1663,7 +1663,7 @@ Called back to send the authentication result.
**Example** **Example**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
...@@ -1692,7 +1692,7 @@ Called back to redirect an authentication request. ...@@ -1692,7 +1692,7 @@ Called back to redirect an authentication request.
**Example** **Example**
``` ```js
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
...@@ -1749,7 +1749,7 @@ Authenticates an app account to obtain the OAuth access token. This method uses ...@@ -1749,7 +1749,7 @@ Authenticates an app account to obtain the OAuth access token. This method uses
**Example** **Example**
``` ```js
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```js
import account_distributedAccount from '@ohos.account.distributedAccount'; import account_distributedAccount from '@ohos.account.distributedAccount';
``` ```
...@@ -28,7 +28,7 @@ Obtains a **DistributedAccountAbility** instance. ...@@ -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.| | [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.|
- Example - Example
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
``` ```
...@@ -50,7 +50,7 @@ Obtains distributed account information. This method uses an asynchronous callba ...@@ -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.| | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.|
- Example - Example
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => { accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
...@@ -73,7 +73,7 @@ Obtains distributed account information. This method uses a promise to return th ...@@ -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.| | Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.|
- Example - Example
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => { accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name); console.log('Query account info name: ' + data.name);
...@@ -98,7 +98,7 @@ Updates distributed account information. This method uses an asynchronous callba ...@@ -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.| | callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.|
- Example - Example
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
...@@ -125,7 +125,7 @@ Updates distributed account information. This method uses a promise to return th ...@@ -125,7 +125,7 @@ Updates distributed account information. This method uses a promise to return th
| Promise<void> | Promise used to return the result.| | Promise<void> | Promise used to return the result.|
- Example - Example
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```js
import account_osAccount from '@ohos.account.osAccount'; import account_osAccount from '@ohos.account.osAccount';
``` ```
...@@ -24,7 +24,7 @@ Obtains an **AccountManager** instance. ...@@ -24,7 +24,7 @@ Obtains an **AccountManager** instance.
| [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.|
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
``` ```
...@@ -64,7 +64,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -64,7 +64,7 @@ This is a system API and cannot be called by third-party applications.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**: Activate OS account 100. **Example**: Activate OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.activateOsAccount(localId, (err)=>{ accountManager.activateOsAccount(localId, (err)=>{
...@@ -97,7 +97,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -97,7 +97,7 @@ This is a system API and cannot be called by third-party applications.
| Promise<void> | Promise used to return the result.| | Promise<void> | Promise used to return the result.|
**Example**: Activate OS account 100. **Example**: Activate OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.activateOsAccount(localId).then(() => { accountManager.activateOsAccount(localId).then(() => {
...@@ -123,7 +123,7 @@ Checks whether multiple OS accounts are supported. This method uses an asynchron ...@@ -123,7 +123,7 @@ Checks whether multiple OS accounts are supported. This method uses an asynchron
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => { accountManager.isMultiOsAccountEnable((err, isEnabled) => {
console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
...@@ -147,7 +147,7 @@ Checks whether multiple OS accounts are supported. This method uses a promise to ...@@ -147,7 +147,7 @@ Checks whether multiple OS accounts are supported. This method uses a promise to
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled) => { accountManager.isMultiOsAccountEnable().then((isEnabled) => {
console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
...@@ -175,7 +175,7 @@ Checks whether an OS account is activated. This method uses an asynchronous call ...@@ -175,7 +175,7 @@ Checks whether an OS account is activated. This method uses an asynchronous call
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
...@@ -208,7 +208,7 @@ Checks whether an OS account is activated. This method uses a promise to return ...@@ -208,7 +208,7 @@ Checks whether an OS account is activated. This method uses a promise to return
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId).then((isActive) => { accountManager.isOsAccountActived(osLocalId).then((isActive) => {
...@@ -236,9 +236,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho ...@@ -236,9 +236,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho
| constraint | string | Yes | [Constraint](#constraints) specified. | | constraint | string | Yes | [Constraint](#constraints) specified. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. **Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{
...@@ -270,9 +270,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho ...@@ -270,9 +270,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho
| :--------------------- | :----------------------------------------------------------- | | :--------------------- | :----------------------------------------------------------- |
| Promise<boolean> | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| | Promise<boolean> | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. **Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => {
...@@ -298,7 +298,7 @@ Checks whether this OS account is a test account. This method uses an asynchrono ...@@ -298,7 +298,7 @@ Checks whether this OS account is a test account. This method uses an asynchrono
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTest) => { accountManager.isTestOsAccount((err, isTest) => {
console.log("isTestOsAccount err: " + JSON.stringify(err)); console.log("isTestOsAccount err: " + JSON.stringify(err));
...@@ -322,7 +322,7 @@ Checks whether this OS account is a test account. This method uses a promise to ...@@ -322,7 +322,7 @@ Checks whether this OS account is a test account. This method uses a promise to
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTest) => { accountManager.isTestOsAccount().then((isTest) => {
console.log('isTestOsAccount, isTest: ' + isTest); console.log('isTestOsAccount, isTest: ' + isTest);
...@@ -347,7 +347,7 @@ Checks whether this OS account has been verified. This method uses an asynchrono ...@@ -347,7 +347,7 @@ Checks whether this OS account has been verified. This method uses an asynchrono
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => { accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err)); console.log("isOsAccountVerified err: " + JSON.stringify(err));
...@@ -374,7 +374,7 @@ Checks whether an OS account has been verified. This method uses an asynchronous ...@@ -374,7 +374,7 @@ Checks whether an OS account has been verified. This method uses an asynchronous
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => { accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err)); console.log("isOsAccountVerified err: " + JSON.stringify(err));
...@@ -406,7 +406,7 @@ Checks whether an OS account has been verified. This method uses a promise to re ...@@ -406,7 +406,7 @@ Checks whether an OS account has been verified. This method uses a promise to re
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified().then((isVerified) => { accountManager.isOsAccountVerified().then((isVerified) => {
console.log('isOsAccountVerified, isVerified: ' + isVerified); console.log('isOsAccountVerified, isVerified: ' + isVerified);
...@@ -436,7 +436,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -436,7 +436,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
...@@ -473,7 +473,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -473,7 +473,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
...@@ -508,9 +508,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -508,9 +508,9 @@ This is a system API and cannot be called by third-party applications.
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. |
** Example**: Disable Wi-Fi for OS account 100. **Example**: Disable Wi-Fi for OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{
...@@ -546,7 +546,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -546,7 +546,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Remote the constraint on the use of Wi-Fi for OS account 100. **Example**: Remote the constraint on the use of Wi-Fi for OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => {
...@@ -578,7 +578,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -578,7 +578,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Set the name of OS account 100 to **demoName**. **Example**: Set the name of OS account 100 to **demoName**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var newName = "demoName"; var newName = "demoName";
...@@ -614,7 +614,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -614,7 +614,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Set the name of OS account 100 to **demoName**. **Example**: Set the name of OS account 100 to **demoName**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var nameLimit = "demoName"; var nameLimit = "demoName";
...@@ -643,7 +643,7 @@ Obtains the number of OS accounts created. This method uses an asynchronous call ...@@ -643,7 +643,7 @@ Obtains the number of OS accounts created. This method uses an asynchronous call
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); console.log("obtains the number of all os accounts created err:" + JSON.stringify(err));
...@@ -669,7 +669,7 @@ Obtains the number of OS accounts created. This method uses a promise to return ...@@ -669,7 +669,7 @@ Obtains the number of OS accounts created. This method uses a promise to return
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((accountCnt) => { accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
...@@ -694,7 +694,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth ...@@ -694,7 +694,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
...@@ -718,7 +718,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth ...@@ -718,7 +718,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
...@@ -744,7 +744,7 @@ Obtains the OS account ID based on the process UID. This method uses an asynchro ...@@ -744,7 +744,7 @@ Obtains the OS account ID based on the process UID. This method uses an asynchro
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
...@@ -775,7 +775,7 @@ Obtains the OS account ID based on the process UID. This method uses a promise t ...@@ -775,7 +775,7 @@ Obtains the OS account ID based on the process UID. This method uses a promise t
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
...@@ -804,7 +804,7 @@ Obtains the OS account ID based on domain account information. This method uses ...@@ -804,7 +804,7 @@ Obtains the OS account ID based on domain account information. This method uses
**Example** **Example**
``` ```js
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
...@@ -837,7 +837,7 @@ Obtains the OS account ID based on domain account information. This method uses ...@@ -837,7 +837,7 @@ Obtains the OS account ID based on domain account information. This method uses
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
...@@ -865,7 +865,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -865,7 +865,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err));
...@@ -891,7 +891,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -891,7 +891,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber().then((maxCnt) => { accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
...@@ -917,9 +917,9 @@ Obtains all constraints enabled for an OS account. This method uses an asynchron ...@@ -917,9 +917,9 @@ Obtains all constraints enabled for an OS account. This method uses an asynchron
| localId | number | Yes | ID of the target OS account. | | localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback<Array<string>> | Yes | Callback used to return all [constraints](#constraints) obtained.| | callback | AsyncCallback<Array<string>> | Yes | Callback used to return all [constraints](#constraints) obtained.|
** Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
...@@ -950,9 +950,9 @@ Obtains all constraints enabled for an OS account. This method uses a promise to ...@@ -950,9 +950,9 @@ Obtains all constraints enabled for an OS account. This method uses a promise to
| :--------------------------------- | :----------------------------------------------------------- | | :--------------------------------- | :----------------------------------------------------------- |
| Promise<Array<string>> | Promise used to return the [constraints](#constraints) obtained.| | Promise<Array<string>> | Promise used to return the [constraints](#constraints) obtained.|
** Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints) => { accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
...@@ -980,7 +980,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -980,7 +980,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err));
...@@ -1006,7 +1006,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1006,7 +1006,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts().then((accountArr) => { accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
...@@ -1031,7 +1031,7 @@ Obtains information about all activated OS accounts. This method uses an asynchr ...@@ -1031,7 +1031,7 @@ Obtains information about all activated OS accounts. This method uses an asynchr
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err, idArray)=>{ accountManager.queryActivatedOsAccountIds((err, idArray)=>{
console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err));
...@@ -1058,7 +1058,7 @@ Obtains information about all activated OS accounts. This method uses a promise ...@@ -1058,7 +1058,7 @@ Obtains information about all activated OS accounts. This method uses a promise
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray) => { accountManager.queryActivatedOsAccountIds().then((idArray) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray); console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
...@@ -1089,7 +1089,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1089,7 +1089,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.log("createOsAccount err:" + JSON.stringify(err)); console.log("createOsAccount err:" + JSON.stringify(err));
...@@ -1124,7 +1124,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1124,7 +1124,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
...@@ -1155,7 +1155,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1155,7 +1155,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
...@@ -1191,7 +1191,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1191,7 +1191,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
...@@ -1219,7 +1219,7 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -1219,7 +1219,7 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); console.log("queryCurrentOsAccount err:" + JSON.stringify(err));
...@@ -1245,7 +1245,7 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -1245,7 +1245,7 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo) => { accountManager.queryCurrentOsAccount().then((accountInfo) => {
console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo));
...@@ -1275,7 +1275,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1275,7 +1275,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Query information about OS account 100. **Example**: Query information about OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
...@@ -1310,7 +1310,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1310,7 +1310,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Query information about OS account 100. **Example**: Query information about OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.queryOsAccountById(localId).then((accountInfo) => { accountManager.queryOsAccountById(localId).then((accountInfo) => {
...@@ -1336,7 +1336,7 @@ Obtains the type of the OS account to which the current process belongs. This me ...@@ -1336,7 +1336,7 @@ Obtains the type of the OS account to which the current process belongs. This me
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err, accountType) => { accountManager.getOsAccountTypeFromProcess((err, accountType) => {
console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
...@@ -1360,7 +1360,7 @@ Obtains the type of the OS account to which the current process belongs. This me ...@@ -1360,7 +1360,7 @@ Obtains the type of the OS account to which the current process belongs. This me
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType) => { accountManager.getOsAccountTypeFromProcess().then((accountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
...@@ -1387,7 +1387,7 @@ Obtains the ID of this distributed virtual device. This method uses an asynchron ...@@ -1387,7 +1387,7 @@ Obtains the ID of this distributed virtual device. This method uses an asynchron
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err, virtualID) => { accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
...@@ -1413,7 +1413,7 @@ Obtains the ID of this distributed virtual device. This method uses a promise to ...@@ -1413,7 +1413,7 @@ Obtains the ID of this distributed virtual device. This method uses a promise to
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID) => { accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
...@@ -1443,7 +1443,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1443,7 +1443,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Obtain the profile photo of OS account 100. **Example**: Obtain the profile photo of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
...@@ -1478,7 +1478,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1478,7 +1478,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Obtain the profile photo of OS account 100. **Example**: Obtain the profile photo of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountProfilePhoto(localId).then((photo) => { accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
...@@ -1510,7 +1510,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1510,7 +1510,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Set a profile photo for OS account 100. **Example**: Set a profile photo for OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
...@@ -1549,7 +1549,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1549,7 +1549,7 @@ This is a system API and cannot be called by third-party applications.
**Example**: Set a profile photo for OS account 100. **Example**: Set a profile photo for OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
...@@ -1580,7 +1580,7 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call ...@@ -1580,7 +1580,7 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call
**Example**: Obtain the ID of the OS account whose SN is **12345**. **Example**: Obtain the ID of the OS account whose SN is **12345**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
...@@ -1611,7 +1611,7 @@ Obtains the OS account ID based on the SN. This method uses a promise to return ...@@ -1611,7 +1611,7 @@ Obtains the OS account ID based on the SN. This method uses a promise to return
**Example**: Obtain the ID of the OS account whose SN is **12345**. **Example**: Obtain the ID of the OS account whose SN is **12345**.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
...@@ -1638,7 +1638,7 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy ...@@ -1638,7 +1638,7 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy
**Example**: Obtain the SN of OS account 100. **Example**: Obtain the SN of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
...@@ -1669,7 +1669,7 @@ Obtains the SN of an OS account based on the account ID. This method uses a prom ...@@ -1669,7 +1669,7 @@ Obtains the SN of an OS account based on the account ID. This method uses a prom
**Example**: Obtain the SN of OS account 100. **Example**: Obtain the SN of OS account 100.
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
...@@ -1701,7 +1701,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1701,7 +1701,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
function onCallback(receiveLocalId){ function onCallback(receiveLocalId){
console.log("receive localId:" + receiveLocalId); console.log("receive localId:" + receiveLocalId);
...@@ -1731,7 +1731,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1731,7 +1731,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
function offCallback(){ function offCallback(){
console.log("off enter") console.log("off enter")
......
# USB Usage Demo<a name="EN-US_TOPIC_0000001092792986"></a> # USB Usage Demo<a name="EN-US_TOPIC_0000001092792986"></a>
``` ```cpp
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <map> #include <map>
......
...@@ -7,40 +7,40 @@ The following procedure uses bulk transfer as an example. ...@@ -7,40 +7,40 @@ The following procedure uses bulk transfer as an example.
1. Obtain a USB service instance. 1. Obtain a USB service instance.
``` ```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
``` ```
2. Obtain the USB device list. 2. Obtain the USB device list.
``` ```cpp
std::vector<OHOS::USB::UsbDevice> deviceList; std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList); int32_t ret = g_usbClient.GetDevices(deviceList);
``` ```
3. Apply for device access permissions. 3. Apply for device access permissions.
``` ```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName()); int32_t ret = g_usbClient.RequestRight(device.GetName());
``` ```
4. Open the USB device. 4. Open the USB device.
``` ```cpp
USBDevicePipe pip; USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip); int32_t et = g_usbClient.OpenDevice(device, pip);
``` ```
5. Configure the USB interface. 5. Configure the USB interface.
``` ```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true); ret = g_usbClient.ClaimInterface(pip, interface, true);
**interface** indicates an interface of the USB device in **deviceList**. **interface** indicates an interface of the USB device in **deviceList**.
``` ```
6. Transfer data. 6. Transfer data.
``` ```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
``` ```
- **pipe** indicates the pipe for data transfer of the USB device opened. - **pipe** indicates the pipe for data transfer of the USB device opened.
...@@ -50,6 +50,6 @@ srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); ...@@ -50,6 +50,6 @@ srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
7. Close the USB device. 7. Close the USB device.
``` ```cpp
ret = g_usbClient.Close(pip); ret = g_usbClient.Close(pip);
``` ```
...@@ -38,7 +38,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -38,7 +38,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
1. 获取设备列表。 1. 获取设备列表。
``` ```js
// 导入usb接口api包。 // 导入usb接口api包。
import usb from '@ohos.usb'; import usb from '@ohos.usb';
// 获取设备列表。 // 获取设备列表。
...@@ -97,7 +97,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -97,7 +97,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
``` ```
2. 获取设备操作权限。 2. 获取设备操作权限。
``` ```js
var deviceName = deviceList[0].name; var deviceName = deviceList[0].name;
// 申请操作指定的device的操作权限。 // 申请操作指定的device的操作权限。
usb.requestRight(deviceName).then(hasRight => { usb.requestRight(deviceName).then(hasRight => {
...@@ -108,7 +108,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -108,7 +108,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
``` ```
3. 打开Device设备。 3. 打开Device设备。
``` ```js
// 打开设备,获取数据传输通道。 // 打开设备,获取数据传输通道。
var pipe = usb.connectDevice(deviceList[0]); var pipe = usb.connectDevice(deviceList[0]);
/* /*
...@@ -119,7 +119,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -119,7 +119,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
``` ```
4. 数据传输。 4. 数据传输。
``` ```js
/* /*
读取数据,在device信息中选取对应数据接收的endpoint来做数据传输 读取数据,在device信息中选取对应数据接收的endpoint来做数据传输
(endpoint.direction == 0x80);dataUint8Array是要读取的数据,类型为Uint8Array。 (endpoint.direction == 0x80);dataUint8Array是要读取的数据,类型为Uint8Array。
...@@ -149,7 +149,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -149,7 +149,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
``` ```
5. 释放接口,关闭设备。 5. 释放接口,关闭设备。
``` ```js
usb.releaseInterface(pipe, interface1); usb.releaseInterface(pipe, interface1);
usb.closePipe(pipe); usb.closePipe(pipe);
``` ```
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```js
import account_appAccount from '@ohos.account.appAccount'; import account_appAccount from '@ohos.account.appAccount';
``` ```
...@@ -25,7 +25,7 @@ createAppAccountManager(): AppAccountManager ...@@ -25,7 +25,7 @@ createAppAccountManager(): AppAccountManager
| AppAccountManager | 获取应用帐号模块的实例。 | | AppAccountManager | 获取应用帐号模块的实例。 |
**示例:** **示例:**
``` ```js
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
``` ```
...@@ -50,7 +50,7 @@ addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -50,7 +50,7 @@ addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("WangWu", (err) => { appAccountManager.addAccount("WangWu", (err) => {
console.log("addAccount err: " + JSON.stringify(err)); console.log("addAccount err: " + JSON.stringify(err));
...@@ -75,7 +75,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;) ...@@ -75,7 +75,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;)
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101", (err) => { appAccountManager.addAccount("LiSi", "token101", (err) => {
console.log("addAccount err: " + JSON.stringify(err)); console.log("addAccount err: " + JSON.stringify(err));
...@@ -107,7 +107,7 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt; ...@@ -107,7 +107,7 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccount("LiSi", "token101").then(()=> { appAccountManager.addAccount("LiSi", "token101").then(()=> {
console.log('addAccount Success'); console.log('addAccount Success');
...@@ -135,7 +135,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a ...@@ -135,7 +135,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
**示例:** **示例:**
``` ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
...@@ -174,7 +174,7 @@ deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -174,7 +174,7 @@ deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu", (err) => { appAccountManager.deleteAccount("ZhaoLiu", (err) => {
console.log("deleteAccount err: " + JSON.stringify(err)); console.log("deleteAccount err: " + JSON.stringify(err));
...@@ -203,7 +203,7 @@ deleteAccount(name: string): Promise&lt;void&gt; ...@@ -203,7 +203,7 @@ deleteAccount(name: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteAccount("ZhaoLiu").then(() => { appAccountManager.deleteAccount("ZhaoLiu").then(() => {
console.log('deleteAccount Success'); console.log('deleteAccount Success');
...@@ -230,7 +230,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;vo ...@@ -230,7 +230,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;vo
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("disableAppAccess err: " + JSON.stringify(err)); console.log("disableAppAccess err: " + JSON.stringify(err));
...@@ -260,7 +260,7 @@ disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt; ...@@ -260,7 +260,7 @@ disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('disableAppAccess Success'); console.log('disableAppAccess Success');
...@@ -287,7 +287,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;voi ...@@ -287,7 +287,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;voi
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
console.log("enableAppAccess: " + JSON.stringify(err)); console.log("enableAppAccess: " + JSON.stringify(err));
...@@ -317,7 +317,7 @@ enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt; ...@@ -317,7 +317,7 @@ enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success'); console.log('enableAppAccess Success');
}).catch((err) => { }).catch((err) => {
...@@ -344,7 +344,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): ...@@ -344,7 +344,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;):
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
...@@ -376,7 +376,7 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt; ...@@ -376,7 +376,7 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data); console.log('checkAppAccountSyncEnable, result: ' + data);
...@@ -404,7 +404,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca ...@@ -404,7 +404,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
console.log("setAccountCredential err: " + JSON.stringify(err)); console.log("setAccountCredential err: " + JSON.stringify(err));
...@@ -435,7 +435,7 @@ setAccountCredential(name: string, credentialType: string, credential: string): ...@@ -435,7 +435,7 @@ setAccountCredential(name: string, credentialType: string, credential: string):
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
console.log('setAccountCredential Success'); console.log('setAccountCredential Success');
...@@ -462,7 +462,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt; ...@@ -462,7 +462,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(err)); console.log("setAccountExtraInfo err: " + JSON.stringify(err));
...@@ -492,7 +492,7 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt; ...@@ -492,7 +492,7 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
console.log('setAccountExtraInfo Success'); console.log('setAccountExtraInfo Success');
...@@ -521,7 +521,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback ...@@ -521,7 +521,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
...@@ -553,7 +553,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt; ...@@ -553,7 +553,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
console.log('setAppAccountSyncEnable Success'); console.log('setAppAccountSyncEnable Success');
...@@ -581,7 +581,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb ...@@ -581,7 +581,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
**示例:** **示例:**
``` ```js
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err)); console.log("setAssociatedData err: " + JSON.stringify(err));
}); });
...@@ -611,7 +611,7 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt; ...@@ -611,7 +611,7 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
console.log('setAssociatedData Success'); console.log('setAssociatedData Success');
...@@ -638,7 +638,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba ...@@ -638,7 +638,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
console.log("getAccountCredential err: " + JSON.stringify(err)); console.log("getAccountCredential err: " + JSON.stringify(err));
...@@ -669,7 +669,7 @@ getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt ...@@ -669,7 +669,7 @@ getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
console.log('getAccountCredential, result: ' + data); console.log('getAccountCredential, result: ' + data);
...@@ -695,7 +695,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void ...@@ -695,7 +695,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err)); console.log("getAccountExtraInfo err: " + JSON.stringify(err));
...@@ -725,7 +725,7 @@ getAccountExtraInfo(name: string): Promise&lt;string&gt; ...@@ -725,7 +725,7 @@ getAccountExtraInfo(name: string): Promise&lt;string&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
console.log('getAccountExtraInfo, result: ' + data); console.log('getAccountExtraInfo, result: ' + data);
...@@ -752,7 +752,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&g ...@@ -752,7 +752,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&g
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
console.log("getAssociatedData err: " + JSON.stringify(err)); console.log("getAssociatedData err: " + JSON.stringify(err));
...@@ -783,7 +783,7 @@ getAssociatedData(name: string, key: string): Promise&lt;string&gt; ...@@ -783,7 +783,7 @@ getAssociatedData(name: string, key: string): Promise&lt;string&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
console.log('getAssociatedData: ' + data); console.log('getAssociatedData: ' + data);
...@@ -810,7 +810,7 @@ getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;& ...@@ -810,7 +810,7 @@ getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts((err, data)=>{ appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
...@@ -836,7 +836,7 @@ getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt; ...@@ -836,7 +836,7 @@ getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllAccessibleAccounts().then((data) => { appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data); console.log('getAllAccessibleAccounts: ' + data);
...@@ -864,7 +864,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo ...@@ -864,7 +864,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo
**示例:** **示例:**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
...@@ -897,7 +897,7 @@ getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt; ...@@ -897,7 +897,7 @@ getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle).then((data) => { appAccountManager.getAllAccounts(selfBundle).then((data) => {
...@@ -925,7 +925,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A ...@@ -925,7 +925,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A
**示例:** **示例:**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
...@@ -955,7 +955,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void ...@@ -955,7 +955,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
**示例:** **示例:**
``` ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
...@@ -991,7 +991,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri ...@@ -991,7 +991,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
**示例:** **示例:**
``` ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
...@@ -1032,7 +1032,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall ...@@ -1032,7 +1032,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err)); console.log('getOAuthToken err: ' + JSON.stringify(err));
...@@ -1064,7 +1064,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string& ...@@ -1064,7 +1064,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
...@@ -1092,7 +1092,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall ...@@ -1092,7 +1092,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err)); console.log('setOAuthToken err: ' + JSON.stringify(err));
...@@ -1123,7 +1123,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt ...@@ -1123,7 +1123,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
console.log('setOAuthToken successfully'); console.log('setOAuthToken successfully');
...@@ -1152,7 +1152,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c ...@@ -1152,7 +1152,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err)); console.log('deleteOAuthToken err: ' + JSON.stringify(err));
...@@ -1184,7 +1184,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): ...@@ -1184,7 +1184,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully'); console.log('deleteOAuthToken successfully');
...@@ -1213,7 +1213,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ...@@ -1213,7 +1213,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -1245,7 +1245,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ...@@ -1245,7 +1245,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully'); console.log('setOAuthTokenVisibility successfully');
...@@ -1273,7 +1273,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca ...@@ -1273,7 +1273,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -1305,7 +1305,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P ...@@ -1305,7 +1305,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
...@@ -1332,7 +1332,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array& ...@@ -1332,7 +1332,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); console.log("getAllOAuthTokens err: " + JSON.stringify(err));
...@@ -1363,7 +1363,7 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn ...@@ -1363,7 +1363,7 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
...@@ -1390,7 +1390,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt ...@@ -1390,7 +1390,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err)); console.log('getOAuthList err: ' + JSON.stringify(err));
...@@ -1421,7 +1421,7 @@ getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt; ...@@ -1421,7 +1421,7 @@ getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
...@@ -1447,7 +1447,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic ...@@ -1447,7 +1447,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => { featureAbility.getWant((err, want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
...@@ -1487,7 +1487,7 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt ...@@ -1487,7 +1487,7 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => { featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
...@@ -1522,7 +1522,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo ...@@ -1522,7 +1522,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
...@@ -1552,7 +1552,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt; ...@@ -1552,7 +1552,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
...@@ -1663,7 +1663,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void ...@@ -1663,7 +1663,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void
**示例:** **示例:**
``` ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
...@@ -1692,7 +1692,7 @@ onRequestRedirected: (request: Want) =&gt; void ...@@ -1692,7 +1692,7 @@ onRequestRedirected: (request: Want) =&gt; void
**示例:** **示例:**
``` ```js
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
...@@ -1749,7 +1749,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options: ...@@ -1749,7 +1749,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options:
**示例:** **示例:**
``` ```js
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## 导入模块 ## 导入模块
``` ```js
import bluetooth from '@ohos.bluetooth'; import bluetooth from '@ohos.bluetooth';
``` ```
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```js
import account_distributedAccount from '@ohos.account.distributedAccount'; import account_distributedAccount from '@ohos.account.distributedAccount';
``` ```
...@@ -28,7 +28,7 @@ getDistributedAccountAbility(): DistributedAccountAbility ...@@ -28,7 +28,7 @@ getDistributedAccountAbility(): DistributedAccountAbility
| [DistributedAccountAbility](#distributedaccountability) | 返回一个实例,实例提供查询和更新分布式帐号登录状态方法。 | | [DistributedAccountAbility](#distributedaccountability) | 返回一个实例,实例提供查询和更新分布式帐号登录状态方法。 |
- 示例: - 示例:
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
``` ```
...@@ -50,7 +50,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): v ...@@ -50,7 +50,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): v
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | 是 | 获取分布式帐号信息的回调。 | | callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | 是 | 获取分布式帐号信息的回调。 |
- 示例: - 示例:
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => { accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
...@@ -73,7 +73,7 @@ queryOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt; ...@@ -73,7 +73,7 @@ queryOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt;
| Promise&lt;[DistributedInfo](#distributedinfo)&gt; | Promise实例,用于获取异步返回结果。 | | Promise&lt;[DistributedInfo](#distributedinfo)&gt; | Promise实例,用于获取异步返回结果。 |
- 示例: - 示例:
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => { accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name); console.log('Query account info name: ' + data.name);
...@@ -98,7 +98,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall ...@@ -98,7 +98,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall
| callback | AsyncCallback&lt;void&gt; | 是 | 更新分布式帐号信息的回调。 | | callback | AsyncCallback&lt;void&gt; | 是 | 更新分布式帐号信息的回调。 |
- 示例: - 示例:
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
...@@ -125,7 +125,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt ...@@ -125,7 +125,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 | | Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例: - 示例:
``` ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
......
...@@ -29,10 +29,10 @@ SystemCapability.Ability.Form ...@@ -29,10 +29,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formId | string | 是 | 卡片标识 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -72,7 +72,7 @@ SystemCapability.Ability.Form ...@@ -72,7 +72,7 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.deleteForm(formId).catch((error) => { formHost.deleteForm(formId).catch((error) => {
console.log('formProvider deleteForm, error:' + JSON.stringify(error)); console.log('formHost deleteForm, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -88,10 +88,10 @@ SystemCapability.Ability.Form ...@@ -88,10 +88,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formId | string | 是 | 卡片标识 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -116,11 +116,11 @@ SystemCapability.Ability.Form ...@@ -116,11 +116,11 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | ----------- | | -------------- | ------ | ---- | ----------- |
| formId | string | 是 | 卡片标识 | | formId | string | 是 | 卡片标识 |
| isReleaseCache | boolean | 是 | 是否释放缓存 | | isReleaseCache | boolean | 是 | 是否释放缓存 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -161,7 +161,7 @@ SystemCapability.Ability.Form ...@@ -161,7 +161,7 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.releaseForm(formId, true).catch((error) => { formHost.releaseForm(formId, true).catch((error) => {
console.log('formProvider releaseForm, error:' + JSON.stringify(error)); console.log('formHost releaseForm, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -177,10 +177,10 @@ SystemCapability.Ability.Form ...@@ -177,10 +177,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formId | string | 是 | 卡片标识 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -220,7 +220,7 @@ SystemCapability.Ability.Form ...@@ -220,7 +220,7 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.requestForm(formId).catch((error) => { formHost.requestForm(formId).catch((error) => {
console.log('formProvider requestForm, error:' + JSON.stringify(error)); console.log('formHost requestForm, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -236,10 +236,10 @@ SystemCapability.Ability.Form ...@@ -236,10 +236,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formId | string | 是 | 卡片标识 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -279,13 +279,13 @@ SystemCapability.Ability.Form ...@@ -279,13 +279,13 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.castTempForm(formId).catch((error) => { formHost.castTempForm(formId).catch((error) => {
console.log('formProvider castTempForm, error:' + JSON.stringify(error)); console.log('formHost castTempForm, error:' + JSON.stringify(error));
}); });
``` ```
## notifyVisibleForms ## notifyVisibleForms
notifyVisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void; notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。
...@@ -295,10 +295,10 @@ SystemCapability.Ability.Form ...@@ -295,10 +295,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -313,7 +313,7 @@ SystemCapability.Ability.Form ...@@ -313,7 +313,7 @@ SystemCapability.Ability.Form
## notifyVisibleForms ## notifyVisibleForms
notifyVisibleForms(formId: string): Promise&lt;void&gt;; notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。
...@@ -323,9 +323,9 @@ SystemCapability.Ability.Form ...@@ -323,9 +323,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
**返回值:** **返回值:**
...@@ -338,13 +338,13 @@ SystemCapability.Ability.Form ...@@ -338,13 +338,13 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.notifyVisibleForms(formId).catch((error) => { formHost.notifyVisibleForms(formId).catch((error) => {
console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error)); console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
}); });
``` ```
## notifyInvisibleForms ## notifyInvisibleForms
notifyInvisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void; notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。
...@@ -354,10 +354,10 @@ SystemCapability.Ability.Form ...@@ -354,10 +354,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -372,7 +372,7 @@ SystemCapability.Ability.Form ...@@ -372,7 +372,7 @@ SystemCapability.Ability.Form
## notifyInvisibleForms ## notifyInvisibleForms
notifyInvisibleForms(formId: string): Promise&lt;void&gt;; notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。
...@@ -382,9 +382,9 @@ SystemCapability.Ability.Form ...@@ -382,9 +382,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
**返回值:** **返回值:**
...@@ -397,13 +397,13 @@ SystemCapability.Ability.Form ...@@ -397,13 +397,13 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.notifyInvisibleForms(formId).catch((error) => { formHost.notifyInvisibleForms(formId).catch((error) => {
console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error)); console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
}); });
``` ```
## enableFormsUpdate ## enableFormsUpdate
enableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void; enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。
...@@ -413,10 +413,10 @@ SystemCapability.Ability.Form ...@@ -413,10 +413,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -431,7 +431,7 @@ SystemCapability.Ability.Form ...@@ -431,7 +431,7 @@ SystemCapability.Ability.Form
## enableFormsUpdate ## enableFormsUpdate
enableFormsUpdate(formId: string): Promise&lt;void&gt;; enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。
...@@ -441,9 +441,9 @@ SystemCapability.Ability.Form ...@@ -441,9 +441,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
**返回值:** **返回值:**
...@@ -456,13 +456,13 @@ SystemCapability.Ability.Form ...@@ -456,13 +456,13 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.enableFormsUpdate(formId).catch((error) => { formHost.enableFormsUpdate(formId).catch((error) => {
console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error)); console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
}); });
``` ```
## disableFormsUpdate ## disableFormsUpdate
disableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void; disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。
...@@ -472,10 +472,10 @@ SystemCapability.Ability.Form ...@@ -472,10 +472,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -490,7 +490,7 @@ SystemCapability.Ability.Form ...@@ -490,7 +490,7 @@ SystemCapability.Ability.Form
## disableFormsUpdate ## disableFormsUpdate
disableFormsUpdate(formId: string): Promise&lt;void&gt;; disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。
...@@ -500,9 +500,9 @@ SystemCapability.Ability.Form ...@@ -500,9 +500,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
**返回值:** **返回值:**
...@@ -515,7 +515,7 @@ SystemCapability.Ability.Form ...@@ -515,7 +515,7 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.disableFormsUpdate(formId).catch((error) => { formHost.disableFormsUpdate(formId).catch((error) => {
console.log('formProvider disableFormsUpdate, error:' + JSON.stringify(error)); console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -531,9 +531,9 @@ SystemCapability.Ability.Form ...@@ -531,9 +531,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -567,7 +567,7 @@ SystemCapability.Ability.Form ...@@ -567,7 +567,7 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formHost.isSystemReady().catch((error) => { formHost.isSystemReady().catch((error) => {
console.log('formProvider isSystemReady, error:' + JSON.stringify(error)); console.log('formHost isSystemReady, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -617,7 +617,7 @@ SystemCapability.Ability.Form ...@@ -617,7 +617,7 @@ SystemCapability.Ability.Form
```js ```js
formHost.getAllFormsInfo().catch((error) => { formHost.getAllFormsInfo().catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -641,7 +641,7 @@ SystemCapability.Ability.Form ...@@ -641,7 +641,7 @@ SystemCapability.Ability.Form
**示例:** **示例:**
```js ```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
if (error) { if (error) {
console.log('formHost getFormsInfo, error:' + error.code); console.log('formHost getFormsInfo, error:' + error.code);
} }
...@@ -669,7 +669,7 @@ SystemCapability.Ability.Form ...@@ -669,7 +669,7 @@ SystemCapability.Ability.Form
**示例:** **示例:**
```js ```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
if (error) { if (error) {
console.log('formHost getFormsInfo, error:' + error.code); console.log('formHost getFormsInfo, error:' + error.code);
} }
...@@ -702,8 +702,8 @@ SystemCapability.Ability.Form ...@@ -702,8 +702,8 @@ SystemCapability.Ability.Form
**示例:** **示例:**
```js ```js
formHost.getAllFormsInfo().catch((error) => { formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -719,10 +719,10 @@ SystemCapability.Ability.Form ...@@ -719,10 +719,10 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | 是 | 卡片标识列表 | | formIds | Array&lt;string&gt; | 是 | 有效卡片标识列表 |
| callback | AsyncCallback&lt;number&gt; | 是 | callback形式返回删除的卡片个数 | | callback | AsyncCallback&lt;number&gt; | 是 | callback形式返回删除的卡片个数 |
**示例:** **示例:**
...@@ -737,7 +737,7 @@ SystemCapability.Ability.Form ...@@ -737,7 +737,7 @@ SystemCapability.Ability.Form
## deleteInvalidForms ## deleteInvalidForms
function deleteInvalidForms(formIds: Array&ltstring&gt): Promise&lt;number&gt;; function deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;;
根据列表删除应用程序的无效卡片。 根据列表删除应用程序的无效卡片。
...@@ -747,9 +747,9 @@ SystemCapability.Ability.Form ...@@ -747,9 +747,9 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | 是 | 卡片标识列表 | | formIds | Array&lt;string&gt; | 是 | 有效卡片标识列表 |
**返回值:** **返回值:**
...@@ -762,7 +762,7 @@ SystemCapability.Ability.Form ...@@ -762,7 +762,7 @@ SystemCapability.Ability.Form
```js ```js
var formIds = new Array("12400633174999288", "12400633174999289"); var formIds = new Array("12400633174999288", "12400633174999289");
formHost.deleteInvalidForms(formIds).catch((error) => { formHost.deleteInvalidForms(formIds).catch((error) => {
console.log('formProvider deleteInvalidForms, error:' + JSON.stringify(error)); console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -806,9 +806,9 @@ function acquireFormState(want: Want): Promise&lt;FormStateInfo&gt;; ...@@ -806,9 +806,9 @@ function acquireFormState(want: Want): Promise&lt;FormStateInfo&gt;;
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | 是 | 卡片标识列表 | | want | [Want](js-apis-featureAbility.md#want) | 是 | 查询卡片状态时携带的want信息 |
**返回值:** **返回值:**
...@@ -829,7 +829,7 @@ SystemCapability.Ability.Form ...@@ -829,7 +829,7 @@ SystemCapability.Ability.Form
"abilityName": "com.extreme.test.MainAbility" "abilityName": "com.extreme.test.MainAbility"
}; };
formHost.acquireFormState(want).catch((error) => { formHost.acquireFormState(want).catch((error) => {
console.log('formProvider acquireFormState, error:' + JSON.stringify(error)); console.log('formHost acquireFormState, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -845,24 +845,23 @@ SystemCapability.Ability.Form ...@@ -845,24 +845,23 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 |
| callback | Callback&lt;string&gt; | 是 | 接口本身调用的回调方法 | | callback | Callback&lt;string&gt; | 是 | 需要注册的事件回调方法 |
**示例:** **示例:**
```js ```js
formHost.on("formUninstall", (error, data) => { let callback = function(formId) {
if (error) { console.log('formHost on formUninstall, formId:' + formId);
console.log('formHost on formUninstall, error:' + error.code);
} }
}); formHost.on("formUninstall", callback);
``` ```
## off("formUninstall") ## off("formUninstall")
off(type: "formUninstall", callback: Callback&lt;string&gt;): void; off(type: "formUninstall", callback?: Callback&lt;string&gt;): void;
取消订阅卡片卸载事件。 取消订阅卡片卸载事件。
...@@ -872,19 +871,18 @@ SystemCapability.Ability.Form ...@@ -872,19 +871,18 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 |
| callback | Callback&lt;string&gt; | 是 | 接口本身调用的回调方法 | | callback | Callback&lt;string&gt; | 否 | 需要注销的事件回调方法。缺省时,表示注销所有已注册事件回调 |
**示例:** **示例:**
```js ```js
formHost.off("formUninstall", (error, data) => { let callback = function(formId) {
if (error) { console.log('formHost on formUninstall, formId:' + formId);
console.log('formHost off formUninstall, error:' + error.code);
} }
}); formHost.off("formUninstall", callback);
``` ```
## notifyFormsVisible ## notifyFormsVisible
...@@ -899,11 +897,11 @@ SystemCapability.Ability.Form ...@@ -899,11 +897,11 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | 是 | 卡片标识列表 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| isVisible | boolean | 是 | 是否可见 | | isVisible | boolean | 是 | 是否可见 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -944,7 +942,7 @@ SystemCapability.Ability.Form ...@@ -944,7 +942,7 @@ SystemCapability.Ability.Form
```js ```js
var formIds = new Array("12400633174999288", "12400633174999289"); var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsVisible(formIds, true).catch((error) => { formHost.notifyFormsVisible(formIds, true).catch((error) => {
console.log('formProvider notifyFormsVisible, error:' + JSON.stringify(error)); console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -960,11 +958,11 @@ SystemCapability.Ability.Form ...@@ -960,11 +958,11 @@ SystemCapability.Ability.Form
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | 是 | 卡片标识列表 | | formIds | Array&lt;string&gt; | 是 | 卡片标识列表 |
| isEnableUpdate | boolean | 是 | 是否使能更新 | | isEnableUpdate | boolean | 是 | 是否使能更新 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回结果 |
**示例:** **示例:**
...@@ -1005,6 +1003,6 @@ SystemCapability.Ability.Form ...@@ -1005,6 +1003,6 @@ SystemCapability.Ability.Form
```js ```js
var formIds = new Array("12400633174999288", "12400633174999289"); var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => { formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => {
console.log('formProvider notifyFormsEnableUpdate, error:' + JSON.stringify(error)); console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
}); });
``` ```
\ No newline at end of file
...@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController ...@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController
| [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 |
- 示例 - 示例
``` ```js
var InputMethodController = inputMethod.getInputMethodController(); var InputMethodController = inputMethod.getInputMethodController();
``` ```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a> ## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
...@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting ...@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting
- 示例 - 示例
``` ```js
var InputMethodSetting = inputMethod.getInputMethodSetting(); var InputMethodSetting = inputMethod.getInputMethodSetting();
``` ```
...@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
- 示例 - 示例
``` ```js
InputMethodController.stopInput((error)=>{ InputMethodController.stopInput((error)=>{
console.info('stopInput'); console.info('stopInput');
}); });
...@@ -113,7 +113,7 @@ stopInput(): Promise&lt;boolean&gt; ...@@ -113,7 +113,7 @@ stopInput(): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = InputMethodController.stopInput(); var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess); console.info('stopInput isSuccess = ' + isSuccess);
``` ```
...@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 |
- 示例 - 示例
``` ```js
InputMethodSetting.listInputMethod((properties)=>{ InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
...@@ -159,7 +159,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -159,7 +159,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 | | Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 |
- 示例 - 示例
``` ```js
var properties = InputMethodSetting.listInputMethod(); var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
...@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
- 示例 - 示例
``` ```js
InputMethodSetting.displayOptionalInputMethod(()=>{ InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called'); console.info('displayOptionalInputMethod is called');
}); });
...@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| Promise&lt;void&gt; | 回调函数。 | | Promise&lt;void&gt; | 回调函数。 |
- 示例 - 示例
``` ```js
InputMethodSetting.displayOptionalInputMethod(); InputMethodSetting.displayOptionalInputMethod();
``` ```
\ No newline at end of file
...@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine ...@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine
- 示例 - 示例
``` ```js
var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
``` ```
...@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate ...@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate
- 示例 - 示例
``` ```js
var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
``` ```
...@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli ...@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
- 示例: - 示例:
``` ```js
InputMethodEngine.on('inputStart', (kbController, textInputClient) => { InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
KeyboardController = kbController; KeyboardController = kbController;
TextInputClient = textInputClient; TextInputClient = textInputClient;
...@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC ...@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
- 示例: - 示例:
``` ```js
InputMethodEngine.off('inputStart'); InputMethodEngine.off('inputStart');
``` ```
...@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
- 示例: - 示例:
``` ```js
InputMethodEngine.on('keyboardShow', (err) => { InputMethodEngine.on('keyboardShow', (err) => {
console.info('keyboardShow'); console.info('keyboardShow');
}); });
...@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
- 示例: - 示例:
``` ```js
InputMethodEngine.off('keyboardShow'); InputMethodEngine.off('keyboardShow');
``` ```
...@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void ...@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('keyDown', (event) => { KeyboardDelegate.on('keyDown', (event) => {
console.info('keyDown'); console.info('keyDown');
}); });
...@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void ...@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('keyDown'); KeyboardDelegate.off('keyDown');
``` ```
...@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = ...@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('cursorContextChange', (x, y, height) => { KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info('cursorContextChange'); console.info('cursorContextChange');
}); });
...@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) ...@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('cursorContextChange'); KeyboardDelegate.off('cursorContextChange');
``` ```
### on('selectionChange') ### on('selectionChange')
...@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi ...@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info('selectionChange'); console.info('selectionChange');
}); });
...@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe ...@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('selectionChange'); KeyboardDelegate.off('selectionChange');
``` ```
...@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('textChange', (text) => { KeyboardDelegate.on('textChange', (text) => {
console.info('textChange'); console.info('textChange');
}); });
...@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void ...@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('textChange'); KeyboardDelegate.off('textChange');
``` ```
...@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
- 示例 - 示例
``` ```js
KeyboardController.hideKeyboard(()=>{ KeyboardController.hideKeyboard(()=>{
}); });
``` ```
...@@ -408,7 +408,7 @@ hideKeyboard(): Promise&lt;void&gt; ...@@ -408,7 +408,7 @@ hideKeyboard(): Promise&lt;void&gt;
- 示例 - 示例
``` ```js
KeyboardController.hideKeyboard(); KeyboardController.hideKeyboard();
``` ```
...@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 | | callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例 - 示例
``` ```js
TextInputClient.getForward(5,(text) =>{ TextInputClient.getForward(5,(text) =>{
console.info("text = " + text); console.info("text = " + text);
}); });
...@@ -458,7 +458,7 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -458,7 +458,7 @@ getForward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 | | Promise&lt;string&gt; | 返回文本。 |
- 示例 - 示例
``` ```js
var text = TextInputClient.getForward(5); var text = TextInputClient.getForward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
...@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 | | callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例 - 示例
``` ```js
TextInputClient.getBackward(5,(text)=>{ TextInputClient.getBackward(5,(text)=>{
console.info("text = " + text); console.info("text = " + text);
}); });
...@@ -505,7 +505,7 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -505,7 +505,7 @@ getBackward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 | | Promise&lt;string&gt; | 返回文本。 |
- 示例 - 示例
``` ```js
var text = TextInputClient.getBackward(5); var text = TextInputClient.getBackward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
...@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.deleteForward(5,(isSuccess)=>{ TextInputClient.deleteForward(5,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -551,7 +551,7 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -551,7 +551,7 @@ deleteForward(length:number): Promise&lt;boolean&gt;
| Promise&lt;boolean&gt; | 操作成功与否。 | | Promise&lt;boolean&gt; | 操作成功与否。 |
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.deleteForward(5); var isSuccess = TextInputClient.deleteForward(5);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.deleteBackward(5, (isSuccess)=>{ TextInputClient.deleteBackward(5, (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.deleteBackward(5); var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt; ...@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.insertText("test", (isSuccess)=>{ TextInputClient.insertText("test", (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -691,7 +691,7 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -691,7 +691,7 @@ insertText(text:string): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.insertText("test"); var isSuccess = TextInputClient.insertText("test");
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 编辑框属性值。 | | callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 编辑框属性值。 |
- 示例 - 示例
``` ```js
TextInputClient.getEditorAttribute((EditorAttribute)=>{ TextInputClient.getEditorAttribute((EditorAttribute)=>{
}); });
``` ```
...@@ -729,7 +729,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -729,7 +729,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
| Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | 返回编辑框属性值。 | | Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | 返回编辑框属性值。 |
- 示例 - 示例
``` ```js
var EditorAttribute = TextInputClient.getEditorAttribute(); var EditorAttribute = TextInputClient.getEditorAttribute();
``` ```
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```js
import account_osAccount from '@ohos.account.osAccount'; import account_osAccount from '@ohos.account.osAccount';
``` ```
...@@ -24,7 +24,7 @@ getAccountManager(): AccountManager ...@@ -24,7 +24,7 @@ getAccountManager(): AccountManager
| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | | [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 |
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
``` ```
...@@ -64,7 +64,7 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -64,7 +64,7 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**示例:**激活ID为100的系统帐号 **示例:**激活ID为100的系统帐号
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.activateOsAccount(localId, (err)=>{ accountManager.activateOsAccount(localId, (err)=>{
...@@ -97,7 +97,7 @@ activateOsAccount(localId: number): Promise&lt;void&gt; ...@@ -97,7 +97,7 @@ activateOsAccount(localId: number): Promise&lt;void&gt;
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 | | Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**激活ID为100的系统帐号 **示例:**激活ID为100的系统帐号
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.activateOsAccount(localId).then(() => { accountManager.activateOsAccount(localId).then(() => {
...@@ -123,7 +123,7 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -123,7 +123,7 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => { accountManager.isMultiOsAccountEnable((err, isEnabled) => {
console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
...@@ -147,7 +147,7 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt; ...@@ -147,7 +147,7 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled) => { accountManager.isMultiOsAccountEnable().then((isEnabled) => {
console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
...@@ -175,7 +175,7 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi ...@@ -175,7 +175,7 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi
**示例:**判断ID为100的系统帐号是否处于激活状态 **示例:**判断ID为100的系统帐号是否处于激活状态
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
...@@ -208,7 +208,7 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt; ...@@ -208,7 +208,7 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt;
**示例:**判断ID为100的系统帐号是否处于激活状态 **示例:**判断ID为100的系统帐号是否处于激活状态
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100; var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId).then((isActive) => { accountManager.isOsAccountActived(osLocalId).then((isActive) => {
...@@ -238,7 +238,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async ...@@ -238,7 +238,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{
...@@ -272,7 +272,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boo ...@@ -272,7 +272,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boo
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => {
...@@ -298,7 +298,7 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -298,7 +298,7 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTest) => { accountManager.isTestOsAccount((err, isTest) => {
console.log("isTestOsAccount err: " + JSON.stringify(err)); console.log("isTestOsAccount err: " + JSON.stringify(err));
...@@ -322,7 +322,7 @@ isTestOsAccount(): Promise&lt;boolean&gt; ...@@ -322,7 +322,7 @@ isTestOsAccount(): Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTest) => { accountManager.isTestOsAccount().then((isTest) => {
console.log('isTestOsAccount, isTest: ' + isTest); console.log('isTestOsAccount, isTest: ' + isTest);
...@@ -347,7 +347,7 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -347,7 +347,7 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => { accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err)); console.log("isOsAccountVerified err: " + JSON.stringify(err));
...@@ -374,7 +374,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo ...@@ -374,7 +374,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => { accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err)); console.log("isOsAccountVerified err: " + JSON.stringify(err));
...@@ -406,7 +406,7 @@ isOsAccountVerified(localId?: number): Promise&lt;boolean&gt; ...@@ -406,7 +406,7 @@ isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified().then((isVerified) => { accountManager.isOsAccountVerified().then((isVerified) => {
console.log('isOsAccountVerified, isVerified: ' + isVerified); console.log('isOsAccountVerified, isVerified: ' + isVerified);
...@@ -436,7 +436,7 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -436,7 +436,7 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
...@@ -473,7 +473,7 @@ removeOsAccount(localId: number): Promise&lt;void&gt; ...@@ -473,7 +473,7 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
...@@ -510,7 +510,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl ...@@ -510,7 +510,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
**示例:**给ID为100的系统帐号设置禁止使用wifi的约束 **示例:**给ID为100的系统帐号设置禁止使用wifi的约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{
...@@ -546,7 +546,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl ...@@ -546,7 +546,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
**示例:**删除ID为100的系统帐号的禁止使用wifi的约束 **示例:**删除ID为100的系统帐号的禁止使用wifi的约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => {
...@@ -578,7 +578,7 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt; ...@@ -578,7 +578,7 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;
**示例:**将ID为100的系统帐号的帐号名设置成demoName **示例:**将ID为100的系统帐号的帐号名设置成demoName
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var newName = "demoName"; var newName = "demoName";
...@@ -614,7 +614,7 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt; ...@@ -614,7 +614,7 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
**示例:**将ID为100的系统帐号的帐号名设置成demoName **示例:**将ID为100的系统帐号的帐号名设置成demoName
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var nameLimit = "demoName"; var nameLimit = "demoName";
...@@ -643,7 +643,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void ...@@ -643,7 +643,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); console.log("obtains the number of all os accounts created err:" + JSON.stringify(err));
...@@ -669,7 +669,7 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt; ...@@ -669,7 +669,7 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((accountCnt) => { accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
...@@ -694,7 +694,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void ...@@ -694,7 +694,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
...@@ -718,7 +718,7 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt; ...@@ -718,7 +718,7 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
...@@ -744,7 +744,7 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): ...@@ -744,7 +744,7 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;):
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID **示例:**查询值为12345678的uid所属的系统帐号的帐号ID
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
...@@ -775,7 +775,7 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt; ...@@ -775,7 +775,7 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID **示例:**查询值为12345678的uid所属的系统帐号的帐号ID
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
...@@ -804,7 +804,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall ...@@ -804,7 +804,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
**示例:** **示例:**
``` ```js
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
...@@ -837,7 +837,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number& ...@@ -837,7 +837,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
...@@ -865,7 +865,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void ...@@ -865,7 +865,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err));
...@@ -891,7 +891,7 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt; ...@@ -891,7 +891,7 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber().then((maxCnt) => { accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
...@@ -919,7 +919,7 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt; ...@@ -919,7 +919,7 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;
**示例:**获取ID为100的系统帐号的全部约束 **示例:**获取ID为100的系统帐号的全部约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
...@@ -952,7 +952,7 @@ getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt; ...@@ -952,7 +952,7 @@ getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
**示例:**获取ID为100的系统帐号的全部约束 **示例:**获取ID为100的系统帐号的全部约束
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints) => { accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
...@@ -980,7 +980,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;& ...@@ -980,7 +980,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err));
...@@ -1006,7 +1006,7 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt; ...@@ -1006,7 +1006,7 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts().then((accountArr) => { accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
...@@ -1031,7 +1031,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): ...@@ -1031,7 +1031,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;):
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err, idArray)=>{ accountManager.queryActivatedOsAccountIds((err, idArray)=>{
console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err));
...@@ -1058,7 +1058,7 @@ queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt; ...@@ -1058,7 +1058,7 @@ queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray) => { accountManager.queryActivatedOsAccountIds().then((idArray) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray); console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
...@@ -1089,7 +1089,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& ...@@ -1089,7 +1089,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.log("createOsAccount err:" + JSON.stringify(err)); console.log("createOsAccount err:" + JSON.stringify(err));
...@@ -1124,7 +1124,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf ...@@ -1124,7 +1124,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
...@@ -1155,7 +1155,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal ...@@ -1155,7 +1155,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
...@@ -1191,7 +1191,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr ...@@ -1191,7 +1191,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
...@@ -1219,7 +1219,7 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void ...@@ -1219,7 +1219,7 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); console.log("queryCurrentOsAccount err:" + JSON.stringify(err));
...@@ -1245,7 +1245,7 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt; ...@@ -1245,7 +1245,7 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo) => { accountManager.queryCurrentOsAccount().then((accountInfo) => {
console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo));
...@@ -1275,7 +1275,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt; ...@@ -1275,7 +1275,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;
**示例:**查询ID为100的系统帐号信息 **示例:**查询ID为100的系统帐号信息
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
...@@ -1310,7 +1310,7 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt; ...@@ -1310,7 +1310,7 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
**示例:**查询ID为100的系统帐号信息 **示例:**查询ID为100的系统帐号信息
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.queryOsAccountById(localId).then((accountInfo) => { accountManager.queryOsAccountById(localId).then((accountInfo) => {
...@@ -1336,7 +1336,7 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void ...@@ -1336,7 +1336,7 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err, accountType) => { accountManager.getOsAccountTypeFromProcess((err, accountType) => {
console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
...@@ -1360,7 +1360,7 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt; ...@@ -1360,7 +1360,7 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType) => { accountManager.getOsAccountTypeFromProcess().then((accountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
...@@ -1387,7 +1387,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void ...@@ -1387,7 +1387,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err, virtualID) => { accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
...@@ -1413,7 +1413,7 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt; ...@@ -1413,7 +1413,7 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt;
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID) => { accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
...@@ -1443,7 +1443,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;) ...@@ -1443,7 +1443,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;)
**示例:**获取ID为100的系统帐号的头像 **示例:**获取ID为100的系统帐号的头像
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
...@@ -1478,7 +1478,7 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt; ...@@ -1478,7 +1478,7 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
**示例:**获取ID为100的系统帐号的头像 **示例:**获取ID为100的系统帐号的头像
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getOsAccountProfilePhoto(localId).then((photo) => { accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
...@@ -1510,7 +1510,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback ...@@ -1510,7 +1510,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
**示例:**给ID为100的系统帐号设置头像 **示例:**给ID为100的系统帐号设置头像
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
...@@ -1549,7 +1549,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt; ...@@ -1549,7 +1549,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
**示例:**给ID为100的系统帐号设置头像 **示例:**给ID为100的系统帐号设置头像
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
...@@ -1580,7 +1580,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& ...@@ -1580,7 +1580,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&
**示例:**查询与SN码12345关联的系统帐号的ID **示例:**查询与SN码12345关联的系统帐号的ID
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
...@@ -1611,7 +1611,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt; ...@@ -1611,7 +1611,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
**示例:**查询与SN码12345关联的系统帐号的ID **示例:**查询与SN码12345关联的系统帐号的ID
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345; var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
...@@ -1638,7 +1638,7 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;nu ...@@ -1638,7 +1638,7 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;nu
**示例:**获取ID为100的系统帐号关联的SN码 **示例:**获取ID为100的系统帐号关联的SN码
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
...@@ -1669,7 +1669,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt; ...@@ -1669,7 +1669,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
**示例:**获取ID为100的系统帐号关联的SN码 **示例:**获取ID为100的系统帐号关联的SN码
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var localId = 100; var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
...@@ -1701,7 +1701,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g ...@@ -1701,7 +1701,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
function onCallback(receiveLocalId){ function onCallback(receiveLocalId){
console.log("receive localId:" + receiveLocalId); console.log("receive localId:" + receiveLocalId);
...@@ -1731,7 +1731,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number ...@@ -1731,7 +1731,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
**示例:** **示例:**
``` ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
function offCallback(){ function offCallback(){
console.log("off enter") console.log("off enter")
......
...@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData ...@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
``` ```
...@@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData ...@@ -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 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 pasteData = pasteboard.createHtmlData(html);
``` ```
...@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData ...@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData ...@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord ...@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord
**示例** **示例**
``` ```js
var record = pasteboard.createPlainTextRecord("hello"); var record = pasteboard.createPlainTextRecord("hello");
``` ```
...@@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord ...@@ -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 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); var record = pasteboard.createHtmlTextRecord(html);
``` ```
...@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord ...@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord ...@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -284,7 +284,7 @@ convertToText(): Promise&lt;string&gt; ...@@ -284,7 +284,7 @@ convertToText(): Promise&lt;string&gt;
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => { record.convertToText().then((data) => {
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
...@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void ...@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => { record.convertToText((err, data) => {
if (err) { if (err) {
...@@ -346,7 +346,7 @@ getPrimaryText(): string ...@@ -346,7 +346,7 @@ getPrimaryText(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var plainText = pasteData.getPrimaryText(); var plainText = pasteData.getPrimaryText();
``` ```
...@@ -367,7 +367,7 @@ getPrimaryHtml(): string ...@@ -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 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 pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml(); var htmlText = pasteData.getPrimaryHtml();
...@@ -389,7 +389,7 @@ getPrimaryWant(): Want ...@@ -389,7 +389,7 @@ getPrimaryWant(): Want
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -414,7 +414,7 @@ getPrimaryUri(): string ...@@ -414,7 +414,7 @@ getPrimaryUri(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri(); var uri = pasteData.getPrimaryUri();
``` ```
...@@ -437,7 +437,7 @@ addTextRecord(text: string): void ...@@ -437,7 +437,7 @@ addTextRecord(text: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addTextRecord("good"); pasteData.addTextRecord("good");
``` ```
...@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void ...@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); 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>"; 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); pasteData.addHtmlRecord(html);
...@@ -484,7 +484,7 @@ addWantRecord(want: Want): void ...@@ -484,7 +484,7 @@ addWantRecord(want: Want): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
...@@ -511,7 +511,7 @@ addUriRecord(uri: string): void ...@@ -511,7 +511,7 @@ addUriRecord(uri: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void ...@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var textRecord = pasteboard.createPlainTextRecord("hello"); 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>"; 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; ...@@ -559,7 +559,7 @@ getMimeTypes(): Array&lt;string&gt;
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes(); var types = pasteData.getMimeTypes();
``` ```
...@@ -580,7 +580,7 @@ getPrimaryMimeType(): string ...@@ -580,7 +580,7 @@ getPrimaryMimeType(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType(); var type = pasteData.getPrimaryMimeType();
``` ```
...@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty ...@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var property = pasteData.getProperty(); var property = pasteData.getProperty();
``` ```
...@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord ...@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteData.getRecordAt(0); var record = pasteData.getRecordAt(0);
``` ```
...@@ -648,7 +648,7 @@ getRecordCount(): number ...@@ -648,7 +648,7 @@ getRecordCount(): number
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount(); var count = pasteData.getRecordCount();
``` ```
...@@ -669,7 +669,7 @@ getTag(): string ...@@ -669,7 +669,7 @@ getTag(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var tag = pasteData.getTag(); var tag = pasteData.getTag();
``` ```
...@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean ...@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
...@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean ...@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var isRemove = pasteData.removeRecordAt(0); var isRemove = pasteData.removeRecordAt(0);
``` ```
...@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean ...@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
var isReplace = pasteData.replaceRecordAt(0, record); var isReplace = pasteData.replaceRecordAt(0, record);
...@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard ...@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
...@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void ...@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (error, data) => { systemPasteboard.setPasteData(pasteData, (error, data) => {
...@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise&lt;void&gt; ...@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise&lt;void&gt;
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => { systemPasteboard.setPasteData(pasteData).then((data) => {
...@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void ...@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((error, pasteData) => { systemPasteboard.getPasteData((error, pasteData) => {
if (error) { if (error) {
...@@ -886,7 +886,7 @@ getPasteData(): Promise&lt;PasteData&gt; ...@@ -886,7 +886,7 @@ getPasteData(): Promise&lt;PasteData&gt;
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => { systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
...@@ -912,7 +912,7 @@ on(type: 'update', callback: () =&gt;void ): void ...@@ -912,7 +912,7 @@ on(type: 'update', callback: () =&gt;void ): void
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
var listener = ()=>{ var listener = ()=>{
console.info('The system pasteboard has changed'); console.info('The system pasteboard has changed');
...@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =&gt;void ): void ...@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =&gt;void ): void
**示例** **示例**
``` ```js
systemPasteboard.off('update', listener); systemPasteboard.off('update', listener);
``` ```
...@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void
**示例** **示例**
``` ```js
systemPasteboard.hasPasteData((err, data) => { systemPasteboard.hasPasteData((err, data) => {
if (err) { if (err) {
console.error('failed to hasPasteData because ' + JSON.stringify(err)); console.error('failed to hasPasteData because ' + JSON.stringify(err));
...@@ -983,7 +983,7 @@ hasPasteData(): Promise&lt;boolean&gt; ...@@ -983,7 +983,7 @@ hasPasteData(): Promise&lt;boolean&gt;
**示例** **示例**
``` ```js
systemPasteboard.hasPasteData().then((data) => { systemPasteboard.hasPasteData().then((data) => {
console.info('success hasPasteData : ' + JSON.stringify(data)); console.info('success hasPasteData : ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```js
systemPasteboard.clear((err, data) => { systemPasteboard.clear((err, data) => {
if (err) { if (err) {
console.error('failed to clear because ' + JSON.stringify(err)); console.error('failed to clear because ' + JSON.stringify(err));
...@@ -1034,7 +1034,7 @@ clear(): Promise&lt;void&gt; ...@@ -1034,7 +1034,7 @@ clear(): Promise&lt;void&gt;
**示例** **示例**
``` ```js
systemPasteboard.clear().then((data) => { systemPasteboard.clear().then((data) => {
console.info('success clear'); console.info('success clear');
}).catch((error) => { }).catch((error) => {
......
...@@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise&lt;UploadTask&gt; ...@@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise&lt;UploadTask&gt;
- 示例: - 示例:
``` ```js
request.upload({ url: 'https://patch' }).then((data) => { request.upload({ url: 'https://patch' }).then((data) => {
uploadTask = data; uploadTask = data;
}).catch((err) => { }).catch((err) => {
...@@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void ...@@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void
- 示例: - 示例:
``` ```js
request.upload({ url: 'https://patch' }, (err, data) => { request.upload({ url: 'https://patch' }, (err, data) => {
if (err) { if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(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 ...@@ -142,14 +142,14 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; vo
回调函数的参数: 回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | | totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
- 示例: - 示例:
``` ```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) { uploadTask.on('progress', function callback(uploadedSize, totalSize) {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
} }
...@@ -175,13 +175,13 @@ on(type: 'headerReceive', callback: (header: object) =&gt; void): void ...@@ -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){ uploadTask.on('headerReceive', function callback(headers){
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
...@@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g ...@@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
回调函数的参数: 回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | | totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
- 示例: - 示例:
``` ```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) { uploadTask.off('progress', function callback(uploadedSize, totalSize) {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
} }
...@@ -240,13 +240,13 @@ off(type: 'headerReceive', callback?: (header: object) =&gt; void): void ...@@ -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) { uploadTask.off('headerReceive', function callback(headers) {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
...@@ -271,7 +271,7 @@ remove(): Promise&lt;boolean&gt; ...@@ -271,7 +271,7 @@ remove(): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
uploadTask.remove().then((result) => { uploadTask.remove().then((result) => {
if (result) { if (result) {
console.info('Upload task removed successfully. '); console.info('Upload task removed successfully. ');
...@@ -301,7 +301,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -301,7 +301,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
- 示例 - 示例
``` ```js
uploadTask.remove((err, result) => { uploadTask.remove((err, result) => {
if (err) { if (err) {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
...@@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise&lt;DownloadTask&gt; ...@@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise&lt;DownloadTask&gt;
- 示例 - 示例
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
downloadTask = data; downloadTask = data;
}).catch((err) => { }).catch((err) => {
...@@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): v ...@@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): v
- 示例 - 示例
``` ```js
request.download({ url: 'https://xxxx/xxxxx.hap', request.download({ url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => { filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) { if (err) {
...@@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; vo ...@@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; vo
回调函数的参数: 回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 | | receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 | | totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
- 示例: - 示例:
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; ...@@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt;
回调函数的参数: 回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 | | receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 | | totalSize | number | 是 | 下载文件的总大小。 |
- 示例: - 示例:
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void ...@@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void
- 示例: - 示例:
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void ...@@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void
- 示例: - 示例:
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + JSON.stringify(err)); console.error('Failed to request download. Cause:' + JSON.stringify(err));
...@@ -581,13 +581,13 @@ on(type: 'fail', callback: (err: number) =&gt; void): void ...@@ -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)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -620,13 +620,13 @@ off(type: 'fail', callback?: (err: number) =&gt; void): void ...@@ -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)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -658,7 +658,7 @@ remove(): Promise&lt;boolean&gt; ...@@ -658,7 +658,7 @@ remove(): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
downloadTask.remove().then((result) => { downloadTask.remove().then((result) => {
if (result) { if (result) {
console.info('Download task removed.'); console.info('Download task removed.');
...@@ -688,7 +688,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -688,7 +688,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
- 示例 - 示例
``` ```js
downloadTask.remove((err, result)=>{ downloadTask.remove((err, result)=>{
if(err) { if(err) {
console.error('Failed to remove the download task.'); console.error('Failed to remove the download task.');
...@@ -720,7 +720,7 @@ query(): Promise&lt;DownloadInfo&gt; ...@@ -720,7 +720,7 @@ query(): Promise&lt;DownloadInfo&gt;
- 示例 - 示例
``` ```js
downloadTask.query().then((downloadInfo) => { downloadTask.query().then((downloadInfo) => {
console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
}) .catch((err) => { }) .catch((err) => {
...@@ -746,7 +746,7 @@ query(callback: AsyncCallback&lt;DownloadInfo&gt;): void ...@@ -746,7 +746,7 @@ query(callback: AsyncCallback&lt;DownloadInfo&gt;): void
- 示例: - 示例:
``` ```js
downloadTask.query((err, downloadInfo)=>{ downloadTask.query((err, downloadInfo)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
...@@ -774,7 +774,7 @@ queryMimeType(): Promise&lt;string&gt; ...@@ -774,7 +774,7 @@ queryMimeType(): Promise&lt;string&gt;
- 示例 - 示例
``` ```js
downloadTask.queryMimeType().then((data) => { downloadTask.queryMimeType().then((data) => {
console.info('Download task queried. Data:' + JSON.stringify(data)); console.info('Download task queried. Data:' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback&lt;string&gt;): void; ...@@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback&lt;string&gt;): void;
- 示例 - 示例
``` ```js
downloadTask.queryMimeType((err, data)=>{ downloadTask.queryMimeType((err, data)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
...@@ -828,7 +828,7 @@ pause(): Promise&lt;void&gt; ...@@ -828,7 +828,7 @@ pause(): Promise&lt;void&gt;
- 示例 - 示例
``` ```js
downloadTask.pause().then((result) => { downloadTask.pause().then((result) => {
if (result) { if (result) {
console.info('Download task paused. '); console.info('Download task paused. ');
...@@ -858,7 +858,7 @@ pause(callback: AsyncCallback&lt;void&gt;): void ...@@ -858,7 +858,7 @@ pause(callback: AsyncCallback&lt;void&gt;): void
- 示例 - 示例
``` ```js
downloadTask.pause((err, result)=>{ downloadTask.pause((err, result)=>{
if(err) { if(err) {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
...@@ -890,7 +890,7 @@ resume(): Promise&lt;void&gt; ...@@ -890,7 +890,7 @@ resume(): Promise&lt;void&gt;
- 示例 - 示例
``` ```js
downloadTask.resume().then((result) => { downloadTask.resume().then((result) => {
if (result) { if (result) {
console.info('Download task resumed.') console.info('Download task resumed.')
...@@ -921,7 +921,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void ...@@ -921,7 +921,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void
- 示例 - 示例
``` ```js
downloadTask.resume((err, result)=>{ downloadTask.resume((err, result)=>{
if (err) { if (err) {
console.error('Failed to resume the download task. Cause:' + err); console.error('Failed to resume the download task. Cause:' + err);
......
...@@ -30,7 +30,7 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void ...@@ -30,7 +30,7 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void
- 示例: - 示例:
``` ```js
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time, (error, data) => { systemTime.setTime(time, (error, data) => {
...@@ -65,7 +65,7 @@ setTime(time : number) : Promise&lt;void&gt; ...@@ -65,7 +65,7 @@ setTime(time : number) : Promise&lt;void&gt;
- 示例: - 示例:
``` ```js
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time).then((data) => { systemTime.setTime(time).then((data) => {
...@@ -92,7 +92,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -92,7 +92,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
...@@ -123,7 +123,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -123,7 +123,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -148,7 +148,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -148,7 +148,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));
...@@ -179,7 +179,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -179,7 +179,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -204,7 +204,7 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void ...@@ -204,7 +204,7 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
...@@ -235,7 +235,7 @@ getRealTime(): Promise&lt;number&gt; ...@@ -235,7 +235,7 @@ getRealTime(): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -262,7 +262,7 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void ...@@ -262,7 +262,7 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void
- 示例: - 示例:
``` ```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
if (error) { if (error) {
...@@ -296,7 +296,7 @@ setDate(date: Date): Promise&lt;void&gt; ...@@ -296,7 +296,7 @@ setDate(date: Date): Promise&lt;void&gt;
- 示例: - 示例:
``` ```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); console.log(`systemTime.setDate success data : ` + JSON.stringify(value));
...@@ -321,7 +321,7 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void ...@@ -321,7 +321,7 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void
- 示例: - 示例:
``` ```js
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
...@@ -347,7 +347,7 @@ getDate(): Promise&lt;Date&gt; ...@@ -347,7 +347,7 @@ getDate(): Promise&lt;Date&gt;
- 示例: - 示例:
``` ```js
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -374,7 +374,7 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -374,7 +374,7 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void
- 示例: - 示例:
``` ```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));
...@@ -407,7 +407,7 @@ setTimezone(timezone: string): Promise&lt;void&gt; ...@@ -407,7 +407,7 @@ setTimezone(timezone: string): Promise&lt;void&gt;
- 示例: - 示例:
``` ```js
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -431,7 +431,7 @@ getTimezone(callback: AsyncCallback&lt;string&gt;): void ...@@ -431,7 +431,7 @@ getTimezone(callback: AsyncCallback&lt;string&gt;): void
- 示例: - 示例:
``` ```js
systemTime.getTimezone((error, data) => { systemTime.getTimezone((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
...@@ -457,7 +457,7 @@ getTimezone(): Promise&lt;string&gt; ...@@ -457,7 +457,7 @@ getTimezone(): Promise&lt;string&gt;
- 示例: - 示例:
``` ```js
systemTime.getTimezone().then((data) => { systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
......
...@@ -18,7 +18,7 @@ import wallpaper from '@ohos.wallpaper'; ...@@ -18,7 +18,7 @@ import wallpaper from '@ohos.wallpaper';
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 说明 | | 名称 | 说明 |
| -------- | -------- | | -------- | -------- |
| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | | WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 |
| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | | WALLPAPER_SYSTEM | 主屏幕壁纸标识。 |
...@@ -40,7 +40,7 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;Rgba ...@@ -40,7 +40,7 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;Rgba
- 示例: - 示例:
``` ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getColors because: ` + JSON.stringify(error)); console.error(`failed to getColors because: ` + JSON.stringify(error));
...@@ -71,7 +71,7 @@ getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt; ...@@ -71,7 +71,7 @@ getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt;
- 示例: - 示例:
``` ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getColors.`); console.log(`success to getColors.`);
}).catch((error) => { }).catch((error) => {
...@@ -96,7 +96,7 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void ...@@ -96,7 +96,7 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
...@@ -128,7 +128,7 @@ getId(wallpaperType: WallpaperType): Promise&lt;number&gt; ...@@ -128,7 +128,7 @@ getId(wallpaperType: WallpaperType): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -152,7 +152,7 @@ getMinHeight(callback: AsyncCallback&lt;number&gt;): void ...@@ -152,7 +152,7 @@ getMinHeight(callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.getMinHeight((error, data) => { wallpaper.getMinHeight((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
...@@ -179,7 +179,7 @@ getMinHeight(): Promise&lt;number&gt; ...@@ -179,7 +179,7 @@ getMinHeight(): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
wallpaper.getMinHeight().then((data) => { wallpaper.getMinHeight().then((data) => {
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -204,7 +204,7 @@ getMinWidth(callback: AsyncCallback&lt;number&gt;): void ...@@ -204,7 +204,7 @@ getMinWidth(callback: AsyncCallback&lt;number&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.getMinWidth((error, data) => { wallpaper.getMinWidth((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
...@@ -230,7 +230,7 @@ getMinWidth(): Promise&lt;number&gt; ...@@ -230,7 +230,7 @@ getMinWidth(): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
wallpaper.getMinWidth().then((data) => { wallpaper.getMinWidth().then((data) => {
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -254,7 +254,7 @@ isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -254,7 +254,7 @@ isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.isChangePermitted((error, data) => { wallpaper.isChangePermitted((error, data) => {
if (error) { if (error) {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
...@@ -280,7 +280,7 @@ isChangePermitted(): Promise&lt;boolean&gt; ...@@ -280,7 +280,7 @@ isChangePermitted(): Promise&lt;boolean&gt;
- 示例: - 示例:
``` ```js
wallpaper.isChangePermitted().then((data) => { wallpaper.isChangePermitted().then((data) => {
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -304,7 +304,7 @@ isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -304,7 +304,7 @@ isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.isOperationAllowed((error, data) => { wallpaper.isOperationAllowed((error, data) => {
if (error) { if (error) {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
...@@ -330,7 +330,7 @@ isOperationAllowed(): Promise&lt;boolean&gt; ...@@ -330,7 +330,7 @@ isOperationAllowed(): Promise&lt;boolean&gt;
- 示例: - 示例:
``` ```js
wallpaper.isOperationAllowed().then((data) => { wallpaper.isOperationAllowed().then((data) => {
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -357,7 +357,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void ...@@ -357,7 +357,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
- 示例: - 示例:
``` ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
...@@ -390,7 +390,7 @@ reset(wallpaperType: WallpaperType): Promise&lt;void&gt; ...@@ -390,7 +390,7 @@ reset(wallpaperType: WallpaperType): Promise&lt;void&gt;
- 示例: - 示例:
``` ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`); console.log(`success to reset.`);
}).catch((error) => { }).catch((error) => {
...@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call ...@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call
- 示例: - 示例:
``` ```js
// source类型为string // source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
...@@ -475,7 +475,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro ...@@ -475,7 +475,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro
- 示例: - 示例:
``` ```js
// source类型为string // source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
...@@ -522,7 +522,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo ...@@ -522,7 +522,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo
- 示例: - 示例:
``` ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
...@@ -554,7 +554,7 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt; ...@@ -554,7 +554,7 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
- 示例: - 示例:
``` ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType ...@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType
- 示例: - 示例:
``` ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
...@@ -603,7 +603,7 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy ...@@ -603,7 +603,7 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
- 示例: - 示例:
``` ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
...@@ -619,7 +619,7 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy ...@@ -619,7 +619,7 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 | | red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 | | green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
......
# init启动引导组件<a name="ZH-CN_TOPIC_0000001062722441"></a> # init启动引导组件
## 功能说明<a name="section56901555916"> ## 功能说明
init启动引导组件负责在系统启动阶段启动关键服务进程。 若用户需要新增随开机自启动的系统服务,可添加新的配置文件xxx.cfg,系统会自动分析对应的cfg文件,并按照cfg文件启动对应的服务。 init启动引导组件负责在系统启动阶段启动关键服务进程。 若用户需要新增随开机自启动的系统服务,可添加新的配置文件xxx.cfg,系统会自动分析对应的cfg文件,并按照cfg文件启动对应的服务。
- init启动引导的配置文件<a name="section56901555917"></a> - init启动引导的配置文件
init启动引导组件配置文件包含了所有需要由init进程启动的系统关键服务的服务名、可执行文件路径、权限和其他信息,烧写单板后可在“/etc/“目录下找到,文件名称为init.cfg,采用json格式,文件大小目前限制在100KB以内。 init启动引导组件配置文件包含了所有需要由init进程启动的系统关键服务的服务名、可执行文件路径、权限和其他信息,烧写单板后可在“/etc/“目录下找到,文件名称为init.cfg,采用json格式,文件大小目前限制在100KB以内。
init进程启动后读取/etc/init.cfg,然后解析其json格式内容,并根据解析结果依次加载系统服务。 init进程启动后读取/etc/init.cfg,然后解析其json格式内容,并根据解析结果依次加载系统服务。
各模块需要添加关键服务时,也可以添加模块对应的cfg文件,编译时拷贝文件到/system/etc/init目录下,init进程会解析改cfg文件,并启动对应的服务。 各模块需要配置或添加关键服务时,可以在对应模块的cfg文件进行配置,编译过程中会将配置后的文件拷贝到/system/etc/init目录下,单板中可在"/etc/init/"目录下查找到对应的cfg文件,
- init服务启动控制(仅标准系统以上提供)<a name="section56901555918"></a> 对于单板中/etc/init下存在的cfg文件,init进程会逐一解析,下面分别介绍一下init扫描cfg文件的规则和cfg文件内容的具体组成格式。
- cfg文件扫描规则
对于标准系统和小型系统,cfg文件扫描是共用一个相同的接口,接口代码如下:
```
void ReadConfig(void)
{
// parse cfg
if (InChargerMode() == 1) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL);
} else if (InUpdaterMode() == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CFG_PATH, ".cfg", ParseInitCfg, NULL);
ReadFileInDir("/vendor/etc/init", ".cfg", ParseInitCfg, NULL);
} else {
ReadFileInDir("/etc", ".cfg", ParseInitCfg, NULL);
}
}
```
以下是这段代码中的宏定义:
```
#define INIT_CONFIGURATION_FILE "/etc/init.cfg"
#define OTHER_CHARGE_PATH "/system/etc/charge"
#define OTHER_CFG_PATH "/system/etc/init"
```
对于充电模式和升级模式下cfg的扫描此处不作详细说明,我们关注正常系统启动时init扫描cfg文件的规则。
1. 对于/etc/init.cfg文件,是应当最先解析,因此直接调用解析接口解析该文件。
2. 对于/etc/init目录(note:/etc是指向/system/etc的一个符号链接,可以把它们看作是等价的),init进程会遍历该目录下的文件,匹配文件的后缀名,匹配到cfg文件时就会调用解析接口对该文件进行解析。
3. init还会遍历/vendor/etc/init目录下的cfg文件并进行解析,这个目录下的cfg文件应当是与硬件平台相关的。
- cfg文件的组成格式
下面展示一个cfg文件的框架:
```
{
"import" : [
"/etc/init.xxx.cfg",
"/vendor/etc/init.${ohos.boot.hardware}.cfg"
],
"jobs" : [{
"name" : "example-stage",
"cmds" : [
"write /example/file 0",
"start example"
]
}
],
"services" : [{
"name" : "example",
"path" : ["/system/bin/example"],
}
]
}
```
前面已经提到,cfg文件是json格式的文本文件。对于启动组件来说,init进程能够解析的cfg文件中的内容主要包括3种json对象,其对象名分别为"import", "jobs", "services"。下面逐一讲解这3个部分。
1. "import": 导入其他cfg文件。一个cfg文件中导入的其他cfg文件,会在当前cfg文件解析完成后,按顺序继续解析。
2. "jobs": 带名字的命令组。一个job被执行时,会按照先后顺序逐条执行"cmds"中的命令。触发执行job的方式在下文中有详细介绍。
3. "services": 服务。最简单的服务可以只有一个名字和一个可执行文件路径。一个服务的基本运行逻辑是在init进程中fork一个子进程,然后在子进程中执行路径中的可执行文件。服务是启动组件中的核心内容,cfg中服务的配置还包括了各种各样的属性,服务的控制方式也涵盖了多方面的内容,这些都将在下文中展开详细的叙述。
- init服务启动控制(仅标准系统以上提供)<a name = "section56901555918">
init会根据用户的服务配置,把服务分成三类,在不同的阶段进行启动。 init会根据用户的服务配置,把服务分成三类,在不同的阶段进行启动。
- “boot”类型:对应系统中需要优先启动的服务,这类服务在init完成init阶段后启动。 - “boot”类型:对应系统中需要优先启动的服务,该类服务在“init”阶段启动。
- “normal”类型:默认配置,对应系统中的普通服务,这类服务在init命令执行完成后启动。 - “normal”类型:默认配置,对应系统中的普通服务,该类服务在“post-init"阶段启动。
- "condition"类型:对应有特殊要求的服务,可以直接通过start xxx 命令执行启动,一般在条件job或者在init的某个阶段使用命令启动。 - “condition”类型:表示服务按照条件启动。对有特殊要求的服务,可以直接通过start xxx 命令执行启动,一般在条件“job”或者在“init”的某个阶段使用命令启动。
服务间或服务与命令之间存在依赖关系,需要通过"condition"描述服务,例如 服务间或服务与命令之间存在依赖关系,需要通过"condition"描述服务,配置参考如下
``` ```
"services" : [{ "services" : [{
"name" : "service1", "name" : "serviceName",
"path" : ["/bin/process1", "param1", "param2"],
"uid" : 1,
"gid" : 1,
"once" : 0,
"importance" : 1,
"caps" : [0, 1, 2, 5],
"start-mode" : "condition", "start-mode" : "condition",
"cpucore" : [0],
"critical" : [0, 5, 10],
"apl" : "normal",
"d-caps" : ["OHOS_DMS"]
"jobs" : {
"on-boot" : "boot",
"on-start" : "services:service1_start",
"on-stop" : "services:service1_stop",
"on-restart" : "services:service1_restart"
}
}, },
``` ```
- init服务并行控制(仅标准系统以上提供)<a name="section56901555919"></a> - init服务并行控制(仅标准系统以上提供)<a name="section56901555919"></a>
init提供服务并行处理能力,启动服务在不同的阶段执行job的能力。 init提供服务并行处理能力,启动服务在不同的阶段执行job的能力。
- “on-start”:在服务进程被fock后执行,不同服务的on-start job可以并行执行(在服务的子进程中执行,只对改进程产生影响)。 - “on-start”:在服务进程被fork后执行,不同服务的on-start job可以并行执行(在服务的子进程中执行,只对该进程产生影响)。
- “on-stop”:在服务停止时执行。 - “on-stop”:在服务停止时执行。
- "on-restart":在服务重启时执行。 - "on-restart":在服务重启时执行。
- init 按需启动(仅标准系统以上提供)<a name="section56901555920"></a> 配置参考如下:
```
"services" : [{
"name" : "serviceName",
"jobs" : {
"on-boot" : "boot",
"on-start" : "services:serviceName_start",
"on-stop" : "services:serviceName_stop",
"on-restart" : "services:serviceName_restart"
}
},
```
- init 按需启动(仅标准系统以上提供) <a name="section56901555920">
由init管理的服务支持按需启动,按需启动的服务不会在系统启动过程中主动被拉起,而是当某些事件发生时才会被init按需拉起,触发服务启动的事件可能是被init监听的相关socket有消息上报、samgr收到客户端的请求需要拉起SA服务等情况。 由init管理的服务支持按需启动,按需启动的服务不会在系统启动过程中主动被拉起,而是当某些事件发生时才会被init按需拉起,触发服务启动的事件可能是被init监听的相关socket有消息上报、samgr收到客户端的请求需要拉起SA服务等情况。
"ondemand" 属性是按需启动的服务的标志,一个服务配置了该属性值为true的时候,服务不再需要配置start命令来拉起,而是被监听的相应事件发生时才会被拉起。 "ondemand":按需启动服务的标志,一个服务配置了该属性值为true的时候,服务不再需要配置start命令来拉起,而是被监听的相应事件发生时才会被拉起。
“ondemand”配置参考如下:
```
"services" : [{
"name" : "serviceName",
"ondemand" : true,
}]
```
- SA进程按需启动 - SA进程按需启动
1. 应用请求SA句柄时samgr需识别SA所属进程是否可动态拉起。 1. 应用请求SA句柄时samgr需识别SA所属进程是否可动态拉起。
2. 如需拉起,则需阻塞请求,等init拉起SA进程并注册SA后再返回所请求的SA句柄。 2. 如需拉起,则需阻塞请求,等init拉起SA进程并注册SA后再返回所请求的SA句柄。
- socket进程按需启动 - socket进程按需启动
1. init在pre-fork阶段为socket类进程创建好socket,init中监听创建好的socket上的网络事件。 1. init进程在pre-fork阶段为socket类进程创建好socket,init进程中监听创建好的socket上的网络事件。
2. socket上有报文事件后,init拉起socket进程进行报文处理,init进程取消socket数据的监听,由socket进程处理。 2. socket上有报文事件后,init进程拉起socket进程进行报文处理,init进程取消socket数据的监听,由socket进程处理。
3. socket进程无报文处理后,可以自动退出,退出后init回收该子进程并重新监听socket网络数据。 3. socket进程无报文处理后,可以自动退出,退出后init进程回收该子进程并重新监听socket网络数据。
- 热插拔服务进程按需启动  进程可根据系统参数的变化进行热插拔事件按需启动处理。
- 热插拔服务进程按需启动
<br> &emsp; 进程可根据系统参数的变化进行热插拔事件按需启动处理。
- init 进程启动&回收能力增强 <a name="section56901555921"></a> - init 进程启动&amp;回收能力增强
进程启动时,支持在配置文件中配置服务进程的绑核、优先级、MAC信息以及AccessToken信息。 进程启动时,支持在配置文件中配置服务进程的绑核、优先级、MAC信息以及AccessToken信息。
- init提供修改*.cfg配置文件, 为服务进程提供cpu绑核功能。 - init提供修改\*.cfg配置文件, 为服务进程提供cpu绑核功能。
- init提供修改*.cfg配置文件, 为服务进程提供优先级设置。 - init提供修改\*.cfg配置文件, 为服务进程提供优先级设置。
- init提供修改*.cfg配置文件, 为服务提供设置AccessToken, 为系统服务进程设置其分布式Capability能力(仅标准系统以上提供)。 - init提供修改\*.cfg配置文件, 为服务提供MAC信息设置,即服务的SELinux标签。
- init提供修改*.cfg配置文件, 为服务提供抑制机制。 - init提供修改\*.cfg配置文件, 为服务提供设置AccessToken, 为系统服务进程设置其分布式Capability能力(仅标准系统以上提供)。
- init提供修改\*.cfg配置文件, 为服务提供抑制机制。
- init FD代持(仅标准系统以上提供)<a name="section56901555922"></a> 服务进程启动&回收能力增强配置,如下:
```
"services" : [{
"name" : "serviceName",
"importance" : 1, // 服务进程提供优先级设置
"cpucore" : [0], // 服务进程提供cpu绑核功能
"critical" : [1, 5, 10], // 服务提供抑制机制
"apl" : "normal", // 系统服务进程设置其分布式Capability能力
"d-caps" : ["OHOS_DMS"], // 系统服务进程设置其分布式Capability能力
"secon" : "u:r:distributedsche:s0" / 服务的SELinux标签, "u:r:distributedsche:s0"为要设置的SELinux标签信息
},
```
- init FD代持(仅标准系统以上提供)
FD代持是按需启动的一个辅助扩展机制,按需启动进程可以保持退出前的fd状态句柄不丢失。按需启动进程退出前可将fd发送给init代持,再次启动后再从init获取fd。 FD代持是按需启动的一个辅助扩展机制,按需启动进程可以保持退出前的fd状态句柄不丢失。按需启动进程退出前可将fd发送给init代持,再次启动后再从init获取fd。
init提供了相关接口供服务调用,服务进程退出前调用接口将fd通过支持IPC通信的socket发送给init代持,待该服务重新启动时,init将持有的该服务相关的fd句柄通过同样的方式返回给服务。 init提供了相关接口供服务调用,服务进程退出前调用接口将fd通过支持IPC通信的socket发送给init代持,待该服务重新启动时,init将持有的该服务相关的fd句柄通过同样的方式返回给服务。相关接口参考:[FD代持接口介绍](#table14737791479)。
- init job<a name="section56901555923"></a> - init job
init提供job能力,一个job就是一组命令的集合。job可以在init.cfg中配置,也可以在模块的自定义cfg中配置。init解析程序会把相同名字job的命令合并到一个job中。同一名字的job只能保证init.cfg中的命令优先执行,其他cfg间的命令执行顺序不保证。 init提供job能力,一个job就是一组命令的集合。job可以在init.cfg中配置,也可以在模块的自定义cfg中配置。init解析程序会把相同名字job的命令合并到一个job中。同一名字的job只能保证init.cfg中的命令优先执行,其他cfg间的命令执行顺序不保证。
- 普通job:一般是init启动的固定阶段,如“pre-init“,”init“,”post-init“等,这类job在init启动的固定阶段执行。 - 普通job:一般是init启动的固定阶段,如“pre-init“,“init”,“post-init”等,这类job在init启动的固定阶段执行。
- 自定义job:用户自定义的job,这类job按照一定的规则进行触发。 - 自定义job:用户自定义的job,这类job按照一定的规则进行触发。
- job:用户任意定义,可以通过trigger命令执行。 - job:用户任意定义,可以通过trigger命令执行。
- 控制job(仅标准系统以上提供):按条件触发处理的能力。在job中可以设置触发条件,当对应的属性值满足设置的条件时,就会触发job执行。触发条件支持&&和||操作,可以根据不同的属性就行组合。 - 控制job(仅标准系统以上提供):按条件触发处理的能力。在job中可以设置触发条件,当对应的属性值满足设置的条件时,就会触发job执行。触发条件支持&amp;&amp;和||操作,可以根据不同的属性自行组合。
## 开发指导<a name="section56901555924"></a> - bootchart 插件
1. 配置jobs数组。 bootchart是一个用于linux启动过程性能分析的开源工具软件,在系统中自动收集CPU占用率、磁盘吞吐率、进程等信息,并以图形方式显示分析结果,可用作指导优化系统启动过程。begetctl命令参考:[begetctl命令说明](#table14737791480)
如下所示:
预制条件:
1. 准备bootchart测试环境:linux操作系统下安装python及pycairo
pip install pycairo
2. 在linux解压:bootchart-master.tar
tar -zxvf bootchart-master.tar
执行步骤:
1. 启动系统
2. 执行命令行:begetctl bootchart enable
3. 重启系统
4. 执行命令行:begetctl bootchart stop
5. 执行命令行:begetctl bootchart disable
6. 在/data/bootchart目录下导出如下文件:<br>
header<br>
proc_diskstats.log<br>
proc_ps.log<br>
proc_stat.log<br>
并存放在bootchart文件夹
7. 使用命令:tar -zcvf bootchart.tgz * 进行打包(只支持linux版本)并将该打包文件拷贝到linux:bootchart-master目录下
8. 运行:<br>
在bootchart-master目录下运行<br>
python3 pybootchartgui.py -f pdf bootchart.tgz<br>
预期结果:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在bootchart-master目录下生成bootchart.pdf
## 开发指导
1. 配置jobs数组。
init启动引导组件将系统启动分为三个阶段: init启动引导组件将系统启动分为三个阶段:
- “pre-init”阶段:启动系统服务之前需要先执行的操作,例如挂载文件系统、创建文件夹、修改权限等。 - “pre-init”阶段:启动系统服务之前需要先执行的操作,例如挂载文件系统、创建文件夹、修改权限等。
- “init”阶段:系统服务启动阶段。 - “init”阶段:系统服务启动阶段。
- “post-init”阶段:系统服务启动完后还需要执行的操作。 - “post-init”阶段:系统服务启动完成后还需要执行的操作。
``` ```
"jobs" : [{ "jobs" : [{
...@@ -126,98 +235,62 @@ ...@@ -126,98 +235,62 @@
] ]
``` ```
**表 1** 执行job介绍 <a name="table1801509284"></a> **表1** 执行job介绍
<table><thead align="left"><tr id="row680703289"><th class="cellrowborder" valign="top" width="13.4%" id="mcps1.2.3.1.1"><p id="p11805012282"><a name="p11805012282"></a><a name="p11805012282"></a>job名</p> | job名 | 说明 |
</th> | :-------- | :-------- |
<th class="cellrowborder" valign="top" width="86.6%" id="mcps1.2.3.1.2"><p id="p2811605289"><a name="p2811605289"></a><a name="p2811605289"></a>说明</p> | pre-init | 最先执行的job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。 |
</th> | init | 中间执行的job,例如服务启动。 |
</tr> | post-init | 最后被执行的job,如果开发者的进程在启动完成之后需要有一些处理(如驱动初始化后再挂载设备),可以把这类操作放到该job执行。单个job最多支持30条命令(当前仅支持start/mkdir/chmod/chown/mount/loadcfg),命令名称和后面的参数(参数长度≤128字节)之间有且只能有一个空格。 |
</thead>
<tbody><tr id="row178140112810"><td class="cellrowborder" valign="top" width="13.4%" headers="mcps1.2.3.1.1 "><p id="p6811809281"><a name="p6811809281"></a><a name="p6811809281"></a>pre-init</p> **表2** 命令集说明
</td> | 命令 | 命令格式和示例 | 说明 | 支持系统类型 |
<td class="cellrowborder" valign="top" width="86.6%" headers="mcps1.2.3.1.2 "><p id="p18115019284"><a name="p18115019284"></a><a name="p18115019284"></a>最先执行的job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。</p> | -------- | -------- | -------- | -------- |
</td> | mkdir | mkdir&nbsp;目标文件夹<br/>如:mkdir&nbsp;/storage/myDirectory | 创建文件夹命令,mkdir和目标文件夹之间有且只能有一个空格。 | small&amp;standard |
</tr> | chmod | chmod&nbsp;权限&nbsp;目标<br/>如:chmod&nbsp;0600&nbsp;/storage/myFile.txt<br/>chmod&nbsp;0750&nbsp;/storage/myDir | 修改权限命令,chmod权限目标之间间隔有且仅有一个空格,权限必须为0xxx格式。 | small&amp;standard |
<tr id="row381120182817"><td class="cellrowborder" valign="top" width="13.4%" headers="mcps1.2.3.1.1 "><p id="p148116002812"><a name="p148116002812"></a><a name="p148116002812"></a>init</p> | chown | chown&nbsp;uid&nbsp;gid&nbsp;目标<br/>如:chown&nbsp;900&nbsp;800&nbsp;/storage/myDir<br/>chown&nbsp;100&nbsp;100&nbsp;/storage/myFile.txt | 修改属组命令,chown&nbsp;uid&nbsp;gid目标之间间隔有且仅有一个空格。 | small&amp;standard |
</td> | mount | mount&nbsp;fileSystemType&nbsp;src&nbsp;dst&nbsp;flags&nbsp;data<br/>如:mount&nbsp;vfat&nbsp;/dev/mmcblk0&nbsp;/sdc&nbsp;rw,umask=000<br/>mount&nbsp;jffs2&nbsp;/dev/mtdblock3&nbsp;/storage&nbsp;nosuid | 挂载命令,各参数之间有且仅有一个空格。flags当前仅支持nodev、noexec、nosuid、rdonly,data为可选字段。 | small&amp;standard |
<td class="cellrowborder" valign="top" width="86.6%" headers="mcps1.2.3.1.2 "><p id="p14818016288"><a name="p14818016288"></a><a name="p14818016288"></a>中间执行的job,例如服务启动。</p> | start | start&nbsp;serviceName<br/>如:start&nbsp;foundation<br/>start&nbsp;shell | 启动服务命令,start后面跟着service名称,该service名称必须能够在services数组中找到。 | small&amp;standard |
</td> | export | export key value<br>如:export TEST /data/test | 设置环境变量命令。后面跟两个参数,第一个参数是环境变量名,第二个参数是环境变量值。| small&amp;standard |
</tr> | rm | rm filename<br>如:rm /data/testfile | 删除文件命令。后面跟一个参数,即文件的绝对路径。 | small&amp;standard |
<tr id="row181100162813"><td class="cellrowborder" valign="top" width="13.4%" headers="mcps1.2.3.1.1 "><p id="p3811804281"><a name="p3811804281"></a><a name="p3811804281"></a>post-init</p> | rmdir | rmdir dirname<br>如:rmdir /data/testdir | 删除目录命令。后面跟一个参数,即目录的绝对路径。 | small&amp;standard | write | write filename value<br>如:write /data/testfile 0 | 写文件命令。后面跟两个参数,第一个参数是文件的绝对路径,第二个参数是要写入文件的字符串。 | small&amp;standard |
</td> | stop | stop servicename<br>如:stop console | 关闭服务命令。后面跟一个参数,即要关闭的服务名。 | small&amp;standard |
<td class="cellrowborder" valign="top" width="86.6%" headers="mcps1.2.3.1.2 "><p id="p18116016285"><a name="p18116016285"></a><a name="p18116016285"></a>最后被执行的job,如果开发者的进程在启动完成之后需要有一些处理(如驱动初始化后再挂载设备),可以把这类操作放到该job执行。单个job最多支持30条命令(当前仅支持start/mkdir/chmod/chown/mount/loadcfg),命令名称和后面的参数(参数长度≤128字节)之间有且只能有一个空格。</p> | copy | copy oldfile newfile<br>如:copy /data/old /data/new | 拷贝文件命令。后面跟两个参数,第一个参数是原文件绝对路径,第二个参数是新文件绝对路径。 | small&amp;standard |
</td> | reset | reset servicename<br>如:reset console | 重启服务命令。后面跟一个参数,即要重启的服务名。目前reset命令的策略是,如果一个服务没有启动,则该命令会将其拉起,如果一个服务处于运行状态,则该命令会将其关闭后重启。| small&amp;standard |
</tr> | reboot | reboot (subsystem)<br>如:reboot updater | 重启系统命令。后面可以跟一个参数,也可以没有参数,当没有参数时执行该命令,将会使设备重启到当前系统,当后面跟参数时,参数应当是子系统的名字,例如,reboot updater,将会重启进入updater子系统。 | small&amp;standard |
</tbody> | sleep | sleep time<br>如:sleep 5 | 睡眠命令。后面可以跟一个参数,该参数是睡眠时间。 | small&amp;standard |
</table> | domainname | domainname name<br>如:domainname localdomain | 设置域名 | small&amp;standard |
| hostname | hostname name<br>如:hostname localhost | 设置主机名命令。 | small&amp;standard |
**表 2** 命令集说明 <a name="table122681439144112"></a> | wait | wait PID<br>如:wait pid | 等待命令。| small&amp;standard |
<table><thead align="left"><tr id="row826873984116"><th class="cellrowborder" valign="top" width="10.15%" id="mcps1.2.4.1.1"><p id="p826833919412"><a name="p826833919412"></a><a name="p826833919412"></a>命令</p> | setrlimit | setrlimit resource curValue maxValue<br>如:| 设定资源使用限制命令。 | small&amp;standard |
</th> | write | write path content<br>如:write /proc/sys/kernel/sysrq 0 | 写文件命令。 | small&amp;standard |
<th class="cellrowborder" valign="top" width="51.83%" id="mcps1.2.4.1.2"><p id="p3381142134118"><a name="p3381142134118"></a><a name="p3381142134118"></a>命令格式和示例</p> | exec | exec 可执行文件路径 可执行文件传的参数<br>如:exec /system/bin/udevadm trigger | 系统调用命令。 | small&amp;standard |
</th> | mknode |mknod name { b \| c } Major Minor<br>如mknod path b 0644 1 9| 建立一个目录项和一个特殊文件的对应索引节点。 参考mknod命令 |standard |
<th class="cellrowborder" valign="top" width="38.019999999999996%" id="mcps1.2.4.1.3"><p id="p1268539154110"><a name="p1268539154110"></a><a name="p1268539154110"></a>说明</p> | makedev | makedev major minor<br>如:makedev -v update | 创建静态的设备节点命令,通常位于/dev目录下。| standard |
</th> | symlink | symlink path1 path2<br>如:symlink /proc/self/fd/0 /dev/stdin | 符号链接命令。 | standard |
</tr> | trigger | trigger jobName<br>如:trigger early-fs | 触发job执行的命令。 | standard |
</thead> | insmod | insmod ko文件<br>如:insmod xxx.ko| 内核模块文件载入命令。 | standard |
<tbody><tr id="row142681039124116"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p2083714604313"><a name="p2083714604313"></a><a name="p2083714604313"></a>mkdir</p> | setparam | setparam paramname paramvalue<br>如:setparam sys.usb.config hdc| 设置系统参数。| standard |
</td> | load_persist_params | load persist params<br>如:load_persist_params&nbsp;| 加载persist参数。load_persist_params命令后有且仅有一个空格 | standard |
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p143811842154111"><a name="p143811842154111"></a><a name="p143811842154111"></a>mkdir 目标文件夹</p> | load_param | load params<br>如:load_param /data/test.normal.para| 将文件里的param加载到内存。| standard |
<p id="p4377174213435"><a name="p4377174213435"></a><a name="p4377174213435"></a>如:mkdir /storage/myDirectory</p> | load_access_token_id | 如:load_access_token_id&nbsp;| 将access token信息写入data/service/el0/access_token/nativetoken.json文件,load_access_token_id后有且只有一个空格。| standard |
</td> | ifup | ifup 激活网络接口<br>如:ifup eth0 | 激活指定的网络接口。| standard |
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p56817536457"><a name="p56817536457"></a><a name="p56817536457"></a>创建文件夹命令,mkdir和目标文件夹之间有且只能有一个空格。</p> | mount_fstab | mount_fstab fstab.test<br>如:mount_fstab /vendor/etc/fstab.test| 按照fstab挂载分区的命令。 | standard |
</td> | umount_fstab | umount_fstab fstab.test<br>如:umount_fstab /vendor/etc/fstab.test | 按照fstab卸载分区的命令。 | standard |
</tr> | restorecon | restorecon file or dir<br>如:restorecon /file | 重新加载selinux 的context。 | standard |
<tr id="row1268133919413"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p97961563461"><a name="p97961563461"></a><a name="p97961563461"></a>chmod</p> | stopAllServices | stopAllServices [bool]<br>如:stopAllServices false 或 stopAllServices | 停止所有服务。 | standard |
</td> | umount |umount path<br>如:umount /vendor | 卸载已经挂载的硬件设备 。 | standard |
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p20381144234118"><a name="p20381144234118"></a><a name="p20381144234118"></a>chmod 权限 目标</p> | sync | 如:sync&nbsp; | 同步写入数据到磁盘。sync后有且仅有一个空格。| standard |
<p id="p6334213124413"><a name="p6334213124413"></a><a name="p6334213124413"></a>如:chmod 0600 /storage/myFile.txt</p> | timer_start | timer_start serviceName<br>如:timer_start console | 启动服务计时器。 | standard |
<p id="p1748214543444"><a name="p1748214543444"></a><a name="p1748214543444"></a>chmod 0750 /storage/myDir</p> | timer_stop | timer_stop serviceName<br>如:timer_stop console | 停止服务计时器。 | standard |
</td> | init_global_key | init_global_key path 如:init_global_key /data | data分区文件加密key初始化。| standard |
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p2023822074614"><a name="p2023822074614"></a><a name="p2023822074614"></a>修改权限命令,chmod权限目标之间间隔有且仅有一个空格,权限必须为0xxx格式。</p> | init_main_user | 如:init_main_user| 主用户目录加密。| standard |
</td> | mkswap | mkswap file<br>如:mkswap /swapfile1 | 在一个文件或者设备上建立交换分区。 | standard |
</tr> | swapon | swapon file <br>如:swapon /swapfile1| 激活交换空间 | standard |
<tr id="row7268143918416"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p8255346174610"><a name="p8255346174610"></a><a name="p8255346174610"></a>chown</p> | loadcfg | loadcfg&nbsp;filePath<br/>如:loadcfg&nbsp;/patch/fstab.cfg | 加载其他cfg文件命令。后面跟着的目标文件大小不得超过50KB,且目前仅支持加载/patch/fstab.cfg,其他文件路径和文件名均不支持。/patch/fstab.cfg文件的每一行都是一条命令,命令类型和格式必须符合本表格描述,命令条数不得超过20条。 | small |
</td>
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p238114423418"><a name="p238114423418"></a><a name="p238114423418"></a>chown uid gid 目标</p> 2. 配置services数组,service集合(数组形式),包含了init进程需要启动的所有系统服务。
<p id="p1118592184518"><a name="p1118592184518"></a><a name="p1118592184518"></a>如:chown 900 800 /storage/myDir</p>
<p id="p1235374884510"><a name="p1235374884510"></a><a name="p1235374884510"></a>chown 100 100 /storage/myFile.txt</p> ```
</td>
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p18408185817467"><a name="p18408185817467"></a><a name="p18408185817467"></a>修改属组命令,chown uid gid目标之间间隔有且仅有一个空格。</p>
</td>
</tr>
<tr id="row109751379478"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p1017823174717"><a name="p1017823174717"></a><a name="p1017823174717"></a>mount</p>
</td>
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p10381124244117"><a name="p10381124244117"></a><a name="p10381124244117"></a>mount fileSystemType src dst flags data</p>
<p id="p572019493485"><a name="p572019493485"></a><a name="p572019493485"></a>如:mount vfat /dev/mmcblk0 /sdc rw,umask=000</p>
<p id="p7381173625313"><a name="p7381173625313"></a><a name="p7381173625313"></a>mount jffs2 /dev/mtdblock3 /storage nosuid</p>
</td>
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p11976107144710"><a name="p11976107144710"></a><a name="p11976107144710"></a>挂载命令,各参数之间有且仅有一个空格。flags当前仅支持nodev、noexec、nosuid、rdonly,data为可选字段。</p>
</td>
</tr>
<tr id="row1334911198482"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p1214153117480"><a name="p1214153117480"></a><a name="p1214153117480"></a>start</p>
</td>
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p133816420411"><a name="p133816420411"></a><a name="p133816420411"></a>start serviceName</p>
<p id="p2036714132541"><a name="p2036714132541"></a><a name="p2036714132541"></a>如:start foundation</p>
<p id="p115951820185412"><a name="p115951820185412"></a><a name="p115951820185412"></a>start shell</p>
</td>
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p4350121915488"><a name="p4350121915488"></a><a name="p4350121915488"></a>启动服务命令,start后面跟着service名称,该service名称必须能够在services数组中找到。</p>
</td>
</tr>
<tr id="row96921442712"><td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.2.4.1.1 "><p id="p1693642018"><a name="p1693642018"></a><a name="p1693642018"></a>loadcfg</p>
</td>
<td class="cellrowborder" valign="top" width="51.83%" headers="mcps1.2.4.1.2 "><p id="p1969364211116"><a name="p1969364211116"></a><a name="p1969364211116"></a>loadcfg filePath</p>
<p id="p1858112368211"><a name="p1858112368211"></a><a name="p1858112368211"></a>如:loadcfg /patch/fstab.cfg</p>
</td>
<td class="cellrowborder" valign="top" width="38.019999999999996%" headers="mcps1.2.4.1.3 "><p id="p13986141320510"><a name="p13986141320510"></a><a name="p13986141320510"></a>加载其他cfg文件命令。后面跟着的目标文件大小不得超过50KB,且目前仅支持加载/patch/fstab.cfg,其他文件路径和文件名均不支持。/patch/fstab.cfg文件的每一行都是一条命令,命令类型和格式必须符合本表格描述,命令条数不得超过20条。</p>
</td>
</tr>
</tbody>
</table>
2. 配置services数组,service集合(数组形式),包含了init进程需要启动的所有系统服务(最多支持100个)。
```
"services" : [{ "services" : [{
"name" : "service1", "name" : "service1",
"path" : ["/bin/process1", "param1", "param2"], "path" : ["/bin/process1", "param1", "param2"],
...@@ -230,7 +303,7 @@ ...@@ -230,7 +303,7 @@
"cpucore" : [0], "cpucore" : [0],
"critical" : [0, 5, 10], "critical" : [0, 5, 10],
"apl" : "normal", "apl" : "normal",
"d-caps" : ["OHOS_DMS"] "d-caps" : ["OHOS_DMS"],
"jobs" : { "jobs" : {
"on-boot" : "boot", "on-boot" : "boot",
"on-start" : "services:service1_start", "on-start" : "services:service1_start",
...@@ -250,113 +323,137 @@ ...@@ -250,113 +323,137 @@
"apl" : "normal", "apl" : "normal",
"d-caps" : [ ] "d-caps" : [ ]
}] }]
``` ```
**表 3** service字段说明<a name="table14737791471"></a> **表3** service字段说明<a name="table14737791471"></a>
<table><thead align="left"><tr id="row273839577"><th class="cellrowborder" valign="top" width="16.64%" id="mcps1.2.3.1.1"><p id="p107382095711"><a name="p107382095711"></a><a name="p107382095711"></a>字段名</p> | 字段名 | 字段说明 | 字段解释 | 支持系统类型 |
</th> | ---------- |-------- | --------| --------|
<th class="cellrowborder" valign="top" width="83.36%" id="mcps1.2.3.1.2"><p id="p17738189277"><a name="p17738189277"></a><a name="p17738189277"></a>说明</p> | name | 当前服务的服务名。 | 类型:字符串; 服务名非空且长度<=32字节。| small&amp;standard |
</th> | path | 当前服务的可执行文件全路径和参数,数组形式。 | 确保第一个数组元素为可执行文件路径、数组元素个数<=20。 <br> 每个元素为字符串形式以及每个字符串长度<=64字节。| small&amp;standard |
</tr> | uid | 当前服务进程的uid值。 | 类型:int | small&amp;standard |
</thead> | gid | 当前服务进程的gid值。 | 类型:int | small&amp;standard |
<tbody><tr id="row17386911716"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p17384912710"><a name="p17384912710"></a><a name="p17384912710"></a>name</p> | once | 当前服务进程是否为一次性进程。 | 1:一次性进程,当该进程退出时,init不会重新启动该服务进程。 <br> 0 : 常驻进程,当该进程退出时,init收到SIGCHLD信号并重新启动该服务进程。 | small&amp;standard |
</td> | importance | 当前服务优先级 | 标准系统中:<br> &emsp; &emsp;服务优先级取值范围 [-20, 19],超出为无效设置。<br> 小型系统中:<br> &emsp; &emsp;0 : 非重要进程 <br> &emsp; &emsp;非0 : 重要进程 | small&amp;standard |
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p1173818913714"><a name="p1173818913714"></a><a name="p1173818913714"></a>当前服务的服务名,须确保非空且长度&lt;=32字节。</p> | caps | 当前服务所需的capability值,根据安全子系统已支持的capability,评估所需的capability,遵循最小权限原则配置。| 类型:数字或者字符串数组,在配置数字时,按linux标准的capability进行配置。字符串时,使用标准定义的宏的名字进行配置。 | small&amp;standard |
</td> | critical | 为服务提供抑制机制,服务在配置时间 T 内,频繁重启次数超过设置次数 N 重启系统。 | 标准系统中<br> &emsp; &emsp;类型:int型数组,如:"critical" : [M, N, T]<br> &emsp; &emsp; M:使能标志位(0:不使能;1:使能), N:频繁拉起服务次数, T:时间(单位:秒)。<br> &emsp; &emsp; M > 0; N > 0 <br> 小型系统中 & 标准系统中:<br> &emsp; &emsp;类型:int,如:"critical" : M<br> &emsp; &emsp; M:使能标志位(0:不使能;1:使能)<br> &emsp; &emsp;默认拉起服务次数:4次, 时间:20秒。 | small&amp;standard |
</tr> | cpucore | 服务需要的绑定的cpu核心数 | 类型:int型数组, 如"cpucore" : [N1, N2, ...], N1, N2均为需要绑定的cpu核索引<br> 如单核设备 cpucore : [0] | small&amp;standard |
<tr id="row1473810916714"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p127381991571"><a name="p127381991571"></a><a name="p127381991571"></a>path</p> | d-caps | 服务分布式能力(仅标准系统以上提供)。| 类型:字符串数组, 如 "d-caps" : ["OHOS_DMS"] | standard |
</td> | apl | 服务能力特权级别(仅标准系统以上提供)。 | 类型:字符串, 如 "apl" : "system_core"。<br> 目前支持"system_core"(默认值), "normal", "system_basic"。 | standard |
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p1073815910717"><a name="p1073815910717"></a><a name="p1073815910717"></a>当前服务的可执行文件全路径和参数,数组形式。须确保第一个数组元素为可执行文件路径、数组元素个数&lt;=20、每个元素为字符串形式以及每个字符串长度&lt;=64字节。</p> | start-mode | 服务的启动模式(仅标准系统以上提供)。 | 类型:字符串, 如 "start-mode" : "condition"。<br>目前支持"boot", "normal", "condition"。具体说明参考:[init服务启动控制](#section56901555918) | standard |
</td> | jobs | 当前服务在不同阶段可以执行的job。 | 具体说明参考:[init服务并行控制](#section56901555919) | small&amp;standard |
</tr> | ondemand | 按需启动服务的标志。 | 类型:bool,如"ondemand" : true,小型系统只在Linux内核上支持。具体说明参考:[init服务按需启动](#section56901555920)| small&amp;standard |
<tr id="row77381291271"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p77381391770"><a name="p77381391770"></a><a name="p77381391770"></a>uid</p> | disable | 预留字段,无实际意义。 | | small&amp;standard |
</td> 3. 服务中socket配置和按需启动。
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p107387920711"><a name="p107387920711"></a><a name="p107387920711"></a>当前服务进程的uid值。</p>
</td> 服务中支持配置 "socket" 属性,该属性以一个JSON对象的格式配置。配置有 "socket" 属性的服务,init将会为其创建socket,以是否为按需启动服务来区分其创建的时机。
</tr> - 按需启动的服务,init会在解析到该服务时,根据解析到的socket配置进行创建。
<tr id="row127381591673"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p47388919715"><a name="p47388919715"></a><a name="p47388919715"></a>gid</p> - 正常启动的服务,init会在拉起该服务时,执行服务可执行文件之前创建其配置的socket。
</td>
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p12738691479"><a name="p12738691479"></a><a name="p12738691479"></a>当前服务进程的gid值。</p> 无论服务是否按需启动,其真正被拉起后,都需要通过特定接口获取init为其创建的socket句柄,进而接手该socket的管理,成为服务自有的socket。
</td> 除以上socket的配置和创建流程,对于按需启动的服务,init还有不同行为。当init在创建根据服务的socket配置创建完socket后,将会判断服务的ondemand属性是否为true(按需启动服务),若是则会调用接口对socket进行轮询监听,直到socket有消息上报,此时将停止监听并拉起对应服务,由服务接管该socket并处理消息。
</tr>
<tr id="row188301014171116"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p183112146115"><a name="p183112146115"></a><a name="p183112146115"></a>once</p> 下面以ueventd服务为例介绍服务中socket和按需启动的配置以及各字段的含义。
</td>
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p18548317195715"><a name="p18548317195715"></a><a name="p18548317195715"></a>当前服务进程是否为一次性进程:</p> ```
<p id="p103571840105812"><a name="p103571840105812"></a><a name="p103571840105812"></a>1:一次性进程,当该进程退出时,init不会重新启动该服务进程</p> "services" : [{
<p id="p5831191431116"><a name="p5831191431116"></a><a name="p5831191431116"></a>0 : 常驻进程,当该进程退出时,init收到SIGCHLD信号并重新启动该服务进程;</p> "name" : "ueventd",
<p id="p378912714010"><a name="p378912714010"></a><a name="p378912714010"></a>注意,对于常驻进程,若在4分钟之内连续退出5次,第5次退出时init将不会再重新拉起该服务进程。</p> "path" : ["/system/bin/ueventd"],
</td> "socket" : [{
</tr> "name" : "ueventd",
<tr id="row386110321155"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p14861113212156"><a name="p14861113212156"></a><a name="p14861113212156"></a>importance</p> "family" : "AF_NETLINK",
</td> "type" : "SOCK_DGRAM",
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p166448210816"><a name="p166448210816"></a><a name="p166448210816"></a>标准系统中:<br> 服务进程优先级, 取值范围[-20, 19]; <br> 小型系统中:<br>0 : 非重要进程 <br> 1 : 重要进程</p> "protocol" : "NETLINK_KOBJECT_UEVENT",
</td> "permissions" : "0660",
</tr> "uid" : "system",
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>caps</p> "gid" : "system",
</td> "option" : [
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>当前服务所需的capability值,根据安全子系统已支持的capability,评估所需的capability,遵循最小权限原则配置(当前最多可配置100个值)。</p> "SOCKET_OPTION_PASSCRED",
</td> "SOCKET_OPTION_RCVBUFFORCE",
</tr> "SOCK_CLOEXEC",
</tr> "SOCK_NONBLOCK"
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>critical</p> ]
</td> }],
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>critical服务启动失败后, 需要M秒内重新拉起, 拉起失败N次后, 直接重启系统, N默认为4, M默认20。(仅标准系统以上提供 "critical" : [0, 2, 10]; 类型为int型数组)。<a name="section56901555917"></a><a name="section56901555917"></a></p> "critical" : [ 0, 5, 15],
<p id="p8572182712811"><a name="p8572182712811"></a><a name="p8572182712811"></a>0:不使能;</p> "ondemand" : true,
<p id="p11861032111517"><a name="p11861032111517"></a><a name="p11861032111517"></a>1:使能。</p> "start-mode" : "condition"
</td> }]
</tr> ```
</tr>
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>cpucore</p> **表4** socket字段说明
</td> |字段名 | 说明 |
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>服务需要的绑定的cpu核心数, 类型为int型数组。<a name="section56901555917"></a><a name="section56901555917"></a></p> | -------- | -------- |
</td> |name|当前socket的命名,不要求必须与服务同名,与服务名同样须满足非空且长度<=32字节。|
</tr> |family|socket所属的地址族,目前支持的为服务创建的socket有AF_UNIX和AF_NETLINK族。|
</tr> |type|socket的类型,目前支持的类型有基于连接的SOCK_SEQPACKET和SOCK_STREAM,还有基于UDP无连接的SOCK_DGRAM。|
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>d-caps</p> |protocol|socket通信遵循的协议类型,在无特殊需求的情况下,该值可配置为default缺省值,因为socket接口会自动根据socket地址族和类型选择合适的协议。此处除了default,并且支持NETLINK_KOBJECT_UEVENT协议类型。|
</td> |permissions|socket节点文件的权限。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。|
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>分布式能力 (仅标准系统以上提供)。<a name="section56901555917"></a><a name="section56901555917"></a></p> |uid|socket节点文件的用户ID。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。|
</td> |gid|socket节点文件的组ID。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。|
</tr> |option|socket的可选配置。在调用setsockopt接口时传入设置,目前支持的option选项有SOCKET_OPTION_PASSCRED、SOCKET_OPTION_RCVBUFFORCE、SOCK_CLOEXEC和SOCK_NONBLOCK。|
</tr>
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>apl</p> **表5** FD代持接口介绍<a name="table14737791479"></a>
</td>
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>能力特权级别:system_core, normal, system_basic。 默认system_core (仅标准系统以上提供)。<a name="section56901555917"></a><a name="section56901555917"></a></p>
</td>
</tr>
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>start-mode</p>
</td>
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>服务的启动模式,具体描述:init服务启动控制(仅标准系统以上提供)。<a name="section56901555917"></a><a name="section56901555917"></a></p>
</td>
</tr>
<tr id="row1689310618179"><td class="cellrowborder" valign="top" width="16.64%" headers="mcps1.2.3.1.1 "><p id="p108931367177"><a name="p108931367177"></a><a name="p108931367177"></a>jobs</p>
</td>
<td class="cellrowborder" valign="top" width="83.36%" headers="mcps1.2.3.1.2 "><p id="p489313618173"><a name="p489313618173"></a><a name="p489313618173"></a>当前服务在不同阶段可以执行的job。具体说明可以看:init服务并行控制(仅标准系统以上提供)。<a name="section56901555917"></a></p>
</td>
</tr>
</tbody>
</table>
**表 4** 接口介绍
| 函数名 | 函数解释 |参数解释 | | 函数名 | 函数解释 |参数解释 |
| :---------- | :---------- |:--------| | ---------- | ---------- |--------|
| int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | 获取init代持的fd | 返回值:成功返回fd数组指针,失败返回NULL。备注:需手动释放<br>参数:<br> serviceName: 服务名<br>outfdCount: 返回的fd数组长度 | | int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | 获取init代持的fd | 返回值:成功返回fd数组指针,失败返回NULL。备注:需手动释放<br>参数:<br> serviceName: 服务名<br>outfdCount: 返回的fd数组长度 |
| int ServiceSaveFd(const char *serviceName, int *fds, int fdCount) | 请求init代持fd | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 <br> fds: 需要init代持的fd数组指针<br>fdCount: fd数组长度 | int ServiceSaveFd(const char *serviceName, int *fds, int fdCount) | 请求init代持fd | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 <br> fds: 需要init代持的fd数组指针<br>fdCount: fd数组长度
| int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc) | 配置服务参数 | 返回值:成功返回0,失败返回-1 <br> 参数: <br> serviceName: 服务名 <br> action: 服务行为("start", "stop", "restart") <br> extArgv: 参数数组 <br> extArgc: 参数个数 | int ServiceSaveFdWithPoll(const char *serviceName, int *fds, int fdCount) | 使用poll方式,请求fd代持 | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 <br> fds: fd代持数组指针 <br> fdCount 数组长度
| int ServiceControl(const char *serviceName, int action) | 控制服务行为 | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 <br> action: 服务行为("start", "stop", "restart")
## 开发实例<a name="section56901555925"></a> **表6** 服务控制接口介绍
init启动引导程序,此处以要新增一个名为MySystemApp的系统服务为例进行说明,使用如下配置: | 函数名 | 函数解释 |参数解释 |
| :---------- | :---------- |:--------|
| int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc) | 配置服务参数 | 返回值:成功返回0,失败返回-1 <br> 参数: <br> serviceName: 服务名 <br> action: 服务行为("start", "stop", "restart") <br> extArgv: 参数数组 <br> extArgc: 参数个数 |
| int ServiceControl(const char *serviceName, int action) | 控制服务行为 | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 <br> action: 服务行为("start", "stop", "restart") |
| int ServiceWaitForStatus(const char *serviceName, ServiceStatus status, int waitTimeout) | 等待服务状态 | 返回值:成功返回0, 失败返回-1。<br> 参数:<br>serviceName: 服务名 <br> status: 返回服务状态 <br> 超时时间 |
| int ServiceSetReady(const char *serviceName) | 设置服务准备 | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 |
| int StartServiceByTimer(const char *serviceName, uint64_t timeout) | 定时启动服务 | 返回值:成功返回0,失败返回-1 <br> 参数: <br> serviceName: 服务名 <br> timeout: 超时时间 |
| int StopServiceTimer(const char *serviceName) | 停止服务计时器 | 返回值:成功返回0,失败返回-1 <br> 参数:<br> serviceName: 服务名 |
**表7** begetctl 命令说明<a name="table14737791480"></a>
| 命令 | 命令格式和示例 | 说明 |
| :---------- | :---------- |:--------|
| init group test [stage] | init group test | statge参见ServiceStatus |
| param ls [-r] [name] | 显示系统参数,例如:<br>查看usb系统参数:begetctl param ls persist.sys.usb | 无 |
| param get [name] | 获取系统参数信息,例如:<br>begetctl param get 或 param get | 无 |
| param set name value| 设置系统参数,例如:<br>begetctl param set ohos.servicectrl.display 1 或 param set ohos.servicectrl.display 1| 无 |
| param wait name [value] [timeout] | 等待系统参数,例如:<br>begetctl param wait persist.sys.usb.config hdc 或 param wait persist.sys.usb.config hdc | timeout默认值:30 |
| param dump [verbose] | dump 系统参数信息,例如:<br>begetctl param dump 或 param dump| 无 |
| param shell [name] | 进入Parameter shell,例如:<br>begetctl param shell 或 param shell| 无 |
| timer_stop servicename | 停止服务计时器,例如:<br>begetctl timer_stop appspawn | servicename长度不超过96字符 |
| timer_start servicename timeout | 启动服务计时器,例如:<br>begetctl timer_start appspawn | servicename长度不超过96;timeout默认值:10 |
| start_service servicename | 启动服务,例如:<br>begetctl start_service appspawn 或 start_service appspawn | 无 |
| stop_service servicename | 停止服务,例如:<br>begetctl stop_service appspawn 或 stop_service appspawn | 无 |
| service_control start servicename | 启动服务,例如:<br>begetctl service_control start appspawn 或 service_control start appspawn | 无 |
| service_control stop servicename | 停止服务,例如:<br>begetctl service_control stop appspawn 或 service_control stop appspawn | 无 |
| misc_daemon --write_logo xxx.rgb | 写入开机logo,例如:<br>begetctl misc_daemon --write_logo logo.rgb 或 misc_daemon --write_logo logo.rgb| rgb文件最大不超过1024*2038,仅支持hi3516dv300 |
| reboot | 重启系统,例如:<br>begetctl reboot 或 reboot|无 |
| reboot shutdown | 关闭系统,例如:<br>begetctl reboot shutdown 或 reboot shutdown |无 |
| reboot suspend | 暂停系统,例如:<br>begetctl reboot suspend 或 reboot suspend | 无 |
| reboot updater | 重新启动并进入updater,例如:<br>begetctl reboot updater 或 reboot updater | 无 |
| reboot updater[:options] | 重新启动并进入updater,例如:<br>begetctl reboot updater 或 reboot updater | 无 |
| reboot flashd | 重新启动并进入flashd,例如:<br>begetctl reboot flashd 或 reboot flashd | 无 |
| reboot flashd[:options] | 重新启动并进入flashd,例如:<br>begetctl reboot flashd 或 reboot flashd | 无 |
| reboot charing | 重新启动并进入charing,例如:<br>begetctl reboot charing 或 reboot charing| 无 |
| reboot loader | 重新启动并进入烧写模式,例如:<br>begetctl reboot loader 或 reboot loader | 无 |
| bootchart stop | 停止图形分析,例如:<br>begetctl bootchart stop | 仅支持rk3568|
| bootchart start | 开始图形分析,例如:<br>begetctl bootchart start | 无 |
| bootchart disable | 图形分析不使能,例如:<br>begetctl bootchart disable | 无 |
| bootchart enable | 图形分析使能,例如:<br>begetctl bootchart enable | 无 |
## 开发实例
init启动引导程序,此处以要新增一个名为MySystemApp的系统服务为例进行说明,使用如下配置:
``` ```
{ {
"jobs" : [{ "jobs" : [{
"name" : "pre-init", "name" : "pre-init",
"cmds" : [ "cmds" : [
"mkdir /storage/MyDir", // MySystemApp服务启动之前需要先创建文件夹,因此放在 “pre-init”中进行 "mkdir /storage/MyDir", // MySystemApp服务启动之前需要先创建文件夹,因此放在 “pre-init”中进行
"chmod 0600 /storage/MyDir", // MySystemApp服务要求该文件只有本用户和属组才可读写,因此需要修改权限 "chmod 0600 /storage/MyDir", // MySystemApp服务要求该文件只有本用户和属组才可读写,因此需要修改权限
"chown 10 10 /storage/MyDir" "chown 10 10 /storage/MyDir"
] ]
}, { }, {
...@@ -379,6 +476,9 @@ ...@@ -379,6 +476,9 @@
"caps" : [], // MySystemApp系统服务不需要任何capability权限(即MySystemApp系统服务不涉及与capability相关的操作) "caps" : [], // MySystemApp系统服务不需要任何capability权限(即MySystemApp系统服务不涉及与capability相关的操作)
"start-mode" : "condition", "start-mode" : "condition",
"critical": [1, 2, 10], //MySystemApp系统服务的critical配置,需传入三个参数, 分别为使能:1, 执行次数:2, 执行时间:10 "critical": [1, 2, 10], //MySystemApp系统服务的critical配置,需传入三个参数, 分别为使能:1, 执行次数:2, 执行时间:10
"cpucore" : [0, 1], // 设备为双核, 且都绑定cpu
"apl" : "system_core",
"d-caps" : ["OHOS_DMS"],
"jobs" : { "jobs" : {
"on-boot" : "boot", "on-boot" : "boot",
"on-start" : "services:MySystemApp_start", "on-start" : "services:MySystemApp_start",
...@@ -388,48 +488,64 @@ ...@@ -388,48 +488,64 @@
} }
] ]
} }
``` ```
完成配置后,编译出包烧写单板: 完成配置后,编译出包烧写单板:
1. 启动后使用task -a(liteos-a版本)或ps命令(linux版本)查看是否MySystemApp系统服务进程已启动。 1. 启动后使用task -a(liteos-a版本)或ps命令(linux版本)查看是否MySystemApp系统服务进程已启动。
2. 使用kill命令将上述新增的MySystemApp进程杀死,观察该进程是否会被重新拉起(此处应该为重新拉起)。 2. 使用kill命令将上述新增的MySystemApp进程杀死,观察该进程是否会被重新拉起(此处应该为重新拉起)。
3. 使用kill命令将上述新增的MySystemApp进程杀死,观察是否会导致单板重启(此处应该为不重启)。 3. 使用kill命令将上述新增的MySystemApp进程杀死,观察是否会导致单板重启(此处应该为不重启)。
## 常见问题<a name="section56901555926"></a>
### 服务不存在<a name="section56901555927"></a> ## 常见问题
### 服务不存在
**现象描述**
内核Log打印 "Failed get servName"。
**原因分析**
kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务不存在。
**解决方法**
1. 确认服务是否在cfg中正确配置。
2. 服务的cfg文件是否正常加载。
3. cfg文件格式是否正确。
### 请求其他服务代持fd,init有报错
**现象描述**
内核Log打印 "Service ' xxx '(pid = xxx) is not valid or request with unexpected process(pid = xxx)"。
&emsp; **现象描述** <br> **原因分析**
&emsp;&emsp; 内核Log打印 "Failed get servName"。
&emsp; **原因分析** <br> kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是其他服务代持fd。
&emsp; &emsp; kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务不存在。
&emsp; **解决方法** <br> **解决方法**
&emsp; &emsp; 1. 确认服务是否在cfg中正确配置。 <br>
&emsp; &emsp; 2. 服务的cfg文件是否正常加载。 <br>
&emsp; &emsp; 3. cfg文件格式是否正确。
### 请求其他服务代持fd,init有报错<a name="section56901555928"></a> 只支持代持本服务的fd, 不允许让其他服务代持fd。
&emsp; **现象描述**
&emsp; &emsp; 内核Log打印 "Service \' xxx \'(pid = xxx) is not valid or request with unexpected process(pid = xxx)"。 ### 服务没有配置ondemand 选项
&emsp; **原因分析** <br> **现象描述**
&emsp; &emsp; kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是其他服务代持fd。
&emsp; **解决方法** <br> 内核Log打印 "service : %s had started already"。
&emsp; &emsp; 只支持代持本服务的fd, 不允许让其他服务代持fd。
### 服务没有配置ondemand 选项<a name="section56901555929"></a> **原因分析**
&emsp; **现象描述** <br> kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务没有配置ondemand。
&emsp; &emsp; 内核Log打印 "service : %s had started already"。
&emsp; **原因分析** <br> **解决方法**
&emsp; &emsp; kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务没有配置ondemand。
&emsp; **解决方法** <br> 服务对应的.cfg文件正确配置如: "ondemand" : true。
&emsp; &emsp; 服务对应的.cfg文件正确配置如: "ondemand" : true。
\ No newline at end of file
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
## 概述 ## 概述
HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。 HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。本章节内容适用于标准系统。
本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。
## 开发指导 ## 开发指导
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
### 功能简介 ### 功能简介
HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。 HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。本章节内容适用于标准系统。
本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。
### 源码目录说明 ### 源码目录说明
......
...@@ -9,9 +9,17 @@ ...@@ -9,9 +9,17 @@
- HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。 - HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。
- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。 - HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。
- HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。 - HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。
- HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。 - HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。
- HiChecker缺陷扫描,标准系统类设备(参考内存≥128MB)适用。
- HiDumper信息导出,标准系统类设备(参考内存≥128MB)适用。
- Faultlogger崩溃故障检测,标准系统类设备(参考内存≥128MB)适用。
## 基本概念<a name="section5635178134811"></a> ## 基本概念<a name="section5635178134811"></a>
**流水日志:** **流水日志:**
......
# USB服务子系使用实例<a name="ZH-CN_TOPIC_0000001092792986"></a> # USB服务子系使用实例<a name="ZH-CN_TOPIC_0000001092792986"></a>
``` ```cpp
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <map> #include <map>
......
...@@ -8,46 +8,46 @@ ...@@ -8,46 +8,46 @@
1. 获取usb service实例 1. 获取usb service实例
``` ```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
``` ```
2. 获取usb设备列表 2. 获取usb设备列表
``` ```cpp
std::vector<OHOS::USB::UsbDevice> deviceList; std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList); int32_t ret = g_usbClient.GetDevices(deviceList);
``` ```
3. 申请设备权限 3. 申请设备权限
``` ```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName()); int32_t ret = g_usbClient.RequestRight(device.GetName());
``` ```
4. 打开设备 4. 打开设备
``` ```cpp
USBDevicePipe pip; USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip); int32_t et = g_usbClient.OpenDevice(device, pip);
``` ```
5. 配置设备接口 5. 配置设备接口
``` ```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true); ret = g_usbClient.ClaimInterface(pip, interface, true);
interfacedeviceListdeviceinterface interfacedeviceListdeviceinterface
``` ```
6. 数据传输 6. 数据传输
``` ```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
``` ```
pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长. pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长.
7. 关闭设备 7. 关闭设备
``` ```cpp
ret = g_usbClient.Close(pip); ret = g_usbClient.Close(pip);
``` ```
...@@ -398,12 +398,12 @@ ...@@ -398,12 +398,12 @@
- [普通组件开发指导](subsystems/subsys-graphics-common-guide.md) - [普通组件开发指导](subsystems/subsys-graphics-common-guide.md)
- [动画开发指导](subsystems/subsys-graphics-animation-guide.md) - [动画开发指导](subsystems/subsys-graphics-animation-guide.md)
- 媒体 - 媒体
- [相机](subsystems/subsys-multimedia-camera.md) - 相机
- [相机开发概述](subsystems/subsys-multimedia-camera-overview.md) - [相机开发概述](subsystems/subsys-multimedia-camera-overview.md)
- [拍照开发指导](subsystems/subsys-multimedia-camera-photo-guide.md) - [拍照开发指导](subsystems/subsys-multimedia-camera-photo-guide.md)
- [录像开发指导](subsystems/subsys-multimedia-camera-record-guide.md) - [录像开发指导](subsystems/subsys-multimedia-camera-record-guide.md)
- [预览开发指导](subsystems/subsys-multimedia-camera-preview-guide.md) - [预览开发指导](subsystems/subsys-multimedia-camera-preview-guide.md)
- [音视频](subsystems/subsys-multimedia-video.md) - 音视频
- [音视频开发概述](subsystems/subsys-multimedia-video-overview.md) - [音视频开发概述](subsystems/subsys-multimedia-video-overview.md)
- [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md) - [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md)
- [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md) - [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md)
...@@ -427,10 +427,10 @@ ...@@ -427,10 +427,10 @@
- [唤醒词识别插件的开发示例](subsystems/subsys-aiframework-demo-plugin.md) - [唤醒词识别插件的开发示例](subsystems/subsys-aiframework-demo-plugin.md)
- [唤醒词识别配置文件的开发示例](subsystems/subsys-aiframework-demo-conf.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-overview.md)
- [关系型数据库开发指导](subsystems/subsys-data-relational-database-guide.md) - [关系型数据库开发指导](subsystems/subsys-data-relational-database-guide.md)
- [轻量级数据存储](subsystems/subsys-data-storage.md) - 轻量级数据存储
- [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md) - [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md)
- [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md) - [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md)
- Sensor服务 - Sensor服务
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册