diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
index c13f884ac99a9b3b3a74dcc34ccc8f48aed1fa22..b8c557185193c2f1ca58fcd399d54a2a69d5a7b1 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
@@ -1,6 +1,6 @@
# 系统帐号管理
-本模块提供管理系统帐号的一些基础能力,包括系统帐号的添加、删除、查询、设置、订阅、启动等功能,提供系统帐号数据落盘的能力。
+本模块提供管理系统帐号的基础能力,包括系统帐号的添加、删除、查询、设置、订阅、启动等功能。
>  **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
@@ -16,15 +16,15 @@ import account_osAccount from '@ohos.account.osAccount';
getAccountManager(): AccountManager
-获取系统帐号能力的实例。
+获取系统帐号管理对象。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| --------------------------------- | ------------------------ |
-| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 |
+| 类型 | 说明 |
+| --------------------------------- | ---------------- |
+| [AccountManager](#accountmanager) | 系统帐号管理对象。 |
**示例:**
```js
@@ -33,27 +33,27 @@ getAccountManager(): AccountManager
## OsAccountType
-枚举,系统帐号类型。
+表示系统帐号类型的枚举。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
+**系统能力:** SystemCapability.Account.OsAccount。
| 参数 | 默认值 | 说明 |
-| ------ | ------ | ------------ |
+| ------ | ------ | ----------- |
| ADMIN | 0 | 管理员帐号。 |
| NORMAL | 1 | 普通帐号。 |
| GUEST | 2 | 访客帐号。 |
## AccountManager
-管理系统帐号能力的类。
+系统帐号管理类。
### activateOsAccount
activateOsAccount(localId: number, callback: AsyncCallback<void>): void
-激活指定系统帐号,使用callback回调异步返回结果。
+激活指定系统帐号。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
@@ -61,10 +61,18 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------- | ---- | -------------------- |
-| localId | number | 是 | 要激活的系统帐号ID。 |
-| callback | AsyncCallback<void> | 是 | 回调结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------- | ---- | -------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。当帐号激活成功时,err为null,否则为错误对象。 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
**示例:** 激活ID为100的系统帐号
```js
@@ -72,10 +80,14 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
let localId = 100;
try {
accountManager.activateOsAccount(localId, (err)=>{
- console.log('activateOsAccount err:' + JSON.stringify(err));
+ if (err) {
+ console.log("activateOsAccount failed, error:" + JSON.stringify(err));
+ } else {
+ console.log("activateOsAccount successfully");
+ }
});
- } catch (e) {
- console.log('activateOsAccount exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log("activateOsAccount exception:" + JSON.stringify(err));
}
```
@@ -83,9 +95,9 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
activateOsAccount(localId: number): Promise<void>
-激活指定系统帐号,使用Promise方式异步返回结果。
+激活指定系统帐号。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
@@ -95,13 +107,21 @@ activateOsAccount(localId: number): Promise<void>
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | -------------------- |
-| localId | number | 是 | 要激活的系统帐号ID。 |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :------------------ | :---------------------------------- |
-| Promise<void> | Promise实例,用于获取异步返回结果。 |
+| 类型 | 说明 |
+| :------------------ | :----------------------------------- |
+| Promise<void> | Promise对象。无返回结果的Promise对象。 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
**示例:** 激活ID为100的系统帐号
```js
@@ -109,240 +129,332 @@ activateOsAccount(localId: number): Promise<void>
let localId = 100;
try {
accountManager.activateOsAccount(localId).then(() => {
- console.log('activateOsAccount success');
+ console.log('activateOsAccount successfully');
}).catch((err) => {
- console.log('activateOsAccount err:' + JSON.stringify(err));
+ console.log('activateOsAccount failed, err:' + JSON.stringify(err));
});
} catch (e) {
console.log('activateOsAccount exception:' + JSON.stringify(e));
}
```
-### isMultiOsAccountEnabled9+
+### checkMultiOsAccountEnabled9+
-isMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void
+checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void
-判断是否支持多系统帐号,使用callback回调异步返回结果。
+判断是否支持多系统帐号。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | --------------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示支持多系统帐号;返回false表示不支持。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.isMultiOsAccountEnabled((err, isEnabled) => {
- console.log('isMultiOsAccountEnabled err: ' + JSON.stringify(err));
- console.log('isMultiOsAccountEnabled isEnabled: ' + isEnabled);
+ accountManager.checkMultiOsAccountEnabled((err, isEnalbed) => {
+ if (err) {
+ console.log("checkMultiOsAccountEnabled failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkMultiOsAccountEnabled successfully, isEnabled: " + isEnabled);
+ }
});
- } catch (e) {
- console.log('isMultiOsAccountEnabled exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log("checkMultiOsAccountEnabled exception: " + JSON.stringify(err));
}
```
-### isMultiOsAccountEnabled9+
+### checkMultiOsAccountEnabled9+
-isMultiOsAccountEnabled(): Promise<boolean>
+checkMultiOsAccountEnabled(): Promise<boolean>
-判断是否支持多系统帐号,使用Promise方式异步返回结果。
+判断是否支持多系统帐号。使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 |
+| 类型 | 说明 |
+| :--------------------- | :--------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示支持多系统帐号;返回false表示不支持。 |
**示例:**
```js
try {
let accountManager = account_osAccount.getAccountManager();
- accountManager.isMultiOsAccountEnabled().then((isEnabled) => {
- console.log('isMultiOsAccountEnabled, isEnabled: ' + isEnabled);
+ accountManager.checkMultiOsAccountEnabled().then((isEnabled) => {
+ console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => {
- console.log('isMultiOsAccountEnabled err: ' + JSON.stringify(err));
+ console.log('checkMultiOsAccountEnabled failed, error: ' + JSON.stringify(err));
});
- } catch (e) {
- console.log('isMultiOsAccountEnabled exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log('checkMultiOsAccountEnabled exception: ' + JSON.stringify(err));
}
```
-### isMultiOsAccountEnable(deprecated)
+### checkOsAccountActivated9+
-isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
+checkOsAccountActivated(localId: number, callback: AsyncCallback<boolean>): void
-判断是否支持多系统帐号,使用callback回调异步返回结果。
+判断指定系统帐号是否处于激活状态。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[isMultiOsAccountEnabled](#ismultiosaccountenabled9)
->
-> 从 API version 7开始支持。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | --------------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示帐号已激活;返回false表示帐号未激活。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 判断ID为100的系统帐号是否处于激活状态
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isMultiOsAccountEnable((err, isEnabled) => {
- console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err));
- console.log('isMultiOsAccountEnable isEnabled: ' + isEnabled);
- });
+ let osLocalId = 100;
+ try {
+ accountManager.checkOsAccountActivated(osLocalId, (err, isActivated)=>{
+ if (err) {
+ console.log('checkOsAccountActivated failed, error:' + JSON.stringify(err));
+ } else {
+ console.log('checkOsAccountActivated successfully, isActivated:' + isActivated);
+ }
+ });
+ } catch (err) {
+ console.log('checkOsAccountActivated exception:' + JSON.stringify(err));
+ }
```
-### isMultiOsAccountEnable(deprecated)
+### checkOsAccountActivated9+
-isMultiOsAccountEnable(): Promise<boolean>
+checkOsAccountActivated(localId: number): Promise<boolean>
-判断是否支持多系统帐号,使用Promise方式异步返回结果。
+判断指定系统帐号是否处于激活状态。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[isMultiOsAccountEnabled](#ismultiosaccountenabled9-1)
->
-> 从 API version 7开始支持。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | --------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 |
+| 类型 | 说明 |
+| ---------------------- | ---------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示帐号已激活;返回false表示帐号未激活。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 判断ID为100的系统帐号是否处于激活状态
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isMultiOsAccountEnable().then((isEnabled) => {
- console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
- }).catch((err) => {
- console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err));
- });
+ let localId = 100;
+ try {
+ accountManager.checkOsAccountActivated(localId).then((isActivated) => {
+ console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated);
+ }).catch((err) => {
+ console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('checkOsAccountActivated exception:' + JSON.stringify(err));
+ }
```
-### isOsAccountActivated9+
+### checkConstraintEnabled9+
-isOsAccountActivated(localId: number, callback: AsyncCallback<boolean>): void
+checkConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback<boolean>): void
-判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。
+判断指定系统帐号是否具有指定约束。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------------- |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
-**示例:** 判断ID为100的系统帐号是否处于激活状态
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
- let osLocalId = 100;
+ let localId = 100;
+ let constraint = "constraint.wifi";
try {
- accountManager.isOsAccountActivated(osLocalId, (err, isActive)=>{
- console.log('isOsAccountActivated err:' + JSON.stringify(err));
- console.log('isOsAccountActivated isActive:' + isActive);
+ accountManager.checkConstraintEnabled(localId, constraint, (err, isEnabled)=>{
+ if (err) {
+ console.log("checkConstraintEnabled failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkConstraintEnabled successfully, isEnabled: " + isEnabled);
+ }
});
- } catch (e) {
- console.log('isOsAccountActivated exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log("checkConstraintEnabled exception: " + JSON.stringify(err));
}
```
-### isOsAccountActivated9+
+### checkConstraintEnabled9+
-isOsAccountActivated(localId: number): Promise<boolean>
+checkConstraintEnabled(localId: number, constraint: string): Promise<boolean>
-判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。
+判断指定系统帐号是否具有指定约束。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ------ | ---- | ---------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 |
+| 类型 | 说明 |
+| --------------------- | --------------------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
-**示例:** 判断ID为100的系统帐号是否处于激活状态
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
- let osLocalId = 100;
+ let localId = 100;
+ let constraint = "constraint.wifi";
try {
- accountManager.isOsAccountActivated(osLocalId).then((isActive) => {
- console.log('isOsAccountActivated, isActive: ' + isActive);
+ accountManager.checkConstraintEnabled(localId, constraint).then((isEnabled) => {
+ console.log("checkConstraintEnabled successfully, isEnabled: " + isEnabled);
}).catch((err) => {
- console.log('isOsAccountActivated err: ' + JSON.stringify(err));
+ console.log("checkConstraintEnabled failed, error: " + JSON.stringify(err));
});
- } catch (e) {
- console.log('isOsAccountActivated exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log("checkConstraintEnabled exception: " + JSON.stringify(err));
}
```
-### isOsAccountActived(deprecated)
-
-isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void
-
-判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。
+### checkOsAccountTestable9+
-> **说明:** 从API version 9开始废弃, 建议使用[isOsAccountActivated](#isosaccountactivated9)
->
-> 从 API version 7开始支持。
+checkOsAccountTestable(callback: AsyncCallback<boolean>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+检查当前系统帐号是否为测试帐号。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------------- |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前帐号为测试帐号;返回false表示当前帐号非测试帐号。 |
-**示例:** 判断ID为100的系统帐号是否处于激活状态
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let osLocalId = 100;
- accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
- console.log('isOsAccountActived err:' + JSON.stringify(err));
- console.log('isOsAccountActived isActive:' + isActive);
- });
+ try {
+ accountManager.checkOsAccountTestable((err, isTestable) => {
+ if (err) {
+ console.log("checkOsAccountTestable failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkOsAccountTestable successfully, isTestable: " + isTestable);
+ }
+ });
+ } catch (err) {
+ console.log("checkOsAccountTestable error: " + JSON.stringify(err));
+ }
```
-### isOsAccountActived(deprecated)
+### checkOsAccountTestable9+
-isOsAccountActived(localId: number): Promise<boolean>
+checkOsAccountTestable(): Promise<boolean>
-判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。
+检查当前系统帐号是否为测试帐号。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃, 建议使用[isOsAccountActivated](#isosaccountactivated9-1)
->
-> 从 API version 7开始支持。
+**系统能力:** SystemCapability.Account.OsAccount
+
+**返回值:**
+
+| 类型 | 说明 |
+| ---------------------- | ------------------------------------------------------------------------ |
+| Promise<boolean> | Promise对象。返回true表示当前帐号为测试帐号;返回false表示当前帐号非测试帐号。 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:**
+
+ ```js
+ let accountManager = account_osAccount.getAccountManager();
+ try {
+ accountManager.checkOsAccountTestable().then((isTestable) => {
+ console.log("checkOsAccountTestable successfully, isTestable: " + isTestable);
+ }).catch((err) => {
+ console.log("checkOsAccountTestable failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('checkOsAccountTestable exception: ' + JSON.stringify(err));
+ }
+ ```
+
+### checkOsAccountVerified9+
+
+checkOsAccountVerified(callback: AsyncCallback<boolean>): void
+
+检查当前系统帐号是否已验证。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
@@ -350,109 +462,128 @@ isOsAccountActived(localId: number): Promise<boolean>
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前帐号已验证;返回false表示当前帐号未验证。 |
-**返回值:**
+**错误码:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 |
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
-**示例:** 判断ID为100的系统帐号是否处于激活状态
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let osLocalId = 100;
- accountManager.isOsAccountActived(osLocalId).then((isActive) => {
- console.log('isOsAccountActived, isActive: ' + isActive);
- }).catch((err) => {
- console.log('isOsAccountActived err: ' + JSON.stringify(err));
- });
+ try {
+ accountManager.checkOsAccountVerified((err, isVerified) => {
+ if (err) {
+ console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
+ }
+ });
+ } catch (err) {
+ console.log("checkOsAccountVerified exception: " + JSON.stringify(err));
+ }
```
-### isConstraintEnabled9+
+### checkOsAccountVerified9+
-isConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback<boolean>): void
+checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void
-判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。
+检查指定系统帐号是否已验证。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | ---------------------------- | ---- | ------------------------------------------------- |
-| localId | number | 是 | 指定的系统帐号ID。 |
-| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
+| localId | number | 否 | 系统帐号ID。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示指定帐号已验证;返回false表示指定帐号未验证。 |
-**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
try {
- accountManager.isConstraintEnabled(localId, 'constraint.wifi', (err, isEnabled)=>{
- console.log('isConstraintEnabled err:' + JSON.stringify(err));
- console.log('isConstraintEnabled isEnabled:' + isEnabled);
+ accountManager.checkOsAccountVerified(localId, (err, result) => {
+ if (err) {
+ console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
+ }
});
- } catch (e) {
- console.log('isConstraintEnabled exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log("checkOsAccountVerified exception: " + err);
}
```
-### isConstraintEnabled9+
+### checkOsAccountVerified9+
-isConstraintEnabled(localId: number, constraint: string): Promise<boolean>
+checkOsAccountVerified(localId?: number): Promise<boolean>
-判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。
+检查指定系统帐号是否已验证。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | ------ | ---- | ------------------------------------- |
-| localId | number | 是 | 指定的系统帐号ID。 |
-| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | --------------------------------------------------------------- |
+| localId | number | 否 | 系统帐号ID。不填则检查当前系统帐号是否已验证。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 |
+| 类型 | 说明 |
+| ---------------------- | ----------------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示指定帐号已验证;返回false表示指定帐号未验证。 |
-**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
try {
- accountManager.isConstraintEnabled(localId, 'constraint.wifi').then((isEnabled) => {
- console.log('isConstraintEnabled, isEnabled: ' + isEnabled);
+ accountManager.checkOsAccountVerified(localId).then((isVerified) => {
+ console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
}).catch((err) => {
- console.log('isConstraintEnabled err: ' + JSON.stringify(err));
+ console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
});
- } catch (e) {
- console.log('isConstraintEnabled exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log('checkOsAccountVerified exception: ' + JSON.stringify(e));
}
```
-### isOsAccountConstraintEnable(deprecated)
+### removeOsAccount
-isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void
+removeOsAccount(localId: number, callback: AsyncCallback<void>): void
-判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。
+删除指定系统帐号。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[isConstraintEnabled](#isconstraintenabled9)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -460,32 +591,46 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | ---------------------------- | ---- | ------------------------------------------------- |
-| localId | number | 是 | 指定的系统帐号ID。 |
-| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------- | ---- | -------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。如果删除帐号成功,err为null,否则为错误对象。 |
-**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi', (err, isConstraintEnabled)=>{
- console.log('isOsAccountConstraintEnable err:' + JSON.stringify(err));
- console.log('isOsAccountConstraintEnable isConstraintEnabled:' + isConstraintEnabled);
- });
+ let accountName = "testAccountName";
+ try {
+ accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => {
+ accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{
+ if (err) {
+ console.log("removeOsAccount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("removeOsAccount successfully");
+ }
+ });
+ });
+ } catch (err) {
+ console.log('removeOsAccount exception:' + JSON.stringify(err));
+ }
```
-### isOsAccountConstraintEnable(deprecated)
+### removeOsAccount
-isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean>
+removeOsAccount(localId: number): Promise<void>
-判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。
+删除指定系统帐号。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[isConstraintEnabled](#isconstraintenabled9-1)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -493,344 +638,445 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | ------ | ---- | ------------------------------------- |
-| localId | number | 是 | 指定的系统帐号ID。 |
-| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | --------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------------------ |
+| Promise<void> | Promise对象。无返回结果的Promise对象。 |
-**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi').then((isConstraintEnabled) => {
- console.log('isOsAccountConstraintEnable, isConstraintEnabled: ' + isConstraintEnabled);
- }).catch((err) => {
- console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err));
- });
+ let accountName = "testAccountName";
+ try {
+ accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
+ accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
+ console.log("removeOsAccount successfully");
+ }).catch((err) => {
+ console.log("removeOsAccount failed, error: " + JSON.stringify(err));
+ });
+ });
+ } catch (err) {
+ console.log("removeOsAccount exception: " + JSON.stringify(err));
+ }
```
-### isTestable9+
+### setOsAccountConstraints
+
+setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void
+
+为指定系统帐号设置/删除约束。使用callback异步回调。
-isTestable(callback: AsyncCallback<boolean>): void
+**系统接口:** 此接口为系统接口。
-检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ----------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ----------- | ------------------------- | ---- | ----------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
+| enable | boolean | 是 | 设置(true)/删除(false) |
+| callback | AsyncCallback<void> | 是 | 回调函数。如果设置成功,err为null,否则为错误对象。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:** 给ID为100的系统帐号设置禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
+ let constraint = "constraint.wifi";
try {
- accountManager.isTestable((err, isTest) => {
- console.log('isTestable err: ' + JSON.stringify(err));
- console.log('isTestable isTest: ' + isTest);
+ accountManager.setOsAccountConstraints(localId, [constraint], true, (err) => {
+ if (err) {
+ console.log("setOsAccountConstraints failed, error:" + JSON.stringify(err));
+ } else {
+ console.log("setOsAccountConstraints successfully");
+ }
});
- } catch (e) {
- console.log('isTestable exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log("setOsAccountConstraints exception: " + JSON.stringify(err));
}
```
-### isTestable9+
+### setOsAccountConstraints
+
+setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void>
+
+为指定系统帐号设置/删除约束。使用Promise异步回调。
-isTestable(): Promise<boolean>
+**系统接口:** 此接口为系统接口。
-检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ----------- | ------------------- | ---- | -------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
+| enable | boolean | 是 | 设置(true)/删除(false)。 |
+
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 |
+| 类型 | 说明 |
+| :------------------ | :----------------------------------- |
+| Promise<void> | Promise对象。无返回结果的Promise对象。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:** 删除ID为100的系统帐号的禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
try {
- accountManager.isTestable().then((isTest) => {
- console.log('isTestable, isTest: ' + isTest);
+ accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
+ console.log('setOsAccountConstraints succsuccessfully');
}).catch((err) => {
- console.log('isTestable err: ' + JSON.stringify(err));
+ console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
});
- } catch (e) {
- console.log('isTestable exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log('setOsAccountConstraints exception:' + JSON.stringify(err));
}
```
-### isTestOsAccount(deprecated)
+### setOsAccountName
-isTestOsAccount(callback: AsyncCallback<boolean>): void
+setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void
-检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。
+设置指定系统帐号的帐号名。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[isTestable](#istestable9)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ----------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| :-------- | ------------------------- | ---- | ----------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| localName | string | 是 | 帐号名,最大长度为1024。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。如果设置成功,err为null,否则为错误对象。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid parameters. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:** 将ID为100的系统帐号的帐号名设置成demoName
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isTestOsAccount((err, isTest) => {
- console.log('isTestOsAccount err: ' + JSON.stringify(err));
- console.log('isTestOsAccount isTest: ' + isTest);
- });
+ let localId = 100;
+ let name = "demoName";
+ try {
+ accountManager.setOsAccountName(localId, name, (err) => {
+ if (err) {
+ console.log("setOsAccountName failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("setOsAccountName successfully");
+ }
+ });
+ } catch (err) {
+ console.log('setOsAccountName exception:' + JSON.stringify(err));
+ }
```
-### isTestOsAccount(deprecated)
+### setOsAccountName
-isTestOsAccount(): Promise<boolean>
+setOsAccountName(localId: number, localName: string): Promise<void>
-检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。
+设置指定系统帐号的帐号名。使用Promise异步调用。
-> **说明:** 从API version 9开始废弃,建议使用[isTestable](#istestable9-1)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------ | ---- | --------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| localName | string | 是 | 帐号名,最大长度为1024。 |
+
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 |
+| 类型 | 说明 |
+| :------------------ | :----------------------------------- |
+| Promise<void> | Promise对象。无返回结果的Promise对象。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:** 将ID为100的系统帐号的帐号名设置成demoName
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isTestOsAccount().then((isTest) => {
- console.log('isTestOsAccount, isTest: ' + isTest);
- }).catch((err) => {
- console.log('isTestOsAccount err: ' + JSON.stringify(err));
- });
+ let localId = 100;
+ let name = 'testName';
+ try {
+ accountManager.setOsAccountName(localId, name).then(() => {
+ console.log('setOsAccountName successfully');
+ }).catch((err) => {
+ console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('setOsAccountName exception:' + JSON.stringify(err));
+ }
```
-### isVerified9+
+### getOsAccountCount9+
-isVerified(callback: AsyncCallback<boolean>): void
+getOsAccountCount(callback: AsyncCallback<number>): void
-检查当前系统帐号是否已验证,使用callback回调异步返回结果。
+获取已创建的系统帐号数量。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
+| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为已创建的系统帐号的数量;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.isVerified((err, isVeri) => {
- console.log('isVerified err: ' + JSON.stringify(err));
- console.log('isVerified isVeri: ' + isVeri);
+ accountManager.getOsAccountCount((err, count) => {
+ if (err) {
+ console.log("getOsAccountCount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getOsAccountCount successfully, count: " + count);
+ }
});
- } catch (e) {
- console.log('isVerified exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log("getOsAccountCount exception: " + JSON.stringify(err));
}
```
-### isVerified9+
+### getOsAccountCount9+
-isVerified(localId: number, callback: AsyncCallback<boolean>): void
+getOsAccountCount(): Promise<number>
-检查指定系统帐号是否已验证,使用callback回调异步返回结果。
+获取已创建的系统帐号数量。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
+**返回值:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------- |
-| localId | number | 否 | 指定的系统帐号ID。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 |
+| 类型 | 说明 |
+| --------------------- | -------------------------------------- |
+| Promise<number> | Promise对象,返回已创建的系统帐号的数量。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.isVerified((err, isVeri) => {
- console.log('isVerified err: ' + JSON.stringify(err));
- console.log('isVerified isVeri: ' + isVeri);
+ accountManager.getOsAccountCount().then((count) => {
+ console.log("getOsAccountCount successfully, count: " + count);
+ }).catch((err) => {
+ console.log("getOsAccountCount failed, error: " + JSON.stringify(err));
});
- } catch (e) {
- console.log('isVerified exception: ' + JSON.stringify(e));
+ } catch(err) {
+ console.log('getOsAccountCount exception:' + JSON.stringify(err));
}
```
-### isVerified9+
-
-isVerified(localId?: number): Promise<boolean>
+### queryOsAccountLocalIdFromProcess9+
-检查指定系统帐号是否已验证,使用Promise方式异步返回结果。
+queryOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+获取当前进程所属的系统帐号ID,使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------------ |
-| localId | number | 否 | 指定的系统帐号ID。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
+| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为当前进程所属的系统帐号ID;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.isVerified().then((isVeri) => {
- console.log('isVerified, isVeri: ' + isVeri);
- }).catch((err) => {
- console.log('isVerified err: ' + JSON.stringify(err));
+ accountManager.queryOsAccountLocalIdFromProcess((err, localId) => {
+ if (err) {
+ console.log("queryOsAccountLocalIdFromProcess failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("queryOsAccountLocalIdFromProcess successfully, localId: " + localId);
+ }
});
- } catch (e) {
- console.log('isVerified exception: ' + JSON.stringify(e));
+ } catch (err) {
+ console.log("queryOsAccountLocalIdFromProcess exception: " + JSON.stringify(err));
}
```
-### isOsAccountVerified(deprecated)
-
-isOsAccountVerified(callback: AsyncCallback<boolean>): void
+### queryOsAccountLocalIdFromProcess9+
-检查当前系统帐号是否已验证,使用callback回调异步返回结果。
+queryOsAccountLocalIdFromProcess(): Promise<number>
-> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9)
->
-> 从 API version 7开始支持。
+获取当前进程所属的系统帐号ID,使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
+**返回值:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 |
+| 类型 | 说明 |
+| :-------------------- | :--------------------------------------- |
+| Promise<number> | Promise对象,返回当前进程所属的系统帐号ID。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isOsAccountVerified((err, isVerified) => {
- console.log('isOsAccountVerified err: ' + JSON.stringify(err));
- console.log('isOsAccountVerified isVerified: ' + isVerified);
- });
+ try {
+ accountManager.queryOsAccountLocalIdFromProcess().then((localId) => {
+ console.log("queryOsAccountLocalIdFromProcess successfully, localId: " + localId);
+ }).catch((err) => {
+ console.log("queryOsAccountLocalIdFromProcess failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('queryOsAccountLocalIdFromProcess exception: ' + JSON.stringify(err));
+ }
```
-### isOsAccountVerified(deprecated)
-
-isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void
-
-检查指定系统帐号是否已验证,使用callback回调异步返回结果。
+### queryOsAccountLocalIdFromUid9+
-> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9-1)
->
-> 从 API version 7开始支持。
+queryOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+根据uid查询对应的系统帐号ID,使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | ------------------------------------------- |
-| localId | number | 否 | 指定的系统帐号ID。 |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
+| uid | number | 是 | 进程uid。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为对应的系统帐号ID;否则为错误对象。 |
-**示例:**
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid uid. |
+
+**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isOsAccountVerified((err, isVerified) => {
- console.log('isOsAccountVerified err: ' + JSON.stringify(err));
- console.log('isOsAccountVerified isVerified: ' + isVerified);
- });
+ let uid = 12345678;
+ try {
+ accountManager.queryOsAccountLocalIdFromUid(uid, (err, localId) => {
+ if (err) {
+ console.log("queryOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ }
+ console.log("queryOsAccountLocalIdFromUid successfully, localId: " + localId);
+ });
+ } catch (err) {
+ console.log("queryOsAccountLocalIdFromUid exception: " + JSON.stringify(err));
+ }
```
-### isOsAccountVerified(deprecated)
-
-isOsAccountVerified(localId?: number): Promise<boolean>
-
-检查指定系统帐号是否已验证,使用Promise方式异步返回结果。
+### queryOsAccountLocalIdFromUid9+
-> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9-2)
->
-> 从 API version 7开始支持。
+queryOsAccountLocalIdFromUid(uid: number): Promise<number>
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+根据uid查询对应的系统帐号ID,使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------------ |
-| localId | number | 否 | 指定的系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------ | ---- | --------- |
+| uid | number | 是 | 进程uid。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 |
+| 类型 | 说明 |
+| --------------------- | --------------------------------------- |
+| Promise<number> | Promise对象,返回指定uid对应的系统帐号ID。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid uid. |
+
+**示例:** 查询值为12345678的uid所属的系统帐号ID
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.isOsAccountVerified().then((isVerified) => {
- console.log('isOsAccountVerified, isVerified: ' + isVerified);
- }).catch((err) => {
- console.log('isOsAccountVerified err: ' + JSON.stringify(err));
- });
+ let uid = 12345678;
+ try {
+ accountManager.queryOsAccountLocalIdFromUid(uid).then((localId) => {
+ console.log("queryOsAccountLocalIdFromUid successfully, localId: " + localId);
+ }).catch((err) => {
+ console.log("queryOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('queryOsAccountLocalIdFromUid exception: ' + JSON.stringify(err));
+ }
```
-### removeOsAccount
-
-removeOsAccount(localId: number, callback: AsyncCallback<void>): void
+### queryOsAccountLocalIdFromDomain9+
-删除指定系统帐号,使用callback回调异步返回结果。
+getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+根据域帐号信息,获取与其关联的系统帐号ID。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -838,33 +1084,34 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------- | ---- | -------------------- |
-| localId | number | 是 | 要删除的系统帐号ID。 |
-| callback | AsyncCallback<void> | 是 | 回调结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | --------------------------------------- | ---- | -------------------------------------------------------------------------- |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为域帐号关联的系统帐号ID;否则为错误对象。 |
**示例:**
```js
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => {
- accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{
- console.log('removeOsAccount err:' + JSON.stringify(err));
- });
+ accountManager.queryOsAccountLocalIdFromDomain(domainInfo, (err, localId) => {
+ if (err) {
+ console.log("queryOsAccountLocalIdFromDomain failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("queryOsAccountLocalIdFromDomain successfully, localId: " + localId);
+ }
});
- } catch (e) {
- console.log('removeOsAccount exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log('queryOsAccountLocalIdFromDomain exception: ' + JSON.stringify(err));
}
```
-### removeOsAccount
-
-removeOsAccount(localId: number): Promise<void>
+### queryOsAccountLocalIdFromDomain9+
-删除指定系统帐号,使用Promise方式异步返回结果。
+queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+根据域帐号信息,获取与其关联的系统帐号的帐号ID。使用Promise异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -872,117 +1119,101 @@ removeOsAccount(localId: number): Promise<void>
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | -------------------- |
-| localId | number | 是 | 要删除的系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | --------------------------------------- | ---- | ------------ |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
**返回值:**
-| 类型 | 说明 |
-| :------------------ | :---------------------------------- |
-| Promise<void> | Promise实例,用于获取异步返回结果。 |
+| 类型 | 说明 |
+| :-------------------- | :------------------------------------- |
+| Promise<number> | Promise对象,返回域帐号关联的系统帐号ID。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
- accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
- accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
- console.log('removeOsAccount Success');
- }).catch(() => {
- console.log('removeOsAccount err: ' + JSON.stringify(err));
- });
+ accountManager.queryOsAccountLocalIdFromDomain(domainInfo).then((localId) => {
+ console.log("queryOsAccountLocalIdFromDomain successfully, localId: " + localId);
+ }).catch((err) => {
+ console.log("queryOsAccountLocalIdFromDomain failed, error: " + JSON.stringify(err));
});
- } catch (e) {
- console.log('removeOsAccount exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log("queryOsAccountLocalIdFromDomain exception: " + JSON.stringify(err));
}
```
-### setOsAccountConstraints
-
-setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void
+### queryMaxOsAccountNumber
-为指定系统帐号设置/删除约束,使用callback回调异步返回结果。
+queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+查询允许创建的系统帐号的最大数量。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ----------- | ------------------------- | ---- | -------------------------------------------- |
-| localId | number | 是 | 系统帐号ID。 |
-| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
-| enable | boolean | 是 | 设置(true)/删除(false) |
-| callback | AsyncCallback<void> | 是 | 回调结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | -------------------------------------------------------------------------------- |
+| callback | AsyncCallback<number> | 是 | 回调函数,如果查询成功,err为null,data为允许创建的系统帐号的最大数量;否则为错误对象。 |
-**示例:** 给ID为100的系统帐号设置禁止使用Wi-Fi的约束
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
try {
- accountManager.setOsAccountConstraints(localId, ['constraint.wifi'], true, (err)=>{
- console.log('setOsAccountConstraints err:' + JSON.stringify(err));
+ accountManager.queryMaxOsAccountNumber((err, maxCnt) => {
+ if (err) {
+ console.log('queryMaxOsAccountNumber failed, error:' + JSON.stringify(err));
+ } else {
+ console.log('queryMaxOsAccountNumber successfully, maxCnt:' + maxCnt);
+ }
});
- } catch (e) {
- console.log('setOsAccountConstraints exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(err));
}
```
-### setOsAccountConstraints
-
-setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void>
+### queryMaxOsAccountNumber
-为指定系统帐号设置/删除约束,使用Promise方式异步返回结果。
+queryMaxOsAccountNumber(): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+查询允许创建的系统帐号的最大数量。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| ----------- | ------------------- | ---- | -------------------------------------------- |
-| localId | number | 是 | 系统帐号ID。 |
-| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
-| enable | boolean | 是 | 设置(true)/删除(false)。 |
-
**返回值:**
-| 类型 | 说明 |
-| :------------------ | :---------------------------------- |
-| Promise<void> | Promise实例,用于获取异步返回结果。 |
+| 类型 | 说明 |
+| --------------------- | ------------------------------------------- |
+| Promise<number> | Promise对象,返回允许创建的系统帐号的最大数量。 |
-**示例:** 删除ID为100的系统帐号的禁止使用Wi-Fi的约束
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
try {
- accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
- console.log('setOsAccountConstraints Success');
+ accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
+ console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt);
}).catch((err) => {
- console.log('setOsAccountConstraints err: ' + JSON.stringify(err));
+ console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
});
- } catch (e) {
- console.log('setOsAccountConstraints exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(err));
}
```
-### setOsAccountName
-
-setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void
+### getOsAccountConstraints9+
-设置指定系统帐号的帐号名,使用callback回调异步返回结果。
+getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<string>>): void
-此接口为系统接口,三方应用不支持调用。
+获取指定系统帐号的全部约束。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -990,34 +1221,41 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback<
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| :-------- | ------------------------- | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| localName | string | 是 | 帐号名。 |
-| callback | AsyncCallback<void> | 是 | 回调结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<Array<string>> | 是 | 回调函数,如果获取成功,err为null,data为该系统帐号的全部[约束](#系统帐号约束列表);否则为错误对象。 |
-**示例:** 将ID为100的系统帐号的帐号名设置成demoName
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号的全部约束
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let newName = 'demoName';
try {
- accountManager.setOsAccountName(localId, newName, (err)=>{
- console.debug('setOsAccountName err:' + JSON.stringify(err));
+ accountManager.getOsAccountConstraints(localId, (err, constraints) => {
+ if (err) {
+ console.log("getOsAccountConstraints failed, err: " + JSON.stringify(err));
+ } else {
+ console.log("getOsAccountConstraints successfully, constraints: " + JSON.stringify(constraints));
+ }
});
- } catch (e) {
- console.log('setOsAccountName exception:' + JSON.stringify(e));
+ } catch (err) {
+ console.log('getOsAccountConstraints exception:' + JSON.stringify(err));
}
```
-### setOsAccountName
-
-setOsAccountName(localId: number, localName: string): Promise<void>
+### getOsAccountConstraints9+
-设置指定系统帐号的帐号名,使用Promise方式异步返回结果。
+getOsAccountConstraints(localId: number): Promise<Array<string>>
-此接口为系统接口,三方应用不支持调用。
+获取指定系统帐号的全部约束。使用Promise异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1025,481 +1263,539 @@ setOsAccountName(localId: number, localName: string): Promise<void>
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| --------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| localName | string | 是 | 帐号名。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------ |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :------------------ | :---------------------------------- |
-| Promise<void> | Promise实例,用于获取异步返回结果。 |
+| 类型 | 说明 |
+| ---------------------------------- | ---------------------------------------------------------- |
+| Promise<Array<string>> | Promise对象,返回指定系统帐号的全部[约束](#系统帐号约束列表)。 |
-**示例:** 将ID为100的系统帐号的帐号名设置成demoName
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号的全部约束
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let nameLimit = 'demoName';
try {
- accountManager.setOsAccountName(localId, nameLimit).then(() => {
- console.log('setOsAccountName Success');
+ accountManager.getOsAccountConstraints(localId).then((constraints) => {
+ console.log('getOsAccountConstraints, constraints: ' + constraints);
}).catch((err) => {
- console.log('setOsAccountName err: ' + JSON.stringify(err));
+ console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('setOsAccountName exception:' + JSON.stringify(e));
+ console.log('getOsAccountConstraints exception:' + JSON.stringify(e));
}
```
-### getOsAccountCount9+
+### queryAllCreatedOsAccounts
-getOsAccountCount(callback: AsyncCallback<number>): void
+queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void
-获取已创建的系统帐号数量,使用callback回调异步返回结果。
+查询已创建的所有系统帐号的信息列表。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------------ |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
+| callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调函数。如果查询成功,err为null,data为已创建的所有系统帐号的信息列表;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.getOsAccountCount((err, accountCnt)=>{
- console.log('obtains the number of all os accounts created err:' + JSON.stringify(err));
- console.log('obtains the number of all os accounts created accountCnt:' + accountCnt);
+ accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
+ console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err));
+ console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
});
} catch (e) {
- console.log('obtains the number of all os accounts created exception:' + JSON.stringify(e));
+ console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
}
```
-### getOsAccountCount9+
+### queryAllCreatedOsAccounts
-getOsAccountCount(): Promise<number>
+queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
-获取已创建的系统帐号数量,使用Promise方式异步返回结果。
+查询已创建的所有系统帐号的信息列表。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 |
+| 类型 | 说明 |
+| ----------------------------------------------------------- | --------------------------------------------- |
+| Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise对象,返回已创建的所有系统帐号的信息列表。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.getOsAccountCount().then((accountCnt) => {
- console.log('getOsAccountCount, accountCnt: ' + accountCnt);
+ accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
+ console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => {
- console.log('getOsAccountCount err: ' + JSON.stringify(err));
+ console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
});
- } catch(e) {
- console.log('getOsAccountCount exception: ' + JSON.stringify(e));
+ } catch (e) {
+ console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
}
```
-### getCreatedOsAccountsCount(deprecated)
-
-getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
-
-获取已创建的系统帐号数量,使用callback回调异步返回结果。
+### getActivatedOsAccountIds9+
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9)
->
-> 从 API version 7开始支持。
+getActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+查询当前处于激活状态的系统帐号的ID列表。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------------ |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
+| callback | AsyncCallback<Array<number>> | 是 | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统帐号的ID列表;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
- console.log('obtains the number of all os accounts created err:' + JSON.stringify(err));
- console.log('obtains the number of all os accounts created accountCnt:' + accountCnt);
- });
+ try {
+ accountManager.getActivatedOsAccountIds((err, idArray)=>{
+ console.log('getActivatedOsAccountIds err:' + JSON.stringify(err));
+ console.log('getActivatedOsAccountIds idArray length:' + idArray.length);
+ for(let i=0;i(deprecated)
-
-getCreatedOsAccountsCount(): Promise<number>
-
-获取已创建的系统帐号数量,使用Promise方式异步返回结果。
+### getActivatedOsAccountIds9+
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9-1)
->
-> 从 API version 7开始支持。
+getActivatedOsAccountIds(): Promise<Array<number>>
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+查询当前处于激活状态的系统帐号的ID列表。使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 |
+| 类型 | 说明 |
+| :--------------------------------- | :------------------------------------------------ |
+| Promise<Array<number>> | Promise对象,返回当前处于激活状态的系统帐号的ID列表。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
- console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
- }).catch((err) => {
- console.log('getCreatedOsAccountsCount err: ' + JSON.stringify(err));
- });
+ try {
+ accountManager.getActivatedOsAccountIds().then((idArray) => {
+ console.log('getActivatedOsAccountIds, idArray: ' + idArray);
+ }).catch((err) => {
+ console.log('getActivatedOsAccountIds err: ' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.log('getActivatedOsAccountIds exception:' + JSON.stringify(e));
+ }
```
-### queryOsAccountLocalIdFromProcess9+
+### createOsAccount
-queryOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
+createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void
+
+创建一个系统帐号。使用callback异步回调。
+
+**系统接口:** 此接口为系统接口。
-获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | -------------------------------------------------- |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| :-------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------- |
+| localName | string | 是 | 创建的系统帐号的名称。 |
+| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
+| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果创建成功,err为null,data为新创建的系统帐号的信息;否则为错误对象。 |
+
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid localName or type. |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.queryOsAccountLocalIdFromProcess((err, accountID) => {
- console.log('queryOsAccountLocalIdFromProcess err: ' + JSON.stringify(err));
- console.log('queryOsAccountLocalIdFromProcess accountID: ' + accountID);
+ accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
+ console.log('createOsAccount err:' + JSON.stringify(err));
+ console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromProcess exception: ' + JSON.stringify(e));
+ console.log('createOsAccount exception:' + JSON.stringify(e));
}
```
-### queryOsAccountLocalIdFromProcess9+
+### createOsAccount
-queryOsAccountLocalIdFromProcess(): Promise<number>
+createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInfo>
+
+创建一个系统帐号。使用Promise异步回调。
+
+**系统接口:** 此接口为系统接口。
-获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------------------------------- | ---- | ---------------------- |
+| localName | string | 是 | 创建的系统帐号的名称。 |
+| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
+
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ------------------------------------- |
+| Promise<[OsAccountInfo](#osaccountinfo)> | Promis对象,返回新创建的系统帐号的信息。 |
+
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid localName or type. |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.queryOsAccountLocalIdFromProcess().then((accountID) => {
- console.log('queryOsAccountLocalIdFromProcess, accountID: ' + accountID);
- }).catch((err) => {
- console.log('queryOsAccountLocalIdFromProcess err: ' + JSON.stringify(err));
+ accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => {
+ console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
+ }).catch((err) => {
+ console.log('createOsAccount err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromProcess exception: ' + JSON.stringify(e));
+ console.log('createOsAccount exception:' + JSON.stringify(e));
}
```
-### getOsAccountLocalIdFromProcess(deprecated)
+### createOsAccountForDomain8+
-getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
+createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void
-获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。
+根据域帐号信息,创建一个系统帐号并将其与域帐号关联。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | -------------------------------------------------- |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| :--------- | ---------------------------------------------------- | ---- | -------------------------------------------------------------------------- |
+| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
+| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果创建成功,err为null,data为新创建的系统帐号的信息;否则为错误对象。 |
+
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid type or domainInfo. |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
- console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err));
- console.log('getOsAccountLocalIdFromProcess accountID: ' + accountID);
- });
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
+ try {
+ accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
+ console.log('createOsAccountForDomain err:' + JSON.stringify(err));
+ console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
+ });
+ } catch (e) {
+ console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ }
```
-### getOsAccountLocalIdFromProcess(deprecated)
+### createOsAccountForDomain8+
-getOsAccountLocalIdFromProcess(): Promise<number>
+createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>
-获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
+根据传入的域帐号信息,创建与其关联的系统帐号。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9-1)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ---------------------------------------- | ---- | -------------------- |
+| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
+
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | -------------------------------------- |
+| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回新创建的系统帐号的信息。 |
+
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid type or domainInfo. |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
- console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
- }).catch((err) => {
- console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err));
- });
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
+ try {
+ accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
+ console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
+ }).catch((err) => {
+ console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ }
```
-### queryOsAccountLocalIdFromUid9+
+### getCurrentOsAccount9+
-queryOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void
+getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
-从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。
+查询当前进程所属的系统帐号的信息。使用callback异步回调。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | --------------------------------------------- |
-| uid | number | 是 | 进程uid。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
+| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统帐号信息;否则为错误对象。 |
-**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let uid = 12345678;
try {
- accountManager.queryOsAccountLocalIdFromUid(uid, (err, accountID) => {
- console.log('queryOsAccountLocalIdFromUid err: ' + JSON.stringify(err));
- console.log('queryOsAccountLocalIdFromUid: ' + accountID);
+ accountManager.getCurrentOsAccount((err, curAccountInfo)=>{
+ console.log('getCurrentOsAccount err:' + JSON.stringify(err));
+ console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromUid exception: ' + JSON.stringify(e));
+ console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
}
```
-### queryOsAccountLocalIdFromUid9+
-
-queryOsAccountLocalIdFromUid(uid: number): Promise<number>
+### getCurrentOsAccount9+
-从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
+getCurrentOsAccount(): Promise<OsAccountInfo>
-**系统能力:** SystemCapability.Account.OsAccount
+查询当前进程所属的系统帐号的信息。使用Promise异步回调。
-**参数:**
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
-| 参数名 | 类型 | 必填 | 说明 |
-| ------ | ------ | ---- | --------- |
-| uid | number | 是 | 进程uid。 |
+**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ----------------------------------------- |
+| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回当前进程所属的系统帐号信息。 |
-**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let uid = 12345678;
try {
- accountManager.queryOsAccountLocalIdFromUid(uid).then((accountID) => {
- console.log('queryOsAccountLocalIdFromUid: ' + accountID);
+ accountManager.getCurrentOsAccount().then((accountInfo) => {
+ console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('queryOsAccountLocalIdFromUid err: ' + JSON.stringify(err));
+ console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromUid exception: ' + JSON.stringify(e));
+ console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
}
```
-### getOsAccountLocalIdFromUid(deprecated)
+### queryOsAccountById
-getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void
+queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void
-从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。
+查询指定系统帐号的信息。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | --------------------------------------------- |
-| uid | number | 是 | 进程uid。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------------------ |
+| localId | number | 是 | 要查询的系统帐号的ID。 |
+| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果查询成功,err为null,data为查到的系统帐号的信息;否则为错误对象。 |
-**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 查询ID为100的系统帐号信息
```js
let accountManager = account_osAccount.getAccountManager();
- let uid = 12345678;
- accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
- console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err));
- console.log('getOsAccountLocalIdFromUid: ' + accountID);
- });
+ let localId = 100;
+ try {
+ accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
+ console.log('queryOsAccountById err:' + JSON.stringify(err));
+ console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
+ });
+ } catch (e) {
+ console.log('queryOsAccountById exception:' + JSON.stringify(e));
+ }
```
-### getOsAccountLocalIdFromUid(deprecated)
+### queryOsAccountById
-getOsAccountLocalIdFromUid(uid: number): Promise<number>
+queryOsAccountById(localId: number): Promise<OsAccountInfo>
-从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
+查询指定系统帐号的信息。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9-1)
->
-> 从 API version 7开始支持。
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------ | ------ | ---- | --------- |
-| uid | number | 是 | 进程uid。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | -------------------- |
+| localId | number | 是 | 要查询的系统帐号的ID |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ------------------------------------ |
+| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回查到的系统帐号的信息。 |
-**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 查询ID为100的系统帐号信息
```js
let accountManager = account_osAccount.getAccountManager();
- let uid = 12345678;
- accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
- console.log('getOsAccountLocalIdFromUid: ' + accountID);
- }).catch((err) => {
- console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err));
- });
+ let localId = 100;
+ try {
+ accountManager.queryOsAccountById(localId).then((accountInfo) => {
+ console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
+ }).catch((err) => {
+ console.log('queryOsAccountById err: ' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.log('queryOsAccountById exception:' + JSON.stringify(e));
+ }
```
-### queryOsAccountLocalIdFromDomain9+
-
-queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void
+### getOsAccountType9+
-根据域帐号信息,获取与其关联的系统帐号的帐号ID。
+getOsAccountType(callback: AsyncCallback<OsAccountType>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS
+查询当前进程所属的系统帐号的帐号类型。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
+| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统帐号的帐号类型;否则为错误对象。 |
**示例:**
```js
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.queryOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
- console.log('queryOsAccountLocalIdFromDomain: ' + JSON.stringify(err));
- console.log('queryOsAccountLocalIdFromDomain: ' + accountID);
+ accountManager.getOsAccountType((err, accountType) => {
+ console.log('getOsAccountType err: ' + JSON.stringify(err));
+ console.log('getOsAccountType accountType: ' + accountType);
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromDomain: ' + JSON.stringify(e));
+ console.log('getOsAccountType exception: ' + JSON.stringify(e));
}
```
-### queryOsAccountLocalIdFromDomain9+
-
-queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>
+### getOsAccountType9+
-根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
+getOsAccountType(): Promise<OsAccountType>
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS
+查询当前进程所属的系统帐号的帐号类型。使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | --------------------------------------- | ---- | ------------ |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
-
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ----------------------------------------------- |
+| Promise<[OsAccountType](#osaccounttype)> | Promise对象,返回当前进程所属的系统帐号的帐号类型。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
- accountManager.queryOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
- console.log('queryOsAccountLocalIdFromDomain: ' + accountID);
+ accountManager.getOsAccountType().then((accountType) => {
+ console.log('getOsAccountType, accountType: ' + accountType);
}).catch((err) => {
- console.log('queryOsAccountLocalIdFromDomain err: ' + JSON.stringify(err));
+ console.log('getOsAccountType err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryOsAccountLocalIdFromDomain exception: ' + JSON.stringify(e));
+ console.log('getOsAccountType exception: ' + JSON.stringify(e));
}
```
-### getOsAccountLocalIdFromDomain(deprecated)
-
-getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void
+### queryDistributedVirtualDeviceId9+
-根据域帐号信息,获取与其关联的系统帐号的帐号ID。
+queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9)
->
-> 从 API version 8开始支持。
+获取分布式虚拟设备ID。使用callback异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1507,160 +1803,195 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
+| callback | AsyncCallback<string> | 是 | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
**示例:**
```js
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager();
- accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
- console.log('getOsAccountLocalIdFromDomain: ' + JSON.stringify(err));
- console.log('getOsAccountLocalIdFromDomain: ' + accountID);
- });
+ try {
+ accountManager.queryDistributedVirtualDeviceId((err, virtualID) => {
+ console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID);
+ });
+ } catch (e) {
+ console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
+ }
```
-### getOsAccountLocalIdFromDomain(deprecated)
-
-getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>
+### queryDistributedVirtualDeviceId9+
-根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
+queryDistributedVirtualDeviceId(): Promise<string>
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9-1)
->
-> 从 API version 8开始支持。
+获取分布式虚拟设备ID。使用Promise异步回调。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | --------------------------------------- | ---- | ------------ |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
-
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 |
+| 类型 | 说明 |
+| --------------------- | --------------------------------- |
+| Promise<string> | Promise对象,返回分布式虚拟设备ID。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
- accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
- console.log('getOsAccountLocalIdFromDomain: ' + accountID);
- }).catch((err) => {
- console.log('getOsAccountLocalIdFromDomain err: ' + JSON.stringify(err));
- });
+ try {
+ accountManager.queryDistributedVirtualDeviceId().then((virtualID) => {
+ console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
+ }).catch((err) => {
+ console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
+ }
```
-### queryMaxOsAccountNumber
+### getOsAccountProfilePhoto
-queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
+getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void
+
+获取指定系统帐号的头像信息。使用callback异步回调。
-查询允许创建的系统帐号的最大数量,使用callback回调异步返回结果。
+**系统接口:** 此接口为系统接口。
-此接口为系统接口,三方应用不支持调用。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------------------ |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<string> | 是 | 回调函数。如果获取成功,err为null,data为指定系统帐号的头像信息;否则为错误对象。 |
-**示例:**
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号的头像
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
try {
- accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
- console.log('queryMaxOsAccountNumber err:' + JSON.stringify(err));
- console.log('queryMaxOsAccountNumber maxCnt:' + maxCnt);
+ accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
+ console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err));
+ console.log('get photo:' + photo + ' by localId: ' + localId);
});
} catch (e) {
- console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(e));
+ console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
}
```
-### queryMaxOsAccountNumber
+### getOsAccountProfilePhoto
-queryMaxOsAccountNumber(): Promise<number>
+getOsAccountProfilePhoto(localId: number): Promise<string>
+
+获取指定系统帐号的头像信息。使用Promise异步回调。
-查询允许创建的系统帐号的最大数量,使用Promise方式异步返回结果。
+**系统接口:** 此接口为系统接口。
-此接口为系统接口,三方应用不支持调用。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------ |
+| localId | number | 是 | 系统帐号ID。 |
+
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 |
+| 类型 | 说明 |
+| --------------------- | -------------------------------------- |
+| Promise<string> | Promise对象,返回指定系统帐号的头像信息。 |
-**示例:**
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号的头像
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
try {
- accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
- console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
+ accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
+ console.log('getOsAccountProfilePhoto: ' + photo);
}).catch((err) => {
- console.log('queryMaxOsAccountNumber err: ' + JSON.stringify(err));
+ console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(e));
+ console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
}
```
-### getOsAccountConstraints9+
+### setOsAccountProfilePhoto
-getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<string>>): void
+setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void
-获取指定系统帐号的全部约束,使用callback回调异步返回结果。
+为指定系统帐号设置头像信息。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------- | ---- | ------------ |
+| localId | number | 是 | 系统帐号ID。 |
+| photo | string | 是 | 头像信息。 |
+| callback | AsyncCallback<void> | 是 | 回调结果。 |
+
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
-**示例:** 获取ID为100的系统帐号的全部约束
+**示例:** 给ID为100的系统帐号设置头像
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
+ let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
+ 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
+ '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
try {
- accountManager.getOsAccountConstraints(localId, (err, constraints)=>{
- console.log('getOsAccountConstraints err:' + JSON.stringify(err));
- console.log('getOsAccountConstraints:' + JSON.stringify(constraints));
+ accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
+ console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
});
} catch (e) {
- console.log('getOsAccountConstraints exception:' + JSON.stringify(e));
+ console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
}
```
-### getOsAccountConstraints9+
+### setOsAccountProfilePhoto
-getOsAccountConstraints(localId: number): Promise<Array<string>>
+setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
-获取指定系统帐号的全部约束,使用Promise方式异步返回结果。
+为指定系统帐号设置头像信息。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
@@ -1669,291 +2000,339 @@ getOsAccountConstraints(localId: number): Promise<Array<string>>
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
+| photo | string | 是 | 头像信息。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------- | :----------------------------------------------------------- |
-| Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
+| 类型 | 说明 |
+| :------------------ | :----------------------------------- |
+| Promise<void> | Promise对象。无返回结果的Promise对象。 |
-**示例:** 获取ID为100的系统帐号的全部约束
+**错误码:**
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+| 12300004 | Restricted Account. |
+
+**示例:** 给ID为100的系统帐号设置头像
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
+ let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
+ 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
+ '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
try {
- accountManager.getOsAccountConstraints(localId).then((constraints) => {
- console.log('getOsAccountConstraints, constraints: ' + constraints);
+ accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
+ console.log('setOsAccountProfilePhoto success');
}).catch((err) => {
- console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
+ console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getOsAccountConstraints exception:' + JSON.stringify(e));
+ console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
}
```
-### getOsAccountAllConstraints(deprecated)
-
-getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void
-
-获取指定系统帐号的全部约束,使用callback回调异步返回结果。
+### queryOsAccountLocalIdBySerialNumber9+
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9)
->
-> 从 API version 7开始支持。
+queryOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+通过SN码查询与其关联的系统帐号的帐号ID。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------ | --------------------------- | ---- | ---------------------------------------------------------------------------- |
+| serialNumber | number | 是 | 帐号SN码。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果成功,err为null,data为与SN码关联的系统帐号的帐号ID;否则为错误对象。 |
-**示例:** 获取ID为100的系统帐号的全部约束
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid serialNumber. |
+
+**示例:** 查询与SN码12345关联的系统帐号的ID
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
- console.log('getOsAccountAllConstraints err:' + JSON.stringify(err));
- console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints));
- });
+ let serialNumber = 12345;
+ try {
+ accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
+ console.log('ger localId err:' + JSON.stringify(err));
+ console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
+ });
+ } catch (e) {
+ console.log('ger localId exception:' + JSON.stringify(e));
+ }
```
-### getOsAccountAllConstraints(deprecated)
-
-getOsAccountAllConstraints(localId: number): Promise<Array<string>>
-
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9-1)
->
-> 从 API version 7开始支持。
+### queryOsAccountLocalIdBySerialNumber9+
-获取指定系统帐号的全部约束,使用Promise方式异步返回结果。
+queryOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+通过SN码查询与其关联的系统帐号的帐号ID。使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------ | ------ | ---- | ---------- |
+| serialNumber | number | 是 | 帐号SN码。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------- | :----------------------------------------------------------- |
-| Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
+| 类型 | 说明 |
+| :-------------------- | :------------------- ----------------------- |
+| Promise<number> | Promise对象,返回与SN码关联的系统帐号的帐号ID。 |
-**示例:** 获取ID为100的系统帐号的全部约束
+**错误码:**
+| 错误码ID | 错误信息 |
+| 12300002 | Invalid serialNumber. |
+
+**示例:** 查询与SN码12345关联的系统帐号的ID
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
- console.log('getOsAccountAllConstraints, constraints: ' + constraints);
- }).catch((err) => {
- console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
- });
+ let serialNumber = 12345;
+ try {
+ accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
+ console.log('queryOsAccountLocalIdBySerialNumber localId: ' + localId);
+ }).catch((err) => {
+ console.log('queryOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.log('queryOsAccountLocalIdBySerialNumber exception: ' + JSON.stringify(e));
+ }
```
-### queryAllCreatedOsAccounts
-
-queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void
+### querySerialNumberByOsAccountLocalId9+
-查询已创建的所有系统帐号的信息列表,使用callback回调异步返回结果。
+querySerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+通过系统帐号ID获取与该系统帐号关联的SN码。使用callback异步回调。
**系统能力:** SystemCapability.Account.OsAccount
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
-
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
-| callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果获取成功,err为null,data为与该系统帐号关联的SN码;否则为错误对象。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号关联的SN码
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
try {
- accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
- console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err));
- console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
+ accountManager.querySerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
+ console.log('ger serialNumber err:' + JSON.stringify(err));
+ console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
});
} catch (e) {
- console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
+ console.log('ger serialNumber exception:' + JSON.stringify(e));
}
```
-### queryAllCreatedOsAccounts
-
-queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
+### querySerialNumberByOsAccountLocalId9+
-查询已创建的所有系统帐号的信息列表,使用Promise方式异步返回结果。
+querySerialNumberByOsAccountLocalId(localId: number): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+通过系统帐号ID获取与该系统帐号关联的SN码。使用Promise异步回调。
**系统能力:** SystemCapability.Account.OsAccount
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ----------- |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :---------------------------------------------------------- | :----------------------------------------------------------- |
-| Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 |
+| 类型 | 说明 |
+| :-------------------- | :------------------------------------- |
+| Promise<number> | Promise对象,返回与该系统帐号关联的SN码。 |
-**示例:**
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | ------------------- |
+| 12300002 | Invalid localId. |
+| 12300003 | Account not exists. |
+
+**示例:** 获取ID为100的系统帐号关联的SN码
```js
let accountManager = account_osAccount.getAccountManager();
+ let localId = 100;
try {
- accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
- console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
+ accountManager.querySerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
+ console.log('querySerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err) => {
- console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
+ console.log('querySerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
+ console.log('querySerialNumberByOsAccountLocalId exception:' + JSON.stringify(e));
}
```
-### getActivatedOsAccountIds9+
+### on
-getActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void
+on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void
+
+订阅系统帐号的变动信息。使用callback异步回调。
+
+**系统接口:** 此接口为系统接口。
-查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。
+**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
-| callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 |
+| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 |
+| callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
+ function onCallback(receiveLocalId){
+ console.log('receive localId:' + receiveLocalId);
+ }
try {
- accountManager.getActivatedOsAccountIds((err, idArray)=>{
- console.log('getActivatedOsAccountIds err:' + JSON.stringify(err));
- console.log('getActivatedOsAccountIds idArray length:' + idArray.length);
- for(let i=0;i9+
+### off
-getActivatedOsAccountIds(): Promise<Array<number>>
+off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void
-查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。
+取消订阅系统帐号的变动信息。使用callback异步回调。
+
+**系统接口:** 此接口为系统接口。
+
+**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**系统能力:** SystemCapability.Account.OsAccount
-**返回值:**
+**参数:**
-| 类型 | 说明 |
-| :--------------------------------- | :----------------------------------------------------------- |
-| Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 |
+| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
+| callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
+ function offCallback(){
+ console.log('off enter')
+ }
try {
- accountManager.getActivatedOsAccountIds().then((idArray) => {
- console.log('getActivatedOsAccountIds, idArray: ' + idArray);
- }).catch((err) => {
- console.log('getActivatedOsAccountIds err: ' + JSON.stringify(err));
- });
+ accountManager.off('activating', 'osAccountOnOffNameA', offCallback);
} catch (e) {
- console.log('getActivatedOsAccountIds exception:' + JSON.stringify(e));
+ console.log('off exception:' + JSON.stringify(e));
}
```
-### queryActivatedOsAccountIds(deprecated)
+### getBundleIdFromUid9+
-queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void
+getBundleIdFromUid(uid: number, callback: AsyncCallback<number>): void;
-查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。
+通过uid查询对应的bundleId,使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9)
->
-> 从 API version 8开始支持。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
-| callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | ------------------------------------------------------------------------ |
+| uid | number | 是 | 进程uid。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为与uid对应的bundleId;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.queryActivatedOsAccountIds((err, idArray)=>{
- console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err));
- console.log('queryActivatedOsAccountIds idArray length:' + idArray.length);
- for(let i=0;i {
+ console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err));
+ console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId));
+ });
+ } catch (e) {
+ console.info('getBundleIdFromUid exception:' + JSON.stringify(e));
+ }
```
+### getBundleIdFromUid9+
-### queryActivatedOsAccountIds(deprecated)
-
-queryActivatedOsAccountIds(): Promise<Array<number>>
+getBundleIdFromUid(uid: number): Promise<number>;
-> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9-1)
->
-> 从 API version 8开始支持。
+通过uid查询对应的bundleId,使用Promis异步回调。
-查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------ |
+| uid | number | 是 | 进程uid。 |
+
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------- | :----------------------------------------------------------- |
-| Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
+| 类型 | 说明 |
+| --------------------- | ------------------------------------ |
+| Promise<number> | Promise对象,返回与uid对应的bundleId。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.queryActivatedOsAccountIds().then((idArray) => {
- console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
- }).catch((err) => {
- console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
- });
- ```
-
-### createOsAccount
+ let testUid = 1000000;
+ try {
+ accountManager.getBundleIdFromUid(testUid).then((result) => {
+ console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result));
+ }).catch((err)=>{
+ console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err));
+ });
+ } catch (e) {
+ console.info('getBundleIdFromUid exception:' + JSON.stringify(e));
+ }
+ ```
-createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void
+### isMainOsAccount9+
+
+isMainOsAccount(callback: AsyncCallback<boolean>): void;
-创建一个系统帐号,使用callback回调异步返回结果。
+查询当前进程是否处于主用户,使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1961,73 +2340,62 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
-| localName | string | 是 | 创建的系统帐号的名称。 |
-| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
-| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | 是 | 回调函数,返回true表示当前帐号为主帐号,返回false表示当前帐号非主帐号。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
- console.log('createOsAccount err:' + JSON.stringify(err));
- console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
+ accountManager.isMainOsAccount((err,result)=>{
+ console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
+ console.info('isMainOsAccount result:' + JSON.stringify(result));
});
} catch (e) {
- console.log('createOsAccount exception:' + JSON.stringify(e));
+ console.info('isMainOsAccount exception:' + JSON.stringify(e));
}
```
+### isMainOsAccount9+
-### createOsAccount
-
-createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInfo>
+isMainOsAccount(): Promise<boolean>;
-创建一个系统帐号,使用Promise方式异步返回结果。
+查询当前进程是否处于主用户,使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| --------- | ------------------------------- | ---- | ---------------------- |
-| localName | string | 是 | 创建的系统帐号的名称。 |
-| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
-
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
+| 类型 | 说明 |
+| ---------------------- | --------------------------------------------------------------------- |
+| Promise<boolean> | Promise对象,返回true表示当前帐号为主帐号,返回false表示当前帐号非主帐号。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
try {
- accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => {
- console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
- }).catch((err) => {
- console.log('createOsAccount err: ' + JSON.stringify(err));
+ accountManager.isMainOsAccount().then((result) => {
+ console.info('isMainOsAccount result:' + JSON.stringify(result));
+ }).catch((err)=>{
+ console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
});
} catch (e) {
- console.log('createOsAccount exception:' + JSON.stringify(e));
+ console.info('isMainOsAccount exception:' + JSON.stringify(e));
}
```
+### queryOsAccountConstraintSourceTypes9+
-### createOsAccountForDomain8+
-
-createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void
+queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void;
-根据域帐号信息,创建一个系统帐号并将其与域帐号关联,使用callback回调异步返回结果。
+查询指定系统帐号的指定约束来源信息,使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -2035,34 +2403,33 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
-| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
-| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| localId | number | 是 | 要查询的系统帐号ID |
+| constraint | string | 是 | 要查询的[约束](#系统帐号约束列表)名称 |
+| callback | AsyncCallback<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | 是 | 回调函数。如果成功,err为null,data为指定系统帐号的指定[约束](#系统帐号约束列表)来源信息;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
- accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
- console.log('createOsAccountForDomain err:' + JSON.stringify(err));
- console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
+ accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{
+ console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err));
+ console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
});
} catch (e) {
- console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
}
```
-### createOsAccountForDomain8+
+### queryOsAccountConstraintSourceTypes9+
-createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>
+queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise<Array<ConstraintSourceTypeInfo>>;
-根据传入的域帐号信息,创建与其关联的系统帐号,使用Promise方式异步返回结果。
+查询指定系统帐号的指定约束来源信息,使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -2070,293 +2437,310 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | --------------------------------------- | ---- | ---------------------- |
-| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
-| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------ |
+| localId | number | 是 | 要查询的系统帐号ID |
+| constraint | string | 是 | 要查询的[约束](#系统帐号约束列表)名称 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
+| 类型 | 说明 |
+| :-------------------- | :----------------------------------------------------------- |
+| Promise<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | Promise对象,返回指定系统帐号的指定[约束](#系统帐号约束列表)来源信息。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
- accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
- console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
- }).catch((err) => {
- console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
+ accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => {
+ console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result));
+ }).catch((err)=>{
+ console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err));
});
} catch (e) {
- console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
}
```
-### getCurrentOsAccount9+
+### isMultiOsAccountEnable(deprecated)
-getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
+isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
-查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。
+判断是否支持多系统帐号。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
-| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示支持多系统帐号;返回false表示不支持。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.getCurrentOsAccount((err, curAccountInfo)=>{
- console.log('getCurrentOsAccount err:' + JSON.stringify(err));
- console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
- });
- } catch (e) {
- console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
- }
+ accountManager.isMultiOsAccountEnable((err, isEnalbed) => {
+ if (err) {
+ console.log("isMultiOsAccountEnable failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("isMultiOsAccountEnable successfully, isEnabled: " + isEnabled);
+ }
+ });
```
-### getCurrentOsAccount9+
+### isMultiOsAccountEnable(deprecated)
-getCurrentOsAccount(): Promise<OsAccountInfo>
+isMultiOsAccountEnable(): Promise<boolean>
-查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。
+判断是否支持多系统帐号。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9-1)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 |
+| 类型 | 说明 |
+| :--------------------- | :--------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示支持多系统帐号;返回false表示不支持。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.getCurrentOsAccount().then((accountInfo) => {
- console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
- }).catch((err) => {
- console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
- }
+ accountManager.isMultiOsAccountEnable().then((isEnabled) => {
+ console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
+ }).catch((err) => {
+ console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
+ });
```
-### queryCurrentOsAccount(deprecated)
-queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
+### isOsAccountActived(deprecated)
+
+isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void
-查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。
+判断指定系统帐号是否处于激活状态。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9)
+> **说明:** 从API version 9开始废弃, 建议使用[checkOsAccountActivated](#checkosaccountactivated9)
>
> 从 API version 7开始支持。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
-| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示帐号已激活;返回false表示帐号未激活。 |
-**示例:**
+**示例:** 判断ID为100的系统帐号是否处于激活状态
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
- console.log('queryCurrentOsAccount err:' + JSON.stringify(err));
- console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
+ let localId = 100;
+ accountManager.isOsAccountActived(localId, (err, isActived) => {
+ if (err) {
+ console.log('isOsAccountActived failed, err:' + JSON.stringify(err));
+ } else {
+ console.log('isOsAccountActived successfully, isActived:' + isActived);
+ }
});
```
-### queryCurrentOsAccount(deprecated)
+### isOsAccountActived(deprecated)
-queryCurrentOsAccount(): Promise<OsAccountInfo>
+isOsAccountActived(localId: number): Promise<boolean>
-查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。
+判断指定系统帐号是否处于激活状态。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9-1)
+> **说明:** 从API version 9开始废弃, 建议使用[checkOsAccountActivated](#checkosaccountactivated9-1)
>
> 从 API version 7开始支持。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | --------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 |
+| 类型 | 说明 |
+| --------------------- | ----------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示帐号已激活;返回false表示帐号未激活。 |
-**示例:**
+**示例:** 判断ID为100的系统帐号是否处于激活状态
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.queryCurrentOsAccount().then((accountInfo) => {
- console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
+ let localId = 100;
+ accountManager.isOsAccountActived(localId).then((isActived) => {
+ console.log('isOsAccountActived successfully, isActived: ' + isActived);
}).catch((err) => {
- console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
+ console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
});
```
-### queryOsAccountById
+### isOsAccountConstraintEnable(deprecated)
-queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void
+isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void
-查询指定系统帐号的信息,使用callback回调异步返回结果。
+判断指定系统帐号是否具有指定约束。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+> **说明:** 从API version 9开始废弃,建议使用[checkConstraintEnabled](#checkconstraintenabled9)
+>
+> 从 API version 7开始支持。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- |
-| localId | number | 是 | 要查询的系统帐号的ID |
-| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是查到的系统帐号的信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
-**示例:** 查询ID为100的系统帐号信息
+**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- try {
- accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
- console.log('queryOsAccountById err:' + JSON.stringify(err));
- console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
- });
- } catch (e) {
- console.log('queryOsAccountById exception:' + JSON.stringify(e));
- }
+ let constraint = "constraint.wifi";
+ accountManager.isOsAccountConstraintEnable(localId, constraint, (err, isEnabled) => {
+ if (err) {
+ console.log("isOsAccountConstraintEnable failed, error:" + JSON.stringify(err));
+ } else {
+ console.log("isOsAccountConstraintEnable successfully, isEnabled:" + isEnabled);
+ }
+ });
```
-### queryOsAccountById
+### isOsAccountConstraintEnable(deprecated)
-queryOsAccountById(localId: number): Promise<OsAccountInfo>
+isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean>
-查询指定系统帐号的信息,使用Promise方式异步返回结果。
+判断指定系统帐号是否具有指定约束。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+> **说明:** 从API version 9开始废弃,建议使用[checkConstraintEnabled](#checkconstraintenabled9-1)
+>
+> 从 API version 7开始支持。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | -------------------- |
-| localId | number | 是 | 要查询的系统帐号的ID |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ------ | ---- | ---------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 |
+| 类型 | 说明 |
+| ---------------------- | --------------------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
-**示例:** 查询ID为100的系统帐号信息
+**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- try {
- accountManager.queryOsAccountById(localId).then((accountInfo) => {
- console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
- }).catch((err) => {
- console.log('queryOsAccountById err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('queryOsAccountById exception:' + JSON.stringify(e));
- }
+ let constraint = "constraint.wifi";
+ accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled) => {
+ console.log("isOsAccountConstraintEnable successfully, isEnabled: " + isEnabled);
+ }).catch((err) => {
+ console.log("isOsAccountConstraintEnable err: " + JSON.stringify(err));
+ });
```
-### getOsAccountType9+
+### isTestOsAccount(deprecated)
-getOsAccountType(callback: AsyncCallback<OsAccountType>): void
+isTestOsAccount(callback: AsyncCallback<boolean>): void
+
+检查当前系统帐号是否为测试帐号。使用callback异步回调。
-查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。
+> **说明:** 从API version 9开始废弃,建议使用[checkOsAccountTestable](#checkosaccounttestable9)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
-| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前帐号为测试帐号;返回false表示当前帐号非测试帐号。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.getOsAccountType((err, accountType) => {
- console.log('getOsAccountType err: ' + JSON.stringify(err));
- console.log('getOsAccountType accountType: ' + accountType);
- });
- } catch (e) {
- console.log('getOsAccountType exception: ' + JSON.stringify(e));
- }
+ accountManager.isTestOsAccount((err, isTestable) => {
+ if (err) {
+ console.log("isTestOsAccount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("isTestOsAccount successfully, isTestable: " + isTestable);
+ }
+ });
```
-### getOsAccountType9+
+### isTestOsAccount(deprecated)
-getOsAccountType(): Promise<OsAccountType>
+isTestOsAccount(): Promise<boolean>
-查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。
+检查当前系统帐号是否为测试帐号。使用Promise异步回调。
+
+> **说明:** 从API version 9开始废弃,建议使用[checkOsAccountTestable](#checkosaccounttestable9-1)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 |
+| 类型 | 说明 |
+| ---------------------- | ------------------------------------------------------------------------ |
+| Promise<boolean> | Promise对象。返回true表示当前帐号为测试帐号;返回false表示当前帐号非测试帐号。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.getOsAccountType().then((accountType) => {
- console.log('getOsAccountType, accountType: ' + accountType);
- }).catch((err) => {
- console.log('getOsAccountType err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('getOsAccountType exception: ' + JSON.stringify(e));
- }
+ accountManager.isTestOsAccount().then((isTestable) => {
+ console.log("isTestOsAccount successfully, isTestable: " + isTestable);
+ }).catch((err) => {
+ console.log("isTestOsAccount failed, error: " + JSON.stringify(err));
+ });
```
-### getOsAccountTypeFromProcess(deprecated)
+### isOsAccountVerified(deprecated)
-getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
+isOsAccountVerified(callback: AsyncCallback<boolean>): void
-查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。
+检查当前系统帐号是否已验证。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9)
+> **说明:** 从API version 9开始废弃,建议使用[checkOsAccountVerified](#checkosaccountverified9)
>
> 从 API version 7开始支持。
@@ -2364,871 +2748,807 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
-| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示指定帐号已验证;返回false表示指定帐号未验证。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getOsAccountTypeFromProcess((err, accountType) => {
- console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
- console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
+ accountManager.isOsAccountVerified((err, isVerified) => {
+ if (err) {
+ console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ }
});
```
-### getOsAccountTypeFromProcess(deprecated)
+### isOsAccountVerified(deprecated)
-getOsAccountTypeFromProcess(): Promise<OsAccountType>
+isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void
-查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。
+检查指定系统帐号是否已验证。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9-1)
+> **说明:** 从API version 9开始废弃,建议使用[checkOsAccountVerified](#checkosaccountverified9-1)
>
> 从 API version 7开始支持。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+
**系统能力:** SystemCapability.Account.OsAccount
-**返回值:**
+**参数:**
-| 类型 | 说明 |
-| :--------------------------------------------- | :----------------------------------------------------------- |
-| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
+| localId | number | 否 | 系统帐号ID。 |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示指定帐号已验证;返回false表示指定帐号未验证。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getOsAccountTypeFromProcess().then((accountType) => {
- console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
- }).catch((err) => {
- console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
+ let localId = 100;
+ accountManager.isOsAccountVerified(localId, (err, isVerified) => {
+ if (err) {
+ console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ }
});
```
-### queryDistributedVirtualDeviceId9+
+### isOsAccountVerified(deprecated)
-queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
+isOsAccountVerified(localId?: number): Promise<boolean>
+
+检查指定系统帐号是否已验证。使用Promise异步回调。
-获取分布式虚拟设备ID,使用callback回调异步返回结果。
+> **说明:** 从API version 9开始废弃,建议使用[checkOsAccountVerified](#checkosaccountverified9-2)
+>
+> 从 API version 7开始支持。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 |
-
-**示例:**
-
- ```js
- let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.queryDistributedVirtualDeviceId((err, virtualID) => {
- console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
- console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID);
- });
- } catch (e) {
- console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
- }
- ```
-
-### queryDistributedVirtualDeviceId9+
-
-queryDistributedVirtualDeviceId(): Promise<string>
-
-获取分布式虚拟设备ID,使用Promise方式异步返回结果。
-
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
-
-**系统能力:** SystemCapability.Account.OsAccount
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ---------------------------------------------------------------- |
+| localId | number | 否 | 系统帐号ID。不填则检查当前系统帐号是否已验证。 |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 |
+| 类型 | 说明 |
+| ---------------------- | ----------------------------------------------------------------- |
+| Promise<boolean> | Promise对象。返回true表示指定帐号已验证;返回false表示指定帐号未验证。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.queryDistributedVirtualDeviceId().then((virtualID) => {
- console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
- }).catch((err) => {
- console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
- }
+ accountManager.isOsAccountVerified(localId).then((isVerified) => {
+ console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ }).catch((err) => {
+ console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ });
```
-### getDistributedVirtualDeviceId(deprecated)
+### getCreatedOsAccountsCount(deprecated)
-getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
+getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
-获取分布式虚拟设备ID,使用callback回调异步返回结果。
+获取已创建的系统帐号数量。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9)
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9)
>
> 从 API version 7开始支持。
-**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
+| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为已创建的系统帐号的数量;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
- console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
- console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
+ accountManager.getCreatedOsAccountsCount((err, count)=>{
+ if (err) {
+ console.log("getCreatedOsAccountsCount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getCreatedOsAccountsCount successfully, count: " + count);
+ }
});
```
-### getDistributedVirtualDeviceId(deprecated)
+### getCreatedOsAccountsCount(deprecated)
-getDistributedVirtualDeviceId(): Promise<string>
+getCreatedOsAccountsCount(): Promise<number>
-获取分布式虚拟设备ID,使用Promise方式异步返回结果。
+获取已创建的系统帐号数量,使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1)
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9-1)
>
> 从 API version 7开始支持。
-**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 |
+| 类型 | 说明 |
+| --------------------- | -------------------------------------- |
+| Promise<number> | Promise对象,返回已创建的系统帐号的数量。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
- console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
+ accountManager.getCreatedOsAccountsCount().then((count) => {
+ console.log("getCreatedOsAccountsCount successfully, count: " + count);
}).catch((err) => {
- console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ console.log("getCreatedOsAccountsCount failed, error: " + JSON.stringify(err));
});
```
-### getOsAccountProfilePhoto
-
-getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void
+### getOsAccountLocalIdFromProcess(deprecated)
-获取指定系统帐号的头像信息,使用callback回调异步返回结果。
+getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+获取当前进程所属的系统帐号ID,使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ---------------------------------------- |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<string> | 是 | 回调结果,返回的是该系统帐号的头像信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
+| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为当前进程所属的系统帐号ID;否则为错误对象。 |
-**示例:** 获取ID为100的系统帐号的头像
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- try {
- accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
- console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err));
- console.log('get photo:' + photo + ' by localId: ' + localId);
- });
- } catch (e) {
- console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
- }
+ accountManager.getOsAccountLocalIdFromProcess((err, localId) => {
+ if (err) {
+ console.log("getOsAccountLocalIdFromProcess failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getOsAccountLocalIdFromProcess successfully, localId: " + localId);
+ }
+ });
```
-### getOsAccountProfilePhoto
-
-getOsAccountProfilePhoto(localId: number): Promise<string>
+### getOsAccountLocalIdFromProcess(deprecated)
-获取指定系统帐号的头像信息,使用Promise方式异步返回结果。
+getOsAccountLocalIdFromProcess(): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+获取当前进程所属的系统帐号ID,使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9-1)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
-
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<string> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 |
+| 类型 | 说明 |
+| :-------------------- | :--------------------------------------- |
+| Promise<number> | Promise对象,返回当前进程所属的系统帐号ID。 |
-**示例:** 获取ID为100的系统帐号的头像
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- try {
- accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
- console.log('getOsAccountProfilePhoto: ' + photo);
- }).catch((err) => {
- console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
- }
+ accountManager.getOsAccountLocalIdFromProcess().then((localId) => {
+ console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
+ }).catch((err) => {
+ console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
+ });
```
-### setOsAccountProfilePhoto
-
-setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void
+### getOsAccountLocalIdFromUid(deprecated)
-为指定系统帐号设置头像信息,使用callback回调异步返回结果。
+getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+根据uid查询对应的系统帐号ID。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------- | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| photo | string | 是 | 头像信息。 |
-| callback | AsyncCallback<void> | 是 | 回调结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
+| uid | number | 是 | 进程uid。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为对应的系统帐号ID;否则为错误对象。 |
-**示例:** 给ID为100的系统帐号设置头像
+**示例:** 查询值为12345678的uid所属的系统帐号ID
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
- 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
- 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
- '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
- try {
- accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
- console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
- }
+ let uid = 12345678;
+ accountManager.getOsAccountLocalIdFromUid(uid, (err, localId) => {
+ if (err) {
+ console.log("getOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getOsAccountLocalIdFromUid successfully, localId: " + localId);
+ }
+ });
```
-### setOsAccountProfilePhoto
-
-setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
+### getOsAccountLocalIdFromUid(deprecated)
-为指定系统帐号设置头像信息,使用Promise方式异步返回结果。
+getOsAccountLocalIdFromUid(uid: number): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+根据uid查询对应的系统帐号ID,使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9-1)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| photo | string | 是 | 头像信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------ | ---- | --------- |
+| uid | number | 是 | 进程uid。 |
**返回值:**
-| 类型 | 说明 |
-| :------------------ | :---------------------------------- |
-| Promise<void> | Promise实例,用于获取异步返回结果。 |
+| 类型 | 说明 |
+| :-------------------- | :----------------------------------- |
+| Promise<number> | Promise对象,返回uid对应的系统帐号ID。 |
-**示例:** 给ID为100的系统帐号设置头像
+**示例:** 查询值为12345678的uid所属的系统帐号ID
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
- 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
- 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
- '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
- try {
- accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
- console.log('setOsAccountProfilePhoto success');
- }).catch((err) => {
- console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
- }
+ let uid = 12345678;
+ accountManager.getOsAccountLocalIdFromUid(uid).then((localId) => {
+ console.log("getOsAccountLocalIdFromUid successfully, localId: " + localId);
+ }).catch((err) => {
+ console.log("getOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ });
```
-### queryOsAccountLocalIdBySerialNumber9+
+### getOsAccountLocalIdFromDomain(deprecated)
-queryOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void
+getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void
+
+根据域帐号信息,获取与其关联的系统帐号的帐号ID。使用callback异步回调。
+
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9)
+>
+> 从 API version 8开始支持。
-通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------ | --------------------------- | ---- | ------------------------------------------------ |
-| serialNumber | number | 是 | 帐号SN码。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | --------------------------------------- | ---- | --------------------------------------------------------------------------- |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
+| callback | AsyncCallback<number> | 是 | 回调函数,如果获取成功,err为null,data为域帐号关联的系统帐号ID;否则为错误对象。 |
-**示例:** 查询与SN码12345关联的系统帐号的ID
+**示例:**
```js
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager();
- let serialNumber = 12345;
- try {
- accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
- console.log('ger localId err:' + JSON.stringify(err));
- console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
- });
- } catch (e) {
- console.log('ger localId exception:' + JSON.stringify(e));
- }
+ accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, localId) => {
+ if (err) {
+ console.log("getOsAccountLocalIdFromDomain failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getOsAccountLocalIdFromDomain successfully, localId: " + localId);
+ }
+ });
```
-### queryOsAccountLocalIdBySerialNumber9+
+### getOsAccountLocalIdFromDomain(deprecated)
-queryOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
+getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>
+
+根据域帐号信息,获取与其关联的系统帐号的帐号ID。使用Promise异步回调。
+
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9-1)
+>
+> 从 API version 8开始支持。
-通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------ | ------ | ---- | ---------- |
-| serialNumber | number | 是 | 帐号SN码。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | --------------------------------------- | ---- | ------------ |
+| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| :-------------------- | :------------------------------------- |
+| Promise<number> | Promise对象,返回域帐号关联的系统帐号ID。 |
-**示例:** 查询与SN码12345关联的系统帐号的ID
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let serialNumber = 12345;
- try {
- accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
- console.log('queryOsAccountLocalIdBySerialNumber localId: ' + localId);
- }).catch((err) => {
- console.log('queryOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('queryOsAccountLocalIdBySerialNumber exception: ' + JSON.stringify(e));
- }
+ let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
+ accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId) => {
+ console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
+ }).catch((err) => {
+ console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
+ });
```
-### getOsAccountLocalIdBySerialNumber(deprecated)
+### getOsAccountAllConstraints(deprecated)
-getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void
+getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void
-通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。
+获取指定系统帐号的全部约束。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9)
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9)
>
-> 从 API version 8开始支持。
+> 从 API version 7开始支持。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------ | --------------------------- | ---- | ------------------------------------------------ |
-| serialNumber | number | 是 | 帐号SN码。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<Array<string>> | 是 | 回调函数。如果获取成功,err为null,data为指定系统帐号的全部[约束](#系统帐号约束列表);否则为错误对象。 |
-**示例:** 查询与SN码12345关联的系统帐号的ID
+**示例:** 获取ID为100的系统帐号的全部约束
```js
let accountManager = account_osAccount.getAccountManager();
- let serialNumber = 12345;
- accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
- console.log('ger localId err:' + JSON.stringify(err));
- console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
+ let localId = 100;
+ accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
+ console.log('getOsAccountAllConstraints err:' + JSON.stringify(err));
+ console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints));
});
```
-### getOsAccountLocalIdBySerialNumber(deprecated)
-
-getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
+### getOsAccountAllConstraints(deprecated)
-通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
+getOsAccountAllConstraints(localId: number): Promise<Array<string>>
-> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9-1)
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9-1)
>
-> 从 API version 8开始支持。
+> 从 API version 7开始支持。
+
+获取指定系统帐号的全部约束。使用Promise异步回调。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------ | ------ | ---- | ---------- |
-| serialNumber | number | 是 | 帐号SN码。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------ |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 |
+| 类型 | 说明 |
+| :--------------------------------- | :----------------------------------------------------------- |
+| Promise<Array<string>> | Promise对象,返回指定系统帐号的全部[约束](#系统帐号约束列表)。 |
-**示例:** 查询与SN码12345关联的系统帐号的ID
+**示例:** 获取ID为100的系统帐号的全部约束
```js
let accountManager = account_osAccount.getAccountManager();
- let serialNumber = 12345;
- accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
- console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
+ let localId = 100;
+ accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
+ console.log('getOsAccountAllConstraints, constraints: ' + constraints);
}).catch((err) => {
- console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
+ console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
});
```
-### querySerialNumberByOsAccountLocalId9+
+### queryActivatedOsAccountIds(deprecated)
-querySerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void
+queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void
+
+查询当前处于激活状态的系统帐号的ID列表。使用callback异步回调。
-通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。
+> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9)
+>
+> 从 API version 8开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
+| callback | AsyncCallback<Array<number>> | 是 | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统帐号的ID列表;否则为错误对象。 |
-**示例:** 获取ID为100的系统帐号关联的SN码
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- try {
- accountManager.querySerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
- console.log('ger serialNumber err:' + JSON.stringify(err));
- console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
- });
- } catch (e) {
- console.log('ger serialNumber exception:' + JSON.stringify(e));
- }
+ accountManager.queryActivatedOsAccountIds((err, idArray)=>{
+ console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err));
+ console.log('queryActivatedOsAccountIds idArray length:' + idArray.length);
+ for(let i=0;i9+
-
-querySerialNumberByOsAccountLocalId(localId: number): Promise<number>
+### queryActivatedOsAccountIds(deprecated)
-通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。
+queryActivatedOsAccountIds(): Promise<Array<number>>
-**系统能力:** SystemCapability.Account.OsAccount
+> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9-1)
+>
+> 从 API version 8开始支持。
-**参数:**
+查询当前处于激活状态的系统帐号的ID列表。使用Promise异步回调。
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
+**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 |
+| 类型 | 说明 |
+| ---------------------------------- | ------------------------------------------------- |
+| Promise<Array<number>> | Promise对象,返回当前处于激活状态的系统帐号的ID列表。 |
-**示例:** 获取ID为100的系统帐号关联的SN码
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- try {
- accountManager.querySerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
- console.log('querySerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
- }).catch((err) => {
- console.log('querySerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
- });
- } catch (e) {
- console.log('querySerialNumberByOsAccountLocalId exception:' + JSON.stringify(e));
- }
+ accountManager.queryActivatedOsAccountIds().then((idArray) => {
+ console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
+ }).catch((err) => {
+ console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
+ });
```
-### getSerialNumberByOsAccountLocalId(deprecated)
+### queryCurrentOsAccount(deprecated)
-getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void
+queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
-通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。
+查询当前进程所属的系统帐号的信息。使用callback异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9)
+> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9)
>
-> 从 API version 8开始支持。
+> 从 API version 7开始支持。
+
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------- | ---- | ------------------------------------------ |
-| localId | number | 是 | 系统帐号ID。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
+| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统帐号信息;否则为错误对象。 |
-**示例:** 获取ID为100的系统帐号关联的SN码
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
- console.log('ger serialNumber err:' + JSON.stringify(err));
- console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
+ accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
+ console.log('queryCurrentOsAccount err:' + JSON.stringify(err));
+ console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
});
```
-### getSerialNumberByOsAccountLocalId(deprecated)
+### queryCurrentOsAccount(deprecated)
-getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
+queryCurrentOsAccount(): Promise<OsAccountInfo>
-通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。
+查询当前进程所属的系统帐号的信息。使用Promise异步回调。
-> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9-1)
+> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9-1)
>
-> 从 API version 8开始支持。
-
-**系统能力:** SystemCapability.Account.OsAccount
+> 从 API version 7开始支持。
-**参数:**
+**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 系统帐号ID。 |
+**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ------------------------------------------ |
+| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回当前进程所属的系统帐号信息。 |
-**示例:** 获取ID为100的系统帐号关联的SN码
+**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let localId = 100;
- accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
- console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
+ accountManager.queryCurrentOsAccount().then((accountInfo) => {
+ console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
+ console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
});
```
-### on
-
-on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void
+### getOsAccountTypeFromProcess(deprecated)
-订阅系统帐号的变动信息,使用callback回调异步返回结果。
+getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
-此接口为系统接口,三方应用不支持调用。
+查询当前进程所属的系统帐号的帐号类型。使用callback异步回调。
-**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
-| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 |
-| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 |
-| callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
+| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统帐号的帐号类型;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- function onCallback(receiveLocalId){
- console.log('receive localId:' + receiveLocalId);
- }
- try {
- accountManager.on('activating', 'osAccountOnOffNameA', onCallback);
- } catch (e) {
- console.log('receive localId exception:' + JSON.stringify(e));
- }
+ accountManager.getOsAccountTypeFromProcess((err, accountType) => {
+ console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
+ console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
+ });
```
-### off
-
-off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void
+### getOsAccountTypeFromProcess(deprecated)
-取消订阅系统帐号的变动信息,使用callback回调异步返回结果。
+getOsAccountTypeFromProcess(): Promise<OsAccountType>
-此接口为系统接口,三方应用不支持调用。
+查询当前进程所属的系统帐号的帐号类型。使用Promise异步回调。
-**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
+> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9-1)
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.Account.OsAccount
-**参数:**
+**返回值:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
-| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 |
-| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
-| callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 |
+| 类型 | 说明 |
+| ---------------------------------------------- | ----------------------------------------------- |
+| Promise<[OsAccountType](#osaccounttype)> | Promise对象,返回当前进程所属的系统帐号的帐号类型。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- function offCallback(){
- console.log('off enter')
- }
- try {
- accountManager.off('activating', 'osAccountOnOffNameA', offCallback);
- } catch (e) {
- console.log('off exception:' + JSON.stringify(e));
- }
+ accountManager.getOsAccountTypeFromProcess().then((accountType) => {
+ console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
+ }).catch((err) => {
+ console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
+ });
```
-### getBundleIdFromUid9+
+### getDistributedVirtualDeviceId(deprecated)
-getBundleIdFromUid(uid: number, callback: AsyncCallback<number>): void;
+getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
-通过uid查询对应的bundleId。
+获取分布式虚拟设备ID。使用callback异步回调。
+
+> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9)
+>
+> 从 API version 7开始支持。
-此接口为系统接口,三方应用不支持调用。
+**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
-| uid | number | 是 | 进程uid。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与uid对应的bundleId。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
+| callback | AsyncCallback<string> | 是 | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let testUid = 1000000;
- try {
- accountManager.getBundleIdFromUid(testUid, (err, bundleId) => {
- console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err));
- console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId));
- });
- } catch (e) {
- console.info('getBundleIdFromUid exception:' + JSON.stringify(e));
- }
+ accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
+ console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
+ });
```
-### getBundleIdFromUid9+
-getBundleIdFromUid(uid: number): Promise<number>;
+### getDistributedVirtualDeviceId(deprecated)
-通过uid查询对应的bundleId。
+getDistributedVirtualDeviceId(): Promise<string>
-此接口为系统接口,三方应用不支持调用。
+获取分布式虚拟设备ID。使用Promise异步回调。
-**系统能力:** SystemCapability.Account.OsAccount
+> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1)
+>
+> 从 API version 7开始支持。
-**参数:**
+**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| uid | number | 是 | 进程uid。 |
+**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与uid对应的bundleId。 |
+| 类型 | 说明 |
+| --------------------- | --------------------------------- |
+| Promise<string> | Promise对象,返回分布式虚拟设备ID。 |
**示例:**
```js
let accountManager = account_osAccount.getAccountManager();
- let testUid = 1000000;
- try {
- accountManager.getBundleIdFromUid(testUid).then((result) => {
- console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result));
- }).catch((err)=>{
- console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err));
- });
- } catch (e) {
- console.info('getBundleIdFromUid exception:' + JSON.stringify(e));
- }
+ accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
+ console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
+ }).catch((err) => {
+ console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ });
```
-### isMainOsAccount9+
-
-isMainOsAccount(callback: AsyncCallback<boolean>): void;
+### getOsAccountLocalIdBySerialNumber(deprecated)
-查询当前进程是否处于主用户。
+getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+通过SN码查询与其关联的系统帐号的帐号ID。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9)
+>
+> 从 API version 8开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback<boolean> | 是 | 回调结果,返回的是当前进程是否处于主用户,是则返回true,否则返回false。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------ | --------------------------- | ---- | -------------------------------------------------------------------------------- |
+| serialNumber | number | 是 | 帐号SN码。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为与SN码关联的系统帐号的帐号ID;否则为错误对象。 |
-**示例:**
+**示例:** 查询与SN码12345关联的系统帐号的ID
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.isMainOsAccount((err,result)=>{
- console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
- console.info('isMainOsAccount result:' + JSON.stringify(result));
- });
- } catch (e) {
- console.info('isMainOsAccount exception:' + JSON.stringify(e));
- }
+ let serialNumber = 12345;
+ accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
+ console.log('ger localId err:' + JSON.stringify(err));
+ console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
+ });
```
-### isMainOsAccount9+
-isMainOsAccount(): Promise<boolean>;
+### getOsAccountLocalIdBySerialNumber(deprecated)
-查询当前进程是否处于主用户。
+getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+通过SN码查询与其关联的系统帐号的帐号ID。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9-1)
+>
+> 从 API version 8开始支持。
**系统能力:** SystemCapability.Account.OsAccount
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------ | ------ | ---- | ---------- |
+| serialNumber | number | 是 | 帐号SN码。 |
+
**返回值:**
| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<boolean> | Promise实例,用于获取异步返回结果,回调结果,返回的是当前进程是否处于主用户,是则返回true,否则返回false。 |
+| --------------------- | -------------------------------------------- |
+| Promise<number> | Promise对象,返回与SN码关联的系统帐号的帐号ID。 |
-**示例:**
+**示例:** 查询与SN码12345关联的系统帐号的ID
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.isMainOsAccount().then((result) => {
- console.info('isMainOsAccount result:' + JSON.stringify(result));
- }).catch((err)=>{
- console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
- });
- } catch (e) {
- console.info('isMainOsAccount exception:' + JSON.stringify(e));
- }
+ let serialNumber = 12345;
+ accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
+ console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
+ }).catch((err) => {
+ console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
+ });
```
-### queryOsAccountConstraintSourceTypes9+
-queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void;
+### getSerialNumberByOsAccountLocalId(deprecated)
-查询指定系统帐号的指定约束来源信息。
+getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void
-此接口为系统接口,三方应用不支持调用。
+通过系统帐号ID获取与该系统帐号关联的SN码。使用callback异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9)
+>
+> 从 API version 8开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
-| localId | number | 是 | 要查询的系统帐号ID |
-| constraint | string | 是 | 要查询的[约束](#系统帐号约束列表)名称 |
-| callback | AsyncCallback<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | 是 | 回调结果,返回的是指定系统帐号的指定[约束](#系统帐号约束列表)来源信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------- | ---- | --------------------------------------------------------------------------- |
+| localId | number | 是 | 系统帐号ID。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果获取成功,err为null,data为与该系统帐号关联的SN码;否则为错误对象。 |
-**示例:**
+**示例:** 获取ID为100的系统帐号关联的SN码
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{
- console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err));
- console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
- });
- } catch (e) {
- console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
- }
+ let localId = 100;
+ accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
+ console.log('ger serialNumber err:' + JSON.stringify(err));
+ console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
+ });
```
-### queryOsAccountConstraintSourceTypes9+
-
-queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise<Array<ConstraintSourceTypeInfo>>;
+### getSerialNumberByOsAccountLocalId(deprecated)
-查询指定系统帐号的指定约束来源信息。
+getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
-此接口为系统接口,三方应用不支持调用。
+通过系统帐号ID获取与该系统帐号关联的SN码。使用Promise异步回调。
-**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS
+> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9-1)
+>
+> 从 API version 8开始支持。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------- | ------ | ---- | ------------ |
-| localId | number | 是 | 要查询的系统帐号ID |
-| constraint | string | 是 | 要查询的[约束](#系统帐号约束列表)名称 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ----------- |
+| localId | number | 是 | 系统帐号ID。 |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | Promise实例,用于获取异步返回结果,返回的是指定系统帐号的指定[约束](#系统帐号约束列表)来源信息。 |
+| 类型 | 说明 |
+| --------------------- | -------------------------------------- |
+| Promise<number> | Promise对象,返回与该系统帐号关联的SN码。 |
-**示例:**
+**示例:** 获取ID为100的系统帐号关联的SN码
```js
let accountManager = account_osAccount.getAccountManager();
- try {
- accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => {
- console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result));
- }).catch((err)=>{
- console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err));
- });
- } catch (e) {
- console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
- }
+ let localId = 100;
+ accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
+ console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
+ }).catch((err) => {
+ console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
+ });
```
## UserAuth8+
用户认证类。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### constructor8+
@@ -3236,7 +3556,7 @@ constructor()
创建用户认证的实例。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力**:SystemCapability.Account.OsAccount
@@ -3252,7 +3572,7 @@ getVersion(): number;
返回版本信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3275,7 +3595,7 @@ getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
检查身份认证功能是否可用。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3311,9 +3631,9 @@ getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProperty>): void;
-基于指定的请求信息获取属性,使用callback回调异步返回结果。
+基于指定的请求信息获取属性。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3324,7 +3644,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------------------- | ---- | ---------------------------------- |
| request | [GetPropertyRequest](#getpropertyrequest8) | 是 | 请求信息,包括认证类型和属性类型列表。 |
-| callback | AsyncCallback<[ExecutorProperty](#executorproperty8)> | 是 | 回调结果,返回的是调用者属性。 |
+| callback | AsyncCallback<[ExecutorProperty](#executorproperty8)> | 是 | 回调函数。如果获取成功,err为null,data为执行器属性信息;否则为错误对象。 |
**示例:**
```js
@@ -3352,9 +3672,9 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
-基于指定的请求信息获取属性,使用Promise方式异步返回结果。
+基于指定的请求信息获取属性。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3370,7 +3690,7 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
| 类型 | 说明 |
| :---------------------------------------------------------------- | :-------------------------------------------------- |
-| Promise<[ExecutorProperty](#executorproperty8)> | Promise实例,用于获取异步返回结果,返回的是调用者属性。 |
+| Promise<[ExecutorProperty](#executorproperty8)> | Promise对象,返回执行者属性信息。 |
**示例:**
```js
@@ -3399,9 +3719,9 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void;
-设置可用于初始化算法的属性,使用callback回调异步返回结果。
+设置可用于初始化算法的属性。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3412,7 +3732,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
| request | [SetPropertyRequest](#setpropertyrequest8)| 是 | 请求信息,包括认证类型和要设置的密钥值。 |
-| callback | AsyncCallback<number> | 是 | 回调结果,返回一个[数值](#resultcode8),指示属性设置是否成功。 |
+| callback | AsyncCallback<number> | 是 | 回调函数。如果设置成功,err为null,data为一个[数值](#resultcode8),指示属性设置是否成功;否则为错误对象。 |
**示例:**
```js
@@ -3436,9 +3756,9 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>):
setProperty(request: SetPropertyRequest): Promise<number>;
-设置可用于初始化算法的属性,使用Promise方式异步返回结果。
+设置可用于初始化算法的属性。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3446,15 +3766,15 @@ setProperty(request: SetPropertyRequest): Promise<number>;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------------------ | ---- | ---------------------------------------- |
| request | [SetPropertyRequest](#setpropertyrequest8) | 是 | 请求信息,包括身份验证类型和要设置的密钥值。 |
**返回值:**
-| 类型 | 说明 |
-| :-------------------- | :-------------------------------------------------------------------------------------------- |
-| Promise<number> | Promise实例,用于获取异步返回结果,返回一个[数值](#resultcode8),指示属性设置是否成功。 |
+| 类型 | 说明 |
+| :-------------------- | :------------------------------------------------------------ |
+| Promise<number> | Promise对象,返回一个[数值](#resultcode8),指示属性设置是否成功。 |
**示例:**
```js
@@ -3479,9 +3799,9 @@ setProperty(request: SetPropertyRequest): Promise<number>;
auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
-执行认证,使用callback回调异步返回结果。
+执行认证。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3491,10 +3811,10 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel,
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
-| challenge | Uint8Array | 是 | 指示挑战值,挑战值为一个随机数,用于提升安全性。|
+| challenge | Uint8Array | 是 | 指示挑战值,挑战值为一个随机数,用于提升安全性。|
| authType | [AuthType](#authtype8) | 是 | 指示认证类型。 |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 指示认证结果的信任级别。 |
-| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 回调结果,返回的是结果和所获取的信息。 |
+| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 回调对象,返回认证结果。 |
**返回值:**
@@ -3525,9 +3845,9 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel,
authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
-执行用户认证,使用callback回调异步返回结果。
+执行用户认证。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3541,7 +3861,7 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev
| challenge | Uint8Array | 是 | 指示挑战值,挑战值为一个随机数,用于提升安全性。 |
| authType | [AuthType](#authtype8) | 是 | 指示认证类型。 |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 指示认证结果的信任级别。 |
-| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 回调结果,返回的是结果和所获取的信息。 |
+| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 回调对象,返回认证结果。 |
**返回值:**
@@ -3575,7 +3895,7 @@ cancelAuth(contextID: Uint8Array): void;
取消特定的认证。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3609,7 +3929,7 @@ cancelAuth(contextID: Uint8Array): void;
Pin码认证功能基类。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### constructor8+
@@ -3617,7 +3937,7 @@ constructor()
创建Pin码认证的实例。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力**:SystemCapability.Account.OsAccount
@@ -3632,7 +3952,7 @@ registerInputer(inputer: IInputer): boolean;
注册输入器。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3672,7 +3992,7 @@ unregisterInputer(): void;
卸载输入器。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3688,7 +4008,7 @@ unregisterInputer(): void;
获取用户身份管理类。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### constructor8+
@@ -3696,7 +4016,7 @@ constructor()
创建用户认证的实例。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力**:SystemCapability.Account.OsAccount
@@ -3709,9 +4029,9 @@ constructor()
openSession(callback: AsyncCallback<Uint8Array>): void;
-打开会话,启动IDM操作以获取挑战值,使用callback回调异步返回结果。
+打开会话,启动IDM操作以获取挑战值。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3719,9 +4039,9 @@ openSession(callback: AsyncCallback<Uint8Array>): void;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------- | ---- | -------------------------------- |
-| callback | AsyncCallback<Uint8Array> | 是 | 回调结果,返回的是挑战值,非0即成功,为0则失败。|
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------- | ---- | -------------------------------------------------------------- |
+| callback | AsyncCallback<Uint8Array> | 是 | 回调函数。如果打开会话成功,err为null,data为挑战值;否则为错误对象。|
**示例:**
```js
@@ -3740,9 +4060,9 @@ openSession(callback: AsyncCallback<Uint8Array>): void;
openSession(): Promise<Uint8Array>;
-打开会话,启动IDM操作以获取挑战值,使用Promise方式异步返回结果。
+打开会话,启动IDM操作以获取挑战值。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3750,9 +4070,9 @@ openSession(): Promise<Uint8Array>;
**返回值:**
-| 类型 | 说明 |
-| :------------------------ | :------------------------------------------------------- |
-| Promise<Uint8Array> | Promise实例,用于获取异步返回结果,返回的是挑战值,非0即成功,为0则失败。|
+| 类型 | 说明 |
+| :------------------------ | ----------------------- |
+| Promise<Uint8Array> | Promise对象,返回挑战值。 |
**示例:**
```js
@@ -3772,9 +4092,9 @@ openSession(): Promise<Uint8Array>;
addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
-添加凭据,添加用户凭据信息,传入凭据添加方法和凭据信息(凭据类型,子类,如果添加用户的非密码凭据,则传入密码身份验证令牌),并获取结果/获取信息,使用callback回调异步返回结果。
+添加凭据,添加用户凭据信息,传入凭据添加方法和凭据信息(凭据类型,子类,如果添加用户的非密码凭据,则传入密码身份验证令牌),并获取结果/获取信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3782,10 +4102,10 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| --------------- | ------------------------------------------------ | --- | -------------------------------- |
-| credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 |
-| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是结果和获取信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| --------------- | ------------------------------ ----- | --- | ---------------------------- |
+| credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 |
+| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调对象,返回添加凭据的结果。 |
**示例:**
```js
@@ -3820,9 +4140,9 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
-更新凭据,使用callback回调异步返回结果。
+更新凭据。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3830,10 +4150,10 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| --------------- | ------------------------------------------------- | --- | -------------------------------- |
-| credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 |
-| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是结果和获取信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| --------------- | ------------------------------------- | --- | ------------------------- |
+| credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 |
+| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调对象,返回更新凭据的结果。 |
**示例:**
```js
@@ -3877,9 +4197,9 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
closeSession(): void;
-关闭会话,结束IDM操作
+关闭会话,结束IDM操作。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3897,7 +4217,7 @@ cancel(challenge: Uint8Array): void;
根据挑战值取消条目。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3927,7 +4247,7 @@ delUser(token: Uint8Array, callback: IIdmCallback): void;
删除具有身份验证令牌的用户,使用callback方式异步返回结果。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3935,10 +4255,10 @@ delUser(token: Uint8Array, callback: IIdmCallback): void;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------------------------------ | --- | ------------------------- |
-| token | Uint8Array | 是 | 身份验证令牌。 |
-| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是删除结果。|
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------ | --- | ------------------------- |
+| token | Uint8Array | 是 | 身份验证令牌。 |
+| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调对象,返回删除用户的结果。|
**示例:**
```js
@@ -3960,9 +4280,9 @@ delUser(token: Uint8Array, callback: IIdmCallback): void;
delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void;
-删除用户凭据信息,使用callback方式异步返回结果。
+删除用户凭据信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -3971,10 +4291,10 @@ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): vo
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
-| --------------- | ----------------------------------------------- | --- | ---------------------------|
-| credentialId | Uint8Array | 是 | 凭证索引。 |
-| token | Uint8Array | 是 | 身份验证令牌。 |
-| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是删除结果。 |
+| --------------- | ----------------------------------- | --- | ---------------------------|
+| credentialId | Uint8Array | 是 | 凭证索引。 |
+| token | Uint8Array | 是 | 身份验证令牌。 |
+| callback | [IIdmCallback](#iidmcallback8) | 是 | 回调对象,返回删除凭据的结果。 |
**示例:**
```js
@@ -3997,9 +4317,9 @@ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): vo
getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
-获取认证信息,使用callback回调异步返回结果。
+获取认证信息。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4007,9 +4327,9 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
-| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调结果,返回的是当前用户指定类型的所有已注册凭据信息。|
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------------------------------------------------ | ---- | --------------------------------------------- |
+| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调函数。如果成功,err为null,data为当前用户指定类型的所有已注册凭据信息;否则为错误对象。|
**示例:**
@@ -4029,9 +4349,9 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
-获取指定类型的认证信息,使用callback回调异步返回结果。
+获取指定类型的认证信息。使用callback异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4042,7 +4362,12 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
| authType | [AuthType](#authtype8) | 是 | 认证类型。 |
-| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调结果,返回的是当前用户指定类型的所有已注册凭据信息。|
+| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调函数,如果获取成功,err为null,data为当前用户指定类型的所有已注册凭据信息;否则为错误对象。 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| 12300015 | Unsupported authType. |
**示例:**
```js
@@ -4061,9 +4386,9 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred
getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>;
-获取认证信息,使用Promise方式异步返回结果。
+获取认证信息。使用Promise异步回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4073,13 +4398,18 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | -------- |
-| authType | [AuthType](#authtype8) | 否 | 认证类型。|
+| authType | [AuthType](#authtype8) | 否 | 认证类型。|
**返回值:**
-| 类型 | 说明 |
-| :------------------------------------------- | :------------------------------------------------------------------------ |
-| Promise<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Promise实例,用于获取异步返回结果,返回的是当前用户指定类型的所有已注册凭据信息。|
+| 类型 | 说明 |
+| :------------------------------------------- | :------------------------------------------------------------ ---------- |
+| Promise<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Promise对象,返回当前用户指定类型的所有已注册凭据信息。|
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| 12300015 | Unsupported authType. |
**示例:**
```js
@@ -4099,13 +4429,13 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>;
密码数据回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### onSetData8+
onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
通知设置数据。
@@ -4115,7 +4445,7 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
-| pinSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 |
+| pinSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 |
| data | Uint8Array | 是 | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 |
**示例:**
@@ -4137,7 +4467,7 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
密码输入框回调。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### onGetData8+
@@ -4145,7 +4475,7 @@ onGetData: (pinSubType: AuthSubType, callback: IInputData) => void;
通知获取数据。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4175,17 +4505,17 @@ onGetData: (pinSubType: AuthSubType, callback: IInputData) => void;
## IUserAuthCallback8+
-用户认证回调。
+表示用户认证回调类。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### onResult8+
onResult: (result: number, extraInfo: AuthResult) => void;
-身份认证结果代码通过回调返回。
+身份认证结果回调函数,返回结果码和认证结果信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4210,9 +4540,9 @@ onResult: (result: number, extraInfo: AuthResult) => void;
onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
-在身份验证期间,TipsCode通过回调返回。
+身份认证信息获取回调函数。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4241,17 +4571,17 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## IIdmCallback8+
-身份管理回调。
+表示身份管理回调类。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
### onResult8+
onResult: (result: number, extraInfo: RequestResult) => void;
-身份认证结果代码通过回调返回。
+身份管理操作结果回调函数,返回结果码和请求结果信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4276,9 +4606,9 @@ onResult: (result: number, extraInfo: RequestResult) => void;
onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
-在身份验证期间,TipsCode通过回调返回。
+身份管理信息获取回调函数。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Account.OsAccount
@@ -4309,7 +4639,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
提供获取属性请求的信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4322,7 +4652,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
提供设置属性请求的信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4336,7 +4666,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
提供执行器的属性。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4349,9 +4679,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## AuthResult8+
-指示认证结果的信息。
+表示认证结果的信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4363,9 +4693,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## CredentialInfo8+
-指示凭证信息。
+表示凭证信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4377,9 +4707,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## RequestResult8+
-指示请求结果的信息。
+表示请求结果的信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4389,9 +4719,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## EnrolledCredInfo8+
-指示已注册凭据的信息。
+表示已注册凭据的信息。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4404,9 +4734,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## GetPropertyType8+
-枚举,指示要获取的属性类型。
+表示要获取的属性类型的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4418,9 +4748,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## SetPropertyType8+
-枚举,指示要设置的属性类型。
+表示要设置的属性类型的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4430,9 +4760,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## AuthType8+
-枚举,指示身份验证的凭据类型。
+表示身份验证的凭据类型的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4443,9 +4773,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## AuthSubType8+
-枚举,指示用于认证的凭据子类型。
+表示用于认证的凭据子类型的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4459,9 +4789,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## AuthTrustLevel8+
-枚举,指示认证结果的受信任级别。
+表示认证结果的受信任级别的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4474,9 +4804,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## Module8+
-枚举,表示获取信息的模块。
+表示获取信息的模块的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4486,9 +4816,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## ResultCode8+
-枚举,指示身份验证结果代码。
+表示身份验证结果码。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4508,9 +4838,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## FaceTipsCode8+
-枚举,指示人脸验证过程中提示代码。
+表示人脸验证过程中提示的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4530,9 +4860,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## FingerprintTips8+
-枚举,指示指纹身份验证过程中提示代码。
+表示指纹身份验证过程中提示的枚举。
-此接口为系统接口,三方应用不支持调用。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
@@ -4547,7 +4877,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## OsAccountInfo
-系统帐号信息。
+表示系统帐号信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
@@ -4569,7 +4899,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## DomainAccountInfo8+
-域帐号信息。
+表示域帐号信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
@@ -4648,9 +4978,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## ConstraintSourceTypeInfo9+
-约束来源类型信息。
+表示约束来源类型信息。
-此接口为系统接口。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
@@ -4661,9 +4991,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
## ConstraintSourceType9+
-枚举,约束来源类型。
+表示约束来源类型的枚举。
-此接口为系统接口。
+**系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。