1e41f4b71Sopenharmony_ci# @ohos.account.osAccount (System Account Management) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **osAccount** module provides basic capabilities for managing system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling a system account. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 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. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Modules to Import 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci```ts 12e41f4b71Sopenharmony_ciimport { osAccount } from '@kit.BasicServicesKit'; 13e41f4b71Sopenharmony_ci``` 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## osAccount.getAccountManager 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_cigetAccountManager(): AccountManager 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciObtains an **AccountManager** instance. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Return value** 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Type | Description | 26e41f4b71Sopenharmony_ci| --------------------------------- | ---------------- | 27e41f4b71Sopenharmony_ci| [AccountManager](#accountmanager) | **AccountManager** instance obtained. | 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**Example** 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci ```ts 32e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 33e41f4b71Sopenharmony_ci ``` 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci## OsAccountType 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ciEnumerates the system account types. 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci| Name | Value | Description | 42e41f4b71Sopenharmony_ci| ------ | ------ | ----------- | 43e41f4b71Sopenharmony_ci| ADMIN | 0 | Administrator account. | 44e41f4b71Sopenharmony_ci| NORMAL | 1 | Normal account. | 45e41f4b71Sopenharmony_ci| GUEST | 2 | Guest account. | 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci## AccountManager 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ciProvides APIs for managing system accounts. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci### checkMultiOsAccountEnabled<sup>9+</sup> 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_cicheckMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ciChecks whether multiple system accounts are supported. This API uses an asynchronous callback to return the result. 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**Parameters** 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 62e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 63e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means multiple system accounts are supported; the value **false** means the opposite.| 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**Error codes** 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci| ID | Error Message | 68e41f4b71Sopenharmony_ci| -------- | ------------------- | 69e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 70e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**Example** 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci ```ts 75e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 76e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 77e41f4b71Sopenharmony_ci try { 78e41f4b71Sopenharmony_ci accountManager.checkMultiOsAccountEnabled((err: BusinessError, isEnabled: boolean) => { 79e41f4b71Sopenharmony_ci if (err) { 80e41f4b71Sopenharmony_ci console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`); 81e41f4b71Sopenharmony_ci } else { 82e41f4b71Sopenharmony_ci console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled); 83e41f4b71Sopenharmony_ci } 84e41f4b71Sopenharmony_ci }); 85e41f4b71Sopenharmony_ci } catch (err) { 86e41f4b71Sopenharmony_ci console.log('checkMultiOsAccountEnabled failed, error:' + JSON.stringify(err)); 87e41f4b71Sopenharmony_ci } 88e41f4b71Sopenharmony_ci ``` 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci### checkMultiOsAccountEnabled<sup>9+</sup> 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_cicheckMultiOsAccountEnabled(): Promise<boolean> 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ciChecks whether multiple system accounts are supported. This API uses a promise to return the result. 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**Return value** 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci| Type | Description | 101e41f4b71Sopenharmony_ci| :--------------------- | :--------------------------------------------------------- | 102e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means multiple system accounts are supported; the value **false** means the opposite.| 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**Error codes** 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci| ID | Error Message | 107e41f4b71Sopenharmony_ci| -------- | ------------------- | 108e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**Example** 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci ```ts 113e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 114e41f4b71Sopenharmony_ci try { 115e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 116e41f4b71Sopenharmony_ci accountManager.checkMultiOsAccountEnabled().then((isEnabled: boolean) => { 117e41f4b71Sopenharmony_ci console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled); 118e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 119e41f4b71Sopenharmony_ci console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`); 120e41f4b71Sopenharmony_ci }); 121e41f4b71Sopenharmony_ci } catch (err) { 122e41f4b71Sopenharmony_ci console.log('checkMultiOsAccountEnabled failed, error:' + JSON.stringify(err)); 123e41f4b71Sopenharmony_ci } 124e41f4b71Sopenharmony_ci ``` 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci### checkOsAccountActivated<sup>(deprecated)</sup> 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_cicheckOsAccountActivated(localId: number, callback: AsyncCallback<boolean>): void 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ciChecks whether a system account is activated. This API uses an asynchronous callback to return the result. 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci> **NOTE** 133e41f4b71Sopenharmony_ci> 134e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**Parameters** 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 143e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 144e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 145e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the account is activated; the value **false** means the opposite.| 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Error codes** 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci| ID | Error Message | 150e41f4b71Sopenharmony_ci| -------- | ------------------- | 151e41f4b71Sopenharmony_ci| 201 | Permission denied.| 152e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 153e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 154e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 155e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is activated. 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci ```ts 160e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 161e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 162e41f4b71Sopenharmony_ci let localId: number = 100; 163e41f4b71Sopenharmony_ci try { 164e41f4b71Sopenharmony_ci accountManager.checkOsAccountActivated(localId, (err: BusinessError, isActivated: boolean) => { 165e41f4b71Sopenharmony_ci if (err) { 166e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated failed, error:' + JSON.stringify(err)); 167e41f4b71Sopenharmony_ci } else { 168e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated successfully, isActivated:' + isActivated); 169e41f4b71Sopenharmony_ci } 170e41f4b71Sopenharmony_ci }); 171e41f4b71Sopenharmony_ci } catch (err) { 172e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated exception: ' + JSON.stringify(err)); 173e41f4b71Sopenharmony_ci } 174e41f4b71Sopenharmony_ci ``` 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci### checkOsAccountActivated<sup>(deprecated)</sup> 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_cicheckOsAccountActivated(localId: number): Promise<boolean> 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ciChecks whether a system account is activated. This API uses a promise to return the result. 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci> **NOTE** 183e41f4b71Sopenharmony_ci> 184e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**Parameters** 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 193e41f4b71Sopenharmony_ci| ------- | ------ | ---- | --------------------------------- | 194e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci**Return value** 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci| Type | Description | 199e41f4b71Sopenharmony_ci| ---------------------- | ---------------------------------------------------------- | 200e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the account is activated; the value **false** means the opposite.| 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Error codes** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci| ID | Error Message | 205e41f4b71Sopenharmony_ci| -------- | ------------------- | 206e41f4b71Sopenharmony_ci| 201 | Permission denied.| 207e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 208e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 209e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 210e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is activated. 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci ```ts 215e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 216e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 217e41f4b71Sopenharmony_ci let localId: number = 100; 218e41f4b71Sopenharmony_ci try { 219e41f4b71Sopenharmony_ci accountManager.checkOsAccountActivated(localId).then((isActivated: boolean) => { 220e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated); 221e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 222e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err)); 223e41f4b71Sopenharmony_ci }); 224e41f4b71Sopenharmony_ci } catch (err) { 225e41f4b71Sopenharmony_ci console.log('checkOsAccountActivated exception: ' + JSON.stringify(err)); 226e41f4b71Sopenharmony_ci } 227e41f4b71Sopenharmony_ci ``` 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci### isOsAccountConstraintEnabled<sup>11+</sup> 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ciisOsAccountConstraintEnabled(constraint: string): Promise<boolean> 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ciChecks whether a constraint is enabled for this system account. This API uses a promise to return the result. 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci**Parameters** 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 240e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---------------------------------- | 241e41f4b71Sopenharmony_ci| constraint | string | Yes | [Constraint](#constraints) to check. | 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_ci**Return value** 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci| Type | Description | 246e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------------------------------------- | 247e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.| 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci**Error codes** 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci| ID | Error Message | 252e41f4b71Sopenharmony_ci| -------- | ------------------- | 253e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 254e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is forbidden to use Wi-Fi. 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci ```ts 259e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 260e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 261e41f4b71Sopenharmony_ci let constraint: string = 'constraint.wifi'; 262e41f4b71Sopenharmony_ci try { 263e41f4b71Sopenharmony_ci accountManager.isOsAccountConstraintEnabled(constraint).then((isEnabled: boolean) => { 264e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled); 265e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 266e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err)); 267e41f4b71Sopenharmony_ci }); 268e41f4b71Sopenharmony_ci } catch (err) { 269e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnabled exception: ' + JSON.stringify(err)); 270e41f4b71Sopenharmony_ci } 271e41f4b71Sopenharmony_ci ``` 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci### checkOsAccountConstraintEnabled<sup>(deprecated)</sup> 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_cicheckOsAccountConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback<boolean>): void 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ciChecks whether the specified constraint is enabled for a system account. This API uses an asynchronous callback to return the result. 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci> **NOTE** 280e41f4b71Sopenharmony_ci> 281e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**Parameters** 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 290e41f4b71Sopenharmony_ci| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- | 291e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 292e41f4b71Sopenharmony_ci| constraint | string | Yes | [Constraint](#constraints) to check. | 293e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.| 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci**Error codes** 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci| ID | Error Message | 298e41f4b71Sopenharmony_ci| -------- | ------------------- | 299e41f4b71Sopenharmony_ci| 201 | Permission denied.| 300e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 301e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 302e41f4b71Sopenharmony_ci| 12300002 | Invalid localId or constraint. | 303e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is forbidden to use Wi-Fi. 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci ```ts 308e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 309e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 310e41f4b71Sopenharmony_ci let localId: number = 100; 311e41f4b71Sopenharmony_ci let constraint: string = 'constraint.wifi'; 312e41f4b71Sopenharmony_ci try { 313e41f4b71Sopenharmony_ci accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err: BusinessError, isEnabled: boolean)=>{ 314e41f4b71Sopenharmony_ci if (err) { 315e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err)); 316e41f4b71Sopenharmony_ci } else { 317e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled); 318e41f4b71Sopenharmony_ci } 319e41f4b71Sopenharmony_ci }); 320e41f4b71Sopenharmony_ci } catch (err) { 321e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err)); 322e41f4b71Sopenharmony_ci } 323e41f4b71Sopenharmony_ci ``` 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci### checkOsAccountConstraintEnabled<sup>(deprecated)</sup> 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_cicheckOsAccountConstraintEnabled(localId: number, constraint: string): Promise<boolean> 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ciChecks whether the specified constraint is enabled for a system account. This API uses a promise to return the result. 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci> **NOTE** 332e41f4b71Sopenharmony_ci> 333e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci**Parameters** 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 342e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---------------------------------- | 343e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 344e41f4b71Sopenharmony_ci| constraint | string | Yes | [Constraint](#constraints) to check. | 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci**Return value** 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci| Type | Description | 349e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------------------------------------- | 350e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.| 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci**Error codes** 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci| ID | Error Message | 355e41f4b71Sopenharmony_ci| -------- | ------------------- | 356e41f4b71Sopenharmony_ci| 201 | Permission denied.| 357e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 358e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 359e41f4b71Sopenharmony_ci| 12300002 | Invalid localId or constraint. | 360e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is forbidden to use Wi-Fi. 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci ```ts 365e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 366e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 367e41f4b71Sopenharmony_ci let localId: number = 100; 368e41f4b71Sopenharmony_ci let constraint: string = 'constraint.wifi'; 369e41f4b71Sopenharmony_ci try { 370e41f4b71Sopenharmony_ci accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => { 371e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled); 372e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 373e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err)); 374e41f4b71Sopenharmony_ci }); 375e41f4b71Sopenharmony_ci } catch (err) { 376e41f4b71Sopenharmony_ci console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err)); 377e41f4b71Sopenharmony_ci } 378e41f4b71Sopenharmony_ci ``` 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ci### checkOsAccountTestable<sup>9+</sup> 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_cicheckOsAccountTestable(callback: AsyncCallback<boolean>): void 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ciChecks whether this system account is a test account. This API uses an asynchronous callback to return the result. 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci**Parameters** 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 391e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- | 392e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.| 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci**Error codes** 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci| ID | Error Message | 397e41f4b71Sopenharmony_ci| -------- | ------------------- | 398e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 399e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**Example** 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci ```ts 404e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 405e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 406e41f4b71Sopenharmony_ci try { 407e41f4b71Sopenharmony_ci accountManager.checkOsAccountTestable((err: BusinessError, isTestable: boolean) => { 408e41f4b71Sopenharmony_ci if (err) { 409e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err)); 410e41f4b71Sopenharmony_ci } else { 411e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable); 412e41f4b71Sopenharmony_ci } 413e41f4b71Sopenharmony_ci }); 414e41f4b71Sopenharmony_ci } catch (err) { 415e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable error: ' + JSON.stringify(err)); 416e41f4b71Sopenharmony_ci } 417e41f4b71Sopenharmony_ci ``` 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci### checkOsAccountTestable<sup>9+</sup> 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_cicheckOsAccountTestable(): Promise<boolean> 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ciChecks whether this system account is a test account. This API uses a promise to return the result. 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 426e41f4b71Sopenharmony_ci 427e41f4b71Sopenharmony_ci**Return value** 428e41f4b71Sopenharmony_ci 429e41f4b71Sopenharmony_ci| Type | Description | 430e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------------------ | 431e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.| 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci**Error codes** 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci| ID | Error Message | 436e41f4b71Sopenharmony_ci| -------- | ------------------- | 437e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci**Example** 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci ```ts 442e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 443e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 444e41f4b71Sopenharmony_ci try { 445e41f4b71Sopenharmony_ci accountManager.checkOsAccountTestable().then((isTestable: boolean) => { 446e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable); 447e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 448e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err)); 449e41f4b71Sopenharmony_ci }); 450e41f4b71Sopenharmony_ci } catch (err) { 451e41f4b71Sopenharmony_ci console.log('checkOsAccountTestable exception: ' + JSON.stringify(err)); 452e41f4b71Sopenharmony_ci } 453e41f4b71Sopenharmony_ci ``` 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci### isOsAccountUnlocked<sup>11+</sup> 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ciisOsAccountUnlocked(): Promise<boolean> 458e41f4b71Sopenharmony_ci 459e41f4b71Sopenharmony_ciChecks whether this system account is unlocked. This API uses a promise to return the result. 460e41f4b71Sopenharmony_ci 461e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 462e41f4b71Sopenharmony_ci 463e41f4b71Sopenharmony_ci**Return value** 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci| Type | Description | 466e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------------------ | 467e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the system account is unlocked; the value **false** means the opposite.| 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci**Error codes** 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci| ID | Error Message | 472e41f4b71Sopenharmony_ci| -------- | ------------------- | 473e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci**Example** 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci ```ts 478e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 479e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 480e41f4b71Sopenharmony_ci try { 481e41f4b71Sopenharmony_ci accountManager.isOsAccountUnlocked().then((isVerified: boolean) => { 482e41f4b71Sopenharmony_ci console.log('isOsAccountUnlocked successfully, isVerified: ' + isVerified); 483e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 484e41f4b71Sopenharmony_ci console.log('isOsAccountUnlocked failed, error: ' + JSON.stringify(err)); 485e41f4b71Sopenharmony_ci }); 486e41f4b71Sopenharmony_ci } catch (err) { 487e41f4b71Sopenharmony_ci console.log('isOsAccountUnlocked exception: ' + JSON.stringify(err)); 488e41f4b71Sopenharmony_ci } 489e41f4b71Sopenharmony_ci ``` 490e41f4b71Sopenharmony_ci 491e41f4b71Sopenharmony_ci### checkOsAccountVerified<sup>(deprecated)</sup> 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_cicheckOsAccountVerified(callback: AsyncCallback<boolean>): void 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ciChecks whether this system account has been verified. This API uses an asynchronous callback to return the result. 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_ci> **NOTE** 498e41f4b71Sopenharmony_ci> 499e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. Use [isOsAccountUnlocked](#isosaccountunlocked11) instead. 500e41f4b71Sopenharmony_ci 501e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**Parameters** 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 506e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 507e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 508e41f4b71Sopenharmony_ci 509e41f4b71Sopenharmony_ci**Error codes** 510e41f4b71Sopenharmony_ci 511e41f4b71Sopenharmony_ci| ID | Error Message | 512e41f4b71Sopenharmony_ci| -------- | ------------------- | 513e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci**Example** 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_ci ```ts 518e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 519e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 520e41f4b71Sopenharmony_ci try { 521e41f4b71Sopenharmony_ci accountManager.checkOsAccountVerified((err: BusinessError, isVerified: boolean) => { 522e41f4b71Sopenharmony_ci if (err) { 523e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); 524e41f4b71Sopenharmony_ci } else { 525e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); 526e41f4b71Sopenharmony_ci } 527e41f4b71Sopenharmony_ci }); 528e41f4b71Sopenharmony_ci } catch (err) { 529e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified exception: ' + JSON.stringify(err)); 530e41f4b71Sopenharmony_ci } 531e41f4b71Sopenharmony_ci ``` 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci### checkOsAccountVerified<sup>(deprecated)</sup> 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_cicheckOsAccountVerified(): Promise<boolean> 536e41f4b71Sopenharmony_ci 537e41f4b71Sopenharmony_ciChecks whether this system account has been verified. This API uses a promise to return the result. 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci> **NOTE** 540e41f4b71Sopenharmony_ci> 541e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. Use [isOsAccountUnlocked](#isosaccountunlocked11) instead. 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 544e41f4b71Sopenharmony_ci 545e41f4b71Sopenharmony_ci**Return value** 546e41f4b71Sopenharmony_ci 547e41f4b71Sopenharmony_ci| Type | Description | 548e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------------------ | 549e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 550e41f4b71Sopenharmony_ci 551e41f4b71Sopenharmony_ci**Error codes** 552e41f4b71Sopenharmony_ci 553e41f4b71Sopenharmony_ci| ID | Error Message | 554e41f4b71Sopenharmony_ci| -------- | ------------------- | 555e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci**Example** 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci ```ts 560e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 561e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 562e41f4b71Sopenharmony_ci try { 563e41f4b71Sopenharmony_ci accountManager.checkOsAccountVerified().then((isVerified: boolean) => { 564e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); 565e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 566e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); 567e41f4b71Sopenharmony_ci }); 568e41f4b71Sopenharmony_ci } catch (err) { 569e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified exception: ' + JSON.stringify(err)); 570e41f4b71Sopenharmony_ci } 571e41f4b71Sopenharmony_ci ``` 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci### checkOsAccountVerified<sup>(deprecated)</sup> 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_cicheckOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ciChecks whether a system account has been verified. This API uses an asynchronous callback to return the result. 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ci> **NOTE** 580e41f4b71Sopenharmony_ci> 581e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 586e41f4b71Sopenharmony_ci 587e41f4b71Sopenharmony_ci**Parameters** 588e41f4b71Sopenharmony_ci 589e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 590e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 591e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 592e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_ci**Error codes** 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ci| ID | Error Message | 597e41f4b71Sopenharmony_ci| -------- | ------------------- | 598e41f4b71Sopenharmony_ci| 201 | Permission denied.| 599e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 600e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 601e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 602e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci**Example** 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci ```ts 607e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 608e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 609e41f4b71Sopenharmony_ci let localId: number = 100; 610e41f4b71Sopenharmony_ci try { 611e41f4b71Sopenharmony_ci accountManager.checkOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => { 612e41f4b71Sopenharmony_ci if (err) { 613e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); 614e41f4b71Sopenharmony_ci } else { 615e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); 616e41f4b71Sopenharmony_ci } 617e41f4b71Sopenharmony_ci }); 618e41f4b71Sopenharmony_ci } catch (err) { 619e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified exception: ' + err); 620e41f4b71Sopenharmony_ci } 621e41f4b71Sopenharmony_ci ``` 622e41f4b71Sopenharmony_ci 623e41f4b71Sopenharmony_ci### checkOsAccountVerified<sup>(deprecated)</sup> 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_cicheckOsAccountVerified(localId: number): Promise<boolean> 626e41f4b71Sopenharmony_ci 627e41f4b71Sopenharmony_ciChecks whether a system account has been verified. This API uses a promise to return the result. 628e41f4b71Sopenharmony_ci 629e41f4b71Sopenharmony_ci> **NOTE** 630e41f4b71Sopenharmony_ci> 631e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci**Parameters** 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 640e41f4b71Sopenharmony_ci| ------- | ------ | ---- | --------------------------------------------------------------- | 641e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. If this parameter is not specified, this API checks whether the current system account has been verified. | 642e41f4b71Sopenharmony_ci 643e41f4b71Sopenharmony_ci**Return value** 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci| Type | Description | 646e41f4b71Sopenharmony_ci| ---------------------- | ----------------------------------------------------------------- | 647e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 648e41f4b71Sopenharmony_ci 649e41f4b71Sopenharmony_ci**Error codes** 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci| ID | Error Message | 652e41f4b71Sopenharmony_ci| -------- | ------------------- | 653e41f4b71Sopenharmony_ci| 201 | Permission denied.| 654e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 655e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 656e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 657e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci**Example** 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci ```ts 662e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 663e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 664e41f4b71Sopenharmony_ci let localId: number = 100; 665e41f4b71Sopenharmony_ci try { 666e41f4b71Sopenharmony_ci accountManager.checkOsAccountVerified(localId).then((isVerified: boolean) => { 667e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); 668e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 669e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); 670e41f4b71Sopenharmony_ci }); 671e41f4b71Sopenharmony_ci } catch (err) { 672e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified exception: ' + JSON.stringify(err)); 673e41f4b71Sopenharmony_ci } 674e41f4b71Sopenharmony_ci ``` 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_ci### checkOsAccountVerified<sup>9+</sup> 677e41f4b71Sopenharmony_ci 678e41f4b71Sopenharmony_cicheckOsAccountVerified(): Promise<boolean> 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ciChecks whether this system account has been verified. This API uses a promise to return the result. 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ci**Return value** 685e41f4b71Sopenharmony_ci 686e41f4b71Sopenharmony_ci| Type | Description | 687e41f4b71Sopenharmony_ci| ---------------------- | ----------------------------------------------------------------- | 688e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 689e41f4b71Sopenharmony_ci 690e41f4b71Sopenharmony_ci**Error codes** 691e41f4b71Sopenharmony_ci 692e41f4b71Sopenharmony_ci| ID | Error Message | 693e41f4b71Sopenharmony_ci| -------- | ------------------- | 694e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci**Example** 697e41f4b71Sopenharmony_ci 698e41f4b71Sopenharmony_ci ```ts 699e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 700e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 701e41f4b71Sopenharmony_ci try { 702e41f4b71Sopenharmony_ci accountManager.checkOsAccountVerified().then((isVerified: boolean) => { 703e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified); 704e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 705e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err)); 706e41f4b71Sopenharmony_ci }); 707e41f4b71Sopenharmony_ci } catch (err) { 708e41f4b71Sopenharmony_ci console.log('checkOsAccountVerified exception: ' + JSON.stringify(err)); 709e41f4b71Sopenharmony_ci } 710e41f4b71Sopenharmony_ci ``` 711e41f4b71Sopenharmony_ci 712e41f4b71Sopenharmony_ci### getOsAccountCount<sup>9+</sup> 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_cigetOsAccountCount(callback: AsyncCallback<number>): void 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ciObtains the number of system accounts created. This API uses an asynchronous callback to return the result. 717e41f4b71Sopenharmony_ci 718e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 719e41f4b71Sopenharmony_ci 720e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 721e41f4b71Sopenharmony_ci 722e41f4b71Sopenharmony_ci**Parameters** 723e41f4b71Sopenharmony_ci 724e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 725e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 726e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 727e41f4b71Sopenharmony_ci 728e41f4b71Sopenharmony_ci**Error codes** 729e41f4b71Sopenharmony_ci 730e41f4b71Sopenharmony_ci| ID | Error Message | 731e41f4b71Sopenharmony_ci| -------- | ------------------- | 732e41f4b71Sopenharmony_ci| 201 | Permission denied.| 733e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 734e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci**Example** 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci ```ts 739e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 740e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 741e41f4b71Sopenharmony_ci try { 742e41f4b71Sopenharmony_ci accountManager.getOsAccountCount((err: BusinessError, count: number) => { 743e41f4b71Sopenharmony_ci if (err) { 744e41f4b71Sopenharmony_ci console.log('getOsAccountCount failed, error: ' + JSON.stringify(err)); 745e41f4b71Sopenharmony_ci } else { 746e41f4b71Sopenharmony_ci console.log('getOsAccountCount successfully, count: ' + count); 747e41f4b71Sopenharmony_ci } 748e41f4b71Sopenharmony_ci }); 749e41f4b71Sopenharmony_ci } catch (err) { 750e41f4b71Sopenharmony_ci console.log('getOsAccountCount exception: ' + JSON.stringify(err)); 751e41f4b71Sopenharmony_ci } 752e41f4b71Sopenharmony_ci ``` 753e41f4b71Sopenharmony_ci 754e41f4b71Sopenharmony_ci### getOsAccountCount<sup>9+</sup> 755e41f4b71Sopenharmony_ci 756e41f4b71Sopenharmony_cigetOsAccountCount(): Promise<number> 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ciObtains the number of system accounts created. This API uses a promise to return the result. 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 761e41f4b71Sopenharmony_ci 762e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 763e41f4b71Sopenharmony_ci 764e41f4b71Sopenharmony_ci**Return value** 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci| Type | Description | 767e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------- | 768e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the number of created system accounts. | 769e41f4b71Sopenharmony_ci 770e41f4b71Sopenharmony_ci**Error codes** 771e41f4b71Sopenharmony_ci 772e41f4b71Sopenharmony_ci| ID | Error Message | 773e41f4b71Sopenharmony_ci| -------- | ------------------- | 774e41f4b71Sopenharmony_ci| 201 | Permission denied.| 775e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 776e41f4b71Sopenharmony_ci 777e41f4b71Sopenharmony_ci**Example** 778e41f4b71Sopenharmony_ci 779e41f4b71Sopenharmony_ci ```ts 780e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 781e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 782e41f4b71Sopenharmony_ci try { 783e41f4b71Sopenharmony_ci accountManager.getOsAccountCount().then((count: number) => { 784e41f4b71Sopenharmony_ci console.log('getOsAccountCount successfully, count: ' + count); 785e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 786e41f4b71Sopenharmony_ci console.log('getOsAccountCount failed, error: ' + JSON.stringify(err)); 787e41f4b71Sopenharmony_ci }); 788e41f4b71Sopenharmony_ci } catch(err) { 789e41f4b71Sopenharmony_ci console.log('getOsAccountCount exception: ' + JSON.stringify(err)); 790e41f4b71Sopenharmony_ci } 791e41f4b71Sopenharmony_ci ``` 792e41f4b71Sopenharmony_ci 793e41f4b71Sopenharmony_ci### getOsAccountLocalId<sup>9+</sup> 794e41f4b71Sopenharmony_ci 795e41f4b71Sopenharmony_cigetOsAccountLocalId(callback: AsyncCallback<number>): void 796e41f4b71Sopenharmony_ci 797e41f4b71Sopenharmony_ciObtains the ID of the system account to which the current process belongs. This API uses an asynchronous callback to return the result. 798e41f4b71Sopenharmony_ci 799e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 800e41f4b71Sopenharmony_ci 801e41f4b71Sopenharmony_ci**Parameters** 802e41f4b71Sopenharmony_ci 803e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 804e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- | 805e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 806e41f4b71Sopenharmony_ci 807e41f4b71Sopenharmony_ci**Error codes** 808e41f4b71Sopenharmony_ci 809e41f4b71Sopenharmony_ci| ID | Error Message | 810e41f4b71Sopenharmony_ci| -------- | ------------------- | 811e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 812e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 813e41f4b71Sopenharmony_ci 814e41f4b71Sopenharmony_ci**Example** 815e41f4b71Sopenharmony_ci 816e41f4b71Sopenharmony_ci ```ts 817e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 818e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 819e41f4b71Sopenharmony_ci try { 820e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalId((err: BusinessError, localId: number) => { 821e41f4b71Sopenharmony_ci if (err) { 822e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err)); 823e41f4b71Sopenharmony_ci } else { 824e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId successfully, localId: ' + localId); 825e41f4b71Sopenharmony_ci } 826e41f4b71Sopenharmony_ci }); 827e41f4b71Sopenharmony_ci } catch (err) { 828e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId exception: ' + JSON.stringify(err)); 829e41f4b71Sopenharmony_ci } 830e41f4b71Sopenharmony_ci ``` 831e41f4b71Sopenharmony_ci 832e41f4b71Sopenharmony_ci### getOsAccountLocalId<sup>9+</sup> 833e41f4b71Sopenharmony_ci 834e41f4b71Sopenharmony_cigetOsAccountLocalId(): Promise<number> 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ciObtains the ID of the system account to which the current process belongs. This API uses a promise to return the result. 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 839e41f4b71Sopenharmony_ci 840e41f4b71Sopenharmony_ci**Return value** 841e41f4b71Sopenharmony_ci 842e41f4b71Sopenharmony_ci| Type | Description | 843e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------------- | 844e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 845e41f4b71Sopenharmony_ci 846e41f4b71Sopenharmony_ci**Error codes** 847e41f4b71Sopenharmony_ci 848e41f4b71Sopenharmony_ci| ID | Error Message | 849e41f4b71Sopenharmony_ci| -------- | ------------------- | 850e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 851e41f4b71Sopenharmony_ci 852e41f4b71Sopenharmony_ci**Example** 853e41f4b71Sopenharmony_ci 854e41f4b71Sopenharmony_ci ```ts 855e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 856e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 857e41f4b71Sopenharmony_ci try { 858e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalId().then((localId: number) => { 859e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId successfully, localId: ' + localId); 860e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 861e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err)); 862e41f4b71Sopenharmony_ci }); 863e41f4b71Sopenharmony_ci } catch (err) { 864e41f4b71Sopenharmony_ci console.log('getOsAccountLocalId exception: ' + JSON.stringify(err)); 865e41f4b71Sopenharmony_ci } 866e41f4b71Sopenharmony_ci ``` 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci### getOsAccountLocalIdForUid<sup>9+</sup> 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_cigetOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): void 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ciObtains the system account ID based on the process UID. This API uses an asynchronous callback to return the result. 873e41f4b71Sopenharmony_ci 874e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 875e41f4b71Sopenharmony_ci 876e41f4b71Sopenharmony_ci**Parameters** 877e41f4b71Sopenharmony_ci 878e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 879e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 880e41f4b71Sopenharmony_ci| uid | number | Yes | Process UID. | 881e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 882e41f4b71Sopenharmony_ci 883e41f4b71Sopenharmony_ci**Error codes** 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ci| ID | Error Message | 886e41f4b71Sopenharmony_ci| -------- | --------------- | 887e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 888e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 889e41f4b71Sopenharmony_ci| 12300002 | Invalid uid. | 890e41f4b71Sopenharmony_ci 891e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose process UID is **12345678**. 892e41f4b71Sopenharmony_ci 893e41f4b71Sopenharmony_ci ```ts 894e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 895e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 896e41f4b71Sopenharmony_ci let uid: number = 12345678; 897e41f4b71Sopenharmony_ci try { 898e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForUid(uid, (err: BusinessError, localId: number) => { 899e41f4b71Sopenharmony_ci if (err) { 900e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err)); 901e41f4b71Sopenharmony_ci } 902e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId); 903e41f4b71Sopenharmony_ci }); 904e41f4b71Sopenharmony_ci } catch (err) { 905e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err)); 906e41f4b71Sopenharmony_ci } 907e41f4b71Sopenharmony_ci ``` 908e41f4b71Sopenharmony_ci 909e41f4b71Sopenharmony_ci### getOsAccountLocalIdForUid<sup>9+</sup> 910e41f4b71Sopenharmony_ci 911e41f4b71Sopenharmony_cigetOsAccountLocalIdForUid(uid: number): Promise<number> 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ciObtains the system account ID based on the process UID. This API uses a promise to return the result. 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 916e41f4b71Sopenharmony_ci 917e41f4b71Sopenharmony_ci**Parameters** 918e41f4b71Sopenharmony_ci 919e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 920e41f4b71Sopenharmony_ci| ------ | ------ | ---- | --------- | 921e41f4b71Sopenharmony_ci| uid | number | Yes | Process UID. | 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_ci**Return value** 924e41f4b71Sopenharmony_ci 925e41f4b71Sopenharmony_ci| Type | Description | 926e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------- | 927e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci**Error codes** 930e41f4b71Sopenharmony_ci 931e41f4b71Sopenharmony_ci| ID | Error Message | 932e41f4b71Sopenharmony_ci| -------- | ------------- | 933e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 934e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 935e41f4b71Sopenharmony_ci| 12300002 | Invalid uid. | 936e41f4b71Sopenharmony_ci 937e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose process UID is **12345678**. 938e41f4b71Sopenharmony_ci 939e41f4b71Sopenharmony_ci ```ts 940e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 941e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 942e41f4b71Sopenharmony_ci let uid: number = 12345678; 943e41f4b71Sopenharmony_ci try { 944e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForUid(uid).then((localId: number) => { 945e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId); 946e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 947e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err)); 948e41f4b71Sopenharmony_ci }); 949e41f4b71Sopenharmony_ci } catch (err) { 950e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err)); 951e41f4b71Sopenharmony_ci } 952e41f4b71Sopenharmony_ci ``` 953e41f4b71Sopenharmony_ci 954e41f4b71Sopenharmony_ci### getOsAccountLocalIdForUidSync<sup>10+</sup> 955e41f4b71Sopenharmony_ci 956e41f4b71Sopenharmony_cigetOsAccountLocalIdForUidSync(uid: number): number 957e41f4b71Sopenharmony_ci 958e41f4b71Sopenharmony_ciObtains the system account ID based on the process UID. The API returns the result synchronously. 959e41f4b71Sopenharmony_ci 960e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 961e41f4b71Sopenharmony_ci 962e41f4b71Sopenharmony_ci**Parameters** 963e41f4b71Sopenharmony_ci 964e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 965e41f4b71Sopenharmony_ci| ------ | ------ | ---- | --------- | 966e41f4b71Sopenharmony_ci| uid | number | Yes | Process UID. | 967e41f4b71Sopenharmony_ci 968e41f4b71Sopenharmony_ci**Return value** 969e41f4b71Sopenharmony_ci 970e41f4b71Sopenharmony_ci| Type | Description | 971e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------- | 972e41f4b71Sopenharmony_ci| number | System account ID obtained. | 973e41f4b71Sopenharmony_ci 974e41f4b71Sopenharmony_ci**Error codes** 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci| ID | Error Message | 977e41f4b71Sopenharmony_ci| -------- | ------------- | 978e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 979e41f4b71Sopenharmony_ci| 12300002 | Invalid uid. | 980e41f4b71Sopenharmony_ci 981e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose process UID is **12345678**. 982e41f4b71Sopenharmony_ci 983e41f4b71Sopenharmony_ci ```ts 984e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 985e41f4b71Sopenharmony_ci let uid: number = 12345678; 986e41f4b71Sopenharmony_ci try { 987e41f4b71Sopenharmony_ci let localId : number = accountManager.getOsAccountLocalIdForUidSync(uid); 988e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUidSync successfully, localId: ' + localId); 989e41f4b71Sopenharmony_ci } catch (err) { 990e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForUidSync exception: ' + JSON.stringify(err)); 991e41f4b71Sopenharmony_ci } 992e41f4b71Sopenharmony_ci ``` 993e41f4b71Sopenharmony_ci 994e41f4b71Sopenharmony_ci### getOsAccountLocalIdForDomain<sup>9+</sup> 995e41f4b71Sopenharmony_ci 996e41f4b71Sopenharmony_cigetOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void 997e41f4b71Sopenharmony_ci 998e41f4b71Sopenharmony_ciObtains the system account ID based on the domain account information. This API uses an asynchronous callback to return the result. 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1003e41f4b71Sopenharmony_ci 1004e41f4b71Sopenharmony_ci**Parameters** 1005e41f4b71Sopenharmony_ci 1006e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1007e41f4b71Sopenharmony_ci| ---------- | --------------------------------------- | ---- | -------------------------------------------------------------------------- | 1008e41f4b71Sopenharmony_ci| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. | 1009e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 1010e41f4b71Sopenharmony_ci 1011e41f4b71Sopenharmony_ci**Error codes** 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci| ID | Error Message | 1014e41f4b71Sopenharmony_ci| -------- | ------------- | 1015e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1016e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1017e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1018e41f4b71Sopenharmony_ci| 12300002 | Invalid domainInfo. | 1019e41f4b71Sopenharmony_ci 1020e41f4b71Sopenharmony_ci**Example** 1021e41f4b71Sopenharmony_ci 1022e41f4b71Sopenharmony_ci ```ts 1023e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1024e41f4b71Sopenharmony_ci let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'}; 1025e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1026e41f4b71Sopenharmony_ci try { 1027e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForDomain(domainInfo, (err: BusinessError, localId: number) => { 1028e41f4b71Sopenharmony_ci if (err) { 1029e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err)); 1030e41f4b71Sopenharmony_ci } else { 1031e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId); 1032e41f4b71Sopenharmony_ci } 1033e41f4b71Sopenharmony_ci }); 1034e41f4b71Sopenharmony_ci } catch (err) { 1035e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err)); 1036e41f4b71Sopenharmony_ci } 1037e41f4b71Sopenharmony_ci ``` 1038e41f4b71Sopenharmony_ci 1039e41f4b71Sopenharmony_ci### getOsAccountLocalIdForDomain<sup>9+</sup> 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_cigetOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number> 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ciObtains the system account ID based on the domain account information. This API uses a promise to return the result. 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1046e41f4b71Sopenharmony_ci 1047e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1048e41f4b71Sopenharmony_ci 1049e41f4b71Sopenharmony_ci**Parameters** 1050e41f4b71Sopenharmony_ci 1051e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1052e41f4b71Sopenharmony_ci| ---------- | --------------------------------------- | ---- | ------------ | 1053e41f4b71Sopenharmony_ci| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. | 1054e41f4b71Sopenharmony_ci 1055e41f4b71Sopenharmony_ci**Return value** 1056e41f4b71Sopenharmony_ci 1057e41f4b71Sopenharmony_ci| Type | Description | 1058e41f4b71Sopenharmony_ci| :-------------------- | :------------------------------------- | 1059e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the ID of the system account associated with the domain account. | 1060e41f4b71Sopenharmony_ci 1061e41f4b71Sopenharmony_ci**Error codes** 1062e41f4b71Sopenharmony_ci 1063e41f4b71Sopenharmony_ci| ID | Error Message | 1064e41f4b71Sopenharmony_ci| -------- | ------------- | 1065e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1066e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1067e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1068e41f4b71Sopenharmony_ci| 12300002 | Invalid domainInfo. | 1069e41f4b71Sopenharmony_ci 1070e41f4b71Sopenharmony_ci**Example** 1071e41f4b71Sopenharmony_ci 1072e41f4b71Sopenharmony_ci ```ts 1073e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1074e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1075e41f4b71Sopenharmony_ci let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'}; 1076e41f4b71Sopenharmony_ci try { 1077e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId: number) => { 1078e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId); 1079e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1080e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err)); 1081e41f4b71Sopenharmony_ci }); 1082e41f4b71Sopenharmony_ci } catch (err) { 1083e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err)); 1084e41f4b71Sopenharmony_ci } 1085e41f4b71Sopenharmony_ci ``` 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ci### getOsAccountConstraints<sup>(deprecated)</sup> 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_cigetOsAccountConstraints(localId: number, callback: AsyncCallback<Array<string>>): void 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ciObtains all constraints enabled for a system account. This API uses an asynchronous callback to return the result. 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci> **NOTE** 1094e41f4b71Sopenharmony_ci> 1095e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 1096e41f4b71Sopenharmony_ci 1097e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1100e41f4b71Sopenharmony_ci 1101e41f4b71Sopenharmony_ci**Parameters** 1102e41f4b71Sopenharmony_ci 1103e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1104e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------- | 1105e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1106e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is all [constraints](#constraints) obtained. Otherwise, **err** is an error object.| 1107e41f4b71Sopenharmony_ci 1108e41f4b71Sopenharmony_ci**Error codes** 1109e41f4b71Sopenharmony_ci 1110e41f4b71Sopenharmony_ci| ID | Error Message | 1111e41f4b71Sopenharmony_ci| -------- | ------------------- | 1112e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1113e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1114e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1115e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 1116e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 1117e41f4b71Sopenharmony_ci 1118e41f4b71Sopenharmony_ci**Example**: Obtain all constraints of system account 100. 1119e41f4b71Sopenharmony_ci 1120e41f4b71Sopenharmony_ci ```ts 1121e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1122e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1123e41f4b71Sopenharmony_ci let localId: number = 100; 1124e41f4b71Sopenharmony_ci try { 1125e41f4b71Sopenharmony_ci accountManager.getOsAccountConstraints(localId, (err: BusinessError, constraints: string[]) => { 1126e41f4b71Sopenharmony_ci if (err) { 1127e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err)); 1128e41f4b71Sopenharmony_ci } else { 1129e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints successfully, constraints: ' + JSON.stringify(constraints)); 1130e41f4b71Sopenharmony_ci } 1131e41f4b71Sopenharmony_ci }); 1132e41f4b71Sopenharmony_ci } catch (err) { 1133e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints exception: ' + JSON.stringify(err)); 1134e41f4b71Sopenharmony_ci } 1135e41f4b71Sopenharmony_ci ``` 1136e41f4b71Sopenharmony_ci 1137e41f4b71Sopenharmony_ci### getOsAccountConstraints<sup>(deprecated)</sup> 1138e41f4b71Sopenharmony_ci 1139e41f4b71Sopenharmony_cigetOsAccountConstraints(localId: number): Promise<Array<string>> 1140e41f4b71Sopenharmony_ci 1141e41f4b71Sopenharmony_ciObtains all constraints enabled for a system account. This API uses a promise to return the result. 1142e41f4b71Sopenharmony_ci 1143e41f4b71Sopenharmony_ci> **NOTE** 1144e41f4b71Sopenharmony_ci> 1145e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 1146e41f4b71Sopenharmony_ci 1147e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1148e41f4b71Sopenharmony_ci 1149e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1150e41f4b71Sopenharmony_ci 1151e41f4b71Sopenharmony_ci**Parameters** 1152e41f4b71Sopenharmony_ci 1153e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1154e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ------------ | 1155e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1156e41f4b71Sopenharmony_ci 1157e41f4b71Sopenharmony_ci**Return value** 1158e41f4b71Sopenharmony_ci 1159e41f4b71Sopenharmony_ci| Type | Description | 1160e41f4b71Sopenharmony_ci| ---------------------------------- | ---------------------------------------------------------- | 1161e41f4b71Sopenharmony_ci| Promise<Array<string>> | Promise used to return all the [constraints](#constraints) enabled for the system account. | 1162e41f4b71Sopenharmony_ci 1163e41f4b71Sopenharmony_ci**Error codes** 1164e41f4b71Sopenharmony_ci 1165e41f4b71Sopenharmony_ci| ID | Error Message | 1166e41f4b71Sopenharmony_ci| -------- | ------------------- | 1167e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1168e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1169e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1170e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 1171e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 1172e41f4b71Sopenharmony_ci 1173e41f4b71Sopenharmony_ci**Example**: Obtain all constraints of system account 100. 1174e41f4b71Sopenharmony_ci 1175e41f4b71Sopenharmony_ci ```ts 1176e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1177e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1178e41f4b71Sopenharmony_ci let localId: number = 100; 1179e41f4b71Sopenharmony_ci try { 1180e41f4b71Sopenharmony_ci accountManager.getOsAccountConstraints(localId).then((constraints: string[]) => { 1181e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints, constraints: ' + constraints); 1182e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1183e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints err: ' + JSON.stringify(err)); 1184e41f4b71Sopenharmony_ci }); 1185e41f4b71Sopenharmony_ci } catch (e) { 1186e41f4b71Sopenharmony_ci console.log('getOsAccountConstraints exception: ' + JSON.stringify(e)); 1187e41f4b71Sopenharmony_ci } 1188e41f4b71Sopenharmony_ci ``` 1189e41f4b71Sopenharmony_ci 1190e41f4b71Sopenharmony_ci### getActivatedOsAccountLocalIds<sup>9+</sup> 1191e41f4b71Sopenharmony_ci 1192e41f4b71Sopenharmony_cigetActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>>): void 1193e41f4b71Sopenharmony_ci 1194e41f4b71Sopenharmony_ciObtains information about all activated system accounts. This API uses an asynchronous callback to return the result. 1195e41f4b71Sopenharmony_ci 1196e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1197e41f4b71Sopenharmony_ci 1198e41f4b71Sopenharmony_ci**Parameters** 1199e41f4b71Sopenharmony_ci 1200e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1201e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | 1202e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<number>> | Yes | Callback 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.| 1203e41f4b71Sopenharmony_ci 1204e41f4b71Sopenharmony_ci**Error codes** 1205e41f4b71Sopenharmony_ci 1206e41f4b71Sopenharmony_ci| ID | Error Message | 1207e41f4b71Sopenharmony_ci| -------- | ------------- | 1208e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1209e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1210e41f4b71Sopenharmony_ci 1211e41f4b71Sopenharmony_ci**Example** 1212e41f4b71Sopenharmony_ci 1213e41f4b71Sopenharmony_ci ```ts 1214e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1215e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1216e41f4b71Sopenharmony_ci try { 1217e41f4b71Sopenharmony_ci accountManager.getActivatedOsAccountLocalIds((err: BusinessError, idArray: number[])=>{ 1218e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds err:' + JSON.stringify(err)); 1219e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds idArray length:' + idArray.length); 1220e41f4b71Sopenharmony_ci for(let i=0;i<idArray.length;i++) { 1221e41f4b71Sopenharmony_ci console.info('activated os account id: ' + idArray[i]); 1222e41f4b71Sopenharmony_ci } 1223e41f4b71Sopenharmony_ci }); 1224e41f4b71Sopenharmony_ci } catch (e) { 1225e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e)); 1226e41f4b71Sopenharmony_ci } 1227e41f4b71Sopenharmony_ci ``` 1228e41f4b71Sopenharmony_ci 1229e41f4b71Sopenharmony_ci### getActivatedOsAccountLocalIds<sup>9+</sup> 1230e41f4b71Sopenharmony_ci 1231e41f4b71Sopenharmony_cigetActivatedOsAccountLocalIds(): Promise<Array<number>> 1232e41f4b71Sopenharmony_ci 1233e41f4b71Sopenharmony_ciObtains information about all activated system accounts. This API uses a promise to return the result. 1234e41f4b71Sopenharmony_ci 1235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1236e41f4b71Sopenharmony_ci 1237e41f4b71Sopenharmony_ci**Return value** 1238e41f4b71Sopenharmony_ci 1239e41f4b71Sopenharmony_ci| Type | Description | 1240e41f4b71Sopenharmony_ci| :--------------------------------- | :------------------------------------------------ | 1241e41f4b71Sopenharmony_ci| Promise<Array<number>> | Promise used to return the information about all activated system accounts. | 1242e41f4b71Sopenharmony_ci 1243e41f4b71Sopenharmony_ci**Error codes** 1244e41f4b71Sopenharmony_ci 1245e41f4b71Sopenharmony_ci| ID | Error Message | 1246e41f4b71Sopenharmony_ci| -------- | ------------- | 1247e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1248e41f4b71Sopenharmony_ci 1249e41f4b71Sopenharmony_ci**Example** 1250e41f4b71Sopenharmony_ci 1251e41f4b71Sopenharmony_ci ```ts 1252e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1253e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1254e41f4b71Sopenharmony_ci try { 1255e41f4b71Sopenharmony_ci accountManager.getActivatedOsAccountLocalIds().then((idArray: number[]) => { 1256e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray); 1257e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1258e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err)); 1259e41f4b71Sopenharmony_ci }); 1260e41f4b71Sopenharmony_ci } catch (e) { 1261e41f4b71Sopenharmony_ci console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e)); 1262e41f4b71Sopenharmony_ci } 1263e41f4b71Sopenharmony_ci ``` 1264e41f4b71Sopenharmony_ci 1265e41f4b71Sopenharmony_ci### getCurrentOsAccount<sup>(deprecated)</sup> 1266e41f4b71Sopenharmony_ci 1267e41f4b71Sopenharmony_cigetCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void 1268e41f4b71Sopenharmony_ci 1269e41f4b71Sopenharmony_ciObtains information about the system account to which the current process belongs. This API uses an asynchronous callback to return the result. 1270e41f4b71Sopenharmony_ci 1271e41f4b71Sopenharmony_ci> **NOTE** 1272e41f4b71Sopenharmony_ci> 1273e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 1274e41f4b71Sopenharmony_ci 1275e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup> (available only for system applications) 1276e41f4b71Sopenharmony_ci 1277e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1278e41f4b71Sopenharmony_ci 1279e41f4b71Sopenharmony_ci**Parameters** 1280e41f4b71Sopenharmony_ci 1281e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1282e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 1283e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback 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.| 1284e41f4b71Sopenharmony_ci 1285e41f4b71Sopenharmony_ci**Error codes** 1286e41f4b71Sopenharmony_ci 1287e41f4b71Sopenharmony_ci| ID | Error Message | 1288e41f4b71Sopenharmony_ci| -------- | ------------------- | 1289e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1290e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1291e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1292e41f4b71Sopenharmony_ci 1293e41f4b71Sopenharmony_ci**Example** 1294e41f4b71Sopenharmony_ci 1295e41f4b71Sopenharmony_ci ```ts 1296e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1297e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1298e41f4b71Sopenharmony_ci try { 1299e41f4b71Sopenharmony_ci accountManager.getCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{ 1300e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount err:' + JSON.stringify(err)); 1301e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); 1302e41f4b71Sopenharmony_ci }); 1303e41f4b71Sopenharmony_ci } catch (e) { 1304e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount exception: ' + JSON.stringify(e)); 1305e41f4b71Sopenharmony_ci } 1306e41f4b71Sopenharmony_ci ``` 1307e41f4b71Sopenharmony_ci 1308e41f4b71Sopenharmony_ci### getCurrentOsAccount<sup>(deprecated)</sup> 1309e41f4b71Sopenharmony_ci 1310e41f4b71Sopenharmony_cigetCurrentOsAccount(): Promise<OsAccountInfo> 1311e41f4b71Sopenharmony_ci 1312e41f4b71Sopenharmony_ciObtains information about the system account to which the current process belongs. This API uses a promise to return the result. 1313e41f4b71Sopenharmony_ci 1314e41f4b71Sopenharmony_ci> **NOTE** 1315e41f4b71Sopenharmony_ci> 1316e41f4b71Sopenharmony_ci> This API is supported since API version 9 and deprecated since API version 11. The substitute API is available only to system applications. 1317e41f4b71Sopenharmony_ci 1318e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup> (available only for system applications) 1319e41f4b71Sopenharmony_ci 1320e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1321e41f4b71Sopenharmony_ci 1322e41f4b71Sopenharmony_ci**Return value** 1323e41f4b71Sopenharmony_ci 1324e41f4b71Sopenharmony_ci| Type | Description | 1325e41f4b71Sopenharmony_ci| ---------------------------------------------- | ----------------------------------------- | 1326e41f4b71Sopenharmony_ci| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the system account information obtained. | 1327e41f4b71Sopenharmony_ci 1328e41f4b71Sopenharmony_ci**Error codes** 1329e41f4b71Sopenharmony_ci 1330e41f4b71Sopenharmony_ci| ID | Error Message | 1331e41f4b71Sopenharmony_ci| -------- | ------------------- | 1332e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1333e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1334e41f4b71Sopenharmony_ci 1335e41f4b71Sopenharmony_ci**Example** 1336e41f4b71Sopenharmony_ci 1337e41f4b71Sopenharmony_ci ```ts 1338e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1339e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1340e41f4b71Sopenharmony_ci try { 1341e41f4b71Sopenharmony_ci accountManager.getCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => { 1342e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); 1343e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1344e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount err: ' + JSON.stringify(err)); 1345e41f4b71Sopenharmony_ci }); 1346e41f4b71Sopenharmony_ci } catch (e) { 1347e41f4b71Sopenharmony_ci console.log('getCurrentOsAccount exception: ' + JSON.stringify(e)); 1348e41f4b71Sopenharmony_ci } 1349e41f4b71Sopenharmony_ci ``` 1350e41f4b71Sopenharmony_ci 1351e41f4b71Sopenharmony_ci### getOsAccountType<sup>9+</sup> 1352e41f4b71Sopenharmony_ci 1353e41f4b71Sopenharmony_cigetOsAccountType(callback: AsyncCallback<OsAccountType>): void 1354e41f4b71Sopenharmony_ci 1355e41f4b71Sopenharmony_ciObtains the type of the account to which the current process belongs. This API uses an asynchronous callback to return the result. 1356e41f4b71Sopenharmony_ci 1357e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1358e41f4b71Sopenharmony_ci 1359e41f4b71Sopenharmony_ci**Parameters** 1360e41f4b71Sopenharmony_ci 1361e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1362e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | 1363e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | Yes | Callback 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.| 1364e41f4b71Sopenharmony_ci 1365e41f4b71Sopenharmony_ci**Error codes** 1366e41f4b71Sopenharmony_ci 1367e41f4b71Sopenharmony_ci| ID | Error Message | 1368e41f4b71Sopenharmony_ci| -------- | ------------------- | 1369e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1370e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1371e41f4b71Sopenharmony_ci 1372e41f4b71Sopenharmony_ci**Example** 1373e41f4b71Sopenharmony_ci 1374e41f4b71Sopenharmony_ci ```ts 1375e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1376e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1377e41f4b71Sopenharmony_ci try { 1378e41f4b71Sopenharmony_ci accountManager.getOsAccountType((err: BusinessError, accountType: osAccount.OsAccountType) => { 1379e41f4b71Sopenharmony_ci console.log('getOsAccountType err: ' + JSON.stringify(err)); 1380e41f4b71Sopenharmony_ci console.log('getOsAccountType accountType: ' + accountType); 1381e41f4b71Sopenharmony_ci }); 1382e41f4b71Sopenharmony_ci } catch (e) { 1383e41f4b71Sopenharmony_ci console.log('getOsAccountType exception: ' + JSON.stringify(e)); 1384e41f4b71Sopenharmony_ci } 1385e41f4b71Sopenharmony_ci ``` 1386e41f4b71Sopenharmony_ci 1387e41f4b71Sopenharmony_ci### getOsAccountType<sup>9+</sup> 1388e41f4b71Sopenharmony_ci 1389e41f4b71Sopenharmony_cigetOsAccountType(): Promise<OsAccountType> 1390e41f4b71Sopenharmony_ci 1391e41f4b71Sopenharmony_ciObtains the type of the account to which the current process belongs. This API uses a promise to return the result. 1392e41f4b71Sopenharmony_ci 1393e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1394e41f4b71Sopenharmony_ci 1395e41f4b71Sopenharmony_ci**Return value** 1396e41f4b71Sopenharmony_ci 1397e41f4b71Sopenharmony_ci| Type | Description | 1398e41f4b71Sopenharmony_ci| ---------------------------------------------- | ----------------------------------------------- | 1399e41f4b71Sopenharmony_ci| Promise<[OsAccountType](#osaccounttype)> | Promise used to return the system account type obtained. | 1400e41f4b71Sopenharmony_ci 1401e41f4b71Sopenharmony_ci**Error codes** 1402e41f4b71Sopenharmony_ci 1403e41f4b71Sopenharmony_ci| ID | Error Message | 1404e41f4b71Sopenharmony_ci| -------- | ------------------- | 1405e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1406e41f4b71Sopenharmony_ci 1407e41f4b71Sopenharmony_ci**Example** 1408e41f4b71Sopenharmony_ci 1409e41f4b71Sopenharmony_ci ```ts 1410e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1411e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1412e41f4b71Sopenharmony_ci try { 1413e41f4b71Sopenharmony_ci accountManager.getOsAccountType().then((accountType: osAccount.OsAccountType) => { 1414e41f4b71Sopenharmony_ci console.log('getOsAccountType, accountType: ' + accountType); 1415e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1416e41f4b71Sopenharmony_ci console.log('getOsAccountType err: ' + JSON.stringify(err)); 1417e41f4b71Sopenharmony_ci }); 1418e41f4b71Sopenharmony_ci } catch (e) { 1419e41f4b71Sopenharmony_ci console.log('getOsAccountType exception: ' + JSON.stringify(e)); 1420e41f4b71Sopenharmony_ci } 1421e41f4b71Sopenharmony_ci ``` 1422e41f4b71Sopenharmony_ci 1423e41f4b71Sopenharmony_ci### queryDistributedVirtualDeviceId<sup>9+</sup> 1424e41f4b71Sopenharmony_ci 1425e41f4b71Sopenharmony_ciqueryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void 1426e41f4b71Sopenharmony_ci 1427e41f4b71Sopenharmony_ciQueries the ID of the distributed virtual device. This API uses an asynchronous callback to return the result. 1428e41f4b71Sopenharmony_ci 1429e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC 1430e41f4b71Sopenharmony_ci 1431e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1432e41f4b71Sopenharmony_ci 1433e41f4b71Sopenharmony_ci**Parameters** 1434e41f4b71Sopenharmony_ci 1435e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1436e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 1437e41f4b71Sopenharmony_ci| callback | AsyncCallback<string> | Yes | Callback 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.| 1438e41f4b71Sopenharmony_ci 1439e41f4b71Sopenharmony_ci**Error codes** 1440e41f4b71Sopenharmony_ci 1441e41f4b71Sopenharmony_ci| ID | Error Message | 1442e41f4b71Sopenharmony_ci| -------- | ------------------- | 1443e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1444e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1445e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1446e41f4b71Sopenharmony_ci 1447e41f4b71Sopenharmony_ci**Example** 1448e41f4b71Sopenharmony_ci 1449e41f4b71Sopenharmony_ci ```ts 1450e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1451e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1452e41f4b71Sopenharmony_ci try { 1453e41f4b71Sopenharmony_ci accountManager.queryDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => { 1454e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); 1455e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID); 1456e41f4b71Sopenharmony_ci }); 1457e41f4b71Sopenharmony_ci } catch (e) { 1458e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e)); 1459e41f4b71Sopenharmony_ci } 1460e41f4b71Sopenharmony_ci ``` 1461e41f4b71Sopenharmony_ci 1462e41f4b71Sopenharmony_ci### queryDistributedVirtualDeviceId<sup>9+</sup> 1463e41f4b71Sopenharmony_ci 1464e41f4b71Sopenharmony_ciqueryDistributedVirtualDeviceId(): Promise<string> 1465e41f4b71Sopenharmony_ci 1466e41f4b71Sopenharmony_ciQueries the ID of the distributed virtual device. This API uses a promise to return the result. 1467e41f4b71Sopenharmony_ci 1468e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC 1469e41f4b71Sopenharmony_ci 1470e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1471e41f4b71Sopenharmony_ci 1472e41f4b71Sopenharmony_ci**Return value** 1473e41f4b71Sopenharmony_ci 1474e41f4b71Sopenharmony_ci| Type | Description | 1475e41f4b71Sopenharmony_ci| --------------------- | --------------------------------- | 1476e41f4b71Sopenharmony_ci| Promise<string> | Promise used to return the distributed virtual device ID obtained. | 1477e41f4b71Sopenharmony_ci 1478e41f4b71Sopenharmony_ci**Error codes** 1479e41f4b71Sopenharmony_ci 1480e41f4b71Sopenharmony_ci| ID | Error Message | 1481e41f4b71Sopenharmony_ci| -------- | ------------------- | 1482e41f4b71Sopenharmony_ci| 201 | Permission denied.| 1483e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1484e41f4b71Sopenharmony_ci 1485e41f4b71Sopenharmony_ci**Example** 1486e41f4b71Sopenharmony_ci 1487e41f4b71Sopenharmony_ci ```ts 1488e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1489e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1490e41f4b71Sopenharmony_ci try { 1491e41f4b71Sopenharmony_ci accountManager.queryDistributedVirtualDeviceId().then((virtualID: string) => { 1492e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID); 1493e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1494e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); 1495e41f4b71Sopenharmony_ci }); 1496e41f4b71Sopenharmony_ci } catch (e) { 1497e41f4b71Sopenharmony_ci console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e)); 1498e41f4b71Sopenharmony_ci } 1499e41f4b71Sopenharmony_ci ``` 1500e41f4b71Sopenharmony_ci 1501e41f4b71Sopenharmony_ci### getOsAccountLocalIdForSerialNumber<sup>9+</sup> 1502e41f4b71Sopenharmony_ci 1503e41f4b71Sopenharmony_cigetOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback<number>): void 1504e41f4b71Sopenharmony_ci 1505e41f4b71Sopenharmony_ciObtains the system account ID based on the SN. This API uses an asynchronous callback to return the result. 1506e41f4b71Sopenharmony_ci 1507e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1508e41f4b71Sopenharmony_ci 1509e41f4b71Sopenharmony_ci**Parameters** 1510e41f4b71Sopenharmony_ci 1511e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1512e41f4b71Sopenharmony_ci| ------------ | --------------------------- | ---- | ---------------------------------------------------------------------------- | 1513e41f4b71Sopenharmony_ci| serialNumber | number | Yes | Account SN. | 1514e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 1515e41f4b71Sopenharmony_ci 1516e41f4b71Sopenharmony_ci**Error codes** 1517e41f4b71Sopenharmony_ci 1518e41f4b71Sopenharmony_ci| ID | Error Message | 1519e41f4b71Sopenharmony_ci| -------- | ------------------- | 1520e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1521e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1522e41f4b71Sopenharmony_ci| 12300002 | Invalid serialNumber. | 1523e41f4b71Sopenharmony_ci| 12300003 | The account indicated by serialNumber dose not exist. | 1524e41f4b71Sopenharmony_ci 1525e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose SN is 12345. 1526e41f4b71Sopenharmony_ci 1527e41f4b71Sopenharmony_ci ```ts 1528e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1529e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1530e41f4b71Sopenharmony_ci let serialNumber: number = 12345; 1531e41f4b71Sopenharmony_ci try { 1532e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err: BusinessError, localId: number)=>{ 1533e41f4b71Sopenharmony_ci console.log('ger localId err:' + JSON.stringify(err)); 1534e41f4b71Sopenharmony_ci console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); 1535e41f4b71Sopenharmony_ci }); 1536e41f4b71Sopenharmony_ci } catch (e) { 1537e41f4b71Sopenharmony_ci console.log('ger localId exception: ' + JSON.stringify(e)); 1538e41f4b71Sopenharmony_ci } 1539e41f4b71Sopenharmony_ci ``` 1540e41f4b71Sopenharmony_ci 1541e41f4b71Sopenharmony_ci### getOsAccountLocalIdForSerialNumber<sup>9+</sup> 1542e41f4b71Sopenharmony_ci 1543e41f4b71Sopenharmony_cigetOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number> 1544e41f4b71Sopenharmony_ci 1545e41f4b71Sopenharmony_ciObtains the system account ID based on the SN. This API uses a promise to return the result. 1546e41f4b71Sopenharmony_ci 1547e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1548e41f4b71Sopenharmony_ci 1549e41f4b71Sopenharmony_ci**Parameters** 1550e41f4b71Sopenharmony_ci 1551e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1552e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | ---------- | 1553e41f4b71Sopenharmony_ci| serialNumber | number | Yes | Account SN. | 1554e41f4b71Sopenharmony_ci 1555e41f4b71Sopenharmony_ci**Return value** 1556e41f4b71Sopenharmony_ci 1557e41f4b71Sopenharmony_ci| Type | Description | 1558e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------------- | 1559e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 1560e41f4b71Sopenharmony_ci 1561e41f4b71Sopenharmony_ci**Error codes** 1562e41f4b71Sopenharmony_ci 1563e41f4b71Sopenharmony_ci| ID | Error Message | 1564e41f4b71Sopenharmony_ci| -------- | ------------------- | 1565e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1566e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1567e41f4b71Sopenharmony_ci| 12300002 | Invalid serialNumber. | 1568e41f4b71Sopenharmony_ci| 12300003 | The account indicated by serialNumber dose not exist. | 1569e41f4b71Sopenharmony_ci 1570e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose SN is 12345. 1571e41f4b71Sopenharmony_ci 1572e41f4b71Sopenharmony_ci ```ts 1573e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1574e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1575e41f4b71Sopenharmony_ci let serialNumber: number = 12345; 1576e41f4b71Sopenharmony_ci try { 1577e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId: number) => { 1578e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId); 1579e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1580e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err)); 1581e41f4b71Sopenharmony_ci }); 1582e41f4b71Sopenharmony_ci } catch (e) { 1583e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdForSerialNumber exception: ' + JSON.stringify(e)); 1584e41f4b71Sopenharmony_ci } 1585e41f4b71Sopenharmony_ci ``` 1586e41f4b71Sopenharmony_ci 1587e41f4b71Sopenharmony_ci### getSerialNumberForOsAccountLocalId<sup>9+</sup> 1588e41f4b71Sopenharmony_ci 1589e41f4b71Sopenharmony_cigetSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void 1590e41f4b71Sopenharmony_ci 1591e41f4b71Sopenharmony_ciObtains the SN of a system account based on the account ID. This API uses an asynchronous callback to return the result. 1592e41f4b71Sopenharmony_ci 1593e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1594e41f4b71Sopenharmony_ci 1595e41f4b71Sopenharmony_ci**Parameters** 1596e41f4b71Sopenharmony_ci 1597e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1598e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 1599e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1600e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 1601e41f4b71Sopenharmony_ci 1602e41f4b71Sopenharmony_ci**Error codes** 1603e41f4b71Sopenharmony_ci 1604e41f4b71Sopenharmony_ci| ID | Error Message | 1605e41f4b71Sopenharmony_ci| -------- | ------------------- | 1606e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1607e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1608e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 1609e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 1610e41f4b71Sopenharmony_ci 1611e41f4b71Sopenharmony_ci**Example**: Obtain the SN of the system account 100. 1612e41f4b71Sopenharmony_ci 1613e41f4b71Sopenharmony_ci ```ts 1614e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1615e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1616e41f4b71Sopenharmony_ci let localId: number = 100; 1617e41f4b71Sopenharmony_ci try { 1618e41f4b71Sopenharmony_ci accountManager.getSerialNumberForOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{ 1619e41f4b71Sopenharmony_ci console.log('ger serialNumber err:' + JSON.stringify(err)); 1620e41f4b71Sopenharmony_ci console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); 1621e41f4b71Sopenharmony_ci }); 1622e41f4b71Sopenharmony_ci } catch (e) { 1623e41f4b71Sopenharmony_ci console.log('ger serialNumber exception: ' + JSON.stringify(e)); 1624e41f4b71Sopenharmony_ci } 1625e41f4b71Sopenharmony_ci ``` 1626e41f4b71Sopenharmony_ci 1627e41f4b71Sopenharmony_ci### getSerialNumberForOsAccountLocalId<sup>9+</sup> 1628e41f4b71Sopenharmony_ci 1629e41f4b71Sopenharmony_cigetSerialNumberForOsAccountLocalId(localId: number): Promise<number> 1630e41f4b71Sopenharmony_ci 1631e41f4b71Sopenharmony_ciObtains the SN of a system account based on the account ID. This API uses a promise to return the result. 1632e41f4b71Sopenharmony_ci 1633e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1634e41f4b71Sopenharmony_ci 1635e41f4b71Sopenharmony_ci**Parameters** 1636e41f4b71Sopenharmony_ci 1637e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1638e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ----------- | 1639e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1640e41f4b71Sopenharmony_ci 1641e41f4b71Sopenharmony_ci**Return value** 1642e41f4b71Sopenharmony_ci 1643e41f4b71Sopenharmony_ci| Type | Description | 1644e41f4b71Sopenharmony_ci| :-------------------- | :------------------------------------- | 1645e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the SN obtained. | 1646e41f4b71Sopenharmony_ci 1647e41f4b71Sopenharmony_ci**Error codes** 1648e41f4b71Sopenharmony_ci 1649e41f4b71Sopenharmony_ci| ID | Error Message | 1650e41f4b71Sopenharmony_ci| -------- | ------------------- | 1651e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1652e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 1653e41f4b71Sopenharmony_ci| 12300002 | Invalid localId. | 1654e41f4b71Sopenharmony_ci| 12300003 | Account not found. | 1655e41f4b71Sopenharmony_ci 1656e41f4b71Sopenharmony_ci**Example**: Obtain the SN of the system account 100. 1657e41f4b71Sopenharmony_ci 1658e41f4b71Sopenharmony_ci ```ts 1659e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1660e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1661e41f4b71Sopenharmony_ci let localId: number = 100; 1662e41f4b71Sopenharmony_ci try { 1663e41f4b71Sopenharmony_ci accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber: number) => { 1664e41f4b71Sopenharmony_ci console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber); 1665e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1666e41f4b71Sopenharmony_ci console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err)); 1667e41f4b71Sopenharmony_ci }); 1668e41f4b71Sopenharmony_ci } catch (e) { 1669e41f4b71Sopenharmony_ci console.log('getSerialNumberForOsAccountLocalId exception: ' + JSON.stringify(e)); 1670e41f4b71Sopenharmony_ci } 1671e41f4b71Sopenharmony_ci ``` 1672e41f4b71Sopenharmony_ci 1673e41f4b71Sopenharmony_ci### isMultiOsAccountEnable<sup>(deprecated)</sup> 1674e41f4b71Sopenharmony_ci 1675e41f4b71Sopenharmony_ciisMultiOsAccountEnable(callback: AsyncCallback<boolean>): void 1676e41f4b71Sopenharmony_ci 1677e41f4b71Sopenharmony_ciChecks whether multiple system accounts are supported. This API uses an asynchronous callback to return the result. 1678e41f4b71Sopenharmony_ci 1679e41f4b71Sopenharmony_ci> **NOTE** 1680e41f4b71Sopenharmony_ci> 1681e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [checkMultiOsAccountEnabled](#checkmultiosaccountenabled9) instead. 1682e41f4b71Sopenharmony_ci 1683e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1684e41f4b71Sopenharmony_ci 1685e41f4b71Sopenharmony_ci**Parameters** 1686e41f4b71Sopenharmony_ci 1687e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1688e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 1689e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means multiple system accounts are supported; the value **false** means the opposite.| 1690e41f4b71Sopenharmony_ci 1691e41f4b71Sopenharmony_ci**Example** 1692e41f4b71Sopenharmony_ci 1693e41f4b71Sopenharmony_ci ```ts 1694e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1695e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1696e41f4b71Sopenharmony_ci accountManager.isMultiOsAccountEnable((err: BusinessError, isEnabled: boolean) => { 1697e41f4b71Sopenharmony_ci if (err) { 1698e41f4b71Sopenharmony_ci console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err)); 1699e41f4b71Sopenharmony_ci } else { 1700e41f4b71Sopenharmony_ci console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled); 1701e41f4b71Sopenharmony_ci } 1702e41f4b71Sopenharmony_ci }); 1703e41f4b71Sopenharmony_ci ``` 1704e41f4b71Sopenharmony_ci 1705e41f4b71Sopenharmony_ci### isMultiOsAccountEnable<sup>(deprecated)</sup> 1706e41f4b71Sopenharmony_ci 1707e41f4b71Sopenharmony_ciisMultiOsAccountEnable(): Promise<boolean> 1708e41f4b71Sopenharmony_ci 1709e41f4b71Sopenharmony_ciChecks whether multiple system accounts are supported. This API uses a promise to return the result. 1710e41f4b71Sopenharmony_ci 1711e41f4b71Sopenharmony_ci> **NOTE** 1712e41f4b71Sopenharmony_ci> 1713e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [checkMultiOsAccountEnabled](#checkmultiosaccountenabled9-1) instead. 1714e41f4b71Sopenharmony_ci 1715e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1716e41f4b71Sopenharmony_ci 1717e41f4b71Sopenharmony_ci**Return value** 1718e41f4b71Sopenharmony_ci 1719e41f4b71Sopenharmony_ci| Type | Description | 1720e41f4b71Sopenharmony_ci| :--------------------- | :--------------------------------------------------------- | 1721e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means multiple system accounts are supported; the value **false** means the opposite.| 1722e41f4b71Sopenharmony_ci 1723e41f4b71Sopenharmony_ci**Example** 1724e41f4b71Sopenharmony_ci 1725e41f4b71Sopenharmony_ci ```ts 1726e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1727e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1728e41f4b71Sopenharmony_ci accountManager.isMultiOsAccountEnable().then((isEnabled: boolean) => { 1729e41f4b71Sopenharmony_ci console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled); 1730e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1731e41f4b71Sopenharmony_ci console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err)); 1732e41f4b71Sopenharmony_ci }); 1733e41f4b71Sopenharmony_ci ``` 1734e41f4b71Sopenharmony_ci 1735e41f4b71Sopenharmony_ci### isOsAccountActived<sup>(deprecated)</sup> 1736e41f4b71Sopenharmony_ci 1737e41f4b71Sopenharmony_ciisOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void 1738e41f4b71Sopenharmony_ci 1739e41f4b71Sopenharmony_ciChecks whether a system account is activated. This API uses an asynchronous callback to return the result. 1740e41f4b71Sopenharmony_ci 1741e41f4b71Sopenharmony_ci> **NOTE** 1742e41f4b71Sopenharmony_ci> 1743e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 1744e41f4b71Sopenharmony_ci 1745e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 1746e41f4b71Sopenharmony_ci 1747e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1748e41f4b71Sopenharmony_ci 1749e41f4b71Sopenharmony_ci**Parameters** 1750e41f4b71Sopenharmony_ci 1751e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1752e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 1753e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1754e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the account is activated; the value **false** means the opposite.| 1755e41f4b71Sopenharmony_ci 1756e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is activated. 1757e41f4b71Sopenharmony_ci 1758e41f4b71Sopenharmony_ci ```ts 1759e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1760e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1761e41f4b71Sopenharmony_ci let localId: number = 100; 1762e41f4b71Sopenharmony_ci accountManager.isOsAccountActived(localId, (err: BusinessError, isActived: boolean) => { 1763e41f4b71Sopenharmony_ci if (err) { 1764e41f4b71Sopenharmony_ci console.log('isOsAccountActived failed, err:' + JSON.stringify(err)); 1765e41f4b71Sopenharmony_ci } else { 1766e41f4b71Sopenharmony_ci console.log('isOsAccountActived successfully, isActived:' + isActived); 1767e41f4b71Sopenharmony_ci } 1768e41f4b71Sopenharmony_ci }); 1769e41f4b71Sopenharmony_ci ``` 1770e41f4b71Sopenharmony_ci 1771e41f4b71Sopenharmony_ci### isOsAccountActived<sup>(deprecated)</sup> 1772e41f4b71Sopenharmony_ci 1773e41f4b71Sopenharmony_ciisOsAccountActived(localId: number): Promise<boolean> 1774e41f4b71Sopenharmony_ci 1775e41f4b71Sopenharmony_ciChecks whether a system account is activated. This API uses a promise to return the result. 1776e41f4b71Sopenharmony_ci 1777e41f4b71Sopenharmony_ci> **NOTE** 1778e41f4b71Sopenharmony_ci> 1779e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 1780e41f4b71Sopenharmony_ci 1781e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 1782e41f4b71Sopenharmony_ci 1783e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1784e41f4b71Sopenharmony_ci 1785e41f4b71Sopenharmony_ci**Parameters** 1786e41f4b71Sopenharmony_ci 1787e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1788e41f4b71Sopenharmony_ci| ------- | ------ | ---- | --------------------------------- | 1789e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1790e41f4b71Sopenharmony_ci 1791e41f4b71Sopenharmony_ci**Return value** 1792e41f4b71Sopenharmony_ci 1793e41f4b71Sopenharmony_ci| Type | Description | 1794e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------------------------------- | 1795e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the account is activated; the value **false** means the opposite.| 1796e41f4b71Sopenharmony_ci 1797e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is activated. 1798e41f4b71Sopenharmony_ci 1799e41f4b71Sopenharmony_ci ```ts 1800e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1801e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1802e41f4b71Sopenharmony_ci let localId: number = 100; 1803e41f4b71Sopenharmony_ci accountManager.isOsAccountActived(localId).then((isActived: boolean) => { 1804e41f4b71Sopenharmony_ci console.log('isOsAccountActived successfully, isActived: ' + isActived); 1805e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1806e41f4b71Sopenharmony_ci console.log('isOsAccountActived failed, error: ' + JSON.stringify(err)); 1807e41f4b71Sopenharmony_ci }); 1808e41f4b71Sopenharmony_ci ``` 1809e41f4b71Sopenharmony_ci 1810e41f4b71Sopenharmony_ci### isOsAccountConstraintEnable<sup>(deprecated)</sup> 1811e41f4b71Sopenharmony_ci 1812e41f4b71Sopenharmony_ciisOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void 1813e41f4b71Sopenharmony_ci 1814e41f4b71Sopenharmony_ciChecks whether the specified constraint is enabled for a system account. This API uses an asynchronous callback to return the result. 1815e41f4b71Sopenharmony_ci 1816e41f4b71Sopenharmony_ci> **NOTE** 1817e41f4b71Sopenharmony_ci> 1818e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 1819e41f4b71Sopenharmony_ci 1820e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1821e41f4b71Sopenharmony_ci 1822e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1823e41f4b71Sopenharmony_ci 1824e41f4b71Sopenharmony_ci**Parameters** 1825e41f4b71Sopenharmony_ci 1826e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1827e41f4b71Sopenharmony_ci| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- | 1828e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1829e41f4b71Sopenharmony_ci| constraint | string | Yes | [Constraint](#constraints) to check. | 1830e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.| 1831e41f4b71Sopenharmony_ci 1832e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is forbidden to use Wi-Fi. 1833e41f4b71Sopenharmony_ci 1834e41f4b71Sopenharmony_ci ```ts 1835e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1836e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1837e41f4b71Sopenharmony_ci let localId: number = 100; 1838e41f4b71Sopenharmony_ci let constraint: string = 'constraint.wifi'; 1839e41f4b71Sopenharmony_ci accountManager.isOsAccountConstraintEnable(localId, constraint, (err: BusinessError, isEnabled: boolean) => { 1840e41f4b71Sopenharmony_ci if (err) { 1841e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err)); 1842e41f4b71Sopenharmony_ci } else { 1843e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled); 1844e41f4b71Sopenharmony_ci } 1845e41f4b71Sopenharmony_ci }); 1846e41f4b71Sopenharmony_ci ``` 1847e41f4b71Sopenharmony_ci 1848e41f4b71Sopenharmony_ci### isOsAccountConstraintEnable<sup>(deprecated)</sup> 1849e41f4b71Sopenharmony_ci 1850e41f4b71Sopenharmony_ciisOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean> 1851e41f4b71Sopenharmony_ci 1852e41f4b71Sopenharmony_ciChecks whether the specified constraint is enabled for a system account. This API uses a promise to return the result. 1853e41f4b71Sopenharmony_ci 1854e41f4b71Sopenharmony_ci> **NOTE** 1855e41f4b71Sopenharmony_ci> 1856e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 1857e41f4b71Sopenharmony_ci 1858e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 1859e41f4b71Sopenharmony_ci 1860e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1861e41f4b71Sopenharmony_ci 1862e41f4b71Sopenharmony_ci**Parameters** 1863e41f4b71Sopenharmony_ci 1864e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1865e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---------------------------------- | 1866e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 1867e41f4b71Sopenharmony_ci| constraint | string | Yes | [Constraint](#constraints) to check. | 1868e41f4b71Sopenharmony_ci 1869e41f4b71Sopenharmony_ci**Return value** 1870e41f4b71Sopenharmony_ci 1871e41f4b71Sopenharmony_ci| Type | Description | 1872e41f4b71Sopenharmony_ci| ---------------------- | --------------------------------------------------------------------- | 1873e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.| 1874e41f4b71Sopenharmony_ci 1875e41f4b71Sopenharmony_ci**Example**: Check whether system account 100 is forbidden to use Wi-Fi. 1876e41f4b71Sopenharmony_ci 1877e41f4b71Sopenharmony_ci ```ts 1878e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1879e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1880e41f4b71Sopenharmony_ci let localId: number = 100; 1881e41f4b71Sopenharmony_ci let constraint: string = 'constraint.wifi'; 1882e41f4b71Sopenharmony_ci accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled: boolean) => { 1883e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled); 1884e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1885e41f4b71Sopenharmony_ci console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err)); 1886e41f4b71Sopenharmony_ci }); 1887e41f4b71Sopenharmony_ci ``` 1888e41f4b71Sopenharmony_ci 1889e41f4b71Sopenharmony_ci### isTestOsAccount<sup>(deprecated)</sup> 1890e41f4b71Sopenharmony_ci 1891e41f4b71Sopenharmony_ciisTestOsAccount(callback: AsyncCallback<boolean>): void 1892e41f4b71Sopenharmony_ci 1893e41f4b71Sopenharmony_ciChecks whether this system account is a test account. This API uses an asynchronous callback to return the result. 1894e41f4b71Sopenharmony_ci 1895e41f4b71Sopenharmony_ci> **NOTE** 1896e41f4b71Sopenharmony_ci> 1897e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [checkOsAccountTestable](#checkosaccounttestable9) instead. 1898e41f4b71Sopenharmony_ci 1899e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1900e41f4b71Sopenharmony_ci 1901e41f4b71Sopenharmony_ci**Parameters** 1902e41f4b71Sopenharmony_ci 1903e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1904e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- | 1905e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.| 1906e41f4b71Sopenharmony_ci 1907e41f4b71Sopenharmony_ci**Example** 1908e41f4b71Sopenharmony_ci 1909e41f4b71Sopenharmony_ci ```ts 1910e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1911e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1912e41f4b71Sopenharmony_ci accountManager.isTestOsAccount((err: BusinessError, isTestable: boolean) => { 1913e41f4b71Sopenharmony_ci if (err) { 1914e41f4b71Sopenharmony_ci console.log('isTestOsAccount failed, error: ' + JSON.stringify(err)); 1915e41f4b71Sopenharmony_ci } else { 1916e41f4b71Sopenharmony_ci console.log('isTestOsAccount successfully, isTestable: ' + isTestable); 1917e41f4b71Sopenharmony_ci } 1918e41f4b71Sopenharmony_ci }); 1919e41f4b71Sopenharmony_ci ``` 1920e41f4b71Sopenharmony_ci 1921e41f4b71Sopenharmony_ci### isTestOsAccount<sup>(deprecated)</sup> 1922e41f4b71Sopenharmony_ci 1923e41f4b71Sopenharmony_ciisTestOsAccount(): Promise<boolean> 1924e41f4b71Sopenharmony_ci 1925e41f4b71Sopenharmony_ciChecks whether this system account is a test account. This API uses a promise to return the result. 1926e41f4b71Sopenharmony_ci 1927e41f4b71Sopenharmony_ci> **NOTE** 1928e41f4b71Sopenharmony_ci> 1929e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [checkOsAccountTestable](#checkosaccounttestable9-1) instead. 1930e41f4b71Sopenharmony_ci 1931e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1932e41f4b71Sopenharmony_ci 1933e41f4b71Sopenharmony_ci**Return value** 1934e41f4b71Sopenharmony_ci 1935e41f4b71Sopenharmony_ci| Type | Description | 1936e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------------------ | 1937e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the account is a test account; the value **false** means the opposite.| 1938e41f4b71Sopenharmony_ci 1939e41f4b71Sopenharmony_ci**Example** 1940e41f4b71Sopenharmony_ci 1941e41f4b71Sopenharmony_ci ```ts 1942e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1943e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1944e41f4b71Sopenharmony_ci accountManager.isTestOsAccount().then((isTestable: boolean) => { 1945e41f4b71Sopenharmony_ci console.log('isTestOsAccount successfully, isTestable: ' + isTestable); 1946e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 1947e41f4b71Sopenharmony_ci console.log('isTestOsAccount failed, error: ' + JSON.stringify(err)); 1948e41f4b71Sopenharmony_ci }); 1949e41f4b71Sopenharmony_ci ``` 1950e41f4b71Sopenharmony_ci 1951e41f4b71Sopenharmony_ci### isOsAccountVerified<sup>(deprecated)</sup> 1952e41f4b71Sopenharmony_ci 1953e41f4b71Sopenharmony_ciisOsAccountVerified(callback: AsyncCallback<boolean>): void 1954e41f4b71Sopenharmony_ci 1955e41f4b71Sopenharmony_ciChecks whether this system account has been verified. This API uses an asynchronous callback to return the result. 1956e41f4b71Sopenharmony_ci 1957e41f4b71Sopenharmony_ci> **NOTE** 1958e41f4b71Sopenharmony_ci> 1959e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [checkOsAccountVerified](#checkosaccountverified9) instead. 1960e41f4b71Sopenharmony_ci 1961e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 1962e41f4b71Sopenharmony_ci 1963e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1964e41f4b71Sopenharmony_ci 1965e41f4b71Sopenharmony_ci**Parameters** 1966e41f4b71Sopenharmony_ci 1967e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 1968e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 1969e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 1970e41f4b71Sopenharmony_ci 1971e41f4b71Sopenharmony_ci**Example** 1972e41f4b71Sopenharmony_ci 1973e41f4b71Sopenharmony_ci ```ts 1974e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 1975e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 1976e41f4b71Sopenharmony_ci accountManager.isOsAccountVerified((err: BusinessError, isVerified: boolean) => { 1977e41f4b71Sopenharmony_ci if (err) { 1978e41f4b71Sopenharmony_ci console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); 1979e41f4b71Sopenharmony_ci } else { 1980e41f4b71Sopenharmony_ci console.log('isOsAccountVerified successfully, isVerified: ' + isVerified); 1981e41f4b71Sopenharmony_ci } 1982e41f4b71Sopenharmony_ci }); 1983e41f4b71Sopenharmony_ci ``` 1984e41f4b71Sopenharmony_ci 1985e41f4b71Sopenharmony_ci### isOsAccountVerified<sup>(deprecated)</sup> 1986e41f4b71Sopenharmony_ci 1987e41f4b71Sopenharmony_ciisOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void 1988e41f4b71Sopenharmony_ci 1989e41f4b71Sopenharmony_ciChecks whether a system account has been verified. This API uses an asynchronous callback to return the result. 1990e41f4b71Sopenharmony_ci 1991e41f4b71Sopenharmony_ci> **NOTE** 1992e41f4b71Sopenharmony_ci> 1993e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 1994e41f4b71Sopenharmony_ci 1995e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 1996e41f4b71Sopenharmony_ci 1997e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 1998e41f4b71Sopenharmony_ci 1999e41f4b71Sopenharmony_ci**Parameters** 2000e41f4b71Sopenharmony_ci 2001e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2002e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 2003e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 2004e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 2005e41f4b71Sopenharmony_ci 2006e41f4b71Sopenharmony_ci**Example** 2007e41f4b71Sopenharmony_ci 2008e41f4b71Sopenharmony_ci ```ts 2009e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2010e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2011e41f4b71Sopenharmony_ci let localId: number = 100; 2012e41f4b71Sopenharmony_ci accountManager.isOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => { 2013e41f4b71Sopenharmony_ci if (err) { 2014e41f4b71Sopenharmony_ci console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); 2015e41f4b71Sopenharmony_ci } else { 2016e41f4b71Sopenharmony_ci console.log('isOsAccountVerified successfully, isVerified: ' + isVerified); 2017e41f4b71Sopenharmony_ci } 2018e41f4b71Sopenharmony_ci }); 2019e41f4b71Sopenharmony_ci ``` 2020e41f4b71Sopenharmony_ci 2021e41f4b71Sopenharmony_ci### isOsAccountVerified<sup>(deprecated)</sup> 2022e41f4b71Sopenharmony_ci 2023e41f4b71Sopenharmony_ciisOsAccountVerified(localId?: number): Promise<boolean> 2024e41f4b71Sopenharmony_ci 2025e41f4b71Sopenharmony_ciChecks whether a system account has been verified. This API uses a promise to return the result. 2026e41f4b71Sopenharmony_ci 2027e41f4b71Sopenharmony_ci> **NOTE** 2028e41f4b71Sopenharmony_ci> 2029e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 2030e41f4b71Sopenharmony_ci 2031e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (available only for system applications) 2032e41f4b71Sopenharmony_ci 2033e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2034e41f4b71Sopenharmony_ci 2035e41f4b71Sopenharmony_ci**Parameters** 2036e41f4b71Sopenharmony_ci 2037e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2038e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ---------------------------------------------------------------- | 2039e41f4b71Sopenharmony_ci| localId | number | No | ID of the target system account. If this parameter is not specified, this API checks whether the current system account has been verified. | 2040e41f4b71Sopenharmony_ci 2041e41f4b71Sopenharmony_ci**Return value** 2042e41f4b71Sopenharmony_ci 2043e41f4b71Sopenharmony_ci| Type | Description | 2044e41f4b71Sopenharmony_ci| ---------------------- | ----------------------------------------------------------------- | 2045e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.| 2046e41f4b71Sopenharmony_ci 2047e41f4b71Sopenharmony_ci**Example** 2048e41f4b71Sopenharmony_ci 2049e41f4b71Sopenharmony_ci ```ts 2050e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2051e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2052e41f4b71Sopenharmony_ci accountManager.isOsAccountVerified().then((isVerified: boolean) => { 2053e41f4b71Sopenharmony_ci console.log('isOsAccountVerified successfully, isVerified: ' + isVerified); 2054e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2055e41f4b71Sopenharmony_ci console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err)); 2056e41f4b71Sopenharmony_ci }); 2057e41f4b71Sopenharmony_ci ``` 2058e41f4b71Sopenharmony_ci 2059e41f4b71Sopenharmony_ci### getCreatedOsAccountsCount<sup>(deprecated)</sup> 2060e41f4b71Sopenharmony_ci 2061e41f4b71Sopenharmony_cigetCreatedOsAccountsCount(callback: AsyncCallback<number>): void 2062e41f4b71Sopenharmony_ci 2063e41f4b71Sopenharmony_ciObtains the number of system accounts created. This API uses an asynchronous callback to return the result. 2064e41f4b71Sopenharmony_ci 2065e41f4b71Sopenharmony_ci> **NOTE** 2066e41f4b71Sopenharmony_ci> 2067e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountCount](#getosaccountcount9) instead. 2068e41f4b71Sopenharmony_ci 2069e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2070e41f4b71Sopenharmony_ci 2071e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2072e41f4b71Sopenharmony_ci 2073e41f4b71Sopenharmony_ci**Parameters** 2074e41f4b71Sopenharmony_ci 2075e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2076e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 2077e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2078e41f4b71Sopenharmony_ci 2079e41f4b71Sopenharmony_ci**Example** 2080e41f4b71Sopenharmony_ci 2081e41f4b71Sopenharmony_ci ```ts 2082e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2083e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2084e41f4b71Sopenharmony_ci accountManager.getCreatedOsAccountsCount((err: BusinessError, count: number)=>{ 2085e41f4b71Sopenharmony_ci if (err) { 2086e41f4b71Sopenharmony_ci console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err)); 2087e41f4b71Sopenharmony_ci } else { 2088e41f4b71Sopenharmony_ci console.log('getCreatedOsAccountsCount successfully, count: ' + count); 2089e41f4b71Sopenharmony_ci } 2090e41f4b71Sopenharmony_ci }); 2091e41f4b71Sopenharmony_ci ``` 2092e41f4b71Sopenharmony_ci 2093e41f4b71Sopenharmony_ci### getCreatedOsAccountsCount<sup>(deprecated)</sup> 2094e41f4b71Sopenharmony_ci 2095e41f4b71Sopenharmony_cigetCreatedOsAccountsCount(): Promise<number> 2096e41f4b71Sopenharmony_ci 2097e41f4b71Sopenharmony_ciObtains the number of system accounts created. This API uses a promise to return the result. 2098e41f4b71Sopenharmony_ci 2099e41f4b71Sopenharmony_ci> **NOTE** 2100e41f4b71Sopenharmony_ci> 2101e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountCount](#getosaccountcount9-1) instead. 2102e41f4b71Sopenharmony_ci 2103e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2104e41f4b71Sopenharmony_ci 2105e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2106e41f4b71Sopenharmony_ci 2107e41f4b71Sopenharmony_ci**Return value** 2108e41f4b71Sopenharmony_ci 2109e41f4b71Sopenharmony_ci| Type | Description | 2110e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------- | 2111e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the number of created system accounts. | 2112e41f4b71Sopenharmony_ci 2113e41f4b71Sopenharmony_ci**Example** 2114e41f4b71Sopenharmony_ci 2115e41f4b71Sopenharmony_ci ```ts 2116e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2117e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2118e41f4b71Sopenharmony_ci accountManager.getCreatedOsAccountsCount().then((count: number) => { 2119e41f4b71Sopenharmony_ci console.log('getCreatedOsAccountsCount successfully, count: ' + count); 2120e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2121e41f4b71Sopenharmony_ci console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err)); 2122e41f4b71Sopenharmony_ci }); 2123e41f4b71Sopenharmony_ci ``` 2124e41f4b71Sopenharmony_ci 2125e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup> 2126e41f4b71Sopenharmony_ci 2127e41f4b71Sopenharmony_cigetOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void 2128e41f4b71Sopenharmony_ci 2129e41f4b71Sopenharmony_ciObtains the ID of the system account to which the current process belongs. This API uses an asynchronous callback to return the result. 2130e41f4b71Sopenharmony_ci 2131e41f4b71Sopenharmony_ci> **NOTE** 2132e41f4b71Sopenharmony_ci> 2133e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountLocalId](#getosaccountlocalid9) instead. 2134e41f4b71Sopenharmony_ci 2135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2136e41f4b71Sopenharmony_ci 2137e41f4b71Sopenharmony_ci**Parameters** 2138e41f4b71Sopenharmony_ci 2139e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2140e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- | 2141e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2142e41f4b71Sopenharmony_ci 2143e41f4b71Sopenharmony_ci**Example** 2144e41f4b71Sopenharmony_ci 2145e41f4b71Sopenharmony_ci ```ts 2146e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2147e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2148e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromProcess((err: BusinessError, localId: number) => { 2149e41f4b71Sopenharmony_ci if (err) { 2150e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err)); 2151e41f4b71Sopenharmony_ci } else { 2152e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromProcess failed, error: ' + localId); 2153e41f4b71Sopenharmony_ci } 2154e41f4b71Sopenharmony_ci }); 2155e41f4b71Sopenharmony_ci ``` 2156e41f4b71Sopenharmony_ci 2157e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup> 2158e41f4b71Sopenharmony_ci 2159e41f4b71Sopenharmony_cigetOsAccountLocalIdFromProcess(): Promise<number> 2160e41f4b71Sopenharmony_ci 2161e41f4b71Sopenharmony_ciObtains the ID of the system account to which the current process belongs. This API uses a promise to return the result. 2162e41f4b71Sopenharmony_ci 2163e41f4b71Sopenharmony_ci> **NOTE** 2164e41f4b71Sopenharmony_ci> 2165e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountLocalId](#getosaccountlocalid9-1) instead. 2166e41f4b71Sopenharmony_ci 2167e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2168e41f4b71Sopenharmony_ci 2169e41f4b71Sopenharmony_ci**Return value** 2170e41f4b71Sopenharmony_ci 2171e41f4b71Sopenharmony_ci| Type | Description | 2172e41f4b71Sopenharmony_ci| :-------------------- | :--------------------------------------- | 2173e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 2174e41f4b71Sopenharmony_ci 2175e41f4b71Sopenharmony_ci**Example** 2176e41f4b71Sopenharmony_ci 2177e41f4b71Sopenharmony_ci ```ts 2178e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2179e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2180e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromProcess().then((localId: number) => { 2181e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId); 2182e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2183e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err)); 2184e41f4b71Sopenharmony_ci }); 2185e41f4b71Sopenharmony_ci ``` 2186e41f4b71Sopenharmony_ci 2187e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromUid<sup>(deprecated)</sup> 2188e41f4b71Sopenharmony_ci 2189e41f4b71Sopenharmony_cigetOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void 2190e41f4b71Sopenharmony_ci 2191e41f4b71Sopenharmony_ciObtains the system account ID based on the process UID. This API uses an asynchronous callback to return the result. 2192e41f4b71Sopenharmony_ci 2193e41f4b71Sopenharmony_ci> **NOTE** 2194e41f4b71Sopenharmony_ci> 2195e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountLocalIdForUid](#getosaccountlocalidforuid9) instead. 2196e41f4b71Sopenharmony_ci 2197e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2198e41f4b71Sopenharmony_ci 2199e41f4b71Sopenharmony_ci**Parameters** 2200e41f4b71Sopenharmony_ci 2201e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2202e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 2203e41f4b71Sopenharmony_ci| uid | number | Yes | Process UID. | 2204e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2205e41f4b71Sopenharmony_ci 2206e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose process UID is **12345678**. 2207e41f4b71Sopenharmony_ci 2208e41f4b71Sopenharmony_ci ```ts 2209e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2210e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2211e41f4b71Sopenharmony_ci let uid: number = 12345678; 2212e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromUid(uid, (err: BusinessError, localId: number) => { 2213e41f4b71Sopenharmony_ci if (err) { 2214e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err)); 2215e41f4b71Sopenharmony_ci } else { 2216e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId); 2217e41f4b71Sopenharmony_ci } 2218e41f4b71Sopenharmony_ci }); 2219e41f4b71Sopenharmony_ci ``` 2220e41f4b71Sopenharmony_ci 2221e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromUid<sup>(deprecated)</sup> 2222e41f4b71Sopenharmony_ci 2223e41f4b71Sopenharmony_cigetOsAccountLocalIdFromUid(uid: number): Promise<number> 2224e41f4b71Sopenharmony_ci 2225e41f4b71Sopenharmony_ciObtains the system account ID based on the process UID. This API uses a promise to return the result. 2226e41f4b71Sopenharmony_ci 2227e41f4b71Sopenharmony_ci> **NOTE** 2228e41f4b71Sopenharmony_ci> 2229e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountLocalIdForUid](#getosaccountlocalidforuid9-1) instead. 2230e41f4b71Sopenharmony_ci 2231e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2232e41f4b71Sopenharmony_ci 2233e41f4b71Sopenharmony_ci**Parameters** 2234e41f4b71Sopenharmony_ci 2235e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2236e41f4b71Sopenharmony_ci| ------ | ------ | ---- | --------- | 2237e41f4b71Sopenharmony_ci| uid | number | Yes | Process UID. | 2238e41f4b71Sopenharmony_ci 2239e41f4b71Sopenharmony_ci**Return value** 2240e41f4b71Sopenharmony_ci 2241e41f4b71Sopenharmony_ci| Type | Description | 2242e41f4b71Sopenharmony_ci| :-------------------- | :----------------------------------- | 2243e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 2244e41f4b71Sopenharmony_ci 2245e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose process UID is **12345678**. 2246e41f4b71Sopenharmony_ci 2247e41f4b71Sopenharmony_ci ```ts 2248e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2249e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2250e41f4b71Sopenharmony_ci let uid: number = 12345678; 2251e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromUid(uid).then((localId: number) => { 2252e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId); 2253e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2254e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err)); 2255e41f4b71Sopenharmony_ci }); 2256e41f4b71Sopenharmony_ci ``` 2257e41f4b71Sopenharmony_ci 2258e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup> 2259e41f4b71Sopenharmony_ci 2260e41f4b71Sopenharmony_cigetOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void 2261e41f4b71Sopenharmony_ci 2262e41f4b71Sopenharmony_ciObtains the system account ID based on the domain account information. This API uses an asynchronous callback to return the result. 2263e41f4b71Sopenharmony_ci 2264e41f4b71Sopenharmony_ci> **NOTE** 2265e41f4b71Sopenharmony_ci> 2266e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9) instead. 2267e41f4b71Sopenharmony_ci 2268e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2269e41f4b71Sopenharmony_ci 2270e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2271e41f4b71Sopenharmony_ci 2272e41f4b71Sopenharmony_ci**Parameters** 2273e41f4b71Sopenharmony_ci 2274e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2275e41f4b71Sopenharmony_ci| ---------- | --------------------------------------- | ---- | --------------------------------------------------------------------------- | 2276e41f4b71Sopenharmony_ci| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. | 2277e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2278e41f4b71Sopenharmony_ci 2279e41f4b71Sopenharmony_ci**Example** 2280e41f4b71Sopenharmony_ci 2281e41f4b71Sopenharmony_ci ```ts 2282e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2283e41f4b71Sopenharmony_ci let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'}; 2284e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2285e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => { 2286e41f4b71Sopenharmony_ci if (err) { 2287e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err)); 2288e41f4b71Sopenharmony_ci } else { 2289e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId); 2290e41f4b71Sopenharmony_ci } 2291e41f4b71Sopenharmony_ci }); 2292e41f4b71Sopenharmony_ci ``` 2293e41f4b71Sopenharmony_ci 2294e41f4b71Sopenharmony_ci### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup> 2295e41f4b71Sopenharmony_ci 2296e41f4b71Sopenharmony_cigetOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> 2297e41f4b71Sopenharmony_ci 2298e41f4b71Sopenharmony_ciObtains the system account ID based on the domain account information. This API uses a promise to return the result. 2299e41f4b71Sopenharmony_ci 2300e41f4b71Sopenharmony_ci> **NOTE** 2301e41f4b71Sopenharmony_ci> 2302e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9-1) instead. 2303e41f4b71Sopenharmony_ci 2304e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2305e41f4b71Sopenharmony_ci 2306e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2307e41f4b71Sopenharmony_ci 2308e41f4b71Sopenharmony_ci**Parameters** 2309e41f4b71Sopenharmony_ci 2310e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2311e41f4b71Sopenharmony_ci| ---------- | --------------------------------------- | ---- | ------------ | 2312e41f4b71Sopenharmony_ci| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. | 2313e41f4b71Sopenharmony_ci 2314e41f4b71Sopenharmony_ci**Return value** 2315e41f4b71Sopenharmony_ci 2316e41f4b71Sopenharmony_ci| Type | Description | 2317e41f4b71Sopenharmony_ci| :-------------------- | :------------------------------------- | 2318e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the ID of the system account associated with the domain account. | 2319e41f4b71Sopenharmony_ci 2320e41f4b71Sopenharmony_ci**Example** 2321e41f4b71Sopenharmony_ci 2322e41f4b71Sopenharmony_ci ```ts 2323e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2324e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2325e41f4b71Sopenharmony_ci let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'}; 2326e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => { 2327e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId); 2328e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2329e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err)); 2330e41f4b71Sopenharmony_ci }); 2331e41f4b71Sopenharmony_ci ``` 2332e41f4b71Sopenharmony_ci 2333e41f4b71Sopenharmony_ci### getOsAccountAllConstraints<sup>(deprecated)</sup> 2334e41f4b71Sopenharmony_ci 2335e41f4b71Sopenharmony_cigetOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void 2336e41f4b71Sopenharmony_ci 2337e41f4b71Sopenharmony_ciObtains all constraints enabled for a system account. This API uses an asynchronous callback to return the result. 2338e41f4b71Sopenharmony_ci 2339e41f4b71Sopenharmony_ci> **NOTE** 2340e41f4b71Sopenharmony_ci> 2341e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 2342e41f4b71Sopenharmony_ci 2343e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2344e41f4b71Sopenharmony_ci 2345e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2346e41f4b71Sopenharmony_ci 2347e41f4b71Sopenharmony_ci**Parameters** 2348e41f4b71Sopenharmony_ci 2349e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2350e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ---------------------------------------------------------------------------------------------- | 2351e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 2352e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is a list of all [constraints](#constraints) enabled for the system account. Otherwise, **err** is an error object.| 2353e41f4b71Sopenharmony_ci 2354e41f4b71Sopenharmony_ci**Example**: Obtain all constraints of system account 100. 2355e41f4b71Sopenharmony_ci 2356e41f4b71Sopenharmony_ci ```ts 2357e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2358e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2359e41f4b71Sopenharmony_ci let localId: number = 100; 2360e41f4b71Sopenharmony_ci accountManager.getOsAccountAllConstraints(localId, (err: BusinessError, constraints: string[])=>{ 2361e41f4b71Sopenharmony_ci console.log('getOsAccountAllConstraints err:' + JSON.stringify(err)); 2362e41f4b71Sopenharmony_ci console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints)); 2363e41f4b71Sopenharmony_ci }); 2364e41f4b71Sopenharmony_ci ``` 2365e41f4b71Sopenharmony_ci 2366e41f4b71Sopenharmony_ci### getOsAccountAllConstraints<sup>(deprecated)</sup> 2367e41f4b71Sopenharmony_ci 2368e41f4b71Sopenharmony_cigetOsAccountAllConstraints(localId: number): Promise<Array<string>> 2369e41f4b71Sopenharmony_ci 2370e41f4b71Sopenharmony_ciObtains all constraints enabled for a system account. This API uses a promise to return the result. 2371e41f4b71Sopenharmony_ci 2372e41f4b71Sopenharmony_ci> **NOTE** 2373e41f4b71Sopenharmony_ci> 2374e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 2375e41f4b71Sopenharmony_ci 2376e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2377e41f4b71Sopenharmony_ci 2378e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2379e41f4b71Sopenharmony_ci 2380e41f4b71Sopenharmony_ci**Parameters** 2381e41f4b71Sopenharmony_ci 2382e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2383e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ------------ | 2384e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 2385e41f4b71Sopenharmony_ci 2386e41f4b71Sopenharmony_ci**Return value** 2387e41f4b71Sopenharmony_ci 2388e41f4b71Sopenharmony_ci| Type | Description | 2389e41f4b71Sopenharmony_ci| :--------------------------------- | :----------------------------------------------------------- | 2390e41f4b71Sopenharmony_ci| Promise<Array<string>> | Promise used to return all the [constraints](#constraints) enabled for the system account. | 2391e41f4b71Sopenharmony_ci 2392e41f4b71Sopenharmony_ci**Example**: Obtain all constraints of system account 100. 2393e41f4b71Sopenharmony_ci 2394e41f4b71Sopenharmony_ci ```ts 2395e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2396e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2397e41f4b71Sopenharmony_ci let localId: number = 100; 2398e41f4b71Sopenharmony_ci accountManager.getOsAccountAllConstraints(localId).then((constraints: string[]) => { 2399e41f4b71Sopenharmony_ci console.log('getOsAccountAllConstraints, constraints: ' + constraints); 2400e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2401e41f4b71Sopenharmony_ci console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err)); 2402e41f4b71Sopenharmony_ci }); 2403e41f4b71Sopenharmony_ci ``` 2404e41f4b71Sopenharmony_ci 2405e41f4b71Sopenharmony_ci### queryActivatedOsAccountIds<sup>(deprecated)</sup> 2406e41f4b71Sopenharmony_ci 2407e41f4b71Sopenharmony_ciqueryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void 2408e41f4b71Sopenharmony_ci 2409e41f4b71Sopenharmony_ciQueries information about all activated system accounts. This API uses an asynchronous callback to return the result. 2410e41f4b71Sopenharmony_ci 2411e41f4b71Sopenharmony_ci> **NOTE** 2412e41f4b71Sopenharmony_ci> 2413e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9) instead. 2414e41f4b71Sopenharmony_ci 2415e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2416e41f4b71Sopenharmony_ci 2417e41f4b71Sopenharmony_ci**Parameters** 2418e41f4b71Sopenharmony_ci 2419e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2420e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | 2421e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<number>> | Yes | Callback 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.| 2422e41f4b71Sopenharmony_ci 2423e41f4b71Sopenharmony_ci**Example** 2424e41f4b71Sopenharmony_ci 2425e41f4b71Sopenharmony_ci ```ts 2426e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2427e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2428e41f4b71Sopenharmony_ci accountManager.queryActivatedOsAccountIds((err: BusinessError, idArray: number[])=>{ 2429e41f4b71Sopenharmony_ci console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err)); 2430e41f4b71Sopenharmony_ci console.log('queryActivatedOsAccountIds idArray length:' + idArray.length); 2431e41f4b71Sopenharmony_ci for(let i=0;i<idArray.length;i++) { 2432e41f4b71Sopenharmony_ci console.info('activated os account id: ' + idArray[i]); 2433e41f4b71Sopenharmony_ci } 2434e41f4b71Sopenharmony_ci }); 2435e41f4b71Sopenharmony_ci ``` 2436e41f4b71Sopenharmony_ci 2437e41f4b71Sopenharmony_ci### queryActivatedOsAccountIds<sup>(deprecated)</sup> 2438e41f4b71Sopenharmony_ci 2439e41f4b71Sopenharmony_ciqueryActivatedOsAccountIds(): Promise<Array<number>> 2440e41f4b71Sopenharmony_ci 2441e41f4b71Sopenharmony_ci> **NOTE** 2442e41f4b71Sopenharmony_ci> 2443e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9-1) instead. 2444e41f4b71Sopenharmony_ci 2445e41f4b71Sopenharmony_ciObtains information about all activated system accounts. This API uses a promise to return the result. 2446e41f4b71Sopenharmony_ci 2447e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2448e41f4b71Sopenharmony_ci 2449e41f4b71Sopenharmony_ci**Return value** 2450e41f4b71Sopenharmony_ci 2451e41f4b71Sopenharmony_ci| Type | Description | 2452e41f4b71Sopenharmony_ci| ---------------------------------- | ------------------------------------------------- | 2453e41f4b71Sopenharmony_ci| Promise<Array<number>> | Promise used to return the information about all activated system accounts. | 2454e41f4b71Sopenharmony_ci 2455e41f4b71Sopenharmony_ci**Example** 2456e41f4b71Sopenharmony_ci 2457e41f4b71Sopenharmony_ci ```ts 2458e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2459e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2460e41f4b71Sopenharmony_ci accountManager.queryActivatedOsAccountIds().then((idArray: number[]) => { 2461e41f4b71Sopenharmony_ci console.log('queryActivatedOsAccountIds, idArray: ' + idArray); 2462e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2463e41f4b71Sopenharmony_ci console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err)); 2464e41f4b71Sopenharmony_ci }); 2465e41f4b71Sopenharmony_ci ``` 2466e41f4b71Sopenharmony_ci 2467e41f4b71Sopenharmony_ci### queryCurrentOsAccount<sup>(deprecated)</sup> 2468e41f4b71Sopenharmony_ci 2469e41f4b71Sopenharmony_ciqueryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void 2470e41f4b71Sopenharmony_ci 2471e41f4b71Sopenharmony_ciQueries information about the system account to which the current process belongs. This API uses an asynchronous callback to return the result. 2472e41f4b71Sopenharmony_ci 2473e41f4b71Sopenharmony_ci> **NOTE** 2474e41f4b71Sopenharmony_ci> 2475e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 2476e41f4b71Sopenharmony_ci 2477e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2478e41f4b71Sopenharmony_ci 2479e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2480e41f4b71Sopenharmony_ci 2481e41f4b71Sopenharmony_ci**Parameters** 2482e41f4b71Sopenharmony_ci 2483e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2484e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 2485e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback 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.| 2486e41f4b71Sopenharmony_ci 2487e41f4b71Sopenharmony_ci**Example** 2488e41f4b71Sopenharmony_ci 2489e41f4b71Sopenharmony_ci ```ts 2490e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2491e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2492e41f4b71Sopenharmony_ci accountManager.queryCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{ 2493e41f4b71Sopenharmony_ci console.log('queryCurrentOsAccount err:' + JSON.stringify(err)); 2494e41f4b71Sopenharmony_ci console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); 2495e41f4b71Sopenharmony_ci }); 2496e41f4b71Sopenharmony_ci ``` 2497e41f4b71Sopenharmony_ci 2498e41f4b71Sopenharmony_ci### queryCurrentOsAccount<sup>(deprecated)</sup> 2499e41f4b71Sopenharmony_ci 2500e41f4b71Sopenharmony_ciqueryCurrentOsAccount(): Promise<OsAccountInfo> 2501e41f4b71Sopenharmony_ci 2502e41f4b71Sopenharmony_ciQueries information about the system account to which the current process belongs. This API uses a promise to return the result. 2503e41f4b71Sopenharmony_ci 2504e41f4b71Sopenharmony_ci> **NOTE** 2505e41f4b71Sopenharmony_ci> 2506e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. The substitute API is available only to system applications. 2507e41f4b71Sopenharmony_ci 2508e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) 2509e41f4b71Sopenharmony_ci 2510e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2511e41f4b71Sopenharmony_ci 2512e41f4b71Sopenharmony_ci**Return value** 2513e41f4b71Sopenharmony_ci 2514e41f4b71Sopenharmony_ci| Type | Description | 2515e41f4b71Sopenharmony_ci| ---------------------------------------------- | ------------------------------------------ | 2516e41f4b71Sopenharmony_ci| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the system account information obtained. | 2517e41f4b71Sopenharmony_ci 2518e41f4b71Sopenharmony_ci**Example** 2519e41f4b71Sopenharmony_ci 2520e41f4b71Sopenharmony_ci ```ts 2521e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2522e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2523e41f4b71Sopenharmony_ci accountManager.queryCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => { 2524e41f4b71Sopenharmony_ci console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); 2525e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2526e41f4b71Sopenharmony_ci console.log('queryCurrentOsAccount err: ' + JSON.stringify(err)); 2527e41f4b71Sopenharmony_ci }); 2528e41f4b71Sopenharmony_ci ``` 2529e41f4b71Sopenharmony_ci 2530e41f4b71Sopenharmony_ci### getOsAccountTypeFromProcess<sup>(deprecated)</sup> 2531e41f4b71Sopenharmony_ci 2532e41f4b71Sopenharmony_cigetOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void 2533e41f4b71Sopenharmony_ci 2534e41f4b71Sopenharmony_ciObtains the type of the account to which the current process belongs. This API uses an asynchronous callback to return the result. 2535e41f4b71Sopenharmony_ci 2536e41f4b71Sopenharmony_ci> **NOTE** 2537e41f4b71Sopenharmony_ci> 2538e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountType](#getosaccounttype9) instead. 2539e41f4b71Sopenharmony_ci 2540e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2541e41f4b71Sopenharmony_ci 2542e41f4b71Sopenharmony_ci**Parameters** 2543e41f4b71Sopenharmony_ci 2544e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2545e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | 2546e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | Yes | Callback 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.| 2547e41f4b71Sopenharmony_ci 2548e41f4b71Sopenharmony_ci**Example** 2549e41f4b71Sopenharmony_ci 2550e41f4b71Sopenharmony_ci ```ts 2551e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2552e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2553e41f4b71Sopenharmony_ci accountManager.getOsAccountTypeFromProcess((err: BusinessError, accountType: osAccount.OsAccountType) => { 2554e41f4b71Sopenharmony_ci console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); 2555e41f4b71Sopenharmony_ci console.log('getOsAccountTypeFromProcess accountType: ' + accountType); 2556e41f4b71Sopenharmony_ci }); 2557e41f4b71Sopenharmony_ci ``` 2558e41f4b71Sopenharmony_ci 2559e41f4b71Sopenharmony_ci### getOsAccountTypeFromProcess<sup>(deprecated)</sup> 2560e41f4b71Sopenharmony_ci 2561e41f4b71Sopenharmony_cigetOsAccountTypeFromProcess(): Promise<OsAccountType> 2562e41f4b71Sopenharmony_ci 2563e41f4b71Sopenharmony_ciObtains the type of the account to which the current process belongs. This API uses a promise to return the result. 2564e41f4b71Sopenharmony_ci 2565e41f4b71Sopenharmony_ci> **NOTE** 2566e41f4b71Sopenharmony_ci> 2567e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [getOsAccountType](#getosaccounttype9-1) instead. 2568e41f4b71Sopenharmony_ci 2569e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2570e41f4b71Sopenharmony_ci 2571e41f4b71Sopenharmony_ci**Return value** 2572e41f4b71Sopenharmony_ci 2573e41f4b71Sopenharmony_ci| Type | Description | 2574e41f4b71Sopenharmony_ci| ---------------------------------------------- | ----------------------------------------------- | 2575e41f4b71Sopenharmony_ci| Promise<[OsAccountType](#osaccounttype)> | Promise used to return the system account type obtained. | 2576e41f4b71Sopenharmony_ci 2577e41f4b71Sopenharmony_ci**Example** 2578e41f4b71Sopenharmony_ci 2579e41f4b71Sopenharmony_ci ```ts 2580e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2581e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2582e41f4b71Sopenharmony_ci accountManager.getOsAccountTypeFromProcess().then((accountType: osAccount.OsAccountType) => { 2583e41f4b71Sopenharmony_ci console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); 2584e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2585e41f4b71Sopenharmony_ci console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); 2586e41f4b71Sopenharmony_ci }); 2587e41f4b71Sopenharmony_ci ``` 2588e41f4b71Sopenharmony_ci 2589e41f4b71Sopenharmony_ci### getDistributedVirtualDeviceId<sup>(deprecated)</sup> 2590e41f4b71Sopenharmony_ci 2591e41f4b71Sopenharmony_cigetDistributedVirtualDeviceId(callback: AsyncCallback<string>): void 2592e41f4b71Sopenharmony_ci 2593e41f4b71Sopenharmony_ciObtains the ID of this distributed virtual device. This API uses an asynchronous callback to return the result. 2594e41f4b71Sopenharmony_ci 2595e41f4b71Sopenharmony_ci> **NOTE** 2596e41f4b71Sopenharmony_ci> 2597e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9) instead. 2598e41f4b71Sopenharmony_ci 2599e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC 2600e41f4b71Sopenharmony_ci 2601e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2602e41f4b71Sopenharmony_ci 2603e41f4b71Sopenharmony_ci**Parameters** 2604e41f4b71Sopenharmony_ci 2605e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2606e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 2607e41f4b71Sopenharmony_ci| callback | AsyncCallback<string> | Yes | Callback 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.| 2608e41f4b71Sopenharmony_ci 2609e41f4b71Sopenharmony_ci**Example** 2610e41f4b71Sopenharmony_ci 2611e41f4b71Sopenharmony_ci ```ts 2612e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2613e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2614e41f4b71Sopenharmony_ci accountManager.getDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => { 2615e41f4b71Sopenharmony_ci console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); 2616e41f4b71Sopenharmony_ci console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID); 2617e41f4b71Sopenharmony_ci }); 2618e41f4b71Sopenharmony_ci ``` 2619e41f4b71Sopenharmony_ci 2620e41f4b71Sopenharmony_ci### getDistributedVirtualDeviceId<sup>(deprecated)</sup> 2621e41f4b71Sopenharmony_ci 2622e41f4b71Sopenharmony_cigetDistributedVirtualDeviceId(): Promise<string> 2623e41f4b71Sopenharmony_ci 2624e41f4b71Sopenharmony_ciObtains the ID of this distributed virtual device. This API uses a promise to return the result. 2625e41f4b71Sopenharmony_ci 2626e41f4b71Sopenharmony_ci> **NOTE** 2627e41f4b71Sopenharmony_ci> 2628e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. Use [queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1) instead. 2629e41f4b71Sopenharmony_ci 2630e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only for system applications) or ohos.permission.DISTRIBUTED_DATASYNC 2631e41f4b71Sopenharmony_ci 2632e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2633e41f4b71Sopenharmony_ci 2634e41f4b71Sopenharmony_ci**Return value** 2635e41f4b71Sopenharmony_ci 2636e41f4b71Sopenharmony_ci| Type | Description | 2637e41f4b71Sopenharmony_ci| --------------------- | --------------------------------- | 2638e41f4b71Sopenharmony_ci| Promise<string> | Promise used to return the distributed virtual device ID obtained. | 2639e41f4b71Sopenharmony_ci 2640e41f4b71Sopenharmony_ci**Example** 2641e41f4b71Sopenharmony_ci 2642e41f4b71Sopenharmony_ci ```ts 2643e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2644e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2645e41f4b71Sopenharmony_ci accountManager.getDistributedVirtualDeviceId().then((virtualID: string) => { 2646e41f4b71Sopenharmony_ci console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); 2647e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2648e41f4b71Sopenharmony_ci console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); 2649e41f4b71Sopenharmony_ci }); 2650e41f4b71Sopenharmony_ci ``` 2651e41f4b71Sopenharmony_ci 2652e41f4b71Sopenharmony_ci### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup> 2653e41f4b71Sopenharmony_ci 2654e41f4b71Sopenharmony_cigetOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void 2655e41f4b71Sopenharmony_ci 2656e41f4b71Sopenharmony_ciObtains the system account ID based on the SN. This API uses an asynchronous callback to return the result. 2657e41f4b71Sopenharmony_ci 2658e41f4b71Sopenharmony_ci> **NOTE** 2659e41f4b71Sopenharmony_ci> 2660e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9) instead. 2661e41f4b71Sopenharmony_ci 2662e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2663e41f4b71Sopenharmony_ci 2664e41f4b71Sopenharmony_ci**Parameters** 2665e41f4b71Sopenharmony_ci 2666e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2667e41f4b71Sopenharmony_ci| ------------ | --------------------------- | ---- | -------------------------------------------------------------------------------- | 2668e41f4b71Sopenharmony_ci| serialNumber | number | Yes | Account SN. | 2669e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2670e41f4b71Sopenharmony_ci 2671e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose SN is 12345. 2672e41f4b71Sopenharmony_ci 2673e41f4b71Sopenharmony_ci ```ts 2674e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2675e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2676e41f4b71Sopenharmony_ci let serialNumber: number = 12345; 2677e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err: BusinessError, localId: number)=>{ 2678e41f4b71Sopenharmony_ci console.log('ger localId err:' + JSON.stringify(err)); 2679e41f4b71Sopenharmony_ci console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); 2680e41f4b71Sopenharmony_ci }); 2681e41f4b71Sopenharmony_ci ``` 2682e41f4b71Sopenharmony_ci 2683e41f4b71Sopenharmony_ci### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup> 2684e41f4b71Sopenharmony_ci 2685e41f4b71Sopenharmony_cigetOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> 2686e41f4b71Sopenharmony_ci 2687e41f4b71Sopenharmony_ciObtains the system account ID based on the SN. This API uses a promise to return the result. 2688e41f4b71Sopenharmony_ci 2689e41f4b71Sopenharmony_ci> **NOTE** 2690e41f4b71Sopenharmony_ci> 2691e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9-1) instead. 2692e41f4b71Sopenharmony_ci 2693e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2694e41f4b71Sopenharmony_ci 2695e41f4b71Sopenharmony_ci**Parameters** 2696e41f4b71Sopenharmony_ci 2697e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2698e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | ---------- | 2699e41f4b71Sopenharmony_ci| serialNumber | number | Yes | Account SN. | 2700e41f4b71Sopenharmony_ci 2701e41f4b71Sopenharmony_ci**Return value** 2702e41f4b71Sopenharmony_ci 2703e41f4b71Sopenharmony_ci| Type | Description | 2704e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------------- | 2705e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the system account ID obtained. | 2706e41f4b71Sopenharmony_ci 2707e41f4b71Sopenharmony_ci**Example**: Obtain the ID of the system account whose SN is 12345. 2708e41f4b71Sopenharmony_ci 2709e41f4b71Sopenharmony_ci ```ts 2710e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2711e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2712e41f4b71Sopenharmony_ci let serialNumber: number = 12345; 2713e41f4b71Sopenharmony_ci accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId: number) => { 2714e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId); 2715e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2716e41f4b71Sopenharmony_ci console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err)); 2717e41f4b71Sopenharmony_ci }); 2718e41f4b71Sopenharmony_ci ``` 2719e41f4b71Sopenharmony_ci 2720e41f4b71Sopenharmony_ci### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup> 2721e41f4b71Sopenharmony_ci 2722e41f4b71Sopenharmony_cigetSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void 2723e41f4b71Sopenharmony_ci 2724e41f4b71Sopenharmony_ciObtains the SN of a system account based on the account ID. This API uses an asynchronous callback to return the result. 2725e41f4b71Sopenharmony_ci 2726e41f4b71Sopenharmony_ci> **NOTE** 2727e41f4b71Sopenharmony_ci> 2728e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9) instead. 2729e41f4b71Sopenharmony_ci 2730e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2731e41f4b71Sopenharmony_ci 2732e41f4b71Sopenharmony_ci**Parameters** 2733e41f4b71Sopenharmony_ci 2734e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2735e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | --------------------------------------------------------------------------- | 2736e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 2737e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback 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.| 2738e41f4b71Sopenharmony_ci 2739e41f4b71Sopenharmony_ci**Example**: Obtain the SN of the system account 100. 2740e41f4b71Sopenharmony_ci 2741e41f4b71Sopenharmony_ci ```ts 2742e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2743e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2744e41f4b71Sopenharmony_ci let localId: number = 100; 2745e41f4b71Sopenharmony_ci accountManager.getSerialNumberByOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{ 2746e41f4b71Sopenharmony_ci console.log('ger serialNumber err:' + JSON.stringify(err)); 2747e41f4b71Sopenharmony_ci console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); 2748e41f4b71Sopenharmony_ci }); 2749e41f4b71Sopenharmony_ci ``` 2750e41f4b71Sopenharmony_ci 2751e41f4b71Sopenharmony_ci### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup> 2752e41f4b71Sopenharmony_ci 2753e41f4b71Sopenharmony_cigetSerialNumberByOsAccountLocalId(localId: number): Promise<number> 2754e41f4b71Sopenharmony_ci 2755e41f4b71Sopenharmony_ciObtains the SN of a system account based on the account ID. This API uses a promise to return the result. 2756e41f4b71Sopenharmony_ci 2757e41f4b71Sopenharmony_ci> **NOTE** 2758e41f4b71Sopenharmony_ci> 2759e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. Use [getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9-1) instead. 2760e41f4b71Sopenharmony_ci 2761e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2762e41f4b71Sopenharmony_ci 2763e41f4b71Sopenharmony_ci**Parameters** 2764e41f4b71Sopenharmony_ci 2765e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2766e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ----------- | 2767e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the target system account. | 2768e41f4b71Sopenharmony_ci 2769e41f4b71Sopenharmony_ci**Return value** 2770e41f4b71Sopenharmony_ci 2771e41f4b71Sopenharmony_ci| Type | Description | 2772e41f4b71Sopenharmony_ci| --------------------- | -------------------------------------- | 2773e41f4b71Sopenharmony_ci| Promise<number> | Promise used to return the SN obtained. | 2774e41f4b71Sopenharmony_ci 2775e41f4b71Sopenharmony_ci**Example**: Obtain the SN of the system account 100. 2776e41f4b71Sopenharmony_ci 2777e41f4b71Sopenharmony_ci ```ts 2778e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2779e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2780e41f4b71Sopenharmony_ci let localId: number = 100; 2781e41f4b71Sopenharmony_ci accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber: number) => { 2782e41f4b71Sopenharmony_ci console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber); 2783e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2784e41f4b71Sopenharmony_ci console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err)); 2785e41f4b71Sopenharmony_ci }); 2786e41f4b71Sopenharmony_ci ``` 2787e41f4b71Sopenharmony_ci 2788e41f4b71Sopenharmony_ci### getOsAccountName<sup>12+</sup> 2789e41f4b71Sopenharmony_ci 2790e41f4b71Sopenharmony_cigetOsAccountName(): Promise<string> 2791e41f4b71Sopenharmony_ci 2792e41f4b71Sopenharmony_ciObtains the name of the system account of the caller. This API uses a promise to return the result. 2793e41f4b71Sopenharmony_ci 2794e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2795e41f4b71Sopenharmony_ci 2796e41f4b71Sopenharmony_ci**Return value** 2797e41f4b71Sopenharmony_ci 2798e41f4b71Sopenharmony_ci| Type | Description | 2799e41f4b71Sopenharmony_ci| :------------------------ | ----------------------- | 2800e41f4b71Sopenharmony_ci| Promise<string> | Promise used to return the system account name obtained. | 2801e41f4b71Sopenharmony_ci 2802e41f4b71Sopenharmony_ci**Error codes** 2803e41f4b71Sopenharmony_ci 2804e41f4b71Sopenharmony_ci| ID | Error Message | 2805e41f4b71Sopenharmony_ci| -------- | --------------------------- | 2806e41f4b71Sopenharmony_ci| 12300001 | The system service works abnormally. | 2807e41f4b71Sopenharmony_ci 2808e41f4b71Sopenharmony_ci**Example** 2809e41f4b71Sopenharmony_ci ```ts 2810e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 2811e41f4b71Sopenharmony_ci let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 2812e41f4b71Sopenharmony_ci try { 2813e41f4b71Sopenharmony_ci accountManager.getOsAccountName().then((name: string) => { 2814e41f4b71Sopenharmony_ci console.log('getOsAccountName, name: ' + name); 2815e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2816e41f4b71Sopenharmony_ci console.log('getOsAccountName err: ' + err); 2817e41f4b71Sopenharmony_ci }); 2818e41f4b71Sopenharmony_ci } catch (e) { 2819e41f4b71Sopenharmony_ci console.log('getOsAccountName exception: ' + e); 2820e41f4b71Sopenharmony_ci } 2821e41f4b71Sopenharmony_ci ``` 2822e41f4b71Sopenharmony_ci 2823e41f4b71Sopenharmony_ci## OsAccountInfo 2824e41f4b71Sopenharmony_ci 2825e41f4b71Sopenharmony_ciRepresents information about a system account. 2826e41f4b71Sopenharmony_ci 2827e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2828e41f4b71Sopenharmony_ci 2829e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2830e41f4b71Sopenharmony_ci| ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------- | 2831e41f4b71Sopenharmony_ci| localId | number | Yes | ID of the system account. | 2832e41f4b71Sopenharmony_ci| localName | string | Yes | Name of the system account. | 2833e41f4b71Sopenharmony_ci| type | [OsAccountType](#osaccounttype) | Yes | Type of the system account. | 2834e41f4b71Sopenharmony_ci| constraints | Array<string> | Yes | [Constraints](#constraints) of the system account. By default, no value is passed in.| 2835e41f4b71Sopenharmony_ci| isVerified<sup>(deprecated)</sup> | boolean | Yes | Whether the account has been verified.<br>**NOTE**<br/>This parameter is supported since API version 7 and deprecated since API version 11. | 2836e41f4b71Sopenharmony_ci| isUnlocked<sup>11+</sup> | boolean | Yes | Whether the account is unlocked (whether the **el2/** directory is decrypted). | 2837e41f4b71Sopenharmony_ci| photo<sup>8+</sup> | string | Yes | Avatar of the system account. By default, no value is passed in. | 2838e41f4b71Sopenharmony_ci| createTime<sup>8+</sup> | number | Yes | Time when the system account was created. | 2839e41f4b71Sopenharmony_ci| lastLoginTime<sup>8+</sup> | number | Yes | Last login time of the system account. By default, no value is passed in. | 2840e41f4b71Sopenharmony_ci| serialNumber<sup>8+</sup> | number | Yes | SN of the system account. | 2841e41f4b71Sopenharmony_ci| isActived<sup>(deprecated)</sup> | boolean | Yes | Whether the system account is activated.<br>**NOTE**<br/>This parameter is supported since API version 7 and deprecated since API version 11. | 2842e41f4b71Sopenharmony_ci| isActivated<sup>11+</sup> | boolean | Yes | Whether the system account is activated. | 2843e41f4b71Sopenharmony_ci| isCreateCompleted<sup>8+</sup> | boolean | Yes | Whether the system account information is complete. | 2844e41f4b71Sopenharmony_ci| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md#distributedinfo) | Yes | Distributed account information. By default, no value is passed in. | 2845e41f4b71Sopenharmony_ci| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. By default, no value is passed in. | 2846e41f4b71Sopenharmony_ci 2847e41f4b71Sopenharmony_ci## DomainAccountInfo<sup>8+</sup> 2848e41f4b71Sopenharmony_ci 2849e41f4b71Sopenharmony_ciRepresents information about a domain account. 2850e41f4b71Sopenharmony_ci 2851e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Account.OsAccount 2852e41f4b71Sopenharmony_ci 2853e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 2854e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ---------- | 2855e41f4b71Sopenharmony_ci| domain | string | Yes | Domain name. | 2856e41f4b71Sopenharmony_ci| accountName | string | Yes | Domain account name. | 2857e41f4b71Sopenharmony_ci 2858e41f4b71Sopenharmony_ci## Constraints 2859e41f4b71Sopenharmony_ci 2860e41f4b71Sopenharmony_ci| Constraint | Description | 2861e41f4b71Sopenharmony_ci| ------------------------------------- | ------------------------------ | 2862e41f4b71Sopenharmony_ci| constraint.wifi | Disallow the use of Wi-Fi. | 2863e41f4b71Sopenharmony_ci| constraint.wifi.set | Disallow setting of Wi-Fi. | 2864e41f4b71Sopenharmony_ci| constraint.locale.set | Disallow setting of the language to use. | 2865e41f4b71Sopenharmony_ci| constraint.app.accounts | Disallow adding or deletion of app accounts. | 2866e41f4b71Sopenharmony_ci| constraint.apps.install | Disallow app installation. | 2867e41f4b71Sopenharmony_ci| constraint.apps.uninstall | Disallow app uninstallation. | 2868e41f4b71Sopenharmony_ci| constraint.location.shared | Disallow location sharing. | 2869e41f4b71Sopenharmony_ci| constraint.unknown.sources.install | Disallow installation of apps from unknown sources. | 2870e41f4b71Sopenharmony_ci| constraint.global.unknown.app.install | Disallow installation of apps from unknown sources for all users. | 2871e41f4b71Sopenharmony_ci| constraint.bluetooth.set | Disallow setting of Bluetooth. | 2872e41f4b71Sopenharmony_ci| constraint.bluetooth | Disallow the use of Bluetooth.| 2873e41f4b71Sopenharmony_ci| constraint.bluetooth.share | Disallow Bluetooth sharing.| 2874e41f4b71Sopenharmony_ci| constraint.usb.file.transfer | Disallow file transfer over USB.| 2875e41f4b71Sopenharmony_ci| constraint.credentials.set | Disallow setting of user credentials.| 2876e41f4b71Sopenharmony_ci| constraint.os.account.remove | Disallow removal of users.| 2877e41f4b71Sopenharmony_ci| constraint.managed.profile.remove | Disallow removal of the managed profiles of this user.| 2878e41f4b71Sopenharmony_ci| constraint.debug.features.use | Disallow the use of debugging features.| 2879e41f4b71Sopenharmony_ci| constraint.vpn.set | Disallow setting of VPN.| 2880e41f4b71Sopenharmony_ci| constraint.date.time.set | Disallow setting of date, time, or time zone.| 2881e41f4b71Sopenharmony_ci| constraint.tethering.config | Disallow setting of Tethering.| 2882e41f4b71Sopenharmony_ci| constraint.network.reset | Disallow reset of network settings.| 2883e41f4b71Sopenharmony_ci| constraint.factory.reset | Disallow reset to factory settings.| 2884e41f4b71Sopenharmony_ci| constraint.os.account.create | Disallow creation of new users.| 2885e41f4b71Sopenharmony_ci| constraint.add.managed.profile | Disallow addition of managed profiles.| 2886e41f4b71Sopenharmony_ci| constraint.apps.verify.disable | Disallow app verification from being disabled.| 2887e41f4b71Sopenharmony_ci| constraint.cell.broadcasts.set | Disallow setting of cell broadcasts.| 2888e41f4b71Sopenharmony_ci| constraint.mobile.networks.set | Disallow setting of mobile networks.| 2889e41f4b71Sopenharmony_ci| constraint.control.apps | Disallow modification of apps in **Settings** or the boot module.| 2890e41f4b71Sopenharmony_ci| constraint.physical.media | Disallow mounting of external physical media.| 2891e41f4b71Sopenharmony_ci| constraint.microphone | Disallow the use of microphones.| 2892e41f4b71Sopenharmony_ci| constraint.microphone.unmute | Disallow unmuting of the microphone.| 2893e41f4b71Sopenharmony_ci| constraint.volume.adjust | Disallow adjustment of the volume.| 2894e41f4b71Sopenharmony_ci| constraint.calls.outgoing | Disallow outgoing calls.| 2895e41f4b71Sopenharmony_ci| constraint.sms.use | Disallow the use of the short message service (SMS).| 2896e41f4b71Sopenharmony_ci| constraint.fun | Disallow the use of entertainment features.| 2897e41f4b71Sopenharmony_ci| constraint.windows.create | Disallow creation of the windows other than app windows.| 2898e41f4b71Sopenharmony_ci| constraint.system.error.dialogs | Disallow display of error dialogs for crashed or unresponsive apps.| 2899e41f4b71Sopenharmony_ci| constraint.cross.profile.copy.paste | Disallow pasting of clipboard content to other users or profiles.| 2900e41f4b71Sopenharmony_ci| constraint.beam.outgoing | Disallow the use of Near Field Communications (NFC) to transfer data from apps.| 2901e41f4b71Sopenharmony_ci| constraint.wallpaper | Disallow wallpaper management.| 2902e41f4b71Sopenharmony_ci| constraint.safe.boot | Disallow reboot of the device in safe boot mode.| 2903e41f4b71Sopenharmony_ci| constraint.parent.profile.app.linking | Disallow the app in the parent profile from handling web links from the managed profiles.| 2904e41f4b71Sopenharmony_ci| constraint.audio.record | Disallow audio recording.| 2905e41f4b71Sopenharmony_ci| constraint.camera.use | Disallow the use of cameras.| 2906e41f4b71Sopenharmony_ci| constraint.os.account.background.run | Disallow background system accounts.| 2907e41f4b71Sopenharmony_ci| constraint.data.roam | Disallow the use of cellular data when roaming.| 2908e41f4b71Sopenharmony_ci| constraint.os.account.set.icon | Disallow setting of user icons.| 2909e41f4b71Sopenharmony_ci| constraint.wallpaper.set | Disallow setting of wallpapers.| 2910e41f4b71Sopenharmony_ci| constraint.oem.unlock | Disallow the use of OEM unlock.| 2911e41f4b71Sopenharmony_ci| constraint.device.unmute | Disallow unmuting of the device.| 2912e41f4b71Sopenharmony_ci| constraint.password.unified | Disallow the use of the unified lock screen challenge for the managed profile with the primary user.| 2913e41f4b71Sopenharmony_ci| constraint.autofill | Disallow the use of the autofill service.| 2914e41f4b71Sopenharmony_ci| constraint.content.capture | Disallow capturing of the screen content.| 2915e41f4b71Sopenharmony_ci| constraint.content.suggestions | Disallow receiving of content suggestions.| 2916e41f4b71Sopenharmony_ci| constraint.os.account.activate | Disallow activating of system accounts in the foreground.| 2917e41f4b71Sopenharmony_ci| constraint.location.set | Disallow setting of the location service.| 2918e41f4b71Sopenharmony_ci| constraint.airplane.mode.set | Disallow setting of the airplane mode.| 2919e41f4b71Sopenharmony_ci| constraint.brightness.set | Disallow setting of the brightness.| 2920e41f4b71Sopenharmony_ci| constraint.share.into.profile | Disallow sharing of files, images, and data of the primary user to the managed profiles.| 2921e41f4b71Sopenharmony_ci| constraint.ambient.display | Disallow display of the ambient environment.| 2922e41f4b71Sopenharmony_ci| constraint.screen.timeout.set | Disallow setting of the screen-off timeout.| 2923e41f4b71Sopenharmony_ci| constraint.print | Disallow printing.| 2924e41f4b71Sopenharmony_ci| constraint.private.dns.set | Disallow setting of the private domain name server (DNS).| 2925