js-apis-osAccount.md 76.5 KB
Newer Older
A
annie_wangli 已提交
1 2
#    OS Account Management

A
Annie_wang 已提交
3 4 5
The osAccount module provides basic capabilities for managing operating system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account, and storing OS account data to disks.

> **NOTE**<br>
A
annie_wangli 已提交
6 7 8 9 10
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.


## Modules to Import

11
```js
A
annie_wangli 已提交
12 13 14 15 16 17 18 19 20
import account_osAccount from '@ohos.account.osAccount';
```

## account_osAccount.getAccountManager

getAccountManager(): AccountManager

Obtains an **AccountManager** instance.

A
annie_wangli 已提交
21
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
22

A
Annie_wang 已提交
23
**Return value**
A
annie_wangli 已提交
24 25 26 27 28
| Type                             | Description                    |
| --------------------------------- | ------------------------ |
| [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.|

**Example**
29
  ```js
A
annie_wangli 已提交
30 31 32 33
  const accountManager = account_osAccount.getAccountManager();
  ```

## OsAccountType
Z
zengyawen 已提交
34

A
annie_wangli 已提交
35
Enumerates OS account types.
A
annie_wangli 已提交
36 37 38 39 40 41 42 43

**System capability**: SystemCapability.Account.OsAccount

| Name  | Default Value| Description        |
| ------ | ------ | ------------ |
| ADMIN  | 0      | Administrator account|
| NORMAL | 1      | Normal account  |
| GUEST  | 2      | Guest account  |
A
annie_wangli 已提交
44 45 46 47 48 49 50 51 52

## AccountManager

Provides methods to manage OS accounts.

### activateOsAccount

activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void

A
Annie_wang 已提交
53
Activates an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
54

A
annie_wangli 已提交
55 56
This is a system API and cannot be called by third-party applications.

Z
zengyawen 已提交
57 58
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION

A
annie_wangli 已提交
59
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
60

A
annie_wangli 已提交
61
**Parameters**
A
annie_wangli 已提交
62

A
annie_wangli 已提交
63 64 65 66 67 68
| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
| localId  | number                    | Yes  | ID of the OS account to activate.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**: Activate OS account 100.
69
  ```js
A
annie_wangli 已提交
70 71 72 73 74 75 76 77 78 79 80
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.activateOsAccount(localId, (err)=>{
    console.log("activateOsAccount err:" + JSON.stringify(err));
  });
  ```

### activateOsAccount

activateOsAccount(localId: number): Promise&lt;void&gt;

A
Annie_wang 已提交
81
Activates an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
82

A
annie_wangli 已提交
83 84
This is a system API and cannot be called by third-party applications.

Z
zhangalong 已提交
85 86
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION

A
annie_wangli 已提交
87
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
88

A
annie_wangli 已提交
89
**Parameters**
A
annie_wangli 已提交
90

A
annie_wangli 已提交
91 92 93
| Name | Type  | Mandatory| Description                |
| ------- | ------ | ---- | -------------------- |
| localId | number | Yes  | ID of the OS account to activate.|
A
annie_wangli 已提交
94

A
Annie_wang 已提交
95
**Return value**
A
annie_wangli 已提交
96

A
annie_wangli 已提交
97 98 99 100 101
| Type               | Description                               |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|

**Example**: Activate OS account 100.
102
  ```js
A
annie_wangli 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.activateOsAccount(localId).then(() => {
    console.log("activateOsAccount success");
  }).catch((err) => {
    console.log("activateOsAccount err:" + JSON.stringify(err));
  });
  ```

### isMultiOsAccountEnable

isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
116
Checks whether multiple OS accounts are supported. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
117

A
annie_wangli 已提交
118 119 120
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
121

A
annie_wangli 已提交
122 123 124
| Name  | Type                        | Mandatory| Description                                               |
| -------- | ---------------------------- | ---- | --------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
A
annie_wangli 已提交
125

A
annie_wangli 已提交
126
**Example**
A
annie_wangli 已提交
127

128
  ```js
A
annie_wangli 已提交
129 130 131 132 133 134 135 136 137 138 139
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isMultiOsAccountEnable((err, isEnabled) => {
    console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
    console.log('isMultiOsAccountEnable isEnabled: ' + isEnabled);
  });
  ```

### isMultiOsAccountEnable

isMultiOsAccountEnable(): Promise&lt;boolean&gt;

A
Annie_wang 已提交
140
Checks whether multiple OS accounts are supported. This API uses a promise to return the result.
A
annie_wangli 已提交
141

A
annie_wangli 已提交
142
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
143

A
Annie_wang 已提交
144
**Return value**
A
annie_wangli 已提交
145

A
annie_wangli 已提交
146 147 148 149 150
| Type                  | Description                                                        |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|

**Example**
A
annie_wangli 已提交
151

152
  ```js
A
annie_wangli 已提交
153 154 155 156 157 158 159 160 161 162 163 164
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isMultiOsAccountEnable().then((isEnabled) => {
    console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
  }).catch((err) => {
    console.log("isMultiOsAccountEnable err: "  + JSON.stringify(err));
  });
  ```

### isOsAccountActived

isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
165
Checks whether an OS account is activated. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
166

Z
zhangalong 已提交
167
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
A
annie_wangli 已提交
168 169

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
170

A
annie_wangli 已提交
171
**Parameters**
A
annie_wangli 已提交
172

A
annie_wangli 已提交
173 174 175 176 177 178
| Name  | Type                        | Mandatory| Description                                             |
| -------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId  | number                       | Yes  | ID of the target OS account.                                     |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|

**Example**: Check whether OS account 100 is activated.
A
annie_wangli 已提交
179

180
  ```js
A
annie_wangli 已提交
181 182 183 184 185 186 187 188 189 190 191 192
  const accountManager = account_osAccount.getAccountManager();
  var osLocalId = 100;
  accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
    console.log("isOsAccountActived err:" + JSON.stringify(err));
    console.log("isOsAccountActived isActive:" + isActive);
  });
  ```

### isOsAccountActived

isOsAccountActived(localId: number): Promise&lt;boolean&gt;

A
Annie_wang 已提交
193
Checks whether an OS account is activated. This API uses a promise to return the result.
A
annie_wangli 已提交
194

Z
zhangalong 已提交
195
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
A
annie_wangli 已提交
196 197

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
198

A
annie_wangli 已提交
199
**Parameters**
A
annie_wangli 已提交
200

A
annie_wangli 已提交
201 202 203
| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes  | ID of the target OS account.|
A
annie_wangli 已提交
204

A
Annie_wang 已提交
205
**Return value**
A
annie_wangli 已提交
206

A
annie_wangli 已提交
207 208 209 210 211
| Type                  | Description                                                        |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|

**Example**: Check whether OS account 100 is activated.
A
annie_wangli 已提交
212

213
  ```js
A
annie_wangli 已提交
214 215 216 217 218 219 220 221 222 223 224 225 226
  const accountManager = account_osAccount.getAccountManager();
  var osLocalId = 100;
  accountManager.isOsAccountActived(osLocalId).then((isActive) => {
    console.log('isOsAccountActived, isActive: ' + isActive);
  }).catch((err) => {
    console.log("isOsAccountActived err: "  + JSON.stringify(err));
  });
  ```

### isOsAccountConstraintEnable

isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
227
Checks whether the specified constraint is enabled for an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
228

A
annie_wangli 已提交
229 230 231
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
232

A
annie_wangli 已提交
233
**Parameters**
A
annie_wangli 已提交
234

A
annie_wangli 已提交
235 236 237 238 239 240
| Name    | Type                        | Mandatory| Description                                             |
| ---------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId    | number                       | Yes  | ID of the target OS account.                               |
| constraint | string                       | Yes  | [Constraint](#constraints) specified.            |
| callback   | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|

241
**Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
A
annie_wangli 已提交
242

243
  ```js
A
annie_wangli 已提交
244 245 246 247 248 249 250 251 252 253 254 255
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{
    console.log("isOsAccountConstraintEnable err:" + JSON.stringify(err));
    console.log("isOsAccountConstraintEnable isConstraintEnabled:" + isConstraintEnabled);
  });
  ```

### isOsAccountConstraintEnable

isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boolean&gt;

A
Annie_wang 已提交
256
Checks whether the specified constraint is enabled for an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
257

A
annie_wangli 已提交
258 259 260
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
261

A
annie_wangli 已提交
262
**Parameters**
A
annie_wangli 已提交
263

A
annie_wangli 已提交
264 265 266 267
| Name    | Type  | Mandatory| Description                                 |
| ---------- | ------ | ---- | ------------------------------------- |
| localId    | number | Yes  | ID of the target OS account.                   |
| constraint | string | Yes  | [Constraint](#constraints) specified.|
A
annie_wangli 已提交
268

A
Annie_wang 已提交
269
**Return value**
A
annie_wangli 已提交
270

A
annie_wangli 已提交
271 272 273 274
| Type                  | Description                                                        |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|

275
**Example**: Check whether OS account 100 is forbidden to use Wi-Fi.
A
annie_wangli 已提交
276

277
  ```js
A
annie_wangli 已提交
278 279 280 281 282 283 284 285 286 287 288 289 290
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => {
    console.log('isOsAccountConstraintEnable, isConstraintEnabled: ' + isConstraintEnabled);
  }).catch((err) => {
    console.log("isOsAccountConstraintEnable err: "  + JSON.stringify(err));
  });
  ```

### isTestOsAccount

isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
291
Checks whether this OS account is a test account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
292

A
annie_wangli 已提交
293 294 295
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
296

A
annie_wangli 已提交
297 298 299
| Name  | Type                        | Mandatory| Description                                           |
| -------- | ---------------------------- | ---- | ----------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
A
annie_wangli 已提交
300

A
annie_wangli 已提交
301
**Example**
A
annie_wangli 已提交
302

303
  ```js
A
annie_wangli 已提交
304 305 306 307 308 309 310 311 312 313 314
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isTestOsAccount((err, isTest) => {
    console.log("isTestOsAccount err: " + JSON.stringify(err));
    console.log('isTestOsAccount isTest: ' + isTest);
  });
  ```

### isTestOsAccount

isTestOsAccount(): Promise&lt;boolean&gt;

A
Annie_wang 已提交
315
Checks whether this OS account is a test account. This API uses a promise to return the result.
A
annie_wangli 已提交
316

A
annie_wangli 已提交
317
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
318

A
Annie_wang 已提交
319
**Return value**
A
annie_wangli 已提交
320

A
annie_wangli 已提交
321 322 323 324 325
| Type                  | Description                                                        |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|

**Example**
A
annie_wangli 已提交
326

327
  ```js
A
annie_wangli 已提交
328 329 330 331 332 333 334 335 336 337 338 339
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isTestOsAccount().then((isTest) => {
    console.log('isTestOsAccount, isTest: ' + isTest);
  }).catch((err) => {
    console.log("isTestOsAccount err: "  + JSON.stringify(err));
  });
  ```

### isOsAccountVerified

isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
340
Checks whether this OS account has been verified. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
341

A
annie_wangli 已提交
342 343 344
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
345

A
annie_wangli 已提交
346 347 348
| Name  | Type                        | Mandatory| Description                                       |
| -------- | ---------------------------- | ---- | ------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
A
annie_wangli 已提交
349

A
annie_wangli 已提交
350
**Example**
A
annie_wangli 已提交
351

352
  ```js
A
annie_wangli 已提交
353 354 355 356 357 358 359 360 361 362 363
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isOsAccountVerified((err, isVerified) => {
    console.log("isOsAccountVerified err: " + JSON.stringify(err));
    console.log('isOsAccountVerified isVerified: ' + isVerified);
  });
  ```

### isOsAccountVerified

isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void

A
Annie_wang 已提交
364
Checks whether an OS account has been verified. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
365

Z
zhangalong 已提交
366 367
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS

A
annie_wangli 已提交
368
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
369

A
annie_wangli 已提交
370
**Parameters**
A
annie_wangli 已提交
371

A
annie_wangli 已提交
372 373 374 375 376 377
| Name  | Type                        | Mandatory| Description                                       |
| -------- | ---------------------------- | ---- | ------------------------------------------- |
| localId  | number                       | No  | ID of the target OS account.                         |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|

**Example**
A
annie_wangli 已提交
378

379
  ```js
A
annie_wangli 已提交
380 381 382 383 384 385 386 387 388
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isOsAccountVerified((err, isVerified) => {
    console.log("isOsAccountVerified err: " + JSON.stringify(err));
    console.log('isOsAccountVerified isVerified: ' + isVerified);
  });
  ```

### isOsAccountVerified

A
annie_wangli 已提交
389
isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
A
annie_wangli 已提交
390

A
Annie_wang 已提交
391
Checks whether an OS account has been verified. This API uses a promise to return the result.
A
annie_wangli 已提交
392

Z
zhangalong 已提交
393 394
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS

A
annie_wangli 已提交
395 396 397
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
398

A
annie_wangli 已提交
399 400 401
| Name | Type  | Mandatory| Description              |
| ------- | ------ | ---- | ------------------ |
| localId | number | No  | ID of the target OS account.|
A
annie_wangli 已提交
402

A
Annie_wang 已提交
403
**Return value**
A
annie_wangli 已提交
404

A
annie_wangli 已提交
405 406 407
| Type                  | Description                                                        |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
A
annie_wangli 已提交
408

A
annie_wangli 已提交
409
**Example**
A
annie_wangli 已提交
410

411
  ```js
A
annie_wangli 已提交
412 413 414 415 416 417 418 419 420 421 422 423
  const accountManager = account_osAccount.getAccountManager();
  accountManager.isOsAccountVerified().then((isVerified) => {
    console.log('isOsAccountVerified, isVerified: ' + isVerified);
  }).catch((err) => {
    console.log("isOsAccountVerified err: "  + JSON.stringify(err));
  });
  ```

### removeOsAccount

removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void

A
Annie_wang 已提交
424
Removes an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
425

A
annie_wangli 已提交
426
This is a system API and cannot be called by third-party applications.
A
annie_wangli 已提交
427

A
annie_wangli 已提交
428
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
429

A
annie_wangli 已提交
430 431 432 433 434 435 436 437 438 439
**System capability**: SystemCapability.Account.OsAccount

**Parameters**

| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
| localId  | number                    | Yes  | ID of the OS account to remove.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**
A
annie_wangli 已提交
440

441
  ```js
A
annie_wangli 已提交
442 443 444 445
  const accountManager = account_osAccount.getAccountManager();
  var createIocalId;
  osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
    createIocalId = osAccountInfo.localId;
A
annie_wangli 已提交
446
  });
A
annie_wangli 已提交
447 448 449 450 451 452 453 454 455
  accountManager.removeOsAccount(createIocalId, (err)=>{
    console.log("removeOsAccount err:" + JSON.stringify(err));
  });
  ```

### removeOsAccount

removeOsAccount(localId: number): Promise&lt;void&gt;

A
Annie_wang 已提交
456
Removes an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
457

A
annie_wangli 已提交
458 459 460 461 462 463 464
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
465

A
annie_wangli 已提交
466 467 468
| Name | Type  | Mandatory| Description                |
| ------- | ------ | ---- | -------------------- |
| localId | number | Yes  | ID of the OS account to remove.|
A
annie_wangli 已提交
469

A
Annie_wang 已提交
470
**Return value**
A
annie_wangli 已提交
471

A
annie_wangli 已提交
472 473 474
| Type               | Description                               |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
A
annie_wangli 已提交
475

A
annie_wangli 已提交
476
**Example**
A
annie_wangli 已提交
477

478
  ```js
A
annie_wangli 已提交
479 480 481 482
  const accountManager = account_osAccount.getAccountManager();
  var createIocalId;
  osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
    createIocalId = osAccountInfo.localId;
A
annie_wangli 已提交
483
  });
A
annie_wangli 已提交
484 485 486 487 488 489 490 491 492 493 494 495
  createIocalId = osAccount.localId;
  accountManager.removeOsAccount(createIocalId).then(() => {
    console.log('removeOsAccount Success');
  }).catch(() => {
    console.log("removeOsAccount err: "  + JSON.stringify(err));
  });
  ```

### setOsAccountConstraints

setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void

A
Annie_wang 已提交
496
Sets or removes constraints for an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
497 498 499 500 501 502

This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
503

A
annie_wangli 已提交
504
**Parameters**
A
annie_wangli 已提交
505

A
annie_wangli 已提交
506 507 508 509 510 511
| Name     | Type                     | Mandatory| Description                                        |
| ----------- | ------------------------- | ---- | -------------------------------------------- |
| localId     | number                    | Yes  | ID of the target OS account.                                |
| constraints | Array&lt;string&gt;       | Yes  | List of [constraints](#constraints) to set or remove.|
| enable      | boolean                   | Yes  | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.                      |
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                  |
A
annie_wangli 已提交
512

513
**Example**: Disable Wi-Fi for OS account 100.
A
annie_wangli 已提交
514

515
  ```js
A
annie_wangli 已提交
516 517 518 519 520 521 522 523 524 525 526
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{
    console.log("setOsAccountConstraints err:" + JSON.stringify(err));
  });
  ```

### setOsAccountConstraints

setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;

A
Annie_wang 已提交
527
Sets or removes constraints for an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
528

A
annie_wangli 已提交
529
This is a system API and cannot be called by third-party applications.
A
annie_wangli 已提交
530

A
annie_wangli 已提交
531
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
532

A
annie_wangli 已提交
533
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
534

A
annie_wangli 已提交
535
**Parameters**
A
annie_wangli 已提交
536

A
annie_wangli 已提交
537 538 539 540 541 542
| Name     | Type               | Mandatory| Description                                        |
| ----------- | ------------------- | ---- | -------------------------------------------- |
| localId     | number              | Yes  | ID of the target OS account.                                |
| constraints | Array&lt;string&gt; | Yes  | List of [constraints](#constraints) to set or remove.|
| enable      | boolean             | Yes  | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.                    |

A
Annie_wang 已提交
543
**Return value**
A
annie_wangli 已提交
544 545 546 547 548 549

| Type               | Description                               |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|

**Example**: Remote the constraint on the use of Wi-Fi for OS account 100.
A
annie_wangli 已提交
550

551
  ```js
A
annie_wangli 已提交
552 553 554 555 556 557 558 559 560 561 562 563 564
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => {
    console.log('setOsAccountConstraints Success');
  }).catch((err) => {
    console.log("setOsAccountConstraints err: "  + JSON.stringify(err));
  });
  ```

### setOsAccountName

setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;void&gt;): void

A
Annie_wang 已提交
565
Sets a name for an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
566

A
annie_wangli 已提交
567 568
This is a system API and cannot be called by third-party applications.

Z
zhangalong 已提交
569 570
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

A
annie_wangli 已提交
571
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
572

A
annie_wangli 已提交
573
**Parameters**
A
annie_wangli 已提交
574

A
annie_wangli 已提交
575 576 577 578 579 580 581
| Name   | Type                     | Mandatory| Description        |
| :-------- | ------------------------- | ---- | ------------ |
| localId   | number                    | Yes  | ID of the target OS account.|
| localName | string                    | Yes  | Account name to set.    |
| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |

**Example**: Set the name of OS account 100 to **demoName**.
A
annie_wangli 已提交
582

583
  ```js
A
annie_wangli 已提交
584 585 586 587 588 589 590 591 592 593 594 595
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  var newName = "demoName";
  accountManager.setOsAccountName(localId, newName, (err)=>{
    console.debug("setOsAccountName err:" + JSON.stringify(err));
  });
  ```

### setOsAccountName

setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;

A
Annie_wang 已提交
596
Sets a name for an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
597

A
annie_wangli 已提交
598 599
This is a system API and cannot be called by third-party applications.

Z
zhangalong 已提交
600 601
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

A
annie_wangli 已提交
602
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
603

A
annie_wangli 已提交
604
**Parameters**
A
annie_wangli 已提交
605

A
annie_wangli 已提交
606 607 608 609
| Name   | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ------------ |
| localId   | number | Yes  | ID of the target OS account.|
| localName | string | Yes  | Account name to set.    |
A
annie_wangli 已提交
610

A
Annie_wang 已提交
611
**Return value**
A
annie_wangli 已提交
612

A
annie_wangli 已提交
613 614 615 616 617
| Type               | Description                               |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|

**Example**: Set the name of OS account 100 to **demoName**.
A
annie_wangli 已提交
618

619
  ```js
A
annie_wangli 已提交
620 621 622 623 624 625 626 627 628 629 630 631 632 633
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  var nameLimit = "demoName";
  accountManager.setOsAccountName(localId, nameLimit).then(() => {
    console.log('setOsAccountName Success');
  }).catch((err) => {
    console.log("setOsAccountName err: "  + JSON.stringify(err));
  });
  ```

### getCreatedOsAccountsCount

getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
634
Obtains the number of OS accounts created. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
635

A
annie_wangli 已提交
636 637 638
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
639

A
annie_wangli 已提交
640
**Parameters**
A
annie_wangli 已提交
641

A
annie_wangli 已提交
642 643 644 645 646
| Name  | Type                       | Mandatory| Description                                      |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the number of OS accounts created.|

**Example**
A
annie_wangli 已提交
647

648
  ```js
A
annie_wangli 已提交
649 650 651 652 653 654 655 656 657 658 659
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
    console.log("obtains the number of all os accounts created err:" + JSON.stringify(err));
    console.log("obtains the number of all os accounts created accountCnt:" + accountCnt);
  });
  ```

### getCreatedOsAccountsCount

getCreatedOsAccountsCount(): Promise&lt;number&gt;

A
Annie_wang 已提交
660
Obtains the number of OS accounts created. This API uses a promise to return the result.
A
annie_wangli 已提交
661

A
annie_wangli 已提交
662 663 664 665
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

A
Annie_wang 已提交
666
**Return value**
A
annie_wangli 已提交
667

A
annie_wangli 已提交
668 669 670
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of OS accounts created.|
A
annie_wangli 已提交
671

A
annie_wangli 已提交
672
**Example**
A
annie_wangli 已提交
673

674
  ```js
A
annie_wangli 已提交
675 676 677 678 679 680 681 682 683 684 685 686
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
    console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
  }).catch((err) => {
    console.log("getCreatedOsAccountsCount err: "  + JSON.stringify(err));
  });
  ```

### getOsAccountLocalIdFromProcess

getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
687
Obtains the ID of the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
688

A
annie_wangli 已提交
689
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
690

A
annie_wangli 已提交
691
**Parameters**
A
annie_wangli 已提交
692

A
annie_wangli 已提交
693 694 695 696 697
| Name  | Type                       | Mandatory| Description                                              |
| -------- | --------------------------- | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the account ID obtained.|

**Example**
A
annie_wangli 已提交
698

699
  ```js
A
annie_wangli 已提交
700 701 702 703 704 705 706 707 708 709 710
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
    console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
    console.log('getOsAccountLocalIdFromProcess accountID: ' + accountID);
  });
  ```

### getOsAccountLocalIdFromProcess

getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;

A
Annie_wang 已提交
711
Obtains the ID of the OS account to which the current process belongs. This API uses a promise to return the result.
A
annie_wangli 已提交
712

A
annie_wangli 已提交
713 714
**System capability**: SystemCapability.Account.OsAccount

A
Annie_wang 已提交
715
**Return value**
A
annie_wangli 已提交
716

A
annie_wangli 已提交
717 718 719
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account ID obtained.|
A
annie_wangli 已提交
720

A
annie_wangli 已提交
721
**Example**
A
annie_wangli 已提交
722

723
  ```js
A
annie_wangli 已提交
724 725 726 727 728 729 730 731 732 733 734 735
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
    console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
  }).catch((err) => {
    console.log("getOsAccountLocalIdFromProcess err: "  + JSON.stringify(err));
  });
  ```

### getOsAccountLocalIdFromUid

getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
736
Obtains the OS account ID based on the process UID. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
737

A
annie_wangli 已提交
738
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
739

A
annie_wangli 已提交
740
**Parameters**
A
annie_wangli 已提交
741

A
annie_wangli 已提交
742 743 744 745 746 747
| Name  | Type                       | Mandatory| Description                                         |
| -------- | --------------------------- | ---- | --------------------------------------------- |
| uid      | number                      | Yes  | Process UID.                                    |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the OS account ID obtained.|

**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
A
annie_wangli 已提交
748

749
  ```js
A
annie_wangli 已提交
750 751 752 753 754 755 756 757 758 759 760 761
  const accountManager = account_osAccount.getAccountManager();
  let uid = 12345678;
  accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
    console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err));
    console.log('getOsAccountLocalIdFromUid: ' + accountID);
  });
  ```

### getOsAccountLocalIdFromUid

getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;

A
Annie_wang 已提交
762
Obtains the OS account ID based on the process UID. This API uses a promise to return the result.
A
annie_wangli 已提交
763

A
annie_wangli 已提交
764 765 766
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
767

A
annie_wangli 已提交
768 769 770
| Name| Type  | Mandatory| Description     |
| ------ | ------ | ---- | --------- |
| uid    | number | Yes  | Process UID.|
A
annie_wangli 已提交
771

A
Annie_wang 已提交
772
**Return value**
A
annie_wangli 已提交
773

A
annie_wangli 已提交
774 775 776
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
A
annie_wangli 已提交
777

A
annie_wangli 已提交
778
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
A
annie_wangli 已提交
779

780
  ```js
A
annie_wangli 已提交
781 782 783 784 785 786 787 788 789
  const accountManager = account_osAccount.getAccountManager();
  let uid = 12345678;
  accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
    console.log('getOsAccountLocalIdFromUid: ' + accountID);
  }).catch((err) => {
    console.log("getOsAccountLocalIdFromUid err: "  + JSON.stringify(err));
  });
  ```

A
annie_wangli 已提交
790
### getOsAccountLocalIdFromDomain<sup>8+</sup>
A
annie_wangli 已提交
791 792 793

getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
794
Obtains the OS account ID based on domain account information. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
795

A
annie_wangli 已提交
796
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
797

A
annie_wangli 已提交
798
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
799

A
annie_wangli 已提交
800 801 802 803 804 805 806 807
**Parameters**

| Name    | Type                                   | Mandatory| Description                                        |
| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes  | Domain account information.                                |
| callback   | AsyncCallback&lt;number&gt;             | Yes  | Callback used to return the ID of the OS account associated with the domain account.|

**Example**
A
annie_wangli 已提交
808

809
  ```js
A
annie_wangli 已提交
810 811 812 813 814 815 816 817
  var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
    console.log("getOsAccountLocalIdFromDomain: " + JSON.stringify(err));
    console.log('getOsAccountLocalIdFromDomain: ' + accountID);
  });
  ```

A
annie_wangli 已提交
818
### getOsAccountLocalIdFromDomain<sup>8+</sup>
A
annie_wangli 已提交
819 820 821

getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;

A
Annie_wang 已提交
822
Obtains the OS account ID based on domain account information. This API uses a promise to return the result.
A
annie_wangli 已提交
823

A
annie_wangli 已提交
824 825 826 827 828
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
829

A
annie_wangli 已提交
830 831 832
| Name    | Type                                   | Mandatory| Description        |
| ---------- | --------------------------------------- | ---- | ------------ |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes  | Domain account information.|
A
annie_wangli 已提交
833

A
Annie_wang 已提交
834
**Return value**
A
annie_wangli 已提交
835

A
annie_wangli 已提交
836 837 838
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the ID of the OS account associated with the domain account.|
A
annie_wangli 已提交
839

A
annie_wangli 已提交
840
**Example**
A
annie_wangli 已提交
841

842
  ```js
A
annie_wangli 已提交
843 844 845 846 847 848 849 850 851 852 853 854 855
  const accountManager = account_osAccount.getAccountManager();
  var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
  accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
    console.log('getOsAccountLocalIdFromDomain: ' + accountID);
  }).catch((err) => {
    console.log("getOsAccountLocalIdFromDomain err: "  + JSON.stringify(err));
  });
  ```

### queryMaxOsAccountNumber

queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
856
Obtains the maximum number of OS accounts that can be created. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
857

A
annie_wangli 已提交
858
This is a system API and cannot be called by third-party applications.
A
annie_wangli 已提交
859

A
annie_wangli 已提交
860
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
861

A
annie_wangli 已提交
862 863 864 865 866 867 868
**Parameters**

| Name  | Type                       | Mandatory| Description                                            |
| -------- | --------------------------- | ---- | ------------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the maximum number of OS accounts that can be created.|

**Example**
A
annie_wangli 已提交
869

870
  ```js
A
annie_wangli 已提交
871 872 873 874 875 876 877 878 879 880 881
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
    console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err));
    console.log("queryMaxOsAccountNumber maxCnt:" + maxCnt);
  });
  ```

### queryMaxOsAccountNumber

queryMaxOsAccountNumber(): Promise&lt;number&gt;

A
Annie_wang 已提交
882
Obtains the maximum number of OS accounts that can be created. This API uses a promise to return the result.
A
annie_wangli 已提交
883

A
annie_wangli 已提交
884 885 886 887
This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.Account.OsAccount

A
Annie_wang 已提交
888
**Return value**
A
annie_wangli 已提交
889

A
annie_wangli 已提交
890 891 892
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the maximum number of OS accounts that can be created.|
A
annie_wangli 已提交
893

A
annie_wangli 已提交
894
**Example**
A
annie_wangli 已提交
895

896
  ```js
A
annie_wangli 已提交
897 898 899 900 901 902 903 904 905 906 907 908
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
    console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
  }).catch((err) => {
    console.log("queryMaxOsAccountNumber err: "  + JSON.stringify(err));
  });
  ```

### getOsAccountAllConstraints

getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void

A
Annie_wang 已提交
909
Obtains all constraints enabled for an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
910

A
annie_wangli 已提交
911
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
912

A
annie_wangli 已提交
913
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
914

A
annie_wangli 已提交
915 916 917 918 919 920 921
**Parameters**

| Name  | Type                                    | Mandatory| Description                                                        |
| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ |
| localId  | number                                   | Yes  | ID of the target OS account.                                                |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes  | Callback used to return all [constraints](#constraints) obtained.|

922
**Example**: Obtain all constraints of OS account 100.
A
annie_wangli 已提交
923

924
  ```js
A
annie_wangli 已提交
925 926 927 928 929 930 931 932 933 934 935 936
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
    console.log("getOsAccountAllConstraints err:" + JSON.stringify(err));
    console.log("getOsAccountAllConstraints:" + JSON.stringify(constraints));
  });
  ```

### getOsAccountAllConstraints

getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;

A
Annie_wang 已提交
937
Obtains all constraints enabled for an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
938 939

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
940

A
annie_wangli 已提交
941
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
942

A
annie_wangli 已提交
943
**Parameters**
A
annie_wangli 已提交
944

A
annie_wangli 已提交
945 946 947
| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes  | ID of the target OS account.|
A
annie_wangli 已提交
948

A
Annie_wang 已提交
949
**Return value**
A
annie_wangli 已提交
950

A
annie_wangli 已提交
951 952 953 954
| Type                              | Description                                                        |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the [constraints](#constraints) obtained.|

955
**Example**: Obtain all constraints of OS account 100.
A
annie_wangli 已提交
956

957
  ```js
A
annie_wangli 已提交
958 959 960 961 962 963 964 965 966 967 968 969 970
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
    console.log("getOsAccountAllConstraints, constraints: " + constraints);
  }).catch((err) => {
    console.log("getOsAccountAllConstraints err: "  + JSON.stringify(err));
  });
  ```

### queryAllCreatedOsAccounts

queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&gt;): void

A
Annie_wang 已提交
971
Obtains information about all the OS accounts created. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
972

A
annie_wangli 已提交
973 974 975
This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
976

A
Annie_wang 已提交
977 978
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

A
annie_wangli 已提交
979
**Parameters**
A
annie_wangli 已提交
980

A
annie_wangli 已提交
981 982 983 984 985
| Name  | Type                                                        | Mandatory| Description                                              |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Yes  | Callback used to return information about OS accounts created.|

**Example**
A
annie_wangli 已提交
986

987
  ```js
A
annie_wangli 已提交
988 989 990 991 992 993 994 995 996 997 998
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
    console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err));
    console.log("queryAllCreatedOsAccounts accountArr:" + JSON.stringify(accountArr));
  });
  ```

### queryAllCreatedOsAccounts

queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;

A
Annie_wang 已提交
999
Obtains information about all the OS accounts created. This API uses a promise to return the result.
A
annie_wangli 已提交
1000

A
annie_wangli 已提交
1001 1002 1003
This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1004

A
Annie_wang 已提交
1005 1006 1007
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**Return value**
A
annie_wangli 已提交
1008

A
annie_wangli 已提交
1009 1010 1011 1012 1013
| Type                                                       | Description                                                        |
| :---------------------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise used to return information about OS accounts created.|

**Example**
A
annie_wangli 已提交
1014

1015
  ```js
A
annie_wangli 已提交
1016 1017 1018 1019 1020 1021 1022 1023
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
    console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
  }).catch((err) => {
    console.log("queryAllCreatedOsAccounts err: "  + JSON.stringify(err));
  });
  ```

A
annie_wangli 已提交
1024
### queryActivatedOsAccountIds<sup>8+</sup>
A
annie_wangli 已提交
1025 1026 1027

queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

A
Annie_wang 已提交
1028
Obtains information about all activated OS accounts. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1029

A
annie_wangli 已提交
1030 1031 1032
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1033

A
annie_wangli 已提交
1034 1035 1036
| Name  | Type                                    | Mandatory| Description                                                  |
| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return information about activated OS accounts.|
A
annie_wangli 已提交
1037

A
annie_wangli 已提交
1038
**Example**
A
annie_wangli 已提交
1039

1040
  ```js
A
annie_wangli 已提交
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryActivatedOsAccountIds((err, idArray)=>{
    console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err));
    console.log("queryActivatedOsAccountIds idArray length:" + idArray.length);
    for(var i=0;i<idArray.length;i++) {
      console.info("activated os account id: " + idArray[i]);
    }
  });
  ```

A
annie_wangli 已提交
1051
### queryActivatedOsAccountIds<sup>8+</sup>
A
annie_wangli 已提交
1052 1053 1054

queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;

A
Annie_wang 已提交
1055
Obtains information about all activated OS accounts. This API uses a promise to return the result.
A
annie_wangli 已提交
1056

A
annie_wangli 已提交
1057
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1058

A
Annie_wang 已提交
1059
**Return value**
A
annie_wangli 已提交
1060

A
annie_wangli 已提交
1061 1062 1063 1064 1065
| Type                              | Description                                                        |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return information about activated OS accounts.|

**Example**
A
annie_wangli 已提交
1066

1067
  ```js
A
annie_wangli 已提交
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryActivatedOsAccountIds().then((idArray) => {
    console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
  }).catch((err) => {
    console.log("queryActivatedOsAccountIds err: "  + JSON.stringify(err));
  });
  ```

### createOsAccount

createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&lt;OsAccountInfo&gt;): void

A
Annie_wang 已提交
1080
Creates an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1081

A
annie_wangli 已提交
1082 1083 1084
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1085

A
annie_wangli 已提交
1086
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1087

A
annie_wangli 已提交
1088 1089 1090 1091 1092 1093 1094 1095 1096
**Parameters**

| Name   | Type                                                | Mandatory| Description                                      |
| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| localName | string                                               | Yes  | Name of the OS account to create.                    |
| type      | [OsAccountType](#osaccounttype)                      | Yes  | Type of the OS account to create.                    |
| callback  | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes  | Callback used to return the OS account created.|

**Example**
A
annie_wangli 已提交
1097

1098
  ```js
A
annie_wangli 已提交
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
  const accountManager = account_osAccount.getAccountManager();
  accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
    console.log("createOsAccount err:" + JSON.stringify(err));
    console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
  });
  ```

### createOsAccount

createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInfo&gt;

A
Annie_wang 已提交
1110
Creates an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
1111

A
annie_wangli 已提交
1112 1113 1114 1115 1116
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1117

A
annie_wangli 已提交
1118
**Parameters**
A
annie_wangli 已提交
1119

A
annie_wangli 已提交
1120 1121 1122 1123
| Name   | Type                           | Mandatory| Description                  |
| --------- | ------------------------------- | ---- | ---------------------- |
| localName | string                          | Yes  | Name of the OS account to create.|
| type      | [OsAccountType](#osaccounttype) | Yes  | Type of the OS account to create.|
A
annie_wangli 已提交
1124

A
Annie_wang 已提交
1125
**Return value**
A
annie_wangli 已提交
1126

A
annie_wangli 已提交
1127 1128 1129 1130 1131
| Type                                          | Description                                                        |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|

**Example**
A
annie_wangli 已提交
1132

1133
  ```js
A
annie_wangli 已提交
1134 1135 1136 1137 1138 1139 1140 1141
  const accountManager = account_osAccount.getAccountManager();
  accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => {
    console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
  }).catch((err) => {
    console.log("createOsAccount err: "  + JSON.stringify(err));
  });
  ```

A
annie_wangli 已提交
1142
### createOsAccountForDomain<sup>8+</sup>
A
annie_wangli 已提交
1143 1144 1145

createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void

A
Annie_wang 已提交
1146
Creates an OS account and associates it with the specified domain account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1147

A
annie_wangli 已提交
1148 1149 1150 1151 1152
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1153

A
annie_wangli 已提交
1154
**Parameters**
A
annie_wangli 已提交
1155

A
annie_wangli 已提交
1156 1157 1158 1159 1160 1161 1162
| Name    | Type                                                | Mandatory| Description                                      |
| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| type       | [OsAccountType](#osaccounttype)                      | Yes  | Type of the OS account to create.                    |
| domainInfo | [DomainAccountInfo](#domainaccountinfo)              | Yes  | Domain account information.                              |
| callback   | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes  | Callback used to return the OS account created.|

**Example**
A
annie_wangli 已提交
1163

1164
  ```js
A
annie_wangli 已提交
1165 1166 1167 1168 1169 1170 1171 1172
  const accountManager = account_osAccount.getAccountManager();
  var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
  accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
    console.log("createOsAccountForDomain err:" + JSON.stringify(err));
    console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo));
  });
  ```

A
annie_wangli 已提交
1173
### createOsAccountForDomain<sup>8+</sup>
A
annie_wangli 已提交
1174 1175 1176

createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;

A
Annie_wang 已提交
1177
Creates an OS account and associates it with the specified domain account. This API uses a promise to return the result.
A
annie_wangli 已提交
1178

A
annie_wangli 已提交
1179 1180 1181 1182 1183 1184 1185
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1186

A
annie_wangli 已提交
1187 1188 1189 1190
| Name    | Type                                   | Mandatory| Description                  |
| ---------- | --------------------------------------- | ---- | ---------------------- |
| type       | [OsAccountType](#osaccounttype)         | Yes  | Type of the OS account to create.|
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes  | Domain account information.          |
A
annie_wangli 已提交
1191

A
Annie_wang 已提交
1192
**Return value**
A
annie_wangli 已提交
1193

A
annie_wangli 已提交
1194 1195 1196
| Type                                          | Description                                                        |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
A
annie_wangli 已提交
1197

A
annie_wangli 已提交
1198
**Example**
A
annie_wangli 已提交
1199

1200
  ```js
A
annie_wangli 已提交
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
  const accountManager = account_osAccount.getAccountManager();
  var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
  accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
    console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo));
  }).catch((err) => {
    console.log("createOsAccountForDomain err: "  + JSON.stringify(err));
  });
  ```

### queryCurrentOsAccount

queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void

A
Annie_wang 已提交
1214
Obtains information about the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1215

A
annie_wangli 已提交
1216
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1217

A
annie_wangli 已提交
1218
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1219

A
annie_wangli 已提交
1220 1221 1222 1223 1224 1225 1226
**Parameters**

| Name  | Type                                                | Mandatory| Description                                          |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes  | Callback used to return information about the OS account obtained.|

**Example**
A
annie_wangli 已提交
1227

1228
  ```js
A
annie_wangli 已提交
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
    console.log("queryCurrentOsAccount err:" + JSON.stringify(err));
    console.log("queryCurrentOsAccount curAccountInfo:" + JSON.stringify(curAccountInfo));
  });
  ```

### queryCurrentOsAccount

queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;

A
Annie_wang 已提交
1240
Obtains information about the OS account to which the current process belongs. This API uses a promise to return the result.
A
annie_wangli 已提交
1241

A
annie_wangli 已提交
1242 1243 1244 1245
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

A
Annie_wang 已提交
1246
**Return value**
A
annie_wangli 已提交
1247

A
annie_wangli 已提交
1248 1249 1250
| Type                                          | Description                                                        |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return information about the OS account obtained.|
A
annie_wangli 已提交
1251

A
annie_wangli 已提交
1252
**Example**
A
annie_wangli 已提交
1253

1254
  ```js
A
annie_wangli 已提交
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
  const accountManager = account_osAccount.getAccountManager();
  accountManager.queryCurrentOsAccount().then((accountInfo) => {
    console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo));
  }).catch((err) => {
    console.log("queryCurrentOsAccount err: "  + JSON.stringify(err));
  });
  ```

### queryOsAccountById

queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;): void

A
Annie_wang 已提交
1267
Obtains information about an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1268

A
annie_wangli 已提交
1269
This is a system API and cannot be called by third-party applications.
A
annie_wangli 已提交
1270

Z
zhangalong 已提交
1271
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
A
annie_wangli 已提交
1272

A
annie_wangli 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
**System capability**: SystemCapability.Account.OsAccount

**Parameters**

| Name  | Type                                                | Mandatory| Description                                    |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- |
| localId  | number                                               | Yes  | ID of the target OS account.                    |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes  | Callback used to return the OS account information obtained.|

**Example**: Query information about OS account 100.
A
annie_wangli 已提交
1283

1284
  ```js
A
annie_wangli 已提交
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
    console.log("queryOsAccountById err:" + JSON.stringify(err));
    console.log("queryOsAccountById accountInfo:" + JSON.stringify(accountInfo));
  });
  ```

### queryOsAccountById

queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;

A
Annie_wang 已提交
1297
Obtains information about an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
1298

A
annie_wangli 已提交
1299 1300
This is a system API and cannot be called by third-party applications.

Z
zhangalong 已提交
1301
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
A
annie_wangli 已提交
1302

A
annie_wangli 已提交
1303
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1304

A
annie_wangli 已提交
1305
**Parameters**
A
annie_wangli 已提交
1306

A
annie_wangli 已提交
1307 1308 1309
| Name | Type  | Mandatory| Description                |
| ------- | ------ | ---- | -------------------- |
| localId | number | Yes  | ID of the target OS account.|
A
annie_wangli 已提交
1310

A
Annie_wang 已提交
1311
**Return value**
A
annie_wangli 已提交
1312 1313 1314 1315 1316 1317

| Type                                          | Description                                                        |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account information obtained.|

**Example**: Query information about OS account 100.
A
annie_wangli 已提交
1318

1319
  ```js
A
annie_wangli 已提交
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.queryOsAccountById(localId).then((accountInfo) => {
    console.log("queryOsAccountById, accountInfo: " + JSON.stringify(accountInfo));
  }).catch((err) => {
    console.log("queryOsAccountById err: "  + JSON.stringify(err));
  });
  ```

### getOsAccountTypeFromProcess

getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void

A
Annie_wang 已提交
1333
Obtains the type of the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1334

A
annie_wangli 已提交
1335 1336 1337
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1338

A
annie_wangli 已提交
1339 1340 1341
| Name  | Type                                                | Mandatory| Description                                                |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | Yes  | Callback used to return the OS account type.|
A
annie_wangli 已提交
1342

A
annie_wangli 已提交
1343
**Example**
A
annie_wangli 已提交
1344

1345
  ```js
A
annie_wangli 已提交
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getOsAccountTypeFromProcess((err, accountType) => {
    console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
    console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
  });
  ```

### getOsAccountTypeFromProcess

getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;

A
Annie_wang 已提交
1357
Obtains the type of the OS account to which the current process belongs. This API uses a promise to return the result.
A
annie_wangli 已提交
1358

A
annie_wangli 已提交
1359
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1360

A
Annie_wang 已提交
1361
**Return value**
A
annie_wangli 已提交
1362

A
annie_wangli 已提交
1363 1364 1365 1366 1367
| Type                                          | Description                                                        |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise used to return the OS account type.|

**Example**
A
annie_wangli 已提交
1368

1369
  ```js
A
annie_wangli 已提交
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getOsAccountTypeFromProcess().then((accountType) => {
    console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
  }).catch((err) => {
    console.log("getOsAccountTypeFromProcess err: "  + JSON.stringify(err));
  });
  ```

### getDistributedVirtualDeviceId

getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void

A
Annie_wang 已提交
1382
Obtains the ID of this distributed virtual device. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1383

Z
zhangalong 已提交
1384
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1385 1386

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1387

A
annie_wangli 已提交
1388
**Parameters**
A
annie_wangli 已提交
1389

A
annie_wangli 已提交
1390 1391 1392 1393 1394
| Name  | Type                       | Mandatory| Description                                |
| -------- | --------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the device ID obtained.|

**Example**
A
annie_wangli 已提交
1395

1396
  ```js
A
annie_wangli 已提交
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
    console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
    console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
  });
  ```

### getDistributedVirtualDeviceId

getDistributedVirtualDeviceId(): Promise&lt;string&gt;

A
Annie_wang 已提交
1408
Obtains the ID of this distributed virtual device. This API uses a promise to return the result.
A
annie_wangli 已提交
1409

Z
zhangalong 已提交
1410
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1411 1412

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1413

A
Annie_wang 已提交
1414
**Return value**
A
annie_wangli 已提交
1415

A
annie_wangli 已提交
1416 1417 1418 1419 1420
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the device ID obtained.|

**Example**
A
annie_wangli 已提交
1421

1422
  ```js
A
annie_wangli 已提交
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
  const accountManager = account_osAccount.getAccountManager();
  accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
    console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
  }).catch((err) => {
    console.log("getDistributedVirtualDeviceId err: "  + JSON.stringify(err));
  });
  ```

### getOsAccountProfilePhoto

getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;): void

A
Annie_wang 已提交
1435
Obtains the profile photo of an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1436

A
annie_wangli 已提交
1437 1438 1439 1440 1441 1442 1443
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS

**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1444

A
annie_wangli 已提交
1445 1446 1447 1448
| Name  | Type                       | Mandatory| Description                                    |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| localId  | number                      | Yes  | ID of the target OS account.                            |
| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the profile photo obtained.|
A
annie_wangli 已提交
1449

A
annie_wangli 已提交
1450
**Example**: Obtain the profile photo of OS account 100.
A
annie_wangli 已提交
1451

1452
  ```js
A
annie_wangli 已提交
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
    console.log("getOsAccountProfilePhoto err:" + JSON.stringify(err));
    console.log("get photo:" + photo + " by localId: " + localId);
  });
  ```

### getOsAccountProfilePhoto

getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;

A
Annie_wang 已提交
1465
Obtains the profile photo of an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
1466

A
annie_wangli 已提交
1467
This is a system API and cannot be called by third-party applications.
A
annie_wangli 已提交
1468

A
annie_wangli 已提交
1469
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1470

A
annie_wangli 已提交
1471
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1472

A
annie_wangli 已提交
1473
**Parameters**
A
annie_wangli 已提交
1474

A
annie_wangli 已提交
1475 1476 1477 1478
| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes  | ID of the target OS account.|

A
Annie_wang 已提交
1479
**Return value**
A
annie_wangli 已提交
1480 1481 1482 1483 1484 1485

| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the profile photo obtained.|

**Example**: Obtain the profile photo of OS account 100.
A
annie_wangli 已提交
1486

1487
  ```js
A
annie_wangli 已提交
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
    console.log("getOsAccountProfilePhoto: " + photo);
  }).catch((err) => {
    console.log("getOsAccountProfilePhoto err: "  + JSON.stringify(err));
  });
  ```

### setOsAccountProfilePhoto

setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback&lt;void&gt;): void

A
Annie_wang 已提交
1501
Sets a profile photo for an OS account. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1502

A
annie_wangli 已提交
1503 1504 1505
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1506

A
annie_wangli 已提交
1507
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1508

A
annie_wangli 已提交
1509 1510 1511 1512 1513 1514 1515 1516 1517
**Parameters**

| Name  | Type                     | Mandatory| Description        |
| -------- | ------------------------- | ---- | ------------ |
| localId  | number                    | Yes  | ID of the target OS account.|
| photo    | string                    | Yes  | Profile photo information.  |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |

**Example**: Set a profile photo for OS account 100.
A
annie_wangli 已提交
1518

1519
  ```js
A
annie_wangli 已提交
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
  "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
  "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
  "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
  osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
    console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err));
  });
  ```

### setOsAccountProfilePhoto

setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;

A
Annie_wang 已提交
1535
Sets a profile photo for an OS account. This API uses a promise to return the result.
A
annie_wangli 已提交
1536

A
annie_wangli 已提交
1537 1538 1539
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
A
annie_wangli 已提交
1540

A
annie_wangli 已提交
1541
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1542

A
annie_wangli 已提交
1543
**Parameters**
A
annie_wangli 已提交
1544

A
annie_wangli 已提交
1545 1546 1547 1548
| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes  | ID of the target OS account.|
| photo   | string | Yes  | Profile photo information.  |
A
annie_wangli 已提交
1549

A
Annie_wang 已提交
1550
**Return value**
A
annie_wangli 已提交
1551 1552 1553 1554 1555 1556

| Type               | Description                               |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|

**Example**: Set a profile photo for OS account 100.
A
annie_wangli 已提交
1557

1558
  ```js
A
annie_wangli 已提交
1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
  "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
  "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
  "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
  accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
    console.log("setOsAccountProfilePhoto success");
  }).catch((err) => {
    console.log("setOsAccountProfilePhoto err: "  + JSON.stringify(err));
  });
  ```

A
annie_wangli 已提交
1572
### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
A
annie_wangli 已提交
1573 1574 1575

getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
1576
Obtains the OS account ID based on the SN. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1577

A
annie_wangli 已提交
1578
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1579

A
annie_wangli 已提交
1580
**Parameters**
A
annie_wangli 已提交
1581

A
annie_wangli 已提交
1582 1583 1584 1585 1586 1587
| Name      | Type                       | Mandatory| Description                                            |
| ------------ | --------------------------- | ---- | ------------------------------------------------ |
| serialNumber | number                      | Yes  | Account SN.                                      |
| callback     | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the OS account ID obtained.|

**Example**: Obtain the ID of the OS account whose SN is **12345**.
A
annie_wangli 已提交
1588

1589
  ```js
A
annie_wangli 已提交
1590 1591 1592 1593 1594 1595 1596 1597
  const accountManager = account_osAccount.getAccountManager();
  var serialNumber = 12345;
  accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
    console.log("ger localId err:" + JSON.stringify(err));
    console.log("get localId:" + localId + " by serialNumber: " + serialNumber);
  });
  ```

A
annie_wangli 已提交
1598
### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
A
annie_wangli 已提交
1599 1600 1601

getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;

A
Annie_wang 已提交
1602
Obtains the OS account ID based on the SN. This API uses a promise to return the result.
A
annie_wangli 已提交
1603

A
annie_wangli 已提交
1604 1605 1606
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1607

A
annie_wangli 已提交
1608 1609 1610
| Name      | Type  | Mandatory| Description      |
| ------------ | ------ | ---- | ---------- |
| serialNumber | number | Yes  | Account SN.|
A
annie_wangli 已提交
1611

A
Annie_wang 已提交
1612
**Return value**
A
annie_wangli 已提交
1613

A
annie_wangli 已提交
1614 1615 1616
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
A
annie_wangli 已提交
1617

A
annie_wangli 已提交
1618
**Example**: Obtain the ID of the OS account whose SN is **12345**.
A
annie_wangli 已提交
1619

1620
  ```js
A
annie_wangli 已提交
1621 1622 1623 1624 1625 1626 1627 1628 1629
  const accountManager = account_osAccount.getAccountManager();
  var serialNumber = 12345;
  accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
    console.log("getOsAccountLocalIdBySerialNumber localId: " + localId);
  }).catch((err) => {
    console.log("getOsAccountLocalIdBySerialNumber err: "  + JSON.stringify(err));
  });
  ```

A
annie_wangli 已提交
1630
### getSerialNumberByOsAccountLocalId<sup>8+</sup>
A
annie_wangli 已提交
1631 1632 1633

getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void

A
Annie_wang 已提交
1634
Obtains the SN of an OS account based on the account ID. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1635

A
annie_wangli 已提交
1636
**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1637

A
annie_wangli 已提交
1638
**Parameters**
A
annie_wangli 已提交
1639

A
annie_wangli 已提交
1640 1641 1642 1643 1644 1645
| Name  | Type                       | Mandatory| Description                                      |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| localId  | number                      | Yes  | ID of the target OS account.                              |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the account SN obtained.|

**Example**: Obtain the SN of OS account 100.
A
annie_wangli 已提交
1646

1647
  ```js
A
annie_wangli 已提交
1648 1649 1650 1651 1652 1653 1654 1655
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
    console.log("ger serialNumber err:" + JSON.stringify(err));
    console.log("get serialNumber:" + serialNumber + " by localId: " + localId);
  });
  ```

A
annie_wangli 已提交
1656
### getSerialNumberByOsAccountLocalId<sup>8+</sup>
A
annie_wangli 已提交
1657 1658 1659

getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;

A
Annie_wang 已提交
1660
Obtains the SN of an OS account based on the account ID. This API uses a promise to return the result.
A
annie_wangli 已提交
1661

A
annie_wangli 已提交
1662 1663 1664
**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1665

A
annie_wangli 已提交
1666 1667 1668
| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes  | ID of the target OS account.|
A
annie_wangli 已提交
1669

A
Annie_wang 已提交
1670
**Return value**
A
annie_wangli 已提交
1671

A
annie_wangli 已提交
1672 1673 1674
| Type                 | Description                                                        |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account SN obtained.|
A
annie_wangli 已提交
1675

A
annie_wangli 已提交
1676
**Example**: Obtain the SN of OS account 100.
A
annie_wangli 已提交
1677

1678
  ```js
A
annie_wangli 已提交
1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691
  const accountManager = account_osAccount.getAccountManager();
  var localId = 100;
  accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
    console.log("getSerialNumberByOsAccountLocalId serialNumber: " + serialNumber);
  }).catch((err) => {
    console.log("getSerialNumberByOsAccountLocalId err: "  + JSON.stringify(err));
  });
  ```

### on

on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&gt;): void

A
Annie_wang 已提交
1692
Subscribes to OS account changes. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1693

A
annie_wangli 已提交
1694 1695 1696 1697 1698
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION

**System capability**: SystemCapability.Account.OsAccount
A
annie_wangli 已提交
1699

A
annie_wangli 已提交
1700
**Parameters**
A
annie_wangli 已提交
1701

A
annie_wangli 已提交
1702 1703 1704 1705 1706 1707 1708
| Name  | Type                      | Mandatory| Description                                                        |
| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| type     | 'activate' \| 'activating' | Yes  | Type of the event to subscribe to. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.|
| name     | string                     | Yes  | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes.          |
| callback | Callback&lt;number&gt;     | Yes  | Callback used to return the OS account ID and status changes.  |

**Example**
A
annie_wangli 已提交
1709

1710
  ```js
A
annie_wangli 已提交
1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721
  const accountManager = account_osAccount.getAccountManager();
  function onCallback(receiveLocalId){
    console.log("receive localId:" + receiveLocalId);
  }
  accountManager.on("activating", "osAccountOnOffNameA", onCallback);
  ```

### off

off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number&gt;): void

A
Annie_wang 已提交
1722
Unsubscribes from the OS account changes. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
1723

A
annie_wangli 已提交
1724 1725 1726 1727 1728 1729 1730
This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION

**System capability**: SystemCapability.Account.OsAccount

**Parameters**
A
annie_wangli 已提交
1731

A
annie_wangli 已提交
1732 1733 1734 1735 1736
| Name  | Type                      | Mandatory| Description                                                        |
| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| type     | 'activate' \| 'activating' | Yes  | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.|
| name     | string                     | Yes  | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.|
| callback | Callback&lt;number&gt;     | No  | Callback used to return the OS account changes. By default, **0** is returned.                     |
A
annie_wangli 已提交
1737

A
annie_wangli 已提交
1738
**Example**
A
annie_wangli 已提交
1739

1740
  ```js
A
annie_wangli 已提交
1741 1742 1743 1744 1745 1746 1747 1748
  const accountManager = account_osAccount.getAccountManager();
  function offCallback(){
    console.log("off enter")
  }
  accountManager.off("activating", "osAccountOnOffNameA", offCallback);
  ```

## OsAccountInfo
Z
zengyawen 已提交
1749

A
annie_wangli 已提交
1750
Defines information about an OS account.
A
annie_wangli 已提交
1751 1752 1753

**System capability**: SystemCapability.Account.OsAccount

Z
zengyawen 已提交
1754 1755 1756 1757 1758 1759
| Name                        | Type                                                        | Mandatory| Description                             |
| ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------- |
| localId                        | number                                                       | Yes  | ID of the target OS account.                     |
| localName                      | string                                                       | Yes  | OS account name.                   |
| type                           | [OsAccountType](#osaccounttype)                              | Yes  | OS account type.                     |
| constraints                    | Array&lt;string&gt;                                          | No  | [Constraints](#constraints) on the OS account.|
Z
zhangalong 已提交
1760 1761 1762 1763 1764 1765 1766
| isVerified<sup>8+</sup>        | boolean                                                      | Yes  | Whether the OS account is verified.                     |
| photo<sup>8+</sup>             | string                                                       | No  | Profile photo of the OS account.                     |
| createTime<sup>8+</sup>        | number                                                       | Yes  | Time when the OS account was created.                 |
| lastLoginTime<sup>8+</sup>     | number                                                       | No  | Last login time of the OS account.         |
| serialNumber<sup>8+</sup>      | number                                                       | Yes  | SN of the OS account.                     |
| isActived<sup>8+</sup>         | boolean                                                      | Yes  | Whether the OS account is activated.                 |
| isCreateCompleted<sup>8+</sup> | boolean                                                      | Yes  | Whether the OS account information is complete.             |
Z
zengyawen 已提交
1767
| distributedInfo                | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No  | Distributed account information.                   |
Z
zhangalong 已提交
1768
| domainInfo<sup>8+</sup>        | [DomainAccountInfo](#domainaccountinfo)                      | No  | Domain account information.                       |
A
annie_wangli 已提交
1769

Z
zhangalong 已提交
1770
## DomainAccountInfo<sup>8+</sup>
Z
zengyawen 已提交
1771

A
annie_wangli 已提交
1772 1773 1774 1775 1776 1777
Domain account information.

**System capability**: SystemCapability.Account.OsAccount

| Name     | Type  | Mandatory| Description      |
| ----------- | ------ | ---- | ---------- |
Z
zengyawen 已提交
1778
| domain      | string | Yes  | Domain name.    |
A
annie_wangli 已提交
1779
| accountName | string | Yes  | Domain account name.|
A
annie_wangli 已提交
1780 1781 1782

## Constraints

A
annie_wangli 已提交
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792
| Constraint                                 | Description                          |
| ------------------------------------- | ------------------------------ |
| constraint.wifi                       | A user is not allowed to use Wi-Fi.                  |
| constraint.wifi.set                   | A user is not allowed to change Wi-Fi settings.                  |
| constraint.locale.set                 | A user is not allowed to change the device language.              |
| constraint.app.accounts               | A user is not allowed to add or delete app accounts.        |
| constraint.apps.install               | A user is not allowed to install apps.                  |
| constraint.apps.uninstall             | A user is not allowed to uninstall apps.                  |
| constraint.location.shared            | A user is not allowed to enable location sharing.              |
| constraint.unknown.sources.install    | A user is not allowed to install apps from unknown sources.        |
A
annie_wangli 已提交
1793
| constraint.global.unknown.app.install | All users are not allowed to install apps from unknown sources.|
A
annie_wangli 已提交
1794 1795
| constraint.bluetooth.set              | A user is not allowed to configure Bluetooth.                  |
| constraint.bluetooth | The use of Bluetooth is prohibited on the device.|
A
annie_wangli 已提交
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814
| constraint.bluetooth.share | Bluetooth sharing is prohibited.|
| constraint.usb.file.transfer | A user is not allowed to transfer files over USB.|
| constraint.credentials.set | A user is not allowed to configure user credentials.|
| constraint.os.account.remove | An admin user is not allowed to remove users or a non-admin user is not allowed to remove itself.|
| constraint.managed.profile.remove | The managed profiles of this user cannot be removed.|
| constraint.debug.features.use | A user is not allowed to enable or access debugging features.|
| constraint.vpn.set | A user is not allowed to configure a VPN.|
| constraint.date.time.set | A user is not allowed to set date, time, or time zone.|
| constraint.tethering.config | A user is not allowed to configure Tethering.|
| constraint.network.reset | A user is not allowed to reset network settings.|
| constraint.factory.reset | A user is not allowed to reset factory settings.|
| constraint.os.account.create | A user is not allowed to create users.|
| constraint.add.managed.profile | A user is not allowed to add managed profiles.|
| constraint.apps.verify.disable | A user is not allowed to disable app verification.|
| constraint.cell.broadcasts.set | A user is not allowed to configure cell broadcasts.|
| constraint.mobile.networks.set | A user is not allowed to configure radio networks.|
| constraint.control.apps | A user is not allowed to modify apps in **Settings** or the boot module.|
| constraint.physical.media | A user is not allowed to mount external physical media.|
| constraint.microphone | A user is not allowed to use microphones.|
Z
zengyawen 已提交
1815 1816
| constraint.microphone.unmute | A user is not allowed to unmute the microphone.|
| constraint.volume.adjust | A user is not allowed to adjust the volume.|
A
annie_wangli 已提交
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833
| constraint.calls.outgoing | A user is not allowed to make outgoing calls.|
| constraint.sms.use | A user is not allowed to send or receive SMS messages.|
| constraint.fun | A user is not allowed to have entertainment.|
| constraint.windows.create | Windows other than app windows cannot be created.|
| constraint.system.error.dialogs | Error dialogs for crashed or unresponsive apps are prohibited.|
| constraint.cross.profile.copy.paste | Pasting clipboard content to other users or profiles is prohibited.|
| constraint.beam.outgoing | A user is not allowed to use Near Field Communications (NFC) to transfer data from apps.|
| constraint.wallpaper | A user is not allowed to manage wallpapers.|
| constraint.safe.boot | A user is not allowed to reboot the device in safe boot mode.|
| constraint.parent.profile.app.linking | The apps in the parent profile are allowed to handle web links from the managed profile.|
| constraint.audio.record | Audio recording is prohibited.|
| constraint.camera.use | The use of cameras is prohibited.|
| constraint.os.account.background.run | Running in the background is prohibited.|
| constraint.data.roam | A user is not allowed to use cellular data when roaming.|
| constraint.os.account.set.icon | A user is not allowed to change their icon.|
| constraint.wallpaper.set | A user is not allowed to set a wallpaper.|
| constraint.oem.unlock | A user is not allowed to enable OEM unlock.|
Z
zengyawen 已提交
1834
| constraint.device.unmute | A user is not allowed to unmute the device.|
A
annie_wangli 已提交
1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847
| constraint.password.unified | The managed profile is not allowed to have unified lock screen challenge with the primary user.|
| constraint.autofill | A user is not allowed to use the autofill service.|
| constraint.content.capture | Capturing the content of a user's screen is prohibited.|
| constraint.content.suggestions | A user is not allowed to receive content suggestions.|
| constraint.os.account.start | User switching is blocked.|
| constraint.location.set | A user is not allowed to configure the location service.|
| constraint.airplane.mode.set | The airplane mode is prohibited on the device.|
| constraint.brightness.set | A user is not allowed to configure brightness.|
| constraint.share.into.profile | A user is not allowed to share files, images, or data from the primary user to the managed profile.|
| constraint.ambient.display | Ambient display is prohibited for the user.|
| constraint.screen.timeout.set | A user is not allowed to configure the screen off timeout.|
| constraint.print | A user is not allowed to print.|
| constraint.private.dns.set | A user is not allowed to configure a private domain name server (DNS).|