openharmony 鸿蒙 js-apis-osAccount

2025-06-12 浏览 (1)

@ohos.account.osAccount (System Account Management)

The osAccount module provides basic capabilities for managing system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling a system account.

NOTE

The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { osAccount } from '@kit.BasicServicesKit';

osAccount.getAccountManager

getAccountManager(): AccountManager

Obtains an AccountManager instance.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
AccountManagerAccountManager instance obtained.

Example

let accountManager: osAccount.AccountManager = osAccount.getAccountManager();

OsAccountType

Enumerates the system account types.

System capability: SystemCapability.Account.OsAccount

NameValueDescription
ADMIN0Administrator account.
NORMAL1Normal account.
GUEST2Guest account.

AccountManager

Provides APIs for managing system accounts.

checkMultiOsAccountEnabled9+

checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void

Checks whether multiple system accounts are supported. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means multiple system accounts are supported; the value false means the opposite.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.checkMultiOsAccountEnabled((err: BusinessError, isEnabled: boolean) => {
    if (err) {
      console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
    } else {
    console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
    }
  });
} catch (err) {
  console.log('checkMultiOsAccountEnabled failed, error:' + JSON.stringify(err));
}

checkMultiOsAccountEnabled9+

checkMultiOsAccountEnabled(): Promise<boolean>

Checks whether multiple system accounts are supported. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means multiple system accounts are supported; the value false means the opposite.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
try {
  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
  accountManager.checkMultiOsAccountEnabled().then((isEnabled: boolean) => {
    console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
  }).catch((err: BusinessError) => {
    console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
  });
} catch (err) {
  console.log('checkMultiOsAccountEnabled failed, error:' + JSON.stringify(err));
}

checkOsAccountActivated(deprecated)

checkOsAccountActivated(localId: number, callback: AsyncCallback<boolean>): void

Checks whether a system account is activated. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the account is activated; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Check whether system account 100 is activated.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.checkOsAccountActivated(localId, (err: BusinessError, isActivated: boolean) => {
    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));
}

checkOsAccountActivated(deprecated)

checkOsAccountActivated(localId: number): Promise<boolean>

Checks whether a system account is activated. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the account is activated; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Check whether system account 100 is activated.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.checkOsAccountActivated(localId).then((isActivated: boolean) => {
    console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated);
  }).catch((err: BusinessError) => {
    console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('checkOsAccountActivated exception: ' + JSON.stringify(err));
}

isOsAccountConstraintEnabled11+

isOsAccountConstraintEnabled(constraint: string): Promise<boolean>

Checks whether a constraint is enabled for this system account. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
constraintstringYesConstraint to check.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the specified constraint is enabled; the value false means the opposite.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example: Check whether system account 100 is forbidden to use Wi-Fi.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let constraint: string = 'constraint.wifi';
try {
  accountManager.isOsAccountConstraintEnabled(constraint).then((isEnabled: boolean) => {
    console.log('isOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
  }).catch((err: BusinessError) => {
    console.log('isOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('isOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
}

checkOsAccountConstraintEnabled(deprecated)

checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback<boolean>): void

Checks whether the specified constraint is enabled for a system account. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
constraintstringYesConstraint to check.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the specified constraint is enabled; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId or constraint.
12300003Account not found.

Example: Check whether system account 100 is forbidden to use Wi-Fi.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
let constraint: string = 'constraint.wifi';
try {
  accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err: BusinessError, isEnabled: boolean)=>{
    if (err) {
      console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
    } else {
      console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
    }
  });
} catch (err) {
  console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
}

checkOsAccountConstraintEnabled(deprecated)

checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise<boolean>

Checks whether the specified constraint is enabled for a system account. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
constraintstringYesConstraint to check.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the specified constraint is enabled; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId or constraint.
12300003Account not found.

Example: Check whether system account 100 is forbidden to use Wi-Fi.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
let constraint: string = 'constraint.wifi';
try {
  accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => {
    console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
  }).catch((err: BusinessError) => {
    console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
}

checkOsAccountTestable9+

checkOsAccountTestable(callback: AsyncCallback<boolean>): void

Checks whether this system account is a test account. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the account is a test account; the value false means the opposite.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.checkOsAccountTestable((err: BusinessError, isTestable: boolean) => {
    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));
}

checkOsAccountTestable9+

checkOsAccountTestable(): Promise<boolean>

Checks whether this system account is a test account. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the account is a test account; the value false means the opposite.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.checkOsAccountTestable().then((isTestable: boolean) => {
    console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable);
  }).catch((err: BusinessError) => {
    console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('checkOsAccountTestable exception: ' + JSON.stringify(err));
}

isOsAccountUnlocked11+

isOsAccountUnlocked(): Promise<boolean>

Checks whether this system account is unlocked. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the system account is unlocked; the value false means the opposite.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.isOsAccountUnlocked().then((isVerified: boolean) => {
    console.log('isOsAccountUnlocked successfully, isVerified: ' + isVerified);
  }).catch((err: BusinessError) => {
    console.log('isOsAccountUnlocked failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('isOsAccountUnlocked exception: ' + JSON.stringify(err));
}

checkOsAccountVerified(deprecated)

checkOsAccountVerified(callback: AsyncCallback<boolean>): void

Checks whether this system account has been verified. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. Use isOsAccountUnlocked instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the system account has been verified; the value false means the opposite.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.checkOsAccountVerified((err: BusinessError, isVerified: boolean) => {
    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));
}

checkOsAccountVerified(deprecated)

checkOsAccountVerified(): Promise<boolean>

Checks whether this system account has been verified. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. Use isOsAccountUnlocked instead.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the system account has been verified; the value false means the opposite.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.checkOsAccountVerified().then((isVerified: boolean) => {
    console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
  }).catch((err: BusinessError) => {
    console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
}

checkOsAccountVerified(deprecated)

checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void

Checks whether a system account has been verified. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the system account has been verified; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.checkOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
    if (err) {
      console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
    } else {
      console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
    }
  });
} catch (err) {
  console.log('checkOsAccountVerified exception: ' + err);
}

checkOsAccountVerified(deprecated)

checkOsAccountVerified(localId: number): Promise<boolean>

Checks whether a system account has been verified. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account. If this parameter is not specified, this API checks whether the current system account has been verified.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the system account has been verified; the value false means the opposite.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.checkOsAccountVerified(localId).then((isVerified: boolean) => {
    console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
  }).catch((err: BusinessError) => {
    console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
}

getOsAccountCount9+

getOsAccountCount(callback: AsyncCallback<number>): void

Obtains the number of system accounts created. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the number of created system accounts. If the operation fails, err is an error object.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountCount((err: BusinessError, count: number) => {
    if (err) {
      console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
    } else {
      console.log('getOsAccountCount successfully, count: ' + count);
    }
  });
} catch (err) {
  console.log('getOsAccountCount exception: ' + JSON.stringify(err));
}

getOsAccountCount9+

getOsAccountCount(): Promise<number>

Obtains the number of system accounts created. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<number>Promise used to return the number of created system accounts.

Error codes

IDError Message
201Permission denied.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountCount().then((count: number) => {
    console.log('getOsAccountCount successfully, count: ' + count);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
  });
} catch(err) {
  console.log('getOsAccountCount exception: ' + JSON.stringify(err));
}

