From fba717e67c4e167771d395a7046451646da7bff6 Mon Sep 17 00:00:00 2001 From: Gloria Date: Tue, 21 Mar 2023 16:36:55 +0800 Subject: [PATCH] Update docs against 15350+16254 Signed-off-by: wusongqing --- ...js-apis-bundleManager-overlayModuleInfo.md | 19 + .../reference/apis/js-apis-overlay.md | 693 ++++++++++++++++++ .../reference/errorcodes/errorcode-bundle.md | 152 +++- 3 files changed, 858 insertions(+), 6 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-overlay.md diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md new file mode 100644 index 0000000000..5e16b3342c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md @@ -0,0 +1,19 @@ +# OverlayModuleInfo + +> **NOTE** +> +> 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. + +The **OverlayModuleInfo** module provides information about a module with the overlay feature. A system application can obtain such information of the specified application through [overlay.getOverlayModuleInfoByBundleName](js-apis-overlay.md#overlaygetoverlaymoduleinfobybundlename), and a third-party application can obtain such information of the current application through [overlay.getOverlayModuleInfo](js-apis-overlay.md#overlaygetoverlaymoduleinfo). + +## OverlayModuleInfo + + **System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +| Name | Type | Readable| Writable| Description | +| --------------------- | ---------------------------------------------------| ---- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | No | Bundle name of the application to which the module with the overlay feature belongs. | +| moduleName | string | Yes | No | HAP name of the module with the overlay feature. | +| targetModuleName | string | Yes | No | HAP name of the target module specified by the module with the overlay feature. | +| priority | number | Yes | No | Priority of the module with the overlay feature. | +| state | number | Yes | No | Whether the module with the overlay feature is disabled. The value **0** means that the module is disabled, and **1** means the opposite. | diff --git a/en/application-dev/reference/apis/js-apis-overlay.md b/en/application-dev/reference/apis/js-apis-overlay.md new file mode 100644 index 0000000000..61181d1767 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-overlay.md @@ -0,0 +1,693 @@ +# @ohos.bundle.overlay (overlay) + +The **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. + +> **NOTE** +> +> 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. +> +> The APIs provided by this module are system APIs. + +## Modules to Import + +``` ts +import overlay from '@ohos.bundle.overlay' +``` + +## overlay.setOverlayEnabled + +setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\; + +Enables 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| 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.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature"; +var isEnabled = false; + +try { + overlay.setOverlayEnabled(moduleName, isEnabled) + .then(() => { + console.info('setOverlayEnabled success'); + }).catch((error) => { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + }); +} catch (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabled + +setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback\): void; + +Enables 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| 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.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature"; +var isEnabled = false; + +try { + overlay.setOverlayEnabled(moduleName, isEnabled, (error, data) => { + if (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + return; + } + console.info('setOverlayEnabled success'); + }); +} catch (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabledByBundleName + +setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean): Promise\; + +Enables 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. + +**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| bundleName | string | Yes | Bundle name of the application. | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| 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.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" +var isEnabled = false; + +try { + overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled) + .then((data) => { + console.info('setOverlayEnabledByBundleName successfully'); + }).catch((error) => { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + }); +} catch (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabledByBundleName + +setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean, callback: AsyncCallback\): void; + +Enables 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. + +**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| bundleName | string | Yes | Bundle name of the application. | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| 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.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the processing result obtained; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" +var isEnabled = false; + +try { + overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled, (error, data) => { + if (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + return; + } + console.info('setOverlayEnabledByBundleName successfully'); + }); +} catch (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.getOverlayModuleInfo + +getOverlayModuleInfo(moduleName: string): Promise\; + +Obtains 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | ------------------------------------------ | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the result, which is an **OverlayModuleInfo** object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName); + console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo)); + } catch(err) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getOverlayModuleInfo + +getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\): void; + +Obtains 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| callback | AsyncCallback\ | Yes | Callback used to return the result, which is an **OverlayModuleInfo** object. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature" +try { + overlay.getOverlayModuleInfo(moduleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfos + +getTargetOverlayModuleInfos(targetModuleName: string): Promise\>; + +Obtains 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetModuleName | string | Yes | HAP name of the target module, which is **targetModuleName** specified by modules with the overlay feature. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | + +**Example** + +```ts +var targetModuleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getTargetOverlayModuleInfos + +getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\>): void; + +Obtains 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. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetModuleName | string | Yes | HAP name of the target module specified by modules with the overlay feature. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | + +**Example** + +```ts +var targetModuleName = "feature" +try { + overlay.getTargetOverlayModuleInfos(targetModuleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promise\>; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| bundleName | string | Yes | Bundle name of the application. | +| moduleName | string | No | 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. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callback: AsyncCallback\>): void; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| bundleName | string | Yes | Bundle name of the application. | +| 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. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +try { + overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\>): void; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| bundleName | string | Yes | Bundle name of the application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; + +try { + overlay.getOverlayModuleInfoByBundleName(bundleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: string): Promise\>; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| moduleName | string | No | 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. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: string, callback: AsyncCallback\>): void; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| moduleName | string | No | 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. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +try { + overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: AsyncCallback\>): void; + +Obtains 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. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; + +try { + overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## Module with the Overlay Feature + +**Concept** +A 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. + +**How do I identify a module with the overlay feature?** +If 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. diff --git a/en/application-dev/reference/errorcodes/errorcode-bundle.md b/en/application-dev/reference/errorcodes/errorcode-bundle.md index fa35bc1da8..0787c1a765 100644 --- a/en/application-dev/reference/errorcodes/errorcode-bundle.md +++ b/en/application-dev/reference/errorcodes/errorcode-bundle.md @@ -16,7 +16,6 @@ When a query API is called, the bundle name passed in does not exist. 2. The corresponding bundle is not installed. **Solution** - 1. Check whether the spelling of the bundle name is correct. 2. Check whether the corresponding bundle is installed. @@ -125,7 +124,6 @@ When an API of the **distributedBundle** module is called, the device ID passed 2. The device ID does not exist. **Solution** - 1. Check whether the device ID is correct. 2. Check whether the device ID exists. @@ -140,13 +138,11 @@ Failed to install the HAP because the HAP fails to be parsed. When the **install** API of the **installer** module is called, the HAP passed in fails to be parsed. **Possible Causes** - 1. The HAP is not in ZIP format. 2. The configuration file in the HAP is not in JSON format. 3. Necessary fields are missing in the configuration file. **Solution** - 1. Check whether the HAP is in ZIP format. 2. Check whether the configuration file is in [JSON format](../../quick-start/application-configuration-file-overview-stage.md). 3. Check whether an error message is displayed when DevEco Studio compiles the HAP. If necessary fields are missing, an error message will be displayed. @@ -170,7 +166,7 @@ Calling the **install** API of the **installer** module to install the bundle fa **Solution** 1. Check whether the HAP is signed. -2. Ensure that the signature certificate of the HAP is applied for from the application market. +2. Ensure that the signing certificate of the HAP is applied for from the application market. 3. Check whether the same certificate is used for signing multiple HAPs. 4. Check whether the certificate used for signing the upgrade HAP is the same as the certificate used for signing the installed HAP. @@ -248,6 +244,24 @@ The version number is earlier than the version in use. Ensure that the version of the bundle to install is not earlier than the version in use. +## 17700018 Bundle Installation Failure Because the Dependent Module Does Not Exist + +**Error Message** + +Failed to install because the dependent module does not exist. + +**Description** + +The dependent module does not exist during the HAP or HPS installation. + +**Possible Causes** + +The dependent module is not installed. + +**Solution** + +Install the dependent modules first. + ## 17700020 Failure to Uninstall Preinstalled Applications **Error Message** @@ -259,6 +273,7 @@ The preinstalled app cannot be uninstalled. Calling the **uninstall** API of the **installer** module to uninstall a preinstalled application fails. **Possible Causes** + 1. You might want to uninstall a non-preinstalled application but passed the bundle name of a preinstalled app. 2. The preinstalled application cannot be uninstalled. @@ -331,6 +346,7 @@ Failed to get the profile because there is no profile in the HAP. When an API for querying the profile is called, the configuration file does not exist **Possible Causes** + 1. The metadata name passed in the API does not exist in the configuration file. 2. The content of the configuration file is not in JSON format. @@ -444,7 +460,7 @@ The application is a system application and the **AllowAppDataNotCleared** field **Solution** 1. Check whether the application is a system application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **isSystemApp** is **true**. -2. Check whether the **AllowAppDataNotCleared field** is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**. +2. Check whether the **AllowAppDataNotCleared** field is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**. ## 17700031 HAP Installation Fails Due to Overlay Feature Verification Failure @@ -468,4 +484,128 @@ The target application and the to-be-installed application with the overlay feat 3. Ensure that the target application is not an application with the overlay feature. 4. Ensure that the target module is not a module with the overlay feature. +## 17700032 Application Does Not Contain a Module with the Overlay Feature + +**Error Message** + +The specified bundle does not contain any overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object of another application, but that application does not contain a module with the overlay feature. + +**Possible Causes** + +The specified application does not contain a module with the overlay feature. + +**Solution** + +Check whether the application contains a module with the overlay feature. + +## 17700033 Module Is Not Configured with the Overlay Feature + +**Error Message** + +The specified module is not overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object of a module, but the module is not configured with the overlay feature. + +**Possible Causes** + +The specified module is not a module with the overlay feature. + +**Solution** + +Check whether the module is configured with the overlay feature. + +## 17700034 Module Is Configured with the Overlay Feature + +**Error Message** + +The specified module is overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object based on the target module name, but that module is configured with the overlay feature. + +**Possible Causes** + +The specified module is configured with the overlay feature. + +**Solution** + +Check whether the specified module is configured with the overlay feature. + +## 17700035 Application Contains Only Modules with the Overlay Feature + +**Error Message** + +The specified bundle is overlay bundle. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object based on the target module name of another application, but that application contains only modules with the overlay feature. + +**Possible Causes** + +The specified application contains only modules with the overlay feature. + +**Solution** + +Check whether the application contains only modules with the overlay feature. + +## 17700036 Failure in Installing the Shared Library Because of No AllowAppShareLibrary Privilege + +**Error Message** + +Failed to install because without allow app shared bundle permission. + +**Description** + +The shared library is not configured with the **AllowAppShareLibrary** privilege, resulting in security and privacy risks. As a result, the installation fails. + +**Possible Causes** + +The shared library does not request the **AllowAppShareLibrary** privilege before being released. + +**Solution** + +Configure the **AllowAppShareLibrary** privilege for the shared library, re-sign the library, and release it. + +## 17700037 Failure in Uninstalling the Shared Library Due to Dependency + +**Error Message** + +The version of shared bundle is dependent on other applications. + +**Description** + +Other applications depend on the shared library, causing the uninstallation to fail. + +**Possible Causes** +1. The version specified during the uninstallation is the latest version of the shared library, and the shared library is depended on by other applications. +2. No version is not specified during the uninstallation, meaning that all versions of the shared library will be uninstalled, and the shared library is depended on by other applications. + +**Solution** +1. Check whether the shared library to uninstall is depended on by other applications. +2. Check whether the version of the shared library to uninstall is the latest version of the shared library. + +## 17700038 Shared Library to Uninstall Does Not Exist + +**Error Message** + +The specified shared bundle does not exist. +**Description** + +The shared library to uninstall does not exist. + +**Possible Causes** +1. The version specified during the uninstallation is different from the version of the shared library installed. +2. The shared library to uninstall is not installed. + +**Solution** +1. Check whether the shared library exists. +2. Check whether the version of the shared library is the same as that installed. -- GitLab