未验证 提交 0dafb97d 编写于 作者: O openharmony_ci 提交者: Gitee

!23260 [翻译完成】#I7VT1Z

Merge pull request !23260 from Annie_wang/PR22913
...@@ -79,10 +79,10 @@ Activates an OS account. This API uses an asynchronous callback to return the re ...@@ -79,10 +79,10 @@ Activates an OS account. This API uses an asynchronous callback to return the re
**Example**: Activate OS account 100. **Example**: Activate OS account 100.
```js ```js
let accountManager = account_osAccount.getAccountManager(); import { BusinessError } from '@ohos.base';
let localId = 100; let localId: number = 100;
try { try {
accountManager.activateOsAccount(localId, (err)=>{ accountManager.activateOsAccount(localId, (err: BusinessError)=>{
if (err) { if (err) {
console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`); console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
...@@ -130,12 +130,13 @@ Activates an OS account. This API uses a promise to return the result. ...@@ -130,12 +130,13 @@ Activates an OS account. This API uses a promise to return the result.
**Example**: Activate OS account 100. **Example**: Activate OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.activateOsAccount(localId).then(() => { accountManager.activateOsAccount(localId).then(() => {
console.log('activateOsAccount successfully'); console.log('activateOsAccount successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('activateOsAccount failed, err:' + JSON.stringify(err)); console.log('activateOsAccount failed, err:' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -166,9 +167,10 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous ...@@ -166,9 +167,10 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkMultiOsAccountEnabled((err, isEnabled) => { accountManager.checkMultiOsAccountEnabled((err: BusinessError, isEnabled: boolean) => {
if (err) { if (err) {
console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`); console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
...@@ -203,11 +205,12 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re ...@@ -203,11 +205,12 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
try { try {
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.checkMultiOsAccountEnabled().then((isEnabled) => { accountManager.checkMultiOsAccountEnabled().then((isEnabled: boolean) => {
console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled); console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`); console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
...@@ -243,10 +246,11 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac ...@@ -243,10 +246,11 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.checkOsAccountActivated(localId, (err, isActivated) => { accountManager.checkOsAccountActivated(localId, (err: BusinessError, isActivated: boolean) => {
if (err) { if (err) {
console.log('checkOsAccountActivated failed, error:' + JSON.stringify(err)); console.log('checkOsAccountActivated failed, error:' + JSON.stringify(err));
} else { } else {
...@@ -291,12 +295,13 @@ Checks whether an OS account is activated. This API uses a promise to return the ...@@ -291,12 +295,13 @@ Checks whether an OS account is activated. This API uses a promise to return the
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.checkOsAccountActivated(localId).then((isActivated) => { accountManager.checkOsAccountActivated(localId).then((isActivated: boolean) => {
console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated); console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -333,11 +338,12 @@ Checks whether the specified constraint is enabled for an OS account. This API u ...@@ -333,11 +338,12 @@ Checks whether the specified constraint is enabled for an OS account. This API u
**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 ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let constraint = 'constraint.wifi'; let constraint: string = 'constraint.wifi';
try { try {
accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err, isEnabled)=>{ accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err: BusinessError, isEnabled: boolean)=>{
if (err) { if (err) {
console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -383,13 +389,14 @@ Checks whether the specified constraint is enabled for an OS account. This API u ...@@ -383,13 +389,14 @@ Checks whether the specified constraint is enabled for an OS account. This API u
**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 ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let constraint = 'constraint.wifi'; let constraint: string = 'constraint.wifi';
try { try {
accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled) => { accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => {
console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled); console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -420,9 +427,10 @@ Checks whether this OS account is a test account. This API uses an asynchronous ...@@ -420,9 +427,10 @@ Checks whether this OS account is a test account. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkOsAccountTestable((err, isTestable) => { accountManager.checkOsAccountTestable((err: BusinessError, isTestable: boolean) => {
if (err) { if (err) {
console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -457,11 +465,12 @@ Checks whether this OS account is a test account. This API uses a promise to ret ...@@ -457,11 +465,12 @@ Checks whether this OS account is a test account. This API uses a promise to ret
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkOsAccountTestable().then((isTestable) => { accountManager.checkOsAccountTestable().then((isTestable: boolean) => {
console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable); console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -492,9 +501,10 @@ Checks whether this OS account has been verified. This API uses an asynchronous ...@@ -492,9 +501,10 @@ Checks whether this OS account has been verified. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkOsAccountVerified((err, isVerified) => { accountManager.checkOsAccountVerified((err: BusinessError, isVerified: boolean) => {
if (err) { if (err) {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -529,11 +539,12 @@ Checks whether this OS account has been verified. This API uses a promise to ret ...@@ -529,11 +539,12 @@ Checks whether this OS account has been verified. This API uses a promise to ret
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkOsAccountVerified().then((isVerified) => { accountManager.checkOsAccountVerified().then((isVerified: boolean) => {
console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -569,10 +580,11 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca ...@@ -569,10 +580,11 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.checkOsAccountVerified(localId, (err, isVerified) => { accountManager.checkOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
if (err) { if (err) {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -617,12 +629,13 @@ Checks whether an OS account has been verified. This API uses a promise to retur ...@@ -617,12 +629,13 @@ Checks whether an OS account has been verified. This API uses a promise to retur
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.checkOsAccountVerified(localId).then((isVerified) => { accountManager.checkOsAccountVerified(localId).then((isVerified: boolean) => {
console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -653,11 +666,12 @@ Checks whether this OS account has been verified. This API uses a promise to ret ...@@ -653,11 +666,12 @@ Checks whether this OS account has been verified. This API uses a promise to ret
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.checkOsAccountVerified().then((isVerified) => { accountManager.checkOsAccountVerified().then((isVerified: boolean) => {
console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -696,11 +710,13 @@ Deletes an OS account. This API uses an asynchronous callback to return the resu ...@@ -696,11 +710,13 @@ Deletes an OS account. This API uses an asynchronous callback to return the resu
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let accountName = 'testAccountName'; let accountName: string = 'testAccountName';
try { try {
accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL,
accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{ (err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo) => {
accountManager.removeOsAccount(osAccountInfo.localId, (err: BusinessError)=>{
if (err) { if (err) {
console.log('removeOsAccount failed, error: ' + JSON.stringify(err)); console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -749,13 +765,15 @@ Deletes an OS account. This API uses a promise to return the result. ...@@ -749,13 +765,15 @@ Deletes an OS account. This API uses a promise to return the result.
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let accountName = 'testAccountName'; let accountName: string = 'testAccountName';
try { try {
accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL,
(err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
accountManager.removeOsAccount(osAccountInfo.localId).then(() => { accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
console.log('removeOsAccount successfully'); console.log('removeOsAccount successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('removeOsAccount failed, error: ' + JSON.stringify(err)); console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
}); });
}); });
...@@ -797,11 +815,12 @@ Sets or removes constraints for an OS account. This API uses an asynchronous cal ...@@ -797,11 +815,12 @@ Sets or removes constraints for an OS account. This API uses an asynchronous cal
**Example**: Disable Wi-Fi for OS account 100. **Example**: Disable Wi-Fi for OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let constraint = 'constraint.wifi'; let constraint: string = 'constraint.wifi';
try { try {
accountManager.setOsAccountConstraints(localId, [constraint], true, (err) => { accountManager.setOsAccountConstraints(localId, [constraint], true, (err: BusinessError) => {
if (err) { if (err) {
console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err)); console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -851,12 +870,13 @@ Sets or removes constraints for an OS account. This API uses a promise to return ...@@ -851,12 +870,13 @@ Sets or removes constraints for an OS account. This API uses a promise to return
**Example**: Remove the constraint on the use of Wi-Fi for OS account 100. **Example**: Remove the constraint on the use of Wi-Fi for OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => { accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
console.log('setOsAccountConstraints succsuccessfully'); console.log('setOsAccountConstraints succsuccessfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err)); console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -896,11 +916,12 @@ Sets a name for an OS account. This API uses an asynchronous callback to return ...@@ -896,11 +916,12 @@ Sets a name for an OS account. This API uses an asynchronous callback to return
**Example**: Set the name of OS account 100 to **demoName**. **Example**: Set the name of OS account 100 to **demoName**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let name = 'demoName'; let name: string = 'demoName';
try { try {
accountManager.setOsAccountName(localId, name, (err) => { accountManager.setOsAccountName(localId, name, (err: BusinessError) => {
if (err) { if (err) {
console.log('setOsAccountName failed, error: ' + JSON.stringify(err)); console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -949,13 +970,14 @@ Sets a name for an OS account. This API uses a promise to return the result. ...@@ -949,13 +970,14 @@ Sets a name for an OS account. This API uses a promise to return the result.
**Example**: Set the name of OS account 100 to **demoName**. **Example**: Set the name of OS account 100 to **demoName**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let name = 'testName'; let name: string = 'testName';
try { try {
accountManager.setOsAccountName(localId, name).then(() => { accountManager.setOsAccountName(localId, name).then(() => {
console.log('setOsAccountName successfully'); console.log('setOsAccountName successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setOsAccountName failed, error: ' + JSON.stringify(err)); console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -988,9 +1010,10 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac ...@@ -988,9 +1010,10 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountCount((err, count) => { accountManager.getOsAccountCount((err: BusinessError, count: number) => {
if (err) { if (err) {
console.log('getOsAccountCount failed, error: ' + JSON.stringify(err)); console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -1027,11 +1050,12 @@ Obtains the number of OS accounts created. This API uses a promise to return the ...@@ -1027,11 +1050,12 @@ Obtains the number of OS accounts created. This API uses a promise to return the
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountCount().then((count) => { accountManager.getOsAccountCount().then((count: number) => {
console.log('getOsAccountCount successfully, count: ' + count); console.log('getOsAccountCount successfully, count: ' + count);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountCount failed, error: ' + JSON.stringify(err)); console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
}); });
} catch(err) { } catch(err) {
...@@ -1062,9 +1086,10 @@ Obtains the ID of the OS account to which the current process belongs. This API ...@@ -1062,9 +1086,10 @@ Obtains the ID of the OS account to which the current process belongs. This API
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountLocalId((err, localId) => { accountManager.getOsAccountLocalId((err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -1099,11 +1124,12 @@ Obtains the ID of the OS account to which the current process belongs. This API ...@@ -1099,11 +1124,12 @@ Obtains the ID of the OS account to which the current process belongs. This API
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountLocalId().then((localId) => { accountManager.getOsAccountLocalId().then((localId: number) => {
console.log('getOsAccountLocalId successfully, localId: ' + localId); console.log('getOsAccountLocalId successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -1136,10 +1162,11 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou ...@@ -1136,10 +1162,11 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid: number = 12345678;
try { try {
accountManager.getOsAccountLocalIdForUid(uid, (err, localId) => { accountManager.getOsAccountLocalIdForUid(uid, (err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
} }
...@@ -1180,12 +1207,13 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r ...@@ -1180,12 +1207,13 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid: number = 12345678;
try { try {
accountManager.getOsAccountLocalIdForUid(uid).then((localId) => { accountManager.getOsAccountLocalIdForUid(uid).then((localId: number) => {
console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId); console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -1220,10 +1248,11 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -1220,10 +1248,11 @@ Obtains the OS account ID based on the domain account information. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountLocalIdForDomain(domainInfo, (err, localId) => { accountManager.getOsAccountLocalIdForDomain(domainInfo, (err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -1267,12 +1296,13 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -1267,12 +1296,13 @@ Obtains the OS account ID based on the domain account information. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try { try {
accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId) => { accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId: number) => {
console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId); console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -1305,9 +1335,10 @@ Obtains the maximum number of OS accounts that can be created. This API uses an ...@@ -1305,9 +1335,10 @@ Obtains the maximum number of OS accounts that can be created. This API uses an
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryMaxOsAccountNumber((err, maxCnt) => { accountManager.queryMaxOsAccountNumber((err: BusinessError, maxCnt: number) => {
if (err) { if (err) {
console.log('queryMaxOsAccountNumber failed, error:' + JSON.stringify(err)); console.log('queryMaxOsAccountNumber failed, error:' + JSON.stringify(err));
} else { } else {
...@@ -1344,11 +1375,12 @@ Obtains the maximum number of OS accounts that can be created. This API uses a p ...@@ -1344,11 +1375,12 @@ Obtains the maximum number of OS accounts that can be created. This API uses a p
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryMaxOsAccountNumber().then((maxCnt) => { accountManager.queryMaxOsAccountNumber().then((maxCnt: number) => {
console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt); console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err)); console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -1384,10 +1416,11 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous ...@@ -1384,10 +1416,11 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous
**Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getOsAccountConstraints(localId, (err, constraints) => { accountManager.getOsAccountConstraints(localId, (err: BusinessError, constraints: string[]) => {
if (err) { if (err) {
console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err)); console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err));
} else { } else {
...@@ -1432,12 +1465,13 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re ...@@ -1432,12 +1465,13 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re
**Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getOsAccountConstraints(localId).then((constraints) => { accountManager.getOsAccountConstraints(localId).then((constraints: string[]) => {
console.log('getOsAccountConstraints, constraints: ' + constraints); console.log('getOsAccountConstraints, constraints: ' + constraints);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountConstraints err: ' + JSON.stringify(err)); console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1472,9 +1506,10 @@ Obtains information about all the OS accounts created. This API uses an asynchro ...@@ -1472,9 +1506,10 @@ Obtains information about all the OS accounts created. This API uses an asynchro
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: account_osAccount.OsAccountInfo[])=>{
console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err));
console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
}); });
...@@ -1510,11 +1545,12 @@ Obtains information about all the OS accounts created. This API uses a promise t ...@@ -1510,11 +1545,12 @@ Obtains information about all the OS accounts created. This API uses a promise t
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryAllCreatedOsAccounts().then((accountArr) => { accountManager.queryAllCreatedOsAccounts().then((accountArr: account_osAccount.OsAccountInfo[]) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err)); console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1545,9 +1581,10 @@ Obtains information about all activated OS accounts. This API uses an asynchrono ...@@ -1545,9 +1581,10 @@ Obtains information about all activated OS accounts. This API uses an asynchrono
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getActivatedOsAccountLocalIds((err, idArray)=>{ accountManager.getActivatedOsAccountLocalIds((err: BusinessError, idArray: number[])=>{
console.log('getActivatedOsAccountLocalIds err:' + JSON.stringify(err)); console.log('getActivatedOsAccountLocalIds err:' + JSON.stringify(err));
console.log('getActivatedOsAccountLocalIds idArray length:' + idArray.length); console.log('getActivatedOsAccountLocalIds idArray length:' + idArray.length);
for(let i=0;i<idArray.length;i++) { for(let i=0;i<idArray.length;i++) {
...@@ -1582,11 +1619,12 @@ Obtains information about all activated OS accounts. This API uses a promise to ...@@ -1582,11 +1619,12 @@ Obtains information about all activated OS accounts. This API uses a promise to
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getActivatedOsAccountLocalIds().then((idArray) => { accountManager.getActivatedOsAccountLocalIds().then((idArray: number[]) => {
console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray); console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err)); console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1627,9 +1665,11 @@ Creates an OS account. This API uses an asynchronous callback to return the resu ...@@ -1627,9 +1665,11 @@ Creates an OS account. This API uses an asynchronous callback to return the resu
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL,
(err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
console.log('createOsAccount err:' + JSON.stringify(err)); console.log('createOsAccount err:' + JSON.stringify(err));
console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
}); });
...@@ -1676,11 +1716,13 @@ Creates an OS account. This API uses a promise to return the result. ...@@ -1676,11 +1716,13 @@ Creates an OS account. This API uses a promise to return the result.
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then(
(accountInfo: account_osAccount.OsAccountInfo) => {
console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('createOsAccount err: ' + JSON.stringify(err)); console.log('createOsAccount err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1721,10 +1763,12 @@ Creates an OS account and associates it with the specified domain account. This ...@@ -1721,10 +1763,12 @@ Creates an OS account and associates it with the specified domain account. This
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try { try {
accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo,
(err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
console.log('createOsAccountForDomain err:' + JSON.stringify(err)); console.log('createOsAccountForDomain err:' + JSON.stringify(err));
console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
}); });
...@@ -1771,12 +1815,14 @@ Creates an OS account and associates it with the specified domain account. This ...@@ -1771,12 +1815,14 @@ Creates an OS account and associates it with the specified domain account. This
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try { try {
accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then(
(accountInfo: account_osAccount.OsAccountInfo) => {
console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo)); console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('createOsAccountForDomain err: ' + JSON.stringify(err)); console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1809,9 +1855,10 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -1809,9 +1855,10 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getCurrentOsAccount((err, curAccountInfo)=>{ accountManager.getCurrentOsAccount((err: BusinessError, curAccountInfo: account_osAccount.OsAccountInfo)=>{
console.log('getCurrentOsAccount err:' + JSON.stringify(err)); console.log('getCurrentOsAccount err:' + JSON.stringify(err));
console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
}); });
...@@ -1845,11 +1892,12 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -1845,11 +1892,12 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getCurrentOsAccount().then((accountInfo) => { accountManager.getCurrentOsAccount().then((accountInfo: account_osAccount.OsAccountInfo) => {
console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getCurrentOsAccount err: ' + JSON.stringify(err)); console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1887,10 +1935,11 @@ Obtains information about the OS account of the given ID. This API uses an async ...@@ -1887,10 +1935,11 @@ Obtains information about the OS account of the given ID. This API uses an async
**Example**: Query information about OS account 100. **Example**: Query information about OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: account_osAccount.OsAccountInfo)=>{
console.log('queryOsAccountById err:' + JSON.stringify(err)); console.log('queryOsAccountById err:' + JSON.stringify(err));
console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
}); });
...@@ -1934,12 +1983,13 @@ Obtains information about the OS account of the given ID. This API uses a promis ...@@ -1934,12 +1983,13 @@ Obtains information about the OS account of the given ID. This API uses a promis
**Example**: Query information about OS account 100. **Example**: Query information about OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.queryOsAccountById(localId).then((accountInfo) => { accountManager.queryOsAccountById(localId).then((accountInfo: account_osAccount.OsAccountInfo) => {
console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo)); console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryOsAccountById err: ' + JSON.stringify(err)); console.log('queryOsAccountById err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -1970,9 +2020,10 @@ Obtains the type of the account to which the current process belongs. This API u ...@@ -1970,9 +2020,10 @@ Obtains the type of the account to which the current process belongs. This API u
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountType((err, accountType) => { accountManager.getOsAccountType((err: BusinessError, accountType: account_osAccount.OsAccountType) => {
console.log('getOsAccountType err: ' + JSON.stringify(err)); console.log('getOsAccountType err: ' + JSON.stringify(err));
console.log('getOsAccountType accountType: ' + accountType); console.log('getOsAccountType accountType: ' + accountType);
}); });
...@@ -2004,11 +2055,12 @@ Obtains the type of the account to which the current process belongs. This API u ...@@ -2004,11 +2055,12 @@ Obtains the type of the account to which the current process belongs. This API u
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountType().then((accountType) => { accountManager.getOsAccountType().then((accountType: account_osAccount.OsAccountType) => {
console.log('getOsAccountType, accountType: ' + accountType); console.log('getOsAccountType, accountType: ' + accountType);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountType err: ' + JSON.stringify(err)); console.log('getOsAccountType err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2041,9 +2093,10 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous ...@@ -2041,9 +2093,10 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryDistributedVirtualDeviceId((err, virtualID) => { accountManager.queryDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID); console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID);
}); });
...@@ -2077,11 +2130,12 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re ...@@ -2077,11 +2130,12 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.queryDistributedVirtualDeviceId().then((virtualID) => { accountManager.queryDistributedVirtualDeviceId().then((virtualID: string) => {
console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID); console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2119,10 +2173,11 @@ Obtains the profile photo of an OS account. This API uses an asynchronous callba ...@@ -2119,10 +2173,11 @@ Obtains the profile photo of an OS account. This API uses an asynchronous callba
**Example**: Obtain the profile photo of OS account 100. **Example**: Obtain the profile photo of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ accountManager.getOsAccountProfilePhoto(localId, (err: BusinessError, photo: string)=>{
console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err)); console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err));
console.log('get photo:' + photo + ' by localId: ' + localId); console.log('get photo:' + photo + ' by localId: ' + localId);
}); });
...@@ -2166,12 +2221,13 @@ Obtains the profile photo of an OS account. This API uses a promise to return th ...@@ -2166,12 +2221,13 @@ Obtains the profile photo of an OS account. This API uses a promise to return th
**Example**: Obtain the profile photo of OS account 100. **Example**: Obtain the profile photo of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getOsAccountProfilePhoto(localId).then((photo) => { accountManager.getOsAccountProfilePhoto(localId).then((photo: string) => {
console.log('getOsAccountProfilePhoto: ' + photo); console.log('getOsAccountProfilePhoto: ' + photo);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err)); console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2211,14 +2267,15 @@ Sets a profile photo for an OS account. This API uses an asynchronous callback t ...@@ -2211,14 +2267,15 @@ Sets a profile photo for an OS account. This API uses an asynchronous callback t
**Example**: Set a profile photo for OS account 100. **Example**: Set a profile photo for OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
'+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
try { try {
accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ accountManager.setOsAccountProfilePhoto(localId, photo, (err: BusinessError)=>{
console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2263,16 +2320,17 @@ Sets a profile photo for an OS account. This API uses a promise to return the re ...@@ -2263,16 +2320,17 @@ Sets a profile photo for an OS account. This API uses a promise to return the re
**Example**: Set a profile photo for OS account 100. **Example**: Set a profile photo for OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
'+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
try { try {
accountManager.setOsAccountProfilePhoto(localId, photo).then(() => { accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
console.log('setOsAccountProfilePhoto success'); console.log('setOsAccountProfilePhoto success');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err)); console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2306,10 +2364,11 @@ Obtains the OS account ID based on the serial number (SN). This API uses an asyn ...@@ -2306,10 +2364,11 @@ Obtains the OS account ID based on the serial number (SN). This API uses an asyn
**Example**: Obtain the ID of the OS account whose SN is 12345. **Example**: Obtain the ID of the OS account whose SN is 12345.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let serialNumber = 12345; let serialNumber: number = 12345;
try { try {
accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err, localId)=>{ accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
console.log('ger localId err:' + JSON.stringify(err)); console.log('ger localId err:' + JSON.stringify(err));
console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
}); });
...@@ -2349,12 +2408,13 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the ...@@ -2349,12 +2408,13 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the
**Example**: Obtain the ID of the OS account whose SN is 12345. **Example**: Obtain the ID of the OS account whose SN is 12345.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let serialNumber = 12345; let serialNumber: number = 12345;
try { try {
accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId) => { accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId: number) => {
console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId); console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2388,10 +2448,11 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch ...@@ -2388,10 +2448,11 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch
**Example**: Obtain the SN of the OS account 100. **Example**: Obtain the SN of the OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getSerialNumberForOsAccountLocalId(localId, (err, serialNumber)=>{ accountManager.getSerialNumberForOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
console.log('ger serialNumber err:' + JSON.stringify(err)); console.log('ger serialNumber err:' + JSON.stringify(err));
console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
}); });
...@@ -2431,12 +2492,13 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise ...@@ -2431,12 +2492,13 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise
**Example**: Obtain the SN of the OS account 100. **Example**: Obtain the SN of the OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
try { try {
accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber) => { accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber: number) => {
console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber); console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err)); console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2475,7 +2537,7 @@ Subscribes to the OS account activation states, including the states of the acco ...@@ -2475,7 +2537,7 @@ Subscribes to the OS account activation states, including the states of the acco
```js ```js
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
function onCallback(receiveLocalId){ function onCallback(receiveLocalId: number){
console.log('receive localId:' + receiveLocalId); console.log('receive localId:' + receiveLocalId);
} }
try { try {
...@@ -2553,10 +2615,11 @@ Obtains the bundle ID based on the UID. This API uses an asynchronous callback t ...@@ -2553,10 +2615,11 @@ Obtains the bundle ID based on the UID. This API uses an asynchronous callback t
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let testUid = 1000000; let testUid: number = 1000000;
try { try {
accountManager.getBundleIdForUid(testUid, (err, bundleId) => { accountManager.getBundleIdForUid(testUid, (err: BusinessError, bundleId: number) => {
console.info('getBundleIdForUid errInfo:' + JSON.stringify(err)); console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId)); console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId));
}); });
...@@ -2596,12 +2659,13 @@ Obtains the bundle ID based on the UID. This API uses a promise to return the re ...@@ -2596,12 +2659,13 @@ Obtains the bundle ID based on the UID. This API uses a promise to return the re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let testUid = 1000000; let testUid: number = 1000000;
try { try {
accountManager.getBundleIdForUid(testUid).then((result) => { accountManager.getBundleIdForUid(testUid).then((result: number) => {
console.info('getBundleIdForUid bundleId:' + JSON.stringify(result)); console.info('getBundleIdForUid bundleId:' + JSON.stringify(result));
}).catch((err)=>{ }).catch((err: BusinessError) => {
console.info('getBundleIdForUid errInfo:' + JSON.stringify(err)); console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2636,9 +2700,10 @@ Checks whether the current process belongs to the main OS account. This API uses ...@@ -2636,9 +2700,10 @@ Checks whether the current process belongs to the main OS account. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.isMainOsAccount((err,result)=>{ accountManager.isMainOsAccount((err: BusinessError,result: boolean)=>{
console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
console.info('isMainOsAccount result:' + JSON.stringify(result)); console.info('isMainOsAccount result:' + JSON.stringify(result));
}); });
...@@ -2673,11 +2738,12 @@ Checks whether the current process belongs to the main OS account. This API uses ...@@ -2673,11 +2738,12 @@ Checks whether the current process belongs to the main OS account. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.isMainOsAccount().then((result) => { accountManager.isMainOsAccount().then((result: boolean) => {
console.info('isMainOsAccount result:' + JSON.stringify(result)); console.info('isMainOsAccount result:' + JSON.stringify(result));
}).catch((err)=>{ }).catch((err: BusinessError) => {
console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2715,9 +2781,11 @@ Obtains the constraint source information of an OS account. This API uses an asy ...@@ -2715,9 +2781,11 @@ Obtains the constraint source information of an OS account. This API uses an asy
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{ accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi',
(err: BusinessError,sourceTypeInfos: account_osAccount.ConstraintSourceTypeInfo[])=>{
console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err)); console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(sourceTypeInfos)); console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
}); });
...@@ -2762,11 +2830,13 @@ Obtains the constraint source information of an OS account. This API uses a prom ...@@ -2762,11 +2830,13 @@ Obtains the constraint source information of an OS account. This API uses a prom
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
try { try {
accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => { accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi').then(
(result: account_osAccount.ConstraintSourceTypeInfo[]) => {
console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(result)); console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(result));
}).catch((err)=>{ }).catch((err: BusinessError) => {
console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err)); console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -2795,8 +2865,9 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous ...@@ -2795,8 +2865,9 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => { accountManager.isMultiOsAccountEnable((err: BusinessError, isEnabled: boolean) => {
if (err) { if (err) {
console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err)); console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -2826,10 +2897,11 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re ...@@ -2826,10 +2897,11 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled) => { accountManager.isMultiOsAccountEnable().then((isEnabled: boolean) => {
console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled); console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err)); console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2859,9 +2931,10 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac ...@@ -2859,9 +2931,10 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.isOsAccountActived(localId, (err, isActived) => { accountManager.isOsAccountActived(localId, (err: BusinessError, isActived: boolean) => {
if (err) { if (err) {
console.log('isOsAccountActived failed, err:' + JSON.stringify(err)); console.log('isOsAccountActived failed, err:' + JSON.stringify(err));
} else { } else {
...@@ -2899,11 +2972,12 @@ Checks whether an OS account is activated. This API uses a promise to return the ...@@ -2899,11 +2972,12 @@ Checks whether an OS account is activated. This API uses a promise to return the
**Example**: Check whether OS account 100 is activated. **Example**: Check whether OS account 100 is activated.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.isOsAccountActived(localId).then((isActived) => { accountManager.isOsAccountActived(localId).then((isActived: boolean) => {
console.log('isOsAccountActived successfully, isActived: ' + isActived); console.log('isOsAccountActived successfully, isActived: ' + isActived);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('isOsAccountActived failed, error: ' + JSON.stringify(err)); console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2933,10 +3007,11 @@ Checks whether the specified constraint is enabled for an OS account. This API u ...@@ -2933,10 +3007,11 @@ Checks whether the specified constraint is enabled for an OS account. This API u
**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 ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let constraint = 'constraint.wifi'; let constraint: string = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint, (err, isEnabled) => { accountManager.isOsAccountConstraintEnable(localId, constraint, (err: BusinessError, isEnabled: boolean) => {
if (err) { if (err) {
console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err)); console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -2975,12 +3050,13 @@ Checks whether the specified constraint is enabled for an OS account. This API u ...@@ -2975,12 +3050,13 @@ Checks whether the specified constraint is enabled for an OS account. This API u
**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 ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
let constraint = 'constraint.wifi'; let constraint: string = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled) => { accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled: boolean) => {
console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled); console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err)); console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3006,8 +3082,9 @@ Checks whether this OS account is a test account. This API uses an asynchronous ...@@ -3006,8 +3082,9 @@ Checks whether this OS account is a test account. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTestable) => { accountManager.isTestOsAccount((err: BusinessError, isTestable: boolean) => {
if (err) { if (err) {
console.log('isTestOsAccount failed, error: ' + JSON.stringify(err)); console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3037,10 +3114,11 @@ Checks whether this OS account is a test account. This API uses a promise to ret ...@@ -3037,10 +3114,11 @@ Checks whether this OS account is a test account. This API uses a promise to ret
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTestable) => { accountManager.isTestOsAccount().then((isTestable: boolean) => {
console.log('isTestOsAccount successfully, isTestable: ' + isTestable); console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('isTestOsAccount failed, error: ' + JSON.stringify(err)); console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3068,8 +3146,9 @@ Checks whether this OS account has been verified. This API uses an asynchronous ...@@ -3068,8 +3146,9 @@ Checks whether this OS account has been verified. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => { accountManager.isOsAccountVerified((err: BusinessError, isVerified: boolean) => {
if (err) { if (err) {
console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3102,9 +3181,10 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca ...@@ -3102,9 +3181,10 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.isOsAccountVerified(localId, (err, isVerified) => { accountManager.isOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
if (err) { if (err) {
console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3142,10 +3222,11 @@ Checks whether an OS account has been verified. This API uses a promise to retur ...@@ -3142,10 +3222,11 @@ Checks whether an OS account has been verified. This API uses a promise to retur
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified(localId).then((isVerified) => { accountManager.isOsAccountVerified(localId).then((isVerified: boolean) => {
console.log('isOsAccountVerified successfully, isVerified: ' + isVerified); console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3173,8 +3254,9 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac ...@@ -3173,8 +3254,9 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, count)=>{ accountManager.getCreatedOsAccountsCount((err: BusinessError, count: number)=>{
if (err) { if (err) {
console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err)); console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3206,10 +3288,11 @@ Obtains the number of OS accounts created. This API uses a promise to return the ...@@ -3206,10 +3288,11 @@ Obtains the number of OS accounts created. This API uses a promise to return the
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((count) => { accountManager.getCreatedOsAccountsCount().then((count: number) => {
console.log('getCreatedOsAccountsCount successfully, count: ' + count); console.log('getCreatedOsAccountsCount successfully, count: ' + count);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err)); console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3235,8 +3318,9 @@ Obtains the ID of the OS account to which the current process belongs. This API ...@@ -3235,8 +3318,9 @@ Obtains the ID of the OS account to which the current process belongs. This API
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, localId) => { accountManager.getOsAccountLocalIdFromProcess((err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3266,10 +3350,11 @@ Obtains the ID of the OS account to which the current process belongs. This API ...@@ -3266,10 +3350,11 @@ Obtains the ID of the OS account to which the current process belongs. This API
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((localId) => { accountManager.getOsAccountLocalIdFromProcess().then((localId: number) => {
console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId); console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3296,9 +3381,10 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou ...@@ -3296,9 +3381,10 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid: number = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, localId) => { accountManager.getOsAccountLocalIdFromUid(uid, (err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3334,11 +3420,12 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r ...@@ -3334,11 +3420,12 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r
**Example**: Obtain the ID of the OS account whose process UID is **12345678**. **Example**: Obtain the ID of the OS account whose process UID is **12345678**.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let uid = 12345678; let uid: number = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((localId) => { accountManager.getOsAccountLocalIdFromUid(uid).then((localId: number) => {
console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId); console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3367,9 +3454,10 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -3367,9 +3454,10 @@ Obtains the OS account ID based on the domain account information. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, localId) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => {
if (err) { if (err) {
console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -3407,11 +3495,12 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -3407,11 +3495,12 @@ Obtains the OS account ID based on the domain account information. This API uses
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => {
console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId); console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3440,9 +3529,10 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous ...@@ -3440,9 +3529,10 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous
**Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ accountManager.getOsAccountAllConstraints(localId, (err: BusinessError, constraints: string[])=>{
console.log('getOsAccountAllConstraints err:' + JSON.stringify(err)); console.log('getOsAccountAllConstraints err:' + JSON.stringify(err));
console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints)); console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints));
}); });
...@@ -3477,11 +3567,12 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re ...@@ -3477,11 +3567,12 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re
**Example**: Obtain all constraints of OS account 100. **Example**: Obtain all constraints of OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints) => { accountManager.getOsAccountAllConstraints(localId).then((constraints: string[]) => {
console.log('getOsAccountAllConstraints, constraints: ' + constraints); console.log('getOsAccountAllConstraints, constraints: ' + constraints);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err)); console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3507,8 +3598,9 @@ Obtains information about all activated OS accounts. This API uses an asynchrono ...@@ -3507,8 +3598,9 @@ Obtains information about all activated OS accounts. This API uses an asynchrono
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err, idArray)=>{ accountManager.queryActivatedOsAccountIds((err: BusinessError, idArray: number[])=>{
console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err)); console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err));
console.log('queryActivatedOsAccountIds idArray length:' + idArray.length); console.log('queryActivatedOsAccountIds idArray length:' + idArray.length);
for(let i=0;i<idArray.length;i++) { for(let i=0;i<idArray.length;i++) {
...@@ -3538,10 +3630,11 @@ Obtains information about all activated OS accounts. This API uses a promise to ...@@ -3538,10 +3630,11 @@ Obtains information about all activated OS accounts. This API uses a promise to
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray) => { accountManager.queryActivatedOsAccountIds().then((idArray: number[]) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray); console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err)); console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3569,8 +3662,9 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -3569,8 +3662,9 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ accountManager.queryCurrentOsAccount((err: BusinessError, curAccountInfo: account_osAccount.OsAccountInfo)=>{
console.log('queryCurrentOsAccount err:' + JSON.stringify(err)); console.log('queryCurrentOsAccount err:' + JSON.stringify(err));
console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
}); });
...@@ -3599,10 +3693,11 @@ Obtains information about the OS account to which the current process belongs. T ...@@ -3599,10 +3693,11 @@ Obtains information about the OS account to which the current process belongs. T
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo) => { accountManager.queryCurrentOsAccount().then((accountInfo: account_osAccount.OsAccountInfo) => {
console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryCurrentOsAccount err: ' + JSON.stringify(err)); console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3628,8 +3723,9 @@ Obtains the type of the account to which the current process belongs. This API u ...@@ -3628,8 +3723,9 @@ Obtains the type of the account to which the current process belongs. This API u
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err, accountType) => { accountManager.getOsAccountTypeFromProcess((err: BusinessError, accountType: account_osAccount.OsAccountType) => {
console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
console.log('getOsAccountTypeFromProcess accountType: ' + accountType); console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
}); });
...@@ -3656,10 +3752,11 @@ Obtains the type of the account to which the current process belongs. This API u ...@@ -3656,10 +3752,11 @@ Obtains the type of the account to which the current process belongs. This API u
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType) => { accountManager.getOsAccountTypeFromProcess().then((accountType: account_osAccount.OsAccountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3687,8 +3784,9 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous ...@@ -3687,8 +3784,9 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err, virtualID) => { accountManager.getDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID); console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
}); });
...@@ -3717,10 +3815,11 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re ...@@ -3717,10 +3815,11 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID) => { accountManager.getDistributedVirtualDeviceId().then((virtualID: string) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3747,9 +3846,10 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac ...@@ -3747,9 +3846,10 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac
**Example**: Obtain the ID of the OS account whose SN is 12345. **Example**: Obtain the ID of the OS account whose SN is 12345.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let serialNumber = 12345; let serialNumber: number = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
console.log('ger localId err:' + JSON.stringify(err)); console.log('ger localId err:' + JSON.stringify(err));
console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
}); });
...@@ -3782,11 +3882,12 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the ...@@ -3782,11 +3882,12 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the
**Example**: Obtain the ID of the OS account whose SN is 12345. **Example**: Obtain the ID of the OS account whose SN is 12345.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let serialNumber = 12345; let serialNumber: number = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId: number) => {
console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId); console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3813,9 +3914,10 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch ...@@ -3813,9 +3914,10 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch
**Example**: Obtain the SN of the OS account 100. **Example**: Obtain the SN of the OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ accountManager.getSerialNumberByOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
console.log('ger serialNumber err:' + JSON.stringify(err)); console.log('ger serialNumber err:' + JSON.stringify(err));
console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
}); });
...@@ -3848,11 +3950,12 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise ...@@ -3848,11 +3950,12 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise
**Example**: Obtain the SN of the OS account 100. **Example**: Obtain the SN of the OS account 100.
```js ```js
import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId = 100; let localId: number = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber: number) => {
console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber); console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err)); console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3897,7 +4000,7 @@ Obtains version information. ...@@ -3897,7 +4000,7 @@ Obtains version information.
**Example** **Example**
```js ```js
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let version = userAuth.getVersion(); let version: number = userAuth.getVersion();
console.log('getVersion version = ' + version); console.log('getVersion version = ' + version);
``` ```
...@@ -3974,6 +4077,7 @@ Obtains the executor property based on the request. This API uses an asynchronou ...@@ -3974,6 +4077,7 @@ Obtains the executor property based on the request. This API uses an asynchronou
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let keys = [ let keys = [
account_osAccount.GetPropertyType.AUTH_SUB_TYPE, account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
...@@ -3985,7 +4089,7 @@ Obtains the executor property based on the request. This API uses an asynchronou ...@@ -3985,7 +4089,7 @@ Obtains the executor property based on the request. This API uses an asynchronou
keys: keys keys: keys
}; };
try { try {
userAuth.getProperty(request, (err, result) => { userAuth.getProperty(request, (err: BusinessError, result: account_osAccount.ExecutorProperty) => {
console.log('getProperty err = ' + JSON.stringify(err)); console.log('getProperty err = ' + JSON.stringify(err));
console.log('getProperty result = ' + JSON.stringify(result)); console.log('getProperty result = ' + JSON.stringify(result));
}); });
...@@ -4027,6 +4131,7 @@ Obtains the executor property based on the request. This API uses a promise to r ...@@ -4027,6 +4131,7 @@ Obtains the executor property based on the request. This API uses a promise to r
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let keys = [ let keys = [
account_osAccount.GetPropertyType.AUTH_SUB_TYPE, account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
...@@ -4038,9 +4143,9 @@ Obtains the executor property based on the request. This API uses a promise to r ...@@ -4038,9 +4143,9 @@ Obtains the executor property based on the request. This API uses a promise to r
keys: keys keys: keys
}; };
try { try {
userAuth.getProperty(request).then((result) => { userAuth.getProperty(request).then((result: account_osAccount.ExecutorProperty) => {
console.log('getProperty result = ' + JSON.stringify(result)); console.log('getProperty result = ' + JSON.stringify(result));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getProperty error = ' + JSON.stringify(err)); console.log('getProperty error = ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -4076,6 +4181,7 @@ Sets the property for the initialization algorithm. This API uses an asynchronou ...@@ -4076,6 +4181,7 @@ Sets the property for the initialization algorithm. This API uses an asynchronou
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let request = { let request = {
authType: account_osAccount.AuthType.PIN, authType: account_osAccount.AuthType.PIN,
...@@ -4083,7 +4189,7 @@ Sets the property for the initialization algorithm. This API uses an asynchronou ...@@ -4083,7 +4189,7 @@ Sets the property for the initialization algorithm. This API uses an asynchronou
setInfo: new Uint8Array([0]) setInfo: new Uint8Array([0])
}; };
try { try {
userAuth.setProperty(request, (err) => { userAuth.setProperty(request, (err: BusinessError) => {
if (err) { if (err) {
console.log('setProperty failed, error = ' + JSON.stringify(err)); console.log('setProperty failed, error = ' + JSON.stringify(err));
} else { } else {
...@@ -4128,16 +4234,17 @@ Sets the property for the initialization algorithm. This API uses a promise to r ...@@ -4128,16 +4234,17 @@ Sets the property for the initialization algorithm. This API uses a promise to r
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let request = { let request2 = {
authType: account_osAccount.AuthType.PIN, authType: account_osAccount.AuthType.PIN,
key: account_osAccount.SetPropertyType.INIT_ALGORITHM, key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
setInfo: new Uint8Array([0]) setInfo: new Uint8Array([0])
}; };
try { try {
userAuth.setProperty(request).then(() => { userAuth.setProperty(request2).then(() => {
console.log('setProperty successfully'); console.log('setProperty successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setProperty failed, error = ' + JSON.stringify(err)); console.log('setProperty failed, error = ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -4251,7 +4358,7 @@ Performs authentication of the specified user. This API uses an asynchronous cal ...@@ -4251,7 +4358,7 @@ Performs authentication of the specified user. This API uses an asynchronous cal
**Example** **Example**
```js ```js
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let userID = 100; let userID: number = 100;
let challenge = new Uint8Array([0]); let challenge = new Uint8Array([0]);
let authType = account_osAccount.AuthType.PIN; let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
...@@ -4295,10 +4402,10 @@ Cancels an authentication. ...@@ -4295,10 +4402,10 @@ Cancels an authentication.
**Example** **Example**
```js ```js
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
let challenge = new Uint8Array([0]); let challenge = new Uint8Array([0]);
let contextId = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, { let contextId = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
console.log('auth result = ' + result); console.log('auth result = ' + result);
console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -4328,7 +4435,7 @@ A constructor used to create an instance for PIN authentication. ...@@ -4328,7 +4435,7 @@ A constructor used to create an instance for PIN authentication.
**Example** **Example**
```js ```js
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
``` ```
### registerInputer<sup>8+</sup> ### registerInputer<sup>8+</sup>
...@@ -4359,11 +4466,11 @@ Register a PIN inputer. ...@@ -4359,11 +4466,11 @@ Register a PIN inputer.
**Example** **Example**
```js ```js
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
let password = new Uint8Array([0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0]);
try { try {
let result = pinAuth.registerInputer({ let result = pinAuth.registerInputer({
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
callback.onSetData(authSubType, password); callback.onSetData(authSubType, password);
} }
}); });
...@@ -4387,7 +4494,7 @@ Unregisters this PIN inputer. ...@@ -4387,7 +4494,7 @@ Unregisters this PIN inputer.
**Example** **Example**
```js ```js
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
pinAuth.unregisterInputer(); pinAuth.unregisterInputer();
``` ```
...@@ -4426,10 +4533,10 @@ Register a credential inputer. ...@@ -4426,10 +4533,10 @@ Register a credential inputer.
**Example** **Example**
```js ```js
let authType = account_osAccount.AuthType.DOMAIN; let authType = account_osAccount.AuthType.DOMAIN;
let password = new Uint8Array([0, 0, 0, 0, 0]); let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0]);
try { try {
account_osAccount.InputerManager.registerInputer(authType, { account_osAccount.InputerManager.registerInputer(authType, {
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
callback.onSetData(authSubType, password); callback.onSetData(authSubType, password);
} }
}); });
...@@ -4500,8 +4607,10 @@ Authenticates a domain account. ...@@ -4500,8 +4607,10 @@ Authenticates a domain account.
**Example** **Example**
```js ```js
import { AsyncCallback } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => { auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
callback: account_osAccount.IUserAuthCallback) => {
// mock authentication // mock authentication
// notify authentication result // notify authentication result
callback.onResult(0, { callback.onResult(0, {
...@@ -4510,14 +4619,20 @@ Authenticates a domain account. ...@@ -4510,14 +4619,20 @@ Authenticates a domain account.
freezingTime: 0 freezingTime: 0
}); });
}, },
authWithPopup: (domainAccountInfo, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
authWithToken: (domainAccountInfo, token, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAccountInfo: (domain, accountName, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
getAuthStatusInfo: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
bindAccount: (domainAccountInfo, localId, callback) => {}, getAccountInfo: (domain: string, accountName: string,
unbindAccount: (domainAccountInfo, callback) => {}, callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccessToken: (options, callback) => {} callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin); account_osAccount.DomainAccountManager.registerPlugin(plugin);
let userAuth = new account_osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
...@@ -4526,7 +4641,7 @@ Authenticates a domain account. ...@@ -4526,7 +4641,7 @@ Authenticates a domain account.
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
try { try {
userAuth.auth(challenge, authType, authTrustLevel, { userAuth.auth(challenge, authType, authTrustLevel, {
onResult: (resultCode, authResult) => { onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
console.log('auth resultCode = ' + resultCode); console.log('auth resultCode = ' + resultCode);
console.log('auth authResult = ' + JSON.stringify(authResult)); console.log('auth authResult = ' + JSON.stringify(authResult));
} }
...@@ -4555,9 +4670,12 @@ Authenticates a domain account in a pop-up window. ...@@ -4555,9 +4670,12 @@ Authenticates a domain account in a pop-up window.
**Example** **Example**
```js ```js
import { AsyncCallback } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => { callback: account_osAccount.IUserAuthCallback) => {},
authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: account_osAccount.IUserAuthCallback) => {
// mock authentication // mock authentication
// notify authentication result // notify authentication result
callback.onResult(0, { callback.onResult(0, {
...@@ -4566,13 +4684,18 @@ Authenticates a domain account in a pop-up window. ...@@ -4566,13 +4684,18 @@ Authenticates a domain account in a pop-up window.
freezingTime: 0 freezingTime: 0
}); });
}, },
authWithToken: (domainAccountInfo, token, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, getAccountInfo: (domain: string, accountName: string,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
unbindAccount: (domainAccountInfo, callback) => {}, getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
getAccessToken: (options, callback) => {} bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4597,10 +4720,14 @@ Authenticates a domain account by the authorization token. ...@@ -4597,10 +4720,14 @@ Authenticates a domain account by the authorization token.
**Example** **Example**
```js ```js
import { AsyncCallback } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => { authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: account_osAccount.IUserAuthCallback) => {
// mock authentication // mock authentication
// notify authentication result // notify authentication result
callback.onResult(0, { callback.onResult(0, {
...@@ -4609,12 +4736,16 @@ Authenticates a domain account by the authorization token. ...@@ -4609,12 +4736,16 @@ Authenticates a domain account by the authorization token.
freezingTime: 0 freezingTime: 0
}); });
}, },
getAccountInfo: (domain, accountName, callback) => {}, getAccountInfo: (domain: string, accountName: string,
getAuthStatusInfo: (domainAccountInfo, callback) => {}, callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
bindAccount: (domainAccountInfo, localId, callback) => {}, getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
unbindAccount: (domainAccountInfo, callback) => {}, callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
getAccessToken: (options, callback) => {} callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4639,26 +4770,33 @@ Obtains information about a domain account. ...@@ -4639,26 +4770,33 @@ Obtains information about a domain account.
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from '@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => { callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: account_osAccount.IUserAuthCallback) => {},
getAccountInfo: (domain: string, accountName: string,
callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {
// mock getting account information // mock getting account information
// notify result // notify result
callback({ let code: BusinessError
code: 0 callback(code, {
}, {
domain: domain, domain: domain,
accountName: accountName, accountName: accountName,
accountId: 'xxxx' accountId: 'xxxx'
}) })
}, },
getAuthStatusInfo: (domainAccountInfo, callback) => {}, getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
unbindAccount: (domainAccountInfo, callback) => {}, bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, callback: AsyncCallback<void>) => {},
getAccessToken: (options, callback) => {} unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4682,23 +4820,30 @@ Obtains the authentication status of a domain account. ...@@ -4682,23 +4820,30 @@ Obtains the authentication status of a domain account.
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from '@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => { authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback({ callback: account_osAccount.IUserAuthCallback) => {},
code: 0 getAccountInfo: (domain: string, accountName: string,
}, { callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {
let code: BusinessError;
callback(code, {
remainTimes: 5, remainTimes: 5,
freezingTime: 0 freezingTime: 0
}) })
}, },
bindAccount: (domainAccountInfo, localId, callback) => {}, bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
unbindAccount: (domainAccountInfo, callback) => {}, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
getAccessToken: (options, callback) => {} isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4722,20 +4867,29 @@ Binds a domain account. ...@@ -4722,20 +4867,29 @@ Binds a domain account.
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
bindAccount: (domainAccountInfo, localId, callback) => { callback: account_osAccount.IUserAuthCallback) => {},
getAccountInfo: (domain: string, accountName: string,
callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {
// mock unbinding operation // mock unbinding operation
// notify binding result // notify binding result
callback({code: 0}) let code: BusinessError;
callback(code)
}, },
unbindAccount: (domainAccountInfo, callback) => {}, unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
getAccessToken: (options, callback) => {} callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4759,20 +4913,29 @@ Unbinds a domain account. ...@@ -4759,20 +4913,29 @@ Unbinds a domain account.
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
unbindAccount: (domainAccountInfo, callback) => { getAccountInfo: (domain: string, accountName: string,
callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {
// mock unbinding operation // mock unbinding operation
// notify unbinding result // notify unbinding result
callback({code: 0}) let code: BusinessError;
callback(code)
}, },
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
getAccessToken: (options, callback) => {} callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4792,25 +4955,34 @@ Checks whether a domain account token is valid. ...@@ -4792,25 +4955,34 @@ Checks whether a domain account token is valid.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- | | ---------- | --------------------------------------- | ---- | --------------- |
| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| | domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.|
| token | Uint8Array | Yes| Domain account token to check.| | token | Uint8Array | Yes| Domain account token.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result.|
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
unbindAccount: (domainAccountInfo, callback) => {}, getAccountInfo: (domain: string, accountName: string,
isAccountTokenValid: (domainAccountInfo, token, callback) => { callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {
// mock checking operation // mock checking operation
// notify checking result // notify checking result
callback({code: 0}, true); let code: BusinessError
callback(code, true);
}, },
getAccessToken: (options, callback) => {} getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
``` ```
...@@ -4834,20 +5006,29 @@ Obtains the domain access token based on the specified conditions. ...@@ -4834,20 +5006,29 @@ Obtains the domain access token based on the specified conditions.
**Example** **Example**
```js ```js
import { AsyncCallback, BusinessError } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
unbindAccount: (domainAccountInfo, callback) => {}, getAccountInfo: (domain: string, accountName: string,
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAccessToken: (options, callback) => { getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {
// mock getting operation // mock getting operation
let token = new Uint8Array([0]); //let token = new Uint8Array([0]);
// notify result // notify result
callback({code: 0}, token); let code: BusinessError
callback(code, token);
} }
} }
account_osAccount.DomainAccountManager.registerPlugin(plugin) account_osAccount.DomainAccountManager.registerPlugin(plugin)
...@@ -4882,16 +5063,24 @@ Registers a domain plug-in. ...@@ -4882,16 +5063,24 @@ Registers a domain plug-in.
**Example** **Example**
```js ```js
import { AsyncCallback } from './@ohos.base';
let plugin = { let plugin = {
auth: (domainAccountInfo, credential, callback) => {}, auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
authWithPopup: (domainAccountInfo, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
authWithToken: (domainAccountInfo, token, callback) => {}, authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
getAccountInfo: (domain, accountName, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
getAuthStatusInfo: (domainAccountInfo, callback) => {}, authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
bindAccount: (domainAccountInfo, localId, callback) => {}, callback: account_osAccount.IUserAuthCallback) => {},
unbindAccount: (domainAccountInfo, callback) => {}, getAccountInfo: (domain: string, accountName: string,
isAccountTokenValid: (domainAccountInfo, token, callback) => {}, callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
getAccessToken: (options, callback) => {} getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
callback: AsyncCallback<void>) => {},
unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
callback: AsyncCallback<boolean>) => {},
getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
} }
try { try {
account_osAccount.DomainAccountManager.registerPlugin(plugin); account_osAccount.DomainAccountManager.registerPlugin(plugin);
...@@ -4968,7 +5157,7 @@ Authenticates a domain account. ...@@ -4968,7 +5157,7 @@ Authenticates a domain account.
let credential = new Uint8Array([0]) let credential = new Uint8Array([0])
try { try {
account_osAccount.DomainAccountManager.auth(domainAccountInfo, credential, { account_osAccount.DomainAccountManager.auth(domainAccountInfo, credential, {
onResult: (resultCode, authResult) => { onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
console.log('auth resultCode = ' + resultCode); console.log('auth resultCode = ' + resultCode);
console.log('auth authResult = ' + JSON.stringify(authResult)); console.log('auth authResult = ' + JSON.stringify(authResult));
} }
...@@ -5015,7 +5204,7 @@ Authenticates this domain account in a pop-up window. ...@@ -5015,7 +5204,7 @@ Authenticates this domain account in a pop-up window.
```js ```js
try { try {
account_osAccount.DomainAccountManager.authWithPopup({ account_osAccount.DomainAccountManager.authWithPopup({
onResult: (resultCode, authResult) => { onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
console.log('auth resultCode = ' + resultCode); console.log('auth resultCode = ' + resultCode);
console.log('auth authResult = ' + JSON.stringify(authResult)); console.log('auth authResult = ' + JSON.stringify(authResult));
} }
...@@ -5064,7 +5253,7 @@ Authenticates a domain account in a pop-up window. ...@@ -5064,7 +5253,7 @@ Authenticates a domain account in a pop-up window.
```js ```js
try { try {
account_osAccount.DomainAccountManager.authWithPopup(100, { account_osAccount.DomainAccountManager.authWithPopup(100, {
onResult: (resultCode, authResult) => { onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
console.log('authWithPopup resultCode = ' + resultCode); console.log('authWithPopup resultCode = ' + resultCode);
console.log('authWithPopup authResult = ' + JSON.stringify(authResult)); console.log('authWithPopup authResult = ' + JSON.stringify(authResult));
} }
...@@ -5103,12 +5292,13 @@ Checks whether a domain account exists. ...@@ -5103,12 +5292,13 @@ Checks whether a domain account exists.
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainAccountInfo = { let domainAccountInfo = {
domain: 'CHINA', domain: 'CHINA',
accountName: 'zhangsan' accountName: 'zhangsan'
} }
try { try {
account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err, result) => { account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err: BusinessError, result: boolean) => {
if (err) { if (err) {
console.log('call hasAccount failed, error: ' + JSON.stringify(err)); console.log('call hasAccount failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -5154,14 +5344,15 @@ Checks whether a domain account exists. ...@@ -5154,14 +5344,15 @@ Checks whether a domain account exists.
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainAccountInfo = { let domainAccountInfo = {
domain: 'CHINA', domain: 'CHINA',
accountName: 'zhangsan' accountName: 'zhangsan'
} }
try { try {
account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result) => { account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result: boolean) => {
console.log('hasAccount result: ' + result); console.log('hasAccount result: ' + result);
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('call hasAccount failed, error: ' + JSON.stringify(err)); console.log('call hasAccount failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -5199,6 +5390,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th ...@@ -5199,6 +5390,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainAccountInfo = { let domainAccountInfo = {
domain: 'CHINA', domain: 'CHINA',
accountName: 'zhangsan', accountName: 'zhangsan',
...@@ -5206,7 +5398,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th ...@@ -5206,7 +5398,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th
} }
let token = new Uint8Array([0]) let token = new Uint8Array([0])
try { try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err) => { account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err: BusinessError) => {
if (err != null) { if (err != null) {
console.log('updateAccountToken failed, error: ' + JSON.stringify(err)); console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
} else { } else {
...@@ -5253,6 +5445,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th ...@@ -5253,6 +5445,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let domainAccountInfo = { let domainAccountInfo = {
domain: 'CHINA', domain: 'CHINA',
accountName: 'zhangsan', accountName: 'zhangsan',
...@@ -5262,7 +5455,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th ...@@ -5262,7 +5455,7 @@ Updates the token of a domain account. An empty token means an invalid token. Th
try { try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => { account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => {
console.log('updateAccountToken successfully'); console.log('updateAccountToken successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('updateAccountToken failed, error: ' + JSON.stringify(err)); console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -5317,9 +5510,10 @@ Opens a session to obtain the challenge value. This API uses an asynchronous cal ...@@ -5317,9 +5510,10 @@ Opens a session to obtain the challenge value. This API uses an asynchronous cal
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
try { try {
userIDM.openSession((err, challenge) => { userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
console.log('openSession error = ' + JSON.stringify(err)); console.log('openSession error = ' + JSON.stringify(err));
console.log('openSession challenge = ' + JSON.stringify(challenge)); console.log('openSession challenge = ' + JSON.stringify(challenge));
}); });
...@@ -5354,11 +5548,12 @@ Opens a session to obtain the challenge value. This API uses a promise to return ...@@ -5354,11 +5548,12 @@ Opens a session to obtain the challenge value. This API uses a promise to return
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
try { try {
userIDM.openSession().then((challenge) => { userIDM.openSession().then((challengechallenge: Uint8Array) => {
console.info('openSession challenge = ' + JSON.stringify(challenge)); console.info('openSession challenge = ' + JSON.stringify(challenge));
}).catch((err) => { }).catch((err: BusinessError) => {
console.info('openSession error = ' + JSON.stringify(err)); console.info('openSession error = ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -5399,23 +5594,24 @@ Adds credential information, including the credential type, subtype, and token ( ...@@ -5399,23 +5594,24 @@ Adds credential information, including the credential type, subtype, and token (
**Example** **Example**
```js ```js
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); import { BusinessError } from '@ohos.base';
let pinAuth = new account_osAccount.PINAuth(); let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
pinAuth.registerInputer({ pinAuth.registerInputer({
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
callback.onSetData(authSubType, password); callback.onSetData(authSubType, password);
} }
}); });
let credentialInfo = { let credentialInfo: account_osAccount.CredentialInfo = {
credType: account_osAccount.AuthType.PIN, credType: account_osAccount.AuthType.PIN,
credSubType: account_osAccount.AuthSubType.PIN_SIX, credSubType: account_osAccount.AuthSubType.PIN_SIX,
token: null token: null
}; };
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
userIDM.openSession((err, challenge) => { userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
try { try {
userIDM.addCredential(credentialInfo, { userIDM.addCredential(credentialInfo, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
console.log('addCredential result = ' + result); console.log('addCredential result = ' + result);
console.log('addCredential extraInfo = ' + extraInfo); console.log('addCredential extraInfo = ' + extraInfo);
} }
...@@ -5459,30 +5655,31 @@ Updates credential information. This API uses a callback to return the result. ...@@ -5459,30 +5655,31 @@ Updates credential information. This API uses a callback to return the result.
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let userAuth = new account_osAccount.UserAuth(); let userAuth: account_osAccount.UserAuth = new account_osAccount.UserAuth();
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
let credentialInfo = { let credentialInfo = {
credType: account_osAccount.AuthType.PIN, credType: account_osAccount.AuthType.PIN,
credSubType: account_osAccount.AuthSubType.PIN_SIX, credSubType: account_osAccount.AuthSubType.PIN_SIX,
token: null token: null
}; };
pinAuth.registerInputer({ pinAuth.registerInputer({
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
callback.onSetData(authSubType, password); callback.onSetData(authSubType, password);
} }
}); });
userIDM.openSession((err, challenge) => { userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
userAuth.auth(challenge, credentialInfo.credType, account_osAccount.AuthTrustLevel.ATL1, { userAuth.auth(challenge, credentialInfo.credType, account_osAccount.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
if (result != account_osAccount.ResultCode.SUCCESS) { if (result != account_osAccount.ResultCode.SUCCESS) {
return; return;
} }
credentialInfo.token = extraInfo.token; credentialInfo.token = extraInfo.token;
try { try {
userIDM.updateCredential(credentialInfo, { userIDM.updateCredential(credentialInfo, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
console.log('updateCredential result = ' + result); console.log('updateCredential result = ' + result);
console.log('updateCredential extraInfo = ' + extraInfo); console.log('updateCredential extraInfo = ' + extraInfo);
} }
...@@ -5541,7 +5738,7 @@ Cancels an entry based on the challenge value. ...@@ -5541,7 +5738,7 @@ Cancels an entry based on the challenge value.
**Example** **Example**
```js ```js
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let challenge = new Uint8Array([0]); let challenge: Uint8Array = new Uint8Array([0]);
try { try {
userIDM.cancel(challenge); userIDM.cancel(challenge);
} catch(err) { } catch(err) {
...@@ -5578,10 +5775,10 @@ Deletes a user based on the authentication token. This API uses a callback to re ...@@ -5578,10 +5775,10 @@ Deletes a user based on the authentication token. This API uses a callback to re
**Example** **Example**
```js ```js
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let token = new Uint8Array([0]); let token: Uint8Array = new Uint8Array([0]);
try { try {
userIDM.delUser(token, { userIDM.delUser(token, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
console.log('delUser result = ' + result); console.log('delUser result = ' + result);
console.log('delUser extraInfo = ' + JSON.stringify(extraInfo)); console.log('delUser extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -5623,11 +5820,11 @@ Deletes user credential information. ...@@ -5623,11 +5820,11 @@ Deletes user credential information.
**Example** **Example**
```js ```js
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let credentialId = new Uint8Array([0]); let credentialId: Uint8Array = new Uint8Array([0]);
let token = new Uint8Array([0]); let token: Uint8Array = new Uint8Array([0]);
try { try {
userIDM.delCred(credentialId, token, { userIDM.delCred(credentialId, token, {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
console.log('delCred result = ' + result); console.log('delCred result = ' + result);
console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); console.log('delCred extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -5664,9 +5861,10 @@ Obtains authentication information. This API uses an asynchronous callback to re ...@@ -5664,9 +5861,10 @@ Obtains authentication information. This API uses an asynchronous callback to re
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
try { try {
userIDM.getAuthInfo((err, result) => { userIDM.getAuthInfo((err: BusinessError, result: account_osAccount.EnrolledCredInfo[]) => {
console.log('getAuthInfo err = ' + JSON.stringify(err)); console.log('getAuthInfo err = ' + JSON.stringify(err));
console.log('getAuthInfo result = ' + JSON.stringify(result)); console.log('getAuthInfo result = ' + JSON.stringify(result));
}); });
...@@ -5704,9 +5902,11 @@ Obtains authentication information of the specified type. This API uses an async ...@@ -5704,9 +5902,11 @@ Obtains authentication information of the specified type. This API uses an async
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
try { try {
userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => { userIDM.getAuthInfo(account_osAccount.AuthType.PIN,
(err: BusinessError, result: account_osAccount.EnrolledCredInfo[]) => {
console.log('getAuthInfo err = ' + JSON.stringify(err)); console.log('getAuthInfo err = ' + JSON.stringify(err));
console.log('getAuthInfo result = ' + JSON.stringify(result)); console.log('getAuthInfo result = ' + JSON.stringify(result));
}); });
...@@ -5749,11 +5949,12 @@ Obtains authentication information of the specified type. This API uses a promis ...@@ -5749,11 +5949,12 @@ Obtains authentication information of the specified type. This API uses a promis
**Example** **Example**
```js ```js
import { BusinessError } from '@ohos.base';
let userIDM = new account_osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
try { try {
userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => { userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result: account_osAccount.EnrolledCredInfo[]) => {
console.log('getAuthInfo result = ' + JSON.stringify(result)) console.log('getAuthInfo result = ' + JSON.stringify(result))
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getAuthInfo error = ' + JSON.stringify(err)); console.log('getAuthInfo error = ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
...@@ -5792,10 +5993,10 @@ Called to set data in a PIN operation. ...@@ -5792,10 +5993,10 @@ Called to set data in a PIN operation.
**Example** **Example**
```js ```js
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]); let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
let inputer = { let inputer = {
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) { if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(authSubType, passwordNumber); callback.onSetData(authSubType, passwordNumber);
} else { } else {
...@@ -5829,10 +6030,10 @@ Called to obtain data. ...@@ -5829,10 +6030,10 @@ Called to obtain data.
**Example** **Example**
```js ```js
let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]); let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
let inputer = { let inputer = {
onGetData: (authSubType, callback) => { onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) { if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(authSubType, passwordNumber); callback.onSetData(authSubType, passwordNumber);
} else { } else {
...@@ -5840,7 +6041,7 @@ Called to obtain data. ...@@ -5840,7 +6041,7 @@ Called to obtain data.
} }
} }
}; };
let pinAuth = new account_osAccount.PINAuth(); let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
let result = pinAuth.registerInputer(inputer); let result = pinAuth.registerInputer(inputer);
console.log('registerInputer result: ' + result); console.log('registerInputer result: ' + result);
``` ```
...@@ -5871,7 +6072,7 @@ Called to return the result code and authentication result. ...@@ -5871,7 +6072,7 @@ Called to return the result code and authentication result.
**Example** **Example**
```js ```js
let authCallback = { let authCallback = {
onResult: (result, extraInfo) => { onResult: (result: account_osAccount.AuthSubType, extraInfo: account_osAccount.IInputData) => {
console.log('auth result = ' + result); console.log('auth result = ' + result);
console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -5899,11 +6100,11 @@ Called to acquire identity authentication information. ...@@ -5899,11 +6100,11 @@ Called to acquire identity authentication information.
**Example** **Example**
```js ```js
let authCallback = { let authCallback = {
onResult: (result, extraInfo) => { onResult: (result: account_osAccount.AuthSubType, extraInfo: account_osAccount.IInputData) => {
console.log('auth result = ' + result) console.log('auth result = ' + result)
console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
}, },
onAcquireInfo: (module, acquire, extraInfo) => { onAcquireInfo: (module: number, acquire: number, extraInfo: account_osAccount.RequestResult) => {
console.log('auth module = ' + module); console.log('auth module = ' + module);
console.log('auth acquire = ' + acquire); console.log('auth acquire = ' + acquire);
console.info('auth extraInfo = ' + JSON.stringify(extraInfo)); console.info('auth extraInfo = ' + JSON.stringify(extraInfo));
...@@ -5937,7 +6138,7 @@ Called to return the result code and request result information. ...@@ -5937,7 +6138,7 @@ Called to return the result code and request result information.
**Example** **Example**
```js ```js
let idmCallback = { let idmCallback = {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
console.log('callback result = ' + result) console.log('callback result = ' + result)
console.info('callback extraInfo = ' + JSON.stringify(extraInfo)); console.info('callback extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -5965,11 +6166,11 @@ Called to acquire IDM information. ...@@ -5965,11 +6166,11 @@ Called to acquire IDM information.
**Example** **Example**
```js ```js
let idmCallback = { let idmCallback = {
onResult: (result, extraInfo) => { onResult: (result: number, extraInfo: Object) => {
console.log('callback result = ' + result) console.log('callback result = ' + result)
console.log('callback onResult = ' + JSON.stringify(extraInfo)); console.log('callback onResult = ' + JSON.stringify(extraInfo));
}, },
onAcquireInfo: (module, acquire, extraInfo) => { onAcquireInfo: (module: number, acquire: number, extraInfo: Object) => {
console.log('callback module = ' + module); console.log('callback module = ' + module);
console.log('callback acquire = ' + acquire); console.log('callback acquire = ' + acquire);
console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo)); console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册