getOsAccountLocalId9+

getOsAccountLocalId(callback: AsyncCallback<number>): void

Obtains the ID of the system account to which the current process belongs. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, err is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountLocalId((err: BusinessError, localId: number) => {
    if (err) {
      console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
    } else {
      console.log('getOsAccountLocalId successfully, localId: ' + localId);
    }
  });
} catch (err) {
  console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
}

getOsAccountLocalId9+

getOsAccountLocalId(): Promise<number>

Obtains the ID of the system account to which the current process belongs. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountLocalId().then((localId: number) => {
    console.log('getOsAccountLocalId successfully, localId: ' + localId);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
}

getOsAccountLocalIdForUid9+

getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): void

Obtains the system account ID based on the process UID. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
uidnumberYesProcess UID.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, data is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid uid.

Example: Obtain the ID of the system account whose process UID is 12345678.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let uid: number = 12345678;
try {
  accountManager.getOsAccountLocalIdForUid(uid, (err: BusinessError, localId: number) => {
    if (err) {
      console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
    }
    console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
  });
} catch (err) {
  console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
}

getOsAccountLocalIdForUid9+

getOsAccountLocalIdForUid(uid: number): Promise<number>

Obtains the system account ID based on the process UID. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
uidnumberYesProcess UID.

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid uid.

Example: Obtain the ID of the system account whose process UID is 12345678.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let uid: number = 12345678;
try {
  accountManager.getOsAccountLocalIdForUid(uid).then((localId: number) => {
    console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
}

getOsAccountLocalIdForUidSync10+

getOsAccountLocalIdForUidSync(uid: number): number

Obtains the system account ID based on the process UID. The API returns the result synchronously.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
uidnumberYesProcess UID.

Return value

TypeDescription
numberSystem account ID obtained.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300002Invalid uid.

Example: Obtain the ID of the system account whose process UID is 12345678.

let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let uid: number = 12345678;
try {
  let localId : number = accountManager.getOsAccountLocalIdForUidSync(uid);
  console.log('getOsAccountLocalIdForUidSync successfully, localId: ' + localId);
} catch (err) {
  console.log('getOsAccountLocalIdForUidSync exception: ' + JSON.stringify(err));
}

getOsAccountLocalIdForDomain9+

getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void

Obtains the system account ID based on the domain account information. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
domainInfoDomainAccountInfoYesDomain account information.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the ID of the system account associated with the domain account. Otherwise, err is an error object.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid domainInfo.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountLocalIdForDomain(domainInfo, (err: BusinessError, localId: number) => {
    if (err) {
      console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
    } else {
      console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
    }
  });
} catch (err) {
  console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
}

getOsAccountLocalIdForDomain9+

getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number>

Obtains the system account ID based on the domain account information. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
domainInfoDomainAccountInfoYesDomain account information.

Return value

TypeDescription
Promise<number>Promise used to return the ID of the system account associated with the domain account.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid domainInfo.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
  accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId: number) => {
    console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
  });
} catch (err) {
  console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
}

getOsAccountConstraints(deprecated)

getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<string>>): void

Obtains all constraints enabled for a system account. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<Array<string>>YesCallback used to return the result. If the operation is successful, err is null and data is all constraints obtained. Otherwise, err is an error object.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Obtain all constraints of system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.getOsAccountConstraints(localId, (err: BusinessError, constraints: string[]) => {
    if (err) {
      console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err));
    } else {
      console.log('getOsAccountConstraints successfully, constraints: ' + JSON.stringify(constraints));
    }
  });
} catch (err) {
  console.log('getOsAccountConstraints exception: ' + JSON.stringify(err));
}

