提交 d9158b84 编写于 作者: J junyi233

明确错误码类型

Signed-off-by: Njunyi233 <zhengjun29@huawei.com>
上级 6d1c3021
......@@ -250,16 +250,18 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfoForSelf(bundleFlags).then((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);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -294,7 +297,8 @@ try {
}
});
} 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:
```ts
// 额外获取AbilityInfo
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
......@@ -350,13 +355,15 @@ try {
}
});
} 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
// 额外获取ApplicationInfo中的metadata
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
......@@ -371,7 +378,8 @@ try {
}
});
} 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\<
```ts
// 额外获取extensionAbility
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
......@@ -424,7 +433,8 @@ try {
}
});
} 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
```ts
// 额外获取ApplicationInfo和SignatureInfo
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
......@@ -479,16 +490,18 @@ let userId = 100;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((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);
});
} 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
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -496,11 +509,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((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);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
......@@ -556,7 +571,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
......@@ -608,7 +625,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
......@@ -662,11 +681,12 @@ let userId = 100;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((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);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100;
......@@ -715,7 +736,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -754,7 +777,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getAllBundleInfo(bundleFlags).then((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);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
......@@ -854,7 +881,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
......@@ -893,7 +922,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
bundleManager.getAllApplicationInfo(appFlags).then((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);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -1003,7 +1036,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
......@@ -1058,7 +1093,8 @@ try {
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -1115,16 +1152,18 @@ let want = {
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((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);
});
} 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
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
......@@ -1135,11 +1174,12 @@ let want = {
try {
bundleManager.queryAbilityInfo(want, abilityFlags).then((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);
})
} 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);
}
```
......@@ -1185,6 +1225,7 @@ queryAbilityInfoSync(want: Want, abilityFlags: [number](#abilityflag), userId?:
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -1198,12 +1239,14 @@ try {
let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags, userId);
hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
} catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
......@@ -1215,7 +1258,8 @@ try {
let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags);
hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
} catch (err) {
hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
}
```
......@@ -1256,6 +1300,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
......@@ -1274,7 +1319,8 @@ try {
}
});
} 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);
}
```
......@@ -1313,6 +1359,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
......@@ -1330,7 +1377,8 @@ try {
}
});
} 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);
}
```
......@@ -1376,6 +1424,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
......@@ -1389,16 +1438,18 @@ let want = {
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((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);
});
} 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
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
......@@ -1410,11 +1461,12 @@ let want = {
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((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);
})
} 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);
}
```
......@@ -1460,6 +1512,7 @@ queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: [ExtensionAbilit
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
......@@ -1474,12 +1527,14 @@ try {
let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId);
hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
} catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
......@@ -1492,7 +1547,8 @@ try {
let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
} catch (err) {
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
}
```
......@@ -1527,6 +1583,7 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let uid = 20010005;
try {
......@@ -1538,7 +1595,8 @@ try {
}
});
} 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);
}
```
......@@ -1578,16 +1636,18 @@ getBundleNameByUid(uid: number): Promise\<string>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let uid = 20010005;
try {
bundleManager.getBundleNameByUid(uid).then((data) => {
hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -1627,13 +1687,15 @@ getBundleNameByUidSync(uid: number): string;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let uid = 20010005;
try {
let data = bundleManager.getBundleNameByUidSync(uid);
hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message);
}
```
......@@ -1669,6 +1731,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -1682,7 +1745,8 @@ try {
}
});
} 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);
}
```
......@@ -1723,6 +1787,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)):
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -1730,11 +1795,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((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);
});
} 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);
}
```
......@@ -1775,6 +1841,7 @@ getBundleArchiveInfoSync(hapFilePath: string, bundleFlags: number): BundleInfo;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
......@@ -1783,7 +1850,8 @@ try {
let data = bundleManager.getBundleArchiveInfoSync(hapFilePath, bundleFlags)
hilog.info(0x0000, 'testTag', 'getBundleArchiveInfoSync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', message);
}
```
......@@ -1819,6 +1887,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
......@@ -1831,7 +1900,8 @@ try {
}
});
} 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);
}
```
......@@ -1872,17 +1942,19 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
});
} 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);
}
```
......@@ -1918,6 +1990,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
......@@ -1930,7 +2003,8 @@ try {
}
});
} 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);
}
```
......@@ -1971,17 +2045,19 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.setApplicationEnabled(bundleName, false).then(() => {
hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
});
} 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);
}
```
......@@ -2016,6 +2092,7 @@ setApplicationEnabledSync(bundleName: string, isEnabled: boolean): void;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
......@@ -2023,7 +2100,8 @@ try {
bundleManager.setApplicationEnabledSync(bundleName, false);
hilog.info(0x0000, 'testTag', 'setApplicationEnabledSync successfully.');
} catch (err) {
hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', message);
}
```
......@@ -2060,6 +2138,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2081,11 +2160,12 @@ try {
hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
}
});
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -2127,6 +2207,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2143,14 +2224,15 @@ try {
bundleManager.setAbilityEnabled(info, false).then(() => {
hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
});
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -2186,6 +2268,7 @@ setAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md),
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2210,7 +2293,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -2243,6 +2327,7 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
......@@ -2255,7 +2340,8 @@ try {
}
});
} 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);
}
```
......@@ -2293,17 +2379,19 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
try {
bundleManager.isApplicationEnabled(bundleName).then((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);
});
} 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);
}
```
......@@ -2341,6 +2429,7 @@ isApplicationEnabledSync(bundleName: string): boolean;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
......@@ -2348,7 +2437,8 @@ try {
let data = bundleManager.isApplicationEnabledSync(bundleName);
hilog.info(0x0000, 'testTag', 'isApplicationEnabledSync successfully: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', message);
}
```
......@@ -2382,6 +2472,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2403,11 +2494,12 @@ try {
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);
});
} 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);
}
```
......@@ -2446,6 +2538,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2469,7 +2562,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -2508,6 +2602,7 @@ isAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)):
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -2532,7 +2627,8 @@ try {
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -2570,6 +2666,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
......@@ -2583,7 +2680,8 @@ try {
}
});
} 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);
}
```
......@@ -2619,6 +2717,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
......@@ -2631,7 +2730,8 @@ try {
}
});
} 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);
}
```
......@@ -2674,6 +2774,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
......@@ -2681,11 +2782,12 @@ let userId = 100;
try {
bundleManager.getLaunchWantForBundle(bundleName, userId).then((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);
});
} 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);
}
```
......@@ -2729,6 +2831,7 @@ getLaunchWantForBundleSync(bundleName: string, userId?: number): Want;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
......@@ -2737,12 +2840,14 @@ try {
let want = bundleManager.getLaunchWantForBundleSync(bundleName, userId);
hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
......@@ -2751,7 +2856,8 @@ try {
let want = bundleManager.getLaunchWantForBundleSync(bundleName);
hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
}
```
......@@ -2788,6 +2894,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'EntryAbility';
......@@ -2802,7 +2909,8 @@ try {
}
});
} 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);
}
```
......@@ -2844,6 +2952,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'EntryAbility';
......@@ -2851,16 +2960,18 @@ let abilityName = 'EntryAbility';
try {
bundleManager.getProfileByAbility(moduleName, abilityName).then((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);
});
} 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
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'EntryAbility';
......@@ -2868,11 +2979,12 @@ let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((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);
});
} 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);
}
```
......@@ -2914,6 +3026,7 @@ getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?:
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'EntryAbility';
......@@ -2922,12 +3035,14 @@ try {
let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName);
hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName: string = 'entry';
let abilityName: string = 'EntryAbility';
......@@ -2936,7 +3051,8 @@ try {
let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
}
```
......@@ -2972,6 +3088,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
......@@ -2986,7 +3103,8 @@ try {
}
});
} 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);
}
```
......@@ -3027,6 +3145,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
......@@ -3035,21 +3154,23 @@ let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((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);
});
} 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 {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((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);
});
} 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);
}
```
......@@ -3090,6 +3211,7 @@ getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: strin
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
......@@ -3099,14 +3221,16 @@ try {
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
}
try {
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
}
```
......@@ -3141,6 +3265,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let permission = "ohos.permission.GET_BUNDLE_INFO";
try {
......@@ -3152,7 +3277,8 @@ try {
}
});
} 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);
}
```
......@@ -3192,16 +3318,18 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try {
bundleManager.getPermissionDef(permissionName).then((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);
});
} 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);
}
```
......@@ -3241,13 +3369,15 @@ getPermissionDefSync(permissionName: string): [PermissionDef](js-apis-bundleMana
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try {
let PermissionDef = bundleManager.getPermissionDefSync(permission);
hilog.info(0x0000, 'testTag', 'getPermissionDefSync successfully. Data: %{public}s', JSON.stringify(PermissionDef));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', message);
}
```
......@@ -3288,6 +3418,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
......@@ -3302,7 +3433,8 @@ try {
}
});
} 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);
}
```
......@@ -3348,6 +3480,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
......@@ -3356,11 +3489,12 @@ let abilityName = 'EntryAbility';
try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((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);
});
} 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);
}
```
......@@ -3406,6 +3540,7 @@ getAbilityLabelSync(bundleName: string, moduleName: string, abilityName: string)
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
......@@ -3415,7 +3550,8 @@ try {
let abilityLabel = bundleManager.getAbilityLabelSync(bundleName, moduleName, abilityName);
hilog.info(0x0000, 'testTag', 'getAbilityLabelSync successfully. Data: %{public}s', abilityLabel);
} catch (err) {
hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', message);
}
```
......@@ -3459,6 +3595,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
......@@ -3468,7 +3605,8 @@ try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
} 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);
}
```
......@@ -3510,6 +3648,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
......@@ -3518,7 +3657,8 @@ try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
} 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);
}
```
......@@ -3562,6 +3702,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
......@@ -3571,7 +3712,8 @@ try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
} 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);
}
```
......@@ -3613,6 +3755,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
......@@ -3620,7 +3763,8 @@ try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
} 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);
}
```
......@@ -3657,6 +3801,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCall
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'library';
......@@ -3670,7 +3815,8 @@ try {
}
});
} 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);
}
```
......@@ -3712,6 +3858,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<Sha
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'library';
......@@ -3719,11 +3866,12 @@ let moduleName = 'library';
try {
bundleManager.getSharedBundleInfo(bundleName, moduleName).then((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);
});
} 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);
}
```
......@@ -3749,6 +3897,7 @@ getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): vo
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
try {
......@@ -3760,7 +3909,8 @@ try {
}
});
} 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);
}
```
......@@ -3786,16 +3936,18 @@ getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
try {
bundleManager.getAllSharedBundleInfo().then((data) => {
hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
}).catch(err => {
}).catch((err: BusinessError) => {
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
});
} 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);
}
```
......@@ -3830,6 +3982,7 @@ getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionIn
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
......@@ -3842,7 +3995,8 @@ try {
}
});
} 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);
}
```
......@@ -3880,6 +4034,7 @@ getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
let userId = 100;
......@@ -3893,7 +4048,8 @@ try {
}
});
} 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);
}
```
......@@ -3936,6 +4092,7 @@ getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvision
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
let userId = 100;
......@@ -3943,21 +4100,23 @@ let userId = 100;
try {
bundleManager.getAppProvisionInfo(bundleName).then((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);
});
} 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 {
bundleManager.getAppProvisionInfo(bundleName, userId).then((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);
});
} 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);
}
```
......@@ -4000,6 +4159,7 @@ getAppProvisionInfoSync(bundleName: string, userId?: number): AppProvisionInfo;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
let userId = 100;
......@@ -4008,14 +4168,16 @@ try {
let data = bundleManager.getAppProvisionInfoSync(bundleName);
hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
}
try {
let data = bundleManager.getAppProvisionInfoSync(bundleName, userId);
hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
} catch (err) {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', err.message);
let message = (err as BusinessError).message;
hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
}
```
......@@ -4053,13 +4215,15 @@ getSpecifiedDistributionType(bundleName: string): string;
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication";
try {
let type = bundleManager.getSpecifiedDistributionType(bundleName);
console.info('getSpecifiedDistributionType successfully, type:' + type);
} catch (error) {
console.error('getSpecifiedDistributionType failed. Cause: ' + error.message);
let message = (error as BusinessError).message;
console.error('getSpecifiedDistributionType failed. Cause: ' + message);
}
```
......@@ -4100,13 +4264,15 @@ getAdditionalInfo(bundleName: string): string;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication";
try {
let info = bundleManager.getAdditionalInfo(bundleName);
console.info('getAdditionalInfo successfully, additionInfo:' + info);
} catch (error) {
console.error('getAdditionalInfo failed. Cause: ' + error.message);
let message = (error as BusinessError).message;
console.error('getAdditionalInfo failed. Cause: ' + message);
}
```
......@@ -4134,12 +4300,14 @@ getBundleInfoForSelfSync(bundleFlags: number): BundleInfo;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try {
let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
} 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>;
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature";
let isEnabled = false;
......@@ -52,11 +54,13 @@ try {
overlay.setOverlayEnabled(moduleName, isEnabled)
.then(() => {
console.info('setOverlayEnabled success');
}).catch((err) => {
}).catch((err: BusinessError) => {
console.info('setOverlayEnabled failed due to err code: ' + err.code + ' ' + 'message:' + err.message);
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature";
let isEnabled = false;
......@@ -100,7 +106,9 @@ try {
console.info('setOverlayEnabled success');
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
let isEnabled = false;
......@@ -152,11 +162,13 @@ try {
overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled)
.then((data) => {
console.info('setOverlayEnabledByBundleName successfully');
}).catch((err) => {
}).catch((err: BusinessError) => {
console.info('setOverlayEnabledByBundleName failed due to err code: ' + err.code + ' ' + 'message:' + err.message);
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
let isEnabled = false;
......@@ -208,7 +222,9 @@ try {
console.info('setOverlayEnabledByBundleName successfully');
});
} 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>;
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature";
(async() => {
......@@ -252,7 +270,9 @@ let moduleName = "feature";
let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName);
console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo));
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let moduleName = "feature";
try {
overlay.getOverlayModuleInfo(moduleName, (err, data) => {
......@@ -295,7 +317,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetModuleName = "feature";
(async() => {
......@@ -338,7 +364,9 @@ let targetModuleName = "feature";
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetModuleName = "feature";
try {
overlay.getTargetOverlayModuleInfos(targetModuleName, (err, data) => {
......@@ -380,7 +410,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
......@@ -431,7 +465,9 @@ let moduleName = "feature";
let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
......@@ -482,7 +520,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let bundleName = "com.example.myapplication_xxxxx";
try {
......@@ -528,7 +570,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
......@@ -579,7 +625,9 @@ let moduleName = "feature";
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName);
console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx";
let moduleName = "feature";
......@@ -630,7 +680,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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
**示例:**
```ts
import overlay from '@ohos.bundle.overlay';
import { BusinessError } from '@ohos.base';
let targetBundleName = "com.example.myapplication_xxxxx";
try {
......@@ -676,7 +730,9 @@ try {
console.log('overlayModuleInfo is ' + JSON.stringify(data));
});
} 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.
先完成此消息的编辑!
想要评论请 注册