提交 2f4cbbc7 编写于 作者: G geng-wenguang

修改包管理打印格式

Signed-off-by: Ngeng-wenguang <gengwenguang@huawei.com>
上级 c3838456
# bundleManager模块(JS端SDK接口) # @ohos.bundle.bundleManager (bundleManager模块)
本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility等信息的查询 本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility等信息的查询
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
``` ```
## 权限列表 ## 权限列表
| 权限 | 权限等级 | 描述 | | 权限 | 权限等级 | 描述 |
...@@ -27,7 +28,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -27,7 +28,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
包信息标志,指示需要获取的包信息的内容。 包信息标志,指示需要获取的包信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------------------- | ---------- | ------------------------------------------------------------ | | ----------------------------------------- | ---------- | ------------------------------------------------------------ |
...@@ -45,7 +46,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -45,7 +46,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
应用信息标志,指示需要获取的应用信息的内容。 应用信息标志,指示需要获取的应用信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。 **系统接口:** 系统接口,不支持三方应用调用。
...@@ -58,9 +59,9 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -58,9 +59,9 @@ import bundleManager from '@ohos.bundle.bundleManager'
### AbilityFlag ### AbilityFlag
功能组件信息标志,指示需要获取的功能组件信息的内容。 Ability组件信息标志,指示需要获取的Ability组件信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。 **系统接口:** 系统接口,不支持三方应用调用。
...@@ -77,7 +78,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -77,7 +78,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
扩展组件信息标志,指示需要获取的扩展组件信息的内容。 扩展组件信息标志,指示需要获取的扩展组件信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用。 **系统接口:** 系统接口,不支持三方应用调用。
...@@ -92,7 +93,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -92,7 +93,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
指示扩展组件的类型。 指示扩展组件的类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
|:----------------:|:---:|-----| |:----------------:|:---:|-----|
...@@ -115,9 +116,9 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -115,9 +116,9 @@ import bundleManager from '@ohos.bundle.bundleManager'
### PermissionGrantState ### PermissionGrantState
指示权限授予信息 指示权限授予状态
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
|:----------------:|:---:|:---:| |:----------------:|:---:|:---:|
...@@ -128,7 +129,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -128,7 +129,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
标识该组件所支持的窗口模式。 标识该组件所支持的窗口模式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
|:----------------:|:---:|:---:| |:----------------:|:---:|:---:|
...@@ -140,21 +141,21 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -140,21 +141,21 @@ import bundleManager from '@ohos.bundle.bundleManager'
指示组件的启动方式。 指示组件的启动方式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
|:----------------:|:---:|:---:| |:----------------:|:---:|:---:|
| SINGLETON | 0 | ability的启动模式,表示单实例。 | | SINGLETON | 0 | ability的启动模式表示单实例。 |
| STANDARD | 1 | ability的启动模式,表示普通多实例。 | | STANDARD | 1 | ability的启动模式表示普通多实例。 |
| SPECIFIED | 2 | ability的启动模式,表示该ability内部根据业务自己置顶多实例。 | | SPECIFIED | 2 | ability的启动模式表示该ability内部根据业务自己置顶多实例。 |
### AbilityType ### AbilityType
指示Ability组件的类型。 指示Ability组件的类型。
**模型约束:** 仅可在FA模型下使用 **模型约束** 仅可在FA模型下使用
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| :-----: | ---- | :--------------------------------------------------------: | | :-----: | ---- | :--------------------------------------------------------: |
...@@ -166,7 +167,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -166,7 +167,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
标识该Ability的显示模式。该标签仅适用于page类型的Ability。 标识该Ability的显示模式。该标签仅适用于page类型的Ability。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
| 名称 |值 |说明 | | 名称 |值 |说明 |
|:----------------------------------|---|---| |:----------------------------------|---|---|
...@@ -184,7 +185,7 @@ import bundleManager from '@ohos.bundle.bundleManager' ...@@ -184,7 +185,7 @@ import bundleManager from '@ohos.bundle.bundleManager'
| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|表示受开关控制的自动竖向旋转模式。| | AUTO_ROTATION_PORTRAIT_RESTRICTED |11|表示受开关控制的自动竖向旋转模式。|
| LOCKED |12|表示锁定模式。| | LOCKED |12|表示锁定模式。|
## 方法 ## 接口
### bundleManager.getBundleInfoForSelf ### bundleManager.getBundleInfoForSelf
...@@ -209,16 +210,17 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( ...@@ -209,16 +210,17 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
console.info('getBundleInfoForSelf successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfoForSelf failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', error.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfoForSelf failed:' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} }
``` ```
...@@ -240,19 +242,20 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback ...@@ -240,19 +242,20 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfoForSelf failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} else { } else {
console.info('getBundleInfoForSelf successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfoForSelf failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} }
``` ```
...@@ -272,7 +275,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: ...@@ -272,7 +275,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------------------------- | | ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。| | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。|
| userId | number | 是 | 表示用户ID。 | | userId | number | 是 | 表示用户ID。 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的bundleInfo;否则为错误对象。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的bundleInfo;否则为错误对象。 |
...@@ -291,7 +294,8 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: ...@@ -291,7 +294,8 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback:
```ts ```ts
// 额外获取AbilityInfo // 额外获取AbilityInfo
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
let userId = 100; let userId = 100;
...@@ -299,19 +303,20 @@ let userId = 100; ...@@ -299,19 +303,20 @@ let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
```ts ```ts
// 额外获取ApplicationInfo中的metadata // 额外获取ApplicationInfo中的metadata
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
let userId = 100; let userId = 100;
...@@ -319,13 +324,13 @@ let userId = 100; ...@@ -319,13 +324,13 @@ let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -345,7 +350,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< ...@@ -345,7 +350,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------------------------- | | ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。| | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。|
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象。 |
...@@ -363,20 +368,21 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< ...@@ -363,20 +368,21 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
```ts ```ts
// 额外获取extensionAbility // 额外获取extensionAbility
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -396,7 +402,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n ...@@ -396,7 +402,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------------------------- | | ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。 | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。 |
| userId | number | 否 | 表示用户ID。 | | userId | number | 否 | 表示用户ID。 |
...@@ -420,35 +426,37 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n ...@@ -420,35 +426,37 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n
```ts ```ts
// 额外获取ApplicationInfo和SignatureInfo // 额外获取ApplicationInfo和SignatureInfo
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
let userId = 100; let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -469,7 +477,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -469,7 +477,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------------------- | | ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 |
| userId | number | 是 | 表示用户ID。 | | userId | number | 是 | 表示用户ID。 |
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 | | callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 |
...@@ -487,7 +495,8 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -487,7 +495,8 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
...@@ -495,13 +504,13 @@ let userId = 100; ...@@ -495,13 +504,13 @@ let userId = 100;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => { bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -521,7 +530,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ...@@ -521,7 +530,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------------------- | | ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 |
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 | | callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 |
...@@ -538,20 +547,21 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ...@@ -538,20 +547,21 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => { bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
if (err) { if (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -571,7 +581,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -571,7 +581,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------------------- | | ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | 是 | 表示要查询的应用程序包名称。 | | bundleName | string | 是 | 表示要查询的应用Bundle名称。 |
| appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息。 |
| userId | number | 否 | 表示用户ID。 | | userId | number | 否 | 表示用户ID。 |
...@@ -594,19 +604,20 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -594,19 +604,20 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100; let userId = 100;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => { bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
console.info('getApplicationInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -614,7 +625,7 @@ try { ...@@ -614,7 +625,7 @@ try {
getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void; getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
以异步方法根据给定的bundleFlags和userId获取多个BundleInfo,使用callback形式返回结果。 以异步方法根据给定的bundleFlags和userId获取系统中所有的BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -641,20 +652,21 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A ...@@ -641,20 +652,21 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100; let userId = 100;
try { try {
bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => { bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -662,7 +674,7 @@ try { ...@@ -662,7 +674,7 @@ try {
getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void; getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
以异步方法根据给定的bundleFlags获取多个BundleInfo,使用callback形式返回结果。 以异步方法根据给定的bundleFlags获取系统中所有的BundleInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -688,19 +700,20 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr ...@@ -688,19 +700,20 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getAllBundleInfo(bundleFlags, (err, data) => { bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -708,7 +721,7 @@ try { ...@@ -708,7 +721,7 @@ try {
getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>; getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>;
以异步方法根据给定的bundleFlags和userId获取多个BundleInfo,使用Promise形式返回结果。 以异步方法根据给定的bundleFlags和userId获取系统中所有的BundleInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -740,17 +753,18 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A ...@@ -740,17 +753,18 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getAllBundleInfo(bundleFlags).then((data) => { bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
console.info('getAllBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAllBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAllBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -758,7 +772,7 @@ try { ...@@ -758,7 +772,7 @@ try {
getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void; getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
以异步方法根据给定的appFlags和userId获取多个ApplicationInfo,使用callback形式返回结果。 以异步方法根据给定的appFlags和userId获取系统中所有的ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -785,20 +799,21 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call ...@@ -785,20 +799,21 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
try { try {
bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => { bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -806,7 +821,7 @@ try { ...@@ -806,7 +821,7 @@ try {
getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void; getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
以异步方法根据给定的appFlags获取多个ApplicationInfo,使用callback形式返回结果。 以异步方法根据给定的appFlags获取系统中所有的ApplicationInfo,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -832,19 +847,20 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb ...@@ -832,19 +847,20 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
bundleManager.getAllApplicationInfo(appFlags, (err, data) => { bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
if (err) { if (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -852,7 +868,7 @@ try { ...@@ -852,7 +868,7 @@ try {
getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>; getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>;
以异步方法根据给定的appFlags和userId获取多个ApplicationInfo,使用Promise形式返回结果。 以异步方法根据给定的appFlags和userId获取系统中所有的ApplicationInfo,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -884,17 +900,18 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr ...@@ -884,17 +900,18 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
bundleManager.getAllApplicationInfo(appFlags).then((data) => { bundleManager.getAllApplicationInfo(appFlags).then((data) => {
console.info('getAllApplicationInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAllApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAllApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -915,7 +932,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe ...@@ -915,7 +932,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------ | ---- | ------------------------------------------------------- | | ------------ | ------ | ---- | ------------------------------------------------------- |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息。 | | abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息。 |
| userId | number | 是 | 表示用户ID。 | | userId | number | 是 | 表示用户ID。 |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 | | callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 |
...@@ -935,7 +952,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe ...@@ -935,7 +952,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -946,13 +964,13 @@ let want = { ...@@ -946,13 +964,13 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -972,7 +990,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy ...@@ -972,7 +990,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------ | ---- | -------------------------------------------------------| | ------------ | ------ | ---- | -------------------------------------------------------|
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息。 | | abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息。 |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 | | callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 |
...@@ -991,7 +1009,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy ...@@ -991,7 +1009,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
...@@ -1001,13 +1020,13 @@ let want = { ...@@ -1001,13 +1020,13 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => { bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
if (err) { if (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1027,7 +1046,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb ...@@ -1027,7 +1046,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------ | ---- | ------------------------------------------------------- | | ------------ | ------ | ---- | ------------------------------------------------------- |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| abilityFlags | [number](#abilityflag) | 是 | 表示指定返回的AbilityInfo所包含的信息。 | | abilityFlags | [number](#abilityflag) | 是 | 表示指定返回的AbilityInfo所包含的信息。 |
| userId | number | 否 | 表示用户ID。 | | userId | number | 否 | 表示用户ID。 |
...@@ -1052,7 +1071,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb ...@@ -1052,7 +1071,8 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1062,17 +1082,18 @@ let want = { ...@@ -1062,17 +1082,18 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
...@@ -1081,12 +1102,12 @@ let want = { ...@@ -1081,12 +1102,12 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}) })
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1106,10 +1127,10 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1106,10 +1127,10 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 | | extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 |
| userId | number | 是 | 表示用户ID。 | | userId | number | 是 | 表示用户ID。 |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 | | callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 |
**错误码:** **错误码:**
...@@ -1126,7 +1147,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1126,7 +1147,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
...@@ -1138,13 +1160,13 @@ let want = { ...@@ -1138,13 +1160,13 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1164,9 +1186,9 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1164,9 +1186,9 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 | | extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 |
| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 | | callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 |
**错误码:** **错误码:**
...@@ -1183,7 +1205,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1183,7 +1205,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = { let want = {
...@@ -1194,13 +1217,13 @@ let want = { ...@@ -1194,13 +1217,13 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
if (err) { if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1218,9 +1241,9 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1218,9 +1241,9 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------------- | --------------------------------------------- | ---- | ------------------------------------------------------- | | --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
| want | Want | 是 | 表示包含要查询的应用程序包名称的Want。 | | want | Want | 是 | 表示包含要查询的应用Bundle名称的Want。 |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型。 |
| extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 | | extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 |
| userId | number | 否 | 表示用户ID。 | | userId | number | 否 | 表示用户ID。 |
...@@ -1245,7 +1268,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1245,7 +1268,8 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
...@@ -1257,17 +1281,18 @@ let want = { ...@@ -1257,17 +1281,18 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = { let want = {
...@@ -1277,12 +1302,12 @@ let want = { ...@@ -1277,12 +1302,12 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
}) })
} catch (error) { } catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1290,7 +1315,7 @@ try { ...@@ -1290,7 +1315,7 @@ try {
getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void; getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
以异步方法根据给定的uid获取bundleName,使用callback形式返回结果。 以异步方法根据给定的uid获取对应的bundleName,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1316,18 +1341,19 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void; ...@@ -1316,18 +1341,19 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
bundleManager.getBundleNameByUid(uid, (err, data) => { bundleManager.getBundleNameByUid(uid, (err, data) => {
if (err) { if (err) {
console.error('getBundleNameByUid failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleNameByUid successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleNameByUid failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s' + err.message);
} }
``` ```
...@@ -1335,7 +1361,7 @@ try { ...@@ -1335,7 +1361,7 @@ try {
getBundleNameByUid(uid: number): Promise\<string>; getBundleNameByUid(uid: number): Promise\<string>;
以异步方法根据给定的uid获取bundleName,使用Promise形式返回结果。 以异步方法根据给定的uid获取对应的bundleName,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1366,16 +1392,17 @@ getBundleNameByUid(uid: number): Promise\<string>; ...@@ -1366,16 +1392,17 @@ getBundleNameByUid(uid: number): Promise\<string>;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
bundleManager.getBundleNameByUid(uid).then((data) => { bundleManager.getBundleNameByUid(uid).then((data) => {
console.info('getBundleNameByUid successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleNameByUid failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleNameByUid failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1410,20 +1437,21 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca ...@@ -1410,20 +1437,21 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap"; let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleArchiveInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} else { } else {
console.info('getBundleArchiveInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleArchiveInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1463,18 +1491,19 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): ...@@ -1463,18 +1491,19 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)):
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap"; let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => { bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
console.info('getBundleArchiveInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1482,7 +1511,7 @@ try { ...@@ -1482,7 +1511,7 @@ try {
cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void; cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
以异步方法根据给定的bundleName清理BundleCache,并获取清理结果,使用callback形式返回结果。 以异步方法根据给定的bundleName清理BundleCache,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1509,19 +1538,20 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void; ...@@ -1509,19 +1538,20 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.cleanBundleCacheFiles(bundleName, err => { bundleManager.cleanBundleCacheFiles(bundleName, err => {
if (err) { if (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} else { } else {
console.info('cleanBundleCacheFiles successfully.'); hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
} }
}); });
} catch (err) { } catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} }
``` ```
...@@ -1529,7 +1559,7 @@ try { ...@@ -1529,7 +1559,7 @@ try {
cleanBundleCacheFiles(bundleName: string): Promise\<void>; cleanBundleCacheFiles(bundleName: string): Promise\<void>;
以异步方法根据给定的bundleName清理BundleCache,并获取清理结果,使用Promise形式返回结果。 以异步方法根据给定的bundleName清理BundleCache,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1547,7 +1577,7 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>; ...@@ -1547,7 +1577,7 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------------------------------ | | -------------- | ------------------------------------------------------------ |
| Promise\<void> | Promise对象,返回true表示清理应用缓存目录数据成功,返回false表示清理应用缓存目录数据失败。 | | Promise\<void> | 无返回结果的Promise对象。当清理应用缓存目录数据失败会抛出错误对象。 |
**错误码:** **错误码:**
...@@ -1561,17 +1591,18 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>; ...@@ -1561,17 +1591,18 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.cleanBundleCacheFiles(bundleName).then(()=> { bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
console.info('cleanBundleCacheFiles successfully.'); hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}).catch(err=> { }).catch(err => {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
}); });
} catch (err) { } catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} }
``` ```
...@@ -1579,7 +1610,7 @@ try { ...@@ -1579,7 +1610,7 @@ try {
setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void; setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void;
设置指定应用的禁用使能状态,使用callback形式返回结果。 设置指定应用的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1593,7 +1624,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal ...@@ -1593,7 +1624,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
| ---------- | ------- | ---- | ------------------------------------- | | ---------- | ------- | ---- | ------------------------------------- |
| bundleName | string | 是 | 指定应用的bundleName。 | | bundleName | string | 是 | 指定应用的bundleName。 |
| isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用。 | | isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置应用禁用使能状态成功时,err为null,否则为错误对象。 | | callback | AsyncCallback\<void> | 是 | 回调函数,当设置应用禁用使能状态成功时,err为null,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -1606,19 +1637,20 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal ...@@ -1606,19 +1637,20 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.setApplicationEnabled(bundleName, false, err => { bundleManager.setApplicationEnabled(bundleName, false, err => {
if (err) { if (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('setApplicationEnabled successfully.'); hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
} }
}); });
} catch (err) { } catch (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1626,7 +1658,7 @@ try { ...@@ -1626,7 +1658,7 @@ try {
setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>; setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
设置指定应用的禁用使能状态,使用Promise形式返回结果。 设置指定应用的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1658,17 +1690,18 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>; ...@@ -1658,17 +1690,18 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.setApplicationEnabled(bundleName, false).then(()=> { bundleManager.setApplicationEnabled(bundleName, false).then(() => {
console.info('setApplicationEnabled successfully.'); hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
}).catch(err=> { }).catch(err => {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
}); });
} catch (err) { } catch (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1676,7 +1709,7 @@ try { ...@@ -1676,7 +1709,7 @@ try {
setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void; setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void;
设置指定组件的禁用使能状态,使用callback形式返回结果。 设置指定组件的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1690,7 +1723,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1690,7 +1723,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
| -------- | ----------- | ---- | ------------------------------------- | | -------- | ----------- | ---- | ------------------------------------- |
| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件。 | | info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件。 |
| isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用。 | | isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置组件禁用使能状态成功时,err为null,否则为错误对象。 | | callback | AsyncCallback\<void> | 是 | 回调函数,当设置组件禁用使能状态成功时,err为null,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -1704,32 +1737,33 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1704,32 +1737,33 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility" abilityName : "com.example.myapplication.MainAbility"
}; };
var info; let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false, err => { bundleManager.setAbilityEnabled(info, false, err => {
if (err) { if (err) {
console.error('setAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('setAbilityEnabled successfully.'); hilog.info(0x0001, "testTag", "setAbilityEnabled successfully.");
} }
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1737,7 +1771,7 @@ try { ...@@ -1737,7 +1771,7 @@ try {
setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>; setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>;
设置指定组件的禁用使能状态,使用Promise形式返回结果。 设置指定组件的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1770,30 +1804,31 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1770,30 +1804,31 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility" abilityName : "com.example.myapplication.MainAbility"
}; };
var info; let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false).then(()=> { bundleManager.setAbilityEnabled(info, false).then(() => {
console.info('setAbilityEnabled successfully.'); hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
}).catch(err=> { }).catch(err => {
console.error('setAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1801,7 +1836,7 @@ try { ...@@ -1801,7 +1836,7 @@ try {
isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void; isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void;
以异步的方法获取指定应用的禁用使能状态,使用callback形式返回结果。 以异步的方法获取指定应用的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1825,19 +1860,20 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi ...@@ -1825,19 +1860,20 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.isApplicationEnabled(bundleName, (err, data) => { bundleManager.isApplicationEnabled(bundleName, (err, data) => {
if (err) { if (err) {
console.error('isApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('isApplicationEnabled successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('isApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1845,7 +1881,7 @@ try { ...@@ -1845,7 +1881,7 @@ try {
isApplicationEnabled(bundleName: string): Promise\<boolean>; isApplicationEnabled(bundleName: string): Promise\<boolean>;
以异步的方法获取指定应用的禁用使能状态,使用Promise形式返回结果。 以异步的方法获取指定应用的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1874,17 +1910,18 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>; ...@@ -1874,17 +1910,18 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.isApplicationEnabled(bundleName).then((data) => { bundleManager.isApplicationEnabled(bundleName).then((data) => {
console.info('isApplicationEnabled successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('isApplicationEnabled failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('isApplicationEnabled failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1892,7 +1929,7 @@ try { ...@@ -1892,7 +1929,7 @@ try {
isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void; isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void;
以异步的方法获取指定组件的禁用使能状态,使用callback形式返回结果。 以异步的方法获取指定组件的禁用使能状态,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1917,32 +1954,33 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call ...@@ -1917,32 +1954,33 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility" abilityName : "com.example.myapplication.MainAbility"
}; };
var info; let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info, (err, data) => { bundleManager.isAbilityEnabled(info, (err, data) => {
if (err) { if (err) {
console.error('isAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('isAbilityEnabled successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', + JSON.stringify(data));
} }
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1950,7 +1988,7 @@ try { ...@@ -1950,7 +1988,7 @@ try {
isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>; isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>;
以异步的方法获取指定组件的禁用使能状态,使用Promise形式返回结果。 以异步的方法获取指定组件的禁用使能状态,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -1980,30 +2018,31 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro ...@@ -1980,30 +2018,31 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility" abilityName : "com.example.myapplication.MainAbility"
}; };
var info; let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info).then((data) => { bundleManager.isAbilityEnabled(info).then((data) => {
console.info('isAbilityEnabled successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(err => { }).catch(err => {
console.error('isAbilityEnabled failed. Cause: ' + err.message); hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s' + err.message);
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2011,7 +2050,7 @@ try { ...@@ -2011,7 +2050,7 @@ try {
getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void; getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void;
以异步方法根据给定的bundleName和userId获取用于启动应用程序主要功能,使用callback形式返回结果。 以异步方法根据给定的bundleName和userId获取用于启动应用程序的Want参数,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -2040,20 +2079,21 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba ...@@ -2040,20 +2079,21 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
try { try {
bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => { bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
if (err) { if (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else { } else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} }
``` ```
...@@ -2061,7 +2101,7 @@ try { ...@@ -2061,7 +2101,7 @@ try {
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void; getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
以异步方法根据给定的bundleName获取用于启动应用程序主要功能,使用callback形式返回结果。 以异步方法根据给定的bundleName获取用于启动应用程序的Want参数,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -2089,19 +2129,20 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void ...@@ -2089,19 +2129,20 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.getLaunchWantForBundle(bundleName, (err, data) => { bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) { if (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else { } else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} }
``` ```
...@@ -2109,7 +2150,7 @@ try { ...@@ -2109,7 +2150,7 @@ try {
getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>; getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
以异步方法根据给定的bundleName和userId获取用于启动应用程序主要功能,使用Promise形式返回结果。 以异步方法根据给定的bundleName和userId获取用于启动应用程序的Want参数,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -2143,18 +2184,19 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>; ...@@ -2143,18 +2184,19 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
try { try {
bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => { bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
console.info('getLaunchWantForBundle successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2190,7 +2232,8 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin ...@@ -2190,7 +2232,8 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
...@@ -2198,13 +2241,13 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2198,13 +2241,13 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
if (err) { if (err) {
console.error('getProfileByAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} else { } else {
console.info('getProfileByAbility successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getProfileByAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2245,34 +2288,36 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri ...@@ -2245,34 +2288,36 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => { bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2307,7 +2352,8 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2307,7 +2352,8 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
...@@ -2315,13 +2361,13 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2315,13 +2361,13 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
if (err) { if (err) {
console.error('getProfileByExtensionAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s' + err.message);
} else { } else {
console.info('getProfileByExtensionAbility successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getProfileByExtensionAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s' + err.message);
} }
``` ```
...@@ -2361,29 +2407,30 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2361,29 +2407,30 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
} }
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2391,7 +2438,7 @@ try { ...@@ -2391,7 +2438,7 @@ try {
getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void; getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void;
以异步方法根据给定的permissionName获取PermissionDef,使用callback形式返回结果。 以异步方法根据给定的permissionName获取权限定义结构体PermissionDef信息,使用callback形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -2417,18 +2464,19 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef ...@@ -2417,18 +2464,19 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permission = "ohos.permission.GET_BUNDLE_INFO"; let permission = "ohos.permission.GET_BUNDLE_INFO";
try { try {
bundleManager.getPermissionDef(permission, (err, data) => { bundleManager.getPermissionDef(permission, (err, data) => {
if (err) { if (err) {
console.error('getPermissionDef failed:' + err.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s' + err.message);
} else { } else {
console.info('getPermissionDef successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getPermissionDef failed:' + err.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s' + err.message);
} }
``` ```
...@@ -2436,7 +2484,7 @@ try { ...@@ -2436,7 +2484,7 @@ try {
getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>; getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>;
以异步方法根据给定的permissionName获取PermissionDef,使用Promise形式返回结果。 以异步方法根据给定的permissionName获取权限定义结构体PermissionDef信息,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -2467,16 +2515,17 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl ...@@ -2467,16 +2515,17 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permissionName = "ohos.permission.GET_BUNDLE_INFO"; let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try { try {
bundleManager.getPermissionDef(permissionName).then((data) => { bundleManager.getPermissionDef(permissionName).then((data) => {
console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getPermissionDef failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getPermissionDef failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2516,7 +2565,8 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal ...@@ -2516,7 +2565,8 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
...@@ -2524,13 +2574,13 @@ let abilityName = 'MainAbility'; ...@@ -2524,13 +2574,13 @@ let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => { bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
if (err) { if (err) {
console.error('getAbilityLabel failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s' + err.message);
} else { } else {
console.info('getAbilityLabel successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAbilityLabel failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s' + err.message);
} }
``` ```
...@@ -2575,19 +2625,20 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr ...@@ -2575,19 +2625,20 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => { bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityLabel successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAbilityLabel failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAbilityLabel failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2627,7 +2678,8 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call ...@@ -2627,7 +2678,8 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
...@@ -2635,13 +2687,13 @@ let abilityName = 'MainAbility'; ...@@ -2635,13 +2687,13 @@ let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => { bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
if (err) { if (err) {
console.error('getAbilityIcon failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed: %{public}s' + err.message);
} else { } else {
console.info('getAbilityIcon successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAbilityIcon failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed: %{public}s' + err.message);
} }
``` ```
...@@ -2686,19 +2738,20 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro ...@@ -2686,19 +2738,20 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => { bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityIcon successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAbilityIcon failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAbilityIcon failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2706,13 +2759,13 @@ try { ...@@ -2706,13 +2759,13 @@ try {
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
以同步方法根据给定的bundleName、applicationFlags和userId获取ApplicationInfo 以同步方法根据给定的bundleName、applicationFlags和userId获取ApplicationInfo
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:** **参数:**
...@@ -2720,7 +2773,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num ...@@ -2720,7 +2773,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
| ----------- | ------ | ---- | ----------------------------------------------------------| | ----------- | ------ | ---- | ----------------------------------------------------------|
| bundleName | string | 是 | 表示应用程序的bundleName。 | | bundleName | string | 是 | 表示应用程序的bundleName。 |
| applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息。 | | applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息。 |
| userId | number | | 表示用户ID。 | | userId | number | | 表示用户ID。 |
**返回值:** **返回值:**
...@@ -2741,65 +2794,31 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num ...@@ -2741,65 +2794,31 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
try { try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getApplicationInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s' + 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/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found. |
| 17700026 | The specified bundle is disabled. |
**示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getApplicationInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s' + err.message);
} }
``` ```
...@@ -2821,7 +2840,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId ...@@ -2821,7 +2840,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
| ----------- | ------ | ---- | -------------------------------------------------------- | | ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | 是 | 表示应用程序的bundleName。 | | bundleName | string | 是 | 表示应用程序的bundleName。 |
| bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志。 | | bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志。 |
| userId | number | | 表示用户ID。 | | userId | number | | 表示用户ID。 |
**返回值:** **返回值:**
...@@ -2842,64 +2861,29 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId ...@@ -2842,64 +2861,29 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100; let userId = 100;
try { try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getBundleInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s' + 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/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. |
**示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager' import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try { try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getBundleInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s' + err.message);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册