getOsAccountConstraints(deprecated)

getOsAccountConstraints(localId: number): Promise<Array<string>>

Obtains all constraints enabled for a system account. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<Array<string>>Promise used to return all the constraints enabled for the system account.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Obtain all constraints of system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.getOsAccountConstraints(localId).then((constraints: string[]) => {
    console.log('getOsAccountConstraints, constraints: ' + constraints);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getOsAccountConstraints exception: ' + JSON.stringify(e));
}

getActivatedOsAccountLocalIds9+

getActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>>): void

Obtains information about all activated system accounts. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<Array<number>>YesCallback used to return the result. If the operation is successful, err is null and data is a list of activated system accounts. Otherwise, data is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getActivatedOsAccountLocalIds((err: BusinessError, idArray: number[])=>{
    console.log('getActivatedOsAccountLocalIds err:' + JSON.stringify(err));
    console.log('getActivatedOsAccountLocalIds idArray length:' + idArray.length);
    for(let i=0;i<idArray.length;i++) {
      console.info('activated os account id: ' + idArray[i]);
    }
  });
} catch (e) {
  console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
}

getActivatedOsAccountLocalIds9+

getActivatedOsAccountLocalIds(): Promise<Array<number>>

Obtains information about all activated system accounts. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<Array<number>>Promise used to return the information about all activated system accounts.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getActivatedOsAccountLocalIds().then((idArray: number[]) => {
    console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray);
  }).catch((err: BusinessError) => {
    console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
}

getCurrentOsAccount(deprecated)

getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void

Obtains information about the system account to which the current process belongs. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS10+ (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<OsAccountInfo>YesCallback used to return the result. If the operation is successful, err is null and data is the system account information obtained. Otherwise, data is an error object.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
    console.log('getCurrentOsAccount err:' + JSON.stringify(err));
    console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
  });
} catch (e) {
  console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
}

getCurrentOsAccount(deprecated)

getCurrentOsAccount(): Promise<OsAccountInfo>

Obtains information about the system account to which the current process belongs. This API uses a promise to return the result.

NOTE

This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS10+ (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<OsAccountInfo>Promise used to return the system account information obtained.

Error codes

IDError Message
201Permission denied.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
    console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
  }).catch((err: BusinessError) => {
    console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
}

getOsAccountType9+

getOsAccountType(callback: AsyncCallback<OsAccountType>): void

Obtains the type of the account to which the current process belongs. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<OsAccountType>YesCallback used to return the result. If the operation is successful, err is null and data is the system account type obtained. Otherwise, err is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountType((err: BusinessError, accountType: osAccount.OsAccountType) => {
    console.log('getOsAccountType err: ' + JSON.stringify(err));
    console.log('getOsAccountType accountType: ' + accountType);
  });
} catch (e) {
  console.log('getOsAccountType exception: ' + JSON.stringify(e));
}

getOsAccountType9+

getOsAccountType(): Promise<OsAccountType>

Obtains the type of the account to which the current process belongs. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<OsAccountType>Promise used to return the system account type obtained.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountType().then((accountType: osAccount.OsAccountType) => {
    console.log('getOsAccountType, accountType: ' + accountType);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountType err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getOsAccountType exception: ' + JSON.stringify(e));
}

queryDistributedVirtualDeviceId9+

queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void

Queries the ID of the distributed virtual device. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<string>YesCallback used to return the result. If the operation is successful, err is null and data is the distributed virtual device ID obtained. Otherwise, data is an error object.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.queryDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
    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>

Queries the ID of the distributed virtual device. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<string>Promise used to return the distributed virtual device ID obtained.

Error codes

IDError Message
201Permission denied.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.queryDistributedVirtualDeviceId().then((virtualID: string) => {
    console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
  }).catch((err: BusinessError) => {
    console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
}

getOsAccountLocalIdForSerialNumber9+

getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback<number>): void

Obtains the system account ID based on the SN. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
serialNumbernumberYesAccount SN.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, err is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid serialNumber.
12300003The account indicated by serialNumber dose not exist.

Example: Obtain the ID of the system account whose SN is 12345.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let serialNumber: number = 12345;
try {
  accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
    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));
}

getOsAccountLocalIdForSerialNumber9+

getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number>

Obtains the system account ID based on the SN. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
serialNumbernumberYesAccount SN.

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid serialNumber.
12300003The account indicated by serialNumber dose not exist.

Example: Obtain the ID of the system account whose SN is 12345.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let serialNumber: number = 12345;
try {
  accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId: number) => {
    console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getOsAccountLocalIdForSerialNumber exception: ' + JSON.stringify(e));
}

getSerialNumberForOsAccountLocalId9+

getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void

Obtains the SN of a system account based on the account ID. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the SN obtained. Otherwise, err is an error object.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Obtain the SN of the system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.getSerialNumberForOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
    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));
}

getSerialNumberForOsAccountLocalId9+

getSerialNumberForOsAccountLocalId(localId: number): Promise<number>

Obtains the SN of a system account based on the account ID. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<number>Promise used to return the SN obtained.

Error codes

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300002Invalid localId.
12300003Account not found.

