提交 297f7218 编写于 作者: G geng-wenguang

修改打印格式

Signed-off-by: Ngeng-wenguang <gengwenguang@huawei.com>
上级 4da793b5
......@@ -211,15 +211,16 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
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 => {
console.error('getBundleInfoForSelf failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', error.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
if (err) {
console.error('getBundleInfoForSelf failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', error.message);
} else {
console.info('getBundleInfoForSelf successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
}
});
} 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:
```ts
// 额外获取AbilityInfo
import bundleManager from '@ohos.bundle.bundleManager';
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;
let userId = 100;
......@@ -300,19 +303,20 @@ let userId = 100;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) {
console.error('getBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else {
console.info('getBundleInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} catch (err) {
console.error('getBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
}
```
```ts
// 额外获取ApplicationInfo中的metadata
import bundleManager from '@ohos.bundle.bundleManager';
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;
let userId = 100;
......@@ -320,13 +324,13 @@ let userId = 100;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) {
console.error('getBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else {
console.info('getBundleInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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\<
```ts
// 额外获取extensionAbility
import bundleManager from '@ohos.bundle.bundleManager';
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;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
if (err) {
console.error('getBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s' + err.message);
} else {
console.info('getBundleInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
// 额外获取ApplicationInfo和SignatureInfo
import bundleManager from '@ohos.bundle.bundleManager';
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;
let userId = 100;
try {
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 => {
console.error('getBundleInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
});
} catch (error) {
console.error('getBundleInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getBundleInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
......@@ -496,13 +504,13 @@ let userId = 100;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
if (err) {
console.error('getApplicationInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
if (err) {
console.error('getApplicationInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s' + err.message);
} else {
console.info('getApplicationInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100;
try {
bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
console.info('getApplicationInfo successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getApplicationInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100;
try {
bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
if (err) {
console.error('getAllBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
if (err) {
console.error('getAllBundleInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s' + err.message);
} else {
console.info('getAllBundleInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
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 => {
console.error('getAllBundleInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
try {
bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
if (err) {
console.error('getAllApplicationInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
if (err) {
console.error('getAllApplicationInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s' + err.message);
} else {
console.info('getAllApplicationInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
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 => {
console.error('getAllApplicationInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -947,13 +964,13 @@ let want = {
try {
bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
if (err) {
console.error('queryAbilityInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
......@@ -1002,13 +1020,13 @@ let want = {
try {
bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
if (err) {
console.error('queryAbilityInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s' + err.message);
} else {
console.info('queryAbilityInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -1063,17 +1082,18 @@ let want = {
try {
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 => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
});
} catch (error) {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let want = {
bundleName : "com.example.myapplication",
......@@ -1082,12 +1102,12 @@ let want = {
try {
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 => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
})
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let userId = 100;
......@@ -1139,13 +1160,13 @@ let want = {
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = {
......@@ -1195,13 +1217,13 @@ let want = {
try {
bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
if (err) {
console.error('queryExtensionAbilityInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s' + err.message);
} else {
console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
......@@ -1258,17 +1281,18 @@ let want = {
try {
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 => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
});
} catch (error) {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
let want = {
......@@ -1278,12 +1302,12 @@ let want = {
try {
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 => {
console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s' + err.message);
})
} 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;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005;
try {
bundleManager.getBundleNameByUid(uid, (err, data) => {
if (err) {
console.error('getBundleNameByUid failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s' + err.message);
} else {
console.info('getBundleNameByUid successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', + JSON.stringify(data));
}
});
} 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>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let uid = 20010005;
try {
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 => {
console.error('getBundleNameByUid failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) {
console.error('getBundleArchiveInfo failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
} else {
console.info('getBundleArchiveInfo successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', + JSON.stringify(data));
}
});
} 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)):
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
console.info('getBundleArchiveInfo successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getBundleArchiveInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s' + err.message);
});
} 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;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.cleanBundleCacheFiles(bundleName, err => {
if (err) {
console.error('cleanBundleCacheFiles failed:' + err.message);
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
} else {
console.info('cleanBundleCacheFiles successfully.');
hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}
});
} 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>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
console.info('cleanBundleCacheFiles successfully.');
hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
}).catch(err => {
console.error('cleanBundleCacheFiles failed:' + err.message);
hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.setApplicationEnabled(bundleName, false, err => {
if (err) {
console.error('setApplicationEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
} else {
console.info('setApplicationEnabled successfully.');
hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
}
});
} 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>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = "com.ohos.myapplication";
try {
bundleManager.setApplicationEnabled(bundleName, false).then(() => {
console.info('setApplicationEnabled successfully.');
hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
}).catch(err => {
console.error('setApplicationEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -1716,21 +1749,21 @@ let info;
try {
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];
bundleManager.setAbilityEnabled(info, false, err => {
if (err) {
console.error('setAbilityEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
} else {
console.info('setAbilityEnabled successfully.');
hilog.info(0x0001, "testTag", "setAbilityEnabled successfully.");
}
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -1782,19 +1816,19 @@ let info;
try {
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];
bundleManager.setAbilityEnabled(info, false).then(() => {
console.info('setAbilityEnabled successfully.');
hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
}).catch(err => {
console.error('setAbilityEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s' + err.message);
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
try {
bundleManager.isApplicationEnabled(bundleName, (err, data) => {
if (err) {
console.error('isApplicationEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s' + err.message);
} else {
console.info('isApplicationEnabled successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', + JSON.stringify(data));
}
});
} 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>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
try {
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 => {
console.error('isApplicationEnabled failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -1929,21 +1966,21 @@ let info;
try {
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];
bundleManager.isAbilityEnabled(info, (err, data) => {
if (err) {
console.error('isAbilityEnabled failed:' + err.message);
hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s' + err.message);
} else {
console.info('isAbilityEnabled successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', + JSON.stringify(data));
}
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
let userId = 100;
let want = {
......@@ -1992,19 +2030,19 @@ let info;
try {
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];
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 => {
console.error('isAbilityEnabled failed. Cause: ' + err.message);
hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s' + err.message);
});
}).catch(error => {
console.error('queryAbilityInfo failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
try {
bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
if (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
try {
bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) {
console.error('getLaunchWantForBundle failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s' + err.message);
} else {
console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', + JSON.stringify(data));
}
});
} 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>;
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let userId = 100;
try {
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 => {
console.error('getLaunchWantForBundle failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata';
......@@ -2199,13 +2241,13 @@ let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
if (err) {
console.error('getProfileByAbility failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
} else {
console.info('getProfileByAbility successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
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 => {
console.error('getProfileByAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
});
} catch (error) {
console.error('getProfileByAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'com.example.myapplication.metadata';
try {
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 => {
console.error('getProfileByAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata';
......@@ -2316,13 +2361,13 @@ let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
if (err) {
console.error('getProfileByExtensionAbility failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s' + err.message);
} else {
console.info('getProfileByExtensionAbility successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let moduleName = 'entry';
let extensionAbilityName = 'com.example.myapplication.extension';
let metadataName = 'com.example.myapplication.metadata';
try {
bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
});
} catch (error) {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
}
try {
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 => {
console.error('getProfileByExtensionAbility failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permission = "ohos.permission.GET_BUNDLE_INFO";
try {
bundleManager.getPermissionDef(permission, (err, data) => {
if (err) {
console.error('getPermissionDef failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s' + err.message);
} else {
console.info('getPermissionDef successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let permissionName = "ohos.permission.GET_BUNDLE_INFO";
try {
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 => {
console.error('getPermissionDef failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
......@@ -2525,13 +2574,13 @@ let abilityName = 'MainAbility';
try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('getAbilityLabel failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s' + err.message);
} else {
console.info('getAbilityLabel successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityLabel successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getAbilityLabel failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
......@@ -2636,13 +2687,13 @@ let abilityName = 'MainAbility';
try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
if (err) {
console.error('getAbilityIcon failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getAbilityIcon failed: %{public}s' + err.message);
} else {
console.info('getAbilityIcon successfully:' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully: %{public}s', + JSON.stringify(data));
}
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let abilityName = 'MainAbility';
try {
bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => {
console.info('getAbilityIcon successfully. Data: ' + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getAbilityIcon successfully. Data: %{public}s', + JSON.stringify(data));
}).catch(error => {
console.error('getAbilityIcon failed. Cause: ' + error.message);
hilog.error(0x0000, 'testTag', 'getAbilityIcon failed. Cause: %{public}s' + err.message);
});
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
let userId = 100;
try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) {
console.error('getApplicationInfoSync failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
try {
let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
console.info("getApplicationInfoSync successfully:" + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', + JSON.stringify(data));
} 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
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let userId = 100;
try {
let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
console.info("getBundleInfoSync successfully :" + JSON.stringify(data));
hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', + JSON.stringify(data));
} catch (err) {
console.error('getBundleInfoSync failed:' + err.message);
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s' + err.message);
}
```
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleName = 'com.example.myapplication';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try {
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) {
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.
先完成此消息的编辑!
想要评论请 注册