You need to sign in or sign up before continuing.
提交 297f7218 编写于 作者: G geng-wenguang

修改打印格式

Signed-off-by: Ngeng-wenguang <gengwenguang@huawei.com>
上级 4da793b5
...@@ -211,15 +211,16 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( ...@@ -211,15 +211,16 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
console.info('getBundleInfoForSelf successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfoForSelf failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', error.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfoForSelf failed:' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} }
``` ```
...@@ -242,18 +243,19 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback ...@@ -242,18 +243,19 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfoForSelf failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} else { } else {
console.info('getBundleInfoForSelf successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfoForSelf failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} }
``` ```
...@@ -293,6 +295,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: ...@@ -293,6 +295,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 hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
let userId = 100; let userId = 100;
...@@ -300,19 +303,20 @@ let userId = 100; ...@@ -300,19 +303,20 @@ let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
```ts ```ts
// 额外获取ApplicationInfo中的metadata // 额外获取ApplicationInfo中的metadata
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
let userId = 100; let userId = 100;
...@@ -320,13 +324,13 @@ let userId = 100; ...@@ -320,13 +324,13 @@ let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -365,19 +369,20 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< ...@@ -365,19 +369,20 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
```ts ```ts
// 额外获取extensionAbility // 额外获取extensionAbility
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -422,34 +427,36 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n ...@@ -422,34 +427,36 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n
```ts ```ts
// 额外获取ApplicationInfo和SignatureInfo // 额外获取ApplicationInfo和SignatureInfo
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
let userId = 100; let userId = 100;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => { bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -489,6 +496,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -489,6 +496,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
...@@ -496,13 +504,13 @@ let userId = 100; ...@@ -496,13 +504,13 @@ let userId = 100;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => { bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -540,19 +548,20 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ...@@ -540,19 +548,20 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => { bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
if (err) { if (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -596,18 +605,19 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -596,18 +605,19 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100; let userId = 100;
try { try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => { bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
console.info('getApplicationInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -643,19 +653,20 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A ...@@ -643,19 +653,20 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100; let userId = 100;
try { try {
bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => { bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -690,18 +701,19 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr ...@@ -690,18 +701,19 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getAllBundleInfo(bundleFlags, (err, data) => { bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllBundleInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -742,16 +754,17 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A ...@@ -742,16 +754,17 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getAllBundleInfo(bundleFlags).then((data) => { bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
console.info('getAllBundleInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAllBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAllBundleInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -787,19 +800,20 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call ...@@ -787,19 +800,20 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
try { try {
bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => { bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -834,18 +848,19 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb ...@@ -834,18 +848,19 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
bundleManager.getAllApplicationInfo(appFlags, (err, data) => { bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
if (err) { if (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else { } else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAllApplicationInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -886,16 +901,17 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr ...@@ -886,16 +901,17 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
bundleManager.getAllApplicationInfo(appFlags).then((data) => { bundleManager.getAllApplicationInfo(appFlags).then((data) => {
console.info('getAllApplicationInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAllApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAllApplicationInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -937,6 +953,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe ...@@ -937,6 +953,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -947,13 +964,13 @@ let want = { ...@@ -947,13 +964,13 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -993,6 +1010,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy ...@@ -993,6 +1010,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
...@@ -1002,13 +1020,13 @@ let want = { ...@@ -1002,13 +1020,13 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => { bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
if (err) { if (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1054,6 +1072,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb ...@@ -1054,6 +1072,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1063,17 +1082,18 @@ let want = { ...@@ -1063,17 +1082,18 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
...@@ -1082,12 +1102,12 @@ let want = { ...@@ -1082,12 +1102,12 @@ let want = {
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => { bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}) })
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1128,6 +1148,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1128,6 +1148,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
...@@ -1139,13 +1160,13 @@ let want = { ...@@ -1139,13 +1160,13 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
if (err) { if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1185,6 +1206,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1185,6 +1206,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = { let want = {
...@@ -1195,13 +1217,13 @@ let want = { ...@@ -1195,13 +1217,13 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
if (err) { if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else { } else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} }
``` ```
...@@ -1247,6 +1269,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1247,6 +1269,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
...@@ -1258,17 +1281,18 @@ let want = { ...@@ -1258,17 +1281,18 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = { let want = {
...@@ -1278,12 +1302,12 @@ let want = { ...@@ -1278,12 +1302,12 @@ let want = {
try { try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => { bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
}) })
} catch (error) { } catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1318,17 +1342,18 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void; ...@@ -1318,17 +1342,18 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
bundleManager.getBundleNameByUid(uid, (err, data) => { bundleManager.getBundleNameByUid(uid, (err, data) => {
if (err) { if (err) {
console.error('getBundleNameByUid failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s' + err.message);
} else { } else {
console.info('getBundleNameByUid successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleNameByUid failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s' + err.message);
} }
``` ```
...@@ -1368,15 +1393,16 @@ getBundleNameByUid(uid: number): Promise\<string>; ...@@ -1368,15 +1393,16 @@ getBundleNameByUid(uid: number): Promise\<string>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005; let uid = 20010005;
try { try {
bundleManager.getBundleNameByUid(uid).then((data) => { bundleManager.getBundleNameByUid(uid).then((data) => {
console.info('getBundleNameByUid successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleNameByUid failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleNameByUid failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1412,19 +1438,20 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca ...@@ -1412,19 +1438,20 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap"; let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) { if (err) {
console.error('getBundleArchiveInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} else { } else {
console.info('getBundleArchiveInfo successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getBundleArchiveInfo failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1465,17 +1492,18 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): ...@@ -1465,17 +1492,18 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)):
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap"; let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try { try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => { bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
console.info('getBundleArchiveInfo successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1511,18 +1539,19 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void; ...@@ -1511,18 +1539,19 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.cleanBundleCacheFiles(bundleName, err => { bundleManager.cleanBundleCacheFiles(bundleName, err => {
if (err) { if (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} else { } else {
console.info('cleanBundleCacheFiles successfully.'); hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
} }
}); });
} catch (err) { } catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} }
``` ```
...@@ -1563,16 +1592,17 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>; ...@@ -1563,16 +1592,17 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.cleanBundleCacheFiles(bundleName).then(() => { bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
console.info('cleanBundleCacheFiles successfully.'); hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}).catch(err => { }).catch(err => {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
}); });
} catch (err) { } catch (err) {
console.error('cleanBundleCacheFiles failed:' + err.message); hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} }
``` ```
...@@ -1608,18 +1638,19 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal ...@@ -1608,18 +1638,19 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.setApplicationEnabled(bundleName, false, err => { bundleManager.setApplicationEnabled(bundleName, false, err => {
if (err) { if (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('setApplicationEnabled successfully.'); hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
} }
}); });
} catch (err) { } catch (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1660,16 +1691,17 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>; ...@@ -1660,16 +1691,17 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication"; let bundleName = "com.ohos.myapplication";
try { try {
bundleManager.setApplicationEnabled(bundleName, false).then(() => { bundleManager.setApplicationEnabled(bundleName, false).then(() => {
console.info('setApplicationEnabled successfully.'); hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
}).catch(err => { }).catch(err => {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
}); });
} catch (err) { } catch (err) {
console.error('setApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1706,6 +1738,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1706,6 +1738,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 hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1716,21 +1749,21 @@ let info; ...@@ -1716,21 +1749,21 @@ let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false, err => { bundleManager.setAbilityEnabled(info, false, err => {
if (err) { if (err) {
console.error('setAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('setAbilityEnabled successfully.'); hilog.info(0x0001, "testTag", "setAbilityEnabled successfully.");
} }
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1772,6 +1805,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE ...@@ -1772,6 +1805,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 hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1782,19 +1816,19 @@ let info; ...@@ -1782,19 +1816,19 @@ let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.setAbilityEnabled(info, false).then(() => { bundleManager.setAbilityEnabled(info, false).then(() => {
console.info('setAbilityEnabled successfully.'); hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
}).catch(err => { }).catch(err => {
console.error('setAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1827,18 +1861,19 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi ...@@ -1827,18 +1861,19 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.isApplicationEnabled(bundleName, (err, data) => { bundleManager.isApplicationEnabled(bundleName, (err, data) => {
if (err) { if (err) {
console.error('isApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('isApplicationEnabled successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('isApplicationEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s' + err.message);
} }
``` ```
...@@ -1876,16 +1911,17 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>; ...@@ -1876,16 +1911,17 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.isApplicationEnabled(bundleName).then((data) => { bundleManager.isApplicationEnabled(bundleName).then((data) => {
console.info('isApplicationEnabled successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('isApplicationEnabled failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('isApplicationEnabled failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1919,6 +1955,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call ...@@ -1919,6 +1955,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 hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1929,21 +1966,21 @@ let info; ...@@ -1929,21 +1966,21 @@ let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info, (err, data) => { bundleManager.isAbilityEnabled(info, (err, data) => {
if (err) { if (err) {
console.error('isAbilityEnabled failed:' + err.message); hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s' + err.message);
} else { } else {
console.info('isAbilityEnabled successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', + JSON.stringify(data));
} }
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -1982,6 +2019,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro ...@@ -1982,6 +2019,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 hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1992,19 +2030,19 @@ let info; ...@@ -1992,19 +2030,19 @@ let info;
try { try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', + JSON.stringify(abilitiesInfo));
info = abilitiesInfo[0]; info = abilitiesInfo[0];
bundleManager.isAbilityEnabled(info).then((data) => { bundleManager.isAbilityEnabled(info).then((data) => {
console.info('isAbilityEnabled successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(err => { }).catch(err => {
console.error('isAbilityEnabled failed. Cause: ' + err.message); hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s' + err.message);
}); });
}).catch(error => { }).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2042,19 +2080,20 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba ...@@ -2042,19 +2080,20 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
try { try {
bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => { bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
if (err) { if (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else { } else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} }
``` ```
...@@ -2091,18 +2130,19 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void ...@@ -2091,18 +2130,19 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
try { try {
bundleManager.getLaunchWantForBundle(bundleName, (err, data) => { bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) { if (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else { } else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getLaunchWantForBundle failed:' + err.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} }
``` ```
...@@ -2145,17 +2185,18 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>; ...@@ -2145,17 +2185,18 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let userId = 100; let userId = 100;
try { try {
bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => { bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
console.info('getLaunchWantForBundle successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2192,6 +2233,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin ...@@ -2192,6 +2233,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
...@@ -2199,13 +2241,13 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2199,13 +2241,13 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
if (err) { if (err) {
console.error('getProfileByAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} else { } else {
console.info('getProfileByAbility successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getProfileByAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2247,33 +2289,35 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri ...@@ -2247,33 +2289,35 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => { bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2309,6 +2353,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2309,6 +2353,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
...@@ -2316,13 +2361,13 @@ let metadataName = 'com.example.myapplication.metadata'; ...@@ -2316,13 +2361,13 @@ let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
if (err) { if (err) {
console.error('getProfileByExtensionAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s' + err.message);
} else { } else {
console.info('getProfileByExtensionAbility successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getProfileByExtensionAbility failed:' + err.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s' + err.message);
} }
``` ```
...@@ -2363,28 +2408,29 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2363,28 +2408,29 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry'; let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension'; let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata'; let metadataName = 'com.example.myapplication.metadata';
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
} }
try { try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2419,17 +2465,18 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef ...@@ -2419,17 +2465,18 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permission = "ohos.permission.GET_BUNDLE_INFO"; let permission = "ohos.permission.GET_BUNDLE_INFO";
try { try {
bundleManager.getPermissionDef(permission, (err, data) => { bundleManager.getPermissionDef(permission, (err, data) => {
if (err) { if (err) {
console.error('getPermissionDef failed:' + err.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s' + err.message);
} else { } else {
console.info('getPermissionDef successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getPermissionDef failed:' + err.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s' + err.message);
} }
``` ```
...@@ -2469,15 +2516,16 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl ...@@ -2469,15 +2516,16 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permissionName = "ohos.permission.GET_BUNDLE_INFO"; let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try { try {
bundleManager.getPermissionDef(permissionName).then((data) => { bundleManager.getPermissionDef(permissionName).then((data) => {
console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getPermissionDef failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getPermissionDef failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2518,6 +2566,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal ...@@ -2518,6 +2566,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
...@@ -2525,13 +2574,13 @@ let abilityName = 'MainAbility'; ...@@ -2525,13 +2574,13 @@ let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => { bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
if (err) { if (err) {
console.error('getAbilityLabel failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s' + err.message);
} else { } else {
console.info('getAbilityLabel successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAbilityLabel failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s' + err.message);
} }
``` ```
...@@ -2577,18 +2626,19 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr ...@@ -2577,18 +2626,19 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => { bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityLabel successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAbilityLabel failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAbilityLabel failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2629,6 +2679,7 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call ...@@ -2629,6 +2679,7 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
...@@ -2636,13 +2687,13 @@ let abilityName = 'MainAbility'; ...@@ -2636,13 +2687,13 @@ let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => { bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
if (err) { if (err) {
console.error('getAbilityIcon failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed: %{public}s' + err.message);
} else { } else {
console.info('getAbilityIcon successfully:' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully: %{public}s', + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.error('getAbilityIcon failed:' + err.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed: %{public}s' + err.message);
} }
``` ```
...@@ -2688,18 +2739,19 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro ...@@ -2688,18 +2739,19 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let moduleName = 'entry'; let moduleName = 'entry';
let abilityName = 'MainAbility'; let abilityName = 'MainAbility';
try { try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => { bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityIcon successfully. Data: ' + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.error('getAbilityIcon failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed. Cause: %{public}s' + err.message);
}); });
} catch (error) { } catch (error) {
console.error('getAbilityIcon failed. Cause: ' + error.message); hilog.error(0x0000, 'testTag', 'getAbilityIcon failed. Cause: %{public}s' + err.message);
} }
``` ```
...@@ -2743,28 +2795,30 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num ...@@ -2743,28 +2795,30 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100; let userId = 100;
try { try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getApplicationInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try { try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags); let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getApplicationInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s' + err.message);
} }
``` ```
...@@ -2808,26 +2862,28 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId ...@@ -2808,26 +2862,28 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100; let userId = 100;
try { try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getBundleInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s' + err.message);
} }
``` ```
```ts ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication'; let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try { try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) { } catch (err) {
console.error('getBundleInfoSync failed:' + err.message); hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s' + err.message);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册