Example: Obtain the SN of the system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
try {
  accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber: number) => {
    console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber);
  }).catch((err: BusinessError) => {
    console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getSerialNumberForOsAccountLocalId exception: ' + JSON.stringify(e));
}

isMultiOsAccountEnable(deprecated)

isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void

Checks whether multiple system accounts are supported. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use checkMultiOsAccountEnabled instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means multiple system accounts are supported; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err: BusinessError, isEnabled: boolean) => {
  if (err) {
    console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
  } else {
  console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
  }
});

isMultiOsAccountEnable(deprecated)

isMultiOsAccountEnable(): Promise<boolean>

Checks whether multiple system accounts are supported. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use checkMultiOsAccountEnabled instead.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means multiple system accounts are supported; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled: boolean) => {
  console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
}).catch((err: BusinessError) => {
  console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
});

isOsAccountActived(deprecated)

isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void

Checks whether a system account is activated. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the account is activated; the value false means the opposite.

Example: Check whether system account 100 is activated.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.isOsAccountActived(localId, (err: BusinessError, isActived: boolean) => {
  if (err) {
    console.log('isOsAccountActived failed, err:' + JSON.stringify(err));
  } else {
    console.log('isOsAccountActived successfully, isActived:' + isActived);
  }
});

isOsAccountActived(deprecated)

isOsAccountActived(localId: number): Promise<boolean>

Checks whether a system account is activated. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the account is activated; the value false means the opposite.

Example: Check whether system account 100 is activated.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.isOsAccountActived(localId).then((isActived: boolean) => {
  console.log('isOsAccountActived successfully, isActived: ' + isActived);
}).catch((err: BusinessError) => {
  console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
});

isOsAccountConstraintEnable(deprecated)

isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void

Checks whether the specified constraint is enabled for a system account. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
constraintstringYesConstraint to check.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the specified constraint is enabled; the value false means the opposite.

Example: Check whether system account 100 is forbidden to use Wi-Fi.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
let constraint: string = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint, (err: BusinessError, isEnabled: boolean) => {
  if (err) {
    console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err));
  } else {
    console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
  }
});

isOsAccountConstraintEnable(deprecated)

isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean>

Checks whether the specified constraint is enabled for a system account. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
constraintstringYesConstraint to check.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the specified constraint is enabled; the value false means the opposite.

Example: Check whether system account 100 is forbidden to use Wi-Fi.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
let constraint: string = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled: boolean) => {
  console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
}).catch((err: BusinessError) => {
  console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err));
});

isTestOsAccount(deprecated)

isTestOsAccount(callback: AsyncCallback<boolean>): void

Checks whether this system account is a test account. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use checkOsAccountTestable instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the account is a test account; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.isTestOsAccount((err: BusinessError, isTestable: boolean) => {
  if (err) {
    console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
  } else {
    console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
  }
});

isTestOsAccount(deprecated)

isTestOsAccount(): Promise<boolean>

Checks whether this system account is a test account. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use checkOsAccountTestable instead.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the account is a test account; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
  accountManager.isTestOsAccount().then((isTestable: boolean) => {
    console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
  }).catch((err: BusinessError) => {
    console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
});

isOsAccountVerified(deprecated)

isOsAccountVerified(callback: AsyncCallback<boolean>): void

Checks whether this system account has been verified. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. You are advised to use checkOsAccountVerified.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the system account has been verified; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.isOsAccountVerified((err: BusinessError, isVerified: boolean) => {
  if (err) {
    console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
  } else {
    console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
  }
});

isOsAccountVerified(deprecated)

isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void

Checks whether a system account has been verified. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<boolean>YesCallback used to return the result. The value true means the system account has been verified; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.isOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
  if (err) {
    console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
  } else {
    console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
  }
});

isOsAccountVerified(deprecated)

isOsAccountVerified(localId?: number): Promise<boolean>

Checks whether a system account has been verified. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberNoID of the target system account. If this parameter is not specified, this API checks whether the current system account has been verified.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. The value true means the system account has been verified; the value false means the opposite.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.isOsAccountVerified().then((isVerified: boolean) => {
  console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err: BusinessError) => {
  console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
});

getCreatedOsAccountsCount(deprecated)

getCreatedOsAccountsCount(callback: AsyncCallback<number>): void

Obtains the number of system accounts created. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountCount instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the number of created system accounts. If the operation fails, err is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err: BusinessError, count: number)=>{
  if (err) {
    console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
  } else {
    console.log('getCreatedOsAccountsCount successfully, count: ' + count);
  }
});

getCreatedOsAccountsCount(deprecated)

getCreatedOsAccountsCount(): Promise<number>

Obtains the number of system accounts created. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountCount instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<number>Promise used to return the number of created system accounts.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((count: number) => {
  console.log('getCreatedOsAccountsCount successfully, count: ' + count);
}).catch((err: BusinessError) => {
  console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
});

getOsAccountLocalIdFromProcess(deprecated)

getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void

Obtains the ID of the system account to which the current process belongs. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountLocalId instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, err is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err: BusinessError, localId: number) => {
  if (err) {
    console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
  } else {
    console.log('getOsAccountLocalIdFromProcess failed, error: ' + localId);
  }
});

getOsAccountLocalIdFromProcess(deprecated)

getOsAccountLocalIdFromProcess(): Promise<number>

Obtains the ID of the system account to which the current process belongs. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountLocalId instead.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((localId: number) => {
  console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
}).catch((err: BusinessError) => {
  console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
});

getOsAccountLocalIdFromUid(deprecated)

getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void

Obtains the system account ID based on the process UID. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountLocalIdForUid instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
uidnumberYesProcess UID.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, data is an error object.

