diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 71c6d0b796827db454b51c1e439deec9ddb738c7..46304e882adcc8f8fbd69daf30cbe58a565696cd 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -93,7 +93,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 1. Obtain the USB device list. - ``` + ```js // Import the USB API package. import usb from '@ohos.usb'; // Obtain the USB device list. @@ -153,7 +153,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 2. Obtain the device operation permissions. - ``` + ```js var deviceName = deviceList[0].name; // Request the permissions to operate a specified device. usb.requestRight(deviceName).then(hasRight => { @@ -165,7 +165,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 3. Open the device. - ``` + ```js // Open the device, and obtain the USB device pipe for data transfer. var pipe = usb.connectDevice(deviceList[0]); /* @@ -177,7 +177,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 4. Perform data transfer. - ``` + ```js /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. @@ -208,7 +208,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 5. Release the USB interface, and close the USB device. - ``` + ```js usb.releaseInterface(pipe, interface); usb.closePipe(pipe); ``` diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 7041eaef2788d011c6e953e7657d2d4b38a2100e..30d7ac0dd8a49df8f05cab425baa6d781d18371e 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_appAccount from '@ohos.account.appAccount'; ``` @@ -25,7 +25,7 @@ Creates an **AppAccountManager** instance. | AppAccountManager | **AppAccountManager** instance created.| **Example** - ``` + ```js var appAccountManager = account.createAppAccountManager(); ``` @@ -50,7 +50,7 @@ Adds an app account to the account management service. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("WangWu", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -75,7 +75,7 @@ Adds an app account and its additional information to the account management ser **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -107,7 +107,7 @@ Adds an app account and its additional information to the account management ser **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101").then(()=> { console.log('addAccount Success'); @@ -135,7 +135,7 @@ Implicitly adds an app account based on the specified account owner, authenticat **Example** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -174,7 +174,7 @@ Deletes an app account from the account management service. This method uses an **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu", (err) => { console.log("deleteAccount err: " + JSON.stringify(err)); @@ -203,7 +203,7 @@ Deletes an app account from the account management service. This method uses a p **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu").then(() => { console.log('deleteAccount Success'); @@ -230,7 +230,7 @@ Disables an app account from accessing an application with the given bundle name **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -260,7 +260,7 @@ Disables an app account from accessing an application with the given bundle name **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); @@ -287,7 +287,7 @@ Enables an app account to access an application with the given bundle name. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); @@ -317,7 +317,7 @@ Enables an app account to access an application with the given bundle name. This **Example** - ``` + ```js app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { @@ -344,7 +344,7 @@ Checks whether an app account allows application data synchronization. This meth **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -376,7 +376,7 @@ Checks whether an app account allows application data synchronization. This meth **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { console.log('checkAppAccountSyncEnable, result: ' + data); @@ -404,7 +404,7 @@ Sets a credential for an app account. This method uses an asynchronous callback **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { console.log("setAccountCredential err: " + JSON.stringify(err)); @@ -435,7 +435,7 @@ Sets a credential for an app account. This method uses a promise to return the r **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { console.log('setAccountCredential Success'); @@ -462,7 +462,7 @@ Sets additional information for an app account. This method uses an asynchronous **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { console.log("setAccountExtraInfo err: " + JSON.stringify(err)); @@ -492,7 +492,7 @@ Sets additional information for an app account. This method uses a promise to re **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { console.log('setAccountExtraInfo Success'); @@ -521,7 +521,7 @@ Sets whether to enable application data synchronization for an app account. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -553,7 +553,7 @@ Sets whether to enable application data synchronization for an app account. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { console.log('setAppAccountSyncEnable Success'); @@ -581,7 +581,7 @@ Sets data to be associated with an app account. This method uses an asynchronous **Example** - ``` + ```js app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { console.log("setAssociatedData err: " + JSON.stringify(err)); }); @@ -611,7 +611,7 @@ Sets data to be associated with an app account. This method uses a promise to re **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { console.log('setAssociatedData Success'); @@ -638,7 +638,7 @@ Obtains the credential of an app account. This method uses an asynchronous callb **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { console.log("getAccountCredential err: " + JSON.stringify(err)); @@ -669,7 +669,7 @@ Obtains the credential of an app account. This method uses a promise to return t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { console.log('getAccountCredential, result: ' + data); @@ -695,7 +695,7 @@ Obtains additional information of an app account. This method uses an asynchrono **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { console.log("getAccountExtraInfo err: " + JSON.stringify(err)); @@ -725,7 +725,7 @@ Obtains additional information of an app account. This method uses a promise to **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { console.log('getAccountExtraInfo, result: ' + data); @@ -752,7 +752,7 @@ Obtains data associated with an app account. This method uses an asynchronous ca **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { console.log("getAssociatedData err: " + JSON.stringify(err)); @@ -783,7 +783,7 @@ Obtains data associated with an app account. This method uses a promise to retur **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { console.log('getAssociatedData: ' + data); @@ -810,7 +810,7 @@ Obtains information about all accessible app accounts. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts((err, data)=>{ console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); @@ -836,7 +836,7 @@ Obtains information about all accessible app accounts. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts().then((data) => { console.log('getAllAccessibleAccounts: ' + data); @@ -864,7 +864,7 @@ Obtains information about all app accounts of the specified app. This method use **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ @@ -897,7 +897,7 @@ Obtains information about all app accounts of the specified app. This method use **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle).then((data) => { @@ -925,7 +925,7 @@ Subscribes to the account change event of the specified account owners. This met **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -955,7 +955,7 @@ Unsubscribes from the account change event. This method uses an asynchronous cal **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -991,7 +991,7 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok **Example** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -1032,7 +1032,7 @@ Obtains the OAuth access token of an app account based on the specified authenti **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthToken err: ' + JSON.stringify(err)); @@ -1064,7 +1064,7 @@ Obtains the OAuth access token of an app account based on the specified authenti **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthToken token: ' + data); @@ -1092,7 +1092,7 @@ Sets an OAuth access token for an app account. This method uses an asynchronous **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); @@ -1123,7 +1123,7 @@ Sets an OAuth access token for an app account. This method uses a promise to ret **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { console.log('setOAuthToken successfully'); @@ -1152,7 +1152,7 @@ Deletes the specified OAuth access token for an app account. This method uses an **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { console.log('deleteOAuthToken err: ' + JSON.stringify(err)); @@ -1184,7 +1184,7 @@ Deletes the specified OAuth access token for an app account. This method uses a **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { console.log('deleteOAuthToken successfully'); @@ -1213,7 +1213,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { console.log('setOAuthTokenVisibility successfully'); @@ -1273,7 +1273,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1305,7 +1305,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { console.log('checkOAuthTokenVisibility isVisible: ' + data); @@ -1332,7 +1332,7 @@ Obtains information about all OAuth access tokens of an app account visible to t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { console.log("getAllOAuthTokens err: " + JSON.stringify(err)); @@ -1363,7 +1363,7 @@ Obtains information about all OAuth access tokens of an app account visible to t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); @@ -1390,7 +1390,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthList err: ' + JSON.stringify(err)); @@ -1421,7 +1421,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthList data: ' + JSON.stringify(data)); @@ -1447,7 +1447,7 @@ Obtains the authenticator callback for a session. This method uses an asynchrono **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant((err, want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1487,7 +1487,7 @@ Obtains the authenticator callback for a session. This method uses a promise to **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant().then((want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1522,7 +1522,7 @@ Obtains authenticator information of an app account. This method uses an asynchr **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); @@ -1552,7 +1552,7 @@ Obtains authenticator information of an app account. This method uses a promise **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); @@ -1663,7 +1663,7 @@ Called back to send the authentication result. **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { @@ -1692,7 +1692,7 @@ Called back to redirect an authentication request. **Example** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ @@ -1749,7 +1749,7 @@ Authenticates an app account to obtain the OAuth access token. This method uses **Example** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index ddf747f7566d06b48c2d13f99f187b21f997b467..73f6216d255c4629399dfbf9510ab59b176f0273 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_distributedAccount from '@ohos.account.distributedAccount'; ``` @@ -28,7 +28,7 @@ Obtains a **DistributedAccountAbility** instance. | [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -50,7 +50,7 @@ Obtains distributed account information. This method uses an asynchronous callba | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); @@ -73,7 +73,7 @@ Obtains distributed account information. This method uses a promise to return th | Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { console.log('Query account info name: ' + data.name); @@ -98,7 +98,7 @@ Updates distributed account information. This method uses an asynchronous callba | callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { @@ -125,7 +125,7 @@ Updates distributed account information. This method uses a promise to return th | Promise<void> | Promise used to return the result.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index de757b71b485830c58890547591a99fad14bca9c..f0e93479b923928923f27bcda147a7c8d23f0d59 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_osAccount from '@ohos.account.osAccount'; ``` @@ -24,7 +24,7 @@ Obtains an **AccountManager** instance. | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); ``` @@ -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. | **Example**: Activate OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId, (err)=>{ @@ -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.| **Example**: Activate OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId).then(() => { @@ -123,7 +123,7 @@ Checks whether multiple OS accounts are supported. This method uses an asynchron **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); @@ -147,7 +147,7 @@ Checks whether multiple OS accounts are supported. This method uses a promise to **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { @@ -236,9 +236,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho | 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.| -** 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(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ @@ -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.| -** 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(); var localId = 100; 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); @@ -347,7 +347,7 @@ Checks whether this OS account has been verified. This method uses an asynchrono **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -374,7 +374,7 @@ Checks whether an OS account has been verified. This method uses an asynchronous **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); @@ -436,7 +436,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; 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. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; 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. | 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. | -** Example**: Disable Wi-Fi for OS account 100. +**Example**: Disable Wi-Fi for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; 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. **Example**: Set the name of OS account 100 to **demoName**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var newName = "demoName"; @@ -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**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var nameLimit = "demoName"; @@ -643,7 +643,7 @@ Obtains the number of OS accounts created. This method uses an asynchronous call **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); @@ -669,7 +669,7 @@ Obtains the number of OS accounts created. This method uses a promise to return **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((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 **Example**: Obtain the ID of the OS account whose process UID is **12345678**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; 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 **Example**: Obtain the ID of the OS account whose process UID is **12345678**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { @@ -804,7 +804,7 @@ Obtains the OS account ID based on domain account information. This method uses **Example** - ``` + ```js var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { @@ -837,7 +837,7 @@ Obtains the OS account ID based on domain account information. This method uses **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { @@ -865,7 +865,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); @@ -891,7 +891,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); @@ -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. | | 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(); var localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ @@ -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.| -** Example**: Obtain all constraints of OS account 100. +**Example**: Obtain all constraints of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { @@ -980,7 +980,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); @@ -1006,7 +1006,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); @@ -1031,7 +1031,7 @@ Obtains information about all activated OS accounts. This method uses an asynchr **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); @@ -1058,7 +1058,7 @@ Obtains information about all activated OS accounts. This method uses a promise **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds().then((idArray) => { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); @@ -1089,7 +1089,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ console.log("createOsAccount err:" + JSON.stringify(err)); @@ -1124,7 +1124,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1155,7 +1155,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; 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. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ Obtains information about the OS account to which the current process belongs. T **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((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. **Example**: Query information about OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ @@ -1310,7 +1310,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { @@ -1336,7 +1336,7 @@ Obtains the type of the OS account to which the current process belongs. This me **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); @@ -1387,7 +1387,7 @@ Obtains the ID of this distributed virtual device. This method uses an asynchron **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { 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 **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { @@ -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. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; 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. **Example**: Set a profile photo for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; 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 **Example**: Obtain the ID of the OS account whose SN is **12345**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; 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 **Example**: Obtain the ID of the OS account whose SN is **12345**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; 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 **Example**: Obtain the SN of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; 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 **Example**: Obtain the SN of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { @@ -1701,7 +1701,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ console.log("receive localId:" + receiveLocalId); @@ -1731,7 +1731,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function offCallback(){ console.log("off enter") diff --git a/en/device-dev/subsystems/subsys-usbservice-demo.md b/en/device-dev/subsystems/subsys-usbservice-demo.md index 80506e955cea844f4cca1b3552f0f1828fcc77f8..d39ca0544427d05db7b8a8b55f29ed5e8955b280 100644 --- a/en/device-dev/subsystems/subsys-usbservice-demo.md +++ b/en/device-dev/subsystems/subsys-usbservice-demo.md @@ -1,7 +1,7 @@ # USB Usage Demo -``` +```cpp #include #include #include diff --git a/en/device-dev/subsystems/subsys-usbservice-guide.md b/en/device-dev/subsystems/subsys-usbservice-guide.md index 6ccfc2594dafaab234dac597c3aee24b1d60ccb5..090bb05fc948ab10e824ddf7839a2c421e8d5dfe 100644 --- a/en/device-dev/subsystems/subsys-usbservice-guide.md +++ b/en/device-dev/subsystems/subsys-usbservice-guide.md @@ -7,40 +7,40 @@ The following procedure uses bulk transfer as an example. 1. Obtain a USB service instance. -``` +```cpp static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); ``` 2. Obtain the USB device list. -``` +```cpp std::vector deviceList; int32_t ret = g_usbClient.GetDevices(deviceList); ``` 3. Apply for device access permissions. -``` +```cpp int32_t ret = g_usbClient.RequestRight(device.GetName()); ``` 4. Open the USB device. -``` +```cpp USBDevicePipe pip; int32_t et = g_usbClient.OpenDevice(device, pip); ``` 5. Configure the USB interface. -``` +```cpp ret = g_usbClient.ClaimInterface(pip, interface, true); **interface** indicates an interface of the USB device in **deviceList**. ``` 6. Transfer data. -``` +```cpp srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); ``` - **pipe** indicates the pipe for data transfer of the USB device opened. @@ -50,6 +50,6 @@ srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); 7. Close the USB device. -``` +```cpp ret = g_usbClient.Close(pip); ``` diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index e652c76123af68d7a4237af194761bc5eaf15490..d3bf99be8b12623e47df7d87fa28c013ed48b2ad 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -38,7 +38,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 1. 获取设备列表。 - ``` + ```js // 导入usb接口api包。 import usb from '@ohos.usb'; // 获取设备列表。 @@ -97,7 +97,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 2. 获取设备操作权限。 - ``` + ```js var deviceName = deviceList[0].name; // 申请操作指定的device的操作权限。 usb.requestRight(deviceName).then(hasRight => { @@ -108,7 +108,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 3. 打开Device设备。 - ``` + ```js // 打开设备,获取数据传输通道。 var pipe = usb.connectDevice(deviceList[0]); /* @@ -119,7 +119,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 4. 数据传输。 - ``` + ```js /* 读取数据,在device信息中选取对应数据接收的endpoint来做数据传输 (endpoint.direction == 0x80);dataUint8Array是要读取的数据,类型为Uint8Array。 @@ -149,7 +149,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 5. 释放接口,关闭设备。 - ``` + ```js usb.releaseInterface(pipe, interface1); usb.closePipe(pipe); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 267300d71797360c8d830f5e72f238b8551340ba..7fb71c1da37fa5a62251781a727f447a785620fa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_appAccount from '@ohos.account.appAccount'; ``` @@ -25,7 +25,7 @@ createAppAccountManager(): AppAccountManager | AppAccountManager | 获取应用帐号模块的实例。 | **示例:** - ``` + ```js var appAccountManager = account.createAppAccountManager(); ``` @@ -50,7 +50,7 @@ addAccount(name: string, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("WangWu", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -75,7 +75,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -107,7 +107,7 @@ addAccount(name: string, extraInfo?: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101").then(()=> { console.log('addAccount Success'); @@ -135,7 +135,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a **示例:** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -174,7 +174,7 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu", (err) => { console.log("deleteAccount err: " + JSON.stringify(err)); @@ -203,7 +203,7 @@ deleteAccount(name: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu").then(() => { console.log('deleteAccount Success'); @@ -230,7 +230,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -260,7 +260,7 @@ disableAppAccess(name: string, bundleName: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); @@ -287,7 +287,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); @@ -317,7 +317,7 @@ enableAppAccess(name: string, bundleName: string): Promise<void> **示例:** - ``` + ```js app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { @@ -344,7 +344,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -376,7 +376,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { console.log('checkAppAccountSyncEnable, result: ' + data); @@ -404,7 +404,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { console.log("setAccountCredential err: " + JSON.stringify(err)); @@ -435,7 +435,7 @@ setAccountCredential(name: string, credentialType: string, credential: string): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { console.log('setAccountCredential Success'); @@ -462,7 +462,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback< **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { console.log("setAccountExtraInfo err: " + JSON.stringify(err)); @@ -492,7 +492,7 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { console.log('setAccountExtraInfo Success'); @@ -521,7 +521,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -553,7 +553,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { console.log('setAppAccountSyncEnable Success'); @@ -581,7 +581,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb **示例:** - ``` + ```js app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { console.log("setAssociatedData err: " + JSON.stringify(err)); }); @@ -611,7 +611,7 @@ setAssociatedData(name: string, key: string, value: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { console.log('setAssociatedData Success'); @@ -638,7 +638,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { console.log("getAccountCredential err: " + JSON.stringify(err)); @@ -669,7 +669,7 @@ getAccountCredential(name: string, credentialType: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { console.log('getAccountCredential, result: ' + data); @@ -695,7 +695,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { console.log("getAccountExtraInfo err: " + JSON.stringify(err)); @@ -725,7 +725,7 @@ getAccountExtraInfo(name: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { console.log('getAccountExtraInfo, result: ' + data); @@ -752,7 +752,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback<string&g **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { console.log("getAssociatedData err: " + JSON.stringify(err)); @@ -783,7 +783,7 @@ getAssociatedData(name: string, key: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { console.log('getAssociatedData: ' + data); @@ -810,7 +810,7 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts((err, data)=>{ console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); @@ -836,7 +836,7 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts().then((data) => { console.log('getAllAccessibleAccounts: ' + data); @@ -864,7 +864,7 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ @@ -897,7 +897,7 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle).then((data) => { @@ -925,7 +925,7 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -955,7 +955,7 @@ off(type: 'change', callback?: Callback>): void **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -991,7 +991,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri **示例:** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -1032,7 +1032,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthToken err: ' + JSON.stringify(err)); @@ -1064,7 +1064,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthToken token: ' + data); @@ -1092,7 +1092,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); @@ -1123,7 +1123,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { console.log('setOAuthToken successfully'); @@ -1152,7 +1152,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { console.log('deleteOAuthToken err: ' + JSON.stringify(err)); @@ -1184,7 +1184,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { console.log('deleteOAuthToken successfully'); @@ -1213,7 +1213,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { console.log('setOAuthTokenVisibility successfully'); @@ -1273,7 +1273,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1305,7 +1305,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { console.log('checkOAuthTokenVisibility isVisible: ' + data); @@ -1332,7 +1332,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { console.log("getAllOAuthTokens err: " + JSON.stringify(err)); @@ -1363,7 +1363,7 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); @@ -1390,7 +1390,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthList err: ' + JSON.stringify(err)); @@ -1421,7 +1421,7 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthList data: ' + JSON.stringify(data)); @@ -1447,7 +1447,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant((err, want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1487,7 +1487,7 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant().then((want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1522,7 +1522,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); @@ -1552,7 +1552,7 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); @@ -1663,7 +1663,7 @@ onResult: (code: number, result: {[key: string]: any}) => void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { @@ -1692,7 +1692,7 @@ onRequestRedirected: (request: Want) => void **示例:** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ @@ -1749,7 +1749,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options: **示例:** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md index d1e009e1ca54fa4755664a07117303e6e4ba0a22..63bd5cc459609d185c0fa3b1d48ba2ca16ae597a 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -8,7 +8,7 @@ ## 导入模块 -``` +```js import bluetooth from '@ohos.bluetooth'; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md index 67ada726654f2390197b4fd08e5d51d3b9cc4dbe..7cf4c74eba58b7b14151cf55563cbdd19f10b33d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_distributedAccount from '@ohos.account.distributedAccount'; ``` @@ -28,7 +28,7 @@ getDistributedAccountAbility(): DistributedAccountAbility | [DistributedAccountAbility](#distributedaccountability) | 返回一个实例,实例提供查询和更新分布式帐号登录状态方法。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -50,7 +50,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): v | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | 是 | 获取分布式帐号信息的回调。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); @@ -73,7 +73,7 @@ queryOsAccountDistributedInfo(): Promise<DistributedInfo> | Promise<[DistributedInfo](#distributedinfo)> | Promise实例,用于获取异步返回结果。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { console.log('Query account info name: ' + data.name); @@ -98,7 +98,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall | callback | AsyncCallback<void> | 是 | 更新分布式帐号信息的回调。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { @@ -125,7 +125,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> | Promise<void> | Promise实例,用于获取异步返回结果。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-formhost.md index 19a314b9bfb27dfef2b964776f1986cd58b1b0b5..3799a2fdf4622c2f72aeb918ea55c306d0109e41 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formhost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formhost.md @@ -29,10 +29,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -72,7 +72,7 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -116,11 +116,11 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | ----------- | - | formId | string | 是 | 卡片标识 | - | isReleaseCache | boolean | 是 | 是否释放缓存 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ----------- | +| formId | string | 是 | 卡片标识 | +| isReleaseCache | boolean | 是 | 是否释放缓存 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -161,7 +161,7 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -220,7 +220,7 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -279,13 +279,13 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; formHost.castTempForm(formId).catch((error) => { - console.log('formProvider castTempForm, error:' + JSON.stringify(error)); + console.log('formHost castTempForm, error:' + JSON.stringify(error)); }); ``` ## notifyVisibleForms -notifyVisibleForms(formId: string, callback: AsyncCallback<void>): void; +notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; 向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 @@ -295,10 +295,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -313,7 +313,7 @@ SystemCapability.Ability.Form ## notifyVisibleForms -notifyVisibleForms(formId: string): Promise<void>; +notifyVisibleForms(formIds: Array<string>): Promise<void>; 向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 @@ -323,9 +323,9 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | **返回值:** @@ -338,13 +338,13 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; formHost.notifyVisibleForms(formId).catch((error) => { - console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error)); + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); }); ``` ## notifyInvisibleForms -notifyInvisibleForms(formId: string, callback: AsyncCallback<void>): void; +notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; 向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 @@ -354,10 +354,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -372,7 +372,7 @@ SystemCapability.Ability.Form ## notifyInvisibleForms -notifyInvisibleForms(formId: string): Promise<void>; +notifyInvisibleForms(formIds: Array<string>): Promise<void>; 向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 @@ -382,9 +382,9 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | **返回值:** @@ -397,13 +397,13 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; formHost.notifyInvisibleForms(formId).catch((error) => { - console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error)); + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); }); ``` ## enableFormsUpdate -enableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; +enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; 向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 @@ -413,10 +413,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -431,7 +431,7 @@ SystemCapability.Ability.Form ## enableFormsUpdate -enableFormsUpdate(formId: string): Promise<void>; +enableFormsUpdate(formIds: Array<string>): Promise<void>; 向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 @@ -441,9 +441,9 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | **返回值:** @@ -456,13 +456,13 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; formHost.enableFormsUpdate(formId).catch((error) => { - console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error)); + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); }); ``` ## disableFormsUpdate -disableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; +disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; 向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 @@ -472,10 +472,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -490,7 +490,7 @@ SystemCapability.Ability.Form ## disableFormsUpdate -disableFormsUpdate(formId: string): Promise<void>; +disableFormsUpdate(formIds: Array<string>): Promise<void>; 向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 @@ -500,9 +500,9 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | **返回值:** @@ -515,7 +515,7 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -567,7 +567,7 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; 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 ```js 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 **示例:** ```js - formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { + formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { if (error) { console.log('formHost getFormsInfo, error:' + error.code); } @@ -669,7 +669,7 @@ SystemCapability.Ability.Form **示例:** ```js - formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { if (error) { console.log('formHost getFormsInfo, error:' + error.code); } @@ -702,8 +702,8 @@ SystemCapability.Ability.Form **示例:** ```js - formHost.getAllFormsInfo().catch((error) => { - console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").catch((error) => { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); }); ``` @@ -719,10 +719,10 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | - | callback | AsyncCallback<number> | 是 | callback形式返回删除的卡片个数 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 有效卡片标识列表 | +| callback | AsyncCallback<number> | 是 | callback形式返回删除的卡片个数 | **示例:** @@ -737,7 +737,7 @@ SystemCapability.Ability.Form ## deleteInvalidForms -function deleteInvalidForms(formIds: Array<string>): Promise<number>; +function deleteInvalidForms(formIds: Array<string>): Promise<number>; 根据列表删除应用程序的无效卡片。 @@ -747,9 +747,9 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 有效卡片标识列表 | **返回值:** @@ -762,7 +762,7 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); 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<FormStateInfo>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 查询卡片状态时携带的want信息 | **返回值:** @@ -829,7 +829,7 @@ SystemCapability.Ability.Form "abilityName": "com.extreme.test.MainAbility" }; 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | - | callback | Callback<string> | 是 | 接口本身调用的回调方法 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | +| callback | Callback<string> | 是 | 需要注册的事件回调方法 | **示例:** ```js - formHost.on("formUninstall", (error, data) => { - if (error) { - console.log('formHost on formUninstall, error:' + error.code); - } - }); + let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); + } + formHost.on("formUninstall", callback); ``` ## off("formUninstall") -off(type: "formUninstall", callback: Callback<string>): void; +off(type: "formUninstall", callback?: Callback<string>): void; 取消订阅卡片卸载事件。 @@ -872,19 +871,18 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | - | callback | Callback<string> | 是 | 接口本身调用的回调方法 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | +| callback | Callback<string> | 否 | 需要注销的事件回调方法。缺省时,表示注销所有已注册事件回调 | **示例:** ```js - formHost.off("formUninstall", (error, data) => { - if (error) { - console.log('formHost off formUninstall, error:' + error.code); - } - }); + let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); + } + formHost.off("formUninstall", callback); ``` ## notifyFormsVisible @@ -899,11 +897,11 @@ SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | - | isVisible | boolean | 是 | 是否可见 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| isVisible | boolean | 是 | 是否可见 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -944,7 +942,7 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); 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 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | - | isEnableUpdate | boolean | 是 | 是否使能更新 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表 | +| isEnableUpdate | boolean | 是 | 是否使能更新 | +| callback | AsyncCallback<void> | 是 | callback形式返回结果 | **示例:** @@ -1005,6 +1003,6 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); 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 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index bb48bd9a80cdd3f829d3b3e68736edc22dbbb909..5d1e6d2c4a619eee379b47ffc08e15c89ed1bec1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | - 示例 - ``` + ```js var InputMethodController = inputMethod.getInputMethodController(); ``` ## inputMethod.getInputMethodSetting8+ @@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting - 示例 - ``` + ```js var InputMethodSetting = inputMethod.getInputMethodSetting(); ``` @@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback<boolean>): void - 示例 -``` +```js InputMethodController.stopInput((error)=>{ console.info('stopInput'); }); @@ -113,7 +113,7 @@ stopInput(): Promise<boolean> - 示例 -``` +```js var isSuccess = InputMethodController.stopInput(); console.info('stopInput isSuccess = ' + isSuccess); ``` @@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | - 示例 - ``` + ```js InputMethodSetting.listInputMethod((properties)=>{ for (var i = 0;i < properties.length; i++) { var property = properties[i]; @@ -159,7 +159,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>> | Promise> | 返回已安装输入法列表。 | - 示例 - ``` + ```js var properties = InputMethodSetting.listInputMethod(); for (var i = 0;i < properties.length; i++) { var property = properties[i]; @@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 - ``` + ```js InputMethodSetting.displayOptionalInputMethod(()=>{ console.info('displayOptionalInputMethod is called'); }); @@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | Promise<void> | 回调函数。 | - 示例 - ``` + ```js InputMethodSetting.displayOptionalInputMethod(); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index 0ecd9b3257546692b81781d2d41ee55897e7ae56..74c5220408b55b74764a8198c49cd4b8deb26b22 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine - 示例 - ``` + ```js var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); ``` @@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate - 示例 - ``` + ```js var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); ``` @@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli - 示例: - ``` + ```js InputMethodEngine.on('inputStart', (kbController, textInputClient) => { KeyboardController = kbController; TextInputClient = textInputClient; @@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC - 示例: - ``` + ```js InputMethodEngine.off('inputStart'); ``` @@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void - 示例: - ``` + ```js InputMethodEngine.on('keyboardShow', (err) => { console.info('keyboardShow'); }); @@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void - 示例: - ``` + ```js InputMethodEngine.off('keyboardShow'); ``` @@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void - 示例: - ``` + ```js KeyboardDelegate.on('keyDown', (event) => { console.info('keyDown'); }); @@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void - 示例: - ``` + ```js KeyboardDelegate.off('keyDown'); ``` @@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = - 示例: - ``` + ```js KeyboardDelegate.on('cursorContextChange', (x, y, height) => { console.info('cursorContextChange'); }); @@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) - 示例: - ``` + ```js KeyboardDelegate.off('cursorContextChange'); ``` ### on('selectionChange') @@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi - 示例: - ``` + ```js KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { console.info('selectionChange'); }); @@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe - 示例: - ``` + ```js KeyboardDelegate.off('selectionChange'); ``` @@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void - 示例: - ``` + ```js KeyboardDelegate.on('textChange', (text) => { console.info('textChange'); }); @@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void - 示例: - ``` + ```js KeyboardDelegate.off('textChange'); ``` @@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback<void>): void - 示例 -``` +```js KeyboardController.hideKeyboard(()=>{ }); ``` @@ -408,7 +408,7 @@ hideKeyboard(): Promise<void> - 示例 -``` +```js KeyboardController.hideKeyboard(); ``` @@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 返回文本。 | - 示例 - ``` + ```js TextInputClient.getForward(5,(text) =>{ console.info("text = " + text); }); @@ -458,7 +458,7 @@ getForward(length:number): Promise<string> | Promise<string> | 返回文本。 | - 示例 - ``` + ```js var text = TextInputClient.getForward(5); console.info("text = " + text); ``` @@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 返回文本。 | - 示例 - ``` + ```js TextInputClient.getBackward(5,(text)=>{ console.info("text = " + text); }); @@ -505,7 +505,7 @@ getBackward(length:number): Promise<string> | Promise<string> | 返回文本。 | - 示例 - ``` + ```js var text = TextInputClient.getBackward(5); console.info("text = " + text); ``` @@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.deleteForward(5,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -551,7 +551,7 @@ deleteForward(length:number): Promise<boolean> | Promise<boolean> | 操作成功与否。 | - 示例 - ``` + ```js var isSuccess = TextInputClient.deleteForward(5); console.info("isSuccess = " + isSuccess); ``` @@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.deleteBackward(5, (isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -598,7 +598,7 @@ deleteBackward(length:number): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.deleteBackward(5); console.info("isSuccess = " + isSuccess); ``` @@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); console.info("isSuccess = " + isSuccess); ``` @@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.insertText("test", (isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -691,7 +691,7 @@ insertText(text:string): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.insertText("test"); console.info("isSuccess = " + isSuccess); ``` @@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | 是 | 编辑框属性值。 | - 示例 - ``` + ```js TextInputClient.getEditorAttribute((EditorAttribute)=>{ }); ``` @@ -729,7 +729,7 @@ getEditorAttribute(): Promise<EditorAttribute> | Promise<[EditorAttribute](#EditorAttribute)> | 返回编辑框属性值。 | - 示例 - ``` + ```js var EditorAttribute = TextInputClient.getEditorAttribute(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 7a8240be840083cb2da250d8905c71ad126e852a..33868672cb9085ebeaf2494672dc0521e36b8797 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_osAccount from '@ohos.account.osAccount'; ``` @@ -24,7 +24,7 @@ getAccountManager(): AccountManager | [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); ``` @@ -64,7 +64,7 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调结果。 | **示例:**激活ID为100的系统帐号 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId, (err)=>{ @@ -97,7 +97,7 @@ activateOsAccount(localId: number): Promise<void> | Promise<void> | Promise实例,用于获取异步返回结果。 | **示例:**激活ID为100的系统帐号 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId).then(() => { @@ -123,7 +123,7 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); @@ -147,7 +147,7 @@ isMultiOsAccountEnable(): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); @@ -175,7 +175,7 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi **示例:**判断ID为100的系统帐号是否处于激活状态 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ @@ -208,7 +208,7 @@ isOsAccountActived(localId: number): Promise<boolean> **示例:**判断ID为100的系统帐号是否处于激活状态 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { @@ -238,7 +238,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ @@ -272,7 +272,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { @@ -298,7 +298,7 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { console.log("isTestOsAccount err: " + JSON.stringify(err)); @@ -322,7 +322,7 @@ isTestOsAccount(): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); @@ -347,7 +347,7 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -374,7 +374,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -406,7 +406,7 @@ isOsAccountVerified(localId?: number): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); @@ -436,7 +436,7 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -473,7 +473,7 @@ removeOsAccount(localId: number): Promise<void> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -510,7 +510,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl **示例:**给ID为100的系统帐号设置禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ @@ -546,7 +546,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl **示例:**删除ID为100的系统帐号的禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { @@ -578,7 +578,7 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< **示例:**将ID为100的系统帐号的帐号名设置成demoName - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var newName = "demoName"; @@ -614,7 +614,7 @@ setOsAccountName(localId: number, localName: string): Promise<void> **示例:**将ID为100的系统帐号的帐号名设置成demoName - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var nameLimit = "demoName"; @@ -643,7 +643,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); @@ -669,7 +669,7 @@ getCreatedOsAccountsCount(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((accountCnt) => { console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); @@ -694,7 +694,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); @@ -718,7 +718,7 @@ getOsAccountLocalIdFromProcess(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); @@ -744,7 +744,7 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): **示例:**查询值为12345678的uid所属的系统帐号的帐号ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { @@ -775,7 +775,7 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> **示例:**查询值为12345678的uid所属的系统帐号的帐号ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { @@ -804,7 +804,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall **示例:** - ``` + ```js var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { @@ -837,7 +837,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { @@ -865,7 +865,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); @@ -891,7 +891,7 @@ queryMaxOsAccountNumber(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); @@ -919,7 +919,7 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array< **示例:**获取ID为100的系统帐号的全部约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ @@ -952,7 +952,7 @@ getOsAccountAllConstraints(localId: number): Promise<Array<string>> **示例:**获取ID为100的系统帐号的全部约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { @@ -980,7 +980,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); @@ -1006,7 +1006,7 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); @@ -1031,7 +1031,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); @@ -1058,7 +1058,7 @@ queryActivatedOsAccountIds(): Promise<Array<number>> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds().then((idArray) => { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); @@ -1089,7 +1089,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ console.log("createOsAccount err:" + JSON.stringify(err)); @@ -1124,7 +1124,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1155,7 +1155,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ @@ -1191,7 +1191,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { @@ -1219,7 +1219,7 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((accountInfo) => { console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1275,7 +1275,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> **示例:**查询ID为100的系统帐号信息 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ @@ -1310,7 +1310,7 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> **示例:**查询ID为100的系统帐号信息 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { @@ -1336,7 +1336,7 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); @@ -1360,7 +1360,7 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); @@ -1387,7 +1387,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); @@ -1413,7 +1413,7 @@ getDistributedVirtualDeviceId(): Promise<string> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); @@ -1443,7 +1443,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) **示例:**获取ID为100的系统帐号的头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ @@ -1478,7 +1478,7 @@ getOsAccountProfilePhoto(localId: number): Promise<string> **示例:**获取ID为100的系统帐号的头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { @@ -1510,7 +1510,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback **示例:**给ID为100的系统帐号设置头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1549,7 +1549,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> **示例:**给ID为100的系统帐号设置头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1580,7 +1580,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& **示例:**查询与SN码12345关联的系统帐号的ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ @@ -1611,7 +1611,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> **示例:**查询与SN码12345关联的系统帐号的ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { @@ -1638,7 +1638,7 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu **示例:**获取ID为100的系统帐号关联的SN码 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ @@ -1669,7 +1669,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise<number> **示例:**获取ID为100的系统帐号关联的SN码 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { @@ -1701,7 +1701,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ console.log("receive localId:" + receiveLocalId); @@ -1731,7 +1731,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function offCallback(){ console.log("off enter") diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 6ab245ab6d63080d976577ee9a2ddaa44541eae1..ce2e8f8c264eaec822e89098ed321c475041cad4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); ``` @@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var pasteData = pasteboard.createHtmlData(html); ``` @@ -97,7 +97,7 @@ createWantData(want:Want): PasteData **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -126,7 +126,7 @@ createUriData(uri:string): PasteData **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); ``` @@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord **示例** - ``` + ```js var record = pasteboard.createPlainTextRecord("hello"); ``` @@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var record = pasteboard.createHtmlTextRecord(html); ``` @@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); ``` @@ -284,7 +284,7 @@ convertToText(): Promise<string> **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); record.convertToText().then((data) => { console.info('convertToText success data : ' + JSON.stringify(data)); @@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback<string>): void **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); record.convertToText((err, data) => { if (err) { @@ -346,7 +346,7 @@ getPrimaryText(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var plainText = pasteData.getPrimaryText(); ``` @@ -367,7 +367,7 @@ getPrimaryHtml(): string **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var pasteData = pasteboard.createHtmlData(html); var htmlText = pasteData.getPrimaryHtml(); @@ -389,7 +389,7 @@ getPrimaryWant(): Want **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -414,7 +414,7 @@ getPrimaryUri(): string **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var uri = pasteData.getPrimaryUri(); ``` @@ -437,7 +437,7 @@ addTextRecord(text: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); pasteData.addTextRecord("good"); ``` @@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; pasteData.addHtmlRecord(html); @@ -484,7 +484,7 @@ addWantRecord(want: Want): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var object = { bundleName: "com.example.aafwk.test", @@ -511,7 +511,7 @@ addUriRecord(uri: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); ``` @@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var textRecord = pasteboard.createPlainTextRecord("hello"); var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; @@ -559,7 +559,7 @@ getMimeTypes(): Array<string> **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var types = pasteData.getMimeTypes(); ``` @@ -580,7 +580,7 @@ getPrimaryMimeType(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var type = pasteData.getPrimaryMimeType(); ``` @@ -601,7 +601,7 @@ getProperty(): PasteDataProperty **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var property = pasteData.getProperty(); ``` @@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var record = pasteData.getRecordAt(0); ``` @@ -648,7 +648,7 @@ getRecordCount(): number **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var count = pasteData.getRecordCount(); ``` @@ -669,7 +669,7 @@ getTag(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var tag = pasteData.getTag(); ``` @@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` @@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var isRemove = pasteData.removeRecordAt(0); ``` @@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var isReplace = pasteData.replaceRecordAt(0, record); @@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); ``` @@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback<void>): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData, (error, data) => { @@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise<void> **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData).then((data) => { @@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback<PasteData>): void **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getPasteData((error, pasteData) => { if (error) { @@ -886,7 +886,7 @@ getPasteData(): Promise<PasteData> **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getPasteData().then((pasteData) => { var text = pasteData.getPrimaryText(); @@ -912,7 +912,7 @@ on(type: 'update', callback: () =>void ): void **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); var listener = ()=>{ console.info('The system pasteboard has changed'); @@ -937,7 +937,7 @@ off(type: 'update', callback?: () =>void ): void **示例** - ``` + ```js systemPasteboard.off('update', listener); ``` @@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback<boolean>): void **示例** - ``` + ```js systemPasteboard.hasPasteData((err, data) => { if (err) { console.error('failed to hasPasteData because ' + JSON.stringify(err)); @@ -983,7 +983,7 @@ hasPasteData(): Promise<boolean> **示例** - ``` + ```js systemPasteboard.hasPasteData().then((data) => { console.info('success hasPasteData : ' + JSON.stringify(data)); }).catch((error) => { @@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback<void>): void **示例** - ``` + ```js systemPasteboard.clear((err, data) => { if (err) { console.error('failed to clear because ' + JSON.stringify(err)); @@ -1034,7 +1034,7 @@ clear(): Promise<void> **示例** - ``` + ```js systemPasteboard.clear().then((data) => { console.info('success clear'); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 8d7ed2246a63c497b40605392468340e45282c30..4be83b781fc43b2d3dfbb5b350289bc4482c1794 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise<UploadTask> - 示例: - ``` + ```js request.upload({ url: 'https://patch' }).then((data) => { uploadTask = data; }).catch((err) => { @@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void - 示例: - ``` + ```js request.upload({ url: 'https://patch' }, (err, data) => { if (err) { console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); @@ -142,14 +142,14 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | +| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: - ``` + ```js uploadTask.on('progress', function callback(uploadedSize, totalSize) { console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); } @@ -175,13 +175,13 @@ on(type: 'headerReceive', callback: (header: object) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | header | object | 是 | HTTP Response Header。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| header | object | 是 | HTTP Response Header。 | - 示例: - ``` + ```js uploadTask.on('headerReceive', function callback(headers){ console.info("upOnHeader headers:" + JSON.stringify(headers)); } @@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | +| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: - ``` + ```js uploadTask.off('progress', function callback(uploadedSize, totalSize) { console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); } @@ -240,13 +240,13 @@ off(type: 'headerReceive', callback?: (header: object) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | header | object | 是 | HTTP Response Header。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| header | object | 是 | HTTP Response Header。 | - 示例: - ``` + ```js uploadTask.off('headerReceive', function callback(headers) { console.info("upOnHeader headers:" + JSON.stringify(headers)); } @@ -271,7 +271,7 @@ remove(): Promise<boolean> - 示例 - ``` + ```js uploadTask.remove().then((result) => { if (result) { console.info('Upload task removed successfully. '); @@ -301,7 +301,7 @@ remove(callback: AsyncCallback<boolean>): void - 示例 - ``` + ```js uploadTask.remove((err, result) => { if (err) { console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); @@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise<DownloadTask> - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { downloadTask = data; }).catch((err) => { @@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxxx.hap', filePath: 'xxx/xxxxx.hap'}, (err, data) => { if (err) { @@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度,单位为KB。 | - | totalSize | number | 是 | 下载文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| receivedSize | number | 是 | 当前下载的进度,单位为KB。 | +| totalSize | number | 是 | 下载文件的总大小,单位为KB。 | - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度。 | - | totalSize | number | 是 | 下载文件的总大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| receivedSize | number | 是 | 当前下载的进度。 | +| totalSize | number | 是 | 下载文件的总大小。 | - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + JSON.stringify(err)); @@ -581,13 +581,13 @@ on(type: 'fail', callback: (err: number) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -620,13 +620,13 @@ off(type: 'fail', callback?: (err: number) => void): void 回调函数的参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -658,7 +658,7 @@ remove(): Promise<boolean> - 示例 - ``` + ```js downloadTask.remove().then((result) => { if (result) { console.info('Download task removed.'); @@ -688,7 +688,7 @@ remove(callback: AsyncCallback<boolean>): void - 示例 - ``` + ```js downloadTask.remove((err, result)=>{ if(err) { console.error('Failed to remove the download task.'); @@ -720,7 +720,7 @@ query(): Promise<DownloadInfo> - 示例 - ``` + ```js downloadTask.query().then((downloadInfo) => { console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) }) .catch((err) => { @@ -746,7 +746,7 @@ query(callback: AsyncCallback<DownloadInfo>): void - 示例: - ``` + ```js downloadTask.query((err, downloadInfo)=>{ if(err) { console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); @@ -774,7 +774,7 @@ queryMimeType(): Promise<string> - 示例 - ``` + ```js downloadTask.queryMimeType().then((data) => { console.info('Download task queried. Data:' + JSON.stringify(data)); }).catch((err) => { @@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback<string>): void; - 示例 - ``` + ```js downloadTask.queryMimeType((err, data)=>{ if(err) { console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); @@ -828,7 +828,7 @@ pause(): Promise<void> - 示例 - ``` + ```js downloadTask.pause().then((result) => { if (result) { console.info('Download task paused. '); @@ -858,7 +858,7 @@ pause(callback: AsyncCallback<void>): void - 示例 - ``` + ```js downloadTask.pause((err, result)=>{ if(err) { console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); @@ -890,7 +890,7 @@ resume(): Promise<void> - 示例 - ``` + ```js downloadTask.resume().then((result) => { if (result) { console.info('Download task resumed.') @@ -921,7 +921,7 @@ resume(callback: AsyncCallback<void>): void - 示例 - ``` + ```js downloadTask.resume((err, result)=>{ if (err) { console.error('Failed to resume the download task. Cause:' + err); diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index 505af123ce6433ed86f1e11030307d50dbbd61ad..0e0321b65444291c885e94f8a3958e0e4a711f56 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -6,7 +6,7 @@ ## 导入模块 - + ``` import systemTime from '@ohos.systemTime'; ``` @@ -23,14 +23,14 @@ setTime(time : number, callback : AsyncCallback<void>) : void **系统能力**: SystemCapability.Miscservices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | time | number | 是 | 目标时间戳(毫秒)。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; systemTime.setTime(time, (error, data) => { @@ -54,18 +54,18 @@ setTime(time : number) : Promise<void> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | + | time | number | 是 | 目标时间戳(毫秒)。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; systemTime.setTime(time).then((data) => { @@ -85,14 +85,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); @@ -112,18 +112,18 @@ getCurrentTime(isNano?: boolean): Promise<number> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -141,14 +141,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getRealActiveTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); @@ -168,18 +168,18 @@ getRealActiveTime(isNano?: boolean): Promise<number> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -197,14 +197,14 @@ getRealTime(callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | - 示例: - - ``` + + ```js systemTime.getRealTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); @@ -224,18 +224,18 @@ getRealTime(): Promise<number> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getRealTime().then((data) => { console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); }).catch((error) => { @@ -255,14 +255,14 @@ setDate(date: Date, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | date | Date | 是 | 目标日期。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | date | Date | 是 | 目标日期。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data,(error, data) => { if (error) { @@ -285,18 +285,18 @@ setDate(date: Date): Promise<void> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | date | Date | 是 | 目标日期。 | + | date | Date | 是 | 目标日期。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data).then((value) => { console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); @@ -315,13 +315,13 @@ getDate(callback: AsyncCallback<Date>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | + | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | - 示例: - - ``` + + ```js systemTime.getDate((error, data) => { if (error) { console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); @@ -341,13 +341,13 @@ getDate(): Promise<Date> **系统能力**: SystemCapability.MiscServices.Time - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | + | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | - 示例: - - ``` + + ```js systemTime.getDate().then((data) => { console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -367,14 +367,14 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | timezone | string | 是 | 系统时区。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | timezone | string | 是 | 系统时区。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js systemTime.setTimezone('Asia/Shanghai', (error, data) => { if (error) { console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); @@ -396,18 +396,18 @@ setTimezone(timezone: string): Promise<void> **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | timezone | string | 是 | 系统时区。 | + | timezone | string | 是 | 系统时区。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js systemTime.setTimezone('Asia/Shanghai').then((data) => { console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -425,13 +425,13 @@ getTimezone(callback: AsyncCallback<string>): void **系统能力**: SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | + | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | - 示例: - - ``` + + ```js systemTime.getTimezone((error, data) => { if (error) { console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); @@ -451,13 +451,13 @@ getTimezone(): Promise<string> **系统能力**: SystemCapability.MiscServices.Time - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<string> | 以Promise形式返回结果,返回系统时区。 | + | Promise<string> | 以Promise形式返回结果,返回系统时区。 | - 示例: - - ``` + + ```js systemTime.getTimezone().then((data) => { console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index b542ff5ff6493bb84fea27b73a81783ea05d1a1c..372ca96ad2be5c343d39b875e291607bddbd737b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -18,10 +18,10 @@ import wallpaper from '@ohos.wallpaper'; **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 - | 名称 | 说明 | +| 名称 | 说明 | | -------- | -------- | -| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | -| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | +| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | +| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | ## wallpaper.getColors @@ -33,14 +33,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | - 示例: - ``` + ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getColors because: ` + JSON.stringify(error)); @@ -60,18 +60,18 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | + | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | - 示例: - ``` + ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getColors.`); }).catch((error) => { @@ -89,14 +89,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - ``` + ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getId because: ` + JSON.stringify(error)); @@ -117,18 +117,18 @@ getId(wallpaperType: WallpaperType): Promise<number> - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | + | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - ``` + ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getId: ` + JSON.stringify(data)); }).catch((error) => { @@ -146,13 +146,13 @@ getMinHeight(callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - ``` + ```js wallpaper.getMinHeight((error, data) => { if (error) { console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); @@ -173,13 +173,13 @@ getMinHeight(): Promise<number> - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | + | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - ``` + ```js wallpaper.getMinHeight().then((data) => { console.log(`success to getMinHeight: ` + JSON.stringify(data)); }).catch((error) => { @@ -198,13 +198,13 @@ getMinWidth(callback: AsyncCallback<number>): void - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | + | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - ``` + ```js wallpaper.getMinWidth((error, data) => { if (error) { console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); @@ -224,13 +224,13 @@ getMinWidth(): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | + | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - ``` + ```js wallpaper.getMinWidth().then((data) => { console.log(`success to getMinWidth: ` + JSON.stringify(data)); }).catch((error) => { @@ -248,13 +248,13 @@ isChangePermitted(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | + | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isChangePermitted((error, data) => { if (error) { console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); @@ -274,13 +274,13 @@ isChangePermitted(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | + | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isChangePermitted().then((data) => { console.log(`success to isChangePermitted: ` + JSON.stringify(data)); }).catch((error) => { @@ -298,13 +298,13 @@ isOperationAllowed(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | + | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isOperationAllowed((error, data) => { if (error) { console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); @@ -324,13 +324,13 @@ isOperationAllowed(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | + | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isOperationAllowed().then((data) => { console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); }).catch((error) => { @@ -350,14 +350,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to reset because: ` + JSON.stringify(error)); @@ -379,18 +379,18 @@ reset(wallpaperType: WallpaperType): Promise<void> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to reset.`); }).catch((error) => { @@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call - 示例: - ``` + ```js // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -469,13 +469,13 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | + | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -515,14 +515,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getFile because: ` + JSON.stringify(error)); @@ -543,18 +543,18 @@ getFile(wallpaperType: WallpaperType): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getFile: ` + JSON.stringify(data)); }).catch((error) => { @@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType - 示例: - ``` + ```js let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); }; @@ -596,14 +596,14 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | - | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | + | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | + | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | - 示例: - ``` + ```js let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); }; @@ -619,9 +619,9 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 - | 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| red | number | 是 | 是 | 表示红色值,范围为 0 到 255。 | -| green | number | 是 | 是 | 表示绿色值,范围为 0 到 255。 | -| blue | number | 是 | 是 | 表示蓝色值,范围为 0 到 255。 | -| alpha | number | 是 | 是 | 表示 alpha 值,范围为 0 到 255。 | +| red | number | 是 | 是 | 表示红色值,范围为 0 到 255。 | +| green | number | 是 | 是 | 表示绿色值,范围为 0 到 255。 | +| blue | number | 是 | 是 | 表示蓝色值,范围为 0 到 255。 | +| alpha | number | 是 | 是 | 表示 alpha 值,范围为 0 到 255。 | diff --git a/zh-cn/device-dev/subsystems/subsys-boot-init.md b/zh-cn/device-dev/subsystems/subsys-boot-init.md index da099a6475bb20633aff0baa29f9639fe3c5fdca..4aa01f866b8109917b8247bf41e5dcafae097afd 100755 --- a/zh-cn/device-dev/subsystems/subsys-boot-init.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-init.md @@ -1,223 +1,296 @@ -# init启动引导组件 +# init启动引导组件 -## 功能说明 +## 功能说明 - init启动引导组件负责在系统启动阶段启动关键服务进程。 若用户需要新增随开机自启动的系统服务,可添加新的配置文件xxx.cfg,系统会自动分析对应的cfg文件,并按照cfg文件启动对应的服务。 +init启动引导组件负责在系统启动阶段启动关键服务进程。 若用户需要新增随开机自启动的系统服务,可添加新的配置文件xxx.cfg,系统会自动分析对应的cfg文件,并按照cfg文件启动对应的服务。 -- init启动引导的配置文件 +- init启动引导的配置文件 - init启动引导组件配置文件包含了所有需要由init进程启动的系统关键服务的服务名、可执行文件路径、权限和其他信息,烧写单板后可在“/etc/“目录下找到,文件名称为init.cfg,采用json格式,文件大小目前限制在100KB以内。 + init启动引导组件配置文件包含了所有需要由init进程启动的系统关键服务的服务名、可执行文件路径、权限和其他信息,烧写单板后可在“/etc/“目录下找到,文件名称为init.cfg,采用json格式,文件大小目前限制在100KB以内。 init进程启动后读取/etc/init.cfg,然后解析其json格式内容,并根据解析结果依次加载系统服务。 - 各模块需要添加关键服务时,也可以添加模块对应的cfg文件,编译时拷贝文件到/system/etc/init目录下,init进程会解析改cfg文件,并启动对应的服务。 + 各模块需要配置或添加关键服务时,可以在对应模块的cfg文件进行配置,编译过程中会将配置后的文件拷贝到/system/etc/init目录下,单板中可在"/etc/init/"目录下查找到对应的cfg文件, + + 对于单板中/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服务启动控制(仅标准系统以上提供) +- init服务启动控制(仅标准系统以上提供) init会根据用户的服务配置,把服务分成三类,在不同的阶段进行启动。 - - “boot”类型:对应系统中需要优先启动的服务,这类服务在init完成init阶段后启动。 - - “normal”类型:默认配置,对应系统中的普通服务,这类服务在init命令执行完成后启动。 - - "condition"类型:对应有特殊要求的服务,可以直接通过start xxx 命令执行启动,一般在条件job或者在init的某个阶段使用命令启动。 + - “boot”类型:对应系统中需要优先启动的服务,该类服务在“init”阶段启动。 + - “normal”类型:默认配置,对应系统中的普通服务,该类服务在“post-init"阶段启动。 + - “condition”类型:表示服务按照条件启动。对有特殊要求的服务,可以直接通过start xxx 命令执行启动,一般在条件“job”或者在“init”的某个阶段使用命令启动。 - 服务间或服务与命令之间存在依赖关系,需要通过"condition"描述服务,例如: - ``` + 服务间或服务与命令之间存在依赖关系,需要通过"condition"描述服务,配置参考如下: + ``` "services" : [{ - "name" : "service1", - "path" : ["/bin/process1", "param1", "param2"], - "uid" : 1, - "gid" : 1, - "once" : 0, - "importance" : 1, - "caps" : [0, 1, 2, 5], + "name" : "serviceName", "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服务并行控制(仅标准系统以上提供) init提供服务并行处理能力,启动服务在不同的阶段执行job的能力。 - - “on-start”:在服务进程被fock后执行,不同服务的on-start job可以并行执行(在服务的子进程中执行,只对改进程产生影响)。 + - “on-start”:在服务进程被fork后执行,不同服务的on-start job可以并行执行(在服务的子进程中执行,只对该进程产生影响)。 - “on-stop”:在服务停止时执行。 - "on-restart":在服务重启时执行。 -- init 按需启动(仅标准系统以上提供) + 配置参考如下: + ``` + "services" : [{ + "name" : "serviceName", + "jobs" : { + "on-boot" : "boot", + "on-start" : "services:serviceName_start", + "on-stop" : "services:serviceName_stop", + "on-restart" : "services:serviceName_restart" + } + }, + ``` + +- init 按需启动(仅标准系统以上提供) 由init管理的服务支持按需启动,按需启动的服务不会在系统启动过程中主动被拉起,而是当某些事件发生时才会被init按需拉起,触发服务启动的事件可能是被init监听的相关socket有消息上报、samgr收到客户端的请求需要拉起SA服务等情况。 - "ondemand" 属性是按需启动的服务的标志,一个服务配置了该属性值为true的时候,服务不再需要配置start命令来拉起,而是被监听的相应事件发生时才会被拉起。 + "ondemand":按需启动服务的标志,一个服务配置了该属性值为true的时候,服务不再需要配置start命令来拉起,而是被监听的相应事件发生时才会被拉起。 - - SA进程按需启动 - 1. 应用请求SA句柄时samgr需识别SA所属进程是否可动态拉起。 - 2. 如需拉起,则需阻塞请求,等init拉起SA进程并注册SA后再返回所请求的SA句柄。 + “ondemand”配置参考如下: + ``` + "services" : [{ + "name" : "serviceName", + "ondemand" : true, + }] + ``` + - SA进程按需启动 + 1. 应用请求SA句柄时samgr需识别SA所属进程是否可动态拉起。 + 2. 如需拉起,则需阻塞请求,等init拉起SA进程并注册SA后再返回所请求的SA句柄。 - socket进程按需启动 - 1. init在pre-fork阶段为socket类进程创建好socket,init中监听创建好的socket上的网络事件。 - 2. socket上有报文事件后,init拉起socket进程进行报文处理,init进程取消socket数据的监听,由socket进程处理。 - 3. socket进程无报文处理后,可以自动退出,退出后init回收该子进程并重新监听socket网络数据。 + 1. init进程在pre-fork阶段为socket类进程创建好socket,init进程中监听创建好的socket上的网络事件。 + 2. socket上有报文事件后,init进程拉起socket进程进行报文处理,init进程取消socket数据的监听,由socket进程处理。 + 3. socket进程无报文处理后,可以自动退出,退出后init进程回收该子进程并重新监听socket网络数据。 + - 热插拔服务进程按需启动  进程可根据系统参数的变化进行热插拔事件按需启动处理。 - - 热插拔服务进程按需启动 -
  进程可根据系统参数的变化进行热插拔事件按需启动处理。 - -- init 进程启动&回收能力增强
