提交 15d7d773 编写于 作者: W wanghang

IssueNo:#I5ZRIC

Description:api update
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:Feature
Binary Source:No
Signed-off-by: Nwanghang <wanghang26@huawei.com>
上级 f42c7406
...@@ -65,30 +65,16 @@ ...@@ -65,30 +65,16 @@
- [@ohos.events.emitter (Emitter)](js-apis-emitter.md) - [@ohos.events.emitter (Emitter)](js-apis-emitter.md)
- [@ohos.notification (Notification模块)](js-apis-notification.md) - [@ohos.notification (Notification模块)](js-apis-notification.md)
- application/[EventHub (EventHub)](js-apis-eventhub.md) - application/[EventHub (EventHub)](js-apis-eventhub.md)
- 应用程序包管理 - 包管理
- [@ohos.bundle (Bundle模块)](js-apis-Bundle.md) - [@ohos.bundle.appControl(appControl模块)](js-apis-appControl.md)
- [@ohos.bundle.defaultAppManager (Bundle模块)](js-apis-bundle-defaultAppManager.md) - [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md)
- [@ohos.bundle.innerBundleManager (innerBundleManager模块(JS端SDK接口))](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundle.bundleMonitor(bundleMonitor模块)](js-apis-bundleMonitor.md)
- [@ohos.distributedBundle (distributedBundle模块(JS端SDK接口))](js-apis-Bundle-distributedBundle.md) - [@ohos.bundle.defaultAppManager(defaultAppManager模块)](js-apis-defaultAppManager.md)
- [@ohos.bundle.innerBundleManager (innerBundleManager模块)](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundle.distributedBundle (distributedBundle模块)](js-apis-distributedBundle.md)
- [@ohos.bundle.freeInstall(freeInstall模块)](js-apis-freeInstall.md)
- [@ohos.bundle.installer(installer模块)](js-apis-installer.md)
- [@ohos.zlib (Zip模块)](js-apis-zlib.md) - [@ohos.zlib (Zip模块)](js-apis-zlib.md)
- bundle/[AbilityInfo (AbilityInfo)](js-apis-bundle-AbilityInfo.md)
- bundle/[ApplicationInfo (ApplicationInfo)](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo (BundleInfo)](js-apis-bundle-BundleInfo.md)
- bundle/[BundleInstaller (BundleInstaller)](js-apis-bundle-BundleInstaller.md)
- bundle/[BundleStatusCallback (BundleStatusCallback)](js-apis-Bundle-BundleStatusCallback.md)
- bundle/[CustomizeData (CustomizeData)](js-apis-bundle-CustomizeData.md)
- bundle/[DispatchInfo (DispatchInfo)](js-apis-dispatchInfo.md)
- bundle/[ElementName (ElementName)](js-apis-bundle-ElementName.md)
- bundle/[ExtensionAbilityInfo (ExtensionAbilityInfo)](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo (HapModuleInfo)](js-apis-bundle-HapModuleInfo.md)
- bundle/[LauncherAbilityInfo (LauncherAbilityInfo)](js-apis-bundle-LauncherAbilityInfo.md)
- bundle/[Metadata (Metadata)](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo (ModuleInfo)](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef (PermissionDef)](js-apis-bundle-PermissionDef.md)
- bundle/[RemoteAbilityInfo (RemoteAbilityInfo)](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[ShortcutInfo<sup>(deprecated)</sup> (ShortcutInfo)](js-apis-bundle-ShortcutInfo.md)
- bundle/[PackInfo (PackInfo)](js-apis-bundle-PackInfo.md)
- bundleManager/[ShortcutInfo (ShortcutInfo)](js-apis-bundleManager-shortcutInfo.md)
- UI界面 - UI界面
- [@ohos.animator (动画)](js-apis-animator.md) - [@ohos.animator (动画)](js-apis-animator.md)
- [@ohos.curves (插值计算)](js-apis-curve.md) - [@ohos.curves (插值计算)](js-apis-curve.md)
...@@ -269,13 +255,14 @@ ...@@ -269,13 +255,14 @@
- 测试 - 测试
- [@ohos.application.testRunner (TestRunner)](js-apis-testRunner.md) - [@ohos.application.testRunner (TestRunner)](js-apis-testRunner.md)
- [@ohos.uitest (UiTest)](js-apis-uitest.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md)
- 已停止维护的接口 - 已停止维护的接口
- [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md)
- [@ohos.bundle(包管理)](js-apis-Bundle.md)
- [@ohos.bundleState (设备使用信息统计)](js-apis-deviceUsageStatistics.md) - [@ohos.bundleState (设备使用信息统计)](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace (性能打点)](js-apis-bytrace.md) - [@ohos.bytrace (性能打点)](js-apis-bytrace.md)
- [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md) - [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md)
- [@ohos.data.distributedData (分布式数据管理)](js-apis-distributed-data.md) - [@ohos.data.distributedData (分布式数据管理)](js-apis-distributed-data.md)
- [@ohos.distributedBundle(分布式包管理)](js-apis-Bundle-distributedBundle.md)
- [@ohos.prompt (弹窗)](js-apis-prompt.md) - [@ohos.prompt (弹窗)](js-apis-prompt.md)
- [@ohos.reminderAgent (后台代理提醒)](js-apis-reminderAgent.md) - [@ohos.reminderAgent (后台代理提醒)](js-apis-reminderAgent.md)
- [@ohos.usb (USB管理)](js-apis-usb-deprecated.md) - [@ohos.usb (USB管理)](js-apis-usb-deprecated.md)
......
# BundleStatusCallback # BundleStatusCallback
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用包回调的信息,通过接口[innerBundleManager.on](js-apis-Bundle-InnerBundleManager.md)获取。 应用包回调的信息,通过接口[innerBundleManager.on](js-apis-Bundle-InnerBundleManager.md)获取。
## BundleStatusCallback ## BundleStatusCallback<sup>(deprecated)<sup>
> 从API version 9开始不再维护。
**系统API:** 此接口为系统接口,三方应用不支持调用。 **系统API:** 此接口为系统接口,三方应用不支持调用。
...@@ -17,9 +14,6 @@ ...@@ -17,9 +14,6 @@
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| ------ | --------------------------------------------- | -------------------------------------- | | ------ | --------------------------------------------- | -------------------------------------- |
| add | (bundleName : string, userId: number) => void | 获取添加的launcherStatusCallback回调。 | | add | (bundleName : string, userId: number) => void | 获取应用安装时的信息。 |
| update | (bundleName : string, userId: number) => void | 获取编辑的launcherStatusCallback回调。 | | update | (bundleName : string, userId: number) => void | 获取应用更新时的信息。 |
| remove | (bundleName : string, userId: number) => void | 获取移除的launcherStatusCallback回调。 | | remove | (bundleName : string, userId: number) => void | 获取应用卸载时的信息。 |
\ No newline at end of file
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility、应用状态等信息的查询 本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility、应用状态等信息的查询
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> API9 当前为Canary版本,仅供试用,不保证接口可稳定调用。
## 导入模块 ## 导入模块
```js ```js
...@@ -23,7 +22,9 @@ import bundle from '@ohos.bundle'; ...@@ -23,7 +22,9 @@ import bundle from '@ohos.bundle';
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) 权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
## bundle.getApplicationInfo ## bundle.getApplicationInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo)替代。
getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo> getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo>
...@@ -65,7 +66,9 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId) ...@@ -65,7 +66,9 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId)
}) })
``` ```
## bundle.getApplicationInfo ## bundle.getApplicationInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo)替代。
getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void
...@@ -103,7 +106,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { ...@@ -103,7 +106,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
}) })
``` ```
## bundle.getApplicationInfo ## bundle.getApplicationInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo)替代。
getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void
...@@ -139,81 +145,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { ...@@ -139,81 +145,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
}) })
``` ```
## bundle.getApplicationInfoSync<sup>9+</sup>
getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number): ApplicationInfo;
以同步方法根据给定的包名获取ApplicationInfo,返回ApplicationInfo对象。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的包名。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------- | ------------------- |
| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | ApplicationInfo对象 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags, userId);
console.info('Operation successful. Name:' + applicationInfo.name);
```
## bundle.getApplicationInfoSync<sup>9+</sup>
getApplicationInfoSync(bundleName: string, bundleFlags: number) : ApplicationInfo;
以同步方法根据给定的包名获取ApplicationInfo,返回ApplicationInfo对象。 ## bundle.getAllBundleInfo<sup>deprecated<sup>
**需要权限:** > 从API version 9开始不再维护,建议使用[bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo)替代。
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的包名。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------- | ------------------- |
| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | ApplicationInfo对象 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags);
console.info('Operation successful. Name:' + applicationInfo.name);
```
## bundle.getAllBundleInfo
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>> getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>>
...@@ -253,7 +188,10 @@ bundle.getAllBundleInfo(bundleFlag, userId) ...@@ -253,7 +188,10 @@ bundle.getAllBundleInfo(bundleFlag, userId)
}) })
``` ```
## bundle.getAllBundleInfo ## bundle.getAllBundleInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo)替代。
getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void
...@@ -287,7 +225,10 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { ...@@ -287,7 +225,10 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
}) })
``` ```
## bundle.getAllBundleInfo ## bundle.getAllBundleInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo)替代。
getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void
...@@ -323,7 +264,10 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { ...@@ -323,7 +264,10 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
}) })
``` ```
## bundle.getBundleInfo ## bundle.getBundleInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)替代。
getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo> getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo>
...@@ -367,7 +311,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, options) ...@@ -367,7 +311,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, options)
}) })
``` ```
## bundle.getBundleInfo ## bundle.getBundleInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)替代。
getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
...@@ -404,7 +350,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { ...@@ -404,7 +350,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
``` ```
## bundle.getBundleInfo ## bundle.getBundleInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)替代。
getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void
...@@ -444,83 +392,11 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { ...@@ -444,83 +392,11 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
}) })
``` ```
## bundle.getBundleInfoSync<sup>9+</sup>
getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo;
以同步方法根据给定的包名获取BundleInfo,返回BundleInfo对象。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的包名。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
| options | [BundleOptions](#bundleoptions) | 是 | 指定包的选项。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------ | -------------- |
| [BundleInfo](js-apis-bundle-BundleInfo.md) | BundleInfo对象 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
"userId" : 100
};
var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags, options);
console.info('Operation successful. Name:' + bundleInfo.name);
```
## bundle.getBundleInfoSync<sup>9+</sup>
getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo;
以同步方法根据给定的包名获取BundleInfo,返回BundleInfo对象。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的包名。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------ | -------------- |
| [BundleInfo](js-apis-bundle-BundleInfo.md) | BundleInfo对象 |
**示例:**
```js ## bundle.getBundleInstaller<sup>deprecated<sup>
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags);
console.info('Operation successful. Name:' + bundleInfo.name);
```
## bundle.getBundleInstaller > 从API version 9开始不再维护,建议使用[installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller)替代。
getBundleInstaller(): Promise&lt;BundleInstaller&gt;; getBundleInstaller(): Promise&lt;BundleInstaller&gt;;
...@@ -544,7 +420,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -544,7 +420,9 @@ SystemCapability.BundleManager.BundleFramework
| ------------------------------------------------------------ | -------------------------------------------- | | ------------------------------------------------------------ | -------------------------------------------- |
| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 返回值为Promise对象,Promise中包含安装信息。 | | Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 返回值为Promise对象,Promise中包含安装信息。 |
## bundle.getBundleInstaller ## bundle.getBundleInstaller<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller)替代。
getBundleInstaller(callback: AsyncCallback&lt;BundleInstaller&gt;): void; getBundleInstaller(callback: AsyncCallback&lt;BundleInstaller&gt;): void;
...@@ -568,7 +446,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -568,7 +446,9 @@ SystemCapability.BundleManager.BundleFramework
| -------- | ------------------------------------------------------------ | ---- | ---------------- | | -------- | ------------------------------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是 | 安装应用程序包。 | | callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是 | 安装应用程序包。 |
## bundle.cleanBundleCacheFiles<sup>8+</sup> ## bundle.cleanBundleCacheFiles<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback&lt;void&gt;): void; cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback&lt;void&gt;): void;
...@@ -593,7 +473,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -593,7 +473,9 @@ SystemCapability.BundleManager.BundleFramework
| bundleName | string | 是 | 指示要清除其缓存数据的应用程序包名称. | | bundleName | string | 是 | 指示要清除其缓存数据的应用程序包名称. |
| callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 | | callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 |
## bundle.cleanBundleCacheFiles<sup>8+</sup> ## bundle.cleanBundleCacheFiles<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
cleanBundleCacheFiles(bundleName: string): Promise&lt;void&gt; cleanBundleCacheFiles(bundleName: string): Promise&lt;void&gt;
...@@ -623,7 +505,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -623,7 +505,9 @@ SystemCapability.BundleManager.BundleFramework
| ------------- | ------------------------------------ | | ------------- | ------------------------------------ |
| Promise\<void> | 返回值为Promise对象,Promise中为空。 | | Promise\<void> | 返回值为Promise对象,Promise中为空。 |
## bundle.setApplicationEnabled<sup>8+</sup> ## bundle.setApplicationEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void; setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void;
...@@ -649,7 +533,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -649,7 +533,9 @@ SystemCapability.BundleManager.BundleFramework
| isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 |
| callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 | | callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 |
## bundle.setApplicationEnabled<sup>8+</sup> ## bundle.setApplicationEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
setApplicationEnabled(bundleName: string, isEnable: boolean): Promise&lt;void&gt; setApplicationEnabled(bundleName: string, isEnable: boolean): Promise&lt;void&gt;
...@@ -680,7 +566,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -680,7 +566,9 @@ SystemCapability.BundleManager.BundleFramework
| ------------- | ------------------------------------ | | ------------- | ------------------------------------ |
| Promise\<void> | 返回值为Promise对象,Promise中为空。 | | Promise\<void> | 返回值为Promise对象,Promise中为空。 |
## bundle.setAbilityEnabled<sup>8+</sup> ## bundle.setAbilityEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void; setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void;
...@@ -706,7 +594,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -706,7 +594,9 @@ SystemCapability.BundleManager.BundleFramework
| isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 |
| callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 | | callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 |
## bundle.setAbilityEnabled<sup>8+</sup> ## bundle.setAbilityEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise&lt;void&gt; setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise&lt;void&gt;
...@@ -737,7 +627,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -737,7 +627,9 @@ SystemCapability.BundleManager.BundleFramework
| ------------- | ------------------------------------ | | ------------- | ------------------------------------ |
| Promise\<void> | 返回值为Promise对象,Promise中为空。 | | Promise\<void> | 返回值为Promise对象,Promise中为空。 |
## bundle.getPermissionDef<sup>8+</sup> ## bundle.getPermissionDef<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
getPermissionDef(permissionName: string, callback: AsyncCallback&lt;PermissionDef&gt;): void; getPermissionDef(permissionName: string, callback: AsyncCallback&lt;PermissionDef&gt;): void;
...@@ -762,7 +654,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -762,7 +654,9 @@ SystemCapability.BundleManager.BundleFramework
| permissionName | string | 是 | 指定权限的名称。 | | permissionName | string | 是 | 指定权限的名称。 |
| callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | 是 | 程序启动作为入参的回调函数,返回定义的权限信息。 | | callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | 是 | 程序启动作为入参的回调函数,返回定义的权限信息。 |
## bundle.getPermissionDef<sup>8+</sup> ## bundle.getPermissionDef<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
getPermissionDef(permissionName: string): Promise&lt;PermissionDef&gt; getPermissionDef(permissionName: string): Promise&lt;PermissionDef&gt;
...@@ -792,196 +686,10 @@ SystemCapability.BundleManager.BundleFramework ...@@ -792,196 +686,10 @@ SystemCapability.BundleManager.BundleFramework
| ------------------------------------------------------ | ------------------------------------------------------ | | ------------------------------------------------------ | ------------------------------------------------------ |
| Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | 返回值为Promise对象,Promise中包含定义的权限信息对象。 | | Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | 返回值为Promise对象,Promise中包含定义的权限信息对象。 |
## bundle.setModuleUpgradeFlag<sup>9+</sup>
setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback&lt;void&gt;):void;
设置模块是否需要升级
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | --------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
| callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 |
## bundle.setModuleUpgradeFlag<sup>9+</sup>
setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise&lt;void&gt;
设置模块是否需要升级
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | --------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
**返回值:**
| 类型 | 说明 |
| ------------- | ------------------------------------ |
| Promise\<void> | 返回值为Promise对象,Promise中为空。 |
## bundle.isModuleRemovable<sup>9+</sup>
isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback&lt;boolean&gt;): void;
检查指定模块是否被移除
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ---------------------- | ---- | --------------------------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| callback | AsyncCallback\<boolean> | 是 | 程序启动作为入参的回调函数,返回boolean信息。 |
## bundle.isModuleRemovable<sup>9+</sup>
isModuleRemovable(bundleName: string, moduleName: string): Promise&lt;boolean&gt;
检查指定模块是否被移除
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ------------------ |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | ---------------------------- |
| Promise\<boolean> | Promise形式返回boolean信息。 |
## bundle.getBundlePackInfo<sup>9+</sup>
getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback&lt;pack.BundlePackInfo&gt;): void;
基于bundleName和bundleFlags获取bundlePackInfo
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [pack.BundlePackFlag](js-apis-bundle-PackInfo.md) | 是 | 指示要查询的应用包标志 |
| callback | AsyncCallback<[pack.BundlePackInfo](js-apis-bundle-PackInfo.md)> | 是 | 程序启动作为入参的回调函数,返回BundlePackInfo信息。 |
## bundle.getBundlePackInfo<sup>9+</sup>
getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise&lt;pack.BundlePackInfo&gt;;
基于bundleName和bundleFlags获取bundlePackInfo
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [pack.BundlePackFlag](js-apis-bundle-PackInfo.md) | 是 | 指示要查询的应用包标志 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------------- | ----------------------------------- |
| Promise<[pack.BundlePackInfo](js-apis-bundle-PackInfo.md)> | Promise形式返回BundlePackInfo信息。 |
## bundle.getDispatcherVersion<sup>9+</sup>
getDispatcherVersion(callback: AsyncCallback&lt;DispatchInfo&gt;): void;
获取有关dispatcher版本的信息
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:** ## bundle.getAllApplicationInfo<sup>deprecated<sup>
此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<[DispatchInfo](js-apis-dispatchInfo.md)> | 是 | 程序启动作为入参的回调函数,返回[DispatchInfo](js-apis-dispatchInfo.md)信息。 |
## bundle.getDispatcherVersion<sup>9+</sup>
getDispatcherVersion(): Promise&lt;DispatchInfo&gt;;
获取有关dispatcher版本的信息
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**系统API:**
此接口为系统接口,三方应用不支持调用
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------ | ------------------------------------------------------------ |
| Promise<[DispatchInfo](js-apis-dispatchInfo.md)> | Promise形式返回[DispatchInfo](js-apis-dispatchInfo.md)信息。 |
## bundle.getAllApplicationInfo > 从API version 9开始不再维护,建议使用[bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo)替代。
getAllApplicationInfo(bundleFlags: number, userId?: number): Promise<Array\<ApplicationInfo>> getAllApplicationInfo(bundleFlags: number, userId?: number): Promise<Array\<ApplicationInfo>>
...@@ -1021,9 +729,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId) ...@@ -1021,9 +729,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
}) })
``` ```
## bundle.getAllApplicationInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo)替代。
## bundle.getAllApplicationInfo
getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void
...@@ -1060,7 +768,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { ...@@ -1060,7 +768,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
``` ```
## bundle.getAllApplicationInfo ## bundle.getAllApplicationInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo)替代。
getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void; getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void;
...@@ -1094,7 +804,9 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => { ...@@ -1094,7 +804,9 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
}) })
``` ```
## bundle.getBundleArchiveInfo ## bundle.getBundleArchiveInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo)替代。
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo> getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo>
...@@ -1129,7 +841,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) ...@@ -1129,7 +841,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
}) })
``` ```
## bundle.getBundleArchiveInfo ## bundle.getBundleArchiveInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo)替代。
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void
...@@ -1162,7 +876,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { ...@@ -1162,7 +876,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
``` ```
## bundle.getAbilityInfo ## bundle.getAbilityInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)替代。
getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo> getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo>
...@@ -1202,7 +918,9 @@ bundle.getAbilityInfo(bundleName, abilityName) ...@@ -1202,7 +918,9 @@ bundle.getAbilityInfo(bundleName, abilityName)
}) })
``` ```
## bundle.getAbilityInfo ## bundle.getAbilityInfo<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)替代。
getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void; getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
...@@ -1237,91 +955,14 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { ...@@ -1237,91 +955,14 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
console.info('Operation successful. Data:' + JSON.stringify(data)); console.info('Operation successful. Data:' + JSON.stringify(data));
}) })
``` ```
## bundle.getAbilityInfo<sup>9+</sup>
getAbilityInfo(bundleName: string, moduleName: string, abilityName: string): Promise\<AbilityInfo> ## bundle.getAbilityLabel<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。
getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>
通过包名称、moduleName和abilityName获取Ability信息,使用Promise形式返回结果。 通过包名称和abilityName获取应用名称,使用Promise形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------- |
| bundleName | string | 是 | 应用程序包名。 |
| moduleName | string | 是 | Module名称。 |
| abilityName | string | 是 | Ability名称。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | --------------------- |
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise形式返回Ability信息。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, moduleName, abilityName)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.getAbilityInfo<sup>9+</sup>
getAbilityInfo(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
通过包名称、moduleName和abilityName获取Ability信息,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------------ | ---- | ---------------- |
| bundleName | string | 是 | 应用程序包名。 |
| moduleName | string | 是 | Module名称。 |
| abilityName | string | 是 | Ability名称。 |
| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getAbilityLabel<sup>8+</sup>
getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>
通过包名称和abilityName获取应用名称,使用Promise形式返回结果。
**需要权限:** **需要权限:**
...@@ -1357,7 +998,9 @@ bundle.getAbilityLabel(bundleName, abilityName) ...@@ -1357,7 +998,9 @@ bundle.getAbilityLabel(bundleName, abilityName)
}) })
``` ```
## bundle.getAbilityLabel<sup>8+</sup> ## bundle.getAbilityLabel<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。
getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void
...@@ -1392,87 +1035,10 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { ...@@ -1392,87 +1035,10 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
console.info('Operation successful. Data:' + JSON.stringify(data)); console.info('Operation successful. Data:' + JSON.stringify(data));
}) })
``` ```
## bundle.getAbilityLabel<sup>9+</sup>
getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>
通过包名称、moduleName和abilityName获取应用名称,使用Promise形式返回结果。 ## bundle.isAbilityEnabled<sup>deprecated<sup>
**需要权限:** > 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------- |
| bundleName | string | 是 | 应用程序包名。 |
| moduleName | string | 是 | Module名称。 |
| abilityName | string | 是 | Ability名称。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | ------------------ |
| Promise\<string> | Promise形式返回应用名称信息。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, moduleName, abilityName)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.getAbilityLabel<sup>9+</sup>
getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback : AsyncCallback\<string>): void
通过包名称、moduleName和abilityName获取应用名称,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------- | ---- | ---------------- |
| bundleName | string | 是 | 应用程序包名。 |
| moduleName | string | 是 | Module名称。 |
| abilityName | string | 是 | Ability名称。 |
| callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回应用名称信息。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.isAbilityEnabled<sup>8+</sup>
isAbilityEnabled(info: AbilityInfo): Promise\<boolean> isAbilityEnabled(info: AbilityInfo): Promise\<boolean>
...@@ -1508,7 +1074,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ ...@@ -1508,7 +1074,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
}) })
``` ```
## bundle.isAbilityEnabled<sup>8+</sup> ## bundle.isAbilityEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。
isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void
...@@ -1541,7 +1109,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ ...@@ -1541,7 +1109,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
}) })
``` ```
## bundle.isApplicationEnabled<sup>8+</sup> ## bundle.isApplicationEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。
isApplicationEnabled(bundleName: string): Promise\<boolean> isApplicationEnabled(bundleName: string): Promise\<boolean>
...@@ -1575,7 +1145,9 @@ bundle.isApplicationEnabled(bundleName) ...@@ -1575,7 +1145,9 @@ bundle.isApplicationEnabled(bundleName)
}) })
``` ```
## bundle.isApplicationEnabled<sup>8+</sup> ## bundle.isApplicationEnabled<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。
isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void
...@@ -1605,7 +1177,9 @@ bundle.isApplicationEnabled(bundleName, (err, data) => { ...@@ -1605,7 +1177,9 @@ bundle.isApplicationEnabled(bundleName, (err, data) => {
}) })
``` ```
## bundle.queryAbilityByWant ## bundle.queryAbilityByWant<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)替代。
queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise<Array\<AbilityInfo>> queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise<Array\<AbilityInfo>>
...@@ -1652,7 +1226,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) ...@@ -1652,7 +1226,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId)
## bundle.queryAbilityByWant ## bundle.queryAbilityByWant<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)替代。
queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void
...@@ -1693,7 +1269,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { ...@@ -1693,7 +1269,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
}) })
``` ```
## bundle.queryAbilityByWant ## bundle.queryAbilityByWant<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)替代。
queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void; queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void;
...@@ -1734,7 +1312,9 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { ...@@ -1734,7 +1312,9 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
## bundle.getLaunchWantForBundle ## bundle.getLaunchWantForBundle<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle)替代。
getLaunchWantForBundle(bundleName: string): Promise\<Want> getLaunchWantForBundle(bundleName: string): Promise\<Want>
...@@ -1771,7 +1351,9 @@ bundle.getLaunchWantForBundle(bundleName) ...@@ -1771,7 +1351,9 @@ bundle.getLaunchWantForBundle(bundleName)
}) })
``` ```
## bundle.getLaunchWantForBundle ## bundle.getLaunchWantForBundle<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle)替代。
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void; getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
...@@ -1806,7 +1388,9 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ...@@ -1806,7 +1388,9 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => {
``` ```
## bundle.getNameForUid<sup>8+</sup> ## bundle.getNameForUid<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。
getNameForUid(uid: number): Promise\<string> getNameForUid(uid: number): Promise\<string>
...@@ -1839,7 +1423,9 @@ bundle.getNameForUid(uid) ...@@ -1839,7 +1423,9 @@ bundle.getNameForUid(uid)
}) })
``` ```
## bundle.getNameForUid<sup>8+</sup> ## bundle.getNameForUid<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。
getNameForUid(uid: number, callback: AsyncCallback\<string>) : void getNameForUid(uid: number, callback: AsyncCallback\<string>) : void
...@@ -1870,7 +1456,9 @@ bundle.getNameForUid(uid, (err, data) => { ...@@ -1870,7 +1456,9 @@ bundle.getNameForUid(uid, (err, data) => {
``` ```
## bundle.getAbilityIcon<sup>8+</sup> ## bundle.getAbilityIcon<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。
getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>; getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>;
...@@ -1909,7 +1497,9 @@ bundle.getAbilityIcon(bundleName, abilityName) ...@@ -1909,7 +1497,9 @@ bundle.getAbilityIcon(bundleName, abilityName)
}) })
``` ```
## bundle.getAbilityIcon<sup>8+</sup> ## bundle.getAbilityIcon<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。
getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void; getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;
...@@ -1945,487 +1535,8 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { ...@@ -1945,487 +1535,8 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
}) })
``` ```
## bundle.getAbilityIcon<sup>9+</sup> ## InstallErrorCode<sup>deprecated<sup>
> 从API version 9开始不再维护,不推荐使用。
getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise\<image.PixelMap>;
以异步方法通过bundleName、moduleName和abilityName获取对应Icon的[PixelMap](js-apis-image.md),使用Promise形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 要查询的bundleName。 |
| moduleName | string | 是 | moduleName。 |
| abilityName | string | 是 | 要查询的abilityName。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------------------------------------------ |
| Promise\<image.PixelMap> | 返回值为[PixelMap](js-apis-image.md)。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, moduleName, abilityName)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.getAbilityIcon<sup>9+</sup>
getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;
以异步方法通过bundleName、moduleName和abilityName获取对应Icon的[PixelMap](js-apis-image.md),使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 要查询的bundleName。 |
| moduleName | string | 是 | moduleName。 |
| abilityName | string | 是 | 要查询的abilityName。 |
| callback | AsyncCallback\<image.PixelMap> | 是 | 程序启动作为入参的回调函数,返回指定[PixelMap](js-apis-image.md)。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>>
以异步方法根据给定的意图获取ExtensionAbility信息,使用Promise形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------ | ---- | ---------------------------------------- |
| want | [Want](js-apis-application-Want.md) | 是 | 包含要查询的应用程序包名称的意图。 |
| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,取值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) |
| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfo信息。默认值:0,取值范围:枚举值: [ExtensionFlags](#extensionflag9) |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------------------------ |
| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | Promise形式返回ExtensionAbility信息。 |
**示例:**
```js
let extensionType = 0;
let extensionFlags = 0;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void
以异步方法根据给定的意图获取指定用户下的ExtensionAbility信息,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 |
| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,取值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) |
| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfo信息。默认值:0,取值范围:枚举值: [ExtensionFlags](#extensionflag9)|
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0 |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回ExtensionAbility信息。 |
**示例:**
```js
let extensionType = 0;
let extensionFlags = 0;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
const receiver = function onReceive(err, data) {
var errValue = JSON.stringify(err)
var dataValue = JSON.stringify(data)
console.error('Operation failed. Cause: ' + errValue);
console.error('Operation failed. Cause: ' + dataValue);
}
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId, receiver)
```
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void;
以异步方法根据给定的意图获取ExtensionAbility信息,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 或 ohos.permission.GET_BUNDLE_INFO
**系统能力:**
SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 |
| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,取值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) |
| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfo信息。默认值:0,取值范围:枚举值: [ExtensionFlags](#extensionflag9) |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回ExtensionAbility信息。 |
**示例:**
```js
let extensionType = 0;
let extensionFlags = 0;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
const receiver = function onReceive(err, data) {
var errValue = JSON.stringify(err)
var dataValue = JSON.stringify(data)
console.error('Operation failed. Cause: ' + errValue);
console.error('Operation failed. Cause: ' + dataValue);
}
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, receiver)
```
## bundle.getProfileByAbility<sup>9+</sup>
getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;
以异步方法根据给定的moduleName,abilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用callback形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| abilityName | string | 是 | 表示要获取的配置文件所属的ability。 |
| metadataName | string | 是 | 表示要获取的配置文件所属的metadata。 |
| callback | AsyncCallback\<Array\<string>> | 是 | 程序启动作为入参的回调函数,返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';
const caller = function callback(err, data) {
console.error('Operation errcode is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.getProfileByAbility(moduleName, abilityName, metadataName, caller)
```
## bundle.getProfileByAbility<sup>9+</sup>
getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string>>;
以异步方法根据给定的moduleName,abilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用Promise形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| abilityName | string | 是 | 表示要获取的配置文件所属的ability。 |
| metadataName | string | 否 | 表示要获取的配置文件所属的metadata。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------------------------ |
| Promise\<Array\<string>> | Promise形式返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';
bundle.getProfileByAbility(moduleName, abilityName, metadataName).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation errcode is: ' + err);
})
```
## bundle.getProfileByExtensionAbility<sup>9+</sup>
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;
以异步方法根据给定的moduleName,extensionAbilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用callback形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| extensionAbilityName | string | 是 | 表示要获取的配置文件所属的extensionAbility。 |
| metadataName | string | 是 | 表示要获取的配置文件所属的metadata。 |
| callback | AsyncCallback\<Array\<string>> | 是 | 程序启动作为入参的回调函数,返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';
const caller = function callback(err, data) {
console.error('Operation errcode is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, caller)
```
## bundle.getProfileByExtensionAbility<sup>9+</sup>
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string>>;
以异步方法根据给定的moduleName,extensionAbilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用Promise形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| extensionAbilityName | string | 是 | 表示要获取的配置文件所属的extensionAbility。 |
| metadataName | string | 否 | 表示要获取的配置文件所属的metadata。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------------------------ |
| Promise\<Array\<string>> | Promise形式返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';
bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation errcode is: ' + err);
})
```
## bundle.setDisposedStatus<sup>9+</sup>
setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\<void>): void;
以异步方法根据给定的bundleName和status来设置对应应用的处置状态,使用callback形式返回结果。
**需要权限:** ohos.permission.MANAGE_DISPOSED_APP_STATUS
**系统能力:** SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 表示要被设置处置状态的应用包名。 |
| status | number | 是 | 表示要设置的处置状态值。该值预留用于应用市场设置应用的处置状态,默认为0,不做处置。 |
| callback | AsyncCallback\<void> | 是 | 程序启动作为入参的回调函数,无返回值。 |
**示例:**
```js
let bundleName = 'com.ohos.camera';
let status = 1;
const caller = function callback(err, data) {
console.error('Operation err is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.setDisposedStatus(bundleName, status, caller)
```
## bundle.setDisposedStatus<sup>9+</sup>
setDisposedStatus(bundleName: string, status: number): Promise\<void>;
以异步方法根据给定的bundleName和status来设置对应应用的处置状态,使用Promise形式返回结果。
**需要权限:** ohos.permission.MANAGE_DISPOSED_APP_STATUS
**系统能力:** SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 表示要被设置处置状态的应用包名。 |
| status | number | 是 | 表示要设置的处置状态值。该值预留用于应用市场设置应用的处置状态,默认为0,不做处置。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------------------------ |
| Promise\<void> | Promise形式,无返回值。 |
**示例:**
```js
let bundleName = 'com.ohos.camera';
let status = 1;
bundle.setDisposedStatus(bundleName, status).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation err is: ' + err);
})
```
## bundle.getDisposedStatus<sup>9+</sup>
getDisposedStatus(bundleName: string, callback: AsyncCallback\<number>): void;
以异步方法根据给定的bundleName来获取对应应用的处置状态,使用callback形式返回结果。
**需要权限:** ohos.permission.MANAGE_DISPOSED_APP_STATUS
**系统能力:** SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 表示要获取处置状态的应用包名。 |
| callback | AsyncCallback\<number> | 是 | 程序启动作为入参的回调函数,返回应用的处置状态值。 |
**示例:**
```js
let bundleName = 'com.ohos.camera';
const caller = function callback(err, data) {
console.error('Operation err is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.getDisposedStatus(bundleName, caller)
```
## bundle.getDisposedStatus<sup>9+</sup>
getDisposedStatus(bundleName: string): Promise\<number>;
以异步方法根据给定的bundleName来获取对应应用的处置状态,使用Promise形式返回结果。
**需要权限:** ohos.permission.MANAGE_DISPOSED_APP_STATUS
**系统能力:** SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 表示要获取处置状态的应用包名。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------------------------ |
| Promise\<number> | Promise返回应用的处置状态。 |
**示例:**
```js
let bundleName = 'com.ohos.camera';
bundle.getDisposedStatus(bundleName).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation err is: ' + err);
})
```
## InstallErrorCode
**系统能力:** SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFramework
...@@ -2452,7 +1563,9 @@ bundle.getDisposedStatus(bundleName).then(data=>{ ...@@ -2452,7 +1563,9 @@ bundle.getDisposedStatus(bundleName).then(data=>{
| STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | 安装权限拒绝 | | STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | 安装权限拒绝 |
| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | 卸载权限拒绝 | | STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | 卸载权限拒绝 |
## BundleFlag ## BundleFlag<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag)替代。
包的标志 包的标志
...@@ -2467,16 +1580,14 @@ bundle.getDisposedStatus(bundleName).then(data=>{ ...@@ -2467,16 +1580,14 @@ bundle.getDisposedStatus(bundleName).then(data=>{
| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 | | GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 |
| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 | | GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 |
| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | 获取ability的元数据信息 | | GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | 获取ability的元数据信息 |
| GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | 获取包括Ability信息的扩展包信息 |
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | 获取应用的元数据信息 | | GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | 获取应用的元数据信息 |
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | 获取仅包括系统应用的ability信息 | | GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | 获取仅包括系统应用的ability信息 |
| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | 获取包括被禁用的ability信息 | | GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | 获取包括被禁用的ability信息 |
| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | 获取包括被禁用的应用信息 | | GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | 获取包括被禁用的应用信息 |
| GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT <sup>9+</sup> | 0x00000400 | 获取包括应用申请的签名证书的指纹信息 |
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 | | GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 |
| GET_BUNDLE_WITH_HASH_VALUE<sup>9+</sup> | 0x00000030 | 获取包含Hash值的包信息. |
## BundleOptions ## BundleOptions<sup>deprecated<sup>
> 从API version 9开始不再维护,不推荐使用。
包的选项 包的选项
...@@ -2486,7 +1597,9 @@ bundle.getDisposedStatus(bundleName).then(data=>{ ...@@ -2486,7 +1597,9 @@ bundle.getDisposedStatus(bundleName).then(data=>{
| ------ | ------ | ---- | ---- | ---------------------------- | | ------ | ------ | ---- | ---- | ---------------------------- |
| userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
## AbilityType ## AbilityType<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype)替代。
Ability类型 Ability类型
...@@ -2499,7 +1612,9 @@ Ability类型 ...@@ -2499,7 +1612,9 @@ Ability类型
| SERVICE | 无 | Ability没有UI界面 | | SERVICE | 无 | Ability没有UI界面 |
| DATA | 无 | Ability用于提供数据访问服务 | | DATA | 无 | Ability用于提供数据访问服务 |
## DisplayOrientation ## DisplayOrientation<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.DisplayOrientation](js-apis-bundleManager.md#displayorientation)替代。
屏幕显示方向 屏幕显示方向
...@@ -2511,16 +1626,9 @@ Ability类型 ...@@ -2511,16 +1626,9 @@ Ability类型
| LANDSCAPE | 无 | 屏幕方向--横屏 | | LANDSCAPE | 无 | 屏幕方向--横屏 |
| PORTRAIT | 无 | 屏幕方向--竖屏 | | PORTRAIT | 无 | 屏幕方向--竖屏 |
| FOLLOW_RECENT | 无 | 屏幕方向--紧跟上一个组件 | | FOLLOW_RECENT | 无 | 屏幕方向--紧跟上一个组件 |
| LANDSCAPE_INVERTED<sup>9+</sup> |无 | 屏幕方向--反向横屏 | ## LaunchMode<sup>deprecated<sup>
| PORTRAIT_INVERTED<sup>9+</sup> |无 | 屏幕方向--反向竖屏 |
| AUTO_ROTATION<sup>9+</sup> |无 | 屏幕方向--随传感器旋转 | > 从API version 9开始不再维护,建议使用[bundleManager.LaunchType](js-apis-bundleManager.md#launchtype)替代。
| AUTO_ROTATION_LANDSCAPE<sup>9+</sup> |无 | 屏幕方向--传感器横屏旋转,包括了横屏和反向横屏 |
| AUTO_ROTATION_PORTRAIT<sup>9+</sup> |无 | 屏幕方向--传感器竖屏旋转,包括了竖屏和反向竖屏 |
| AUTO_ROTATION_RESTRICTED<sup>9+</sup> |无 | 屏幕方向--传感器开关打开,方向可随传感器旋转 |
| AUTO_ROTATION_LANDSCAPE_RESTRICTED<sup>9+</sup> |无 | 屏幕方向--传感器开关打开,方向可随传感器旋转为横屏, 包括了横屏和反向横屏 |
| AUTO_ROTATION_PORTRAIT_RESTRICTED<sup>9+</sup> |无 | 屏幕方向--传感器开关打开,方向随可传感器旋转为竖屏, 包括了横屏和反向横屏 |
| LOCKED<sup>9+</sup> |无 | 屏幕方向--传感器开关关闭,方向锁定 |
## LaunchMode
启动模式 启动模式
...@@ -2531,7 +1639,8 @@ Ability类型 ...@@ -2531,7 +1639,8 @@ Ability类型
| SINGLETON | 0 | Ability只有一个示例 | | SINGLETON | 0 | Ability只有一个示例 |
| STANDARD | 1 | Ability有多个示例 | | STANDARD | 1 | Ability有多个示例 |
## AbilitySubType ## AbilitySubType<sup>deprecated<sup>
> 从API version 9开始不再维护,不推荐使用。
Ability的子类型 Ability的子类型
...@@ -2542,44 +1651,8 @@ Ability的子类型 ...@@ -2542,44 +1651,8 @@ Ability的子类型
| UNSPECIFIED | 0 | 未定义Ability子类型 | | UNSPECIFIED | 0 | 未定义Ability子类型 |
| CA | 1 | Ability子类型是带有 UI 的服务 | | CA | 1 | Ability子类型是带有 UI 的服务 |
## ExtensionAbilityType<sup>9+</sup> ## ColorMode<sup>deprecated<sup>
> 从API version 9开始不再维护,不推荐使用。
ExtensionAbility的类型
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 类型 | 说明 |
| ------------------------------ | ---- | ------------------------- |
| FORM<sup>9+</sup> | 0 | ExtensionAbility的类型包括卡片 |
| WORK_SCHEDULER<sup>9+</sup> | 1 | ExtensionAbility的类型包括行程安排 |
| INPUT_METHOD<sup>9+</sup> | 2 | ExtensionAbility的类型包括输入法 |
| SERVICE<sup>9+</sup> | 3 | ExtensionAbility的类型包括服务 |
| ACCESSIBILITY<sup>9+</sup> | 4 | ExtensionAbility的类型包括无障碍 |
| DATA_SHARE<sup>9+</sup> | 5 | ExtensionAbility的类型包括数据共享 |
| FILE_SHARE<sup>9+</sup> | 6 | ExtensionAbility的类型包括文件共享 |
| STATIC_SUBSCRIBER<sup>9+</sup> | 7 | ExtensionAbility的类型包括订阅者 |
| WALLPAPER<sup>9+</sup> | 8 | ExtensionAbility的类型包括墙纸 |
| BACKUP<sup>9+</sup> | 9 | ExtensionAbility的类型包括数据备份恢复 |
| WINDOW<sup>9+</sup> | 10 | ExtensionAbility的类型包括窗口类型扩展信息 |
| ENTERPRISE_ADMIN<sup>9+</sup> | 11 | ExtensionAbility的类型包括企业管理员 |
| THUMBNAIL<sup>9+</sup> | 13 | ExtensionAbility的类型包括缩略图 |
| PREVIEW<sup>9+</sup> | 14 | ExtensionAbility的类型包括预览 |
| UNSPECIFIED<sup>9+</sup> | 255 | ExtensionAbility未指定类型 |
## ExtensionFlag<sup>9+</sup>
扩展标志
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 默认值 | 说明 |
| ---------------------------------------- | ---------- | ------------------------------ |
| GET_EXTENSION_INFO_DEFAULT<sup>9+</sup> | 0x00000000 | 获取默认的extensionAbilityInfo |
| GET_EXTENSION_INFO_WITH_PERMISSION<sup>9+</sup> | 0x00000002 | 获取携带权限信息的extensionAbilityInfo |
| GET_EXTENSION_INFO_WITH_APPLICATION<sup>9+</sup> | 0x00000004 | 获取携带应用信息的extensionAbilityInfo |
| GET_EXTENSION_INFO_WITH_METADATA<sup>9+</sup> | 0x00000020 | 获取携带元数据信息的extensionAbilityInfo |
## ColorMode
颜色模式 颜色模式
...@@ -2592,7 +1665,9 @@ ExtensionAbility的类型 ...@@ -2592,7 +1665,9 @@ ExtensionAbility的类型
| LIGHT_MODE | 1 | 亮度模式 | | LIGHT_MODE | 1 | 亮度模式 |
## GrantStatus ## GrantStatus<sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate)替代。
授予状态 授予状态
...@@ -2601,30 +1676,4 @@ ExtensionAbility的类型 ...@@ -2601,30 +1676,4 @@ ExtensionAbility的类型
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| ------------------ | ---- | ---- | | ------------------ | ---- | ---- |
| PERMISSION_DENIED | -1 | 拒绝许可 | | PERMISSION_DENIED | -1 | 拒绝许可 |
| PERMISSION_GRANTED | 0 | 批准 | | PERMISSION_GRANTED | 0 | 批准 |
\ No newline at end of file
## SupportWindowMode
支持窗口模式
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 类型 | 说明 |
| ------------------ | ---- | ---- |
| FULL_SCREEN<sup>9+</sup> | 0 | 全屏模式 |
| SPLIT<sup>9+</sup> | 1 | 分屏模式 |
| FLOATING<sup>9+</sup> | 2 | 悬浮模式 |
## UpgradeFlag
此项仅供内部系统使用
**系统API:** 此接口为系统接口,三方应用不支持调用
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ---------------- |
| NOT_UPGRADE<sup>9+</sup> | 0 | 模块无需升级 |
| SINGLE_UPGRADE<sup>9+</sup> | 1 | 单个模块需要升级 |
| RELATION_UPGRADE<sup>9+</sup> | 2 | 关系模块需要升级 |
...@@ -57,7 +57,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -57,7 +57,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
...@@ -119,7 +119,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -119,7 +119,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
...@@ -186,7 +186,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -186,7 +186,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
...@@ -245,7 +245,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -245,7 +245,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
...@@ -310,7 +310,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -310,7 +310,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
...@@ -369,7 +369,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -369,7 +369,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
var bundleName = 'com.example.myapplication'; var bundleName = 'com.example.myapplication';
var appId; var appId;
try { try {
bundleManager.getBundleInfo(bundleName, BundleManager.BundleFlags.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
.then((data) => { .then((data) => {
appId = data.signatureInfo.appId; appId = data.signatureInfo.appId;
}, error => { }, error => {
......
# AbilityInfo # AbilityInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -9,7 +7,9 @@ ...@@ -9,7 +7,9 @@
Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取
## AbilityInfo ## AbilityInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[AbilityInfo](js-apis-bundleManager-abilityInfo.md)替代。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
...@@ -28,7 +28,7 @@ Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 ...@@ -28,7 +28,7 @@ Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取
| backgroundModes | number | 是 | 否 | 表示后台服务的类型<br />此属性仅可在FA模型下使用 | | backgroundModes | number | 是 | 否 | 表示后台服务的类型<br />此属性仅可在FA模型下使用 |
| isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 | | isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 |
| formEnabled | boolean | 是 | 否 | 判断Ability是否提供卡片能力<br />此属性仅可在FA模型下使用 | | formEnabled | boolean | 是 | 否 | 判断Ability是否提供卡片能力<br />此属性仅可在FA模型下使用 |
| type | AbilityType | 是 | 否 | Ability类型<br />此属性仅可在FA模型下使用 | | type | AbilityType | 是 | 否 | Ability类型<br />此属性仅可在FA模型下使用 |
| orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 | | orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 |
| launchMode | LaunchMode | 是 | 否 | Ability的启动模式 | | launchMode | LaunchMode | 是 | 否 | Ability的启动模式 |
| permissions | Array\<string> | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合<br />通过传入GET_ABILITY_INFO_WITH_PERMISSION获取 | | permissions | Array\<string> | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合<br />通过传入GET_ABILITY_INFO_WITH_PERMISSION获取 |
...@@ -40,13 +40,5 @@ Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 ...@@ -40,13 +40,5 @@ Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取
| uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI)<br />此属性仅可在FA模型下使用 | | uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI)<br />此属性仅可在FA模型下使用 |
| labelId | number | 是 | 否 | Ability的标签id | | labelId | number | 是 | 否 | Ability的标签id |
| subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型<br />此属性仅可在FA模型下使用 | | subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型<br />此属性仅可在FA模型下使用 |
| metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | 否 | ability的自定义信息<br />通过传入GET_ABILITY_INFO_WITH_METADATA获取 | | metadata<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | 否 | ability的元信息<br />通过传入GET_ABILITY_INFO_WITH_METADATA获取 |
| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | 否 | ability的元信息<br />通过传入GET_ABILITY_INFO_WITH_METADATA获取 | | enabled<sup>8+</sup> | boolean | 是 | 否 | ability是否可用 |
| enabled<sup>8+</sup> | boolean | 是 | 否 | ability是否可用 | \ No newline at end of file
| supportWindowMode<sup>9+</sup> | Array\<[SupportWindowMode](js-apis-Bundle.md)> | 是 | 否 | ability支持的窗口模式 |
| maxWindowRatio<sup>9+</sup> | number | 是 | 否 | ability支持的最大的窗口比例 |
| minWindowRatio<sup>9+</sup> | number | 是 | 否 | ability支持的最小的窗口比 |
| maxWindowWidth<sup>9+</sup> | number | 是 | 否 | ability支持的最大的窗口宽度 |
| minWindowWidth<sup>9+</sup> | number | 是 | 否 | ability支持的最小的窗口宽度 |
| maxWindowHeight<sup>9+</sup> | number | 是 | 否 | ability支持的最大的窗口高度 |
| minWindowHeight<sup>9+</sup> | number | 是 | 否 | ability支持的最小的窗口高度 |
\ No newline at end of file
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
应用程序信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 应用程序信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取
## ApplicationInfo ## ApplicationInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)替代。
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
...@@ -20,10 +22,8 @@ ...@@ -20,10 +22,8 @@
| enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true。 | | enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true。 |
| label | string | 是 | 否 | 应用程序的标签。 | | label | string | 是 | 否 | 应用程序的标签。 |
| labelId<sup>(deprecated)</sup> | string | 是 | 否 | 应用程序的标签id。<br />\- **说明:** 从API version 9开始废弃,使用labelIndex。 | | labelId<sup>(deprecated)</sup> | string | 是 | 否 | 应用程序的标签id。<br />\- **说明:** 从API version 9开始废弃,使用labelIndex。 |
| labelIndex<sup>9+</sup> | number | 是 | 否 | 应用程序的标签索引。 |
| icon | string | 是 | 否 | 应用程序的图标。 | | icon | string | 是 | 否 | 应用程序的图标。 |
| iconId<sup>(deprecated)</sup> | string | 是 | 否 | 应用程序的图标id。<br />\- **说明:** 从API version 9开始废弃,使用iconIndex。 | | iconId<sup>(deprecated)</sup> | string | 是 | 否 | 应用程序的图标id。<br />\- **说明:** 从API version 9开始废弃,使用iconIndex。 |
| iconIndex<sup>9+</sup> | number | 是 | 否 | 应用程序的图标索引。 |
| process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称。 | | process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称。 |
| supportedModes | number | 是 | 否 | 应用程序支持的运行模式。 | | supportedModes | number | 是 | 否 | 应用程序支持的运行模式。 |
| moduleSourceDirs | Array\<string> | 是 | 否 | 应用程序的资源存放的相对路径。 | | moduleSourceDirs | Array\<string> | 是 | 否 | 应用程序的资源存放的相对路径。 |
...@@ -32,14 +32,7 @@ ...@@ -32,14 +32,7 @@
| entryDir | string | 是 | 否 | 应用程序的文件保存路径。 | | entryDir | string | 是 | 否 | 应用程序的文件保存路径。 |
| codePath<sup>8+</sup> | string | 是 | 否 | 应用程序的安装目录。 | | codePath<sup>8+</sup> | string | 是 | 否 | 应用程序的安装目录。 |
| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | 否 | 应用程序的自定义元信息。<br />通过传入GET_APPLICATION_INFO_WITH_METADATA获取 | | metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | 否 | 应用程序的自定义元信息。<br />通过传入GET_APPLICATION_INFO_WITH_METADATA获取 |
| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | 是 | 否 | 应用程序的元信息。<br />通过传入GET_APPLICATION_INFO_WITH_METADATA获取 |
| removable<sup>8+</sup> | boolean | 是 | 否 | 应用程序是否可以被移除。 | | removable<sup>8+</sup> | boolean | 是 | 否 | 应用程序是否可以被移除。 |
| accessTokenId<sup>8+</sup> | number | 是 | 否 | 应用程序的accessTokenId。 | | accessTokenId<sup>8+</sup> | number | 是 | 否 | 应用程序的accessTokenId。 |
| uid<sup>8+</sup> | number | 是 | 否 | 应用程序的uid。 | | uid<sup>8+</sup> | number | 是 | 否 | 应用程序的uid。 |
| entityType<sup>8+</sup> | string | 是 | 否 | 应用程序的实体类型。 | | entityType<sup>8+</sup> | string | 是 | 否 | 应用程序的实体类型。 |
| fingerprint<sup>9+</sup> | string | 是 | 否 | 应用程序的签名证书指纹信息,即开发者申请的签名证书的sha256值。<br />通过传入GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT获取 | \ No newline at end of file
| iconResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的图标资源信息。 |
| labelResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的标签资源信息。 |
| descriptionResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的描述资源信息。 |
| appDistributionType<sup>9+</sup> | string | 是 | 否 | 应用程序签名证书的分发类型,分为:app_gallery、enterprise、os_integration和crowdtesting。 |
| appProvisionType<sup>9+</sup> | string | 是 | 否 | 应用程序签名证书文件的类型,分为debug和release两种类型。|
\ No newline at end of file
# BundleInfo # BundleInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用包的信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取。 应用包的信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取。
## BundleInfo ## BundleInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[BundleInfo](js-apis-bundleManager-bundleInfo.md)替代。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。
...@@ -38,11 +36,12 @@ ...@@ -38,11 +36,12 @@
| minCompatibleVersionCode | number | 是 | 否 | 分布式场景下的应用包兼容的最低版本。 | | minCompatibleVersionCode | number | 是 | 否 | 分布式场景下的应用包兼容的最低版本。 |
| entryInstallationFree | boolean | 是 | 否 | Entry是否支持免安装。 | | entryInstallationFree | boolean | 是 | 否 | Entry是否支持免安装。 |
| reqPermissionStates<sup>8+</sup> | Array\<number> | 是 | 否 | 申请权限的授予状态。 | | reqPermissionStates<sup>8+</sup> | Array\<number> | 是 | 否 | 申请权限的授予状态。 |
| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | 是 | 否 | ability的可扩展信息<br />通过传入GET_BUNDLE_WITH_EXTENSION_ABILITY获取。 |
## ReqPermissionDetail ## ReqPermissionDetail<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[ReqPermissionDetail](js-apis-bundleManager-bundleInfo.md)替代。
应用运行时需向系统申请的权限集合的详细信息。 应用运行时需向系统申请的权限集合的详细信息。
...@@ -52,12 +51,13 @@ ...@@ -52,12 +51,13 @@
| --------------------- | ----------------------- | ---- | ---- | ---------------------- | | --------------------- | ----------------------- | ---- | ---- | ---------------------- |
| name | string | 是 | 是 | 需要使用的权限名称。 | | name | string | 是 | 是 | 需要使用的权限名称。 |
| reason | string | 是 | 是 | 描述申请权限的原因。 | | reason | string | 是 | 是 | 描述申请权限的原因。 |
| reasonId<sup>9+</sup> | number | 是 | 是 | 描述申请权限的原因ID。 |
| usedScene | [UsedScene](#usedscene) | 是 | 是 | 权限使用的场景和时机。 | | usedScene | [UsedScene](#usedscene) | 是 | 是 | 权限使用的场景和时机。 |
## UsedScene ## UsedScene<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[UsedScene](js-apis-bundleManager-bundleInfo.md)替代。
描述权限使用的场景和时机。 描述权限使用的场景和时机。
......
# BundleInstaller # BundleInstaller
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
在设备上安装、升级和卸载应用
## BundleInstaller.install<sup>(deprecated)<sup>
在设备上安装、升级和删除捆绑包 > 从API version 9开始不再维护,建议使用[install](js-apis-installer.md)替代。
## BundleInstaller.install
install(bundleFilePaths: Array&lt;string&gt;, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void; install(bundleFilePaths: Array&lt;string&gt;, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
...@@ -35,7 +31,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -35,7 +31,9 @@ SystemCapability.BundleManager.BundleFramework
| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 | | callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 |
## BundleInstaller.uninstall ## BundleInstaller.uninstall<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[uninstall](js-apis-installer.md)替代。
uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void; uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
...@@ -59,7 +57,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -59,7 +57,9 @@ SystemCapability.BundleManager.BundleFramework
| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 | | callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 |
## BundleInstaller.recover<sup>8+</sup> ## BundleInstaller.recover<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[recover](js-apis-installer.md)替代。
recover(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void; recover(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
...@@ -83,20 +83,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -83,20 +83,7 @@ SystemCapability.BundleManager.BundleFramework
| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 | | callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | 是 | 程序启动作为入参的回调函数,返回安装状态信息。 |
## HashParam<sup>9+</sup> ## InstallParam<sup>(deprecated)<sup>
应用程序安装卸载信息
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 说明 |
| ---------- | ------ | ---------------- |
| moduleName | string | 应用程序模块名称 |
| hashValue | string | 哈希值 |
## InstallParam
应用程序安装卸载信息 应用程序安装卸载信息
...@@ -109,10 +96,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -109,10 +96,8 @@ SystemCapability.BundleManager.BundleFramework
| userId | number | 指示用户id | | userId | number | 指示用户id |
| installFlag | number | 指示安装标志 | | installFlag | number | 指示安装标志 |
| isKeepData | boolean | 指示参数是否有数据 | | isKeepData | boolean | 指示参数是否有数据 |
| hashParams<sup>9+</sup> | Array<[HashParam](#hashparam)> | 哈希值参数 |
| crowdtestDeadline<sup>9+</sup> | number | 测试包的被杀死时间 |
## InstallStatus ## InstallStatus<sup>(deprecated)<sup>
应用程序安装状态 应用程序安装状态
......
...@@ -21,5 +21,4 @@ ElementName信息,通过接口[Context.getElementName](js-apis-Context.md)获 ...@@ -21,5 +21,4 @@ ElementName信息,通过接口[Context.getElementName](js-apis-Context.md)获
| bundleName | string | 是 | 是 | 应用包名。 | | bundleName | string | 是 | 是 | 应用包名。 |
| abilityName | string | 是 | 是 | Ability名称。 | | abilityName | string | 是 | 是 | Ability名称。 |
| uri | string | 是 | 是 | 资源标识符。 | | uri | string | 是 | 是 | 资源标识符。 |
| shortName | string | 是 | 是 | Ability短名称。 | | shortName | string | 是 | 是 | Ability短名称。 |
| moduleName<sup>9+</sup> | string | 是 | 是 | Ability所属的HAP包的名称。 | \ No newline at end of file
\ No newline at end of file
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
Hap模块信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 Hap模块信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取
## HapModuleInfo ## HapModuleInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)替代。
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
...@@ -32,8 +34,4 @@ Hap模块信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获 ...@@ -32,8 +34,4 @@ Hap模块信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获
| moduleName | string | 是 | 否 | 模块名 | | moduleName | string | 是 | 否 | 模块名 |
| mainAbilityName | string | 是 | 否 | 入口Ability名称 | | mainAbilityName | string | 是 | 否 | 入口Ability名称 |
| installationFree | boolean | 是 | 否 | 是否支持免安装 | | installationFree | boolean | 是 | 否 | 是否支持免安装 |
| mainElementName<sup>9+</sup> | string | 是 | 否 | 入口ability信息 |
| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | 是 | 否 | extensionAbility信息 |
| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | 否 | Ability的元信息 |
| hashValue<sup>9+</sup> | string | 是 | 否 | Module的Hash值<br />通过传入GET_BUNDLE_WITH_HASH_VALUE获取 |
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
LauncherAbilityInfo信息,通过接口[innerBundleManager.getLauncherAbilityInfos](js-apis-Bundle-InnerBundleManager.md)获取。 LauncherAbilityInfo信息,通过接口[innerBundleManager.getLauncherAbilityInfos](js-apis-Bundle-InnerBundleManager.md)获取。
## LauncherAbilityInfo ## LauncherAbilityInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)替代。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。
......
# ModuleInfo # ModuleInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用程序的模块信息 应用程序的模块信息
## ModuleInfo ## ModuleInfo<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)替代。
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ------ | ---- | ---- | -------- | | --------------- | ------ | ---- | ---- | -------- |
| moduleName | string | 是 | 否 | 模块名称 | | moduleName | string | 是 | 否 | 模块名称 |
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
配置文件中定义的权限详细信息 配置文件中定义的权限详细信息
## **PermissionDef** ## **PermissionDef**<sup>(deprecated)<sup>
> 从API version 9开始不再维护,建议使用[PermissionDef](js-apis-bundleManager-permissionDef.md)替代。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------------- | ------ | ---- | ---- | -------------------- | | ------------------------- | ------ | ---- | ---- | -------------------- |
| targetBundle | string | 是 | 否 | 快捷方式的目标捆绑包 | | targetBundle | string | 是 | 否 | 快捷方式的目标捆绑包 |
| targetModule<sup>9+</sup> | string | 是 | 否 | 快捷方式的目标模块 |
| targetClass | string | 是 | 否 | 快捷方式所需的目标类 | | targetClass | string | 是 | 否 | 快捷方式所需的目标类 |
## ShortcutInfo<sup>(deprecated)<sup> ## ShortcutInfo<sup>(deprecated)<sup>
...@@ -46,5 +45,4 @@ ...@@ -46,5 +45,4 @@
| wants | Array&lt;[ShortcutWant](#shortcutwant)&gt; | 是 | 否 | 快捷方式所需要的信息 | | wants | Array&lt;[ShortcutWant](#shortcutwant)&gt; | 是 | 否 | 快捷方式所需要的信息 |
| isStatic | boolean | 是 | 否 | 快捷方式是否为静态 | | isStatic | boolean | 是 | 否 | 快捷方式是否为静态 |
| isHomeShortcut | boolean | 是 | 否 | 快捷方式是否为主页面快捷方式 | | isHomeShortcut | boolean | 是 | 否 | 快捷方式是否为主页面快捷方式 |
| isEnabled | boolean | 是 | 否 | 是否启用快捷方式 | | isEnabled | boolean | 是 | 否 | 是否启用快捷方式 |
| moduleName<sup>9+</sup> | string | 是 | 否 | 快捷方式的模块名 | \ No newline at end of file
\ No newline at end of file
# AbilityInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Ability信息,未做特殊说明的属性,均通过[GET_ABILITY_INFO_DEFAULT](js-apis-bundleManager.md)获取
## AbilityInfo
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | -------------------------------------------------------- | ---- | ---- | ----------------------------------------- |
| bundleName | string | 是 | 否 | 应用包名 |
| moduleName | string | 是 | 否 | Ability所属的HAP包的名称 |
| name | string | 是 | 否 | Ability名称 |
| label | string | 是 | 否 | Ability对用户显示的名称 |
| labelId | number | 是 | 否 | Ability的标签资源id |
| description | string | 是 | 否 | Ability的描述 |
| descriptionId | number | 是 | 否 | Ability的描述资源id |
| icon | string | 是 | 否 | Ability的图标资源文件索引 |
| iconId | number | 是 | 否 | Ability的图标资源id |
| process | string | 是 | 否 | Ability的进程,如果不设置,默认为包的名称 |
| isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 |
| type | AbilityType | 是 | 否 | Ability类型<br />此属性仅可在FA模型下使用 |
| orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 |
| launchType | number | 是 | 否 | Ability的启动模式 |
| permissions | Array\<string> | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合,通过传入GET_ABILITY_INFO_WITH_PERMISSION获取 |
| readPermission | string | 是 | 否 | 读取Ability数据所需的权限<br />此属性仅可在FA模型下使用 |
| writePermission | string | 是 | 否 | 向Ability写数据所需的权限<br />此属性仅可在FA模型下使用 |
| uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI)<br />此属性仅可在FA模型下使用 |
| deviceTypes | Array\<string> | 是 | 否 | Ability支持的设备类型 |
| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | 应用程序的配置信息,通过传入GET_ABILITY_INFO_WITH_APPLICATION获取 |
| metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | 是 | 否 | ability的元信息,通过传入GET_ABILITY_INFO_WITH_METADATA获取 |
| enabled | boolean | 是 | 否 | ability是否可用 |
| supportWindowModes | Array\<[SupportWindowMode](js-apis-bundleManager.md)> | 是 | 否 | ability支持的窗口模式 |
| windowSize|[WindowSize](#windowsize) | 是 | 否 | 表示窗口尺寸|
## WindowSize
描述窗口尺寸。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------| ------- | ---- | ---- | ---------------------------------- |
| maxWindowRatio | number | 是 | 否 | 表示自由窗口状态下窗口的最大宽高比;取值范围0-1 |
| minWindowRatio | number | 是 | 否 | 表示自由窗口状态下窗口的最小宽高比;取值范围0-1 |
| maxWindowWidth | number | 是 | 否 | 表示自由窗口状态下窗口的最大宽度,宽度单位为vp |
| minWindowWidth | number | 是 | 否 | 表示自由窗口状态下窗口的最小宽度,宽度单位为vp |
| maxWindowHeight | number | 是 | 否 | 表示自由窗口状态下窗口的最大高度,宽度单位为vp |
| minWindowHeight | number | 是 | 否 | 表示自由窗口状态下窗口的最小高度,宽度单位为vp |
\ No newline at end of file
# ApplicationInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用程序信息,未做特殊说明的属性,均通过[GET_APPLICATION_INFO_DEFAULT](js-apis-bundleManager.md)获取
## ApplicationInfo
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 否 | 应用程序的名称 |
| description | string | 是 | 否 | 标识应用的描述信息 |
| descriptionId | number | 是 | 否 | 标识应用的描述信息的资源id |
| enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true |
| label | string | 是 | 否 | 标识应用的名称 |
| labelId | number | 是 | 否 | 标识应用名称的资源id |
| icon | string | 是 | 否 | 应用程序的图标 |
| iconId | number | 是 | 否 | 应用程序图标的资源id |
| process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称。 |
| permissions | Array\<string> | 是 | 否 | 访问应用程序所需的权限,通过传入GET_APPLICATION_INFO_WITH_PERMISSION获取 |
| entryDir | string | 是 | 否 | 应用程序的文件保存路径 |
| codePath | string | 是 | 否 | 应用程序的安装目录 |
| metadata | Map\<string, Array\<[Metadata](js-apis-bundleManager-metadata.md)>> | 是 | 否 | 应用程序的元信息,通过传入GET_APPLICATION_INFO_WITH_METADATA获取 |
| removable | boolean | 是 | 否 | 应用程序是否可以被移除 |
| accessTokenId | number | 是 | 否 | 应用程序的accessTokenId |
| uid | number | 是 | 否 | 应用程序的uid |
| iconResource | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的图标资源信息 |
| labelResource | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的标签资源信息 |
| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的描述资源信息 |
| appDistributionType | string | 是 | 否 | 应用程序签名证书的分发类型,分为:app_gallery、enterprise、os_integration和crowdtesting |
| appProvisionType | string | 是 | 否 | 应用程序签名证书文件的类型,分为debug和release两种类型 |
\ No newline at end of file
# BundleInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用包的信息,未做特殊说明的属性,均通过[GET_BUNDLE_INFO_DEFAULT](js-apis-bundle-bundleManager)获取。
## BundleInfo
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 否 | 应用包的名称 |
| vendor | string | 是 | 否 | 应用包的供应商 |
| versionCode | number | 是 | 否 | 应用包的版本号 |
| versionName | string | 是 | 否 | 应用包的版本文本描述信息 |
| minCompatibleVersionCode | number | 是 | 否 | 分布式场景下的应用包兼容的最低版本 |
| targetVersion | number | 是 | 否 | 该标签标识应用运行目标版本 |
| appInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | 应用程序的配置信息,通过传入GET_BUNDLE_INFO_WITH_APPLICATION获取 |
| hapModulesInfo | Array\<[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)> | 是 | 否 | 模块的配置信息,通过传入GET_BUNDLE_INFO_WITH_HAP_MODULE获取 |
| reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | 是 | 否 | 应用运行时需向系统申请的权限集合的详细信息,通过传入GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION获取|
| permissionGrantStates | Array\<[PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate)> | 是 | 否 | 申请权限的授予状态,通过传入GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION获取 |
| signatureInfo | [SignatureInfo](#signatureinfo) | 是 | 否 | 应用包的签名信息,通过传入GET_BUNDLE_INFO_WITH_SIGNATURE_INFO获取 |
| installTime | number | 是 | 否 | 应用包安装时间 |
| updateTime | number | 是 | 否 | 应用包更新时间 |
## ReqPermissionDetail
应用运行时需向系统申请的权限集合的详细信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | ----------------------- | ---- | ---- | ---------------------|
| name | string | 是 | 是 | 需要使用的权限名称 |
| reason | string | 是 | 是 | 描述申请权限的原因 |
| reasonId | number | 是 | 是 | 描述申请权限的原因ID |
| usedScene | [UsedScene](#usedscene) | 是 | 是 | 权限使用的场景和时机 |
## UsedScene
描述权限使用的场景和时机。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | -------------- | ---- | ---- | --------------------------- |
| abilities | Array\<string> | 是 | 是 | 使用到该权限的Ability集合 |
| when | string | 是 | 是 | 使用该权限的时机。 |
## SignatureInfo
描述应用包的签名信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | -------------- | ---- | ---- | --------------------------- |
| appId | string | 是 | 否 | 应用的appId |
|fingerprint| string | 是 | 否 | 应用包的指纹信息 |
# DispatchInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
免安装结构体和接口版本信息类,通过接口[freeInstall.getDispatchInfo](js-apis-freeInstall.md)获取。
## DispatchInfo
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ------ | ---- | ---- | ------------------------ |
| version | string | 是 | 否 | dispatchInfo结构体版本信息 |
| dispatchAPIVersion | string | 是 | 否 | 免安装接口版本信息 |
# ElementName # ElementName
ElementName信息,通过接口[Context.getElementName](js-apis-Context.md)获取。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
ElementName信息,通过接口[Context.getElementName](js-apis-Context.md)获取。
## ElementName ## ElementName
**系统能力:** SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
......
# ExtensionAbilityInfo # ExtensionAbilityInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** ExtensionAbility信息,未做特殊说明的属性,均通过[getBundleInfo](js-apis-bundleManager.md)获取,flag使用[GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY](js-apis-bundleManager.md#bundleflag)获取
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## ExtensionAbilityInfo
**系统能力**: SystemCapability.BundleManager.BundleFramework.Core
ExtensionAbility信息,未做特殊说明的属性,均通过[getBundleInfo](js-apis-Bundle.md#bundlegetbundleinfo)获取,flag使用[GET_BUNDLE_DEFAULT](js-apis-Bundle.md#bundleflag)获取
| 名称 | 类型 | 可读 | 可写 | 说明 |
## ExtensionAbilityInfo | -------------------- | ----------------------------------------------------------- | ---- | ---- | -------------------------------------------------- |
| bundleName | string | 是 | 否 | 应用包名 |
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework | moduleName | string | 是 | 否 | ExtensionAbility所属的HAP包的名称 |
| name | string | 是 | 否 | ExtensionAbility名称 |
| 名称 | 类型 | 可读 | 可写 | 说明 | | labelId | number | 是 | 否 | ExtensionAbility的标签资源id |
| -------------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------------------- | | descriptionId | number | 是 | 否 | ExtensionAbility的描述资源id |
| bundleName | string | 是 | 否 | 应用包名 | | iconId | number | 是 | 否 | ExtensionAbility的图标资源id |
| moduleName | string | 是 | 否 | ExtensionAbility所属的HAP包的名称 | | isVisible | boolean | 是 | 否 | 判断ExtensionAbility是否可以被其他应用调用 |
| name | string | 是 | 否 | ExtensionAbility名称 | | extensionAbilityType | bundle.ExtensionAbilityType | 是 | 否 | ExtensionAbility类型 |
| labelId | number | 是 | 否 | ExtensionAbility的标签id | | permissions | Array\<string> | 是 | 否 | 被其他应用ExtensionAbility调用时需要申请的权限集合 |
| descriptionId | number | 是 | 否 | ExtensionAbility的描述id | | applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | 应用程序的配置信息 |
| iconId | number | 是 | 否 | ExtensionAbility的图标id | | metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | 是 | 否 | ExtensionAbility的元信息 |
| isVisible | boolean | 是 | 否 | 判断ExtensionAbility是否可以被其他应用调用 | | enabled | boolean | 是 | 否 | ExtensionAbility是否可用 |
| extensionAbilityType | bundle.ExtensionAbilityType | 是 | 否 | ExtensionAbility类型 | | readPermission | string | 是 | 否 | 读取ExtensionAbility数据所需的权限 |
| permissions | Array\<string> | 是 | 否 | 被其他应用ExtensionAbility调用时需要申请的权限集合 | | writePermission | string | 是 | 否 | 向ExtensionAbility写数据所需的权限 |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | 应用程序的配置信息 | \ No newline at end of file
| metadata | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | 否 | ExtensionAbility的元信息 |
| enabled | boolean | 是 | 否 | ExtensionAbility是否可用 |
| readPermission | string | 是 | 否 | 读取ExtensionAbility数据所需的权限 |
| writePermission | string | 是 | 否 | 向ExtensionAbility写数据所需的权限 |
\ No newline at end of file
# HapModuleInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## HapModuleInfo
**系统能力**: SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | -------------------- |
| name | string | 是 | 否 | 模块名称 |
| icon | string | 是 | 否 | 模块图标 |
| iconId | number | 是 | 否 | 模块图标资源id |
| label | string | 是 | 否 | 模块标签 |
| labelId | number | 是 | 否 | 模块标签资源id |
| description | string | 是 | 否 | 模块描述信息 |
| descriptionId | number | 是 | 否 | 描述信息资源id |
| mainElementName | string | 是 | 否 | 入口ability信息 |
| abilitiesInfo | Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | 是 | 否 | Ability信息 |
| extensionAbilitiesInfo | Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | 是 | 否 | extensionAbility信息 |
| metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | 是 | 否 | Ability的元信息 |
| deviceTypes | Array\<string> | 是 | 否 | 支持运行的设备类型 |
| installationFree | boolean | 是 | 否 | 是否支持免安装 |
| hashValue | string | 是 | 否 | Module的Hash值 |
| moduleSourceDir | string | 是 | 否 | Module的路径|
# LauncherAbilityInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## LauncherAbilityInfo
**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher。
**系统:** 系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ----------------------------------------------------------- | ---- | ---- | ------------------------------------ |
| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | launcher ability的应用程序的配置信息 |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是 | 否 | launcher ability的ElementName信息 |
| labelId | number | 是 | 否 | launcher ability的标签ID |
| iconId | number | 是 | 否 | launcher ability的图标ID |
| userId | number | 是 | 否 | launcher ability的用户ID |
| installTime | number | 是 | 否 | launcher ability的安装时间 |
\ No newline at end of file
# Metadata # Metadata
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
描述的module、ability、extensionAbility配置信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** ## Metadata
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 **系统能力**: SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ---------- |
| name | string | 是 | 是 | 元数据名称 |
元数据信息 | value | string | 是 | 是 | 元数据值 |
## Metadata
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ---------- |
| name | string | 是 | 是 | 元数据名称 |
| value | string | 是 | 是 | 元数据值 |
| resource | string | 是 | 是 | 元数据资源 | | resource | string | 是 | 是 | 元数据资源 |
\ No newline at end of file
# PackInfo # PackInfo
> **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
应用包信息,通过接口[bundle.getBundlePackInfo](js-apis-Bundle.md)获取。
## BundlePackFlag
**系统API:** 此接口为系统接口,三方应用不支持调用 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 值 | 说明 | 应用包信息,通过接口[freeInstall.getBundlePackInfo](js-apis-freeInstall.md)获取。
| ------------------ | ---------- | ---------------------------------- |
| GET_PACK_INFO_ALL | 0x00000000 | 获取应用包pack.info的所有信息。 |
| GET_PACKAGES | 0x00000001 | 获取应用包pack.info的package信息。 |
| GET_BUNDLE_SUMMARY | 0x00000002 | 获取应用包pack.info的bundle摘要。 |
| GET_MODULE_SUMMARY | 0x00000004 | 获取应用包pack.info的module摘要。 |
## BundlePackInfo ## BundlePackInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | --------------------------------------- | ---- | ---- | ----------------------------- | | -------- | --------------------------------------- | ---- | ---- | ------------------------- |
| packages | Array\<[PackageConfig](#packageconfig)> | 是 | 否 | 获取pack.info的包信息。 | | packages | Array\<[PackageConfig](#packageconfig)> | 是 | 否 | pack.info的包信息。 |
| summary | [PackageSummary](#packagesummary) | 是 | 否 | 获取pack.info中的包摘要信息。 | | summary | [PackageSummary](#packagesummary) | 是 | 否 | pack.info中的包摘要信息。 |
## PackageConfig ## PackageConfig
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| deviceType | Array\<string> | 是 | 否 | 包支持的设备类型。 | | deviceTypes | Array\<string> | 是 | 否 | 包支持的设备类型。 |
| name | string | 是 | 否 | 包的名称。 | | name | string | 是 | 否 | 包的名称。 |
| moduleType | string | 是 | 否 | 包的module类型。 | | moduleType | string | 是 | 否 | 包的module类型。 |
| deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | | deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 |
## PackageSummary ## PackageSummary
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | --------------------------------------------- | ---- | ---- | -------------------- | | ------- | --------------------------------------------- | ---- | ---- | -------------------- |
...@@ -55,9 +44,9 @@ ...@@ -55,9 +44,9 @@
## BundleConfigInfo ## BundleConfigInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------- | ------------------- | ---- | ---- | ---------------------------------- | | ---------- | ------------------- | ---- | ---- | ---------------------------------- |
...@@ -66,60 +55,61 @@ ...@@ -66,60 +55,61 @@
## ModuleConfigInfo ## ModuleConfigInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- | | ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
| mainAbility | string | 是 | 否 | 应用主ability的名称。 |
| apiVersion | [ApiVersion](#apiversion) | 是 | 否 | module的api版本。 | | apiVersion | [ApiVersion](#apiversion) | 是 | 否 | module的api版本。 |
| deviceType | Array\<string> | 是 | 否 | module的设备类型。 | | deviceType | Array\<string> | 是 | 否 | module的设备类型。 |
| distro | [ModuleDistroInfo](#moduledistroinfo) | 是 | 否 | module发行版信息。 | | distro | [ModuleDistroInfo](#moduledistroinfo) | 是 | 否 | module发行版信息。 |
| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | 是 | 否 | module的元能力信息。 | | abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | 是 | 否 | module包含的ability组件信息。 |
| extensionAbilities | Array\<[ExtensionAbilities](#extensionabilities)> | 是 | 否 | 描述extensionAbilities的配置信息。 | | extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | 是 | 否 | 描述extensionAbilities的配置信息。 |
## ModuleDistroInfo ## ModuleDistroInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ | | ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
| mainAbility | string | 是 | 否 | 主要能力的名称。 |
| deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | | deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 |
| installationFree | boolean | 是 | 否 | 表示当前HAP是否支持免安装特性。true表示支持免安装特性,且符合免安装约束,false表示不支持免安装特性。 | | installationFree | boolean | 是 | 否 | 表示当前HAP是否支持免安装特性。true表示支持免安装特性,且符合免安装约束,false表示不支持免安装特性。 |
| moduleName | string | 是 | 否 | module名称。 | | moduleName | string | 是 | 否 | module名称。 |
| moduleType | string | 是 | 否 | module类型。 | | moduleType | string | 是 | 否 | module类型。 |
## ModuleAbilityInfo ## ModuleAbilityInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 否 | 表示当前ability的逻辑名,该名称在整个应用要唯一。 | | name | string | 是 | 否 | 表示当前ability的名称,该名称在整个应用要唯一。 |
| label | string | 是 | 否 | 表示ability对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 | | label | string | 是 | 否 | 表示ability对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 |
| visible | boolean | 是 | 否 | 表示ability是否可以被其它应用调用,true表示可以被其它应用调用,false表示不可以被其它应用调用。 | | visible | boolean | 是 | 否 | 表示ability是否可以被其它应用调用,true表示可以被其它应用调用,false表示不可以被其它应用调用。 |
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | 是 | 否 | 卡片信息。 | | forms | Array\<[AbilityFormInfo](#abilityforminfo)> | 是 | 否 | 卡片信息。 |
## ExtensionAbilities ## ExtensionAbility
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | | ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 否 | 表示该ExtensionAbility的名称 |
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | 是 | 否 | 表示form卡片的规格,form卡片是可以嵌入桌面上并接收定时更新的应用简要视图。 | | forms | Array\<[AbilityFormInfo](#abilityforminfo)> | 是 | 否 | 表示form卡片的规格,form卡片是可以嵌入桌面上并接收定时更新的应用简要视图。 |
## AbilityFormInfo ## AbilityFormInfo
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
...@@ -128,29 +118,29 @@ ...@@ -128,29 +118,29 @@
| updateEnabled | boolean | 是 | 否 | 表示该卡片是否支持定时刷新,true表示卡片支持定时刷新,false表示不支持。 | | updateEnabled | boolean | 是 | 否 | 表示该卡片是否支持定时刷新,true表示卡片支持定时刷新,false表示不支持。 |
| scheduledUpdateTime | string | 是 | 否 | 表示卡片定点刷新的时间,采用24小时计数,精确到分钟。 | | scheduledUpdateTime | string | 是 | 否 | 表示卡片定点刷新的时间,采用24小时计数,精确到分钟。 |
| updateDuration | number | 是 | 否 | 表示卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数值。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 | | updateDuration | number | 是 | 否 | 表示卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数值。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 |
| supportDimensions | Array\<number> | 是 | 否 | 表示卡片外观规格,取值为“1\*2”,“2\*2”,“2\*4”,“4\*4”,定义卡片时至少要指定一个卡片规格。 | | supportDimensions | Array\<string> | 是 | 否 | 表示卡片外观规格,取值为“1\*2”,“2\*2”,“2\*4”,“4\*4”,定义卡片时至少要指定一个卡片规格。 |
| defaultDimension | number | 是 | 否 | 表示卡片默认外观规格,取值必须在supportDimensions配置的列表中。 | | defaultDimension | string | 是 | 否 | 表示卡片默认外观规格,取值必须在supportDimensions配置的列表中。 |
## ApiVersion ## ApiVersion
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 系统接口,三方应用不支持调用。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ------ | ---- | ---- | -------------------- | | ----------- | ------ | ---- | ---- | -------------------- |
| releaseType | string | 是 | 否 | 版本的名称。 | | releaseType | string | 是 | 否 | 版本的名称。 |
| compatible | number | 是 | 否 | 版本的最小兼容代码。 | | compatible | number | 是 | 否 | 版本的最小兼容代码。 |
| target | numbe | 是 | 否 | 目标版本号。 | | target | number | 是 | 否 | 目标版本号。 |
## Version ## Version
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ | | ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
| minCompatibleVersionCode | number | 是 | 否 | 能够兼容的最低历史版本号,用于跨设备兼容性判断。该值为32位整型数值,非负整数。 | | minCompatibleVersionCode | number | 是 | 否 | 能够兼容的最低历史版本号,用于跨设备兼容性判断。该值为32位整型数值,非负整数。 |
| name | string | 是 | 否 | 标识版本号的文字描述,用于向用户展示。 | | name | string | 是 | 否 | 标识版本号的文字描述,用于向用户展示。 |
| code | number | 是 | 否 | 标识应用的版本号,值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。 | | code | number | 是 | 否 | 标识应用的版本号,值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。 |
\ No newline at end of file
# PermissionDef
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
配置文件中定义的权限详细信息,通过接口[bundleManager.getPermissionDef](js-apis-bundleManager.md)获取。配置文件中定义的权限详细信息。
## **PermissionDef**
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统API:** 系统接口,三方应用不支持调用
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ------ | ---- | ---- | -------------- |
| permissionName | string | 是 | 否 | 用户权限名称 |
| grantMode | number | 是 | 否 | 权限的授予模式 |
| labelId | number | 是 | 否 | 权限的标签ID |
| descriptionId | number | 是 | 否 | 描述权限的ID |
\ No newline at end of file
# RemoteAbilityInfo # RemoteAbilityInfo
包含远程的ability信息,通过接口[distributedBundle.getRemoteAbilityInfo](js-apis-distributedBundle.md)获取。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块接口为系统接口 包含远程的ability信息,通过接口[distributedBundle.getRemoteAbilityInfo](js-apis-distributedBundle.md)获取
## RemoteAbilityInfo ## RemoteAbilityInfo
......
# ShortcutInfo # ShortcutInfo
应用配置文件中定义的快捷方式信息,FA模型配置在[config.json](../../quick-start/package-structure.md)文件中进行配置,Stage模型配置参考[shortcuts对象内部结构](../../quick-start/stage-structure.md#shortcuts对象内部结构)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
模块接口为系统接口。 应用配置文件中定义的快捷方式信息,FA模型配置在[config.json](../../quick-start/package-structure.md)文件中进行配置,Stage模型配置参考[shortcuts对象内部结构](../../quick-start/stage-structure.md#shortcuts对象内部结构)
## ShortcutWant ## ShortcutWant
......
# bundleManager模块(JS端SDK接口)
本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility等信息的查询
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import bundleManager from '@ohos.bundle.bundleManager'
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | ------------------|
| ohos.permission.GET_BUNDLE_INFO | normal | 查询指定应用信息 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.REMOVE_CACHE_FILES | system_basic | 清理应用缓存 |
|ohos.permission.CHANGE_ABILITY_ENABLED_STATE| system_basic | 设置禁用使能所需的权限 |
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
## 枚举
### BundleFlag
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 |
| ----------------------------------------- | ---------- | ------------------------------------------------------------ |
| GET_BUNDLE_INFO_DEFAULT | 0x00000000 | 用于获取默认bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、ability、extensionAbility和permission的信息 |
| GET_BUNDLE_INFO_WITH_APPLICATION | 0x00000001 | 用于获取包含applicationInfo的bundleInfo,获取的bundleInfo不包含signatureInfo、hapModuleInfo、ability、extensionAbility和permission的信息 |
| GET_BUNDLE_INFO_WITH_HAP_MODULE | 0x00000002 | 用于获取包含hapModuleInfo的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、ability、extensionAbility和permission的信息 |
| GET_BUNDLE_INFO_WITH_ABILITY | 0x00000004 | 用于获取包含ability的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、extensionAbility和permission的信息。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用 |
| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY | 0x00000008 | 用于获取包含extensionAbility的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、ability 和permission的信息。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用。 |
| GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION | 0x00000010 | 用于获取包含permission的bundleInfo。获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、extensionAbility和ability的信息 |
| GET_BUNDLE_INFO_WITH_METADATA | 0x00000020 | 用于获取applicationInfo、moduleInfo和abilityInfo中包含的metadata。它不能单独使用,它需要与GET_BUNDLE_INFO_WITH_APPLICATION、GET_BUNDLE_INFO_WITH_HAP_MODULE、GET_BUNDLE_INFO_WITH_ABILITY、GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY一起使用 |
| GET_BUNDLE_INFO_WITH_DISABLE | 0x00000040 | 用于获取application被禁用的BundleInfo和被禁用的Ability信息。获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、ability、extensionAbility和permission的信息 |
| GET_BUNDLE_INFO_WITH_SIGNATURE_INFO | 0x00000080 | 用于获取包含signatureInfo的bundleInfo。获取的bundleInfo不包含applicationInfo、hapModuleInfo、extensionAbility、ability和permission的信息 |
### ApplicationFlag
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。
| 名称 | 值 | 说明 |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| GET_APPLICATION_INFO_DEFAULT | 0x00000000 | 用于获取默认的applicationInfo,获取的applicationInfo不包含permission和metadata信息 |
| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | 用于获取包含permission的applicationInfo |
| GET_APPLICATION_INFO_WITH_METADATA | 0x00000002 | 用于获取包含metadata的applicationInfo |
| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000004 | 用于获取包含禁用应用程序的applicationInfo |
### AbilityFlag
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。
| 名称 | 值 | 说明 |
| --------------------------------- | ---------- | ------------------------------------------------------------ |
| GET_ABILITY_INFO_DEFAULT | 0x00000000 | 用于获取默认abilityInfo,获取的abilityInfo不包含permission、metadata和禁用的abilityInfo |
| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | 用于获取包含permission的abilityInfo |
| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | 用于获取包含applicationInfo的abilityInfo |
| GET_ABILITY_INFO_WITH_METADATA | 0x00000004 | 用于获取包含metadata的abilityInfo |
| GET_ABILITY_INFO_WITH_DISABLE | 0x00000008 | 用于获取包含禁用的abilityInfo的abilityInfo |
| GET_ABILITY_INFO_ONLY_SYSTEM_APP | 0x00000010 | 用于仅为系统应用程序获取abilityInfo |
### ExtensionAbilityFlag
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。
| 名称 | 值 | 说明 |
| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
| GET_EXTENSION_ABILITY_INFO_DEFAULT | 0x00000000 | 用于获取默认extensionAbilityInfo。获取的extensionAbilityInfo不包含permission、metadata 和禁用的abilityInfo |
| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | 用于获取包含permission的extensionAbilityInfo |
| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | 用于获取包含applicationInfo的extensionAbilityInfo |
| GET_EXTENSION_ABILITY_INFO_WITH_METADATA | 0x00000004 | 用于获取包含metadata的extensionAbilityInfo |
### ExtensionAbilityType
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 |
|:----------------:|:---:|
| FORM | 0 |
| WORK_SCHEDULER | 1 |
| INPUT_METHOD | 2 |
| SERVICE | 3 |
| ACCESSIBILITY | 4 |
| DATA_SHARE | 5 |
| FILE_SHARE | 6 |
| STATIC_SUBSCRIBER| 7 |
| WALLPAPER | 8 |
| BACKUP | 9 |
| WINDOW | 10 |
| ENTERPRISE_ADMIN | 11 |
| THUMBNAIL | 13 |
| PREVIEW | 14 |
| UNSPECIFIED | 255 |
### PermissionGrantState
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 |
|:----------------:|:---:|
| PERMISSION_DENIED| -1 |
| PERMISSION_GRANTED | 0 |
### SupportWindowMode
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 |
|:----------------:|:---:|
| FULL_SCREEN | 0 |
| SPLIT | 1 |
| FLOATING | 2 |
### LaunchType
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 |
|:----------------:|:---:|
| SINGLETON | 0 |
| STANDARD | 1 |
| SPECIFIED | 2 |
### AbilityType
**模型约束:** 仅可在FA模型下使用
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 |
|:----------------:|----|
| PAGE | 1 |
| SERVICE | 2 |
| DATA | 3 |
### DisplayOrientation
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 |值 |
|:----------------------------------|---|
| UNSPECIFIED |0 |
| LANDSCAPE |1 |
| PORTRAIT |2 |
| FOLLOW_RECENT |3 |
| LANDSCAPE_INVERTED |4 |
| PORTRAIT_INVERTED |5 |
| AUTO_ROTATION |6 |
| AUTO_ROTATION_LANDSCAPE |7 |
| AUTO_ROTATION_PORTRAIT |8 |
| AUTO_ROTATION_RESTRICTED |9 |
| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|
| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|
| LOCKED |12|
## 方法
### bundleManager.getBundleInfoForSelf
getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
以异步方法根据给定的bundleFlags获取当前应用的BundleInfo,使用Promise形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | --------------------- |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------- |
| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回当前应用的BundleInfo |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
console.info('getBundleInfoForSelf successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getBundleInfoForSelf failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInfoForSelf failed:' + error.message);
}
```
### bundleManager.getBundleInfoForSelf
getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void;
以异步方法根据给定的bundleFlags获取当前应用的BundleInfo,使用callback形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | --------------------- |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
if (err) {
console.error('getBundleInfoForSelf failed:' + err.message);
} else {
console.info('getBundleInfoForSelf successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleInfoForSelf failed:' + err.message);
}
```
### bundleManager.getBundleInfo
getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void;
以异步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息|
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的bundleInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
let userId = 100;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) {
console.error('getBundleInfo failed:' + err.message);
} else {
console.info('getBundleInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleInfo failed:' + err.message);
}
```
### bundleManager.getBundleInfo
getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void;
以异步方法根据给定的bundleName和bundleFlags获取BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息|
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
if (err) {
console.error('getBundleInfo failed:' + err.message);
} else {
console.info('getBundleInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleInfo failed:' + err.message);
}
```
### bundleManager.getBundleInfo
getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: number): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
以异步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | --------------------------- |
| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
let userId = 100;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message);
}
```
### bundleManager.getApplicationInfo
getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void;
以异步方法根据给定的bundleName、appFlags和userId获取ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
if (err) {
console.error('getApplicationInfo failed:' + err.message);
} else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getApplicationInfo failed:' + err.message);
}
```
### bundleManager.getApplicationInfo
getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void;
以异步方法根据给定的bundleName和appFlags获取ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let appsFlag = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
if (err) {
console.error('getApplicationInfo failed:' + err.message);
} else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getApplicationInfo failed:' + err.message);
}
```
### bundleManager.getApplicationInfo
getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId?: number): Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>;
以异步方法根据给定的bundleName、appFlags和userId获取ApplicationInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | -------------------------------- |
| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise对象,返回ApplicationInfo |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
console.info('getApplicationInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getApplicationInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getApplicationInfo failed. Cause: ' + error.message);
}
```
### bundleManager.getAllBundleInfo
getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
以异步方法根据给定的bundleFlags和userId获取多个BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | -------------------------------------------------- |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<BundleInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------- |
| 17700004 | The specified userId is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100;
try {
bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
if (err) {
console.error('getAllBundleInfo failed:' + err.message);
} else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAllBundleInfo failed:' + err.message);
}
```
### bundleManager.getAllBundleInfo
getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
以异步方法根据给定的bundleFlags获取多个BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | -------------------------------------------------- |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<BundleInfo>;否则为错误对象 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
if (err) {
console.error('getAllBundleInfo failed:' + err.message);
} else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAllBundleInfo failed:' + err.message);
}
```
### bundleManager.getAllBundleInfo
getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>;
以异步方法根据给定的bundleFlags和userId获取多个BundleInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | -------------------------------------------------- |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ----------------------------------- |
| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise对象,返回Array\<BundleInfo> |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------- |
| 17700004 | The specified userId is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
console.info('getAllBundleInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getAllBundleInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getAllBundleInfo failed. Cause: ' + error.message);
}
```
### bundleManager.getAllApplicationInfo
getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
以异步方法根据给定的appFlags和userId获取多个ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------ | ---- | ----------------------------------------------------------- |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<ApplicationInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------- |
| 17700004 | The specified userId is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
try {
bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
if (err) {
console.error('getAllApplicationInfo failed:' + err.message);
} else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAllApplicationInfo failed:' + err.message);
}
```
### bundleManager.getAllApplicationInfo
getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
以异步方法根据给定的appFlags获取多个ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------ | ---- | ----------------------------------------------------------- |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<ApplicationInfo>;否则为错误对象 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
if (err) {
console.error('getAllApplicationInfo failed:' + err.message);
} else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAllApplicationInfo failed:' + err.message);
}
```
### bundleManager.getAllApplicationInfo
getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>;
以异步方法根据给定的appFlags和userId获取多个ApplicationInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------ | ---- | ---------------------------------------------------------- |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ---------------------------------------- |
| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise对象,返回Array\<ApplicationInfo> |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------- |
| 17700004 | The specified userId is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
bundleManager.getAllApplicationInfo(appFlags).then((data) => {
console.info('getAllApplicationInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getAllApplicationInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getAllApplicationInfo failed. Cause: ' + error.message);
}
```
### bundleManager.queryAbilityInfo
queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: number, callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void;
以异步方法根据给定的want、abilityFlags和userId获取多个AbilityInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ------------ | ------ | ---- | ------------------------------------------------------- |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息 |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified ability is not found |
| 17700004 | The specified userId is invalid |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
if (err) {
console.error('queryAbilityInfo failed:' + err.message);
} else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('queryAbilityInfo failed:' + err.message);
}
```
### bundleManager.queryAbilityInfo
queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void;
以异步方法根据给定的want和abilityFlags获取一个或多个AbilityInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ------------ | ------ | ---- | -------------------------------------------------------|
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息 |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified ability is not found |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
if (err) {
console.error('queryAbilityInfo failed:' + err.message);
} else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('queryAbilityInfo failed:' + err.message);
}
```
### bundleManager.queryAbilityInfo
queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>;
以异步方法根据给定的want、abilityFlags和userId获取一个或多个AbilityInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ------------ | ------ | ---- | ------------------------------------------------------- |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| abilityFlags | [number](#abilityflag) | 是 | 表示指定返回的AbilityInfo所包含的信息 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------ |
| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise对象,返回Array\<AbilityInfo> |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified ability is not found |
| 17700004 | The specified userId is invalid |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
})
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.queryExtensionAbilityInfo
queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId: number, callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void;
以异步方法根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取一个或多个ExtensionAbilityInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志 |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified extensionAbility is not found |
| 17700004 | The specified userId is invalid |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
} else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
}
```
### bundleManager.queryExtensionAbilityInfo
queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void;
以异步方法根据给定的want、extensionAbilityType和extensionAbilityFlags获取一个或多个ExtensionAbilityInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志 |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified extensionAbility is not found|
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
} else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
}
```
### bundleManager.queryExtensionAbilityInfo
queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>;
以异步方法根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取ExtensionAbilityInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| --------------------- | -------------------- | ---- | ------------------------------------------------------ |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志 |
| userId | number | 否 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | --------------------------------------------- |
| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise对象,返回Array\<ExtensionAbilityInfo> |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified extensionAbility is not found |
| 17700004 | The specified userId is invalid |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
})
} catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.getBundleNameByUid
getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
以异步方法根据给定的uid获取bundleName,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| uid | number | 是 | 表示应用程序的UID |
| callback | AsyncCallback\<string> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleName;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------- |
| 17700021 | The uid is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let uid = 20010005;
try {
bundleManager.getBundleNameByUid(uid, (err, data) => {
if (err) {
console.error('getBundleNameByUid failed:' + err.message);
} else {
console.info('getBundleNameByUid successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleNameByUid failed:' + err.message);
}
```
### bundleManager.getBundleNameByUid
getBundleNameByUid(uid: number): Promise\<string>;
以异步方法根据给定的uid获取bundleName,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---- | ------ | ---- | ------------------ |
| uid | number | 是 | 表示应用程序的UID |
**返回值:**
| 类型 | 说明 |
| ---------------- | --------------------------- |
| Promise\<string> | Promise对象,返回bundleName |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------|
| 17700021 | The uid is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let uid = 20010005;
try {
bundleManager.getBundleNameByUid(uid).then((data) => {
console.info('getBundleNameByUid successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getBundleNameByUid failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleNameByUid failed. Cause: ' + error.message);
}
```
### bundleManager.getBundleArchiveInfo
getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void;
以异步方法根据给定的hapFilePath和bundleFlags获取BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ----------------------------------------------------------- |
| hapFilePath | string | 是 | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径 |
| bundleFlags | [number](#bundleflag) | 是 | 表示用于指定要返回的BundleInfo对象中包含的信息的标志 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------- |
| 17700022 | The hapFilePath is invalid |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) {
console.error('getBundleArchiveInfo failed:' + err.message);
} else {
console.info('getBundleArchiveInfo successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleArchiveInfo failed:' + err.message);
}
```
### bundleManager.getBundleArchiveInfo
getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
以异步方法根据给定的hapFilePath和bundleFlags获取BundleInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| hapFilePath | string | 是 | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径 |
| bundleFlags | [number](#bundleflag) | 是 | 表示用于指定要返回的BundleInfo对象中包含的信息的标志 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | --------------------------- |
| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 17700022 | The hapFilePath is invalid |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
console.info('getBundleArchiveInfo successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message);
}
```
### bundleManager.cleanBundleCacheFiles
cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
以异步方法根据给定的bundleName清理BundleCache,并获取清理结果,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.REMOVE_CACHE_FILES
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 表示要清理其缓存数据的应用程序的bundleName |
| callback | AsyncCallback\<void> | 是 | 回调函数,当清理应用缓存目录数据成功,err为null,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found |
| 17700030 | The specified bundleName does not support cleaning cache files |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = "com.ohos.myapplication";
try {
bundleManager.cleanBundleCacheFiles(bundleName, err => {
if (err) {
console.error('cleanBundleCacheFiles failed:' + err.message);
} else {
console.info('cleanBundleCacheFiles successfully.');
}
});
} catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message);
}
```
### bundleManager.cleanBundleCacheFiles
cleanBundleCacheFiles(bundleName: string): Promise\<void>;
以异步方法根据给定的bundleName清理BundleCache,并获取清理结果,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.REMOVE_CACHE_FILES
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------------------------------------------- |
| bundleName | string | 是 | 表示要清理其缓存数据的应用程序的bundleName |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------------------------------------------ |
| Promise\<void> | Promise对象,返回true表示清理应用缓存目录数据成功,返回false表示清理应用缓存目录数据失败 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found |
| 17700030 | The specified bundle does not support cleaning cache files |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = "com.ohos.myapplication";
try {
bundleManager.cleanBundleCacheFiles(bundleName).then(()=> {
console.info('cleanBundleCacheFiles successfully.');
}).catch(err=> {
console.error('cleanBundleCacheFiles failed:' + err.message);
});
} catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message);
}
```
### bundleManager.setApplicationEnabled
setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void;
设置指定应用的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------- | ---- | ------------------------------------- |
| bundleName | string | 是 | 指定应用的bundleName |
| isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置应用禁用使能状态成功时,err为null,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = "com.ohos.myapplication";
try {
bundleManager.setApplicationEnabled(bundleName, false, err => {
if (err) {
console.error('setApplicationEnabled failed:' + err.message);
} else {
console.info('setApplicationEnabled successfully.');
}
});
} catch (err) {
console.error('setApplicationEnabled failed:' + err.message);
}
```
### bundleManager.setApplicationEnabled
setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
设置指定应用的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------- | ---- | ------------------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------------------ |
| Promise\<void> | Promise对象。无返回结果的Promise对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = "com.ohos.myapplication";
try {
bundleManager.setApplicationEnabled(bundleName, false).then(()=> {
console.info('setApplicationEnabled successfully.');
}).catch(err=> {
console.error('setApplicationEnabled failed:' + err.message);
});
} catch (err) {
console.error('setApplicationEnabled failed:' + err.message);
}
```
### bundleManager.setAbilityEnabled
setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void;
设置指定组件的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ----------- | ---- | ------------------------------------- |
| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件 |
| isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用 |
| callback | AsyncCallback\<void> | | 回调函数,当设置组件禁用使能状态成功时,err为null,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified abilityInfo is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
var info;
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false, err => {
if (err) {
console.error('setAbilityEnabled failed:' + err.message);
} else {
console.info('setAbilityEnabled successfully.');
}
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.setAbilityEnabled
setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>;
设置指定组件的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ----------- | ---- | ------------------------------------- |
| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件 |
| isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用 |
**返回值:**
| 类型 | 说明 |
| -------------- | --------------------------------- |
| Promise\<void> | Promise对象。无返回结果的Promise对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified abilityInfo is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
var info;
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false).then(()=> {
console.info('setAbilityEnabled successfully.');
}).catch(err=> {
console.error('setAbilityEnabled failed:' + err.message);
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.isApplicationEnabled
isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void;
以异步的方法获取指定应用的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| callback | AsyncCallback\<boolean> | 是 | 回调函数,返回true表示当前应用为使能状态,返回false表示应用为禁用状态 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
try {
bundleManager.isApplicationEnabled(bundleName, (err, data) => {
if (err) {
console.error('isApplicationEnabled failed:' + err.message);
} else {
console.info('isApplicationEnabled successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('isApplicationEnabled failed:' + err.message);
}
```
### bundleManager.isApplicationEnabled
isApplicationEnabled(bundleName: string): Promise\<boolean>;
以异步的方法获取指定应用的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | Promise对象,返回true表示当前应用为使能状态,返回false表示当前应用为禁用状态。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
try {
bundleManager.isApplicationEnabled(bundleName).then((data) => {
console.info('isApplicationEnabled successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('isApplicationEnabled failed. Cause: ' + error.message);
});
} catch (error) {
console.error('isApplicationEnabled failed. Cause: ' + error.message);
}
```
### bundleManager.isAbilityEnabled
isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void;
以异步的方法获取指定组件的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---- | ----------- | ---- | --------------------------- |
| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 表示关于检查ability的信息 |
| callback | AsyncCallback\<boolean> | 是 | 回调函数,返回true表示当前应用组件为使能状态,返回false表示应用组件为禁用状态 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified abilityName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
var info;
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info, (err, data) => {
if (err) {
console.error('isAbilityEnabled failed:' + err.message);
} else {
console.info('isAbilityEnabled successfully:' + JSON.stringify(data));
}
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.isAbilityEnabled
isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>;
以异步的方法获取指定组件的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---- | ----------- | ---- | --------------------------- |
| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 表示关于检查ability的信息 |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | Promise对象,返回true表示当前应用组件为使能状态,返回false表示当前应用组件为禁用状态。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700003 | The specified abilityName is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
var info;
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info).then((data) => {
console.info('isAbilityEnabled successfully. Data: ' + JSON.stringify(data));
}).catch(err => {
console.error('isAbilityEnabled failed. Cause: ' + err.message);
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
}
```
### bundleManager.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void;
以异步方法根据给定的bundleName和userId获取用于启动应用程序主要功能,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 表示应用程序的bundleName |
| userId | number | 是 | 表示用户ID |
| callback | AsyncCallback\<Want> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Want;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let userId = 100;
try {
bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
if (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
} else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
}
```
### bundleManager.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
以异步方法根据给定的bundleName获取用于启动应用程序主要功能,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 表示应用程序的bundleName |
| callback | AsyncCallback\<Want> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Want;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
try {
bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
} else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
}
```
### bundleManager.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
以异步方法根据给定的bundleName和userId获取用于启动应用程序主要功能,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ------------------------ |
| bundleName | string | 是 | 表示应用程序的bundleName |
| userId | number | 否 | 表示用户ID|
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------- |
| Promise\<Want> | Promise对象,返回Want对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let userId = 100;
try {
bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
console.info('getLaunchWantForBundle successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message);
}
```
### bundleManager.getProfileByAbility
getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback<Array\<string>>): void;
以异步方法根据给定的moduleName、abilityName和metadataName获取相应配置文件的json格式字符串,使用callback形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
| metadataName | string | 是 | 表示应用程序的metadataName |
| callback | AsyncCallback<Array\<string>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<string>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed |
| 17700003 | The specified abilityName is not existed |
| 17700024 | The specified metadataName is not existed or the profile is not json-format |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
if (err) {
console.error('getProfileByAbility failed:' + err.message);
} else {
console.info('getProfileByAbility successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getProfileByAbility failed:' + err.message);
}
```
### bundleManager.getProfileByAbility
getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise<Array\<string>>;
以异步方法根据给定的moduleName、abilityName和metadataName获取相应配置文件的json格式字符串,使用Promise形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ------------ | ------ | ---- | -------------------------- |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
| metadataName | string | 否 | 表示应用程序的metadataName |
**返回值:**
| 类型 | 说明 |
| ----------------------- | ------------------------------- |
| Promise<Array\<string>> | Promise对象,返回Array\<string> |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed |
| 17700003 | The specified abilityName is not existed |
| 17700024 | The specified metadataName is not existed or the profile is not json-format |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message);
}
try {
bundleManager.getProfileByAbility(moduleName, abilityNamemetadataName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message);
}
```
### bundleManager.getProfileByExtensionAbility
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback<Array\<string>>): void;
以异步方法根据给定的moduleName、extensionAbilityName和metadataName获取相应配置文件的json格式字符串,使用callback形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | 是 | 表示应用程序的moduleName |
| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName |
| metadataName | string | 是 | 表示应用程序的metadataName |
| callback | AsyncCallback<Array\<string>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<string>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed |
| 17700003 | The specified extensionAbilityName is not existed |
| 17700024 | The specified metadataName is not existed or the profile is not json-format |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
if (err) {
console.error('getProfileByExtensionAbility failed:' + err.message);
} else {
console.info('getProfileByExtensionAbility successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getProfileByExtensionAbility failed:' + err.message);
}
```
### bundleManager.getProfileByExtensionAbility
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise<Array\<string>>;
以异步方法根据给定的moduleName、extensionAbilityName和metadataName获取相应配置文件的json格式字符串,使用Promise形式返回结果。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------------- | ------ | ---- | -----------------------------------|
| moduleName | string | 是 | 表示应用程序的moduleName |
| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName |
| metadataName | string | 否 | 表示应用程序的metadataName |
**返回值:**
| 类型 | 说明 |
| ----------------------- | ----------------------------------- |
| Promise<Array\<string>> | Promise对象,返回Array\<string>对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed |
| 17700003 | The specified extensionAbilityName is not existed |
| 17700024 | The specified metadataName is not existed or the profile is not json-format |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
}
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
}
```
### bundleManager.getPermissionDef
getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void;
以异步方法根据给定的permissionName获取PermissionDef,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| permissionName | string | 是 | 表示权限名称 |
| callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<PermissionDef>;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700006 | The specified permission is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let permission = "ohos.permission.GET_BUNDLE_INFO";
try {
bundleManager.getPermissionDef(permission, (err, data) => {
if (err) {
console.error('getPermissionDef failed:' + err.message);
} else {
console.info('getPermissionDef successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getPermissionDef failed:' + err.message);
}
```
### bundleManager.getPermissionDef
getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>;
以异步方法根据给定的permissionName获取PermissionDef,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------ | ---- | -------------------- |
| permissionName | string | 是 | 表示权限名称 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------------ |
| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Promise对象,返回Array\<PermissionDef>对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------|
| 17700006 | The specified permission is not found |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try {
bundleManager.getPermissionDef(permissionName).then((data) => {
console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getPermissionDef failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getPermissionDef failed. Cause: ' + error.message);
}
```
### bundleManager.getAbilityLabel
getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void;
以异步的方法获取指定bundleName、moduleName和abilityName的label,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 表示应用程序的bundleName |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
| callback | AsyncCallback\<string> | 是 | 回调函数,当获取成功时,err为null,data为获指定组件的Label值;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------------|
| 17700001 | The specified bundleName is not found |
| 17700002 | The specified moduleName is not found |
| 17700003 | The specified abilityName is not found |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('getAbilityLabel failed:' + err.message);
} else {
console.info('getAbilityLabel successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAbilityLabel failed:' + err.message);
}
```
### bundleManager.getAbilityLabel
getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>;
以异步的方法获取指定bundleName、moduleName和abilityName的label,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
**返回值:**
| 类型 | 说明 |
| ---------------- | ----------------------------------- |
| Promise\<string> | Promise对象,返回指定组件的Lablel值 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | --------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700002 | The specified moduleName is not found |
| 17700003 | The specified abilityName is not found |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityLabel successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getAbilityLabel failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getAbilityLabel failed. Cause: ' + error.message);
}
```
### bundleManager.getAbilityIcon
getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)>): void;
以异步的方法获取指定bundleName、moduleName和abilityName的icon,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 表示应用程序的bundleName |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数,当获取成功时,err为null,data为指定组件icon的PixelMap对象;否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700002 | The specified moduleName is not found |
| 17700003 | The specified abilityName is not found |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('getAbilityIcon failed:' + err.message);
} else {
console.info('getAbilityIcon successfully:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('getAbilityIcon failed:' + err.message);
}
```
### bundleManager.getAbilityIcon
getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise<[image.PixelMap](js-apis-image.md#pixelmap7)>;
以异步的方法获取指定bundleName、moduleName和abilityName的icon,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| moduleName | string | 是 | 表示应用程序的moduleName |
| abilityName | string | 是 | 表示应用程序的abilityName |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------- | ------------------------------------------- |
| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象,返回指定组件icon的PixelMap对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700002 | The specified moduleName is not found |
| 17700003 | The specified abilityName is not found |
| 17700026 | The specified bundle is disabled |
| 17700029 | The specified ability is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityIcon successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
console.error('getAbilityIcon failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getAbilityIcon failed. Cause: ' + error.message);
}
```
### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
以同步方法根据给定的bundleName、applicationFlags和userId获取ApplicationInfo
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ----------------------------------------------------------|
| bundleName | string | 是 | 表示应用程序的bundleName |
| applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息 |
| userId | number | 是 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| --------------- | ------------------------- |
| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 返回ApplicationInfo对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data));
} catch (err) {
console.error('getApplicationInfoSync failed:' + err.message);
}
```
### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
以同步方法根据给定的bundleName和applicationFlags获取ApplicationInfo
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ----------------------------------------------------------|
| bundleName | string | 是 | 表示应用程序的bundleName |
| applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息 |
**返回值:**
| 类型 | 说明 |
| --------------- | ------------------------- |
| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 返回ApplicationInfo对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data));
} catch (err) {
console.error('getApplicationInfoSync failed:' + err.message);
}
```
### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
以同步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志 |
| userId | number | 是 | 表示用户ID |
**返回值:**
| 类型 | 说明 |
| ---------- | -------------------- |
| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700004 | The specified userId is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100;
try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data));
} catch (err) {
console.error('getBundleInfoSync failed:' + err.message);
}
```
### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
以同步方法根据给定的bundleName和bundleFlags获取BundleInfo。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName |
| bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志 |
**返回值:**
| 类型 | 说明 |
| ---------- | -------------------- |
| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found |
| 17700026 | The specified bundle is disabled |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager'
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data));
} catch (err) {
console.error('getBundleInfoSync failed:' + err.message);
}
```
\ No newline at end of file
# Bundle.bundleMonitor模块(JS端sdk接口)
本模块提供监听应用安装,卸载,更新的能力。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```javascript
import bundleMonitor from '@ohos.bundle.bundleMonitor';
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| ------------------------------------ | ----------- | ------------------------------ |
| ohos.permission.LISTEN_BUNDLE_CHANGE | system_core | 可监听应用的安装,卸载,更新。 |
权限等级参考[权限等级说明]([zh-cn/application-dev/security/accesstoken-overview.md · OpenHarmony/docs - Gitee.com](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md))
## BundleChangeInfo
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
系统接口:为系统接口,三方应用不可调用
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------- | ------ | ---- | ---- | -------------------------- |
| bundleName | string | 是 | 否 | 应用状态发生变化的应用包名 |
| userId | number | 是 | 否 | 应用状态发生变化的用户id |
## bundleMonitor.on
on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
注册监听应用的安装,卸载,更新。
**需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE
**系统接口:**此接口为系统接口
**系统能力:**SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 描述 |
| ---------------------------- | -------- | ---- | ------------------ |
| BundleChangedEvent | string | 是 | 注册监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 是 | 注册监听的回调函数 |
**相关错误码**
| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) |
| ------ | ---------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
**示例:**
```js
import bundleMonitor from '@ohos.bundle.bundleMonitor';
try {
bundleMonitor.on('add', (bundleChangeInfo) => {
console.info(`bundleName : ${bundleChangeInfo.bundleName} userId : ${bundleChangeInfo.userId}`);
})
} catch (errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
## bundleMonitor.off
off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
注销监听应用的安装,卸载,更新。
**需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE
**系统接口:**此接口为系统接口
**系统能力:**SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 描述 |
| ---------------------------- | -------- | ---- | ---------------------------------------------------------- |
| BundleChangedEvent | string | 是 | 注销监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 否 | 注销监听的回调函数,当为空时表示注销当前事件的所有callback |
**相关错误码**
| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) |
| ------ | ---------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
**示例:**
```js
import bundleMonitor from '@ohos.bundle.bundleMonitor';
try {
bundleMonitor.off('add');
} catch (errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
...@@ -51,6 +51,7 @@ isDefaultApplication(type: string): Promise\<boolean> ...@@ -51,6 +51,7 @@ isDefaultApplication(type: string): Promise\<boolean>
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER)
.then((data) => { .then((data) => {
console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data)); console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data));
...@@ -77,6 +78,7 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void ...@@ -77,6 +78,7 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -122,6 +124,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo> ...@@ -122,6 +124,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER)
.then((data) => { .then((data) => {
console.info('Operation successful. bundleInfo: ' + JSON.stringify(data)); console.info('Operation successful. bundleInfo: ' + JSON.stringify(data));
...@@ -170,7 +173,9 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun ...@@ -170,7 +173,9 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun
**示例:** **示例:**
```js ```js
defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100;
defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -178,7 +183,7 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, ...@@ -178,7 +183,7 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100,
console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); console.info('Operation successful. bundleInfo:' + JSON.stringify(data));
}); });
defaultAppMgr.getDefaultApplication("image/png", 100, (err, data) => { defaultAppMgr.getDefaultApplication("image/png", userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -217,6 +222,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void ...@@ -217,6 +222,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -224,7 +230,6 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, ...@@ -224,7 +230,6 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err,
} }
console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); console.info('Operation successful. bundleInfo:' + JSON.stringify(data));
}); });
defaultAppMgr.getDefaultApplication("image/png", (err, data) => { defaultAppMgr.getDefaultApplication("image/png", (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -236,13 +241,19 @@ defaultAppMgr.getDefaultApplication("image/png", (err, data) => { ...@@ -236,13 +241,19 @@ defaultAppMgr.getDefaultApplication("image/png", (err, data) => {
## defaultAppMgr.setDefaultApplication ## defaultAppMgr.setDefaultApplication
setDefaultApplication(type: string, elementName: ElementName, userId?: number): Promise\<void> setDefaultApplication(type: string, elementName: ElementName, userId?: number): Promise\<**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | --------------------------- |
| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo |
>
以异步方法根据系统已定义的应用类型或者符合媒体类型格式(type/subtype)的文件类型设置默认应用,使用Promise形式返回结果。 以异步方法根据系统已定义的应用类型或者符合媒体类型格式(type/subtype)的文件类型设置默认应用,使用Promise形式返回结果。
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -254,6 +265,12 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): ...@@ -254,6 +265,12 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 要设置为默认应用的组件信息。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 要设置为默认应用的组件信息。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ---------------------------------- |
| Promise\<void> | Promise对象,无返回结果的Promise。 |
**错误码:** **错误码:**
| 错误码ID | 错误码信息 | | 错误码ID | 错误码信息 |
...@@ -265,15 +282,25 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): ...@@ -265,15 +282,25 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.test.app", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "MainAbility" abilityName: "MainAbility"
}) }).then((data) => {
.then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}) }).catch((error) => {
.catch((error) => { console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "MainAbility"
}, userId).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}); });
...@@ -281,11 +308,9 @@ defaultAppMgr.setDefaultApplication("image/png", { ...@@ -281,11 +308,9 @@ defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.test.app", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "MainAbility" abilityName: "MainAbility"
}) }, userId).then((data) => {
.then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}) }).catch((error) => {
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}); });
``` ```
...@@ -298,7 +323,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca ...@@ -298,7 +323,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -322,11 +347,13 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca ...@@ -322,11 +347,13 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.test.app", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "MainAbility" abilityName: "MainAbility"
}, 100, (err, data) => { }, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -338,7 +365,7 @@ defaultAppMgr.setDefaultApplication("image/png", { ...@@ -338,7 +365,7 @@ defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.test.app", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "MainAbility" abilityName: "MainAbility"
}, 100, (err, data) => { }, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -355,7 +382,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal ...@@ -355,7 +382,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -378,6 +405,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal ...@@ -378,6 +405,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.test.app", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
...@@ -411,7 +439,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void> ...@@ -411,7 +439,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -432,7 +460,9 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void> ...@@ -432,7 +460,9 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
**示例:** **示例:**
```js ```js
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100;
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId)
.then((data) => { .then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}) })
...@@ -440,7 +470,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) ...@@ -440,7 +470,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER)
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}); });
defaultAppMgr.resetDefaultApplication("image/png") defaultAppMgr.resetDefaultApplication("image/png", userId)
.then((data) => { .then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}) })
...@@ -457,7 +487,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v ...@@ -457,7 +487,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -479,7 +509,9 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v ...@@ -479,7 +509,9 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
**示例:** **示例:**
```js ```js
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100;
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -487,7 +519,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100 ...@@ -487,7 +519,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100
console.info('Operation successful.'); console.info('Operation successful.');
}); });
defaultAppMgr.resetDefaultApplication("image/png", 100, (err, data) => { defaultAppMgr.resetDefaultApplication("image/png", userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -504,7 +536,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; ...@@ -504,7 +536,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
**需要权限:** ohos.permission.SET_DEFAULT_APPLICATION **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager.defaultAppManager **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口,三方应用不支持调用
...@@ -525,6 +557,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; ...@@ -525,6 +557,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
**示例:** **示例:**
```js ```js
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
......
# Bundle.freeInstall模块(JS端SDK接口)
本模块提供免安装相关的设置和查询能力,支持BundlePackInfo、DispatchInfo等信息的查询
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块接口为系统接口。
## 导入模块
```js
import freeInstall from '@ohos.bundle.freeInstall';
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
## UpgradeFlag
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ---------------- |
| NOT_UPGRADE | 0 | 模块无需升级 |
| SINGLE_UPGRADE | 1 | 单个模块需要升级 |
| RELATION_UPGRADE | 2 | 关系模块需要升级 |
## BundlePackFlag
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
| 名称 | 值 | 说明 |
| ------------------ | ---------- | ---------------------------------- |
| GET_PACK_INFO_ALL | 0x00000000 | 获取应用包pack.info的所有信息。 |
| GET_PACKAGES | 0x00000001 | 获取应用包pack.info的package信息。 |
| GET_BUNDLE_SUMMARY | 0x00000002 | 获取应用包pack.info的bundle摘要信息。 |
| GET_MODULE_SUMMARY | 0x00000004 | 获取应用包pack.info的module摘要信息。 |
## freeInstall.setHapModuleUpgradeFlag
setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback\<void>):void;
设置指定模块是否升级。使用callback异步回调。
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | --------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
| callback | AsyncCallback\<void> | 是 | 回调函数。当函数调用成功,err为null,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
| 17700002 | The specified module name is not found. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
try {
freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag, err => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed');
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## setHapModuleUpgradeFlag
setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise\<void>;
设置指定模块是否升级。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | --------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
**返回值:**
| 类型 | 说明 |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise对象。无返回结果的Promise对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
| 17700002 | The specified module name is not found. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
try {
freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag).then(() => {
console.info('Operation succeed')
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## isHapModuleRemovable
isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback\<boolean>): void;
查询指定模块是否可以被移除。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ---------------------- | ---- | --------------------------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| callback | AsyncCallback\<boolean> | 是 | 回调函数。返回true表示可以移除;返回false表示不可移除。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
| 17700002 | The specified module name is not found. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
try {
freeInstall.isHapModuleRemovable(bundleName, moduleName, (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## isHapModuleRemovable
isHapModuleRemovable(bundleName: string, moduleName: string): Promise\<boolean>;
查询指定模块是否可以被移除。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | ------------------ |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | ---------------------------- |
| Promise\<boolean> | Promise对象。返回true表示可以移除;返回false表示不可移除。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
| 17700002 | The specified module name is not found. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
try {
freeInstall.isHapModuleRemovable(bundleName, moduleName).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## getBundlePackInfo
getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: AsyncCallback\<BundlePackInfo>): void;
基于bundleName和bundlePackFlag来获取bundlePackInfo。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 |
| callback | AsyncCallback<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的BundlePackInfo信息。否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let upgradeFlag = freeInstall.UpgradeFlag.GET_PACK_INFO_ALL;
try {
freeInstall.getBundlePackInfo(bundleName, upgradeFlag, (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## getBundlePackInfo
getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\<BundlePackInfo>;
基于bundleName和bundleFlag来获取bundlePackInfo。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------------- | ------------------------------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------------- | ----------------------------------- |
| Promise<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | Promise对象,返回BundlePackInfo信息。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
let bundleName = 'com.example.myapplication';
let upgradeFlag = freeInstall.UpgradeFlag.GET_PACK_INFO_ALL;
try {
freeInstall.getBundlePackInfo(bundleName, upgradeFlag).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## getDispatchInfo
getDispatchInfo(callback: AsyncCallback\<DispatchInfo>): void;
获取有关dispatch版本的信息。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)信息。否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 801 | Capability not supported. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
try {
freeInstall.getDispatchInfo((err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## getDispatchInfo
getDispatchInfo(): Promise\<DispatchInfo>;
获取有关dispatch版本的信息。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------ | ------------------------------------------------------------ |
| Promise<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | Promise对象,返回[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)信息。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) |
|---------------|-------------------------|
| 201 | Permission denied.|
| 801 | Capability not supported. |
**示例:**
```js
import freeInstall from '@ohos.bundle.freeInstall';
try {
freeInstall.getDispatchInfo().then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
# BundleInstaller
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
在设备上安装、升级和卸载应用
## 导入模块
```js
import installer from '@ohos.bundle.installer';
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
## BundleInstaller.getBundleInstaller
getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
获取BundleInstaller对象,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | 是 | 回调函数,获取BundleInstaller对象,err为undefined,data为获取到的BundleInstaller对象;否则为错误对象 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
**示例:**
```ts
import installer from '@ohos.bundle.installer';
try {
installer.getBundleInstaller((err, data) => {
if (err) {
console.error('getBundleInstaller failed:' + err.message);
} else {
console.info('getBundleInstaller successfully');
}
});
} catch (error) {
console.error('getBundleInstaller failed:' + error.message);
}
```
## BundleInstaller.getBundleInstaller
getBundleInstaller(): Promise\<BundleInstaller>;
获取BundleInstaller对象,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------ |
| Promise\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Promise对象,返回BundleInstaller对象 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
**示例:**
```ts
import installer from '@ohos.bundle.installer';
try {
installer.getBundleInstaller().then((data) => {
console.info('getBundleInstaller successfully.');
}).catch((error) => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}
```
## BundleInstaller.install
install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: AsyncCallback&lt;void&gt;): void;
以异步方法安装应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP包的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP包,且这些HAP包的签名需要保持一致 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------------------------------------|
| 17700004 | The specified userId is not existed |
| 17700010 | To parse file of config.json or module.json failed |
| 17700011 | To verify signature failed |
| 17700012 | Invalid hap file path or too large file size |
| 17700015 | Multiple haps have inconsistent configured information |
| 17700016 | No disk space left for installation |
| 17700017 | Downgrade installation is prohibited |
| 17700101 | The system service is excepted |
| 17700103 | I/O operation is failed |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = {
userId: 100,
isKeepData: false,
installFlag: 1,
};
try {
installer.getBundleInstaller().then(data => {
data.install(hapFilePaths, installParam, err => {
if (err) {
console.error('install failed:' + err.message);
} else {
console.info('install successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}
```
## BundleInstaller.uninstall
uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback&lt;void&gt;): void;
以异步方法卸载应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 包名 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------------------------------------------------|
| 17700004 | The specified userId is not existed |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled |
| 17700101 | The system service is excepted |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let bundleName = 'com.ohos.demo';
let installParam = {
userId: 100,
isKeepData: false,
installFlag: 1
};
try {
installer.getBundleInstaller().then(data => {
data.uninstall(bundleName, installParam, 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&lt;void&gt;): void;
以异步方法回滚应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 包名 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,回滚应用成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)
| 错误码ID | 错误码信息 |
| -------- | ---------------------------------------------------------------------------|
| 17700004 | The specified userId is not existed |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let bundleName = 'com.ohos.demo';
let installParam = {
userId: 100,
isKeepData: false,
installFlag: 1
};
try {
installer.getBundleInstaller().then(data => {
data.recover(bundleName, installParam, err => {
if (err) {
console.error('recover failed:' + err.message);
} else {
console.info('recover successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}
```
## HashParam
应用程序安装卸载信息
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 说明 |
| ---------- | ------ | ---------------- |
| moduleName | string | 应用程序模块名称 |
| hashValue | string | 哈希值 |
## InstallParam
应用程序安装卸载信息
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 说明 |
| ------------------------------ | ------------------------------ | ------------------ |
| userId | number | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户 |
| installFlag | number | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装 |
| isKeepData | boolean | 卸载时是否保留数据目录 |
| hashParams | Array<[HashParam](#hashparam)> | 哈希值参数 |
| crowdtestDeadline| number | 测试包的被杀死时间 |
\ No newline at end of file
...@@ -29,7 +29,7 @@ The specified module name is not found. ...@@ -29,7 +29,7 @@ The specified module name is not found.
2. 系统中对应的应用没有安装该模块。 2. 系统中对应的应用没有安装该模块。
**处理步骤**<br/> **处理步骤**<br/>
1. 检查bundleName拼写是否正确。 1. 检查moduleName拼写是否正确。
2. 确认对应的应用是否安装该模块。 2. 确认对应的应用是否安装该模块。
## 17700003 指定的abilityName不存在 ## 17700003 指定的abilityName不存在
...@@ -127,15 +127,16 @@ Failed to install the hap since the hap fails to be parsed. ...@@ -127,15 +127,16 @@ Failed to install the hap since the hap fails to be parsed.
2. 确认hap的配置文件满足[配置文件json格式](../../quick-start/stage-structure.md) 2. 确认hap的配置文件满足[配置文件json格式](../../quick-start/stage-structure.md)
3. 检查DevEco Studio编译hap时是否有错误提示,缺省字段时会有相应的报错。 3. 检查DevEco Studio编译hap时是否有错误提示,缺省字段时会有相应的报错。
## 17700011 签名校验失败失败导致应用安装失败 ## 17700011 签名校验失败导致应用安装失败
**错误信息**<br/> **错误信息**<br/>
Failed to install the hap since the hap signature fails to be verified. Failed to install the hap since the hap signature fails to be verified.
**错误描述**<br/> **错误描述**<br/>
签名校验失败失败导致应用安装失败。 签名校验失败导致应用安装失败。
**可能原因**<br/> **可能原因**<br/>
1. hap包没有签名。 1. hap包没有签名。
2. hap签名信息来源不可靠。 2. hap签名信息来源不可靠。
3. 升级的hap包与已安装的hap包签名信息不一致。 3. 升级的hap包与已安装的hap包签名信息不一致。
...@@ -146,49 +147,23 @@ Failed to install the hap since the hap signature fails to be verified. ...@@ -146,49 +147,23 @@ Failed to install the hap since the hap signature fails to be verified.
2. 确认多个hap签名时使用的证书相同。 2. 确认多个hap签名时使用的证书相同。
3. 确认升级的hap签名证书与已安装的hap相同。 3. 确认升级的hap签名证书与已安装的hap相同。
## 17700012 安装包路径无效导致应用安装失败 ## 17700012 安装包路径无效或者文件过大导致应用安装失败
**错误信息**<br/> **错误信息**<br/>
Failed to install the hap since the path of the hap is invalid. Failed to install the hap since the path of the hap is invalid or too large size.
**错误描述**<br/> **错误描述**<br/>
安装包路径无效导致应用安装失败。 安装包路径无效或者文件过大导致应用安装失败。
**可能原因**<br/> **可能原因**<br/>
1. 输入错误,hap包的文件路径不存在。 1. 输入错误,hap包的文件路径不存在。
2. hap包的路径无法访问。 2. hap包的路径无法访问。
3. hap包的大小超过最大限制4G。
**处理步骤**<br/> **处理步骤**<br/>
1. 确认hap是否存在。 1. 确认hap是否存在。
2. 查看hap的可执行权限,是否可读。 2. 查看hap的可执行权限,是否可读。
3. 查看hap包的大小是否超过4G。
## 17700013 应用包过大导致应用安装失败
**错误信息**<br/>
Failed to install the hap since the hap is too large.
**错误描述**<br/>
应用包过大导致应用安装失败。
**可能原因**<br/>
hap包过大,一个hap不能超过4GB。
**处理步骤**<br/>
确认hap包的大小。
## 17700014 应用包后缀有误导致应用安装失败
**错误信息**<br/>
Failed to install the hap since the extension name of the hap is not .hap.
**错误描述**<br/>
应用包后缀有误导致应用安装失败。
**可能原因**<br/>
hap包的文件后缀名不为.hap。
**处理步骤**<br/>
确认hap包的后缀是否为.hap。
## 17700015 多个hap包配置信息不同导致应用安装失败 ## 17700015 多个hap包配置信息不同导致应用安装失败
...@@ -365,3 +340,32 @@ The distributed service is not running. ...@@ -365,3 +340,32 @@ The distributed service is not running.
**处理步骤**<br/> **处理步骤**<br/>
确认输入的ability和type拼写是否正确。 确认输入的ability和type拼写是否正确。
## 17700029 指定的ability被禁用
**错误信息**<br/>
The specified ability is disabled.
**错误描述**<br/>
指定的ability被禁用。
**可能原因**<br/>
指定的ability被禁用。
**处理步骤**<br/>
确认指定的ability是否被禁用,可以使用[bm工具](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md#bm)命令查询对应的应用信息。
## 17700030 指定的应用不支持清除缓存文件
**错误信息**<br/>
The specified bundle does not support clearing cache files.
**错误描述**<br/>
指定的应用不支持清除缓存文件。
**可能原因**<br/>
指定的应用为系统应用且在签名证书中配置了不能清除数据(AllowAppDataNotCleared)的字段。
**处理步骤**<br/>
1.确认指定的应用是否为系统应用,可以使用[bm工具](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md#bm)命令查询对应的应用信息,查看isSystemApp是否为true。
2.确认指定的应用是否配置了能清除缓存(AllowAppDataNotCleared)的字段,可以使用[bm工具](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md#bm)命令查询对应的应用信息,查看userDataClearable是否为true。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册