1# @ohos.account.osAccount (系统账号管理) 2 3本模块提供管理系统账号的基础能力,包括系统账号的添加、删除、查询、设置、订阅、启动等功能。 4 5> **说明:** 6> 7> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8 9## 导入模块 10 11```ts 12import { osAccount } from '@kit.BasicServicesKit'; 13``` 14 15## osAccount.getAccountManager 16 17getAccountManager(): AccountManager 18 19获取系统账号管理对象。 20 21**系统能力:** SystemCapability.Account.OsAccount 22 23**返回值:** 24 25| 类型 | 说明 | 26| --------------------------------- | ---------------- | 27| [AccountManager](#accountmanager) | 系统账号管理对象。 | 28 29**示例:** 30 31 ```ts 32 let accountManager: osAccount.AccountManager = osAccount.getAccountManager(); 33 ``` 34 35## OsAccountType 36 37表示系统账号类型的枚举。 38 39**系统能力:** SystemCapability.Account.OsAccount。 40 41| 名称 | 值 | 说明 | 42| ------ | ------ | ----------- | 43| ADMIN | 0 | 管理员账号。 | 44| NORMAL | 1 | 普通账号。 | 45| GUEST | 2 | 访客账号。 | 46 47## AccountManager 48 49系统账号管理类。 50 51### checkMultiOsAccountEnabled<sup>9+</sup> 52 53checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void 54 55判断是否支持多系统账号。使用callback异步回调。 56 57**系统能力:** SystemCapability.Account.OsAccount 58 59**参数:** 60 61| 参数名 | 类型 | 必填 | 说明 | 62| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 63| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示支持多系统账号;返回false表示不支持。 | 64 65**错误码:** 66 67| 错误码ID | 错误信息 | 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**示例:** 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 94判断是否支持多系统账号。使用Promise异步回调。 95 96**系统能力:** SystemCapability.Account.OsAccount 97 98**返回值:** 99 100| 类型 | 说明 | 101| :--------------------- | :--------------------------------------------------------- | 102| Promise<boolean> | Promise对象。返回true表示支持多系统账号;返回false表示不支持。 | 103 104**错误码:** 105 106| 错误码ID | 错误信息 | 107| -------- | ------------------- | 108| 12300001 | The system service works abnormally. | 109 110**示例:** 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 130判断指定系统账号是否处于激活状态。使用callback异步回调。 131 132> **说明:** 133> 134> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 135 136**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 137 138**系统能力:** SystemCapability.Account.OsAccount 139 140**参数:** 141 142| 参数名 | 类型 | 必填 | 说明 | 143| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 144| localId | number | 是 | 系统账号ID。 | 145| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示账号已激活;返回false表示账号未激活。 | 146 147**错误码:** 148 149| 错误码ID | 错误信息 | 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**示例:** 判断ID为100的系统账号是否处于激活状态 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 180判断指定系统账号是否处于激活状态。使用Promise异步回调。 181 182> **说明:** 183> 184> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 185 186**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 187 188**系统能力:** SystemCapability.Account.OsAccount 189 190**参数:** 191 192| 参数名 | 类型 | 必填 | 说明 | 193| ------- | ------ | ---- | --------------------------------- | 194| localId | number | 是 | 系统账号ID。 | 195 196**返回值:** 197 198| 类型 | 说明 | 199| ---------------------- | ---------------------------------------------------------- | 200| Promise<boolean> | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 | 201 202**错误码:** 203 204| 错误码ID | 错误信息 | 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**示例:** 判断ID为100的系统账号是否处于激活状态 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 233判断当前系统账号是否使能指定约束。使用Promise异步回调。 234 235**系统能力:** SystemCapability.Account.OsAccount 236 237**参数:** 238 239| 参数名 | 类型 | 必填 | 说明 | 240| ---------- | ------ | ---- | ---------------------------------- | 241| constraint | string | 是 | 指定的[约束](#系统账号约束列表)名称。 | 242 243**返回值:** 244 245| 类型 | 说明 | 246| --------------------- | --------------------------------------------------------------------- | 247| Promise<boolean> | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 | 248 249**错误码:** 250 251| 错误码ID | 错误信息 | 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**示例:** 判断ID为100的系统账号是否有禁止使用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 277判断指定系统账号是否具有指定约束。使用callback异步回调。 278 279> **说明:** 280> 281> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 282 283**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 284 285**系统能力:** SystemCapability.Account.OsAccount 286 287**参数:** 288 289| 参数名 | 类型 | 必填 | 说明 | 290| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- | 291| localId | number | 是 | 系统账号ID。 | 292| constraint | string | 是 | 指定的[约束](#系统账号约束列表)名称。 | 293| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 | 294 295**错误码:** 296 297| 错误码ID | 错误信息 | 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**示例:** 判断ID为100的系统账号是否有禁止使用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 329判断指定系统账号是否具有指定约束。使用Promise异步回调。 330 331> **说明:** 332> 333> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 334 335**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 336 337**系统能力:** SystemCapability.Account.OsAccount 338 339**参数:** 340 341| 参数名 | 类型 | 必填 | 说明 | 342| ---------- | ------ | ---- | ---------------------------------- | 343| localId | number | 是 | 系统账号ID。 | 344| constraint | string | 是 | 指定的[约束](#系统账号约束列表)名称。 | 345 346**返回值:** 347 348| 类型 | 说明 | 349| --------------------- | --------------------------------------------------------------------- | 350| Promise<boolean> | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 | 351 352**错误码:** 353 354| 错误码ID | 错误信息 | 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**示例:** 判断ID为100的系统账号是否有禁止使用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 384检查当前系统账号是否为测试账号。使用callback异步回调。 385 386**系统能力:** SystemCapability.Account.OsAccount 387 388**参数:** 389 390| 参数名 | 类型 | 必填 | 说明 | 391| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- | 392| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 | 393 394**错误码:** 395 396| 错误码ID | 错误信息 | 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**示例:** 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 423检查当前系统账号是否为测试账号。使用Promise异步回调。 424 425**系统能力:** SystemCapability.Account.OsAccount 426 427**返回值:** 428 429| 类型 | 说明 | 430| ---------------------- | ------------------------------------------------------------------------ | 431| Promise<boolean> | Promise对象。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 | 432 433**错误码:** 434 435| 错误码ID | 错误信息 | 436| -------- | ------------------- | 437| 12300001 | The system service works abnormally. | 438 439**示例:** 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 459检查当前系统账号是否已认证解锁。使用Promise异步回调。 460 461**系统能力:** SystemCapability.Account.OsAccount 462 463**返回值:** 464 465| 类型 | 说明 | 466| ---------------------- | ------------------------------------------------------------------------ | 467| Promise<boolean> | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 | 468 469**错误码:** 470 471| 错误码ID | 错误信息 | 472| -------- | ------------------- | 473| 12300001 | The system service works abnormally. | 474 475**示例:** 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 495检查当前系统账号是否已认证解锁。使用callback异步回调。 496 497> **说明:** 498> 499> 从 API version 9开始支持,从API version 11开始废弃。建议使用[isOsAccountUnlocked](#isosaccountunlocked11)替代。 500 501**系统能力:** SystemCapability.Account.OsAccount 502 503**参数:** 504 505| 参数名 | 类型 | 必填 | 说明 | 506| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 507| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 | 508 509**错误码:** 510 511| 错误码ID | 错误信息 | 512| -------- | ------------------- | 513| 12300001 | The system service works abnormally. | 514 515**示例:** 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 537检查当前系统账号是否已认证解锁。使用Promise异步回调。 538 539> **说明:** 540> 541> 从 API version 9开始支持,从API version 11开始废弃。建议使用[isOsAccountUnlocked](#isosaccountunlocked11)替代。 542 543**系统能力:** SystemCapability.Account.OsAccount 544 545**返回值:** 546 547| 类型 | 说明 | 548| ---------------------- | ------------------------------------------------------------------------ | 549| Promise<boolean> | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 | 550 551**错误码:** 552 553| 错误码ID | 错误信息 | 554| -------- | ------------------- | 555| 12300001 | The system service works abnormally. | 556 557**示例:** 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 577检查指定系统账号是否已验证。使用callback异步回调。 578 579> **说明:** 580> 581> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 582 583**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 584 585**系统能力:** SystemCapability.Account.OsAccount 586 587**参数:** 588 589| 参数名 | 类型 | 必填 | 说明 | 590| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 591| localId | number | 是 | 系统账号ID。 | 592| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 | 593 594**错误码:** 595 596| 错误码ID | 错误信息 | 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**示例:** 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 627检查指定系统账号是否已验证。使用Promise异步回调。 628 629> **说明:** 630> 631> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 632 633**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 634 635**系统能力:** SystemCapability.Account.OsAccount 636 637**参数:** 638 639| 参数名 | 类型 | 必填 | 说明 | 640| ------- | ------ | ---- | --------------------------------------------------------------- | 641| localId | number | 是 | 系统账号ID。不填则检查当前系统账号是否已验证。 | 642 643**返回值:** 644 645| 类型 | 说明 | 646| ---------------------- | ----------------------------------------------------------------- | 647| Promise<boolean> | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 | 648 649**错误码:** 650 651| 错误码ID | 错误信息 | 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**示例:** 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 680检查当前系统账号是否已验证。使用Promise异步回调。 681 682**系统能力:** SystemCapability.Account.OsAccount 683 684**返回值:** 685 686| 类型 | 说明 | 687| ---------------------- | ----------------------------------------------------------------- | 688| Promise<boolean> | Promise对象。返回true表示当前账号已验证;返回false表示当前账号未验证。 | 689 690**错误码:** 691 692| 错误码ID | 错误信息 | 693| -------- | ------------------- | 694| 12300001 | The system service works abnormally. | 695 696**示例:** 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 716获取已创建的系统账号数量。使用callback异步回调。 717 718**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 719 720**系统能力:** SystemCapability.Account.OsAccount 721 722**参数:** 723 724| 参数名 | 类型 | 必填 | 说明 | 725| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 726| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为已创建的系统账号的数量;否则为错误对象。 | 727 728**错误码:** 729 730| 错误码ID | 错误信息 | 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**示例:** 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 758获取已创建的系统账号数量。使用Promise异步回调。 759 760**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 761 762**系统能力:** SystemCapability.Account.OsAccount 763 764**返回值:** 765 766| 类型 | 说明 | 767| --------------------- | -------------------------------------- | 768| Promise<number> | Promise对象,返回已创建的系统账号的数量。 | 769 770**错误码:** 771 772| 错误码ID | 错误信息 | 773| -------- | ------------------- | 774| 201 | Permission denied.| 775| 12300001 | The system service works abnormally. | 776 777**示例:** 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 797获取当前进程所属的系统账号ID,使用callback异步回调。 798 799**系统能力:** SystemCapability.Account.OsAccount 800 801**参数:** 802 803| 参数名 | 类型 | 必填 | 说明 | 804| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- | 805| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 | 806 807**错误码:** 808 809| 错误码ID | 错误信息 | 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**示例:** 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 836获取当前进程所属的系统账号ID,使用Promise异步回调。 837 838**系统能力:** SystemCapability.Account.OsAccount 839 840**返回值:** 841 842| 类型 | 说明 | 843| --------------------- | ---------------------------------------- | 844| Promise<number> | Promise对象,返回当前进程所属的系统账号ID。 | 845 846**错误码:** 847 848| 错误码ID | 错误信息 | 849| -------- | ------------------- | 850| 12300001 | The system service works abnormally. | 851 852**示例:** 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 872根据uid查询对应的系统账号ID,使用callback异步回调。 873 874**系统能力:** SystemCapability.Account.OsAccount 875 876**参数:** 877 878| 参数名 | 类型 | 必填 | 说明 | 879| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 880| uid | number | 是 | 进程uid。 | 881| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 | 882 883**错误码:** 884 885| 错误码ID | 错误信息 | 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**示例:** 查询值为12345678的uid所属的系统账号的账号ID 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 913根据uid查询对应的系统账号ID,使用Promise异步回调。 914 915**系统能力:** SystemCapability.Account.OsAccount 916 917**参数:** 918 919| 参数名 | 类型 | 必填 | 说明 | 920| ------ | ------ | ---- | --------- | 921| uid | number | 是 | 进程uid。 | 922 923**返回值:** 924 925| 类型 | 说明 | 926| --------------------- | --------------------------------------- | 927| Promise<number> | Promise对象,返回指定uid对应的系统账号ID。 | 928 929**错误码:** 930 931| 错误码ID | 错误信息 | 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**示例:** 查询值为12345678的uid所属的系统账号ID 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 958根据uid查询对应的系统账号ID。使用同步方式返回结果。 959 960**系统能力:** SystemCapability.Account.OsAccount 961 962**参数:** 963 964| 参数名 | 类型 | 必填 | 说明 | 965| ------ | ------ | ---- | --------- | 966| uid | number | 是 | 进程uid。 | 967 968**返回值:** 969 970| 类型 | 说明 | 971| --------------------- | --------------------------------------- | 972| number | 返回指定uid对应的系统账号ID。 | 973 974**错误码:** 975 976| 错误码ID | 错误信息 | 977| -------- | ------------- | 978| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 979| 12300002 | Invalid uid. | 980 981**示例:** 查询值为12345678的uid所属的系统账号ID 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 998根据域账号信息,获取与其关联的系统账号ID。使用callback异步回调。 999 1000**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1001 1002**系统能力:** SystemCapability.Account.OsAccount 1003 1004**参数:** 1005 1006| 参数名 | 类型 | 必填 | 说明 | 1007| ---------- | --------------------------------------- | ---- | -------------------------------------------------------------------------- | 1008| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域账号信息。 | 1009| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 | 1010 1011**错误码:** 1012 1013| 错误码ID | 错误信息 | 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**示例:** 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 1043根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。 1044 1045**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1046 1047**系统能力:** SystemCapability.Account.OsAccount 1048 1049**参数:** 1050 1051| 参数名 | 类型 | 必填 | 说明 | 1052| ---------- | --------------------------------------- | ---- | ------------ | 1053| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域账号信息。 | 1054 1055**返回值:** 1056 1057| 类型 | 说明 | 1058| :-------------------- | :------------------------------------- | 1059| Promise<number> | Promise对象,返回域账号关联的系统账号ID。 | 1060 1061**错误码:** 1062 1063| 错误码ID | 错误信息 | 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**示例:** 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 1091获取指定系统账号的全部约束。使用callback异步回调。 1092 1093> **说明:** 1094> 1095> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 1096 1097**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1098 1099**系统能力:** SystemCapability.Account.OsAccount 1100 1101**参数:** 1102 1103| 参数名 | 类型 | 必填 | 说明 | 1104| -------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------- | 1105| localId | number | 是 | 系统账号ID。 | 1106| callback | AsyncCallback<Array<string>> | 是 | 回调函数,如果获取成功,err为null,data为该系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 | 1107 1108**错误码:** 1109 1110| 错误码ID | 错误信息 | 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**示例:** 获取ID为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 1141获取指定系统账号的全部约束。使用Promise异步回调。 1142 1143> **说明:** 1144> 1145> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 1146 1147**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1148 1149**系统能力:** SystemCapability.Account.OsAccount 1150 1151**参数:** 1152 1153| 参数名 | 类型 | 必填 | 说明 | 1154| ------- | ------ | ---- | ------------ | 1155| localId | number | 是 | 系统账号ID。 | 1156 1157**返回值:** 1158 1159| 类型 | 说明 | 1160| ---------------------------------- | ---------------------------------------------------------- | 1161| Promise<Array<string>> | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 | 1162 1163**错误码:** 1164 1165| 错误码ID | 错误信息 | 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**示例:** 获取ID为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 1194查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。 1195 1196**系统能力:** SystemCapability.Account.OsAccount 1197 1198**参数:** 1199 1200| 参数名 | 类型 | 必填 | 说明 | 1201| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | 1202| callback | AsyncCallback<Array<number>> | 是 | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 | 1203 1204**错误码:** 1205 1206| 错误码ID | 错误信息 | 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**示例:** 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 1233查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。 1234 1235**系统能力:** SystemCapability.Account.OsAccount 1236 1237**返回值:** 1238 1239| 类型 | 说明 | 1240| :--------------------------------- | :------------------------------------------------ | 1241| Promise<Array<number>> | Promise对象,返回当前处于激活状态的系统账号的ID列表。 | 1242 1243**错误码:** 1244 1245| 错误码ID | 错误信息 | 1246| -------- | ------------- | 1247| 12300001 | The system service works abnormally. | 1248 1249**示例:** 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 1269查询当前进程所属的系统账号的信息。使用callback异步回调。 1270 1271> **说明:** 1272> 1273> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 1274 1275**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。 1276 1277**系统能力:** SystemCapability.Account.OsAccount 1278 1279**参数:** 1280 1281| 参数名 | 类型 | 必填 | 说明 | 1282| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 1283| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 | 1284 1285**错误码:** 1286 1287| 错误码ID | 错误信息 | 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**示例:** 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 1312查询当前进程所属的系统账号的信息。使用Promise异步回调。 1313 1314> **说明:** 1315> 1316> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。 1317 1318**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。 1319 1320**系统能力:** SystemCapability.Account.OsAccount 1321 1322**返回值:** 1323 1324| 类型 | 说明 | 1325| ---------------------------------------------- | ----------------------------------------- | 1326| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回当前进程所属的系统账号信息。 | 1327 1328**错误码:** 1329 1330| 错误码ID | 错误信息 | 1331| -------- | ------------------- | 1332| 201 | Permission denied.| 1333| 12300001 | The system service works abnormally. | 1334 1335**示例:** 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 1355查询当前进程所属的系统账号的账号类型。使用callback异步回调。 1356 1357**系统能力:** SystemCapability.Account.OsAccount 1358 1359**参数:** 1360 1361| 参数名 | 类型 | 必填 | 说明 | 1362| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | 1363| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 | 1364 1365**错误码:** 1366 1367| 错误码ID | 错误信息 | 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**示例:** 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 1391查询当前进程所属的系统账号的账号类型。使用Promise异步回调。 1392 1393**系统能力:** SystemCapability.Account.OsAccount 1394 1395**返回值:** 1396 1397| 类型 | 说明 | 1398| ---------------------------------------------- | ----------------------------------------------- | 1399| Promise<[OsAccountType](#osaccounttype)> | Promise对象,返回当前进程所属的系统账号的账号类型。 | 1400 1401**错误码:** 1402 1403| 错误码ID | 错误信息 | 1404| -------- | ------------------- | 1405| 12300001 | The system service works abnormally. | 1406 1407**示例:** 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 1427获取分布式虚拟设备ID。使用callback异步回调。 1428 1429**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC 1430 1431**系统能力:** SystemCapability.Account.OsAccount 1432 1433**参数:** 1434 1435| 参数名 | 类型 | 必填 | 说明 | 1436| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 1437| callback | AsyncCallback<string> | 是 | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 | 1438 1439**错误码:** 1440 1441| 错误码ID | 错误信息 | 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**示例:** 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 1466获取分布式虚拟设备ID。使用Promise异步回调。 1467 1468**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC 1469 1470**系统能力:** SystemCapability.Account.OsAccount 1471 1472**返回值:** 1473 1474| 类型 | 说明 | 1475| --------------------- | --------------------------------- | 1476| Promise<string> | Promise对象,返回分布式虚拟设备ID。 | 1477 1478**错误码:** 1479 1480| 错误码ID | 错误信息 | 1481| -------- | ------------------- | 1482| 201 | Permission denied.| 1483| 12300001 | The system service works abnormally. | 1484 1485**示例:** 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 1505通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。 1506 1507**系统能力:** SystemCapability.Account.OsAccount 1508 1509**参数:** 1510 1511| 参数名 | 类型 | 必填 | 说明 | 1512| ------------ | --------------------------- | ---- | ---------------------------------------------------------------------------- | 1513| serialNumber | number | 是 | 账号SN码。 | 1514| callback | AsyncCallback<number> | 是 | 回调函数。如果成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 | 1515 1516**错误码:** 1517 1518| 错误码ID | 错误信息 | 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**示例:** 查询与SN码12345关联的系统账号的ID 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 1545通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。 1546 1547**系统能力:** SystemCapability.Account.OsAccount 1548 1549**参数:** 1550 1551| 参数名 | 类型 | 必填 | 说明 | 1552| ------------ | ------ | ---- | ---------- | 1553| serialNumber | number | 是 | 账号SN码。 | 1554 1555**返回值:** 1556 1557| 类型 | 说明 | 1558| --------------------- | -------------------------------------------- | 1559| Promise<number> | Promise对象,返回与SN码关联的系统账号的账号ID。 | 1560 1561**错误码:** 1562 1563| 错误码ID | 错误信息 | 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**示例:** 查询与SN码12345关联的系统账号的ID 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 1591通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。 1592 1593**系统能力:** SystemCapability.Account.OsAccount 1594 1595**参数:** 1596 1597| 参数名 | 类型 | 必填 | 说明 | 1598| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 1599| localId | number | 是 | 系统账号ID。 | 1600| callback | AsyncCallback<number> | 是 | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 | 1601 1602**错误码:** 1603 1604| 错误码ID | 错误信息 | 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**示例:** 获取ID为100的系统账号关联的SN码 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 1631通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。 1632 1633**系统能力:** SystemCapability.Account.OsAccount 1634 1635**参数:** 1636 1637| 参数名 | 类型 | 必填 | 说明 | 1638| ------- | ------ | ---- | ----------- | 1639| localId | number | 是 | 系统账号ID。 | 1640 1641**返回值:** 1642 1643| 类型 | 说明 | 1644| :-------------------- | :------------------------------------- | 1645| Promise<number> | Promise对象,返回与该系统账号关联的SN码。 | 1646 1647**错误码:** 1648 1649| 错误码ID | 错误信息 | 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**示例:** 获取ID为100的系统账号关联的SN码 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 1677判断是否支持多系统账号。使用callback异步回调。 1678 1679> **说明:** 1680> 1681> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9)。 1682 1683**系统能力:** SystemCapability.Account.OsAccount 1684 1685**参数:** 1686 1687| 参数名 | 类型 | 必填 | 说明 | 1688| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 1689| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示支持多系统账号;返回false表示不支持。 | 1690 1691**示例:** 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 1709判断是否支持多系统账号。使用Promise异步回调。 1710 1711> **说明:** 1712> 1713> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9-1)。 1714 1715**系统能力:** SystemCapability.Account.OsAccount 1716 1717**返回值:** 1718 1719| 类型 | 说明 | 1720| :--------------------- | :--------------------------------------------------------- | 1721| Promise<boolean> | Promise对象。返回true表示支持多系统账号;返回false表示不支持。 | 1722 1723**示例:** 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 1739判断指定系统账号是否处于激活状态。使用callback异步回调。 1740 1741> **说明:** 1742> 1743> 从 API version 7开始支持从API version 9开始废弃。替代方法仅向系统应用开放。 1744 1745**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1746 1747**系统能力:** SystemCapability.Account.OsAccount 1748 1749**参数:** 1750 1751| 参数名 | 类型 | 必填 | 说明 | 1752| -------- | ---------------------------- | ---- | ------------------------------------------------------ | 1753| localId | number | 是 | 系统账号ID。 | 1754| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示账号已激活;返回false表示账号未激活。 | 1755 1756**示例:** 判断ID为100的系统账号是否处于激活状态 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 1775判断指定系统账号是否处于激活状态。使用Promise异步回调。 1776 1777> **说明:** 1778> 1779> 从 API version 7开始支持从API version 9开始废弃。替代方法仅向系统应用开放。 1780 1781**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1782 1783**系统能力:** SystemCapability.Account.OsAccount 1784 1785**参数:** 1786 1787| 参数名 | 类型 | 必填 | 说明 | 1788| ------- | ------ | ---- | --------------------------------- | 1789| localId | number | 是 | 系统账号ID。 | 1790 1791**返回值:** 1792 1793| 类型 | 说明 | 1794| --------------------- | ----------------------------------------------------------- | 1795| Promise<boolean> | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 | 1796 1797**示例:** 判断ID为100的系统账号是否处于激活状态 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 1814判断指定系统账号是否具有指定约束。使用callback异步回调。 1815 1816> **说明:** 1817> 1818> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 1819 1820**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 1821 1822**系统能力:** SystemCapability.Account.OsAccount 1823 1824**参数:** 1825 1826| 参数名 | 类型 | 必填 | 说明 | 1827| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- | 1828| localId | number | 是 | 系统账号ID。 | 1829| constraint | string | 是 | 指定的[约束](#系统账号约束列表)名称。 | 1830| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 | 1831 1832**示例:** 判断ID为100的系统账号是否有禁止使用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 1852判断指定系统账号是否具有指定约束。使用Promise异步回调。 1853 1854> **说明:** 1855> 1856> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 1857 1858**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 1859 1860**系统能力:** SystemCapability.Account.OsAccount 1861 1862**参数:** 1863 1864| 参数名 | 类型 | 必填 | 说明 | 1865| ---------- | ------ | ---- | ---------------------------------- | 1866| localId | number | 是 | 系统账号ID。 | 1867| constraint | string | 是 | 指定的[约束](#系统账号约束列表)名称。 | 1868 1869**返回值:** 1870 1871| 类型 | 说明 | 1872| ---------------------- | --------------------------------------------------------------------- | 1873| Promise<boolean> | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 | 1874 1875**示例:** 判断ID为100的系统账号是否有禁止使用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 1893检查当前系统账号是否为测试账号。使用callback异步回调。 1894 1895> **说明:** 1896> 1897> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9)。 1898 1899**系统能力:** SystemCapability.Account.OsAccount 1900 1901**参数:** 1902 1903| 参数名 | 类型 | 必填 | 说明 | 1904| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- | 1905| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 | 1906 1907**示例:** 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 1925检查当前系统账号是否为测试账号。使用Promise异步回调。 1926 1927> **说明:** 1928> 1929> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9-1)。 1930 1931**系统能力:** SystemCapability.Account.OsAccount 1932 1933**返回值:** 1934 1935| 类型 | 说明 | 1936| ---------------------- | ------------------------------------------------------------------------ | 1937| Promise<boolean> | Promise对象。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 | 1938 1939**示例:** 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 1955检查当前系统账号是否已验证。使用callback异步回调。 1956 1957> **说明:** 1958> 1959> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountVerified](#checkosaccountverified9)。 1960 1961**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1962 1963**系统能力:** SystemCapability.Account.OsAccount 1964 1965**参数:** 1966 1967| 参数名 | 类型 | 必填 | 说明 | 1968| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 1969| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 | 1970 1971**示例:** 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 1989检查指定系统账号是否已验证。使用callback异步回调。 1990 1991> **说明:** 1992> 1993> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 1994 1995**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 1996 1997**系统能力:** SystemCapability.Account.OsAccount 1998 1999**参数:** 2000 2001| 参数名 | 类型 | 必填 | 说明 | 2002| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | 2003| localId | number | 是 | 系统账号ID。 | 2004| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 | 2005 2006**示例:** 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 2025检查指定系统账号是否已验证。使用Promise异步回调。 2026 2027> **说明:** 2028> 2029> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 2030 2031**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。 2032 2033**系统能力:** SystemCapability.Account.OsAccount 2034 2035**参数:** 2036 2037| 参数名 | 类型 | 必填 | 说明 | 2038| ------- | ------ | ---- | ---------------------------------------------------------------- | 2039| localId | number | 否 | 系统账号ID。不填则检查当前系统账号是否已验证。 | 2040 2041**返回值:** 2042 2043| 类型 | 说明 | 2044| ---------------------- | ----------------------------------------------------------------- | 2045| Promise<boolean> | Promise对象。返回true表示指定账号已验证;返回false表示指定账号未验证。 | 2046 2047**示例:** 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 2063获取已创建的系统账号数量。使用callback异步回调。 2064 2065> **说明:** 2066> 2067> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9)。 2068 2069**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2070 2071**系统能力:** SystemCapability.Account.OsAccount 2072 2073**参数:** 2074 2075| 参数名 | 类型 | 必填 | 说明 | 2076| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- | 2077| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为已创建的系统账号的数量;否则为错误对象。 | 2078 2079**示例:** 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 2097获取已创建的系统账号数量,使用Promise异步回调。 2098 2099> **说明:** 2100> 2101> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9-1)。 2102 2103**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2104 2105**系统能力:** SystemCapability.Account.OsAccount 2106 2107**返回值:** 2108 2109| 类型 | 说明 | 2110| --------------------- | -------------------------------------- | 2111| Promise<number> | Promise对象,返回已创建的系统账号的数量。 | 2112 2113**示例:** 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 2129获取当前进程所属的系统账号ID,使用callback异步回调。 2130 2131> **说明:** 2132> 2133> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9)。 2134 2135**系统能力:** SystemCapability.Account.OsAccount 2136 2137**参数:** 2138 2139| 参数名 | 类型 | 必填 | 说明 | 2140| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- | 2141| callback | AsyncCallback<number> | 是 | 回调函数。当获取成功时,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 | 2142 2143**示例:** 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 2161获取当前进程所属的系统账号ID,使用Promise异步回调。 2162 2163> **说明:** 2164> 2165> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9-1)。 2166 2167**系统能力:** SystemCapability.Account.OsAccount 2168 2169**返回值:** 2170 2171| 类型 | 说明 | 2172| :-------------------- | :--------------------------------------- | 2173| Promise<number> | Promise对象,返回当前进程所属的系统账号ID。 | 2174 2175**示例:** 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 2191根据uid查询对应的系统账号ID。使用callback异步回调。 2192 2193> **说明:** 2194> 2195> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9)。 2196 2197**系统能力:** SystemCapability.Account.OsAccount 2198 2199**参数:** 2200 2201| 参数名 | 类型 | 必填 | 说明 | 2202| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 2203| uid | number | 是 | 进程uid。 | 2204| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 | 2205 2206**示例:** 查询值为12345678的uid所属的系统账号ID 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 2225根据uid查询对应的系统账号ID,使用Promise异步回调。 2226 2227> **说明:** 2228> 2229> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9-1)。 2230 2231**系统能力:** SystemCapability.Account.OsAccount 2232 2233**参数:** 2234 2235| 参数名 | 类型 | 必填 | 说明 | 2236| ------ | ------ | ---- | --------- | 2237| uid | number | 是 | 进程uid。 | 2238 2239**返回值:** 2240 2241| 类型 | 说明 | 2242| :-------------------- | :----------------------------------- | 2243| Promise<number> | Promise对象,返回uid对应的系统账号ID。 | 2244 2245**示例:** 查询值为12345678的uid所属的系统账号ID 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 2262根据域账号信息,获取与其关联的系统账号的账号ID。使用callback异步回调。 2263 2264> **说明:** 2265> 2266> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9)。 2267 2268**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2269 2270**系统能力:** SystemCapability.Account.OsAccount 2271 2272**参数:** 2273 2274| 参数名 | 类型 | 必填 | 说明 | 2275| ---------- | --------------------------------------- | ---- | --------------------------------------------------------------------------- | 2276| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域账号信息。 | 2277| callback | AsyncCallback<number> | 是 | 回调函数,如果获取成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 | 2278 2279**示例:** 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 2298根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。 2299 2300> **说明:** 2301> 2302> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9-1)。 2303 2304**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2305 2306**系统能力:** SystemCapability.Account.OsAccount 2307 2308**参数:** 2309 2310| 参数名 | 类型 | 必填 | 说明 | 2311| ---------- | --------------------------------------- | ---- | ------------ | 2312| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域账号信息。 | 2313 2314**返回值:** 2315 2316| 类型 | 说明 | 2317| :-------------------- | :------------------------------------- | 2318| Promise<number> | Promise对象,返回域账号关联的系统账号ID。 | 2319 2320**示例:** 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 2337获取指定系统账号的全部约束。使用callback异步回调。 2338 2339> **说明:** 2340> 2341> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 2342 2343**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2344 2345**系统能力:** SystemCapability.Account.OsAccount 2346 2347**参数:** 2348 2349| 参数名 | 类型 | 必填 | 说明 | 2350| -------- | ---------------------------------------- | ---- | ---------------------------------------------------------------------------------------------- | 2351| localId | number | 是 | 系统账号ID。 | 2352| callback | AsyncCallback<Array<string>> | 是 | 回调函数。如果获取成功,err为null,data为指定系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 | 2353 2354**示例:** 获取ID为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 2370获取指定系统账号的全部约束。使用Promise异步回调。 2371 2372> **说明:** 2373> 2374> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 2375 2376**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2377 2378**系统能力:** SystemCapability.Account.OsAccount 2379 2380**参数:** 2381 2382| 参数名 | 类型 | 必填 | 说明 | 2383| ------- | ------ | ---- | ------------ | 2384| localId | number | 是 | 系统账号ID。 | 2385 2386**返回值:** 2387 2388| 类型 | 说明 | 2389| :--------------------------------- | :----------------------------------------------------------- | 2390| Promise<Array<string>> | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 | 2391 2392**示例:** 获取ID为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 2409查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。 2410 2411> **说明:** 2412> 2413> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9)。 2414 2415**系统能力:** SystemCapability.Account.OsAccount 2416 2417**参数:** 2418 2419| 参数名 | 类型 | 必填 | 说明 | 2420| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | 2421| callback | AsyncCallback<Array<number>> | 是 | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 | 2422 2423**示例:** 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> **说明:** 2442> 2443> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9-1)。 2444 2445查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。 2446 2447**系统能力:** SystemCapability.Account.OsAccount 2448 2449**返回值:** 2450 2451| 类型 | 说明 | 2452| ---------------------------------- | ------------------------------------------------- | 2453| Promise<Array<number>> | Promise对象,返回当前处于激活状态的系统账号的ID列表。 | 2454 2455**示例:** 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 2471查询当前进程所属的系统账号的信息。使用callback异步回调。 2472 2473> **说明:** 2474> 2475> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 2476 2477**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2478 2479**系统能力:** SystemCapability.Account.OsAccount 2480 2481**参数:** 2482 2483| 参数名 | 类型 | 必填 | 说明 | 2484| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 2485| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 | 2486 2487**示例:** 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 2502查询当前进程所属的系统账号的信息。使用Promise异步回调。 2503 2504> **说明:** 2505> 2506> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。 2507 2508**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。 2509 2510**系统能力:** SystemCapability.Account.OsAccount 2511 2512**返回值:** 2513 2514| 类型 | 说明 | 2515| ---------------------------------------------- | ------------------------------------------ | 2516| Promise<[OsAccountInfo](#osaccountinfo)> | Promise对象,返回当前进程所属的系统账号信息。 | 2517 2518**示例:** 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 2534查询当前进程所属的系统账号的账号类型。使用callback异步回调。 2535 2536> **说明:** 2537> 2538> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9)。 2539 2540**系统能力:** SystemCapability.Account.OsAccount 2541 2542**参数:** 2543 2544| 参数名 | 类型 | 必填 | 说明 | 2545| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | 2546| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 | 2547 2548**示例:** 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 2563查询当前进程所属的系统账号的账号类型。使用Promise异步回调。 2564 2565> **说明:** 2566> 2567> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9-1)。 2568 2569**系统能力:** SystemCapability.Account.OsAccount 2570 2571**返回值:** 2572 2573| 类型 | 说明 | 2574| ---------------------------------------------- | ----------------------------------------------- | 2575| Promise<[OsAccountType](#osaccounttype)> | Promise对象,返回当前进程所属的系统账号的账号类型。 | 2576 2577**示例:** 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 2593获取分布式虚拟设备ID。使用callback异步回调。 2594 2595> **说明:** 2596> 2597> 从 API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9)。 2598 2599**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC 2600 2601**系统能力:** SystemCapability.Account.OsAccount 2602 2603**参数:** 2604 2605| 参数名 | 类型 | 必填 | 说明 | 2606| -------- | --------------------------- | ---- | --------------------------------------------------------------------- | 2607| callback | AsyncCallback<string> | 是 | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 | 2608 2609**示例:** 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 2624获取分布式虚拟设备ID。使用Promise异步回调。 2625 2626> **说明:** 2627> 2628> 从 API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1)。 2629 2630**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC 2631 2632**系统能力:** SystemCapability.Account.OsAccount 2633 2634**返回值:** 2635 2636| 类型 | 说明 | 2637| --------------------- | --------------------------------- | 2638| Promise<string> | Promise对象,返回分布式虚拟设备ID。 | 2639 2640**示例:** 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 2656通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。 2657 2658> **说明:** 2659> 2660> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9)。 2661 2662**系统能力:** SystemCapability.Account.OsAccount 2663 2664**参数:** 2665 2666| 参数名 | 类型 | 必填 | 说明 | 2667| ------------ | --------------------------- | ---- | -------------------------------------------------------------------------------- | 2668| serialNumber | number | 是 | 账号SN码。 | 2669| callback | AsyncCallback<number> | 是 | 回调函数。如果查询成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 | 2670 2671**示例:** 查询与SN码12345关联的系统账号的ID 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 2687通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。 2688 2689> **说明:** 2690> 2691> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9-1)。 2692 2693**系统能力:** SystemCapability.Account.OsAccount 2694 2695**参数:** 2696 2697| 参数名 | 类型 | 必填 | 说明 | 2698| ------------ | ------ | ---- | ---------- | 2699| serialNumber | number | 是 | 账号SN码。 | 2700 2701**返回值:** 2702 2703| 类型 | 说明 | 2704| --------------------- | -------------------------------------------- | 2705| Promise<number> | Promise对象,返回与SN码关联的系统账号的账号ID。 | 2706 2707**示例:** 查询与SN码12345关联的系统账号的ID 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 2724通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。 2725 2726> **说明:** 2727> 2728> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9)。 2729 2730**系统能力:** SystemCapability.Account.OsAccount 2731 2732**参数:** 2733 2734| 参数名 | 类型 | 必填 | 说明 | 2735| -------- | --------------------------- | ---- | --------------------------------------------------------------------------- | 2736| localId | number | 是 | 系统账号ID。 | 2737| callback | AsyncCallback<number> | 是 | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 | 2738 2739**示例:** 获取ID为100的系统账号关联的SN码 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 2755通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。 2756 2757> **说明:** 2758> 2759> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9-1)。 2760 2761**系统能力:** SystemCapability.Account.OsAccount 2762 2763**参数:** 2764 2765| 参数名 | 类型 | 必填 | 说明 | 2766| ------- | ------ | ---- | ----------- | 2767| localId | number | 是 | 系统账号ID。 | 2768 2769**返回值:** 2770 2771| 类型 | 说明 | 2772| --------------------- | -------------------------------------- | 2773| Promise<number> | Promise对象,返回与该系统账号关联的SN码。 | 2774 2775**示例:** 获取ID为100的系统账号关联的SN码 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 2792查询调用方所属系统账号的名称。使用Promise异步回调。 2793 2794**系统能力:** SystemCapability.Account.OsAccount 2795 2796**返回值:** 2797 2798| 类型 | 说明 | 2799| :------------------------ | ----------------------- | 2800| Promise<string> | Promise对象,返回调用方所属系统账号的名称。 | 2801 2802**错误码:** 2803 2804| 错误码ID | 错误信息 | 2805| -------- | --------------------------- | 2806| 12300001 | The system service works abnormally. | 2807 2808**示例:** 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 2825表示系统账号信息。 2826 2827**系统能力:** SystemCapability.Account.OsAccount 2828 2829| 名称 | 类型 | 必填 | 说明 | 2830| ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------- | 2831| localId | number | 是 | 系统账号ID。 | 2832| localName | string | 是 | 系统账号名称。 | 2833| type | [OsAccountType](#osaccounttype) | 是 | 系统账号类型。 | 2834| constraints | Array<string> | 是 | 系统账号[约束](#系统账号约束列表),默认为空。| 2835| isVerified<sup>(deprecated)</sup> | boolean | 是 | 账号是否验证。<br>**说明**: 从API version 7开始支持,从API version 11开始废弃。 | 2836| isUnlocked<sup>11+</sup> | boolean | 是 | 账号是否已解锁(EL2级别目录是否解密)。 | 2837| photo<sup>8+</sup> | string | 是 | 系统账号头像,默认为空。 | 2838| createTime<sup>8+</sup> | number | 是 | 系统账号创建时间。 | 2839| lastLoginTime<sup>8+</sup> | number | 是 | 系统账号最后一次登录时间,默认为空。 | 2840| serialNumber<sup>8+</sup> | number | 是 | 系统账号SN码。 | 2841| isActived<sup>(deprecated)</sup> | boolean | 是 | 系统账号激活状态。<br>**说明**: 从API version 7开始支持,从API version 11开始废弃。 | 2842| isActivated<sup>11+</sup> | boolean | 是 | 系统账号激是否激活。 | 2843| isCreateCompleted<sup>8+</sup> | boolean | 是 | 系统账号创建是否完整。 | 2844| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md#distributedinfo) | 是 | 分布式账号信息,默认为空。 | 2845| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域账号信息,默认为空。 | 2846 2847## DomainAccountInfo<sup>8+</sup> 2848 2849表示域账号信息。 2850 2851**系统能力:** SystemCapability.Account.OsAccount 2852 2853| 名称 | 类型 | 必填 | 说明 | 2854| ----------- | ------ | ---- | ---------- | 2855| domain | string | 是 | 域名。 | 2856| accountName | string | 是 | 域账号名。 | 2857 2858## 系统账号约束列表 2859 2860| 约束 | 说明 | 2861| ------------------------------------- | ------------------------------ | 2862| constraint.wifi | 禁止使用Wi-Fi | 2863| constraint.wifi.set | 禁止配置Wi-Fi | 2864| constraint.locale.set | 禁止配置设备语言 | 2865| constraint.app.accounts | 禁止添加和删除应用账号 | 2866| constraint.apps.install | 禁止安装应用 | 2867| constraint.apps.uninstall | 禁止卸载应用 | 2868| constraint.location.shared | 禁止打开位置共享 | 2869| constraint.unknown.sources.install | 禁止安装未知来源的应用 | 2870| constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 | 2871| constraint.bluetooth.set | 禁止配置蓝牙 | 2872| constraint.bluetooth | 禁止使用蓝牙 | 2873| constraint.bluetooth.share | 禁止共享使用蓝牙 | 2874| constraint.usb.file.transfer | 禁止通过USB传输文件 | 2875| constraint.credentials.set | 禁止配置用户凭据 | 2876| constraint.os.account.remove | 禁止删除用户 | 2877| constraint.managed.profile.remove | 禁止删除此用户的托管配置文件 | 2878| constraint.debug.features.use | 禁止启用或访问调试功能 | 2879| constraint.vpn.set | 禁止配置VPN | 2880| constraint.date.time.set | 禁止配置日期时间和时区 | 2881| constraint.tethering.config | 禁止配置Tethering | 2882| constraint.network.reset | 禁止重置网络设置 | 2883| constraint.factory.reset | 禁止出厂设置 | 2884| constraint.os.account.create | 禁止创建新用户 | 2885| constraint.add.managed.profile | 禁止添加托管配置文件 | 2886| constraint.apps.verify.disable | 强制应用程序验证 | 2887| constraint.cell.broadcasts.set | 禁止配置小区广播 | 2888| constraint.mobile.networks.set | 禁止配置移动网络 | 2889| constraint.control.apps | 禁止在设置或启动模块中修改应用程序 | 2890| constraint.physical.media | 禁止装载物理外部介质 | 2891| constraint.microphone | 禁止使用麦克风 | 2892| constraint.microphone.unmute | 禁止取消麦克风静音 | 2893| constraint.volume.adjust | 禁止调整音量 | 2894| constraint.calls.outgoing | 禁止拨打外呼电话 | 2895| constraint.sms.use | 禁止发送或接收短信 | 2896| constraint.fun | 禁止享受乐趣 | 2897| constraint.windows.create | 禁止创建应用程序窗口以外的窗口 | 2898| constraint.system.error.dialogs | 禁止显示崩溃或无响应应用程序的系统错误对话框 | 2899| constraint.cross.profile.copy.paste | 禁止通过将数据粘贴到其他用户或配置文件来导出剪贴板内容 | 2900| constraint.beam.outgoing | 禁止使用NFC从应用程序传送数据 | 2901| constraint.wallpaper | 禁止管理壁纸 | 2902| constraint.safe.boot | 禁止进入安全引导模式 | 2903| constraint.parent.profile.app.linking | 禁止父配置文件中的应用程序处理来自托管配置文件的Web链接 | 2904| constraint.audio.record | 禁止录制音频 | 2905| constraint.camera.use | 禁止使用摄像机 | 2906| constraint.os.account.background.run | 禁止在后台运行 | 2907| constraint.data.roam | 禁止漫游通话时使用蜂窝数据 | 2908| constraint.os.account.set.icon | 禁止修改用户头像 | 2909| constraint.wallpaper.set | 禁止设置壁纸 | 2910| constraint.oem.unlock | 禁止启用oem解锁 | 2911| constraint.device.unmute | 禁止取消设备静音 | 2912| constraint.password.unified | 禁止托管配置文件与主用户进行统一锁屏质询 | 2913| constraint.autofill | 禁止使用自动填充服务 | 2914| constraint.content.capture | 禁止捕获用户屏幕 | 2915| constraint.content.suggestions | 禁止接收内容建议 | 2916| constraint.os.account.activate | 禁止前台启动用户 | 2917| constraint.location.set | 禁止配置位置服务 | 2918| constraint.airplane.mode.set | 禁止飞行模式 | 2919| constraint.brightness.set | 禁止配置亮度 | 2920| constraint.share.into.profile | 禁止将主要用户的文件/图片/数据共享到托管配置文件中 | 2921| constraint.ambient.display | 禁止显示环境 | 2922| constraint.screen.timeout.set | 禁止配置屏幕关闭的超时 | 2923| constraint.print | 禁止打印 | 2924| constraint.private.dns.set | 禁止配置专用DNS | 2925