Example: Obtain the ID of the system account whose process UID is 12345678.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let uid: number = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err: BusinessError, localId: number) => {
  if (err) {
    console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
  } else {
    console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
  }
});

getOsAccountLocalIdFromUid(deprecated)

getOsAccountLocalIdFromUid(uid: number): Promise<number>

Obtains the system account ID based on the process UID. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountLocalIdForUid instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
uidnumberYesProcess UID.

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Example: Obtain the ID of the system account whose process UID is 12345678.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let uid: number = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((localId: number) => {
  console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
}).catch((err: BusinessError) => {
  console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
});

getOsAccountLocalIdFromDomain(deprecated)

getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void

Obtains the system account ID based on the domain account information. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getOsAccountLocalIdForDomain instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
domainInfoDomainAccountInfoYesDomain account information.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, err is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => {
  if (err) {
    console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
  } else {
    console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
  }
});

getOsAccountLocalIdFromDomain(deprecated)

getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>

Obtains the system account ID based on the domain account information. This API uses a promise to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getOsAccountLocalIdForDomain instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
domainInfoDomainAccountInfoYesDomain account information.

Return value

TypeDescription
Promise<number>Promise used to return the ID of the system account associated with the domain account.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => {
  console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
}).catch((err: BusinessError) => {
  console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
});

getOsAccountAllConstraints(deprecated)

getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void

Obtains all constraints enabled for a system account. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<Array<string>>YesCallback used to return the result. If the operation is successful, err is null and data is a list of all constraints enabled for the system account. Otherwise, err is an error object.

Example: Obtain all constraints of system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.getOsAccountAllConstraints(localId, (err: BusinessError, constraints: string[])=>{
  console.log('getOsAccountAllConstraints err:' + JSON.stringify(err));
  console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints));
});

getOsAccountAllConstraints(deprecated)

getOsAccountAllConstraints(localId: number): Promise<Array<string>>

Obtains all constraints enabled for a system account. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<Array<string>>Promise used to return all the constraints enabled for the system account.

Example: Obtain all constraints of system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints: string[]) => {
  console.log('getOsAccountAllConstraints, constraints: ' + constraints);
}).catch((err: BusinessError) => {
  console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
});

queryActivatedOsAccountIds(deprecated)

queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void

Obtains information about all activated system accounts. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getActivatedOsAccountLocalIds instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<Array<number>>YesCallback used to return the result. If the operation is successful, err is null and data is a list of activated system accounts. Otherwise, data is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err: BusinessError, idArray: number[])=>{
  console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err));
  console.log('queryActivatedOsAccountIds idArray length:' + idArray.length);
  for(let i=0;i<idArray.length;i++) {
    console.info('activated os account id: ' + idArray[i]);
  }
});

queryActivatedOsAccountIds(deprecated)

queryActivatedOsAccountIds(): Promise<Array<number>>

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getActivatedOsAccountLocalIds instead.

Obtains information about all activated system accounts. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<Array<number>>Promise used to return the information about all activated system accounts.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray: number[]) => {
  console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
}).catch((err: BusinessError) => {
  console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
});

queryCurrentOsAccount(deprecated)

queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void

Obtains information about the system account to which the current process belongs. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<OsAccountInfo>YesCallback used to return the result. If the operation is successful, err is null and data is the system account information obtained. Otherwise, data is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
  console.log('queryCurrentOsAccount err:' + JSON.stringify(err));
  console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
});

queryCurrentOsAccount(deprecated)

queryCurrentOsAccount(): Promise<OsAccountInfo>

Obtains information about the system account to which the current process belongs. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications)

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<OsAccountInfo>Promise used to return the system account information obtained.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
  console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err: BusinessError) => {
  console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
});

getOsAccountTypeFromProcess(deprecated)

getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void

Obtains the type of the account to which the current process belongs. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountType instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<OsAccountType>YesCallback used to return the result. If the operation is successful, err is null and data is the system account type obtained. Otherwise, err is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err: BusinessError, accountType: osAccount.OsAccountType) => {
  console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
  console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
});

getOsAccountTypeFromProcess(deprecated)

getOsAccountTypeFromProcess(): Promise<OsAccountType>

Obtains the type of the account to which the current process belongs. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use getOsAccountType instead.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<OsAccountType>Promise used to return the system account type obtained.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType: osAccount.OsAccountType) => {
  console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
}).catch((err: BusinessError) => {
  console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
});

getDistributedVirtualDeviceId(deprecated)

getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void

Obtains the ID of this distributed virtual device. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use queryDistributedVirtualDeviceId instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<string>YesCallback used to return the result. If the operation is successful, err is null and data is the distributed virtual device ID obtained. Otherwise, data is an error object.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
  console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
  console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
});

getDistributedVirtualDeviceId(deprecated)

getDistributedVirtualDeviceId(): Promise<string>

Obtains the ID of this distributed virtual device. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. Use queryDistributedVirtualDeviceId instead.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<string>Promise used to return the distributed virtual device ID obtained.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID: string) => {
  console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err: BusinessError) => {
  console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
});

getOsAccountLocalIdBySerialNumber(deprecated)

getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void

Obtains the system account ID based on the SN. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getOsAccountLocalIdForSerialNumber instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
serialNumbernumberYesAccount SN.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the system account ID obtained. Otherwise, err is an error object.

