Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
da32ec77
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看板
未验证
提交
da32ec77
编写于
4月 24, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
!17330 修改安装和卸载错误码资料
Merge pull request !17330 from shilei91/master
上级
e01b7a2f
f9312577
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
320 addition
and
37 deletion
+320
-37
zh-cn/application-dev/reference/apis/js-apis-installer.md
zh-cn/application-dev/reference/apis/js-apis-installer.md
+320
-37
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-installer.md
浏览文件 @
da32ec77
...
@@ -149,6 +149,64 @@ try {
...
@@ -149,6 +149,64 @@ try {
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
}
```
```
## BundleInstaller.install
install(hapFilePaths: Array
<
string
>
, callback: AsyncCallback
<
void
>
): void;
以异步方法安装应用,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array
<
string
>
| 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
install
(
hapFilePaths
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
install successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.install
## BundleInstaller.install
...
@@ -209,9 +267,9 @@ try {
...
@@ -209,9 +267,9 @@ try {
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
install
(
hapFilePaths
,
installParam
)
data
.
install
(
hapFilePaths
,
installParam
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
install success:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
install success
fully
:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
'
install failed:
'
+
err
.
message
);
console
.
error
(
'
install failed:
'
+
err
or
.
message
);
});
});
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
...
@@ -247,6 +305,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
...
@@ -247,6 +305,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified user ID is not found. |
| 17700004 | The specified user ID is not found. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. |
| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. |
...
@@ -279,11 +338,11 @@ try {
...
@@ -279,11 +338,11 @@ try {
}
}
```
```
## BundleInstaller.uninstall
<sup>10+</sup>
## BundleInstaller.uninstall
uninstall(
uninstallParam: UninstallParam, callback : AsyncCallback
\<
void>) : void
;
uninstall(
bundleName: string, callback: AsyncCallback
<
void
>
): void
;
以异步方法卸载
一个共享包
,使用callback形式返回结果。
以异步方法卸载
应用
,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
...
@@ -294,8 +353,8 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
...
@@ -294,8 +353,8 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ----------
---- | ----------------------------------- | ---- | ----------
---------------------------------------------- |
| ----------
| ---------------------------------------------------- | ---- |
---------------------------------------------- |
|
uninstallParam |
[
UninstallParam
](
#uninstallparam10
)
| 是 | 共享包卸载需指定的参数信息。
|
|
bundleName | string | 是 | 待卸载应用的包名。
|
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象。 |
**错误码:**
**错误码:**
...
@@ -304,21 +363,19 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
...
@@ -304,21 +363,19 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundle name is not found. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700037 | The version of shared bundle is dependent on other applications. |
| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. |
| 17700038 | The specified shared bundle does not exist. |
**示例:**
**示例:**
```
ts
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
let
bundleName
=
'
com.ohos.demo
'
;
bundleName
:
"
com.ohos.demo
"
,
};
try
{
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
data
.
uninstall
(
bundleName
,
err
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
}
else
{
...
@@ -332,12 +389,11 @@ try {
...
@@ -332,12 +389,11 @@ try {
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
}
```
```
## BundleInstaller.uninstall
## BundleInstaller.uninstall<sup>10+</sup>
uninstall(bundleName: string, installParam?: InstallParam) : Promise
\<
void
\>
;
uninstall(uninstallParam: UninstallParam) : Promise
\<
void>;
以异步方法卸载
一个共享包
,使用Promise形式返回结果。
以异步方法卸载
应用
,使用Promise形式返回结果。
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
...
@@ -348,13 +404,14 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
...
@@ -348,13 +404,14 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
| uninstallParam |
[
UninstallParam
](
#uninstallparam10
)
| 是 | 共享包卸载需指定的参数信息。 |
| bundleName | string | 是 | 待卸载应用的包名。 |
| installParam |
[
InstallParam
](
#installparam
)
| 否 | 指定安装所需的其他参数。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| -------------
--
| -------------------------------------- |
| Promise
\<
void
\>
| Promise对象。无返回结果的Promise对象。 |
| Promise
\<
void
\>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
**错误码:**
...
@@ -363,26 +420,28 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
...
@@ -363,26 +420,28 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified userId is not existed. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700037 | The version of shared bundle is dependent on other applications. |
| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. |
| 17700038 | The specified shared bundle does not exist. |
**示例:**
**示例:**
```
ts
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
let
bundleName
=
'
com.ohos.demo
'
;
bundleName
:
"
com.ohos.demo
"
,
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
};
try
{
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
data
.
uninstall
(
bundleName
,
installParam
)
if
(
err
)
{
.
then
((
data
)
=>
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
console
.
info
(
'
uninstall successfully:
'
+
JSON
.
stringify
(
data
));
}
else
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
uninstall successfully.
'
);
console
.
error
(
'
uninstall failed:
'
+
error
.
message
);
}
});
});
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
...
@@ -396,7 +455,7 @@ try {
...
@@ -396,7 +455,7 @@ try {
recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback
<
void
>
): void;
recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback
<
void
>
): void;
以异步方法回滚应用,使用callback形式返回结果。
以异步方法回滚应用
到初次安装时的状态
,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
...
@@ -418,6 +477,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
...
@@ -418,6 +477,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| -------- | ----------------------------------- |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified user ID is not found. |
| 17700004 | The specified user ID is not found. |
**示例:**
**示例:**
...
@@ -448,6 +508,229 @@ try {
...
@@ -448,6 +508,229 @@ try {
}
}
```
```
## BundleInstaller.recover
recover(bundleName: string, callback: AsyncCallback
<
void
>
): void;
以异步方法回滚应用到初次安装时的状态,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 待恢复应用的包名。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,回滚应用成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700001 | The specified bundle name is not found. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
bundleName
=
'
com.ohos.demo
'
;
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
recover
(
bundleName
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
recover failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
recover successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.recover
recover(bundleName: string, installParam?: InstallParam) : Promise
\<
void
\>
;
以异步方法回滚应用到初次安装时的状态,使用Promise形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 待卸载应用的包名。 |
| installParam |
[
InstallParam
](
#installparam
)
| 否 | 指定安装所需的其他参数。 |
**返回值:**
| 类型 | 说明 |
| --------------- | -------------------------------------- |
| Promise
\<
void
\>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified user ID is not found. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
bundleName
=
'
com.ohos.demo
'
;
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
recover
(
bundleName
,
installParam
)
.
then
((
data
)
=>
{
console
.
info
(
'
recover successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
recover failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.uninstall<sup>10+</sup>
uninstall(uninstallParam: UninstallParam, callback : AsyncCallback
\<
void>) : void ;
以异步方法卸载一个共享包,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- |
| uninstallParam |
[
UninstallParam
](
#uninstallparam10
)
| 是 | 共享包卸载需指定的参数信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700037 | The version of shared bundle is dependent on other applications. |
| 17700038 | The specified shared bundle does not exist. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.uninstall<sup>10+</sup>
uninstall(uninstallParam: UninstallParam) : Promise
\<
void>;
以异步方法卸载一个共享包,使用Promise形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| uninstallParam |
[
UninstallParam
](
#uninstallparam10
)
| 是 | 共享包卸载需指定的参数信息。 |
**返回值:**
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| Promise
\<
void
\>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700037 | The version of shared bundle is dependent on other applications. |
| 17700038 | The specified shared bundle does not exist. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
uninstallParam
=
{
bundleName
:
"
com.ohos.demo
"
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
uninstall
(
uninstallParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## HashParam
## HashParam
应用程序安装卸载哈希参数信息。
应用程序安装卸载哈希参数信息。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录