+- init 进程启动&回收能力增强 进程启动时,支持在配置文件中配置服务进程的绑核、优先级、MAC信息以及AccessToken信息。 - - init提供修改*.cfg配置文件, 为服务进程提供cpu绑核功能。 - - init提供修改*.cfg配置文件, 为服务进程提供优先级设置。 - - init提供修改*.cfg配置文件, 为服务提供设置AccessToken, 为系统服务进程设置其分布式Capability能力(仅标准系统以上提供)。 - - init提供修改*.cfg配置文件, 为服务提供抑制机制。 + - init提供修改\*.cfg配置文件, 为服务进程提供cpu绑核功能。 + - init提供修改\*.cfg配置文件, 为服务进程提供优先级设置。 + - init提供修改\*.cfg配置文件, 为服务提供MAC信息设置,即服务的SELinux标签。 + - init提供修改\*.cfg配置文件, 为服务提供设置AccessToken, 为系统服务进程设置其分布式Capability能力(仅标准系统以上提供)。 + - init提供修改\*.cfg配置文件, 为服务提供抑制机制。 -- init FD代持(仅标准系统以上提供) + 服务进程启动&回收能力增强配置,如下: + ``` + "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。 - init提供了相关接口供服务调用,服务进程退出前调用接口将fd通过支持IPC通信的socket发送给init代持,待该服务重新启动时,init将持有的该服务相关的fd句柄通过同样的方式返回给服务。 + init提供了相关接口供服务调用,服务进程退出前调用接口将fd通过支持IPC通信的socket发送给init代持,待该服务重新启动时,init将持有的该服务相关的fd句柄通过同样的方式返回给服务。相关接口参考:[FD代持接口介绍](#table14737791479)。 -- init job +- init job 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:用户任意定义,可以通过trigger命令执行。 - - 控制job(仅标准系统以上提供):按条件触发处理的能力。在job中可以设置触发条件,当对应的属性值满足设置的条件时,就会触发job执行。触发条件支持&&和||操作,可以根据不同的属性就行组合。 - -## 开发指导 - - 1. 配置jobs数组。 - - init启动引导组件将系统启动分为三个阶段: - - - “pre-init”阶段:启动系统服务之前需要先执行的操作,例如挂载文件系统、创建文件夹、修改权限等。 - - “init”阶段:系统服务启动阶段。 - - “post-init”阶段:系统服务启动完后还需要执行的操作。 - - ``` + - job:用户任意定义,可以通过trigger命令执行。 + - 控制job(仅标准系统以上提供):按条件触发处理的能力。在job中可以设置触发条件,当对应的属性值满足设置的条件时,就会触发job执行。触发条件支持&&和||操作,可以根据不同的属性自行组合。 + + - bootchart 插件 + + 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目录下导出如下文件:
+ header
+ proc_diskstats.log
+ proc_ps.log
+ proc_stat.log
+ 并存放在bootchart文件夹 + 7. 使用命令:tar -zcvf bootchart.tgz * 进行打包(只支持linux版本)并将该打包文件拷贝到linux:bootchart-master目录下 + 8. 运行:
+ 在bootchart-master目录下运行
+ python3 pybootchartgui.py -f pdf bootchart.tgz
+ + 预期结果:
+         在bootchart-master目录下生成bootchart.pdf + +## 开发指导 + +1. 配置jobs数组。 + init启动引导组件将系统启动分为三个阶段: + + - “pre-init”阶段:启动系统服务之前需要先执行的操作,例如挂载文件系统、创建文件夹、修改权限等。 + - “init”阶段:系统服务启动阶段。 + - “post-init”阶段:系统服务启动完成后还需要执行的操作。 + + ``` "jobs" : [{ - "name" : "pre-init", - "cmds" : [ - "mkdir /testdir", - "chmod 0700 /testdir", - "chown 99 99 /testdir", - "mount vfat /dev/mmcblk0p0 /testdir2 noexec nosuid" // mount命令,格式为:mount 文件系统类型 source target flags data - ] - }, { - "name" : "init", - "cmds" : [ - "start service1", - ] - }, { - "name" : "post-init", - "cmds" : [] - } - ] - ``` - -**表 1** 执行job介绍 - - - - - - - - - - - - - - -