Example: Obtain the ID of the system account whose SN is 12345.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let serialNumber: number = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
  console.log('ger localId err:' + JSON.stringify(err));
  console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
});

getOsAccountLocalIdBySerialNumber(deprecated)

getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>

Obtains the system account ID based on the SN. This API uses a promise to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getOsAccountLocalIdForSerialNumber instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
serialNumbernumberYesAccount SN.

Return value

TypeDescription
Promise<number>Promise used to return the system account ID obtained.

Example: Obtain the ID of the system account whose SN is 12345.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let serialNumber: number = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId: number) => {
  console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
}).catch((err: BusinessError) => {
  console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
});

getSerialNumberByOsAccountLocalId(deprecated)

getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void

Obtains the SN of a system account based on the account ID. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getSerialNumberForOsAccountLocalId instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.
callbackAsyncCallback<number>YesCallback used to return the result. If the operation is successful, err is null and data is the SN obtained. Otherwise, err is an error object.

Example: Obtain the SN of the system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
  console.log('ger serialNumber err:' + JSON.stringify(err));
  console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
});

getSerialNumberByOsAccountLocalId(deprecated)

getSerialNumberByOsAccountLocalId(localId: number): Promise<number>

Obtains the SN of a system account based on the account ID. This API uses a promise to return the result.

NOTE

This API is supported since API version 8 and deprecated since API version 9. Use getSerialNumberForOsAccountLocalId instead.

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
localIdnumberYesID of the target system account.

Return value

TypeDescription
Promise<number>Promise used to return the SN obtained.

Example: Obtain the SN of the system account 100.

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber: number) => {
  console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err: BusinessError) => {
  console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
});

getOsAccountName12+

getOsAccountName(): Promise<string>

Obtains the name of the system account of the caller. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<string>Promise used to return the system account name obtained.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getOsAccountName().then((name: string) => {
    console.log('getOsAccountName, name: ' + name);
  }).catch((err: BusinessError) => {
    console.log('getOsAccountName err: ' + err);
  });
} catch (e) {
  console.log('getOsAccountName exception: ' + e);
}

getForegroundOsAccountLocalId15+

getForegroundOsAccountLocalId(): Promise<number>;

Obtains the ID of the foreground system account.

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<number>Promise used to return the result.

Error codes

IDError Message
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
try {
  accountManager.getForegroundOsAccountLocalId().then((localId: number) => {
    console.log('getForegroundOsAccountLocalId, localId: ' + localId);
  }).catch((err: BusinessError) => {
    console.log('getForegroundOsAccountLocalId err: ' + JSON.stringify(err));
  });
} catch (e) {
  console.log('getForegroundOsAccountLocalId exception: ' + JSON.stringify(e));
}

getOsAccountDomainInfo15+

getOsAccountDomainInfo(localId: number): Promise<DomainAccountInfo>;

Obtains the domain account information associated with a specified system account.

Required permissions: ohos.permission.GET_DOMAIN_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available to system applications and enterprise applications)

System capability: SystemCapability.Account.OsAccount

Return value

TypeDescription
Promise<DomainAccountInfo>Promise used to return the result.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
12300001The system service works abnormally.
12300003OS account not found.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
let localId: number = 100;
accountManager.getOsAccountDomainInfo(localId).then((domainAccountInfo: osAccount.DomainAccountInfo) => {
  if (domainAccountInfo === null) {
    console.log('The target OS account is not a domain account.')
  } else {
    console.log('getOsAccountDomainInfo domain: ' + domainAccountInfo.domain);
    console.log('getOsAccountDomainInfo accountName: ' + domainAccountInfo.accountName);
  }
}).catch((err: BusinessError) => {
  console.log('getOsAccountDomainInfo err: ' + JSON.stringify(err));
})

updateAccountInfo18+

updateAccountInfo(oldAccountInfo: DomainAccountInfo, newAccountInfo: DomainAccountInfo): Promise<void>

Updates information of a domain account. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.MANAGE_DOMAIN_ACCOUNTS

System capability: SystemCapability.Account.OsAccount

Parameters

NameTypeMandatoryDescription
oldAccountInfoDomainAccountInfoYesDomain account information.
newAccountInfoDomainAccountInfoYesNew domain account information.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300002The new account info is invalid.
12300003The old account not found.
12300004The new account already exists.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let oldDomainInfo: osAccount.DomainAccountInfo =
  {domain: 'testDomain', accountName: 'oldtestAccountName'};
let newDomainInfo: osAccount.DomainAccountInfo =
  {domain: 'testDomain', accountName: 'newtestAccountName'};
try {
  osAccount.DomainAccountManager.updateAccountInfo(oldDomainInfo, newDomainInfo).then(() => {
    console.log('updateAccountInfo, success');
  }).catch((err: BusinessError) => {
    console.log('updateAccountInfo err: ' + err);
  });
} catch (e) {
  console.log('updateAccountInfo exception: ' + e);
}

OsAccountInfo

Represents information about a system account.

System capability: SystemCapability.Account.OsAccount

