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.OsAccount40
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&lt;boolean&gt;): void
54
55判断是否支持多系统账号。使用callback异步回调。
56
57**系统能力:** SystemCapability.Account.OsAccount
58
59**参数:**
60
61| 参数名   | 类型                         | 必填 | 说明                                                     |
62| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
63| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
93
94判断是否支持多系统账号。使用Promise异步回调。
95
96**系统能力:** SystemCapability.Account.OsAccount
97
98**返回值:**
99
100| 类型                   | 说明                                                        |
101| :--------------------- | :--------------------------------------------------------- |
102| Promise&lt;boolean&gt; | 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&lt;boolean&gt;): void
129
130判断指定系统账号是否处于激活状态。使用callback异步回调。
131
132> **说明:**
133>
134> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
135
136**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
137
138**系统能力:** SystemCapability.Account.OsAccount
139
140**参数:**
141
142| 参数名   | 类型                         | 必填 | 说明                                                     |
143| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
144| localId  | number                       | 是   | 系统账号ID。                                             |
145| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
179
180判断指定系统账号是否处于激活状态。使用Promise异步回调。
181
182> **说明:**
183>
184> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
185
186**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.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&lt;boolean&gt; | 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&lt;boolean&gt;
232
233判断当前系统账号是否使能指定约束。使用Promise异步回调。
234
235**系统能力:** SystemCapability.Account.OsAccount
236
237**参数:**
238
239| 参数名     | 类型   | 必填 | 说明                                |
240| ---------- | ------ | ---- | ---------------------------------- |
241| constraint | string | 是   | 指定的[约束](#系统账号约束列表)名称。 |
242
243**返回值:**
244
245| 类型                   | 说明                                                                  |
246| --------------------- | --------------------------------------------------------------------- |
247| Promise&lt;boolean&gt; | 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&lt;boolean&gt;): void
276
277判断指定系统账号是否具有指定约束。使用callback异步回调。
278
279> **说明:**
280>
281> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
282
283**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.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&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
328
329判断指定系统账号是否具有指定约束。使用Promise异步回调。
330
331> **说明:**
332>
333> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
334
335**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.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&lt;boolean&gt; | 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&lt;boolean&gt;): void
383
384检查当前系统账号是否为测试账号。使用callback异步回调。
385
386**系统能力:** SystemCapability.Account.OsAccount
387
388**参数:**
389
390| 参数名   | 类型                         | 必填 | 说明                                                                   |
391| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
392| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
422
423检查当前系统账号是否为测试账号。使用Promise异步回调。
424
425**系统能力:** SystemCapability.Account.OsAccount
426
427**返回值:**
428
429| 类型                   | 说明                                                                      |
430| ---------------------- | ------------------------------------------------------------------------ |
431| Promise&lt;boolean&gt; | 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&lt;boolean&gt;
458
459检查当前系统账号是否已认证解锁。使用Promise异步回调。
460
461**系统能力:** SystemCapability.Account.OsAccount
462
463**返回值:**
464
465| 类型                   | 说明                                                                      |
466| ---------------------- | ------------------------------------------------------------------------ |
467| Promise&lt;boolean&gt; | 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&lt;boolean&gt;): 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&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
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&lt;boolean&gt; | 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&lt;boolean&gt;): void
576
577检查指定系统账号是否已验证。使用callback异步回调。
578
579> **说明:**
580>
581> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
582
583**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
584
585**系统能力:** SystemCapability.Account.OsAccount
586
587**参数:**
588
589| 参数名   | 类型                         | 必填 | 说明                                                            |
590| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
591| localId  | number                       | 是   | 系统账号ID。                              |
592| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回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&lt;boolean&gt;
626
627检查指定系统账号是否已验证。使用Promise异步回调。
628
629> **说明:**
630>
631> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
632
633**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.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&lt;boolean&gt; | 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### getOsAccountCount<sup>9+</sup>
677
678getOsAccountCount(callback: AsyncCallback&lt;number&gt;): void
679
680获取已创建的系统账号数量。使用callback异步回调。
681
682**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
683
684**系统能力:** SystemCapability.Account.OsAccount
685
686**参数:**
687
688| 参数名   | 类型                        | 必填 | 说明                                                                         |
689| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
690| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。当获取成功时,err为null,data为已创建的系统账号的数量;否则为错误对象。 |
691
692**错误码:**
693
694| 错误码ID | 错误信息             |
695| -------- | ------------------- |
696| 201 | Permission denied.|
697| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
698| 12300001 | The system service works abnormally. |
699
700**示例:**
701
702  ```ts
703  import { BusinessError } from '@kit.BasicServicesKit';
704  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
705  try {
706    accountManager.getOsAccountCount((err: BusinessError, count: number) => {
707      if (err) {
708        console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
709      } else {
710        console.log('getOsAccountCount successfully, count: ' + count);
711      }
712    });
713  } catch (err) {
714    console.log('getOsAccountCount exception: ' + JSON.stringify(err));
715  }
716  ```
717
718### getOsAccountCount<sup>9+</sup>
719
720getOsAccountCount(): Promise&lt;number&gt;
721
722获取已创建的系统账号数量。使用Promise异步回调。
723
724**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
725
726**系统能力:** SystemCapability.Account.OsAccount
727
728**返回值:**
729
730| 类型                  | 说明                                    |
731| --------------------- | -------------------------------------- |
732| Promise&lt;number&gt; | Promise对象,返回已创建的系统账号的数量。 |
733
734**错误码:**
735
736| 错误码ID | 错误信息             |
737| -------- | ------------------- |
738| 201 | Permission denied.|
739| 12300001 | The system service works abnormally. |
740
741**示例:**
742
743  ```ts
744  import { BusinessError } from '@kit.BasicServicesKit';
745  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
746  try {
747    accountManager.getOsAccountCount().then((count: number) => {
748      console.log('getOsAccountCount successfully, count: ' + count);
749    }).catch((err: BusinessError) => {
750      console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
751    });
752  } catch(err) {
753    console.log('getOsAccountCount exception: ' + JSON.stringify(err));
754  }
755  ```
756
757### getOsAccountLocalId<sup>9+</sup>
758
759getOsAccountLocalId(callback: AsyncCallback&lt;number&gt;): void
760
761获取当前进程所属的系统账号ID,使用callback异步回调。
762
763**系统能力:** SystemCapability.Account.OsAccount
764
765**参数:**
766
767| 参数名   | 类型                        | 必填 | 说明                                                                           |
768| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
769| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。当获取成功时,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 |
770
771**错误码:**
772
773| 错误码ID | 错误信息             |
774| -------- | ------------------- |
775| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
776| 12300001 | The system service works abnormally. |
777
778**示例:**
779
780  ```ts
781  import { BusinessError } from '@kit.BasicServicesKit';
782  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
783  try {
784    accountManager.getOsAccountLocalId((err: BusinessError, localId: number) => {
785      if (err) {
786        console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
787      } else {
788        console.log('getOsAccountLocalId successfully, localId: ' + localId);
789      }
790    });
791  } catch (err) {
792    console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
793  }
794  ```
795
796### getOsAccountLocalId<sup>9+</sup>
797
798getOsAccountLocalId(): Promise&lt;number&gt;
799
800获取当前进程所属的系统账号ID,使用Promise异步回调。
801
802**系统能力:** SystemCapability.Account.OsAccount
803
804**返回值:**
805
806| 类型                  | 说明                                      |
807| --------------------- | ---------------------------------------- |
808| Promise&lt;number&gt; | Promise对象,返回当前进程所属的系统账号ID。 |
809
810**错误码:**
811
812| 错误码ID | 错误信息             |
813| -------- | ------------------- |
814| 12300001 | The system service works abnormally. |
815
816**示例:**
817
818  ```ts
819  import { BusinessError } from '@kit.BasicServicesKit';
820  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
821  try {
822    accountManager.getOsAccountLocalId().then((localId: number) => {
823      console.log('getOsAccountLocalId successfully, localId: ' + localId);
824    }).catch((err: BusinessError) => {
825      console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
826    });
827  } catch (err) {
828    console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
829  }
830  ```
831
832### getOsAccountLocalIdForUid<sup>9+</sup>
833
834getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
835
836根据uid查询对应的系统账号ID,使用callback异步回调。
837
838**系统能力:** SystemCapability.Account.OsAccount
839
840**参数:**
841
842| 参数名   | 类型                        | 必填 | 说明                                                                    |
843| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
844| uid      | number                      | 是   | 进程uid。                                                              |
845| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 |
846
847**错误码:**
848
849| 错误码ID | 错误信息         |
850| -------- | --------------- |
851| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
852| 12300001 | The system service works abnormally. |
853| 12300002 | Invalid uid.    |
854
855**示例:** 查询值为12345678的uid所属的系统账号的账号ID
856
857  ```ts
858  import { BusinessError } from '@kit.BasicServicesKit';
859  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
860  let uid: number = 12345678;
861  try {
862    accountManager.getOsAccountLocalIdForUid(uid, (err: BusinessError, localId: number) => {
863      if (err) {
864        console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
865      }
866      console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
867    });
868  } catch (err) {
869    console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
870  }
871  ```
872
873### getOsAccountLocalIdForUid<sup>9+</sup>
874
875getOsAccountLocalIdForUid(uid: number): Promise&lt;number&gt;
876
877根据uid查询对应的系统账号ID,使用Promise异步回调。
878
879**系统能力:** SystemCapability.Account.OsAccount
880
881**参数:**
882
883| 参数名 | 类型   | 必填 | 说明      |
884| ------ | ------ | ---- | --------- |
885| uid    | number | 是   | 进程uid。 |
886
887**返回值:**
888
889| 类型                  | 说明                                     |
890| --------------------- | --------------------------------------- |
891| Promise&lt;number&gt; | Promise对象,返回指定uid对应的系统账号ID。 |
892
893**错误码:**
894
895| 错误码ID | 错误信息       |
896| -------- | ------------- |
897| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
898| 12300001 | The system service works abnormally. |
899| 12300002 | Invalid uid. |
900
901**示例:** 查询值为12345678的uid所属的系统账号ID
902
903  ```ts
904  import { BusinessError } from '@kit.BasicServicesKit';
905  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
906  let uid: number = 12345678;
907  try {
908    accountManager.getOsAccountLocalIdForUid(uid).then((localId: number) => {
909      console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
910    }).catch((err: BusinessError) => {
911      console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
912    });
913  } catch (err) {
914    console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
915  }
916  ```
917
918### getOsAccountLocalIdForUidSync<sup>10+</sup>
919
920getOsAccountLocalIdForUidSync(uid: number): number
921
922根据uid查询对应的系统账号ID。使用同步方式返回结果。
923
924**系统能力:** SystemCapability.Account.OsAccount
925
926**参数:**
927
928| 参数名 | 类型   | 必填 | 说明      |
929| ------ | ------ | ---- | --------- |
930| uid    | number | 是   | 进程uid。 |
931
932**返回值:**
933
934| 类型                  | 说明                                     |
935| --------------------- | --------------------------------------- |
936| number | 返回指定uid对应的系统账号ID。 |
937
938**错误码:**
939
940| 错误码ID | 错误信息       |
941| -------- | ------------- |
942| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
943| 12300002 | Invalid uid. |
944
945**示例:** 查询值为12345678的uid所属的系统账号ID
946
947  ```ts
948  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
949  let uid: number = 12345678;
950  try {
951    let localId : number = accountManager.getOsAccountLocalIdForUidSync(uid);
952    console.log('getOsAccountLocalIdForUidSync successfully, localId: ' + localId);
953  } catch (err) {
954    console.log('getOsAccountLocalIdForUidSync exception: ' + JSON.stringify(err));
955  }
956  ```
957
958### getOsAccountLocalIdForDomain<sup>9+</sup>
959
960getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
961
962根据域账号信息,获取与其关联的系统账号ID。使用callback异步回调。
963
964**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
965
966**系统能力:** SystemCapability.Account.OsAccount
967
968**参数:**
969
970| 参数名     | 类型                                    | 必填 | 说明                                                                         |
971| ---------- | --------------------------------------- | ---- | -------------------------------------------------------------------------- |
972| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。                                                                |
973| callback   | AsyncCallback&lt;number&gt;             | 是   | 回调函数。如果查询成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 |
974
975**错误码:**
976
977| 错误码ID | 错误信息       |
978| -------- | ------------- |
979| 201 | Permission denied.|
980| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
981| 12300001 | The system service works abnormally. |
982| 12300002 | Invalid domainInfo. |
983
984**示例:**
985
986  ```ts
987  import { BusinessError } from '@kit.BasicServicesKit';
988  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
989  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
990  try {
991    accountManager.getOsAccountLocalIdForDomain(domainInfo, (err: BusinessError, localId: number) => {
992      if (err) {
993        console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
994      } else {
995        console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
996      }
997    });
998  } catch (err) {
999    console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
1000  }
1001  ```
1002
1003### getOsAccountLocalIdForDomain<sup>9+</sup>
1004
1005getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
1006
1007根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。
1008
1009**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1010
1011**系统能力:** SystemCapability.Account.OsAccount
1012
1013**参数:**
1014
1015| 参数名     | 类型                                    | 必填 | 说明         |
1016| ---------- | --------------------------------------- | ---- | ------------ |
1017| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。 |
1018
1019**返回值:**
1020
1021| 类型                  | 说明                                    |
1022| :-------------------- | :------------------------------------- |
1023| Promise&lt;number&gt; | Promise对象,返回域账号关联的系统账号ID。 |
1024
1025**错误码:**
1026
1027| 错误码ID | 错误信息       |
1028| -------- | ------------- |
1029| 201 | Permission denied.|
1030| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1031| 12300001 | The system service works abnormally. |
1032| 12300002 | Invalid domainInfo. |
1033
1034**示例:**
1035
1036  ```ts
1037  import { BusinessError } from '@kit.BasicServicesKit';
1038  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1039  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
1040  try {
1041    accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId: number) => {
1042      console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
1043    }).catch((err: BusinessError) => {
1044      console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
1045    });
1046  } catch (err) {
1047    console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
1048  }
1049  ```
1050
1051### getOsAccountConstraints<sup>(deprecated)</sup>
1052
1053getOsAccountConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1054
1055获取指定系统账号的全部约束。使用callback异步回调。
1056
1057> **说明:**
1058>
1059> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1060
1061**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1062
1063**系统能力:** SystemCapability.Account.OsAccount
1064
1065**参数:**
1066
1067| 参数名   | 类型                                     | 必填 | 说明                                                                                           |
1068| -------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------- |
1069| localId  | number                                   | 是   | 系统账号ID。                                                                                  |
1070| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是   | 回调函数,如果获取成功,err为null,data为该系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 |
1071
1072**错误码:**
1073
1074| 错误码ID | 错误信息             |
1075| -------- | ------------------- |
1076| 201 | Permission denied.|
1077| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1078| 12300001 | The system service works abnormally. |
1079| 12300002 | Invalid localId.    |
1080| 12300003 | Account not found. |
1081
1082**示例:** 获取ID为100的系统账号的全部约束
1083
1084  ```ts
1085  import { BusinessError } from '@kit.BasicServicesKit';
1086  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1087  let localId: number = 100;
1088  try {
1089    accountManager.getOsAccountConstraints(localId, (err: BusinessError, constraints: string[]) => {
1090      if (err) {
1091        console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err));
1092      } else {
1093        console.log('getOsAccountConstraints successfully, constraints: ' + JSON.stringify(constraints));
1094      }
1095    });
1096  } catch (err) {
1097    console.log('getOsAccountConstraints exception: ' + JSON.stringify(err));
1098  }
1099  ```
1100
1101### getOsAccountConstraints<sup>(deprecated)</sup>
1102
1103getOsAccountConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
1104
1105获取指定系统账号的全部约束。使用Promise异步回调。
1106
1107> **说明:**
1108>
1109> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1110
1111**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1112
1113**系统能力:** SystemCapability.Account.OsAccount
1114
1115**参数:**
1116
1117| 参数名  | 类型   | 必填 | 说明         |
1118| ------- | ------ | ---- | ------------ |
1119| localId | number | 是   | 系统账号ID。 |
1120
1121**返回值:**
1122
1123| 类型                               | 说明                                                       |
1124| ---------------------------------- | ---------------------------------------------------------- |
1125| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 |
1126
1127**错误码:**
1128
1129| 错误码ID | 错误信息             |
1130| -------- | ------------------- |
1131| 201 | Permission denied.|
1132| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1133| 12300001 | The system service works abnormally. |
1134| 12300002 | Invalid localId.    |
1135| 12300003 | Account not found. |
1136
1137**示例:** 获取ID为100的系统账号的全部约束
1138
1139  ```ts
1140  import { BusinessError } from '@kit.BasicServicesKit';
1141  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1142  let localId: number = 100;
1143  try {
1144    accountManager.getOsAccountConstraints(localId).then((constraints: string[]) => {
1145      console.log('getOsAccountConstraints, constraints: ' + constraints);
1146    }).catch((err: BusinessError) => {
1147      console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
1148    });
1149  } catch (e) {
1150    console.log('getOsAccountConstraints exception: ' + JSON.stringify(e));
1151  }
1152  ```
1153
1154### getActivatedOsAccountLocalIds<sup>9+</sup>
1155
1156getActivatedOsAccountLocalIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
1157
1158查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。
1159
1160**系统能力:** SystemCapability.Account.OsAccount
1161
1162**参数:**
1163
1164| 参数名   | 类型                                     | 必填 | 说明                                                   |
1165| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
1166| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 |
1167
1168**错误码:**
1169
1170| 错误码ID | 错误信息       |
1171| -------- | ------------- |
1172| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1173| 12300001 | The system service works abnormally. |
1174
1175**示例:**
1176
1177  ```ts
1178  import { BusinessError } from '@kit.BasicServicesKit';
1179  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1180  try {
1181    accountManager.getActivatedOsAccountLocalIds((err: BusinessError, idArray: number[])=>{
1182      console.log('getActivatedOsAccountLocalIds err:' + JSON.stringify(err));
1183      console.log('getActivatedOsAccountLocalIds idArray length:' + idArray.length);
1184      for(let i=0;i<idArray.length;i++) {
1185        console.info('activated os account id: ' + idArray[i]);
1186      }
1187    });
1188  } catch (e) {
1189    console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
1190  }
1191  ```
1192
1193### getActivatedOsAccountLocalIds<sup>9+</sup>
1194
1195getActivatedOsAccountLocalIds(): Promise&lt;Array&lt;number&gt;&gt;
1196
1197查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。
1198
1199**系统能力:** SystemCapability.Account.OsAccount
1200
1201**返回值:**
1202
1203| 类型                               | 说明                                               |
1204| :--------------------------------- | :------------------------------------------------ |
1205| Promise&lt;Array&lt;number&gt;&gt; | Promise对象,返回当前处于激活状态的系统账号的ID列表。 |
1206
1207**错误码:**
1208
1209| 错误码ID | 错误信息       |
1210| -------- | ------------- |
1211| 12300001 | The system service works abnormally. |
1212
1213**示例:**
1214
1215  ```ts
1216  import { BusinessError } from '@kit.BasicServicesKit';
1217  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1218  try {
1219    accountManager.getActivatedOsAccountLocalIds().then((idArray: number[]) => {
1220      console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray);
1221    }).catch((err: BusinessError) => {
1222      console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err));
1223    });
1224  } catch (e) {
1225    console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
1226  }
1227  ```
1228
1229### getCurrentOsAccount<sup>(deprecated)</sup>
1230
1231getCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
1232
1233查询当前进程所属的系统账号的信息。使用callback异步回调。
1234
1235> **说明:**
1236>
1237> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1238
1239**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。
1240
1241**系统能力:** SystemCapability.Account.OsAccount
1242
1243**参数:**
1244
1245| 参数名   | 类型                                                 | 必填 | 说明                                           |
1246| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
1247| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 |
1248
1249**错误码:**
1250
1251| 错误码ID | 错误信息             |
1252| -------- | ------------------- |
1253| 201 | Permission denied.|
1254| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1255| 12300001 | The system service works abnormally. |
1256
1257**示例:**
1258
1259  ```ts
1260  import { BusinessError } from '@kit.BasicServicesKit';
1261  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1262  try {
1263    accountManager.getCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
1264      console.log('getCurrentOsAccount err:' + JSON.stringify(err));
1265      console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
1266    });
1267  } catch (e) {
1268    console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
1269  }
1270  ```
1271
1272### getCurrentOsAccount<sup>(deprecated)</sup>
1273
1274getCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
1275
1276查询当前进程所属的系统账号的信息。使用Promise异步回调。
1277
1278> **说明:**
1279>
1280> 从 API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1281
1282**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。
1283
1284**系统能力:** SystemCapability.Account.OsAccount
1285
1286**返回值:**
1287
1288| 类型                                           | 说明                                       |
1289| ---------------------------------------------- | ----------------------------------------- |
1290| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统账号信息。 |
1291
1292**错误码:**
1293
1294| 错误码ID | 错误信息             |
1295| -------- | ------------------- |
1296| 201 | Permission denied.|
1297| 12300001 | The system service works abnormally. |
1298
1299**示例:**
1300
1301  ```ts
1302  import { BusinessError } from '@kit.BasicServicesKit';
1303  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1304  try {
1305    accountManager.getCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
1306      console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
1307    }).catch((err: BusinessError) => {
1308      console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
1309    });
1310  } catch (e) {
1311    console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
1312  }
1313  ```
1314
1315### getOsAccountType<sup>9+</sup>
1316
1317getOsAccountType(callback: AsyncCallback&lt;OsAccountType&gt;): void
1318
1319查询当前进程所属的系统账号的账号类型。使用callback异步回调。
1320
1321**系统能力:** SystemCapability.Account.OsAccount
1322
1323**参数:**
1324
1325| 参数名   | 类型                                                 | 必填 | 说明                                                 |
1326| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
1327| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 |
1328
1329**错误码:**
1330
1331| 错误码ID | 错误信息             |
1332| -------- | ------------------- |
1333| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1334| 12300001 | The system service works abnormally. |
1335
1336**示例:**
1337
1338  ```ts
1339  import { BusinessError } from '@kit.BasicServicesKit';
1340  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1341  try {
1342    accountManager.getOsAccountType((err: BusinessError, accountType: osAccount.OsAccountType) => {
1343      console.log('getOsAccountType err: ' + JSON.stringify(err));
1344      console.log('getOsAccountType accountType: ' + accountType);
1345    });
1346  } catch (e) {
1347    console.log('getOsAccountType exception: ' + JSON.stringify(e));
1348  }
1349  ```
1350
1351### getOsAccountType<sup>9+</sup>
1352
1353getOsAccountType(): Promise&lt;OsAccountType&gt;
1354
1355查询当前进程所属的系统账号的账号类型。使用Promise异步回调。
1356
1357**系统能力:** SystemCapability.Account.OsAccount
1358
1359**返回值:**
1360
1361| 类型                                           | 说明                                             |
1362| ---------------------------------------------- | ----------------------------------------------- |
1363| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise对象,返回当前进程所属的系统账号的账号类型。 |
1364
1365**错误码:**
1366
1367| 错误码ID | 错误信息             |
1368| -------- | ------------------- |
1369| 12300001 | The system service works abnormally. |
1370
1371**示例:**
1372
1373  ```ts
1374  import { BusinessError } from '@kit.BasicServicesKit';
1375  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1376  try {
1377    accountManager.getOsAccountType().then((accountType: osAccount.OsAccountType) => {
1378      console.log('getOsAccountType, accountType: ' + accountType);
1379    }).catch((err: BusinessError) => {
1380      console.log('getOsAccountType err: ' + JSON.stringify(err));
1381    });
1382  } catch (e) {
1383    console.log('getOsAccountType exception: ' + JSON.stringify(e));
1384  }
1385  ```
1386
1387### queryDistributedVirtualDeviceId<sup>9+</sup>
1388
1389queryDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
1390
1391获取分布式虚拟设备ID。使用callback异步回调。
1392
1393**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
1394
1395**系统能力:** SystemCapability.Account.OsAccount
1396
1397**参数:**
1398
1399| 参数名   | 类型                        | 必填 | 说明                                                                   |
1400| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
1401| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
1402
1403**错误码:**
1404
1405| 错误码ID | 错误信息             |
1406| -------- | ------------------- |
1407| 201 | Permission denied.|
1408| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1409| 12300001 | The system service works abnormally. |
1410
1411**示例:**
1412
1413  ```ts
1414  import { BusinessError } from '@kit.BasicServicesKit';
1415  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1416  try {
1417    accountManager.queryDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
1418      console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
1419      console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID);
1420    });
1421  } catch (e) {
1422    console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
1423  }
1424  ```
1425
1426### queryDistributedVirtualDeviceId<sup>9+</sup>
1427
1428queryDistributedVirtualDeviceId(): Promise&lt;string&gt;
1429
1430获取分布式虚拟设备ID。使用Promise异步回调。
1431
1432**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
1433
1434**系统能力:** SystemCapability.Account.OsAccount
1435
1436**返回值:**
1437
1438| 类型                  | 说明                              |
1439| --------------------- | --------------------------------- |
1440| Promise&lt;string&gt; | Promise对象,返回分布式虚拟设备ID。 |
1441
1442**错误码:**
1443
1444| 错误码ID | 错误信息             |
1445| -------- | ------------------- |
1446| 201 | Permission denied.|
1447| 12300001 | The system service works abnormally. |
1448
1449**示例:**
1450
1451  ```ts
1452  import { BusinessError } from '@kit.BasicServicesKit';
1453  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1454  try {
1455    accountManager.queryDistributedVirtualDeviceId().then((virtualID: string) => {
1456      console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
1457    }).catch((err: BusinessError) => {
1458      console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
1459    });
1460  } catch (e) {
1461    console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
1462  }
1463  ```
1464
1465### getOsAccountLocalIdForSerialNumber<sup>9+</sup>
1466
1467getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
1468
1469通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。
1470
1471**系统能力:** SystemCapability.Account.OsAccount
1472
1473**参数:**
1474
1475| 参数名       | 类型                        | 必填 | 说明                                                                           |
1476| ------------ | --------------------------- | ---- | ---------------------------------------------------------------------------- |
1477| serialNumber | number                      | 是   | 账号SN码。                                                                    |
1478| callback     | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 |
1479
1480**错误码:**
1481
1482| 错误码ID | 错误信息               |
1483| -------- | ------------------- |
1484| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1485| 12300001 | The system service works abnormally. |
1486| 12300002 | Invalid serialNumber. |
1487| 12300003 | The account indicated by serialNumber dose not exist. |
1488
1489**示例:** 查询与SN码12345关联的系统账号的ID
1490
1491  ```ts
1492  import { BusinessError } from '@kit.BasicServicesKit';
1493  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1494  let serialNumber: number = 12345;
1495  try {
1496    accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
1497      console.log('ger localId err:' + JSON.stringify(err));
1498      console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
1499    });
1500  } catch (e) {
1501    console.log('ger localId exception: ' + JSON.stringify(e));
1502  }
1503  ```
1504
1505### getOsAccountLocalIdForSerialNumber<sup>9+</sup>
1506
1507getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise&lt;number&gt;
1508
1509通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。
1510
1511**系统能力:** SystemCapability.Account.OsAccount
1512
1513**参数:**
1514
1515| 参数名       | 类型   | 必填 | 说明       |
1516| ------------ | ------ | ---- | ---------- |
1517| serialNumber | number | 是   | 账号SN码。 |
1518
1519**返回值:**
1520
1521| 类型                  | 说明                                         |
1522| --------------------- | -------------------------------------------- |
1523| Promise&lt;number&gt; | Promise对象,返回与SN码关联的系统账号的账号ID。 |
1524
1525**错误码:**
1526
1527| 错误码ID | 错误信息               |
1528| -------- | ------------------- |
1529| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1530| 12300001 | The system service works abnormally. |
1531| 12300002 | Invalid serialNumber. |
1532| 12300003 | The account indicated by serialNumber dose not exist. |
1533
1534**示例:** 查询与SN码12345关联的系统账号的ID
1535
1536  ```ts
1537  import { BusinessError } from '@kit.BasicServicesKit';
1538  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1539  let serialNumber: number = 12345;
1540  try {
1541    accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId: number) => {
1542      console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId);
1543    }).catch((err: BusinessError) => {
1544      console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err));
1545    });
1546  } catch (e) {
1547    console.log('getOsAccountLocalIdForSerialNumber exception: ' + JSON.stringify(e));
1548  }
1549  ```
1550
1551### getSerialNumberForOsAccountLocalId<sup>9+</sup>
1552
1553getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
1554
1555通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。
1556
1557**系统能力:** SystemCapability.Account.OsAccount
1558
1559**参数:**
1560
1561| 参数名   | 类型                        | 必填 | 说明                                                                         |
1562| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
1563| localId  | number                      | 是   | 系统账号ID。                                                                 |
1564| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 |
1565
1566**错误码:**
1567
1568| 错误码ID | 错误信息             |
1569| -------- | ------------------- |
1570| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1571| 12300001 | The system service works abnormally. |
1572| 12300002 | Invalid localId.    |
1573| 12300003 | Account not found. |
1574
1575**示例:** 获取ID为100的系统账号关联的SN码
1576
1577  ```ts
1578  import { BusinessError } from '@kit.BasicServicesKit';
1579  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1580  let localId: number = 100;
1581  try {
1582    accountManager.getSerialNumberForOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
1583      console.log('ger serialNumber err:' + JSON.stringify(err));
1584      console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
1585    });
1586  } catch (e) {
1587    console.log('ger serialNumber exception: ' + JSON.stringify(e));
1588  }
1589  ```
1590
1591### getSerialNumberForOsAccountLocalId<sup>9+</sup>
1592
1593getSerialNumberForOsAccountLocalId(localId: number): Promise&lt;number&gt;
1594
1595通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。
1596
1597**系统能力:** SystemCapability.Account.OsAccount
1598
1599**参数:**
1600
1601| 参数名  | 类型   | 必填 | 说明          |
1602| ------- | ------ | ---- | ----------- |
1603| localId | number | 是   | 系统账号ID。 |
1604
1605**返回值:**
1606
1607| 类型                  | 说明                                    |
1608| :-------------------- | :------------------------------------- |
1609| Promise&lt;number&gt; | Promise对象,返回与该系统账号关联的SN码。 |
1610
1611**错误码:**
1612
1613| 错误码ID | 错误信息             |
1614| -------- | ------------------- |
1615| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1616| 12300001 | The system service works abnormally. |
1617| 12300002 | Invalid localId.    |
1618| 12300003 | Account not found. |
1619
1620**示例:** 获取ID为100的系统账号关联的SN码
1621
1622  ```ts
1623  import { BusinessError } from '@kit.BasicServicesKit';
1624  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1625  let localId: number = 100;
1626  try {
1627    accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber: number) => {
1628      console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber);
1629    }).catch((err: BusinessError) => {
1630      console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err));
1631    });
1632  } catch (e) {
1633    console.log('getSerialNumberForOsAccountLocalId exception: ' + JSON.stringify(e));
1634  }
1635  ```
1636
1637### isMultiOsAccountEnable<sup>(deprecated)</sup>
1638
1639isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
1640
1641判断是否支持多系统账号。使用callback异步回调。
1642
1643> **说明:**
1644>
1645> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9)。
1646
1647**系统能力:** SystemCapability.Account.OsAccount
1648
1649**参数:**
1650
1651| 参数名   | 类型                         | 必填 | 说明                                                     |
1652| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
1653| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示支持多系统账号;返回false表示不支持。 |
1654
1655**示例:**
1656
1657  ```ts
1658  import { BusinessError } from '@kit.BasicServicesKit';
1659  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1660  accountManager.isMultiOsAccountEnable((err: BusinessError, isEnabled: boolean) => {
1661    if (err) {
1662      console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
1663    } else {
1664    console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
1665    }
1666  });
1667  ```
1668
1669### isMultiOsAccountEnable<sup>(deprecated)</sup>
1670
1671isMultiOsAccountEnable(): Promise&lt;boolean&gt;
1672
1673判断是否支持多系统账号。使用Promise异步回调。
1674
1675> **说明:**
1676>
1677> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9-1)。
1678
1679**系统能力:** SystemCapability.Account.OsAccount
1680
1681**返回值:**
1682
1683| 类型                   | 说明                                                       |
1684| :--------------------- | :--------------------------------------------------------- |
1685| Promise&lt;boolean&gt; | Promise对象。返回true表示支持多系统账号;返回false表示不支持。 |
1686
1687**示例:**
1688
1689  ```ts
1690  import { BusinessError } from '@kit.BasicServicesKit';
1691  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1692  accountManager.isMultiOsAccountEnable().then((isEnabled: boolean) => {
1693    console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
1694  }).catch((err: BusinessError) => {
1695    console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
1696  });
1697  ```
1698
1699### isOsAccountActived<sup>(deprecated)</sup>
1700
1701isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
1702
1703判断指定系统账号是否处于激活状态。使用callback异步回调。
1704
1705> **说明:**
1706>
1707> 从 API version 7开始支持从API version 9开始废弃。替代方法仅向系统应用开放。
1708
1709**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1710
1711**系统能力:** SystemCapability.Account.OsAccount
1712
1713**参数:**
1714
1715| 参数名   | 类型                         | 必填 | 说明                                                     |
1716| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
1717| localId  | number                       | 是   | 系统账号ID。                                            |
1718| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示账号已激活;返回false表示账号未激活。 |
1719
1720**示例:** 判断ID为100的系统账号是否处于激活状态
1721
1722  ```ts
1723  import { BusinessError } from '@kit.BasicServicesKit';
1724  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1725  let localId: number = 100;
1726  accountManager.isOsAccountActived(localId, (err: BusinessError, isActived: boolean) => {
1727    if (err) {
1728      console.log('isOsAccountActived failed, err:' + JSON.stringify(err));
1729    } else {
1730      console.log('isOsAccountActived successfully, isActived:' + isActived);
1731    }
1732  });
1733  ```
1734
1735### isOsAccountActived<sup>(deprecated)</sup>
1736
1737isOsAccountActived(localId: number): Promise&lt;boolean&gt;
1738
1739判断指定系统账号是否处于激活状态。使用Promise异步回调。
1740
1741> **说明:**
1742>
1743> 从 API version 7开始支持从API version 9开始废弃。替代方法仅向系统应用开放。
1744
1745**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1746
1747**系统能力:** SystemCapability.Account.OsAccount
1748
1749**参数:**
1750
1751| 参数名  | 类型   | 必填 | 说明                               |
1752| ------- | ------ | ---- | --------------------------------- |
1753| localId | number | 是   | 系统账号ID。 |
1754
1755**返回值:**
1756
1757| 类型                   | 说明                                                        |
1758| --------------------- | ----------------------------------------------------------- |
1759| Promise&lt;boolean&gt; | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 |
1760
1761**示例:** 判断ID为100的系统账号是否处于激活状态
1762
1763  ```ts
1764  import { BusinessError } from '@kit.BasicServicesKit';
1765  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1766  let localId: number = 100;
1767  accountManager.isOsAccountActived(localId).then((isActived: boolean) => {
1768    console.log('isOsAccountActived successfully, isActived: ' + isActived);
1769  }).catch((err: BusinessError) => {
1770    console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
1771  });
1772  ```
1773
1774### isOsAccountConstraintEnable<sup>(deprecated)</sup>
1775
1776isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void
1777
1778判断指定系统账号是否具有指定约束。使用callback异步回调。
1779
1780> **说明:**
1781>
1782> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1783
1784**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
1785
1786**系统能力:** SystemCapability.Account.OsAccount
1787
1788**参数:**
1789
1790| 参数名     | 类型                         | 必填 | 说明                                                                |
1791| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
1792| localId    | number                       | 是   | 系统账号ID。                                 |
1793| constraint | string                       | 是   | 指定的[约束](#系统账号约束列表)名称。                                |
1794| callback   | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
1795
1796**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
1797
1798  ```ts
1799  import { BusinessError } from '@kit.BasicServicesKit';
1800  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1801  let localId: number = 100;
1802  let constraint: string = 'constraint.wifi';
1803  accountManager.isOsAccountConstraintEnable(localId, constraint, (err: BusinessError, isEnabled: boolean) => {
1804    if (err) {
1805      console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err));
1806    } else {
1807      console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
1808    }
1809  });
1810  ```
1811
1812### isOsAccountConstraintEnable<sup>(deprecated)</sup>
1813
1814isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boolean&gt;
1815
1816判断指定系统账号是否具有指定约束。使用Promise异步回调。
1817
1818> **说明:**
1819>
1820> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1821
1822**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
1823
1824**系统能力:** SystemCapability.Account.OsAccount
1825
1826**参数:**
1827
1828| 参数名     | 类型   | 必填 | 说明                                 |
1829| ---------- | ------ | ---- | ---------------------------------- |
1830| localId    | number | 是   | 系统账号ID。  |
1831| constraint | string | 是   | 指定的[约束](#系统账号约束列表)名称。 |
1832
1833**返回值:**
1834
1835| 类型                   | 说明                                                                   |
1836| ---------------------- | --------------------------------------------------------------------- |
1837| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
1838
1839**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
1840
1841  ```ts
1842  import { BusinessError } from '@kit.BasicServicesKit';
1843  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1844  let localId: number = 100;
1845  let constraint: string = 'constraint.wifi';
1846  accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled: boolean) => {
1847    console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
1848  }).catch((err: BusinessError) => {
1849    console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err));
1850  });
1851  ```
1852
1853### isTestOsAccount<sup>(deprecated)</sup>
1854
1855isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
1856
1857检查当前系统账号是否为测试账号。使用callback异步回调。
1858
1859> **说明:**
1860>
1861> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9)。
1862
1863**系统能力:** SystemCapability.Account.OsAccount
1864
1865**参数:**
1866
1867| 参数名   | 类型                         | 必填 | 说明                                                                   |
1868| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
1869| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
1870
1871**示例:**
1872
1873  ```ts
1874  import { BusinessError } from '@kit.BasicServicesKit';
1875  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1876  accountManager.isTestOsAccount((err: BusinessError, isTestable: boolean) => {
1877    if (err) {
1878      console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
1879    } else {
1880      console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
1881    }
1882  });
1883  ```
1884
1885### isTestOsAccount<sup>(deprecated)</sup>
1886
1887isTestOsAccount(): Promise&lt;boolean&gt;
1888
1889检查当前系统账号是否为测试账号。使用Promise异步回调。
1890
1891> **说明:**
1892>
1893> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9-1)。
1894
1895**系统能力:** SystemCapability.Account.OsAccount
1896
1897**返回值:**
1898
1899| 类型                   | 说明                                                                      |
1900| ---------------------- | ------------------------------------------------------------------------ |
1901| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
1902
1903**示例:**
1904
1905  ```ts
1906  import { BusinessError } from '@kit.BasicServicesKit';
1907  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1908    accountManager.isTestOsAccount().then((isTestable: boolean) => {
1909      console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
1910    }).catch((err: BusinessError) => {
1911      console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
1912  });
1913  ```
1914
1915### isOsAccountVerified<sup>(deprecated)</sup>
1916
1917isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
1918
1919检查当前系统账号是否已验证。使用callback异步回调。
1920
1921> **说明:**
1922>
1923> 从 API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountVerified](#checkosaccountverifieddeprecated)。
1924
1925**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1926
1927**系统能力:** SystemCapability.Account.OsAccount
1928
1929**参数:**
1930
1931| 参数名   | 类型                         | 必填 | 说明                                                            |
1932| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
1933| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
1934
1935**示例:**
1936
1937  ```ts
1938  import { BusinessError } from '@kit.BasicServicesKit';
1939  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1940  accountManager.isOsAccountVerified((err: BusinessError, isVerified: boolean) => {
1941    if (err) {
1942      console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
1943    } else {
1944      console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
1945    }
1946  });
1947  ```
1948
1949### isOsAccountVerified<sup>(deprecated)</sup>
1950
1951isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
1952
1953检查指定系统账号是否已验证。使用callback异步回调。
1954
1955> **说明:**
1956>
1957> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1958
1959**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1960
1961**系统能力:** SystemCapability.Account.OsAccount
1962
1963**参数:**
1964
1965| 参数名   | 类型                         | 必填 | 说明                                                            |
1966| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
1967| localId  | number                       | 是   | 系统账号ID。                             |
1968| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
1969
1970**示例:**
1971
1972  ```ts
1973  import { BusinessError } from '@kit.BasicServicesKit';
1974  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1975  let localId: number = 100;
1976  accountManager.isOsAccountVerified(localId, (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): Promise&lt;boolean&gt;
1988
1989检查指定系统账号是否已验证。使用Promise异步回调。
1990
1991> **说明:**
1992>
1993> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1994
1995**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1996
1997**系统能力:** SystemCapability.Account.OsAccount
1998
1999**参数:**
2000
2001| 参数名  | 类型   | 必填 | 说明                                                              |
2002| ------- | ------ | ---- | ---------------------------------------------------------------- |
2003| localId | number | 否   | 系统账号ID。不填则检查当前系统账号是否已验证。 |
2004
2005**返回值:**
2006
2007| 类型                   | 说明                                                               |
2008| ---------------------- | ----------------------------------------------------------------- |
2009| Promise&lt;boolean&gt; | Promise对象。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
2010
2011**示例:**
2012
2013  ```ts
2014  import { BusinessError } from '@kit.BasicServicesKit';
2015  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2016  accountManager.isOsAccountVerified().then((isVerified: boolean) => {
2017    console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
2018  }).catch((err: BusinessError) => {
2019    console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
2020  });
2021  ```
2022
2023### getCreatedOsAccountsCount<sup>(deprecated)</sup>
2024
2025getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
2026
2027获取已创建的系统账号数量。使用callback异步回调。
2028
2029> **说明:**
2030>
2031> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9)。
2032
2033**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2034
2035**系统能力:** SystemCapability.Account.OsAccount
2036
2037**参数:**
2038
2039| 参数名   | 类型                        | 必填 | 说明                                                                         |
2040| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
2041| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。当获取成功时,err为null,data为已创建的系统账号的数量;否则为错误对象。 |
2042
2043**示例:**
2044
2045  ```ts
2046  import { BusinessError } from '@kit.BasicServicesKit';
2047  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2048  accountManager.getCreatedOsAccountsCount((err: BusinessError, count: number)=>{
2049    if (err) {
2050      console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
2051    } else {
2052      console.log('getCreatedOsAccountsCount successfully, count: ' + count);
2053    }
2054  });
2055  ```
2056
2057### getCreatedOsAccountsCount<sup>(deprecated)</sup>
2058
2059getCreatedOsAccountsCount(): Promise&lt;number&gt;
2060
2061获取已创建的系统账号数量,使用Promise异步回调。
2062
2063> **说明:**
2064>
2065> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9-1)。
2066
2067**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2068
2069**系统能力:** SystemCapability.Account.OsAccount
2070
2071**返回值:**
2072
2073| 类型                  | 说明                                    |
2074| --------------------- | -------------------------------------- |
2075| Promise&lt;number&gt; | Promise对象,返回已创建的系统账号的数量。 |
2076
2077**示例:**
2078
2079  ```ts
2080  import { BusinessError } from '@kit.BasicServicesKit';
2081  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2082  accountManager.getCreatedOsAccountsCount().then((count: number) => {
2083    console.log('getCreatedOsAccountsCount successfully, count: ' + count);
2084  }).catch((err: BusinessError) => {
2085    console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
2086  });
2087  ```
2088
2089### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup>
2090
2091getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
2092
2093获取当前进程所属的系统账号ID,使用callback异步回调。
2094
2095> **说明:**
2096>
2097> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9)。
2098
2099**系统能力:** SystemCapability.Account.OsAccount
2100
2101**参数:**
2102
2103| 参数名   | 类型                        | 必填 | 说明                                                                           |
2104| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
2105| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。当获取成功时,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 |
2106
2107**示例:**
2108
2109  ```ts
2110  import { BusinessError } from '@kit.BasicServicesKit';
2111  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2112  accountManager.getOsAccountLocalIdFromProcess((err: BusinessError, localId: number) => {
2113    if (err) {
2114      console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
2115    } else {
2116      console.log('getOsAccountLocalIdFromProcess failed, error: ' + localId);
2117    }
2118  });
2119  ```
2120
2121### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup>
2122
2123getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
2124
2125获取当前进程所属的系统账号ID,使用Promise异步回调。
2126
2127> **说明:**
2128>
2129> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9-1)。
2130
2131**系统能力:** SystemCapability.Account.OsAccount
2132
2133**返回值:**
2134
2135| 类型                  | 说明                                      |
2136| :-------------------- | :--------------------------------------- |
2137| Promise&lt;number&gt; | Promise对象,返回当前进程所属的系统账号ID。 |
2138
2139**示例:**
2140
2141  ```ts
2142  import { BusinessError } from '@kit.BasicServicesKit';
2143  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2144  accountManager.getOsAccountLocalIdFromProcess().then((localId: number) => {
2145    console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
2146  }).catch((err: BusinessError) => {
2147    console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
2148  });
2149  ```
2150
2151### getOsAccountLocalIdFromUid<sup>(deprecated)</sup>
2152
2153getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
2154
2155根据uid查询对应的系统账号ID。使用callback异步回调。
2156
2157> **说明:**
2158>
2159> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9)。
2160
2161**系统能力:** SystemCapability.Account.OsAccount
2162
2163**参数:**
2164
2165| 参数名   | 类型                        | 必填 | 说明                                                                    |
2166| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
2167| uid      | number                      | 是   | 进程uid。                                                              |
2168| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 |
2169
2170**示例:** 查询值为12345678的uid所属的系统账号ID
2171
2172  ```ts
2173  import { BusinessError } from '@kit.BasicServicesKit';
2174  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2175  let uid: number = 12345678;
2176  accountManager.getOsAccountLocalIdFromUid(uid, (err: BusinessError, localId: number) => {
2177    if (err) {
2178      console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
2179    } else {
2180      console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
2181    }
2182  });
2183  ```
2184
2185### getOsAccountLocalIdFromUid<sup>(deprecated)</sup>
2186
2187getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
2188
2189根据uid查询对应的系统账号ID,使用Promise异步回调。
2190
2191> **说明:**
2192>
2193> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9-1)。
2194
2195**系统能力:** SystemCapability.Account.OsAccount
2196
2197**参数:**
2198
2199| 参数名 | 类型   | 必填 | 说明      |
2200| ------ | ------ | ---- | --------- |
2201| uid    | number | 是   | 进程uid。 |
2202
2203**返回值:**
2204
2205| 类型                  | 说明                                  |
2206| :-------------------- | :----------------------------------- |
2207| Promise&lt;number&gt; | Promise对象,返回uid对应的系统账号ID。 |
2208
2209**示例:** 查询值为12345678的uid所属的系统账号ID
2210
2211  ```ts
2212  import { BusinessError } from '@kit.BasicServicesKit';
2213  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2214  let uid: number = 12345678;
2215  accountManager.getOsAccountLocalIdFromUid(uid).then((localId: number) => {
2216    console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
2217  }).catch((err: BusinessError) => {
2218    console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
2219  });
2220  ```
2221
2222### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup>
2223
2224getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
2225
2226根据域账号信息,获取与其关联的系统账号的账号ID。使用callback异步回调。
2227
2228> **说明:**
2229>
2230> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9)。
2231
2232**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2233
2234**系统能力:** SystemCapability.Account.OsAccount
2235
2236**参数:**
2237
2238| 参数名     | 类型                                    | 必填 | 说明                                                                         |
2239| ---------- | --------------------------------------- | ---- | --------------------------------------------------------------------------- |
2240| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。                                                                |
2241| callback   | AsyncCallback&lt;number&gt;             | 是   | 回调函数,如果获取成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 |
2242
2243**示例:**
2244
2245  ```ts
2246  import { BusinessError } from '@kit.BasicServicesKit';
2247  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
2248  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2249  accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => {
2250    if (err) {
2251      console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
2252    } else {
2253      console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
2254    }
2255  });
2256  ```
2257
2258### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup>
2259
2260getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
2261
2262根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。
2263
2264> **说明:**
2265>
2266> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9-1)。
2267
2268**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2269
2270**系统能力:** SystemCapability.Account.OsAccount
2271
2272**参数:**
2273
2274| 参数名     | 类型                                    | 必填 | 说明         |
2275| ---------- | --------------------------------------- | ---- | ------------ |
2276| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。 |
2277
2278**返回值:**
2279
2280| 类型                  | 说明                                    |
2281| :-------------------- | :------------------------------------- |
2282| Promise&lt;number&gt; | Promise对象,返回域账号关联的系统账号ID。 |
2283
2284**示例:**
2285
2286  ```ts
2287  import { BusinessError } from '@kit.BasicServicesKit';
2288  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2289  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
2290  accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => {
2291    console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
2292  }).catch((err: BusinessError) => {
2293    console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
2294  });
2295  ```
2296
2297### getOsAccountAllConstraints<sup>(deprecated)</sup>
2298
2299getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
2300
2301获取指定系统账号的全部约束。使用callback异步回调。
2302
2303> **说明:**
2304>
2305> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2306
2307**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2308
2309**系统能力:** SystemCapability.Account.OsAccount
2310
2311**参数:**
2312
2313| 参数名   | 类型                                     | 必填 | 说明                                                                                             |
2314| -------- | ---------------------------------------- | ---- | ---------------------------------------------------------------------------------------------- |
2315| localId  | number                                   | 是   | 系统账号ID。                                                                                    |
2316| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是   | 回调函数。如果获取成功,err为null,data为指定系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 |
2317
2318**示例:** 获取ID为100的系统账号的全部约束
2319
2320  ```ts
2321  import { BusinessError } from '@kit.BasicServicesKit';
2322  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2323  let localId: number = 100;
2324  accountManager.getOsAccountAllConstraints(localId, (err: BusinessError, constraints: string[])=>{
2325    console.log('getOsAccountAllConstraints err:' + JSON.stringify(err));
2326    console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints));
2327  });
2328  ```
2329
2330### getOsAccountAllConstraints<sup>(deprecated)</sup>
2331
2332getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
2333
2334获取指定系统账号的全部约束。使用Promise异步回调。
2335
2336> **说明:**
2337>
2338> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2339
2340**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2341
2342**系统能力:** SystemCapability.Account.OsAccount
2343
2344**参数:**
2345
2346| 参数名  | 类型   | 必填 | 说明         |
2347| ------- | ------ | ---- | ------------ |
2348| localId | number | 是   | 系统账号ID。 |
2349
2350**返回值:**
2351
2352| 类型                               | 说明                                                         |
2353| :--------------------------------- | :----------------------------------------------------------- |
2354| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 |
2355
2356**示例:** 获取ID为100的系统账号的全部约束
2357
2358  ```ts
2359  import { BusinessError } from '@kit.BasicServicesKit';
2360  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2361  let localId: number = 100;
2362  accountManager.getOsAccountAllConstraints(localId).then((constraints: string[]) => {
2363    console.log('getOsAccountAllConstraints, constraints: ' + constraints);
2364  }).catch((err: BusinessError) => {
2365    console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
2366  });
2367  ```
2368
2369### queryActivatedOsAccountIds<sup>(deprecated)</sup>
2370
2371queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2372
2373查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。
2374
2375> **说明:**
2376>
2377> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9)。
2378
2379**系统能力:** SystemCapability.Account.OsAccount
2380
2381**参数:**
2382
2383| 参数名   | 类型                                     | 必填 | 说明                                                   |
2384| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
2385| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 |
2386
2387**示例:**
2388
2389  ```ts
2390  import { BusinessError } from '@kit.BasicServicesKit';
2391  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2392  accountManager.queryActivatedOsAccountIds((err: BusinessError, idArray: number[])=>{
2393    console.log('queryActivatedOsAccountIds err:' + JSON.stringify(err));
2394    console.log('queryActivatedOsAccountIds idArray length:' + idArray.length);
2395    for(let i=0;i<idArray.length;i++) {
2396      console.info('activated os account id: ' + idArray[i]);
2397    }
2398  });
2399  ```
2400
2401### queryActivatedOsAccountIds<sup>(deprecated)</sup>
2402
2403queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
2404
2405> **说明:**
2406>
2407> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9-1)。
2408
2409查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。
2410
2411**系统能力:** SystemCapability.Account.OsAccount
2412
2413**返回值:**
2414
2415| 类型                               | 说明                                               |
2416| ---------------------------------- | ------------------------------------------------- |
2417| Promise&lt;Array&lt;number&gt;&gt; | Promise对象,返回当前处于激活状态的系统账号的ID列表。 |
2418
2419**示例:**
2420
2421  ```ts
2422  import { BusinessError } from '@kit.BasicServicesKit';
2423  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2424  accountManager.queryActivatedOsAccountIds().then((idArray: number[]) => {
2425    console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
2426  }).catch((err: BusinessError) => {
2427    console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
2428  });
2429  ```
2430
2431### queryCurrentOsAccount<sup>(deprecated)</sup>
2432
2433queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
2434
2435查询当前进程所属的系统账号的信息。使用callback异步回调。
2436
2437> **说明:**
2438>
2439> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2440
2441**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2442
2443**系统能力:** SystemCapability.Account.OsAccount
2444
2445**参数:**
2446
2447| 参数名   | 类型                                                 | 必填 | 说明                                           |
2448| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
2449| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 |
2450
2451**示例:**
2452
2453  ```ts
2454  import { BusinessError } from '@kit.BasicServicesKit';
2455  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2456  accountManager.queryCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
2457    console.log('queryCurrentOsAccount err:' + JSON.stringify(err));
2458    console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
2459  });
2460  ```
2461
2462### queryCurrentOsAccount<sup>(deprecated)</sup>
2463
2464queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
2465
2466查询当前进程所属的系统账号的信息。使用Promise异步回调。
2467
2468> **说明:**
2469>
2470> 从 API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2471
2472**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2473
2474**系统能力:** SystemCapability.Account.OsAccount
2475
2476**返回值:**
2477
2478| 类型                                           | 说明                                       |
2479| ---------------------------------------------- | ------------------------------------------ |
2480| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统账号信息。 |
2481
2482**示例:**
2483
2484  ```ts
2485  import { BusinessError } from '@kit.BasicServicesKit';
2486  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2487  accountManager.queryCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
2488    console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
2489  }).catch((err: BusinessError) => {
2490    console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
2491  });
2492  ```
2493
2494### getOsAccountTypeFromProcess<sup>(deprecated)</sup>
2495
2496getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
2497
2498查询当前进程所属的系统账号的账号类型。使用callback异步回调。
2499
2500> **说明:**
2501>
2502> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9)。
2503
2504**系统能力:** SystemCapability.Account.OsAccount
2505
2506**参数:**
2507
2508| 参数名   | 类型                                                 | 必填 | 说明                                                 |
2509| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
2510| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 |
2511
2512**示例:**
2513
2514  ```ts
2515  import { BusinessError } from '@kit.BasicServicesKit';
2516  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2517  accountManager.getOsAccountTypeFromProcess((err: BusinessError, accountType: osAccount.OsAccountType) => {
2518    console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
2519    console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
2520  });
2521  ```
2522
2523### getOsAccountTypeFromProcess<sup>(deprecated)</sup>
2524
2525getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
2526
2527查询当前进程所属的系统账号的账号类型。使用Promise异步回调。
2528
2529> **说明:**
2530>
2531> 从 API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9-1)。
2532
2533**系统能力:** SystemCapability.Account.OsAccount
2534
2535**返回值:**
2536
2537| 类型                                           | 说明                                            |
2538| ---------------------------------------------- | ----------------------------------------------- |
2539| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise对象,返回当前进程所属的系统账号的账号类型。 |
2540
2541**示例:**
2542
2543  ```ts
2544  import { BusinessError } from '@kit.BasicServicesKit';
2545  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2546  accountManager.getOsAccountTypeFromProcess().then((accountType: osAccount.OsAccountType) => {
2547    console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
2548  }).catch((err: BusinessError) => {
2549    console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
2550  });
2551  ```
2552
2553### getDistributedVirtualDeviceId<sup>(deprecated)</sup>
2554
2555getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
2556
2557获取分布式虚拟设备ID。使用callback异步回调。
2558
2559> **说明:**
2560>
2561> 从 API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9)。
2562
2563**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
2564
2565**系统能力:** SystemCapability.Account.OsAccount
2566
2567**参数:**
2568
2569| 参数名   | 类型                        | 必填 | 说明                                                                    |
2570| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
2571| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
2572
2573**示例:**
2574
2575  ```ts
2576  import { BusinessError } from '@kit.BasicServicesKit';
2577  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2578  accountManager.getDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
2579    console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
2580    console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
2581  });
2582  ```
2583
2584### getDistributedVirtualDeviceId<sup>(deprecated)</sup>
2585
2586getDistributedVirtualDeviceId(): Promise&lt;string&gt;
2587
2588获取分布式虚拟设备ID。使用Promise异步回调。
2589
2590> **说明:**
2591>
2592> 从 API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1)。
2593
2594**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
2595
2596**系统能力:** SystemCapability.Account.OsAccount
2597
2598**返回值:**
2599
2600| 类型                  | 说明                              |
2601| --------------------- | --------------------------------- |
2602| Promise&lt;string&gt; | Promise对象,返回分布式虚拟设备ID。 |
2603
2604**示例:**
2605
2606  ```ts
2607  import { BusinessError } from '@kit.BasicServicesKit';
2608  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2609  accountManager.getDistributedVirtualDeviceId().then((virtualID: string) => {
2610    console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
2611  }).catch((err: BusinessError) => {
2612    console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
2613  });
2614  ```
2615
2616### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup>
2617
2618getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
2619
2620通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。
2621
2622> **说明:**
2623>
2624> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9)。
2625
2626**系统能力:** SystemCapability.Account.OsAccount
2627
2628**参数:**
2629
2630| 参数名       | 类型                        | 必填 | 说明                                                                               |
2631| ------------ | --------------------------- | ---- | -------------------------------------------------------------------------------- |
2632| serialNumber | number                      | 是   | 账号SN码。                                                                        |
2633| callback     | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 |
2634
2635**示例:** 查询与SN码12345关联的系统账号的ID
2636
2637  ```ts
2638  import { BusinessError } from '@kit.BasicServicesKit';
2639  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2640  let serialNumber: number = 12345;
2641  accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
2642    console.log('ger localId err:' + JSON.stringify(err));
2643    console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
2644  });
2645  ```
2646
2647### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup>
2648
2649getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
2650
2651通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。
2652
2653> **说明:**
2654>
2655> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9-1)。
2656
2657**系统能力:** SystemCapability.Account.OsAccount
2658
2659**参数:**
2660
2661| 参数名       | 类型   | 必填 | 说明       |
2662| ------------ | ------ | ---- | ---------- |
2663| serialNumber | number | 是   | 账号SN码。 |
2664
2665**返回值:**
2666
2667| 类型                  | 说明                                                         |
2668| --------------------- | -------------------------------------------- |
2669| Promise&lt;number&gt; | Promise对象,返回与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).then((localId: number) => {
2678    console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
2679  }).catch((err: BusinessError) => {
2680    console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
2681  });
2682  ```
2683
2684### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup>
2685
2686getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
2687
2688通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。
2689
2690> **说明:**
2691>
2692> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9)。
2693
2694**系统能力:** SystemCapability.Account.OsAccount
2695
2696**参数:**
2697
2698| 参数名   | 类型                        | 必填 | 说明                                                                         |
2699| -------- | --------------------------- | ---- | --------------------------------------------------------------------------- |
2700| localId  | number                      | 是   | 系统账号ID。                                                                 |
2701| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 |
2702
2703**示例:** 获取ID为100的系统账号关联的SN码
2704
2705  ```ts
2706  import { BusinessError } from '@kit.BasicServicesKit';
2707  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2708  let localId: number = 100;
2709  accountManager.getSerialNumberByOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
2710    console.log('ger serialNumber err:' + JSON.stringify(err));
2711    console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
2712  });
2713  ```
2714
2715### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup>
2716
2717getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
2718
2719通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。
2720
2721> **说明:**
2722>
2723> 从 API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9-1)。
2724
2725**系统能力:** SystemCapability.Account.OsAccount
2726
2727**参数:**
2728
2729| 参数名  | 类型   | 必填 | 说明          |
2730| ------- | ------ | ---- | ----------- |
2731| localId | number | 是   | 系统账号ID。 |
2732
2733**返回值:**
2734
2735| 类型                  | 说明                                    |
2736| --------------------- | -------------------------------------- |
2737| Promise&lt;number&gt; | Promise对象,返回与该系统账号关联的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).then((serialNumber: number) => {
2746    console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
2747  }).catch((err: BusinessError) => {
2748    console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
2749  });
2750  ```
2751
2752### getOsAccountName<sup>12+</sup>
2753
2754getOsAccountName(): Promise&lt;string&gt;
2755
2756查询调用方所属系统账号的名称。使用Promise异步回调。
2757
2758**系统能力:** SystemCapability.Account.OsAccount
2759
2760**返回值:**
2761
2762| 类型                      | 说明                     |
2763| :------------------------ | ----------------------- |
2764| Promise&lt;string&gt; | Promise对象,返回调用方所属系统账号的名称。 |
2765
2766**错误码:**
2767
2768| 错误码ID | 错误信息                     |
2769| -------- | --------------------------- |
2770| 12300001 | The system service works abnormally. |
2771
2772**示例:**
2773  ```ts
2774  import { BusinessError } from '@kit.BasicServicesKit';
2775  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2776  try {
2777    accountManager.getOsAccountName().then((name: string) => {
2778      console.log('getOsAccountName, name: ' + name);
2779    }).catch((err: BusinessError) => {
2780      console.log('getOsAccountName err: ' + err);
2781    });
2782  } catch (e) {
2783    console.log('getOsAccountName exception: ' + e);
2784  }
2785  ```
2786
2787## OsAccountInfo
2788
2789表示系统账号信息。
2790
2791**系统能力:** SystemCapability.Account.OsAccount
2792
2793| 名称                         | 类型                                                         | 必填 | 说明                              |
2794| ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------- |
2795| localId                        | number                                                       | 是   | 系统账号ID。                      |
2796| localName                      | string                                                       | 是   | 系统账号名称。                    |
2797| type                           | [OsAccountType](#osaccounttype)                              | 是   | 系统账号类型。                      |
2798| constraints                    | Array&lt;string&gt;                                          | 是   | 系统账号[约束](#系统账号约束列表),默认为空。|
2799| isVerified<sup>(deprecated)</sup> | boolean                                                   | 是   | 账号是否验证。<br>**说明**: 从API version 7开始支持,从API version 11开始废弃。                     |
2800| isUnlocked<sup>11+</sup>      | boolean                                                       | 是   | 账号是否已解锁(EL2级别目录是否解密)。                      |
2801| photo<sup>8+</sup>             | string                                                       | 是   | 系统账号头像,默认为空。                      |
2802| createTime<sup>8+</sup>        | number                                                       | 是   | 系统账号创建时间。                  |
2803| lastLoginTime<sup>8+</sup>     | number                                                       | 是   | 系统账号最后一次登录时间,默认为空。          |
2804| serialNumber<sup>8+</sup>      | number                                                       | 是   | 系统账号SN码。                      |
2805| isActived<sup>(deprecated)</sup>         | boolean                                            | 是   | 系统账号激活状态。<br>**说明**: 从API version 7开始支持,从API version 11开始废弃。                  |
2806| isActivated<sup>11+</sup>         | boolean                                                   | 是   | 系统账号激是否激活。                  |
2807| isCreateCompleted<sup>8+</sup> | boolean                                                      | 是   | 系统账号创建是否完整。              |
2808| distributedInfo                | [distributedAccount.DistributedInfo](js-apis-distributed-account.md#distributedinfo) | 是   | 分布式账号信息,默认为空。                    |
2809| domainInfo<sup>8+</sup>        | [DomainAccountInfo](#domainaccountinfo8)                      | 是   | 域账号信息,默认为空。                        |
2810
2811## DomainAccountInfo<sup>8+</sup>
2812
2813表示域账号信息。
2814
2815**系统能力:** SystemCapability.Account.OsAccount
2816
2817| 名称      | 类型   | 必填 | 说明       |
2818| ----------- | ------ | ---- | ---------- |
2819| domain      | string | 是   | 域名。     |
2820| accountName | string | 是   | 域账号名。 |
2821
2822## 系统账号约束列表
2823
2824| 约束                                  | 说明                           |
2825| ------------------------------------- | ------------------------------ |
2826| constraint.wifi                       | 禁止使用Wi-Fi                  |
2827| constraint.wifi.set                   | 禁止配置Wi-Fi                  |
2828| constraint.locale.set                 | 禁止配置设备语言               |
2829| constraint.app.accounts               | 禁止添加和删除应用账号         |
2830| constraint.apps.install               | 禁止安装应用                   |
2831| constraint.apps.uninstall             | 禁止卸载应用                   |
2832| constraint.location.shared            | 禁止打开位置共享               |
2833| constraint.unknown.sources.install    | 禁止安装未知来源的应用         |
2834| constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 |
2835| constraint.bluetooth.set              | 禁止配置蓝牙                   |
2836| constraint.bluetooth | 禁止使用蓝牙 |
2837| constraint.bluetooth.share | 禁止共享使用蓝牙 |
2838| constraint.usb.file.transfer | 禁止通过USB传输文件 |
2839| constraint.credentials.set | 禁止配置用户凭据 |
2840| constraint.os.account.remove | 禁止删除用户 |
2841| constraint.managed.profile.remove | 禁止删除此用户的托管配置文件 |
2842| constraint.debug.features.use | 禁止启用或访问调试功能 |
2843| constraint.vpn.set | 禁止配置VPN |
2844| constraint.date.time.set | 禁止配置日期时间和时区 |
2845| constraint.tethering.config | 禁止配置Tethering |
2846| constraint.network.reset | 禁止重置网络设置 |
2847| constraint.factory.reset | 禁止出厂设置 |
2848| constraint.os.account.create | 禁止创建新用户 |
2849| constraint.add.managed.profile | 禁止添加托管配置文件 |
2850| constraint.apps.verify.disable | 强制应用程序验证 |
2851| constraint.cell.broadcasts.set | 禁止配置小区广播 |
2852| constraint.mobile.networks.set | 禁止配置移动网络 |
2853| constraint.control.apps | 禁止在设置或启动模块中修改应用程序 |
2854| constraint.physical.media | 禁止装载物理外部介质 |
2855| constraint.microphone | 禁止使用麦克风 |
2856| constraint.microphone.unmute | 禁止取消麦克风静音 |
2857| constraint.volume.adjust | 禁止调整音量 |
2858| constraint.calls.outgoing | 禁止拨打外呼电话 |
2859| constraint.sms.use | 禁止发送或接收短信 |
2860| constraint.fun | 禁止享受乐趣 |
2861| constraint.windows.create | 禁止创建应用程序窗口以外的窗口 |
2862| constraint.system.error.dialogs | 禁止显示崩溃或无响应应用程序的系统错误对话框 |
2863| constraint.cross.profile.copy.paste | 禁止通过将数据粘贴到其他用户或配置文件来导出剪贴板内容 |
2864| constraint.beam.outgoing | 禁止使用NFC从应用程序传送数据 |
2865| constraint.wallpaper | 禁止管理壁纸 |
2866| constraint.safe.boot | 禁止进入安全引导模式 |
2867| constraint.parent.profile.app.linking | 禁止父配置文件中的应用程序处理来自托管配置文件的Web链接 |
2868| constraint.audio.record | 禁止录制音频 |
2869| constraint.camera.use | 禁止使用摄像机 |
2870| constraint.os.account.background.run | 禁止在后台运行 |
2871| constraint.data.roam | 禁止漫游通话时使用蜂窝数据 |
2872| constraint.os.account.set.icon | 禁止修改用户头像 |
2873| constraint.wallpaper.set | 禁止设置壁纸 |
2874| constraint.oem.unlock | 禁止启用oem解锁 |
2875| constraint.device.unmute | 禁止取消设备静音 |
2876| constraint.password.unified | 禁止托管配置文件与主用户进行统一锁屏质询 |
2877| constraint.autofill | 禁止使用自动填充服务 |
2878| constraint.content.capture | 禁止捕获用户屏幕 |
2879| constraint.content.suggestions | 禁止接收内容建议 |
2880| constraint.os.account.activate | 禁止前台启动用户 |
2881| constraint.location.set | 禁止配置位置服务 |
2882| constraint.airplane.mode.set | 禁止飞行模式 |
2883| constraint.brightness.set | 禁止配置亮度 |
2884| constraint.share.into.profile | 禁止将主要用户的文件/图片/数据共享到托管配置文件中 |
2885| constraint.ambient.display | 禁止显示环境 |
2886| constraint.screen.timeout.set | 禁止配置屏幕关闭的超时 |
2887| constraint.print | 禁止打印 |
2888| constraint.private.dns.set | 禁止配置专用DNS |
2889