job名

-

说明

-

pre-init

-

最先执行的job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。

-

init

-

中间执行的job,例如服务启动。

-

post-init

-

最后被执行的job,如果开发者的进程在启动完成之后需要有一些处理(如驱动初始化后再挂载设备),可以把这类操作放到该job执行。单个job最多支持30条命令(当前仅支持start/mkdir/chmod/chown/mount/loadcfg),命令名称和后面的参数(参数长度≤128字节)之间有且只能有一个空格。

-
- -**表 2** 命令集说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

命令

-

命令格式和示例

-

说明

-

mkdir

-

mkdir 目标文件夹

-

如:mkdir /storage/myDirectory

-

创建文件夹命令,mkdir和目标文件夹之间有且只能有一个空格。

-

chmod

-

chmod 权限 目标

-

如:chmod 0600 /storage/myFile.txt

-

chmod 0750 /storage/myDir

-

修改权限命令,chmod权限目标之间间隔有且仅有一个空格,权限必须为0xxx格式。

-

chown

-

chown uid gid 目标

-

如:chown 900 800 /storage/myDir

-

chown 100 100 /storage/myFile.txt

-

修改属组命令,chown uid gid目标之间间隔有且仅有一个空格。

-

mount

-

mount fileSystemType src dst flags data

-

