diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..ad5ee9f5503d04a49060f69b40f4883a0af0773e --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md @@ -0,0 +1,33 @@ +# SharedBundleInfo + +The **SharedBundleInfo** module provides information about the shared bundle. The information can be obtained by calling [bundleManager.getSharedBundleInfo](js-apis-bundleManager.md). + +> **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. + +## SharedBundleInfo + +Defines the shared bundle information. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| ---------------- | ------------------------------ | ---- | ---- | ---------------------- | +| name | string | Yes | No | Name of the shared bundle. | +| compatiblePolicy | bundleManager.CompatiblePolicy | Yes | No | Compatibility type of the shared bundle.| +| sharedModuleInfo | Array\ | Yes | No | Information about the shared module. | + +## SharedModuleInfo + +Defines the shared module information. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| ------------- | ------ | ---- | ---- | -------------------------- | +| name | string | Yes | No | Module name of the shared bundle. | +| versionCode | number | Yes | No | Version number of the shared bundle. | +| versionName | string | Yes | No | Version description of the shared bundle.| +| description | string | Yes | No | Description of the shared bundle. | +| descriptionId | number | Yes | No | Description ID of the shared bundle. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md index 1503f821c413923f28e11a31a77c5cd2eb07c101..a05187320802cde128cfacbd9105c23a13ea5269 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager.md @@ -112,6 +112,7 @@ Enumerates the types of Extension abilities. | ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.| | THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| | PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.| +| PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.| | UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.| @@ -2861,6 +2862,191 @@ try { } ``` +### bundleManager.getSharedBundleInfo10+ + +getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCallback\\>): void; + +Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.| + +**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 found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'library'; + +try { + bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => { + if (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); + } else { + hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); + } + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); +} +``` + +### bundleManager.getSharedBundleInfo10+ + +function getSharedBundleInfo(bundleName: string, moduleName: string): Promise\\>; + +Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------------------- | +| bundleName | string | Yes | Bundle name.| +| moduleName | string | Yes | Module name.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\\> | Promise used to return the shared bundle information obtained.| + +**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 found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'library'; + +try { + bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => { + hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); + }).catch(err => { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); +} +``` + +### bundleManager.getAllSharedBundleInfo10+ + +getAllSharedBundleInfo(callback: AsyncCallback\\>): void; + +Obtains the information about all shared bundles. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is an array of the shared bundle information obtained.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; + +try { + bundleManager.getAllSharedBundleInfo((err, data) => { + if (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); + } else { + hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); + } + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); +} +``` + +### bundleManager.getAllSharedBundleInfo10+ + +function getAllSharedBundleInfo(): Promise\\>; + +Obtains the information about all shared bundles. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\\> | Promise used to return an array of the shared bundle information obtained.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; + +try { + bundleManager.getAllSharedBundleInfo().then((data) => { + hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); + }).catch(err => { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); +} +``` + +## CompatiblePolicy + +Defines the version compatibility type of the shared library. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| ---------------------- | ---- | -------------------------------- | +| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.| + ## ModuleType Enumerates the module types. diff --git a/en/application-dev/reference/apis/js-apis-installer.md b/en/application-dev/reference/apis/js-apis-installer.md index c39fa3514e9722ba2d33a7dce55378ecb875e3e6..625883cf0313cf47a28e8dae9f1cec7ff79b39b2 100644 --- a/en/application-dev/reference/apis/js-apis-installer.md +++ b/en/application-dev/reference/apis/js-apis-installer.md @@ -3,6 +3,7 @@ The **bundle.installer** module provides APIs for you to install, uninstall, and recover bundles on devices. > **NOTE** + > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -118,6 +119,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc | 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | | 17700018 | Failed to install because the dependent module does not exist. | | 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | +| 17700036 | Failed to install because without allow app shared bundle permission. | **Example** @@ -164,7 +166,7 @@ Uninstalls a bundle. This API uses an asynchronous callback to return the result | Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Name of the target bundle. | -| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the uninstall. | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| **Error codes** @@ -204,6 +206,119 @@ try { } ``` +## BundleInstaller.uninstall10+ + +uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\) : void ; + +Uninstalls a shared bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall. | +| callback | AsyncCallback<void> | 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 | +| -------- | ------------------------------------------------------------ | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700037 | The version of shared bundle is dependent on other applications. | +| 17700038 | The specified shared bundle does not exist. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let uninstallParam = { + bundleName : "com.ohos.demo", +}; + +try { + installer.getBundleInstaller().then(data => { + data.uninstall(uninstallParam, err => { + if (err) { + console.error('uninstall failed:' + err.message); + } else { + console.info('uninstall successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## BundleInstaller.uninstall10+ + +uninstall(uninstallParam: UninstallParam) : Promise\; + +Uninstalls a shared bundle. This API uses a promise to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ----------------------------------- | ---- | ---------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall.| + +**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 | +| -------- | ------------------------------------------------------------ | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700037 | The version of shared bundle is dependent on other applications. | +| 17700038 | The specified shared bundle does not exist. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let uninstallParam = { + bundleName : "com.ohos.demo", +}; + +try { + installer.getBundleInstaller().then(data => { + data.uninstall(uninstallParam, err => { + if (err) { + console.error('uninstall failed:' + err.message); + } else { + console.info('uninstall successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + ## BundleInstaller.recover recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; @@ -221,7 +336,7 @@ Recovers a bundle. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Name of the target bundle. | -| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the recovering. | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| **Error codes** @@ -288,3 +403,17 @@ Defines the parameters that need to be specified for bundle installation, uninst | isKeepData | boolean | Yes | Whether to retain the data directory during bundle uninstall.| | hashParams | Array<[HashParam](#hashparam)> | Yes| Hash parameters. | | crowdtestDeadline| number | Yes |End date of crowdtesting.| +| sharedBundleDirPaths | Array\ | No|Paths of the shared bundle files.| + +## UninstallParam10+ + +Defines the parameters required for the uninstallation of a shared bundle. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Name of the shared bundle. | +| versionCode | number | No | Version number of the shared bundle. If this parameter is not set, all shared bundles of the specified name are uninstalled.|