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