如:mount vfat /dev/mmcblk0 /sdc rw,umask=000

-

mount jffs2 /dev/mtdblock3 /storage nosuid

-

挂载命令,各参数之间有且仅有一个空格。flags当前仅支持nodev、noexec、nosuid、rdonly,data为可选字段。

-

start

-

start serviceName

-

如:start foundation

-

start shell

-

启动服务命令,start后面跟着service名称,该service名称必须能够在services数组中找到。

-

loadcfg

-

loadcfg filePath

-

如:loadcfg /patch/fstab.cfg

-

加载其他cfg文件命令。后面跟着的目标文件大小不得超过50KB,且目前仅支持加载/patch/fstab.cfg,其他文件路径和文件名均不支持。/patch/fstab.cfg文件的每一行都是一条命令,命令类型和格式必须符合本表格描述,命令条数不得超过20条。

-
- - 2. 配置services数组,service集合(数组形式),包含了init进程需要启动的所有系统服务(最多支持100个)。 - -``` + "name" : "pre-init", + "cmds" : [ + "mkdir /testdir", + "chmod 0700 /testdir", + "chown 99 99 /testdir", + "mount vfat /dev/mmcblk0p0 /testdir2 noexec nosuid" // mount命令,格式为:mount 文件系统类型 source target flags data + ] + }, { + "name" : "init", + "cmds" : [ + "start service1", + ] + }, { + "name" : "post-init", + "cmds" : [] + } + ] + ``` + + **表1** 执行job介绍 + | job名 | 说明 | + | :-------- | :-------- | + | pre-init | 最先执行的job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。 | + | init | 中间执行的job,例如服务启动。 | + | post-init | 最后被执行的job,如果开发者的进程在启动完成之后需要有一些处理(如驱动初始化后再挂载设备),可以把这类操作放到该job执行。单个job最多支持30条命令(当前仅支持start/mkdir/chmod/chown/mount/loadcfg),命令名称和后面的参数(参数长度≤128字节)之间有且只能有一个空格。 | + + **表2** 命令集说明 + | 命令 | 命令格式和示例 | 说明 | 支持系统类型 | + | -------- | -------- | -------- | -------- | + | mkdir | mkdir 目标文件夹
如:mkdir /storage/myDirectory | 创建文件夹命令,mkdir和目标文件夹之间有且只能有一个空格。 | small&standard | + | chmod | chmod 权限 目标
如:chmod 0600 /storage/myFile.txt
chmod 0750 /storage/myDir | 修改权限命令,chmod权限目标之间间隔有且仅有一个空格,权限必须为0xxx格式。 | small&standard | + | chown | chown uid gid 目标
如:chown 900 800 /storage/myDir
chown 100 100 /storage/myFile.txt | 修改属组命令,chown uid gid目标之间间隔有且仅有一个空格。 | small&standard | + | mount | mount fileSystemType src dst flags data
如:mount vfat /dev/mmcblk0 /sdc rw,umask=000
mount jffs2 /dev/mtdblock3 /storage nosuid | 挂载命令,各参数之间有且仅有一个空格。flags当前仅支持nodev、noexec、nosuid、rdonly,data为可选字段。 | small&standard | + | start | start serviceName
如:start foundation
start shell | 启动服务命令,start后面跟着service名称,该service名称必须能够在services数组中找到。 | small&standard | + | export | export key value
如:export TEST /data/test | 设置环境变量命令。后面跟两个参数,第一个参数是环境变量名,第二个参数是环境变量值。| small&standard | + | rm | rm filename
如:rm /data/testfile | 删除文件命令。后面跟一个参数,即文件的绝对路径。 | small&standard | + | rmdir | rmdir dirname
如:rmdir /data/testdir | 删除目录命令。后面跟一个参数,即目录的绝对路径。 | small&standard | write | write filename value
如:write /data/testfile 0 | 写文件命令。后面跟两个参数,第一个参数是文件的绝对路径,第二个参数是要写入文件的字符串。 | small&standard | + | stop | stop servicename
如:stop console | 关闭服务命令。后面跟一个参数,即要关闭的服务名。 | small&standard | + | copy | copy oldfile newfile
如:copy /data/old /data/new | 拷贝文件命令。后面跟两个参数,第一个参数是原文件绝对路径,第二个参数是新文件绝对路径。 | small&standard | + | reset | reset servicename
如:reset console | 重启服务命令。后面跟一个参数,即要重启的服务名。目前reset命令的策略是,如果一个服务没有启动,则该命令会将其拉起,如果一个服务处于运行状态,则该命令会将其关闭后重启。| small&standard | + | reboot | reboot (subsystem)
如:reboot updater | 重启系统命令。后面可以跟一个参数,也可以没有参数,当没有参数时执行该命令,将会使设备重启到当前系统,当后面跟参数时,参数应当是子系统的名字,例如,reboot updater,将会重启进入updater子系统。 | small&standard | + | sleep | sleep time
如:sleep 5 | 睡眠命令。后面可以跟一个参数,该参数是睡眠时间。 | small&standard | + | domainname | domainname name
如:domainname localdomain | 设置域名 | small&standard | + | hostname | hostname name
如:hostname localhost | 设置主机名命令。 | small&standard | + | wait | wait PID
如:wait pid | 等待命令。| small&standard | + | setrlimit | setrlimit resource curValue maxValue
如:| 设定资源使用限制命令。 | small&standard | + | write | write path content
如:write /proc/sys/kernel/sysrq 0 | 写文件命令。 | small&standard | + | exec | exec 可执行文件路径 可执行文件传的参数
如:exec /system/bin/udevadm trigger | 系统调用命令。 | small&standard | + | mknode |mknod name { b \| c } Major Minor
如mknod path b 0644 1 9| 建立一个目录项和一个特殊文件的对应索引节点。 参考mknod命令 |standard | + | makedev | makedev major minor
如:makedev -v update | 创建静态的设备节点命令,通常位于/dev目录下。| standard | + | symlink | symlink path1 path2
如:symlink /proc/self/fd/0 /dev/stdin | 符号链接命令。 | standard | + | trigger | trigger jobName
如:trigger early-fs | 触发job执行的命令。 | standard | + | insmod | insmod ko文件
如:insmod xxx.ko| 内核模块文件载入命令。 | standard | + | setparam | setparam paramname paramvalue
如:setparam sys.usb.config hdc| 设置系统参数。| standard | + | load_persist_params | load persist params
如:load_persist_params | 加载persist参数。load_persist_params命令后有且仅有一个空格 | standard | + | load_param | load params
如:load_param /data/test.normal.para| 将文件里的param加载到内存。| standard | + | load_access_token_id | 如:load_access_token_id | 将access token信息写入data/service/el0/access_token/nativetoken.json文件,load_access_token_id后有且只有一个空格。| standard | + | ifup | ifup 激活网络接口
如:ifup eth0 | 激活指定的网络接口。| standard | + | mount_fstab | mount_fstab fstab.test
如:mount_fstab /vendor/etc/fstab.test| 按照fstab挂载分区的命令。 | standard | + | umount_fstab | umount_fstab fstab.test
如:umount_fstab /vendor/etc/fstab.test | 按照fstab卸载分区的命令。 | standard | + | restorecon | restorecon file or dir
如:restorecon /file | 重新加载selinux 的context。 | standard | + | stopAllServices | stopAllServices [bool]
如:stopAllServices false 或 stopAllServices | 停止所有服务。 | standard | + | umount |umount path
如:umount /vendor | 卸载已经挂载的硬件设备 。 | standard | + | sync | 如:sync  | 同步写入数据到磁盘。sync后有且仅有一个空格。| standard | + | timer_start | timer_start serviceName
如:timer_start console | 启动服务计时器。 | standard | + | timer_stop | timer_stop serviceName
如:timer_stop console | 停止服务计时器。 | standard | + | init_global_key | init_global_key path 如:init_global_key /data | data分区文件加密key初始化。| standard | + | init_main_user | 如:init_main_user| 主用户目录加密。| standard | + | mkswap | mkswap file
如:mkswap /swapfile1 | 在一个文件或者设备上建立交换分区。 | standard | + | swapon | swapon file
如:swapon /swapfile1| 激活交换空间 | standard | + | loadcfg | loadcfg filePath
如:loadcfg /patch/fstab.cfg | 加载其他cfg文件命令。后面跟着的目标文件大小不得超过50KB,且目前仅支持加载/patch/fstab.cfg,其他文件路径和文件名均不支持。/patch/fstab.cfg文件的每一行都是一条命令,命令类型和格式必须符合本表格描述,命令条数不得超过20条。 | small | + +2. 配置services数组,service集合(数组形式),包含了init进程需要启动的所有系统服务。 + + ``` "services" : [{ "name" : "service1", "path" : ["/bin/process1", "param1", "param2"], @@ -230,7 +303,7 @@ "cpucore" : [0], "critical" : [0, 5, 10], "apl" : "normal", - "d-caps" : ["OHOS_DMS"] + "d-caps" : ["OHOS_DMS"], "jobs" : { "on-boot" : "boot", "on-start" : "services:service1_start", @@ -250,113 +323,137 @@ "apl" : "normal", "d-caps" : [ ] }] -``` - -**表 3** service字段说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

