未验证 提交 e526edf1 编写于 作者: O openharmony_ci 提交者: Gitee

!23418 【修改挑单monthly】批量修改场景---catch 明确错误码类型

Merge pull request !23418 from junyi233/monthly
...@@ -250,16 +250,18 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( ...@@ -250,16 +250,18 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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) => {
hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
} }
``` ```
...@@ -282,6 +284,7 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback ...@@ -282,6 +284,7 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
...@@ -294,7 +297,8 @@ try { ...@@ -294,7 +297,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
} }
``` ```
...@@ -336,6 +340,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: ...@@ -336,6 +340,7 @@ 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 { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -350,13 +355,15 @@ try { ...@@ -350,13 +355,15 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
} }
``` ```
```ts ```ts
// 额外获取ApplicationInfo中的metadata // 额外获取ApplicationInfo中的metadata
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -371,7 +378,8 @@ try { ...@@ -371,7 +378,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -411,6 +419,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< ...@@ -411,6 +419,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
```ts ```ts
// 额外获取extensionAbility // 额外获取extensionAbility
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -424,7 +433,8 @@ try { ...@@ -424,7 +433,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -471,6 +481,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n ...@@ -471,6 +481,7 @@ 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 { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -479,16 +490,18 @@ let userId = 100; ...@@ -479,16 +490,18 @@ let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -496,11 +509,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; ...@@ -496,11 +509,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -542,6 +556,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -542,6 +556,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -556,7 +571,8 @@ try { ...@@ -556,7 +571,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
} }
``` ```
...@@ -595,6 +611,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ...@@ -595,6 +611,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -608,7 +625,8 @@ try { ...@@ -608,7 +625,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
} }
``` ```
...@@ -654,6 +672,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -654,6 +672,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -662,11 +681,12 @@ let userId = 100; ...@@ -662,11 +681,12 @@ let userId = 100;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => { bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -702,6 +722,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A ...@@ -702,6 +722,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -715,7 +736,8 @@ try { ...@@ -715,7 +736,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -742,6 +764,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr ...@@ -742,6 +764,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
...@@ -754,7 +777,8 @@ try { ...@@ -754,7 +777,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -795,17 +819,19 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A ...@@ -795,17 +819,19 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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) => {
hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -841,6 +867,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call ...@@ -841,6 +867,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -854,7 +881,8 @@ try { ...@@ -854,7 +881,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
} }
``` ```
...@@ -881,6 +909,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb ...@@ -881,6 +909,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
...@@ -893,7 +922,8 @@ try { ...@@ -893,7 +922,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
} }
``` ```
...@@ -934,17 +964,19 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr ...@@ -934,17 +964,19 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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) => {
hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -986,6 +1018,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe ...@@ -986,6 +1018,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1003,7 +1036,8 @@ try { ...@@ -1003,7 +1036,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
} }
``` ```
...@@ -1042,6 +1076,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy ...@@ -1042,6 +1076,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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 = {
...@@ -1058,7 +1093,8 @@ try { ...@@ -1058,7 +1093,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
} }
``` ```
...@@ -1104,6 +1140,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb ...@@ -1104,6 +1140,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1115,16 +1152,18 @@ let want = { ...@@ -1115,16 +1152,18 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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 = {
...@@ -1135,11 +1174,12 @@ let want = { ...@@ -1135,11 +1174,12 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}) })
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1180,6 +1220,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1180,6 +1220,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1198,7 +1239,8 @@ try { ...@@ -1198,7 +1239,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
} }
``` ```
...@@ -1237,6 +1279,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1237,6 +1279,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1254,7 +1297,8 @@ try { ...@@ -1254,7 +1297,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
} }
``` ```
...@@ -1300,6 +1344,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1300,6 +1344,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
...@@ -1317,12 +1362,14 @@ try { ...@@ -1317,12 +1362,14 @@ try {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1334,11 +1381,12 @@ let want = { ...@@ -1334,11 +1381,12 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
}) })
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1373,6 +1421,7 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void; ...@@ -1373,6 +1421,7 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
...@@ -1384,7 +1433,8 @@ try { ...@@ -1384,7 +1433,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message);
} }
``` ```
...@@ -1424,6 +1474,7 @@ getBundleNameByUid(uid: number): Promise\<string>; ...@@ -1424,6 +1474,7 @@ getBundleNameByUid(uid: number): Promise\<string>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
...@@ -1433,7 +1484,8 @@ try { ...@@ -1433,7 +1484,8 @@ try {
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1469,6 +1521,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca ...@@ -1469,6 +1521,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1482,7 +1535,8 @@ try { ...@@ -1482,7 +1535,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1523,6 +1577,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): ...@@ -1523,6 +1577,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)):
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1530,11 +1585,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; ...@@ -1530,11 +1585,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => { bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1570,6 +1626,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void; ...@@ -1570,6 +1626,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
...@@ -1582,7 +1639,8 @@ try { ...@@ -1582,7 +1639,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
} }
``` ```
...@@ -1623,17 +1681,19 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>; ...@@ -1623,17 +1681,19 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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(() => {
hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.'); hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
} }
``` ```
...@@ -1669,6 +1729,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal ...@@ -1669,6 +1729,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
...@@ -1681,7 +1742,8 @@ try { ...@@ -1681,7 +1742,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
} }
``` ```
...@@ -1722,6 +1784,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>; ...@@ -1722,6 +1784,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
...@@ -1732,7 +1795,8 @@ try { ...@@ -1732,7 +1795,8 @@ try {
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
} }
``` ```
...@@ -1769,6 +1833,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1769,6 +1833,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1794,7 +1859,8 @@ try { ...@@ -1794,7 +1859,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1836,6 +1902,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1836,6 +1902,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -1859,7 +1926,8 @@ try { ...@@ -1859,7 +1926,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1892,6 +1960,7 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi ...@@ -1892,6 +1960,7 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
...@@ -1904,7 +1973,8 @@ try { ...@@ -1904,7 +1973,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', message);
} }
``` ```
...@@ -1942,17 +2012,19 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>; ...@@ -1942,17 +2012,19 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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) => {
hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message);
} }
``` ```
...@@ -1986,6 +2058,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call ...@@ -1986,6 +2058,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2007,11 +2080,12 @@ try { ...@@ -2007,11 +2080,12 @@ try {
hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data));
} }
}); });
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2050,6 +2124,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro ...@@ -2050,6 +2124,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2073,7 +2148,8 @@ try { ...@@ -2073,7 +2148,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2111,6 +2187,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba ...@@ -2111,6 +2187,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
...@@ -2124,7 +2201,8 @@ try { ...@@ -2124,7 +2201,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
} }
``` ```
...@@ -2160,6 +2238,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void ...@@ -2160,6 +2238,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
...@@ -2172,7 +2251,8 @@ try { ...@@ -2172,7 +2251,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
} }
``` ```
...@@ -2215,6 +2295,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>; ...@@ -2215,6 +2295,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
...@@ -2222,11 +2303,12 @@ let userId = 100; ...@@ -2222,11 +2303,12 @@ let userId = 100;
try { try {
bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => { bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2263,6 +2345,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin ...@@ -2263,6 +2345,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'EntryAbility'; let abilityName = 'EntryAbility';
...@@ -2277,7 +2360,8 @@ try { ...@@ -2277,7 +2360,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2319,6 +2403,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri ...@@ -2319,6 +2403,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'EntryAbility'; let abilityName = 'EntryAbility';
...@@ -2330,12 +2415,14 @@ try { ...@@ -2330,12 +2415,14 @@ try {
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'EntryAbility'; let abilityName = 'EntryAbility';
...@@ -2343,11 +2430,12 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2343,11 +2430,12 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2383,6 +2471,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2383,6 +2471,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
...@@ -2397,7 +2486,8 @@ try { ...@@ -2397,7 +2486,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message);
} }
``` ```
...@@ -2438,6 +2528,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2438,6 +2528,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
...@@ -2446,21 +2537,23 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2446,21 +2537,23 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
} }
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2495,6 +2588,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef ...@@ -2495,6 +2588,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let permission = "ohos.permission.GET_BUNDLE_INFO"; let permission = "ohos.permission.GET_BUNDLE_INFO";
try { try {
...@@ -2506,7 +2600,8 @@ try { ...@@ -2506,7 +2600,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', message);
} }
``` ```
...@@ -2546,16 +2641,18 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl ...@@ -2546,16 +2641,18 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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) => {
hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2596,6 +2693,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal ...@@ -2596,6 +2693,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
...@@ -2610,7 +2708,8 @@ try { ...@@ -2610,7 +2708,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', message);
} }
``` ```
...@@ -2656,6 +2755,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr ...@@ -2656,6 +2755,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
...@@ -2664,11 +2764,12 @@ let abilityName = 'EntryAbility'; ...@@ -2664,11 +2764,12 @@ let abilityName = 'EntryAbility';
try { try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => { bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', message);
} }
``` ```
...@@ -2713,6 +2814,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num ...@@ -2713,6 +2814,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2722,7 +2824,8 @@ try { ...@@ -2722,7 +2824,8 @@ try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
} }
``` ```
...@@ -2764,6 +2867,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat ...@@ -2764,6 +2867,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2772,7 +2876,8 @@ try { ...@@ -2772,7 +2876,8 @@ try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
} }
``` ```
...@@ -2816,6 +2921,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId ...@@ -2816,6 +2921,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2825,7 +2931,8 @@ try { ...@@ -2825,7 +2931,8 @@ try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
} }
``` ```
...@@ -2867,6 +2974,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund ...@@ -2867,6 +2974,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
...@@ -2874,7 +2982,8 @@ try { ...@@ -2874,7 +2982,8 @@ try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
} }
``` ```
...@@ -2911,6 +3020,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCall ...@@ -2911,6 +3020,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCall
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'library'; let moduleName = 'library';
...@@ -2924,7 +3034,8 @@ try { ...@@ -2924,7 +3034,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -2966,6 +3077,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<Sha ...@@ -2966,6 +3077,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<Sha
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'library'; let moduleName = 'library';
...@@ -2973,11 +3085,12 @@ let moduleName = 'library'; ...@@ -2973,11 +3085,12 @@ let moduleName = 'library';
try { try {
bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => { bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => {
hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -3003,6 +3116,7 @@ getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): vo ...@@ -3003,6 +3116,7 @@ getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): vo
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
try { try {
...@@ -3014,7 +3128,8 @@ try { ...@@ -3014,7 +3128,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', message);
} }
``` ```
...@@ -3040,6 +3155,7 @@ getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>; ...@@ -3040,6 +3155,7 @@ getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
try { try {
...@@ -3049,7 +3165,8 @@ try { ...@@ -3049,7 +3165,8 @@ try {
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -3084,6 +3201,7 @@ getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionIn ...@@ -3084,6 +3201,7 @@ getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionIn
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
...@@ -3096,7 +3214,8 @@ try { ...@@ -3096,7 +3214,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
} }
``` ```
...@@ -3134,6 +3253,7 @@ getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\ ...@@ -3134,6 +3253,7 @@ getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
let userId = 100; let userId = 100;
...@@ -3147,7 +3267,8 @@ try { ...@@ -3147,7 +3267,8 @@ try {
} }
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
} }
``` ```
...@@ -3190,6 +3311,7 @@ getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvision ...@@ -3190,6 +3311,7 @@ getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvision
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
let userId = 100; let userId = 100;
...@@ -3197,21 +3319,23 @@ let userId = 100; ...@@ -3197,21 +3319,23 @@ let userId = 100;
try { try {
bundleManager.getAppProvisionInfo(bundleName).then((data) => { bundleManager.getAppProvisionInfo(bundleName).then((data) => {
hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
} }
try { try {
bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => { bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => {
hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
}); });
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
} }
``` ```
...@@ -3249,13 +3373,15 @@ getSpecifiedDistributionType(bundleName: string): string; ...@@ -3249,13 +3373,15 @@ getSpecifiedDistributionType(bundleName: string): string;
**示例:** **示例:**
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
try { try {
let type = bundleManager.getSpecifiedDistributionType(bundleName); let type = bundleManager.getSpecifiedDistributionType(bundleName);
console.info('getSpecifiedDistributionType successfully, type:' + type); console.info('getSpecifiedDistributionType successfully, type:' + type);
} catch (error) { } catch (error) {
console.error('getSpecifiedDistributionType failed. Cause: ' + error.message); let message = (error as BusinessError).message;
console.error('getSpecifiedDistributionType failed. Cause: ' + message);
} }
``` ```
...@@ -3296,13 +3422,15 @@ getAdditionalInfo(bundleName: string): string; ...@@ -3296,13 +3422,15 @@ getAdditionalInfo(bundleName: string): string;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
try { try {
let info = bundleManager.getAdditionalInfo(bundleName); let info = bundleManager.getAdditionalInfo(bundleName);
console.info('getAdditionalInfo successfully, additionInfo:' + info); console.info('getAdditionalInfo successfully, additionInfo:' + info);
} catch (error) { } catch (error) {
console.error('getAdditionalInfo failed. Cause: ' + error.message); let message = (error as BusinessError).message;
console.error('getAdditionalInfo failed. Cause: ' + message);
} }
``` ```
...@@ -3330,12 +3458,14 @@ getBundleInfoForSelfSync(bundleFlags: number): BundleInfo; ...@@ -3330,12 +3458,14 @@ getBundleInfoForSelfSync(bundleFlags: number): BundleInfo;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog'; 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;
try { try {
let data = bundleManager.getBundleInfoForSelfSync(bundleFlags); let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
} catch (err) { } catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', err.message); let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
} }
``` ```
\ No newline at end of file
...@@ -45,6 +45,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\<void>; ...@@ -45,6 +45,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature"; let moduleName = "feature";
let isEnabled = false; let isEnabled = false;
...@@ -52,11 +54,13 @@ try { ...@@ -52,11 +54,13 @@ try {
overlay.setOverlayEnabled(moduleName, isEnabled) overlay.setOverlayEnabled(moduleName, isEnabled)
.then(() => { .then(() => {
console.info('setOverlayEnabled success'); console.info('setOverlayEnabled success');
}).catch((err) => { }).catch((err: BusinessError) => {
console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message); console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message);
}); });
} catch (err) { } catch (err) {
console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.info('setOverlayEnabled failed due to err code: ' + code + ' ' + 'message:' + message);
} }
``` ```
...@@ -88,6 +92,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback ...@@ -88,6 +92,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature"; let moduleName = "feature";
let isEnabled = false; let isEnabled = false;
...@@ -100,7 +106,9 @@ try { ...@@ -100,7 +106,9 @@ try {
console.info('setOverlayEnabled success'); console.info('setOverlayEnabled success');
}); });
} catch (err) { } catch (err) {
console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.info('setOverlayEnabled failed due to err code: ' + code + ' ' + 'message:' + message);
} }
``` ```
...@@ -144,6 +152,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b ...@@ -144,6 +152,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx"; let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
let isEnabled = false; let isEnabled = false;
...@@ -152,11 +162,13 @@ try { ...@@ -152,11 +162,13 @@ try {
overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled) overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled)
.then((data) => { .then((data) => {
console.info('setOverlayEnabledByBundleName successfully'); console.info('setOverlayEnabledByBundleName successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message);
}); });
} catch (err) { } catch (err) {
console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message);
} }
``` ```
...@@ -195,6 +207,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b ...@@ -195,6 +207,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx"; let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
let isEnabled = false; let isEnabled = false;
...@@ -208,7 +222,9 @@ try { ...@@ -208,7 +222,9 @@ try {
console.info('setOverlayEnabledByBundleName successfully'); console.info('setOverlayEnabledByBundleName successfully');
}); });
} catch (err) { } catch (err) {
console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.info('setOverlayEnabledByBundleName failed due to err code: ' + code + ' ' + 'message:' + message);
} }
``` ```
...@@ -245,6 +261,8 @@ getOverlayModuleInfo(moduleName: string): Promise\<OverlayModuleInfo>; ...@@ -245,6 +261,8 @@ getOverlayModuleInfo(moduleName: string): Promise\<OverlayModuleInfo>;
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature"; let moduleName = "feature";
(async() => { (async() => {
...@@ -252,7 +270,9 @@ let moduleName = "feature"; ...@@ -252,7 +270,9 @@ let moduleName = "feature";
let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName); let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName);
console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo)); console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo));
} catch(err) { } catch(err) {
console.log('getOverlayModuleInfo failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getOverlayModuleInfo failed due to err code : ' + code + ' ' + 'message :' + message);
} }
})(); })();
``` ```
...@@ -285,6 +305,8 @@ getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\<OverlayModuleI ...@@ -285,6 +305,8 @@ getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\<OverlayModuleI
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature"; let moduleName = "feature";
try { try {
overlay.getOverlayModuleInfo(moduleName, (err, data) => { overlay.getOverlayModuleInfo(moduleName, (err, data) => {
...@@ -295,7 +317,9 @@ try { ...@@ -295,7 +317,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getOverlayModuleInfo failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getOverlayModuleInfo failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
...@@ -331,6 +355,8 @@ getTargetOverlayModuleInfos(targetModuleName: string): Promise\<Array\<OverlayMo ...@@ -331,6 +355,8 @@ getTargetOverlayModuleInfos(targetModuleName: string): Promise\<Array\<OverlayMo
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetModuleName = "feature"; let targetModuleName = "feature";
(async() => { (async() => {
...@@ -338,7 +364,9 @@ let targetModuleName = "feature"; ...@@ -338,7 +364,9 @@ let targetModuleName = "feature";
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName); let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} catch(err) { } catch(err) {
console.log('getTargetOverlayModuleInfos failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message);
} }
})(); })();
``` ```
...@@ -370,6 +398,8 @@ getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\<A ...@@ -370,6 +398,8 @@ getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\<A
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetModuleName = "feature"; let targetModuleName = "feature";
try { try {
overlay.getTargetOverlayModuleInfos(targetModuleName, (err, data) => { overlay.getTargetOverlayModuleInfos(targetModuleName, (err, data) => {
...@@ -380,7 +410,9 @@ try { ...@@ -380,7 +410,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getTargetOverlayModuleInfos failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
...@@ -423,6 +455,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi ...@@ -423,6 +455,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx"; let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
...@@ -431,7 +465,9 @@ let moduleName = "feature"; ...@@ -431,7 +465,9 @@ let moduleName = "feature";
let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName); let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} catch(err) { } catch(err) {
console.log('getTargetOverlayModuleInfos failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfos failed due to err code : ' + code + ' ' + 'message :' + message);
} }
})(); })();
``` ```
...@@ -470,6 +506,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac ...@@ -470,6 +506,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx"; let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
...@@ -482,7 +520,9 @@ try { ...@@ -482,7 +520,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
...@@ -517,6 +557,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Ar ...@@ -517,6 +557,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Ar
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx"; let bundleName = "com.example.myapplication_xxxxx";
try { try {
...@@ -528,7 +570,9 @@ try { ...@@ -528,7 +570,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getOverlayModuleInfoByBundleName failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
...@@ -571,6 +615,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s ...@@ -571,6 +615,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx"; let targetBundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
...@@ -579,7 +625,9 @@ let moduleName = "feature"; ...@@ -579,7 +625,9 @@ let moduleName = "feature";
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName); let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} catch(err) { } catch(err) {
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message);
} }
})(); })();
``` ```
...@@ -618,6 +666,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st ...@@ -618,6 +666,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx"; let targetBundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature"; let moduleName = "feature";
...@@ -630,7 +680,9 @@ try { ...@@ -630,7 +680,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
...@@ -665,6 +717,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn ...@@ -665,6 +717,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn
**示例:** **示例:**
```ts ```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx"; let targetBundleName = "com.example.myapplication_xxxxx";
try { try {
...@@ -676,7 +730,9 @@ try { ...@@ -676,7 +730,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data)); console.log('overlayModuleInfo is ' + JSON.stringify(data));
}); });
} catch (err) { } catch (err) {
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + err.code + ' ' + 'message :' + err.message); let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.log('getTargetOverlayModuleInfosByBundleName failed due to err code : ' + code + ' ' + 'message :' + message);
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册