1# @ohos.bundle.overlay (overlay) 2 3The **overlay** module provides APIs for installing a [module with the overlay feature](#module-with-the-overlay-feature), querying the [module information](js-apis-bundleManager-overlayModuleInfo.md), and disabling and enabling the module. 4 5> **NOTE** 6> 7> 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. 8 9## Modules to Import 10 11``` ts 12import overlay from '@ohos.bundle.overlay'; 13``` 14 15## overlay.setOverlayEnabled 16 17setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\<void> 18 19Enables or disables a module with the overlay feature in the current application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 20 21**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 22 23**Parameters** 24 25| Name | Type | Mandatory | Description | 26| ----------- | ------ | ---- | --------------------------------------- | 27| moduleName | string | Yes | HAP name of the module with the overlay feature. | 28| 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.| 29 30**Return value** 31 32| Type | Description | 33| ------------------------- | ------------------ | 34| Promise\<void> | Promise that returns no value.| 35 36**Error codes** 37 38For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 39 40| ID| Error Message | 41| ------ | -------------------------------------- | 42| 17700002 | The specified module name is not found. | 43| 17700033 | The specified module is not an overlay module. | 44 45**Example** 46 47```ts 48import overlay from '@ohos.bundle.overlay'; 49import { BusinessError } from '@ohos.base'; 50let moduleName = "feature"; 51let isEnabled = false; 52 53try { 54 overlay.setOverlayEnabled(moduleName, isEnabled) 55 .then(() => { 56 console.info('setOverlayEnabled success'); 57 }).catch((err: BusinessError) => { 58 console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 59 }); 60} catch (err) { 61 let code = (err as BusinessError).code; 62 let message = (err as BusinessError).message; 63 console.info('setOverlayEnabled failed due to err code: ' + code + ' ' + 'message:' + message); 64} 65``` 66 67## overlay.setOverlayEnabled 68 69setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback\<void>): void 70 71Enables or disables a module with the overlay feature in the current 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. 72 73**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 74 75**Parameters** 76 77| Name | Type | Mandatory | Description | 78| ----------- | ------ | ---- | --------------------------------------- | 79| moduleName | string | Yes | HAP name of the module with the overlay feature. | 80| 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.| 81| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 82 83**Error codes** 84 85For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 86 87| ID| Error Message | 88| ------ | -------------------------------------- | 89| 17700002 | The specified module name is not found. | 90| 17700033 | The specified module is not an overlay module. | 91 92**Example** 93 94```ts 95import overlay from '@ohos.bundle.overlay'; 96import { BusinessError } from '@ohos.base'; 97let moduleName = "feature"; 98let isEnabled = false; 99 100try { 101 overlay.setOverlayEnabled(moduleName, isEnabled, (err, data) => { 102 if (err) { 103 console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 104 return; 105 } 106 console.info('setOverlayEnabled success'); 107 }); 108} catch (err) { 109 let code = (err as BusinessError).code; 110 let message = (err as BusinessError).message; 111 console.info('setOverlayEnabled failed due to err code: ' + code + ' ' + 'message:' + message); 112} 113``` 114 115## overlay.setOverlayEnabledByBundleName 116 117setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean): Promise\<void> 118 119Enables 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. 120 121**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE 122 123**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 124 125**System API**: This is a system API. 126 127**Parameters** 128 129| Name | Type | Mandatory | Description | 130| ----------- | ------ | ---- | --------------------------------------- | 131| bundleName | string | Yes | Bundle name of the application. | 132| moduleName | string | Yes | HAP name of the module with the overlay feature. | 133| 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.| 134 135**Return value** 136 137| Type | Description | 138| ------------------------- | ------------------ | 139| Promise\<void> | Promise that returns no value.| 140 141**Error codes** 142 143For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 144 145| ID| Error Message | 146| ------ | -------------------------------------- | 147| 17700001 | The specified bundleName is not found. | 148| 17700002 | The specified module name is not found. | 149| 17700032 | The specified bundle does not contain any overlay module. | 150| 17700033 | The specified module is not an overlay module. | 151 152**Example** 153 154```ts 155import overlay from '@ohos.bundle.overlay'; 156import { BusinessError } from '@ohos.base'; 157let bundleName = "com.example.myapplication_xxxxx"; 158let moduleName = "feature"; 159let isEnabled = false; 160 161try { 162 overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled) 163 .then((data) => { 164 console.info('setOverlayEnabledByBundleName successfully'); 165 }).catch((err: BusinessError) => { 166 console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 167 }); 168} catch (err) { 169 let code = (err as BusinessError).code; 170 let message = (err as BusinessError).message; 171 console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message); 172} 173``` 174 175## overlay.setOverlayEnabledByBundleName 176 177setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean, callback: AsyncCallback\<void>): void 178 179Enables 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. 180 181**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE 182 183**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 184 185**System API**: This is a system API. 186 187**Parameters** 188 189| Name | Type | Mandatory | Description | 190| ----------- | ------ | ---- | --------------------------------------- | 191| bundleName | string | Yes | Bundle name of the application. | 192| moduleName | string | Yes | HAP name of the module with the overlay feature. | 193| 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.| 194| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 195 196**Error codes** 197 198For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 199 200| ID| Error Message | 201| ------ | -------------------------------------- | 202| 17700001 | The specified bundleName is not found. | 203| 17700002 | The specified module name is not found. | 204| 17700032 | The specified bundle does not contain any overlay module. | 205| 17700033 | The specified module is not an overlay module. | 206 207**Example** 208 209```ts 210import overlay from '@ohos.bundle.overlay'; 211import { BusinessError } from '@ohos.base'; 212let bundleName = "com.example.myapplication_xxxxx"; 213let moduleName = "feature"; 214let isEnabled = false; 215 216try { 217 overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled, (err, data) => { 218 if (err) { 219 console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); 220 return; 221 } 222 console.info('setOverlayEnabledByBundleName successfully'); 223 }); 224} catch (err) { 225 let code = (err as BusinessError).code; 226 let message = (err as BusinessError).message; 227 console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message); 228} 229``` 230 231## overlay.getOverlayModuleInfo 232 233getOverlayModuleInfo(moduleName: string): Promise\<OverlayModuleInfo> 234 235Obtains the information about a module with the overlay feature in the current application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. 236 237**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 238 239**Parameters** 240 241| Name | Type | Mandatory | Description | 242| ----------- | ------ | ---- | ------------------------------------------ | 243| moduleName | string | Yes | HAP name of the module with the overlay feature. | 244 245**Return value** 246 247| Type | Description | 248| ------------------------- | ------------------ | 249| Promise\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)> | Promise used to return the result, which is an [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) object.| 250 251**Error codes** 252 253For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 254 255| ID| Error Message | 256| ------ | -------------------------------------- | 257| 17700002 | The specified module name is not found. | 258| 17700032 | The specified bundle does not contain any overlay module. | 259| 17700033 | The specified module is not an overlay module. | 260 261**Example** 262 263```ts 264import overlay from '@ohos.bundle.overlay'; 265import { BusinessError } from '@ohos.base'; 266let moduleName = "feature"; 267 268(async() => { 269 try { 270 let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName); 271 console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo)); 272 } catch(err) { 273 let code = (err as BusinessError).code; 274 let message = (err as BusinessError).message; 275 console.log('getOverlayModuleInfo failed due to err code : ' + code + ' ' + 'message :' + message); 276 } 277})(); 278``` 279 280## overlay.getOverlayModuleInfo 281 282getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\<OverlayModuleInfo>): void 283 284Obtains the information about a module with the overlay feature in the current 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. 285 286**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 287 288**Parameters** 289 290| Name | Type | Mandatory | Description | 291| ----------- | ------ | ---- | --------------------------------------- | 292| moduleName | string | Yes | HAP name of the module with the overlay feature. | 293| callback | AsyncCallback\<[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. | 294 295**Error codes** 296 297For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 298 299| ID| Error Message | 300| ------ | -------------------------------------- | 301| 17700002 | The specified module name is not found. | 302| 17700032 | The specified bundle does not contain any overlay module. | 303| 17700033 | The specified module is not an overlay module. | 304 305**Example** 306 307```ts 308import overlay from '@ohos.bundle.overlay'; 309import { BusinessError } from '@ohos.base'; 310let moduleName = "feature"; 311try { 312 overlay.getOverlayModuleInfo(moduleName, (err, data) => { 313 if (err) { 314 console.log('getOverlayModuleInfo failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 315 return; 316 } 317 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 318 }); 319} catch (err) { 320 let code = (err as BusinessError).code; 321 let message = (err as BusinessError).message; 322 console.log('getOverlayModuleInfo failed due to err code : ' + code + ' ' + 'message :' + message); 323} 324``` 325 326## overlay.getTargetOverlayModuleInfos 327 328getTargetOverlayModuleInfos(targetModuleName: string): Promise\<Array\<OverlayModuleInfo>> 329 330Obtains the information about modules with the overlay feature in the current 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. 331 332**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 333 334**Parameters** 335 336| Name | Type | Mandatory | Description | 337| ----------- | ------ | ---- | --------------------------------------- | 338| targetModuleName | string | Yes | HAP name of the target module, which is **targetModuleName** specified by modules with the overlay feature. | 339 340**Return value** 341 342| Type | Description | 343| ------------------------------------------------------------ | ------------------------------------------------------------ | 344| 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.| 345 346**Error codes** 347 348For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 349 350| ID| Error Message | 351| ------ | -------------------------------------- | 352| 17700002 | The specified module name is not found. | 353| 17700034 | The specified module is an overlay module. | 354 355**Example** 356 357```ts 358import overlay from '@ohos.bundle.overlay'; 359import { BusinessError } from '@ohos.base'; 360let targetModuleName = "feature"; 361 362(async() => { 363 try { 364 let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName); 365 console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); 366 } catch(err) { 367 let code = (err as BusinessError).code; 368 let message = (err as BusinessError).message; 369 console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message); 370 } 371})(); 372``` 373 374## overlay.getTargetOverlayModuleInfos 375 376getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\<Array\<OverlayModuleInfo>>): void 377 378Obtains the information about modules with the overlay feature in the current 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. 379 380**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 381 382**Parameters** 383 384| Name | Type | Mandatory | Description | 385| ----------- | ------ | ---- | --------------------------------------- | 386| targetModuleName | string | Yes | HAP name of the target module specified by modules with the overlay feature. | 387| 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. | 388 389**Error codes** 390 391For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 392 393| ID| Error Message | 394| ------ | -------------------------------------- | 395| 17700002 | The specified module name is not found. | 396| 17700034 | The specified module is an overlay module. | 397 398**Example** 399 400```ts 401import overlay from '@ohos.bundle.overlay'; 402import { BusinessError } from '@ohos.base'; 403let targetModuleName = "feature"; 404try { 405 overlay.getTargetOverlayModuleInfos(targetModuleName, (err, data) => { 406 if (err) { 407 console.log('getTargetOverlayModuleInfos failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 408 return; 409 } 410 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 411 }); 412} catch (err) { 413 let code = (err as BusinessError).code; 414 let message = (err as BusinessError).message; 415 console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message); 416} 417``` 418 419## overlay.getOverlayModuleInfoByBundleName 420 421getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promise\<Array\<OverlayModuleInfo>> 422 423Obtains 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. 424 425**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 426 427**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 428 429**System API**: This is a system API. 430 431**Parameters** 432 433| Name | Type | Mandatory | Description | 434| ----------- | ------ | ---- | --------------------------------------- | 435| bundleName | string | Yes | Bundle name of the application. | 436| moduleName | string | No | HAP 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. | 437 438**Return value** 439 440| Type | Description | 441| ------------------------------------------------------------ | ------------------------------------------------------------ | 442| 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.| 443 444**Error codes** 445 446For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 447 448| ID| Error Message | 449| ------ | -------------------------------------- | 450| 17700001 | The specified bundleName is not found. | 451| 17700002 | The specified module name is not found. | 452| 17700032 | The specified bundle does not contain any overlay module. | 453| 17700033 | The specified module is not an overlay module. | 454 455**Example** 456 457```ts 458import overlay from '@ohos.bundle.overlay'; 459import { BusinessError } from '@ohos.base'; 460let bundleName = "com.example.myapplication_xxxxx"; 461let moduleName = "feature"; 462 463(async() => { 464 try { 465 let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName); 466 console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); 467 } catch(err) { 468 let code = (err as BusinessError).code; 469 let message = (err as BusinessError).message; 470 console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message); 471 } 472})(); 473``` 474 475## overlay.getOverlayModuleInfoByBundleName 476 477getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callback: AsyncCallback\<Array\<OverlayModuleInfo>>): void 478 479Obtains 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. 480 481**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 482 483**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 484 485**System API**: This is a system API. 486 487**Parameters** 488 489| Name | Type | Mandatory | Description | 490| ----------- | ------ | ---- | --------------------------------------- | 491| bundleName | string | Yes | Bundle name of the application. | 492| moduleName | string | Yes | HAP 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. | 493| 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. | 494 495**Error codes** 496 497For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 498 499| ID| Error Message | 500| ------ | -------------------------------------- | 501| 17700001 | The specified bundleName is not found. | 502| 17700002 | The specified module name is not found. | 503| 17700032 | The specified bundle does not contain any overlay module. | 504| 17700033 | The specified module is not an overlay module. | 505 506**Example** 507 508```ts 509import overlay from '@ohos.bundle.overlay'; 510import { BusinessError } from '@ohos.base'; 511let bundleName = "com.example.myapplication_xxxxx"; 512let moduleName = "feature"; 513 514try { 515 overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName, (err, data) => { 516 if (err) { 517 console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 518 return; 519 } 520 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 521 }); 522} catch (err) { 523 let code = (err as BusinessError).code; 524 let message = (err as BusinessError).message; 525 console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 526} 527``` 528 529## overlay.getOverlayModuleInfoByBundleName 530 531getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Array\<OverlayModuleInfo>>): void 532 533Obtains 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. 534 535**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 536 537**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 538 539**System API**: This is a system API. 540 541**Parameters** 542 543| Name | Type | Mandatory | Description | 544| ----------- | ------ | ---- | --------------------------------------- | 545| bundleName | string | Yes | Bundle name of the application. | 546| 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) object. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 547 548**Error codes** 549 550For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 551 552| ID| Error Message | 553| ------ | -------------------------------------- | 554| 17700001 | The specified bundleName is not found. | 555| 17700032 | The specified bundle does not contain any overlay module. | 556 557**Example** 558 559```ts 560import overlay from '@ohos.bundle.overlay'; 561import { BusinessError } from '@ohos.base'; 562let bundleName = "com.example.myapplication_xxxxx"; 563 564try { 565 overlay.getOverlayModuleInfoByBundleName(bundleName, (err, data) => { 566 if (err) { 567 console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 568 return; 569 } 570 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 571 }); 572} catch (err) { 573 let code = (err as BusinessError).code; 574 let message = (err as BusinessError).message; 575 console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 576} 577``` 578 579## overlay.getTargetOverlayModuleInfosByBundleName 580 581getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: string): Promise\<Array\<OverlayModuleInfo>> 582 583Obtains 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. 584 585**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 586 587**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 588 589**System API**: This is a system API. 590 591**Parameters** 592 593| Name | Type | Mandatory | Description | 594| ----------- | ------ | ---- | --------------------------------------- | 595| targetBundleName | string | Yes | Bundle name of the application. | 596| moduleName | string | No | HAP 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. | 597 598**Return value** 599 600| Type | Description | 601| ------------------------- | ------------------ | 602| 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.| 603 604**Error codes** 605 606For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 607 608| ID| Error Message | 609| ------ | -------------------------------------- | 610| 17700001 | The specified bundleName is not found. | 611| 17700002 | The specified module name is not found. | 612| 17700034 | The specified module is an overlay module. | 613| 17700035 | The specified bundle is an overlay bundle. | 614 615**Example** 616 617```ts 618import overlay from '@ohos.bundle.overlay'; 619import { BusinessError } from '@ohos.base'; 620let targetBundleName = "com.example.myapplication_xxxxx"; 621let moduleName = "feature"; 622 623(async() => { 624 try { 625 let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName); 626 console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); 627 } catch(err) { 628 let code = (err as BusinessError).code; 629 let message = (err as BusinessError).message; 630 console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 631 } 632})(); 633``` 634 635## overlay.getTargetOverlayModuleInfosByBundleName 636 637getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: string, callback: AsyncCallback<Array<OverlayModuleInfo>>): void 638 639Obtains 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. 640 641**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 642 643**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 644 645**System API**: This is a system API. 646 647**Parameters** 648 649| Name | Type | Mandatory | Description | 650| ----------- | ------ | ---- | --------------------------------------- | 651| targetBundleName | string | Yes | Bundle name of the application. | 652| moduleName | string | Yes | HAP 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. | 653| callback | AsyncCallback\<Array\<[OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)>> | Yes | Callback used to return the result, which is an array of the [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md) objects. If the operation is successful, **err** is **null**; otherwise, **err** is an error object. | 654 655**Error codes** 656 657For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 658 659| ID| Error Message | 660| ------ | -------------------------------------- | 661| 17700001 | The specified bundleName is not found. | 662| 17700002 | The specified module name is not found. | 663| 17700034 | The specified module is an overlay module. | 664| 17700035 | The specified bundle is an overlay bundle. | 665 666**Example** 667 668```ts 669import overlay from '@ohos.bundle.overlay'; 670import { BusinessError } from '@ohos.base'; 671let targetBundleName = "com.example.myapplication_xxxxx"; 672let moduleName = "feature"; 673 674try { 675 overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName, (err, data) => { 676 if (err) { 677 console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 678 return; 679 } 680 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 681 }); 682} catch (err) { 683 let code = (err as BusinessError).code; 684 let message = (err as BusinessError).message; 685 console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 686} 687``` 688 689## overlay.getTargetOverlayModuleInfosByBundleName 690 691getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: AsyncCallback<Array<OverlayModuleInfo>>): void 692 693Obtains 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. 694 695**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 696 697**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay 698 699**System API**: This is a system API. 700 701**Parameters** 702 703| Name | Type | Mandatory | Description | 704| ----------- | ------ | ---- | --------------------------------------- | 705| targetBundleName | string | Yes | Bundle name of the application. | 706| 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. | 707 708**Error codes** 709 710For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). 711 712| ID| Error Message | 713| ------ | -------------------------------------- | 714| 17700001 | The specified bundleName is not found. | 715| 17700035 | The specified bundle is an overlay bundle. | 716 717**Example** 718 719```ts 720import overlay from '@ohos.bundle.overlay'; 721import { BusinessError } from '@ohos.base'; 722let targetBundleName = "com.example.myapplication_xxxxx"; 723 724try { 725 overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, (err, data) => { 726 if (err) { 727 console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); 728 return; 729 } 730 console.log('overlayModuleInfo is ' + JSON.stringify(data)); 731 }); 732} catch (err) { 733 let code = (err as BusinessError).code; 734 let message = (err as BusinessError).message; 735 console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message); 736} 737``` 738 739## Module with the Overlay Feature 740 741**Concept** 742A module with the overlay feature generally provides additional resource files for modules without the overlay feature on the device, so that the target modules can use these resource files at runtime to display different colors, labels, themes, and the like. The overlay feature applies only to the stage model. 743 744**How do I identify a module with the overlay feature?** 745If the **module.json5** file of a module contains the **targetModuleName** and **targetPriority fields** during project creation on DevEco Studio, the module is identified as a module with the overlay feature in the installation phase. 746