字段名

-

说明

-

name

-

当前服务的服务名,须确保非空且长度<=32字节。

-

path

-

当前服务的可执行文件全路径和参数,数组形式。须确保第一个数组元素为可执行文件路径、数组元素个数<=20、每个元素为字符串形式以及每个字符串长度<=64字节。

-

uid

-

当前服务进程的uid值。

-

gid

-

当前服务进程的gid值。

-

once

-

当前服务进程是否为一次性进程:

-

1:一次性进程,当该进程退出时,init不会重新启动该服务进程

-

0 : 常驻进程,当该进程退出时,init收到SIGCHLD信号并重新启动该服务进程;

-

注意,对于常驻进程,若在4分钟之内连续退出5次,第5次退出时init将不会再重新拉起该服务进程。

-

importance

-

标准系统中:
服务进程优先级, 取值范围[-20, 19];
小型系统中:
0 : 非重要进程
1 : 重要进程

-

caps

-

当前服务所需的capability值,根据安全子系统已支持的capability,评估所需的capability,遵循最小权限原则配置(当前最多可配置100个值)。

-

critical

-

critical服务启动失败后, 需要M秒内重新拉起, 拉起失败N次后, 直接重启系统, N默认为4, M默认20。(仅标准系统以上提供 "critical" : [0, 2, 10]; 类型为int型数组)。

