Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e526edf1
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e526edf1
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23418 【修改挑单monthly】批量修改场景---catch 明确错误码类型
Merge pull request !23418 from junyi233/monthly
上级
e4131e30
a15350a6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
290 addition
and
104 deletion
+290
-104
zh-cn/application-dev/reference/apis/js-apis-bundleManager.md
...n/application-dev/reference/apis/js-apis-bundleManager.md
+218
-88
zh-cn/application-dev/reference/apis/js-apis-overlay.md
zh-cn/application-dev/reference/apis/js-apis-overlay.md
+72
-16
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-bundleManager.md
浏览文件 @
e526edf1
...
...
@@ -250,16 +250,18 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
try
{
bundleManager
.
getBundleInfoForSelf
(
bundleFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf failed: %{public}s
'
,
message
);
}
```
...
...
@@ -282,6 +284,7 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
...
...
@@ -294,7 +297,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelf failed: %{public}s
'
,
message
);
}
```
...
...
@@ -336,6 +340,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback:
```
ts
// 额外获取AbilityInfo
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_HAP_MODULE
|
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_ABILITY
;
...
...
@@ -350,13 +355,15 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
message
);
}
```
```
ts
// 额外获取ApplicationInfo中的metadata
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_APPLICATION
|
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_METADATA
;
...
...
@@ -371,7 +378,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -411,6 +419,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
```
ts
// 额外获取extensionAbility
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_HAP_MODULE
|
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY
;
...
...
@@ -424,7 +433,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -471,6 +481,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n
```
ts
// 额外获取ApplicationInfo和SignatureInfo
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_APPLICATION
|
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
;
...
...
@@ -479,16 +490,18 @@ let userId = 100;
try
{
bundleManager
.
getBundleInfo
(
bundleName
,
bundleFlags
,
userId
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
message
);
}
```
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
...
...
@@ -496,11 +509,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try
{
bundleManager
.
getBundleInfo
(
bundleName
,
bundleFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -542,6 +556,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
...
...
@@ -556,7 +571,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -595,6 +611,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
...
...
@@ -608,7 +625,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -654,6 +672,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
...
...
@@ -662,11 +681,12 @@ let userId = 100;
try
{
bundleManager
.
getApplicationInfo
(
bundleName
,
appFlags
,
userId
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -702,6 +722,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION
;
let
userId
=
100
;
...
...
@@ -715,7 +736,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -742,6 +764,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
...
...
@@ -754,7 +777,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -795,17 +819,19 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
try
{
bundleManager
.
getAllBundleInfo
(
bundleFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllBundleInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -841,6 +867,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -854,7 +881,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -881,6 +909,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
...
...
@@ -893,7 +922,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -934,17 +964,19 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
appFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
try
{
bundleManager
.
getAllApplicationInfo
(
appFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllApplicationInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -986,6 +1018,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -1003,7 +1036,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1042,6 +1076,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
want
=
{
...
...
@@ -1058,7 +1093,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1104,6 +1140,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -1115,16 +1152,18 @@ let want = {
try
{
bundleManager
.
queryAbilityInfo
(
want
,
abilityFlags
,
userId
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
want
=
{
...
...
@@ -1135,11 +1174,12 @@ let want = {
try
{
bundleManager
.
queryAbilityInfo
(
want
,
abilityFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
})
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1180,6 +1220,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
extensionAbilityType
=
bundleManager
.
ExtensionAbilityType
.
FORM
;
let
extensionFlags
=
bundleManager
.
ExtensionAbilityFlag
.
GET_EXTENSION_ABILITY_INFO_DEFAULT
;
...
...
@@ -1198,7 +1239,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1237,6 +1279,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
extensionAbilityType
=
bundleManager
.
ExtensionAbilityType
.
FORM
;
let
extensionFlags
=
bundleManager
.
ExtensionAbilityFlag
.
GET_EXTENSION_ABILITY_INFO_DEFAULT
;
...
...
@@ -1254,7 +1297,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1300,6 +1344,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
extensionAbilityType
=
bundleManager
.
ExtensionAbilityType
.
FORM
;
...
...
@@ -1317,12 +1362,14 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
extensionAbilityType
=
bundleManager
.
ExtensionAbilityType
.
FORM
;
let
extensionFlags
=
bundleManager
.
ExtensionAbilityFlag
.
GET_EXTENSION_ABILITY_INFO_DEFAULT
;
...
...
@@ -1334,11 +1381,12 @@ let want = {
try
{
bundleManager
.
queryExtensionAbilityInfo
(
want
,
extensionAbilityType
,
extensionFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
})
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryExtensionAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1373,6 +1421,7 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
uid
=
20010005
;
try
{
...
...
@@ -1384,7 +1433,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleNameByUid failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleNameByUid failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1424,6 +1474,7 @@ getBundleNameByUid(uid: number): Promise\<string>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
uid
=
20010005
;
try
{
...
...
@@ -1433,7 +1484,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleNameByUid failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleNameByUid failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleNameByUid failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1469,6 +1521,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
hapFilePath
=
"
/data/xxx/test.hap
"
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
...
...
@@ -1482,7 +1535,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1523,6 +1577,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)):
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
hapFilePath
=
"
/data/xxx/test.hap
"
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_DEFAULT
;
...
...
@@ -1530,11 +1585,12 @@ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try
{
bundleManager
.
getBundleArchiveInfo
(
hapFilePath
,
bundleFlags
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleArchiveInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1570,6 +1626,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
...
...
@@ -1582,7 +1639,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1623,17 +1681,19 @@ cleanBundleCacheFiles(bundleName: string): Promise\<void>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
try
{
bundleManager
.
cleanBundleCacheFiles
(
bundleName
).
then
(()
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles successfully.
'
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles failed: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
cleanBundleCacheFiles failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1669,6 +1729,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
...
...
@@ -1681,7 +1742,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
setApplicationEnabled failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
setApplicationEnabled failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1722,6 +1784,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
...
...
@@ -1732,7 +1795,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
setApplicationEnabled failed: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
setApplicationEnabled failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
setApplicationEnabled failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1769,6 +1833,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -1794,7 +1859,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1836,6 +1902,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -1859,7 +1926,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1892,6 +1960,7 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): voi
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
...
...
@@ -1904,7 +1973,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled failed: %{public}s
'
,
message
);
}
```
...
...
@@ -1942,17 +2012,19 @@ isApplicationEnabled(bundleName: string): Promise\<boolean>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
try
{
bundleManager
.
isApplicationEnabled
(
bundleName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
isApplicationEnabled failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -1986,6 +2058,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -2007,11 +2080,12 @@ try {
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
isAbilityEnabled successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
});
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2050,6 +2124,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
abilityFlags
=
bundleManager
.
AbilityFlag
.
GET_ABILITY_INFO_DEFAULT
;
let
userId
=
100
;
...
...
@@ -2073,7 +2148,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
queryAbilityInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2111,6 +2187,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
userId
=
100
;
...
...
@@ -2124,7 +2201,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2160,6 +2238,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
...
...
@@ -2172,7 +2251,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2215,6 +2295,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
userId
=
100
;
...
...
@@ -2222,11 +2303,12 @@ let userId = 100;
try
{
bundleManager
.
getLaunchWantForBundle
(
bundleName
,
userId
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getLaunchWantForBundle failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2263,6 +2345,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
moduleName
=
'
entry
'
;
let
abilityName
=
'
EntryAbility
'
;
...
...
@@ -2277,7 +2360,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2319,6 +2403,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
moduleName
=
'
entry
'
;
let
abilityName
=
'
EntryAbility
'
;
...
...
@@ -2330,12 +2415,14 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
message
);
}
```
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
moduleName
=
'
entry
'
;
let
abilityName
=
'
EntryAbility
'
;
...
...
@@ -2343,11 +2430,12 @@ let metadataName = 'com.example.myapplication.metadata';
try
{
bundleManager
.
getProfileByAbility
(
moduleName
,
abilityName
,
metadataName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByAbility failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2383,6 +2471,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
moduleName
=
'
entry
'
;
let
extensionAbilityName
=
'
com.example.myapplication.extension
'
;
...
...
@@ -2397,7 +2486,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2438,6 +2528,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
moduleName
=
'
entry
'
;
let
extensionAbilityName
=
'
com.example.myapplication.extension
'
;
...
...
@@ -2446,21 +2537,23 @@ let metadataName = 'com.example.myapplication.metadata';
try
{
bundleManager
.
getProfileByExtensionAbility
(
moduleName
,
extensionAbilityName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
message
);
}
try
{
bundleManager
.
getProfileByExtensionAbility
(
moduleName
,
extensionAbilityName
,
metadataName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getProfileByExtensionAbility failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2495,6 +2588,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
permission
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
try
{
...
...
@@ -2506,7 +2600,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getPermissionDef failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getPermissionDef failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2546,16 +2641,18 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
permissionName
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
try
{
bundleManager
.
getPermissionDef
(
permissionName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getPermissionDef successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getPermissionDef failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getPermissionDef failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getPermissionDef failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2596,6 +2693,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
moduleName
=
'
entry
'
;
...
...
@@ -2610,7 +2708,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2656,6 +2755,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
moduleName
=
'
entry
'
;
...
...
@@ -2664,11 +2764,12 @@ let abilityName = 'EntryAbility';
try
{
bundleManager
.
getAbilityLabel
(
bundleName
,
moduleName
,
abilityName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAbilityLabel failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -2713,6 +2814,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
applicationFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
...
...
@@ -2722,7 +2824,8 @@ try {
let
data
=
bundleManager
.
getApplicationInfoSync
(
bundleName
,
applicationFlags
,
userId
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2764,6 +2867,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
applicationFlags
=
bundleManager
.
ApplicationFlag
.
GET_APPLICATION_INFO_DEFAULT
;
...
...
@@ -2772,7 +2876,8 @@ try {
let
data
=
bundleManager
.
getApplicationInfoSync
(
bundleName
,
applicationFlags
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getApplicationInfoSync failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2816,6 +2921,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION
;
...
...
@@ -2825,7 +2931,8 @@ try {
let
data
=
bundleManager
.
getBundleInfoSync
(
bundleName
,
bundleFlags
,
userId
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2867,6 +2974,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION
;
...
...
@@ -2874,7 +2982,8 @@ try {
let
data
=
bundleManager
.
getBundleInfoSync
(
bundleName
,
bundleFlags
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoSync failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2911,6 +3020,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCall
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
moduleName
=
'
library
'
;
...
...
@@ -2924,7 +3034,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -2966,6 +3077,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<Sha
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
moduleName
=
'
library
'
;
...
...
@@ -2973,11 +3085,12 @@ let moduleName = 'library';
try
{
bundleManager
.
getSharedBundleInfo
(
bundleName
,
moduleName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getSharedBundleInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -3003,6 +3116,7 @@ getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): vo
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
try
{
...
...
@@ -3014,7 +3128,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllSharedBundleInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllSharedBundleInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -3040,6 +3155,7 @@ getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
try
{
...
...
@@ -3049,7 +3165,8 @@ try {
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllSharedBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllSharedBundleInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAllSharedBundleInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -3084,6 +3201,7 @@ getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionIn
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
...
...
@@ -3096,7 +3214,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -3134,6 +3253,7 @@ getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
let
userId
=
100
;
...
...
@@ -3147,7 +3267,8 @@ try {
}
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed: %{public}s
'
,
message
);
}
```
...
...
@@ -3190,6 +3311,7 @@ getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvision
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleName
=
"
com.ohos.myapplication
"
;
let
userId
=
100
;
...
...
@@ -3197,21 +3319,23 @@ let userId = 100;
try
{
bundleManager
.
getAppProvisionInfo
(
bundleName
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
message
);
}
try
{
bundleManager
.
getAppProvisionInfo
(
bundleName
,
userId
).
then
((
data
)
=>
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo successfully. Data: %{public}s
'
,
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
err
.
message
);
});
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getAppProvisionInfo failed. Cause: %{public}s
'
,
message
);
}
```
...
...
@@ -3249,13 +3373,15 @@ getSpecifiedDistributionType(bundleName: string): string;
**示例:**
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication
"
;
try
{
let
type
=
bundleManager
.
getSpecifiedDistributionType
(
bundleName
);
console
.
info
(
'
getSpecifiedDistributionType successfully, type:
'
+
type
);
}
catch
(
error
)
{
console
.
error
(
'
getSpecifiedDistributionType failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getSpecifiedDistributionType failed. Cause:
'
+
message
);
}
```
...
...
@@ -3296,13 +3422,15 @@ getAdditionalInfo(bundleName: string): string;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication
"
;
try
{
let
info
=
bundleManager
.
getAdditionalInfo
(
bundleName
);
console
.
info
(
'
getAdditionalInfo successfully, additionInfo:
'
+
info
);
}
catch
(
error
)
{
console
.
error
(
'
getAdditionalInfo failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getAdditionalInfo failed. Cause:
'
+
message
);
}
```
...
...
@@ -3330,12 +3458,14 @@ getBundleInfoForSelfSync(bundleFlags: number): BundleInfo;
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
hilog
from
'
@ohos.hilog
'
;
let
bundleFlags
=
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION
;
try
{
let
data
=
bundleManager
.
getBundleInfoForSelfSync
(
bundleFlags
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelfSync successfully: %{public}s
'
,
JSON
.
stringify
(
data
));
}
catch
(
err
)
{
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelfSync failed: %{public}s
'
,
err
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
getBundleInfoForSelfSync failed: %{public}s
'
,
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-overlay.md
浏览文件 @
e526edf1
...
...
@@ -45,6 +45,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\<void>;
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
moduleName
=
"
feature
"
;
let
isEnabled
=
false
;
...
...
@@ -52,11 +54,13 @@ try {
overlay
.
setOverlayEnabled
(
moduleName
,
isEnabled
)
.
then
(()
=>
{
console
.
info
(
'
setOverlayEnabled success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
setOverlayEnabled failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
});
}
catch
(
err
)
{
console
.
info
(
'
setOverlayEnabled failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
info
(
'
setOverlayEnabled failed due to err code:
'
+
code
+
'
'
+
'
message:
'
+
message
);
}
```
...
...
@@ -88,6 +92,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
moduleName
=
"
feature
"
;
let
isEnabled
=
false
;
...
...
@@ -100,7 +106,9 @@ try {
console
.
info
(
'
setOverlayEnabled success
'
);
});
}
catch
(
err
)
{
console
.
info
(
'
setOverlayEnabled failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
info
(
'
setOverlayEnabled failed due to err code:
'
+
code
+
'
'
+
'
message:
'
+
message
);
}
```
...
...
@@ -144,6 +152,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
let
isEnabled
=
false
;
...
...
@@ -152,11 +162,13 @@ try {
overlay
.
setOverlayEnabledByBundleName
(
bundleName
,
moduleName
,
isEnabled
)
.
then
((
data
)
=>
{
console
.
info
(
'
setOverlayEnabledByBundleName successfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
setOverlayEnabledByBundleName failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
});
}
catch
(
err
)
{
console
.
info
(
'
setOverlayEnabledByBundleName failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
info
(
'
setOverlayEnabledByBundleName failed due to err code:
'
+
code
+
'
'
+
'
message:
'
+
message
);
}
```
...
...
@@ -195,6 +207,8 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
let
isEnabled
=
false
;
...
...
@@ -208,7 +222,9 @@ try {
console
.
info
(
'
setOverlayEnabledByBundleName successfully
'
);
});
}
catch
(
err
)
{
console
.
info
(
'
setOverlayEnabledByBundleName failed due to err code:
'
+
err
.
code
+
'
'
+
'
message:
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
info
(
'
setOverlayEnabledByBundleName failed due to err code:
'
+
code
+
'
'
+
'
message:
'
+
message
);
}
```
...
...
@@ -245,6 +261,8 @@ getOverlayModuleInfo(moduleName: string): Promise\<OverlayModuleInfo>;
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
moduleName
=
"
feature
"
;
(
async
()
=>
{
...
...
@@ -252,7 +270,9 @@ let moduleName = "feature";
let
overlayModuleInfo
=
await
overlay
.
getOverlayModuleInfo
(
moduleName
);
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
overlayModuleInfo
));
}
catch
(
err
)
{
console
.
log
(
'
getOverlayModuleInfo failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getOverlayModuleInfo failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
})();
```
...
...
@@ -285,6 +305,8 @@ getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\<OverlayModuleI
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
moduleName
=
"
feature
"
;
try
{
overlay
.
getOverlayModuleInfo
(
moduleName
,
(
err
,
data
)
=>
{
...
...
@@ -295,7 +317,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getOverlayModuleInfo failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getOverlayModuleInfo failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
@@ -331,6 +355,8 @@ getTargetOverlayModuleInfos(targetModuleName: string): Promise\<Array\<OverlayMo
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
targetModuleName
=
"
feature
"
;
(
async
()
=>
{
...
...
@@ -338,7 +364,9 @@ let targetModuleName = "feature";
let
overlayModuleInfos
=
await
overlay
.
getTargetOverlayModuleInfos
(
targetModuleName
);
console
.
log
(
'
overlayModuleInfos are
'
+
JSON
.
stringify
(
overlayModuleInfos
));
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
})();
```
...
...
@@ -370,6 +398,8 @@ getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\<A
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
targetModuleName
=
"
feature
"
;
try
{
overlay
.
getTargetOverlayModuleInfos
(
targetModuleName
,
(
err
,
data
)
=>
{
...
...
@@ -380,7 +410,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
@@ -423,6 +455,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
...
...
@@ -431,7 +465,9 @@ let moduleName = "feature";
let
overlayModuleInfos
=
await
overlay
.
getOverlayModuleInfoByBundleName
(
bundleName
,
moduleName
);
console
.
log
(
'
overlayModuleInfos are
'
+
JSON
.
stringify
(
overlayModuleInfos
));
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfos failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
})();
```
...
...
@@ -470,6 +506,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
...
...
@@ -482,7 +520,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getOverlayModuleInfoByBundleName failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getOverlayModuleInfoByBundleName failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
@@ -517,6 +557,8 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Ar
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
"
com.example.myapplication_xxxxx
"
;
try
{
...
...
@@ -528,7 +570,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getOverlayModuleInfoByBundleName failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getOverlayModuleInfoByBundleName failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
@@ -571,6 +615,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
targetBundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
...
...
@@ -579,7 +625,9 @@ let moduleName = "feature";
let
overlayModuleInfos
=
await
overlay
.
getTargetOverlayModuleInfosByBundleName
(
targetBundleName
,
moduleName
);
console
.
log
(
'
overlayModuleInfos are
'
+
JSON
.
stringify
(
overlayModuleInfos
));
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
})();
```
...
...
@@ -618,6 +666,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
targetBundleName
=
"
com.example.myapplication_xxxxx
"
;
let
moduleName
=
"
feature
"
;
...
...
@@ -630,7 +680,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
@@ -665,6 +717,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn
**示例:**
```
ts
import
overlay
from
'
@ohos.bundle.overlay
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
targetBundleName
=
"
com.example.myapplication_xxxxx
"
;
try
{
...
...
@@ -676,7 +730,9 @@ try {
console
.
log
(
'
overlayModuleInfo is
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
err
.
code
+
'
'
+
'
message :
'
+
err
.
message
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
'
getTargetOverlayModuleInfosByBundleName failed due to err code :
'
+
code
+
'
'
+
'
message :
'
+
message
);
}
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录