Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8fd604b4
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
未验证
提交
8fd604b4
编写于
8月 30, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23403 Rectify the arkts syntax on monthly
Merge pull request !23403 from 189******51/monthly_20230815
上级
2413aec9
016b265f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
223 addition
and
113 deletion
+223
-113
zh-cn/application-dev/reference/apis/js-apis-distributedBundleManager.md
...on-dev/reference/apis/js-apis-distributedBundleManager.md
+60
-20
zh-cn/application-dev/reference/apis/js-apis-installer.md
zh-cn/application-dev/reference/apis/js-apis-installer.md
+123
-77
zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md
...ation-dev/reference/apis/js-apis-launcherBundleManager.md
+40
-16
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-distributedBundleManager.md
浏览文件 @
8fd604b4
...
...
@@ -59,13 +59,16 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
{
deviceId
:
'
1
'
,
bundleName
:
'
com.example.application
'
,
abilityName
:
'
EntryAbility
'
},
(
err
,
data
)
=>
{
},
(
err
:
BusinessError
,
data
:
distributedBundle
.
RemoteAbilityInfo
)
=>
{
if
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -73,7 +76,9 @@ try {
}
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -115,19 +120,24 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>;
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
{
deviceId
:
'
1
'
,
bundleName
:
'
com.example.application
'
,
abilityName
:
'
EntryAbility
'
}).
then
(
data
=>
{
}).
then
(
(
data
:
distributedBundle
.
RemoteAbilityInfo
)
=>
{
console
.
info
(
'
Operation succeed:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -164,6 +174,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
[
...
...
@@ -177,7 +190,7 @@ try {
bundleName
:
'
com.example.application2
'
,
abilityName
:
'
EntryAbility
'
}
],
(
err
,
data
)
=>
{
],
(
err
:
BusinessError
,
data
:
distributedBundle
.
RemoteAbilityInfo
[]
)
=>
{
if
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -185,7 +198,9 @@ try {
}
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -227,6 +242,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
[
...
...
@@ -240,13 +258,15 @@ try {
bundleName
:
'
com.example.application2
'
,
abilityName
:
'
EntryAbility
'
}
]).
then
(
data
=>
{
]).
then
(
(
data
:
distributedBundle
.
RemoteAbilityInfo
[])
=>
{
console
.
info
(
'
Operation succeed:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -284,13 +304,16 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
{
deviceId
:
'
1
'
,
bundleName
:
'
com.example.application
'
,
abilityName
:
'
EntryAbility
'
},
'
zh-Hans-CN
'
,
(
err
,
data
)
=>
{
},
'
zh-Hans-CN
'
,
(
err
:
BusinessError
,
data
:
distributedBundle
.
RemoteAbilityInfo
)
=>
{
if
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -298,7 +321,9 @@ try {
}
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -341,19 +366,24 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
{
deviceId
:
'
1
'
,
bundleName
:
'
com.example.application
'
,
abilityName
:
'
EntryAbility
'
},
'
zh-Hans-CN
'
).
then
(
data
=>
{
},
'
zh-Hans-CN
'
).
then
(
(
data
:
distributedBundle
.
RemoteAbilityInfo
)
=>
{
console
.
info
(
'
Operation succeed:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -391,6 +421,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
[
...
...
@@ -404,7 +437,7 @@ try {
bundleName
:
'
com.example.application2
'
,
abilityName
:
'
EntryAbility
'
}
],
'
zh-Hans-CN
'
,
(
err
,
data
)
=>
{
],
'
zh-Hans-CN
'
,
(
err
:
BusinessError
,
data
:
distributedBundle
.
RemoteAbilityInfo
[]
)
=>
{
if
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -412,7 +445,9 @@ try {
}
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
...
...
@@ -455,6 +490,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise
**示例:**
```
ts
import
distributedBundle
from
'
@ohos.bundle.distributedBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
distributedBundle
.
getRemoteAbilityInfo
(
[
...
...
@@ -468,12 +506,14 @@ try {
bundleName
:
'
com.example.application2
'
,
abilityName
:
'
EntryAbility
'
}
],
'
zh-Hans-CN
'
).
then
(
data
=>
{
],
'
zh-Hans-CN
'
).
then
(
(
data
:
distributedBundle
.
RemoteAbilityInfo
[])
=>
{
console
.
info
(
'
Operation succeed:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Operation failed: error code is
${
err
.
code
}
and error message is
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
;
console
.
log
(
`Operation failed: error code is
${
code
}
and error message is
${
message
}
`
);
}
```
zh-cn/application-dev/reference/apis/js-apis-installer.md
浏览文件 @
8fd604b4
...
...
@@ -46,9 +46,10 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
installer
.
getBundleInstaller
((
err
,
data
)
=>
{
installer
.
getBundleInstaller
((
err
:
BusinessError
,
data
:
installer
.
BundleInstaller
)
=>
{
if
(
err
)
{
console
.
error
(
'
getBundleInstaller failed:
'
+
err
.
message
);
}
else
{
...
...
@@ -56,7 +57,8 @@ try {
}
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed:
'
+
message
);
}
```
...
...
@@ -79,15 +81,17 @@ getBundleInstaller(): Promise\<BundleInstaller>;
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
installer
.
getBundleInstaller
().
then
((
data
)
=>
{
installer
.
getBundleInstaller
().
then
((
data
:
installer
.
BundleInstaller
)
=>
{
console
.
info
(
'
getBundleInstaller successfully.
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -148,27 +152,30 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback:
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
install
(
hapFilePaths
,
installParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
install
(
hapFilePaths
,
installParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
install successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
## BundleInstaller.install
...
...
@@ -226,22 +233,25 @@ install(hapFilePaths: Array<string>, callback: AsyncCallback<void>):
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
install
(
hapFilePaths
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
install
(
hapFilePaths
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
install successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -308,26 +318,29 @@ install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<v
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
install
(
hapFilePaths
,
installParam
)
.
then
((
data
)
=>
{
.
then
((
data
:
void
)
=>
{
console
.
info
(
'
install successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
e
rror
)
=>
{
}).
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
install failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -367,27 +380,30 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
bundleName
,
installParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
uninstall
(
bundleName
,
installParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -425,22 +441,25 @@ uninstall(bundleName: string, callback: AsyncCallback<void>): void;
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
bundleName
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
uninstall
(
bundleName
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
## BundleInstaller.uninstall
...
...
@@ -483,26 +502,29 @@ uninstall(bundleName: string, installParam?: InstallParam) : Promise\<void\>;
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
uninstall
(
bundleName
,
installParam
)
.
then
((
data
)
=>
{
.
then
((
data
:
void
)
=>
{
console
.
info
(
'
uninstall successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
e
rror
)
=>
{
}).
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
uninstall failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -539,27 +561,30 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
recover
(
bundleName
,
installParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
recover
(
bundleName
,
installParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
recover failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
recover successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -595,22 +620,25 @@ recover(bundleName: string, callback: AsyncCallback<void>): void;
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
recover
(
bundleName
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
recover
(
bundleName
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
recover failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
recover successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -651,26 +679,29 @@ recover(bundleName: string, installParam?: InstallParam) : Promise\<void\>;
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.ohos.demo
'
;
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
recover
(
bundleName
,
installParam
)
.
then
((
data
)
=>
{
.
then
((
data
:
void
)
=>
{
console
.
info
(
'
recover successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
e
rror
)
=>
{
}).
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
recover failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -707,24 +738,27 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
uninstallParam
:
installer
.
UninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
uninstall
(
uninstallParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -766,24 +800,27 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
uninstallParam
:
installer
.
UninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
uninstall
(
uninstallParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -836,27 +873,30 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam: InstallParam, c
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
installParam
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
installParam
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
updateBundleForSelf successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -907,22 +947,25 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, callback: AsyncCallback\<void
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
err
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
updateBundleForSelf successfully.
'
);
}
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
@@ -974,26 +1017,29 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam?: InstallParam):
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
let
installParam
:
installer
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
(
data
:
installer
.
BundleInstaller
)
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
installParam
)
.
then
((
data
)
=>
{
.
then
((
data
:
void
)
=>
{
console
.
info
(
'
updateBundleForSelf successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
e
rror
)
=>
{
}).
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md
浏览文件 @
8fd604b4
...
...
@@ -51,9 +51,11 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba
```
ts
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getLauncherAbilityInfo
(
'
com.example.demo
'
,
100
,
(
errData
,
data
)
=>
{
launcherBundleManager
.
getLauncherAbilityInfo
(
'
com.example.demo
'
,
100
,
(
errData
:
BusinessError
,
data
:
launcherBundleManager
.
LauncherAbilityInfo
[])
=>
{
if
(
errData
!==
null
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
...
...
@@ -61,7 +63,9 @@ try {
}
})
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
...
...
@@ -101,17 +105,21 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau
**示例:**
```
t
ypescript
```
t
s
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getLauncherAbilityInfo
(
"
com.example.demo
"
,
100
).
then
(
data
=>
{
launcherBundleManager
.
getLauncherAbilityInfo
(
"
com.example.demo
"
,
100
)
.
then
((
data
:
launcherBundleManager
.
LauncherAbilityInfo
[])
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
}).
catch
(
(
errData
:
BusinessError
)
=>
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
})
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
...
...
@@ -151,9 +159,11 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch
```
ts
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
,
(
errData
,
data
)
=>
{
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
,
(
errData
:
BusinessError
,
data
:
launcherBundleManager
.
LauncherAbilityInfo
[])
=>
{
if
(
errData
!==
null
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
...
...
@@ -161,7 +171,9 @@ try {
}
});
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
## launcherBundlemanager.getAllLauncherAbilityInfo<sup>9+</sup>
...
...
@@ -200,15 +212,19 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo]
```
ts
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
).
then
(
data
=>
{
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
)
.
then
((
data
:
launcherBundleManager
.
LauncherAbilityInfo
[])
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
}).
catch
(
(
errData
:
BusinessError
)
=>
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
});
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
...
...
@@ -246,9 +262,11 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo
```
ts
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
,
(
errData
,
data
)
=>
{
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
,
(
errData
:
BusinessError
,
data
:
launcherBundleManager
.
ShortcutInfo
[])
=>
{
if
(
errData
!==
null
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
...
...
@@ -256,7 +274,9 @@ try {
}
});
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
...
...
@@ -294,14 +314,18 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun
```
ts
import
launcherBundleManager
from
'
@ohos.bundle.launcherBundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
).
then
(
data
=>
{
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
)
.
then
((
data
:
launcherBundleManager
.
ShortcutInfo
[])
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
}).
catch
(
(
errData
:
BusinessError
)
=>
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
});
}
catch
(
errData
)
{
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
let
code
=
(
errData
as
BusinessError
).
code
;
let
message
=
(
errData
as
BusinessError
).
message
;
console
.
error
(
`errData is errCode:
${
code
}
message:
${
message
}
`
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录