-

0:不使能;

-

1:使能。

-

cpucore

-

服务需要的绑定的cpu核心数, 类型为int型数组。

-

d-caps

-

分布式能力 (仅标准系统以上提供)。

-

apl

-

能力特权级别:system_core, normal, system_basic。 默认system_core (仅标准系统以上提供)。

-

start-mode

-

服务的启动模式,具体描述:init服务启动控制(仅标准系统以上提供)。

-

jobs

-

当前服务在不同阶段可以执行的job。具体说明可以看:init服务并行控制(仅标准系统以上提供)。

-
- - **表 4** 接口介绍 - - | 函数名 | 函数解释 |参数解释 | - | :---------- | :---------- |:--------| - | int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | 获取init代持的fd | 返回值:成功返回fd数组指针,失败返回NULL。备注:需手动释放
参数:
serviceName: 服务名
outfdCount: 返回的fd数组长度 | - | int ServiceSaveFd(const char *serviceName, int *fds, int fdCount) | 请求init代持fd | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
fds: 需要init代持的fd数组指针
fdCount: fd数组长度 - | int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc) | 配置服务参数 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
action: 服务行为("start", "stop", "restart")
extArgv: 参数数组
extArgc: 参数个数 - | int ServiceControl(const char *serviceName, int action) | 控制服务行为 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
action: 服务行为("start", "stop", "restart") - -## 开发实例 - - init启动引导程序,此处以要新增一个名为MySystemApp的系统服务为例进行说明,使用如下配置: - -``` + ``` + + **表3** service字段说明 + + | 字段名 | 字段说明 | 字段解释 | 支持系统类型 | + | ---------- |-------- | --------| --------| + | name | 当前服务的服务名。 | 类型:字符串; 服务名非空且长度<=32字节。| small&standard | + | path | 当前服务的可执行文件全路径和参数,数组形式。 | 确保第一个数组元素为可执行文件路径、数组元素个数<=20。
每个元素为字符串形式以及每个字符串长度<=64字节。| small&standard | + | uid | 当前服务进程的uid值。 | 类型:int | small&standard | + | gid | 当前服务进程的gid值。 | 类型:int | small&standard | + | once | 当前服务进程是否为一次性进程。 | 1:一次性进程,当该进程退出时,init不会重新启动该服务进程。
0 : 常驻进程,当该进程退出时,init收到SIGCHLD信号并重新启动该服务进程。 | small&standard | + | importance | 当前服务优先级 | 标准系统中:
   服务优先级取值范围 [-20, 19],超出为无效设置。
