1# @ohos.bundle.appControl (appControl) (System API) 2 3The **appControl** module provides APIs for setting, obtaining, and deleting the disposed status of an application. An application in the disposed status is forbidden to run. When a user clicks the application icon on the home screen, the corresponding page is displayed based on the disposal intent. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs provided by this module are system APIs. 10 11## Modules to Import 12 13``` ts 14import appControl from '@ohos.bundle.appControl' 15``` 16 17## appControl.setDisposedStatus 18 19setDisposedStatus(appId: string, disposedWant: Want): Promise\<void> 20 21Sets the disposed status for an application. This API uses a promise to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 22 23**System API**: This is a system API. 24 25**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 26 27**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 28 29**Parameters** 30 31| Name | Type | Mandatory | Description | 32| ----------- | ------ | ---- | --------------------------------------- | 33| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 34| disposedWant | Want | Yes| Disposal intent of the application.| 35 36**Return value** 37 38| Type | Description | 39| ------------------------- | ------------------ | 40| Promise\<void> | Promise that returns no value.| 41 42**Error codes** 43 44For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 45 46| ID| Error Message | 47| ------ | -------------------------------------- | 48| 201 | Permission denied. | 49| 202 | Permission denied, non-system app called system api. | 50| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 51| 801 | Capability not supported. | 52| 17700005 | The specified app ID is an empty string. | 53 54**Example** 55 56```ts 57import { BusinessError } from '@ohos.base'; 58import Want from '@ohos.app.ability.Want'; 59import appControl from '@ohos.bundle.appControl'; 60 61let appId = "com.example.myapplication_xxxxx"; 62let want:Want = {bundleName: 'com.example.myapplication'}; 63 64try { 65 appControl.setDisposedStatus(appId, want) 66 .then(() => { 67 console.info('setDisposedStatus success'); 68 }).catch((error: BusinessError) => { 69 let message = (error as BusinessError).message; 70 console.error('setDisposedStatus failed ' + message); 71 }); 72} catch (error) { 73 let message = (error as BusinessError).message; 74 console.error('setDisposedStatus failed ' + message); 75} 76``` 77 78## appControl.setDisposedStatus 79 80setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<void>): void; 81 82Sets the disposed status for an application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 83 84**System API**: This is a system API. 85 86**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 87 88**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 89 90**Parameters** 91 92| Name | Type | Mandatory | Description | 93| ----------- | ------------------------------- | ---- | --------------------------------------- | 94| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 95| disposedWant | Want | Yes| Disposal intent of the application.| 96| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 97 98**Error codes** 99 100For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 101 102| ID| Error Message | 103| ------ | -------------------------------------- | 104| 201 | Permission denied. | 105| 202 | Permission denied, non-system app called system api. | 106| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 107| 801 | Capability not supported. | 108| 17700005 | The specified app ID is an empty string. | 109 110**Example** 111 112```ts 113import appControl from '@ohos.bundle.appControl'; 114import { BusinessError } from '@ohos.base'; 115import Want from '@ohos.app.ability.Want'; 116 117let appId = "com.example.myapplication_xxxxx"; 118let want: Want = {bundleName: 'com.example.myapplication'}; 119 120try { 121 appControl.setDisposedStatus(appId, want, (error: BusinessError, data) => { 122 if (error) { 123 let message = (error as BusinessError).message; 124 console.error('setDisposedStatus failed ' + message); 125 return; 126 } 127 console.info('setDisposedStatus success'); 128 }); 129} catch (error) { 130 let message = (error as BusinessError).message; 131 console.error('setDisposedStatus failed ' + message); 132} 133``` 134 135## appControl.setDisposedStatusSync<sup>10+</sup> 136 137setDisposedStatusSync(appId: string, disposedWant: Want): void; 138 139Sets the disposed status for an application. This API returns the result synchronously. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 140 141**System API**: This is a system API. 142 143**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 144 145**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 146 147 148**Parameters** 149 150| Name | Type | Mandatory | Description | 151| ----------- | ------------------------------- | ---- | --------------------------------------- | 152| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 153| disposedWant | Want | Yes| Disposal intent of the application.| 154 155**Error codes** 156 157For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 158 159| ID| Error Message | 160| ------ | -------------------------------------- | 161| 201 | Permission denied. | 162| 202 | Permission denied, non-system app called system api. | 163| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 164| 801 | Capability not supported. | 165| 17700005 | The specified app ID is an empty string. | 166 167**Example** 168 169```ts 170import appControl from '@ohos.bundle.appControl'; 171import { BusinessError } from '@ohos.base'; 172import Want from '@ohos.app.ability.Want'; 173 174let appId: string = "com.example.myapplication_xxxxx"; 175let want: Want = {bundleName: 'com.example.myapplication'}; 176 177try { 178 appControl.setDisposedStatusSync(appId, want); 179} catch (error) { 180 let message = (error as BusinessError).message; 181 console.error('setDisposedStatusSync failed ' + message); 182} 183``` 184 185## appControl.getDisposedStatus 186 187getDisposedStatus(appId: string): Promise\<Want>; 188 189Obtains the disposed status of an application. This API uses a promise to return the result. If the operation is successful, the disposed status of the application is returned. If the operation fails, an error message is returned. 190 191**System API**: This is a system API. 192 193**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 194 195**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 196 197**Parameters** 198 199| Name | Type | Mandatory | Description | 200| ----------- | ------ | ---- | --------------------------------------- | 201| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 202 203**Return value** 204 205| Type | Description | 206| ------------------------- | ------------------ | 207| Promise\<Want> | Promise used to return the disposed status.| 208 209**Error codes** 210 211For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 212 213| ID| Error Message | 214| ------ | -------------------------------------- | 215| 201 | Permission denied. | 216| 202 | Permission denied, non-system app called system api. | 217| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 218| 801 | Capability not supported. | 219| 17700005 | The specified app ID is an empty string. | 220 221**Example** 222 223```ts 224import appControl from '@ohos.bundle.appControl'; 225import { BusinessError } from '@ohos.base'; 226 227let appId = "com.example.myapplication_xxxxx"; 228 229try { 230 appControl.getDisposedStatus(appId) 231 .then((data) => { 232 console.info('getDisposedStatus success. DisposedStatus: ' + JSON.stringify(data)); 233 }).catch((error: BusinessError) => { 234 let message = (error as BusinessError).message; 235 console.error('getDisposedStatus failed ' + message); 236 }); 237} catch (error) { 238 let message = (error as BusinessError).message; 239 console.error('getDisposedStatus failed ' + message); 240} 241``` 242 243## appControl.getDisposedStatus 244 245getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void; 246 247Obtains the disposed status of an application. This API uses an asynchronous callback to return the result. If the operation is successful, the disposed status of the application is returned. If the operation fails, an error message is returned. 248 249**System API**: This is a system API. 250 251**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 252 253**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 254 255**Parameters** 256 257| Name | Type | Mandatory | Description | 258| ----------- | ------ | ---- | --------------------------------------- | 259| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 260| callback | AsyncCallback\<Want> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the disposed status obtained; otherwise, **err** is an error object. | 261 262**Error codes** 263 264For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 265 266| ID| Error Message | 267| ------ | -------------------------------------- | 268| 201 | Permission denied. | 269| 202 | Permission denied, non-system app called system api. | 270| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 271| 801 | Capability not supported. | 272| 17700005 | The specified app ID is an empty string. | 273 274**Example** 275 276```ts 277import appControl from '@ohos.bundle.appControl'; 278import { BusinessError } from '@ohos.base'; 279 280let appId = "com.example.myapplication_xxxxx"; 281 282try { 283 appControl.getDisposedStatus(appId, (error, data) => { 284 if (error) { 285 let message = (error as BusinessError).message; 286 console.error('getDisposedStatus failed ' + message); 287 return; 288 } 289 console.info('getDisposedStatus success. DisposedStatus: ' + JSON.stringify(data)); 290 }); 291} catch (error) { 292 let message = (error as BusinessError).message; 293 console.error('getDisposedStatus failed ' + message); 294} 295``` 296 297## appControl.getDisposedStatusSync<sup>10+</sup> 298 299getDisposedStatusSync(appId: string): Want; 300 301Obtains the disposed status of an application. This API returns the result synchronously. If the operation is successful, the disposed status of the application is returned. If the operation fails, an error message is returned. 302 303**System API**: This is a system API. 304 305**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 306 307**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 308 309**Parameters** 310 311| Name | Type | Mandatory | Description | 312| ----------- | ------ | ---- | --------------------------------------- | 313| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 314 315**Return value** 316 317| Type | Description | 318| ------------------------- | ------------------ | 319| Want | Disposed status.| 320 321**Error codes** 322 323For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 324 325| ID| Error Message | 326| ------ | -------------------------------------- | 327| 201 | Permission denied. | 328| 202 | Permission denied, non-system app called system api. | 329| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 330| 801 | Capability not supported. | 331| 17700005 | The specified app ID is an empty string. | 332 333**Example** 334 335```ts 336import appControl from '@ohos.bundle.appControl'; 337import { BusinessError } from '@ohos.base'; 338import Want from '@ohos.app.ability.Want'; 339 340let appId: string = "com.example.myapplication_xxxxx"; 341let want: Want; 342 343try { 344 want = appControl.getDisposedStatusSync(appId); 345} catch (error) { 346 let message = (error as BusinessError).message; 347 console.error('getDisposedStatusSync failed ' + message); 348} 349``` 350 351## appControl.deleteDisposedStatus 352 353deleteDisposedStatus(appId: string): Promise\<void> 354 355Deletes the disposed status for an application. This API uses a promise to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 356 357**System API**: This is a system API. 358 359**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 360 361**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 362 363**Parameters** 364 365| Name | Type | Mandatory | Description | 366| ----------- | ------ | ---- | --------------------------------------- | 367| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 368 369**Return value** 370 371| Type | Description | 372| ------------------------- | ------------------ | 373| Promise\<void> | Promise that returns no value.| 374 375**Error codes** 376 377For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 378 379| ID| Error Message | 380| ------ | -------------------------------------- | 381| 201 | Permission denied. | 382| 202 | Permission denied, non-system app called system api. | 383| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 384| 801 | Capability not supported. | 385| 17700005 | The specified app ID is an empty string. | 386 387**Example** 388 389```ts 390import appControl from '@ohos.bundle.appControl'; 391import { BusinessError } from '@ohos.base'; 392 393let appId = "com.example.myapplication_xxxxx"; 394 395try { 396 appControl.deleteDisposedStatus(appId) 397 .then(() => { 398 console.info('deleteDisposedStatus success'); 399 }).catch((error: BusinessError) => { 400 let message = (error as BusinessError).message; 401 console.error('deleteDisposedStatus failed ' + message); 402 }); 403} catch (error) { 404 let message = (error as BusinessError).message; 405 console.error('deleteDisposedStatus failed ' + message); 406} 407``` 408 409## appControl.deleteDisposedStatus 410 411deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void 412 413Deletes the disposed status for an application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 414 415**System API**: This is a system API. 416 417**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 418 419**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 420 421**Parameters** 422 423| Name | Type | Mandatory | Description | 424| ----------- | ------ | ---- | --------------------------------------- | 425| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 426| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 427 428**Error codes** 429 430For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 431 432| ID| Error Message | 433| ------ | -------------------------------------- | 434| 201 | Permission denied. | 435| 202 | Permission denied, non-system app called system api. | 436| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 437| 801 | Capability not supported. | 438| 17700005 | The specified app ID is an empty string. | 439 440**Example** 441 442```ts 443import appControl from '@ohos.bundle.appControl'; 444import { BusinessError } from '@ohos.base'; 445 446let appId = "com.example.myapplication_xxxxx"; 447try { 448 appControl.deleteDisposedStatus(appId, (error: BusinessError, data) => { 449 if (error) { 450 console.error('deleteDisposedStatus failed ' + error.message); 451 return; 452 } 453 console.info('deleteDisposedStatus success'); 454 }); 455} catch (error) { 456 let message = (error as BusinessError).message; 457 console.error('deleteDisposedStatus failed ' + message); 458} 459``` 460 461## appControl.deleteDisposedStatusSync<sup>10+</sup> 462 463deleteDisposedStatusSync(appId: string, appIndex:? number) : void 464 465Deletes the disposed status for an application or an application clone. This API returns the result synchronously. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. 466 467**System API**: This is a system API. 468 469**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 470 471**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 472 473**Parameters** 474 475| Name | Type | Mandatory | Description | 476| ----------- | ------ | ---- | --------------------------------------- | 477| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 478| appIndex<sup>12+</sup> | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to delete the disposed status of the main application. A value greater than 0 means to delete the disposed status of the application clone. | 479 480**Error codes** 481 482For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 483 484| ID| Error Message | 485| ------ | -------------------------------------- | 486| 201 | Permission denied. | 487| 202 | Permission denied, non-system app called system api. | 488| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 489| 801 | Capability not supported. | 490| 17700005 | The specified app ID is an empty string. | 491| 17700061 | AppIndex is not in the valid range. | 492 493**Example** 494 495```ts 496import appControl from '@ohos.bundle.appControl'; 497import { BusinessError } from '@ohos.base'; 498 499let appId: string = "com.example.myapplication_xxxxx"; 500 501try { 502 appControl.deleteDisposedStatusSync(appId, 1); 503} catch (error) { 504 let message = (error as BusinessError).message; 505 console.error('deleteDisposedStatusSync failed ' + message); 506} 507``` 508 509## Obtaining appId of an Application 510 511**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. It can be obtained by calling [getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo14). 512 513**Example** 514 515```ts 516import bundleManager from '@ohos.bundle.bundleManager'; 517import { BusinessError } from '@ohos.base'; 518 519let bundleName = 'com.example.myapplication'; 520let appId: string; 521try { 522 bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) 523 .then((data) => { 524 appId = data.signatureInfo.appId; 525 console.info("appId is " + appId); 526 }).catch((error: BusinessError) => { 527 let message = (error as BusinessError).message; 528 console.error("getBundleInfo failed " + message); 529 }); 530} catch (error) { 531 let message = (error as BusinessError).message; 532 console.error("getBundleInfo failed " + message); 533} 534``` 535 536## appControl.getDisposedRule<sup>11+</sup> 537 538getDisposedRule(appId: string, appIndex:? number): DisposedRule 539 540Obtains the disposed rule of an application or an application clone. 541 542**System API**: This is a system API. 543 544**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 545 546**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 547 548**Parameters** 549 550| Name | Type | Mandatory | Description | 551| ----------- | ------ | ---- | --------------------------------------- | 552| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 553| appIndex<sup>12+</sup> | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to obtain the disposed rule of the main application. A value greater than 0 means to obtain the disposed rule of the application clone. | 554 555**Return value** 556 557| Type | Description | 558| ------------------------- | ------------------ | 559| [DisposedRule](#disposedrule11) | Disposed rule of the application.| 560 561**Error codes** 562 563For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 564 565| ID| Error Message | 566| ------ | -------------------------------------- | 567| 201 | Permission denied. | 568| 202 | Permission denied, non-system app called system api. | 569| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 570| 801 | Capability not supported. | 571| 17700005 | The specified app ID is an empty string. | 572| 17700061 | AppIndex is not in the valid range. | 573 574**Example** 575 576```ts 577import appControl from '@ohos.bundle.appControl'; 578import { BusinessError } from '@ohos.base'; 579import Want from '@ohos.app.ability.Want'; 580 581let appId = "com.example.myapplication_xxxxx"; 582 583try { 584 let data = appControl.getDisposedRule(appId, 1); 585 console.info('getDisposedRule successfully. Data: ' + JSON.stringify(data)); 586} catch (error) { 587 let message = (error as BusinessError).message; 588 console.error('getDisposedRule failed ' + message); 589} 590``` 591 592## appControl.setDisposedRule<sup>11+</sup> 593 594setDisposedRule(appId: string, rule: DisposedRule, appIndex:? number): void 595 596Sets the disposed rule for an application or an application clone. 597 598**System API**: This is a system API. 599 600**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 601 602**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 603 604**Parameters** 605 606| Name | Type | Mandatory | Description | 607| ----------- | ------ | ---- | --------------------------------------- | 608| appId | string | Yes | ID of the target application.<br>**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 609| rule | [DisposedRule](#disposedrule11) | Yes| Disposed rule to set.| 610| appIndex<sup>12+</sup> | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to set the disposed rule for the main application. A value greater than 0 means to set the disposed rule for the application clone. | 611 612**Error codes** 613 614For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 615 616| ID| Error Message | 617| ------ | -------------------------------------- | 618| 201 | Permission denied. | 619| 202 | Permission denied, non-system app called system api. | 620| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 621| 801 | Capability not supported. | 622| 17700005 | The specified app ID is an empty string. | 623| 17700061 | AppIndex is not in the valid range. | 624 625**Example** 626 627```ts 628import appControl from '@ohos.bundle.appControl'; 629import { BusinessError } from '@ohos.base'; 630import Want from '@ohos.app.ability.Want'; 631import bundleManager from '@ohos.bundle.bundleManager'; 632 633let appId = "com.example.myapplication_xxxxx"; 634let want: Want = { 635 bundleName: "com.example.myapplication", 636 moduleName: "entry", 637 abilityName: "EntryAbility" 638}; 639let elementName: bundleManager.ElementName = { 640 bundleName: "com.example.myapplication", 641 moduleName: "entry", 642 abilityName: "EntryAbility" 643}; 644let rule: appControl.DisposedRule = { 645 want: want, 646 componentType: appControl.ComponentType.UI_ABILITY, 647 disposedType: appControl.DisposedType.BLOCK_APPLICATION, 648 controlType: appControl.ControlType.ALLOWED_LIST, 649 elementList: [ 650 elementName 651 ], 652 priority: 100 653}; 654 655try { 656 appControl.setDisposedRule(appId, rule, 1); 657} catch (error) { 658 let message = (error as BusinessError).message; 659 console.error('setDisposedRule failed ' + message); 660} 661``` 662 663## appControl.setUninstallDisposedRule<sup>15+</sup> 664 665setUninstallDisposedRule(appIdentifier: string, rule: UninstallDisposedRule, appIndex:? number): void 666 667Sets an uninstallation disposed rule for an application or an application clone. 668 669**System API**: This is a system API. 670 671**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 672 673**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 674 675**Parameters** 676 677| Name | Type | Mandatory | Description | 678| ----------- | ------ | ---- | --------------------------------------- | 679| appIdentifier | string | Yes | appIdentifier of the target application.<br> If the application does not have an appIdentifier, use its appId instead. **appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 680| rule | [UninstallDisposedRule](#uninstalldisposedrule15) | Yes| Uninstallation disposed rule.| 681| appIndex | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to set the uninstallation disposed rule for the main application. A value greater than 0 means to set the uninstallation disposed rule for the application clone. | 682 683**Error codes** 684 685For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 686 687| ID| Error Message | 688| ------ | -------------------------------------- | 689| 201 | Permission denied. | 690| 202 | Permission denied. A non-system application is not allowed to call a system API. | 691| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 692| 801 | Capability not supported. | 693| 17700061 | AppIndex is not in the valid range. | 694| 17700074 | The specified appIdentifier is invalid. | 695| 17700075 | The specified bundleName of want is not the same with caller. | 696 697**Example** 698 699```ts 700import appControl from '@ohos.bundle.appControl'; 701import { BusinessError } from '@ohos.base'; 702import Want from '@ohos.app.ability.Want'; 703 704let appIdentifier = "com.example.myapplication_xxxxx"; 705let want: Want = { 706 bundleName: "com.example.myapplication", 707 moduleName: "entry", 708 abilityName: "EntryAbility" 709}; 710let rule: appControl.UninstallDisposedRule = { 711 want: want, 712 uninstallComponentType: appControl.UninstallComponentType.EXTENSION, 713 priority: 100 714}; 715 716try { 717 appControl.setUninstallDisposedRule(appIdentifier, rule, 1); 718} catch (error) { 719 let message = (error as BusinessError).message; 720 console.error('setUninstallDisposedRule failed ' + message); 721} 722``` 723 724## appControl.getUninstallDisposedRule<sup>15+</sup> 725 726getUninstallDisposedRule(appIdentifier: string, appIndex:? number): UninstallDisposedRule 727 728Obtains the uninstallation disposed rule of an application or an application clone. 729 730**System API**: This is a system API. 731 732**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS or ohos.permission.GET_DISPOSED_APP_STATUS 733 734**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 735 736**Parameters** 737 738| Name | Type | Mandatory | Description | 739| ----------- | ------ | ---- | --------------------------------------- | 740| appIdentifier | string | Yes | appIdentifier of the target application.<br> If the application does not have an appIdentifier, use its appId instead. **appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 741| appIndex | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to obtain the uninstallation disposed rule of the main application. A value greater than 0 means to obtain the uninstallation disposed rule of the application clone. | 742 743**Return value** 744 745| Type | Description | 746| ------------------------- | ------------------ | 747| [UninstallDisposedRule](#uninstalldisposedrule15) | Uninstallation disposed rule.| 748 749**Error codes** 750 751For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 752 753| ID| Error Message | 754| ------ | -------------------------------------- | 755| 201 | Permission denied. | 756| 202 | Permission denied. A non-system application is not allowed to call a system API. | 757| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 758| 801 | Capability not supported. | 759| 17700061 | AppIndex is not in the valid range. | 760| 17700074 | The specified appIdentifier is invalid. | 761 762**Example** 763 764```ts 765import appControl from '@ohos.bundle.appControl'; 766import { BusinessError } from '@ohos.base'; 767 768let appIdentifier = "com.example.myapplication_xxxxx"; 769 770try { 771 let data = appControl.getUninstallDisposedRule(appIdentifier, 1); 772 console.info('getUninstallDisposedRule successfully. Data: ' + JSON.stringify(data)); 773} catch (error) { 774 let message = (error as BusinessError).message; 775 console.error('getUninstallDisposedRule failed ' + message); 776} 777``` 778 779## appControl.deleteUninstallDisposedRule<sup>15+</sup> 780 781deleteUninstallDisposedRule(appIdentifier: string, appIndex:? number): void 782 783Deletes an uninstallation disposed rule for an application or an application clone. 784 785**System API**: This is a system API. 786 787**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS 788 789**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 790 791**Parameters** 792 793| Name | Type | Mandatory | Description | 794| ----------- | ------ | ---- | --------------------------------------- | 795| appIdentifier | string | Yes | appIdentifier of the target application.<br> If the application does not have an appIdentifier, use its appId instead. **appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). | 796| appIndex | number | No | Index of the application clone. The default value is **0**.<br>The value **0** means to delete the uninstallation disposed rule of the main application. A value greater than 0 means to delete the uninstallation disposed rule of the application clone. | 797 798**Error codes** 799 800For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 801 802| ID| Error Message | 803| ------ | -------------------------------------- | 804| 201 | Permission denied. | 805| 202 | Permission denied. A non-system application is not allowed to call a system API. | 806| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 807| 801 | Capability not supported. | 808| 17700061 | AppIndex is not in the valid range. | 809| 17700074 | The specified appIdentifier is invalid. | 810 811**Example** 812 813```ts 814import appControl from '@ohos.bundle.appControl'; 815import { BusinessError } from '@ohos.base'; 816 817let appIdentifier = "com.example.myapplication_xxxxx"; 818 819try { 820 appControl.deleteUninstallDisposedRule(appIdentifier, 1); 821} catch (error) { 822 let message = (error as BusinessError).message; 823 console.error('deleteUninstallDisposedRule failed ' + message); 824} 825``` 826 827## DisposedRule<sup>11+</sup> 828 829Defines a disposed rule. 830 831**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 832 833**System API**: This is a system API. 834 835| Name | Type | Readable| Writable| Description | 836| --------- | -------------- | ---- | ---- | --------------------------- | 837| want | [Want](js-apis-app-ability-want.md) | Yes | Yes | Page displayed when the application is disposed of.| 838| componentType | [ComponentType](#componenttype11) | Yes | Yes | Type of application component that functions as the displayed page.| 839| disposedType | [DisposedType](#disposedrule11) | Yes| Yes| Type of application disposal.| 840| controlType | [ControlType](#controltype11) | Yes| Yes| Control type of application disposal.| 841| elementList | Array\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes| Yes| List of application components to be disposed of or exempted.| 842| priority | number | Yes| Yes| Priority of the disposed rule.| 843 844### ComponentType<sup>11+</sup> 845 846Enumerates the types of application components that function as the displayed page. 847 848**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 849 850**System API**: This is a system API. 851 852| Name | Value | Description | 853| ------- | ---- | -------------------- | 854| UI_ABILITY | 1 | UIAbility component.| 855| UI_EXTENSION | 2 | UIExtensionAbility component.| 856 857### DisposedType<sup>11+</sup> 858 859Enumerates the types of application disposals. 860 861**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 862 863**System API**: This is a system API. 864 865| Name | Value | Description | 866| ------- | ---- | -------------------- | 867| BLOCK_APPLICATION | 1 | All abilities of the application are blocked. That is, the entire application is blocked.| 868| BLOCK_ABILITY | 2 | A specific ability of the application is blocked.| 869| NON_BLOCK | 3 | The application is not blocked.| 870 871### ControlType<sup>11+</sup> 872 873Enumerates the control type of application disposal. 874 875**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 876 877**System API**: This is a system API. 878 879| Name | Value | Description | 880| ------- | ---- | -------------------- | 881| ALLOWED_LIST | 1 | A trustlist is used, which means that the application components in the list are allowed to run.| 882| DISALLOWED_LIST | 2 | A blocklist is used, which means that the application components in the list are forbidden to run.| 883 884## UninstallDisposedRule<sup>15+</sup> 885 886Describes an uninstallation disposed rule. 887 888 **System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 889 890 **System API**: This is a system API. 891 892| Name | Type | Readable| Writable| Description | 893| --------- | -------------- | ---- | ---- | --------------------------- | 894| want | [Want](js-apis-app-ability-want.md) | Yes | Yes | Page displayed when the application is disposed of.| 895| UninstallComponentType | [UninstallComponentType](#uninstallcomponenttype15) | Yes | Yes | Type of the ability to start during interception.| 896| priority | number | Yes| Yes| Priority of the disposed rule.| 897 898### UninstallComponentType<sup>15+</sup> 899 900Enumerates the types of abilities during uninstallation. 901 902 **System capability**: SystemCapability.BundleManager.BundleFramework.AppControl 903 904 **System API**: This is a system API. 905 906| Name | Value | Description | 907| ------- | ---- | -------------------- | 908| EXTENSION | 1 | Extension ability.| 909