NameTypeMandatoryDescription
localIdnumberYesID of the system account.
localNamestringYesName of the system account.
typeOsAccountTypeYesType of the system account.
constraintsArray<string>YesConstraints of the system account. By default, no value is passed in.
isVerified(deprecated)booleanYesWhether the account has been verified. The value true means the specified account has been verified; the value false means the opposite.
NOTE
This parameter is supported since API version 7 and deprecated since API version 11.
isUnlocked11+booleanYesWhether the account is unlocked (whether the el2/ directory is decrypted). The value true means the specified account is unlocked; the value false means the opposite.
photo8+stringYesAvatar of the system account. By default, no value is passed in.
createTime8+numberYesTime when the system account was created.
lastLoginTime8+numberYesLast login time of the system account. By default, no value is passed in.
serialNumber8+numberYesSN of the system account.
isActived(deprecated)booleanYesWhether the system account is activated. The value true means that the specified account is activated; the value false means the opposite.
NOTE
This parameter is supported since API version 7 and deprecated since API version 11.
isActivated11+booleanYesWhether the system account is activated. The value true indicates that the specified account is activated; the value false means the opposite.
isCreateCompleted8+booleanYesWhether the system account information is complete. The value true means that the specified account is complete; the value false indicates the opposite.
distributedInfodistributedAccount.DistributedInfoYesDistributed account information. By default, no value is passed in.
domainInfo8+DomainAccountInfoYesDomain account information. By default, no value is passed in.

DomainAccountInfo8+

Represents the domain account information.

System capability: SystemCapability.Account.OsAccount

NameTypeMandatoryDescription
domainstringYesDomain name.
accountNamestringYesDomain account name.
serverConfigId18+stringNoDomain account configuration ID.

DomainServerConfig18+

Represents the configuration of a domain server.

System capability: SystemCapability.Account.OsAccount

NameTypeMandatoryDescription
parametersRecord<string, Object>YesServer configuration parameters.
idstringYesServer configuration ID.
domainstringYesDomain to which the server belongs.

DomainServerConfigManager18+

Provides APIs for domain server configuration and management.

addServerConfig18+

static addServerConfig(parameters: Record<string, Object>): Promise<DomainServerConfig>

Adds domain server configuration. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Parameters

NameTypeMandatoryDescription
parametersRecord<string, Object>YesConfiguration parameters of the domain server.

Return value

