1e41f4b71Sopenharmony_ci# @ohos.bundle.overlay (overlay) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **overlay** module provides APIs for installing a [module with the overlay feature]((js-apis-overlay.md#module-with-the-overlay-feature), querying the [module information](js-apis-bundleManager-overlayModuleInfo.md), and disabling and enabling the module. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.bundle.overlay](js-apis-overlay.md). 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci``` ts 14e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## overlay.setOverlayEnabledByBundleName 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_cisetOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean): Promise\<void> 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciEnables or disables a module with the overlay feature in another application. This API uses a promise to return the result. If the operation is successful, the processing result is returned; otherwise, an error message is returned. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**System API**: This is a system API. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**Parameters** 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 32e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 33e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. | 34e41f4b71Sopenharmony_ci| moduleName | string | Yes | Name of the module with the overlay feature. | 35e41f4b71Sopenharmony_ci| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module. | 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**Return value** 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci| Type | Description | 40e41f4b71Sopenharmony_ci| ------------------------- | ------------------ | 41e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value. | 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci**Error codes** 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| ID | Error Message | 48e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 49e41f4b71Sopenharmony_ci| 201 | Permission denied. | 50e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 51e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 52e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 53e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 54e41f4b71Sopenharmony_ci| 17700032 | The specified bundle does not contain any overlay module. | 55e41f4b71Sopenharmony_ci| 17700033 | The specified module is not an overlay module. | 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci**Example** 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci```ts 60e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 61e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 62e41f4b71Sopenharmony_cilet bundleName = "com.example.myapplication_xxxxx"; 63e41f4b71Sopenharmony_cilet moduleName = "feature"; 64e41f4b71Sopenharmony_cilet isEnabled = false; 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_citry { 67e41f4b71Sopenharmony_ci overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled) 68e41f4b71Sopenharmony_ci .then((data) => { 69e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName successfully'); 70e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 71e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 72e41f4b71Sopenharmony_ci }); 73e41f4b71Sopenharmony_ci} catch (err) { 74e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 75e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 76e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message); 77e41f4b71Sopenharmony_ci} 78e41f4b71Sopenharmony_ci``` 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci## overlay.setOverlayEnabledByBundleName 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_cisetOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean, callback: AsyncCallback\<void>): void 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ciEnables or disables a module with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, the processing result is returned; otherwise, an error message is returned. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**System API**: This is a system API. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**Parameters** 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 95e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 96e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. | 97e41f4b71Sopenharmony_ci| moduleName | string | Yes | Name of the module with the overlay feature. | 98e41f4b71Sopenharmony_ci| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module. | 99e41f4b71Sopenharmony_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. | 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci**Error codes** 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci| ID | Error Message | 106e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 107e41f4b71Sopenharmony_ci| 201 | Permission denied. | 108e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 109e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 110e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 111e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 112e41f4b71Sopenharmony_ci| 17700032 | The specified bundle does not contain any overlay module. | 113e41f4b71Sopenharmony_ci| 17700033 | The specified module is not an overlay module. | 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci**Example** 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci```ts 118e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 119e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 120e41f4b71Sopenharmony_cilet bundleName = "com.example.myapplication_xxxxx"; 121e41f4b71Sopenharmony_cilet moduleName = "feature"; 122e41f4b71Sopenharmony_cilet isEnabled = false; 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_citry { 125e41f4b71Sopenharmony_ci overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled, (err, data) => { 126e41f4b71Sopenharmony_ci if (err) { 127e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 128e41f4b71Sopenharmony_ci return; 129e41f4b71Sopenharmony_ci } 130e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName successfully'); 131e41f4b71Sopenharmony_ci }); 132e41f4b71Sopenharmony_ci} catch (err) { 133e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 134e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 135e41f4b71Sopenharmony_ci console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message); 136e41f4b71Sopenharmony_ci} 137e41f4b71Sopenharmony_ci``` 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci## overlay.getOverlayModuleInfoByBundleName 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_cigetOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promise\<Array\<OverlayModuleInfo>> 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ciObtains the information about a module with the overlay feature in another application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci**System API**: This is a system API. 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci**Parameters** 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 154e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 155e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. | 156e41f4b71Sopenharmony_ci| moduleName | string | No | Name of the module with the overlay feature. By default, no value is passed, and the API obtains the information of all modules with the overlay feature in that application. | 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**Return value** 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci| Type | Description | 161e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------------------------------------ | 162e41f4b71Sopenharmony_ci| Promise\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Promise used to return the result, which is an array of [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. | 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci**Error codes** 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci| ID | Error Message | 169e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 170e41f4b71Sopenharmony_ci| 201 | Permission denied. | 171e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 172e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 173e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 174e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 175e41f4b71Sopenharmony_ci| 17700032 | The specified bundle does not contain any overlay module. | 176e41f4b71Sopenharmony_ci| 17700033 | The specified module is not an overlay module. | 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci**Example** 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci```ts 181e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 182e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 183e41f4b71Sopenharmony_cilet bundleName = "com.example.myapplication_xxxxx"; 184e41f4b71Sopenharmony_cilet moduleName = "feature"; 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci(async() => { 187e41f4b71Sopenharmony_ci try { 188e41f4b71Sopenharmony_ci let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName); 189e41f4b71Sopenharmony_ci console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); 190e41f4b71Sopenharmony_ci } catch(err) { 191e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 192e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 193e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message); 194e41f4b71Sopenharmony_ci } 195e41f4b71Sopenharmony_ci})(); 196e41f4b71Sopenharmony_ci``` 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci## overlay.getOverlayModuleInfoByBundleName 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_cigetOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callback: AsyncCallback\<Array\<OverlayModuleInfo>>): void 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ciObtains the information about a module with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**System API**: This is a system API. 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci**Parameters** 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 213e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 214e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. | 215e41f4b71Sopenharmony_ci| moduleName | string | Yes | Name of the module with the overlay feature. If this parameter is not specified, the API obtains the information of all modules with the overlay feature in that application. | 216e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Yes | Callback used to return the result, which is an array of [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci**Error codes** 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci| ID | Error Message | 223e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 224e41f4b71Sopenharmony_ci| 201 | Permission denied. | 225e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 226e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 227e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 228e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 229e41f4b71Sopenharmony_ci| 17700032 | The specified bundle does not contain any overlay module. | 230e41f4b71Sopenharmony_ci| 17700033 | The specified module is not an overlay module. | 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_ci**Example** 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci```ts 235e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 236e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 237e41f4b71Sopenharmony_cilet bundleName = "com.example.myapplication_xxxxx"; 238e41f4b71Sopenharmony_cilet moduleName = "feature"; 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_citry { 241e41f4b71Sopenharmony_ci overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName, (err, data) => { 242e41f4b71Sopenharmony_ci if (err) { 243e41f4b71Sopenharmony_ci console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 244e41f4b71Sopenharmony_ci return; 245e41f4b71Sopenharmony_ci } 246e41f4b71Sopenharmony_ci console.log('overlayModuleInfo is ' + JSON.stringify(data)); 247e41f4b71Sopenharmony_ci }); 248e41f4b71Sopenharmony_ci} catch (err) { 249e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 250e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 251e41f4b71Sopenharmony_ci console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 252e41f4b71Sopenharmony_ci} 253e41f4b71Sopenharmony_ci``` 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci## overlay.getOverlayModuleInfoByBundleName 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_cigetOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Array\<OverlayModuleInfo>>): void 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ciObtains the information about all modules with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci**System API**: This is a system API. 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci**Parameters** 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 270e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 271e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. | 272e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Yes | Callback used to return the result, which is an [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) object. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci**Error codes** 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ci| ID | Error Message | 279e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 280e41f4b71Sopenharmony_ci| 201 | Permission denied. | 281e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 282e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 283e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 284e41f4b71Sopenharmony_ci| 17700032 | The specified bundle does not contain any overlay module. | 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci**Example** 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci```ts 289e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 290e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 291e41f4b71Sopenharmony_cilet bundleName = "com.example.myapplication_xxxxx"; 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_citry { 294e41f4b71Sopenharmony_ci overlay.getOverlayModuleInfoByBundleName(bundleName, (err, data) => { 295e41f4b71Sopenharmony_ci if (err) { 296e41f4b71Sopenharmony_ci console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 297e41f4b71Sopenharmony_ci return; 298e41f4b71Sopenharmony_ci } 299e41f4b71Sopenharmony_ci console.log('overlayModuleInfo is ' + JSON.stringify(data)); 300e41f4b71Sopenharmony_ci }); 301e41f4b71Sopenharmony_ci} catch (err) { 302e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 303e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 304e41f4b71Sopenharmony_ci console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 305e41f4b71Sopenharmony_ci} 306e41f4b71Sopenharmony_ci``` 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci## overlay.getTargetOverlayModuleInfosByBundleName 309e41f4b71Sopenharmony_ci 310e41f4b71Sopenharmony_cigetTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: string): Promise\<Array\<OverlayModuleInfo>> 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ciObtains the information about modules with the overlay feature in another application based on the target module name. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci**System API**: This is a system API. 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci**Parameters** 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 323e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 324e41f4b71Sopenharmony_ci| targetBundleName | string | Yes | Bundle name of the application. | 325e41f4b71Sopenharmony_ci| moduleName | string | No | Name of the target module, which is **targetModuleName** specified by modules with the overlay feature. By default, no value is passed, and the API obtains the information associated with all modules in that application. | 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**Return value** 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci| Type | Description | 330e41f4b71Sopenharmony_ci| ------------------------- | ------------------ | 331e41f4b71Sopenharmony_ci| Promise\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Promise used to return the result, which is an array of [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. | 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci**Error codes** 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci| ID | Error Message | 338e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 339e41f4b71Sopenharmony_ci| 201 | Permission denied. | 340e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 341e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 342e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 343e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 344e41f4b71Sopenharmony_ci| 17700034 | The specified module is an overlay module. | 345e41f4b71Sopenharmony_ci| 17700035 | The specified bundle is an overlay bundle. | 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci**Example** 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci```ts 350e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 351e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 352e41f4b71Sopenharmony_cilet targetBundleName = "com.example.myapplication_xxxxx"; 353e41f4b71Sopenharmony_cilet moduleName = "feature"; 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ci(async() => { 356e41f4b71Sopenharmony_ci try { 357e41f4b71Sopenharmony_ci let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName); 358e41f4b71Sopenharmony_ci console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); 359e41f4b71Sopenharmony_ci } catch(err) { 360e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 361e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 362e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 363e41f4b71Sopenharmony_ci } 364e41f4b71Sopenharmony_ci})(); 365e41f4b71Sopenharmony_ci``` 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci## overlay.getTargetOverlayModuleInfosByBundleName 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_cigetTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: string, callback: AsyncCallback<Array<OverlayModuleInfo>>): void 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ciObtains the information about modules with the overlay feature in another application based on the target module name. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci**System API**: This is a system API. 378e41f4b71Sopenharmony_ci 379e41f4b71Sopenharmony_ci**Parameters** 380e41f4b71Sopenharmony_ci 381e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 382e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 383e41f4b71Sopenharmony_ci| targetBundleName | string | Yes | Bundle name of the application. | 384e41f4b71Sopenharmony_ci| moduleName | string | Yes | Name of the target module, which is **targetModuleName** specified by modules with the overlay feature. If this parameter is not specified, the API obtains the information associated with all modules in that application. | 385e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Yes | Callback used to return the result, which is an array of [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ci**Error codes** 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci| ID | Error Message | 392e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 393e41f4b71Sopenharmony_ci| 201 | Permission denied. | 394e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 395e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 396e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 397e41f4b71Sopenharmony_ci| 17700002 | The specified module name is not found. | 398e41f4b71Sopenharmony_ci| 17700034 | The specified module is an overlay module. | 399e41f4b71Sopenharmony_ci| 17700035 | The specified bundle is an overlay bundle. | 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**Example** 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci```ts 404e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 405e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 406e41f4b71Sopenharmony_cilet targetBundleName = "com.example.myapplication_xxxxx"; 407e41f4b71Sopenharmony_cilet moduleName = "feature"; 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_citry { 410e41f4b71Sopenharmony_ci overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName, (err, data) => { 411e41f4b71Sopenharmony_ci if (err) { 412e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 413e41f4b71Sopenharmony_ci return; 414e41f4b71Sopenharmony_ci } 415e41f4b71Sopenharmony_ci console.log('overlayModuleInfo is ' + JSON.stringify(data)); 416e41f4b71Sopenharmony_ci }); 417e41f4b71Sopenharmony_ci} catch (err) { 418e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 419e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 420e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 421e41f4b71Sopenharmony_ci} 422e41f4b71Sopenharmony_ci``` 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci## overlay.getTargetOverlayModuleInfosByBundleName 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_cigetTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: AsyncCallback<Array<OverlayModuleInfo>>): void 427e41f4b71Sopenharmony_ci 428e41f4b71Sopenharmony_ciObtains the information about all modules with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ci**System API**: This is a system API. 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci**Parameters** 437e41f4b71Sopenharmony_ci 438e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 439e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------------------------- | 440e41f4b71Sopenharmony_ci| targetBundleName | string | Yes | Bundle name of the application. | 441e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Yes | Callback used to return the result, which is an array of [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ci**Error codes** 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci| ID | Error Message | 448e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | 449e41f4b71Sopenharmony_ci| 201 | Permission denied. | 450e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. | 451e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 452e41f4b71Sopenharmony_ci| 17700001 | The specified bundleName is not found. | 453e41f4b71Sopenharmony_ci| 17700035 | The specified bundle is an overlay bundle. | 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci**Example** 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ci```ts 458e41f4b71Sopenharmony_ciimport { overlay } from '@kit.AbilityKit'; 459e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 460e41f4b71Sopenharmony_cilet targetBundleName = "com.example.myapplication_xxxxx"; 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_citry { 463e41f4b71Sopenharmony_ci overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, (err, data) => { 464e41f4b71Sopenharmony_ci if (err) { 465e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 466e41f4b71Sopenharmony_ci return; 467e41f4b71Sopenharmony_ci } 468e41f4b71Sopenharmony_ci console.log('overlayModuleInfo is ' + JSON.stringify(data)); 469e41f4b71Sopenharmony_ci }); 470e41f4b71Sopenharmony_ci} catch (err) { 471e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 472e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 473e41f4b71Sopenharmony_ci console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 474e41f4b71Sopenharmony_ci} 475e41f4b71Sopenharmony_ci``` 476