diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..7a3f872517b48c574436a6f94ca3d646a8022cf7 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md @@ -0,0 +1,32 @@ +# SharedBundleInfo + +> **说明:** +> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +共享包信息,通过接口[bundleManager.getSharedBundleInfo](js-apis-bundleManager.md)获取。 + +## SharedBundleInfo + + 共享包信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------- | ------------------------------ | ---- | ---- | ---------------------- | +| name | string | 是 | 否 | 应用共享包名称。 | +| compatiblePolicy | bundleManager.CompatiblePolicy | 是 | 否 | 共享包兼容策略的类型。 | +| sharedModuleInfo | Array\ | 是 | 否 | 应用共享模块信息。 | + +## SharedModuleInfo + +共享模块信息。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------- | ------ | ---- | ---- | -------------------------- | +| name | string | 是 | 否 | 共享包模块名称。 | +| versionCode | number | 是 | 否 | 共享包的版本号。 | +| versionName | string | 是 | 否 | 共享包的版本文本描述信息。 | +| description | string | 是 | 否 | 共享包的模块描述信息。 | +| descriptionId | number | 是 | 否 | 共享包描述的资源id值。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md index fcbb598bc98a335b044072a084f1eec6b701aac9..fcdb34dd85b3477a2aaa70d8cc58bdc27b890207 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md @@ -111,6 +111,7 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。 | ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md):企业设备管理扩展能力,提供企业管理时处理管理事件的能力,比如设备上应用安装事件、锁屏密码输入错误次数过多事件等。 | | THUMBNAIL | 13 | ThumbnailExtensionAbility:文件缩略图扩展能力,用于为文件提供图标缩略图的能力。预留能力,当前暂未支持。 | | PREVIEW | 14 | PreviewExtensionAbility:文件预览扩展能力,提供文件预览的能力,其他应用可以直接在应用中嵌入显示。预留能力,当前暂未支持。 | +| PRINT10+ | 15 | PrintExtensionAbility:文件打印扩展能力,提供应用打印照片、文档等办公场景。当前支持图片打印,文档类型暂未支持。 | | UNSPECIFIED | 255 | 不指定类型,配合queryExtensionAbilityInfo接口可以查询所有类型的ExtensionAbility。 | @@ -2860,6 +2861,191 @@ try { } ``` +### bundleManager.getSharedBundleInfo10+ + +getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCallback\\>): void; + +以异步的方法获取指定的共享包信息,使用callback形式返回结果。 + +**系统接口:** 此接口为系统接口。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | 是 | 表示应用程序的bundleName。 | +| moduleName | string | 是 | 表示被查询的module的name。 | +| callback | AsyncCallback\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取的指定共享包信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | + +**示例:** + +```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\\>; + +以异步的方法获取指定的共享包信息,使用Promise形式返回结果。 + +**系统接口:** 此接口为系统接口 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------------------- | +| bundleName | string | 是 | 表示应用程序的bundleName。 | +| moduleName | string | 是 | 表示被查询的module的name。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)> | Promise对象,返回指定的共享包信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | + +**示例:** + +```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; + +以异步的方法获取所有的共享包信息,使用callback形式返回结果。 + +**系统接口:** 此接口为系统接口。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\\> | 是 | 回调函数,当获取成功时,err为null,data为获所有的共享包信息。 | + +**示例:** + +```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\\>; + +以异步的方法获取所有的共享包信息,使用Promise形式返回结果。 + +**系统接口:** 此接口为系统接口 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\\> | Promise对象,返回所有的共享包信息。 | + +**示例:** + +```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 + +标识共享库的版本兼容类型。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core + +| 名称 | 值 | 说明 | +| ---------------------- | ---- | -------------------------------- | +| BACKWARD_COMPATIBILITY | 1 | 该字段表明共享库是向后兼容类型。 | + ## ModuleType 标识模块类型。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-installer.md b/zh-cn/application-dev/reference/apis/js-apis-installer.md index 6c0c703946528ccaaeb6117e68bc746c0b877369..221dc9a44ff768ca296b5d57e8946c7bc9ca46b7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-installer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-installer.md @@ -118,6 +118,7 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback: | 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. | **示例:** @@ -204,6 +205,119 @@ try { } ``` +## BundleInstaller.uninstall10+ + +uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\) : void ; + +以异步方法卸载一个共享包,使用callback形式返回结果。 + +**系统接口:** 此接口为系统接口,三方应用不支持调用 + +**需要权限:** ohos.permission.INSTALL_BUNDLE + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | 是 | 共享包卸载需指定的参数信息。 | +| callback | AsyncCallback<void> | 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 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. | + +**示例:** + +```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\; + +以异步方法卸载一个共享包,使用Promise形式返回结果。 + +**系统接口:** 此接口为系统接口,三方应用不支持调用 + +**需要权限:** ohos.permission.INSTALL_BUNDLE + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ----------------------------------- | ---- | ---------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | 是 | 共享包卸载需指定的参数信息。 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | -------------------------------------- | +| Promise | Promise对象。无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 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. | + +**示例:** + +```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; @@ -287,4 +401,18 @@ try { | installFlag | number | 是 | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 | | isKeepData | boolean | 是 | 卸载时是否保留数据目录。 | | hashParams | Array<[HashParam](#hashparam)> | 是 | 哈希值参数。 | -| crowdtestDeadline| number | 是 |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | \ No newline at end of file +| crowdtestDeadline| number | 是 |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | +| sharedBundleDirPaths | Array\ | 否 |共享包文件所在路径。 | + +## UninstallParam10+ + +共享包卸载需指定的参数信息。 + + **系统能力:** SystemCapability.BundleManager.BundleFramework.Core + + **系统接口:** 此接口为系统接口,三方应用不支持调用 + +| 名称 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| bundleName | string | 是 | 共享包包名。 | +| versionCode | number | 否 | 指示共享包的版本号。如果不填写versionCode,则卸载所有同版本共享包。 | \ No newline at end of file