小型系统中:
   0 : 非重要进程
   非0 : 重要进程 | small&standard | + | caps | 当前服务所需的capability值,根据安全子系统已支持的capability,评估所需的capability,遵循最小权限原则配置。| 类型:数字或者字符串数组,在配置数字时,按linux标准的capability进行配置。字符串时,使用标准定义的宏的名字进行配置。 | small&standard | + | critical | 为服务提供抑制机制,服务在配置时间 T 内,频繁重启次数超过设置次数 N 重启系统。 | 标准系统中
   类型:int型数组,如:"critical" : [M, N, T]
    M:使能标志位(0:不使能;1:使能), N:频繁拉起服务次数, T:时间(单位:秒)。
    M > 0; N > 0
小型系统中 & 标准系统中:
   类型:int,如:"critical" : M
    M:使能标志位(0:不使能;1:使能)
   默认拉起服务次数:4次, 时间:20秒。 | small&standard | + | cpucore | 服务需要的绑定的cpu核心数 | 类型:int型数组, 如"cpucore" : [N1, N2, ...], N1, N2均为需要绑定的cpu核索引
如单核设备 cpucore : [0] | small&standard | + | d-caps | 服务分布式能力(仅标准系统以上提供)。| 类型:字符串数组, 如 "d-caps" : ["OHOS_DMS"] | standard | + | apl | 服务能力特权级别(仅标准系统以上提供)。 | 类型:字符串, 如 "apl" : "system_core"。
目前支持"system_core"(默认值), "normal", "system_basic"。 | standard | + | start-mode | 服务的启动模式(仅标准系统以上提供)。 | 类型:字符串, 如 "start-mode" : "condition"。
目前支持"boot", "normal", "condition"。具体说明参考:[init服务启动控制](#section56901555918) | standard | + | jobs | 当前服务在不同阶段可以执行的job。 | 具体说明参考:[init服务并行控制](#section56901555919) | small&standard | + | ondemand | 按需启动服务的标志。 | 类型:bool,如"ondemand" : true,小型系统只在Linux内核上支持。具体说明参考:[init服务按需启动](#section56901555920)| small&standard | + | disable | 预留字段,无实际意义。 | | small&standard | +3. 服务中socket配置和按需启动。 + + 服务中支持配置 "socket" 属性,该属性以一个JSON对象的格式配置。配置有 "socket" 属性的服务,init将会为其创建socket,以是否为按需启动服务来区分其创建的时机。 + - 按需启动的服务,init会在解析到该服务时,根据解析到的socket配置进行创建。 + - 正常启动的服务,init会在拉起该服务时,执行服务可执行文件之前创建其配置的socket。 + + 无论服务是否按需启动,其真正被拉起后,都需要通过特定接口获取init为其创建的socket句柄,进而接手该socket的管理,成为服务自有的socket。 + 除以上socket的配置和创建流程,对于按需启动的服务,init还有不同行为。当init在创建根据服务的socket配置创建完socket后,将会判断服务的ondemand属性是否为true(按需启动服务),若是则会调用接口对socket进行轮询监听,直到socket有消息上报,此时将停止监听并拉起对应服务,由服务接管该socket并处理消息。 + + 下面以ueventd服务为例介绍服务中socket和按需启动的配置以及各字段的含义。 + + ``` + "services" : [{ + "name" : "ueventd", + "path" : ["/system/bin/ueventd"], + "socket" : [{ + "name" : "ueventd", + "family" : "AF_NETLINK", + "type" : "SOCK_DGRAM", + "protocol" : "NETLINK_KOBJECT_UEVENT", + "permissions" : "0660", + "uid" : "system", + "gid" : "system", + "option" : [ + "SOCKET_OPTION_PASSCRED", + "SOCKET_OPTION_RCVBUFFORCE", + "SOCK_CLOEXEC", + "SOCK_NONBLOCK" + ] + }], + "critical" : [ 0, 5, 15], + "ondemand" : true, + "start-mode" : "condition" + }] + ``` + + **表4** socket字段说明 + |字段名 | 说明 | + | -------- | -------- | + |name|当前socket的命名,不要求必须与服务同名,与服务名同样须满足非空且长度<=32字节。| + |family|socket所属的地址族,目前支持的为服务创建的socket有AF_UNIX和AF_NETLINK族。| + |type|socket的类型,目前支持的类型有基于连接的SOCK_SEQPACKET和SOCK_STREAM,还有基于UDP无连接的SOCK_DGRAM。| + |protocol|socket通信遵循的协议类型,在无特殊需求的情况下,该值可配置为default缺省值,因为socket接口会自动根据socket地址族和类型选择合适的协议。此处除了default,并且支持NETLINK_KOBJECT_UEVENT协议类型。| + |permissions|socket节点文件的权限。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。| + |uid|socket节点文件的用户ID。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。| + |gid|socket节点文件的组ID。此项配置仅对如AF_UNIX地址族等有实体节点文件的socket类型有效。| + |option|socket的可选配置。在调用setsockopt接口时传入设置,目前支持的option选项有SOCKET_OPTION_PASSCRED、SOCKET_OPTION_RCVBUFFORCE、SOCK_CLOEXEC和SOCK_NONBLOCK。| + + **表5** FD代持接口介绍 + + | 函数名 | 函数解释 |参数解释 | + | ---------- | ---------- |--------| + | int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | 获取init代持的fd | 返回值:成功返回fd数组指针,失败返回NULL。备注:需手动释放
参数:
serviceName: 服务名
outfdCount: 返回的fd数组长度 | + | int ServiceSaveFd(const char *serviceName, int *fds, int fdCount) | 请求init代持fd | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
fds: 需要init代持的fd数组指针
fdCount: fd数组长度 + | int ServiceSaveFdWithPoll(const char *serviceName, int *fds, int fdCount) | 使用poll方式,请求fd代持 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
fds: fd代持数组指针
fdCount 数组长度 + + **表6** 服务控制接口介绍 + + | 函数名 | 函数解释 |参数解释 | + | :---------- | :---------- |:--------| + | int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc) | 配置服务参数 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
action: 服务行为("start", "stop", "restart")
extArgv: 参数数组
extArgc: 参数个数 | + | int ServiceControl(const char *serviceName, int action) | 控制服务行为 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
action: 服务行为("start", "stop", "restart") | + | int ServiceWaitForStatus(const char *serviceName, ServiceStatus status, int waitTimeout) | 等待服务状态 | 返回值:成功返回0, 失败返回-1。
参数:
serviceName: 服务名
status: 返回服务状态
超时时间 | + | int ServiceSetReady(const char *serviceName) | 设置服务准备 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名 | + | int StartServiceByTimer(const char *serviceName, uint64_t timeout) | 定时启动服务 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名
timeout: 超时时间 | + | int StopServiceTimer(const char *serviceName) | 停止服务计时器 | 返回值:成功返回0,失败返回-1
参数:
serviceName: 服务名 | + + **表7** begetctl 命令说明 + + | 命令 | 命令格式和示例 | 说明 | + | :---------- | :---------- |:--------| + | init group test [stage] | init group test | statge参见ServiceStatus | + | param ls [-r] [name] | 显示系统参数,例如:
查看usb系统参数:begetctl param ls persist.sys.usb | 无 | + | param get [name] | 获取系统参数信息,例如:
begetctl param get 或 param get | 无 | + | param set name value| 设置系统参数,例如:
begetctl param set ohos.servicectrl.display 1 或 param set ohos.servicectrl.display 1| 无 | + | param wait name [value] [timeout] | 等待系统参数,例如:
begetctl param wait persist.sys.usb.config hdc 或 param wait persist.sys.usb.config hdc | timeout默认值:30 | + | param dump [verbose] | dump 系统参数信息,例如:
begetctl param dump 或 param dump| 无 | + | param shell [name] | 进入Parameter shell,例如:
begetctl param shell 或 param shell| 无 | + | timer_stop servicename | 停止服务计时器,例如:
begetctl timer_stop appspawn | servicename长度不超过96字符 | + | timer_start servicename timeout | 启动服务计时器,例如:
begetctl timer_start appspawn | servicename长度不超过96;timeout默认值:10 | + | start_service servicename | 启动服务,例如:
begetctl start_service appspawn 或 start_service appspawn | 无 | + | stop_service servicename | 停止服务,例如:
begetctl stop_service appspawn 或 stop_service appspawn | 无 | + | service_control start servicename | 启动服务,例如:
begetctl service_control start appspawn 或 service_control start appspawn | 无 | + | service_control stop servicename | 停止服务,例如:
begetctl service_control stop appspawn 或 service_control stop appspawn | 无 | + | misc_daemon --write_logo xxx.rgb | 写入开机logo,例如:
begetctl misc_daemon --write_logo logo.rgb 或 misc_daemon --write_logo logo.rgb| rgb文件最大不超过1024*2038,仅支持hi3516dv300 | + | reboot | 重启系统,例如:
begetctl reboot 或 reboot|无 | + | reboot shutdown | 关闭系统,例如:
begetctl reboot shutdown 或 reboot shutdown |无 | + | reboot suspend | 暂停系统,例如:
begetctl reboot suspend 或 reboot suspend | 无 | + | reboot updater | 重新启动并进入updater,例如:
begetctl reboot updater 或 reboot updater | 无 | + | reboot updater[:options] | 重新启动并进入updater,例如:
begetctl reboot updater 或 reboot updater | 无 | + | reboot flashd | 重新启动并进入flashd,例如:
begetctl reboot flashd 或 reboot flashd | 无 | + | reboot flashd[:options] | 重新启动并进入flashd,例如:
begetctl reboot flashd 或 reboot flashd | 无 | + | reboot charing | 重新启动并进入charing,例如:
begetctl reboot charing 或 reboot charing| 无 | + | reboot loader | 重新启动并进入烧写模式,例如:
begetctl reboot loader 或 reboot loader | 无 | + | bootchart stop | 停止图形分析,例如:
begetctl bootchart stop | 仅支持rk3568| + | bootchart start | 开始图形分析,例如:
begetctl bootchart start | 无 | + | bootchart disable | 图形分析不使能,例如:
begetctl bootchart disable | 无 | + | bootchart enable | 图形分析使能,例如:
begetctl bootchart enable | 无 | + +## 开发实例 + +init启动引导程序,此处以要新增一个名为MySystemApp的系统服务为例进行说明,使用如下配置: + + ``` { "jobs" : [{ "name" : "pre-init", "cmds" : [ "mkdir /storage/MyDir", // MySystemApp服务启动之前需要先创建文件夹,因此放在 “pre-init”中进行 - "chmod 0600 /storage/MyDir", // MySystemApp服务要求该文件加只有本用户和属组才可读写,因此需要修改权限 + "chmod 0600 /storage/MyDir", // MySystemApp服务要求该文件夹只有本用户和属组才可读写,因此需要修改权限 "chown 10 10 /storage/MyDir" ] }, { @@ -379,6 +476,9 @@ "caps" : [], // MySystemApp系统服务不需要任何capability权限(即MySystemApp系统服务不涉及与capability相关的操作) "start-mode" : "condition", "critical": [1, 2, 10], //MySystemApp系统服务的critical配置,需传入三个参数, 分别为使能:1, 执行次数:2, 执行时间:10 + "cpucore" : [0, 1], // 设备为双核, 且都绑定cpu + "apl" : "system_core", + "d-caps" : ["OHOS_DMS"], "jobs" : { "on-boot" : "boot", "on-start" : "services:MySystemApp_start", @@ -388,48 +488,64 @@ } ] } -``` + ``` 完成配置后,编译出包烧写单板: -1. 启动后使用task -a(liteos-a版本)或ps命令(linux版本)查看是否MySystemApp系统服务进程已启动。 -2. 使用kill命令将上述新增的MySystemApp进程杀死,观察该进程是否会被重新拉起(此处应该为重新拉起)。 -3. 使用kill命令将上述新增的MySystemApp进程杀死,观察是否会导致单板重启(此处应该为不重启)。 +1. 启动后使用task -a(liteos-a版本)或ps命令(linux版本)查看是否MySystemApp系统服务进程已启动。 + +2. 使用kill命令将上述新增的MySystemApp进程杀死,观察该进程是否会被重新拉起(此处应该为重新拉起)。 + +3. 使用kill命令将上述新增的MySystemApp进程杀死,观察是否会导致单板重启(此处应该为不重启)。 + + +## 常见问题 + + +### 服务不存在 + +**现象描述** + +内核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)"。 -   **现象描述**
-    内核Log打印 "Failed get servName"。 +**原因分析** -   **原因分析**
-     kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务不存在。 +kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是其他服务代持fd。 -   **解决方法**
-     1. 确认服务是否在cfg中正确配置。
-     2. 服务的cfg文件是否正常加载。
-     3. cfg文件格式是否正确。 +**解决方法** -### 请求其他服务代持fd,init有报错 +只支持代持本服务的fd, 不允许让其他服务代持fd。 -  **现象描述** -     内核Log打印 "Service \' xxx \'(pid = xxx) is not valid or request with unexpected process(pid = xxx)"。 +### 服务没有配置ondemand 选项 -   **原因分析**
-     kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是其他服务代持fd。 +**现象描述** -   **解决方法**
-     只支持代持本服务的fd, 不允许让其他服务代持fd。 +内核Log打印 "service : %s had started already"。 -### 服务没有配置ondemand 选项 +**原因分析** -   **现象描述**
-     内核Log打印 "service : %s had started already"。 +kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务没有配置ondemand。 -   **原因分析**
-     kernel log 的输出,都是由init 打印。在init 中查找对应的代码位置。发现是服务没有配置ondemand。 +**解决方法** -   **解决方法**
-     服务对应的.cfg文件正确配置如: "ondemand" : true。 \ No newline at end of file +服务对应的.cfg文件正确配置如: "ondemand" : true。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md index 6c76bc9a0644905ddabe6635665062e4c978e868..0b9030838e3ef2da1f862ca828b32fcf28e2538b 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md @@ -3,9 +3,7 @@ ## 概述 -HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。 - -本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。 +HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。本章节内容适用于标准系统。 ## 开发指导 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md index 9e4a91ff9294a4dfd58117a1e976a0c7c39074ea..c546225c98bce2cb6cdde07786a0595abe7cdb54 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md @@ -6,9 +6,7 @@ ### 功能简介 -HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。 - -本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。 +HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。本章节内容适用于标准系统。 ### 源码目录说明 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md index 4d85164703418f35a1f5306d61130454cc079e3f..c43e87a0da07c188fc17454b7ec780bf6334aa80 100755 --- a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md @@ -6,11 +6,19 @@ 提供以下功能: -- HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。 +- HiLog流水日志,轻量系统类设备(参考内存≥128KB)、小型系统类设备(参考内存≥1MB)、标准系统类设备(参考内存≥128MB)适用。 -- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。 -- HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。 -- HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。 +- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MB)适用。 + +- HiCollie卡死故障检测,标准系统类设备(参考内存≥128MB)适用。 + +- HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MB)适用。 + +- HiChecker缺陷扫描,标准系统类设备(参考内存≥128MB)适用。 + +- HiDumper信息导出,标准系统类设备(参考内存≥128MB)适用。 + +- Faultlogger崩溃故障检测,标准系统类设备(参考内存≥128MB)适用。 ## 基本概念 diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md b/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md index 6d41ebec6e173bdeaab6167d5d9fd4049e8091f1..ddca6dd9964d3b07dab19b4e7d6171e08e4d0b1a 100644 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md +++ b/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md @@ -1,7 +1,7 @@ # USB服务子系使用实例 -``` +```cpp #include #include #include diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md index c5cd8179243fdd10ff5b7b6b90c1271e6b4bbe46..1692e51715a588cbafc20259d30640758daee834 100644 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md @@ -8,46 +8,46 @@ 1. 获取usb service实例 -``` +```cpp static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); ``` 2. 获取usb设备列表 -``` +```cpp std::vector deviceList; int32_t ret = g_usbClient.GetDevices(deviceList); ``` 3. 申请设备权限 -``` +```cpp int32_t ret = g_usbClient.RequestRight(device.GetName()); ``` 4. 打开设备 -``` +```cpp USBDevicePipe pip; int32_t et = g_usbClient.OpenDevice(device, pip); ``` 5. 配置设备接口 -``` +```cpp ret = g_usbClient.ClaimInterface(pip, interface, true); interface为deviceList中device的interface。 ``` 6. 数据传输 -``` +```cpp srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); ``` pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长. 7. 关闭设备 -``` +```cpp ret = g_usbClient.Close(pip); ``` diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index cde7cc29ee90487e0603f3a2d1d89a0f57e0d16a..f844365339643983c8939bc91738421fc1fb0acf 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -398,12 +398,12 @@ - [普通组件开发指导](subsystems/subsys-graphics-common-guide.md) - [动画开发指导](subsystems/subsys-graphics-animation-guide.md) - 媒体 - - [相机](subsystems/subsys-multimedia-camera.md) + - 相机 - [相机开发概述](subsystems/subsys-multimedia-camera-overview.md) - [拍照开发指导](subsystems/subsys-multimedia-camera-photo-guide.md) - [录像开发指导](subsystems/subsys-multimedia-camera-record-guide.md) - [预览开发指导](subsystems/subsys-multimedia-camera-preview-guide.md) - - [音视频](subsystems/subsys-multimedia-video.md) + - 音视频 - [音视频开发概述](subsystems/subsys-multimedia-video-overview.md) - [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md) - [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md) @@ -427,10 +427,10 @@ - [唤醒词识别插件的开发示例](subsystems/subsys-aiframework-demo-plugin.md) - [唤醒词识别配置文件的开发示例](subsystems/subsys-aiframework-demo-conf.md) - 数据管理 - - [关系型数据库](subsystems/subsys-data-relational-database.md) + - 关系型数据库 - [关系型数据库概述](subsystems/subsys-data-relational-database-overview.md) - [关系型数据库开发指导](subsystems/subsys-data-relational-database-guide.md) - - [轻量级数据存储](subsystems/subsys-data-storage.md) + - 轻量级数据存储 - [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md) - [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md) - Sensor服务