TypeDescription
Promise<DomainServerConfig>Promise used to return the configuration of the newly added domain server.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300002- Invalid server config parameters.
12300211- Server unreachable.
12300213- Server config already exists.
12300215- The number of server config reaches the upper limit.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let configParams: Record<string, Object> = {
  'uri': 'test.example.com',
  'port': 100
};
osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('add server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

removeServerConfig18+

static removeServerConfig(configId: string): Promise<void>

Removes domain server configuration. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Parameters

NameTypeMandatoryDescription
configIdstringYesServer configuration ID.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300212- Server config not found.
12300214- Server config has been associated with an account.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let configParams: Record<string, Object> = {
  'uri': 'test.example.com',
  'port': 100
};
osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
  osAccount.DomainServerConfigManager.removeServerConfig(serverConfig.id);
  console.log('remove domain server configuration successfully');
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

updateServerConfig18+

static updateServerConfig(configId: string, parameters: Record<string, Object>): Promise<DomainServerConfig>

Updates the domain server configuration. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Parameters

NameTypeMandatoryDescription
configIdstringYesServer configuration ID.
parametersRecord<string, Object>YesConfiguration parameters of the domain server.

Return value

TypeDescription
Promise<DomainServerConfig>Promise used to return the updated domain server configuration.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300002Invalid server config parameters.
12300211- Server unreachable.
12300212- Server config not found.
12300213- Server config already exists.
12300214- Server config has been associated with an account.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let configParams: Record<string, Object> = {
  'uri': 'test.example.com',
  'port': 100
};
osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
  osAccount.DomainServerConfigManager.updateServerConfig(serverConfig.id, configParams).then((data) => {
    console.log('update domain server configuration successfully, return config: ' + JSON.stringify(data));
  }).catch((err: BusinessError) => {
    console.log('update domain server configuration failed, error: ' + JSON.stringify(err));
  });
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

getServerConfig18+

static getServerConfig(configId: string): Promise<DomainServerConfig>

Obtains the domain server configuration. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Parameters

NameTypeMandatoryDescription
configIdstringYesServer configuration ID.

Return value

TypeDescription
Promise<DomainServerConfig>Promise used to return the domain server configuration obtained.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300212Server config not found.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let configParams: Record<string, Object> = {
  'uri': 'test.example.com',
  'port': 100
};
osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
  osAccount.DomainServerConfigManager.getServerConfig(serverConfig.id).then((data: osaccount.DomainServerConfig) => {
    console.log('get domain server configuration successfully, return config: ' + JSON.stringify(data));
  }).catch((err: BusinessError) => {
    console.log('get domain server configuration failed, error: ' + JSON.stringify(err));
  });
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

getAllServerConfigs18+

static getAllServerConfigs(): Promise<Array<DomainServerConfig>>

Obtains the configurations of all domain servers. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Return value

TypeDescription
Promise<Array<DomainServerConfig>>Promise used to return the domain server configuration obtained.

Error codes

IDError Message
201Permission denied.
801Capability not supported.
12300001The system service works abnormally.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let configParams: Record<string, Object> = {
  'uri': 'test.example.com',
  'port': 100
};
osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
  osAccount.DomainServerConfigManager.getAllServerConfigs().then((data: Array<osaccount.DomainServerConfig>) => {
    console.log('get all domain server configuration successfully, return config: ' + JSON.stringfy(data));
  }).catch((err: BusinessError) => {
    console.log('get all domain server configuration failed, error: ' + JSON.stringfy(err));
  });
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

getAccountServerConfig18+

static getAccountServerConfig(domainAccountInfo: DomainAccountInfo): Promise<DomainServerConfig>

Obtains the server configuration of a domain account. This API uses a promise to return the result.

System capability: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS

Parameters

NameTypeMandatoryDescription
domainAccountInfoDomainAccountInfoYesInformation of the domain account.

Return value

TypeDescription
Promise<DomainServerConfig>Promise used to return the domain server configuration of the account.

Error codes

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
801Capability not supported.
12300001The system service works abnormally.
12300003Domain account not found.

Example

import { BusinessError } from '@kit.BasicServicesKit';
let accountInfo: osAccount.DomainAccountInfo = {
  'accountName': 'demoName',
  'accountId': 'demoId',
  'domain': 'demoDomain'
};
osAccount.DomainServerConfigManager.getAccountServerConfig(accountInfo).then((
  serverConfig: osAccount.DomainServerConfig) => {
  console.log('get account server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
}).catch((err: BusinessError) => {
  console.log('add server configuration failed, error: ' + JSON.stringify(err));
});

Constraints

ConstraintDescription
constraint.wifiDisallow the use of Wi-Fi.
constraint.wifi.setDisallow setting of Wi-Fi.
constraint.locale.setDisallow setting of the language to use.
constraint.app.accountsDisallow adding or deletion of app accounts.
constraint.apps.installDisallow app installation.
constraint.apps.uninstallDisallow app uninstallation.
constraint.location.sharedDisallow location sharing.
constraint.unknown.sources.installDisallow installation of apps from unknown sources.
constraint.global.unknown.app.installDisallow installation of apps from unknown sources for all users.
constraint.bluetooth.setDisallow setting of Bluetooth.
constraint.bluetoothDisallow the use of Bluetooth.
constraint.bluetooth.shareDisallow Bluetooth sharing.
constraint.usb.file.transferDisallow file transfer over USB.
constraint.credentials.setDisallow setting of user credentials.
constraint.os.account.removeDisallow removal of users.
constraint.managed.profile.removeDisallow removal of the managed profiles of this user.
constraint.debug.features.useDisallow the use of debugging features.
constraint.vpn.setDisallow setting of VPN.
constraint.date.time.setDisallow setting of date, time, or time zone.
constraint.tethering.configDisallow setting of Tethering.
constraint.network.resetDisallow reset of network settings.
constraint.factory.resetDisallow reset to factory settings.
constraint.os.account.createDisallow creation of new users.
constraint.add.managed.profileDisallow addition of managed profiles.
constraint.apps.verify.disableDisallow app verification from being disabled.
constraint.cell.broadcasts.setDisallow setting of cell broadcasts.
constraint.mobile.networks.setDisallow setting of mobile networks.
constraint.control.appsDisallow modification of apps in Settings or the boot module.
constraint.physical.mediaDisallow mounting of external physical media.
constraint.microphoneDisallow the use of microphones.
constraint.microphone.unmuteDisallow unmuting of the microphone.
constraint.volume.adjustDisallow adjustment of the volume.
constraint.calls.outgoingDisallow outgoing calls.
constraint.sms.useDisallow the use of the short message service (SMS).
constraint.funDisallow the use of entertainment features.
constraint.windows.createDisallow creation of the windows other than app windows.
constraint.system.error.dialogsDisallow display of error dialogs for crashed or unresponsive apps.
constraint.cross.profile.copy.pasteDisallow pasting of clipboard content to other users or profiles.
constraint.beam.outgoingDisallow the use of Near Field Communications (NFC) to transfer data from apps.
constraint.wallpaperDisallow wallpaper management.
constraint.safe.bootDisallow reboot of the device in safe boot mode.
constraint.parent.profile.app.linkingDisallow the app in the parent profile from handling web links from the managed profiles.
constraint.audio.recordDisallow audio recording.
constraint.camera.useDisallow the use of cameras.
constraint.os.account.background.runDisallow background system accounts.
constraint.data.roamDisallow the use of cellular data when roaming.
constraint.os.account.set.iconDisallow setting of user icons.
constraint.wallpaper.setDisallow setting of wallpapers.
constraint.oem.unlockDisallow the use of OEM unlock.
constraint.device.unmuteDisallow unmuting of the device.
constraint.password.unifiedDisallow the use of the unified lock screen challenge for the managed profile with the primary user.
constraint.autofillDisallow the use of the autofill service.
constraint.content.captureDisallow capturing of the screen content.
constraint.content.suggestionsDisallow receiving of content suggestions.
constraint.os.account.activateDisallow activating of system accounts in the foreground.
constraint.location.setDisallow setting of the location service.
constraint.airplane.mode.setDisallow setting of the airplane mode.
constraint.brightness.setDisallow setting of the brightness.
constraint.share.into.profileDisallow sharing of files, images, and data of the primary user to the managed profiles.
constraint.ambient.displayDisallow display of the ambient environment.
constraint.screen.timeout.setDisallow setting of the screen-off timeout.
constraint.printDisallow printing.
constraint.private.dns.setDisallow setting of the private domain name server (DNS).

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Basic Services Kit

harmony 鸿蒙DeviceInfo

harmony 鸿蒙InitSync

harmony 鸿蒙OH_Print

harmony 鸿蒙OsAccount

harmony 鸿蒙Pasteboard

harmony 鸿蒙Print_Margin

harmony 鸿蒙Print_PageSize

harmony 鸿蒙Print_PrintAttributes

harmony 鸿蒙Print_PrintDocCallback

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/fVCWtd