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