Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
cc2a888f
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看板
未验证
提交
cc2a888f
编写于
8月 25, 2023
作者:
N
ningning
提交者:
Gitee
8月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update模块arkts语法整改
Signed-off-by:
N
ningning
<
wangningning14@huawei.com
>
上级
bb4f9eb7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
110 addition
and
108 deletion
+110
-108
zh-cn/application-dev/reference/apis/js-apis-update.md
zh-cn/application-dev/reference/apis/js-apis-update.md
+110
-108
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-update.md
浏览文件 @
cc2a888f
...
...
@@ -52,17 +52,17 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
```
ts
try
{
const
upgradeInfo
=
{
upgradeApp
:
"
com.ohos.ota.updateclient
"
,
businessType
:
{
vendor
:
update
.
BusinessVendor
.
PUBLIC
,
subType
:
update
.
BusinessSubType
.
FIRMWARE
const
upgradeInfo
:
update
.
UpgradeInfo
=
{
upgradeApp
:
"
com.ohos.ota.updateclient
"
,
businessType
:
{
vendor
:
update
.
BusinessVendor
.
PUBLIC
,
subType
:
update
.
BusinessSubType
.
FIRMWARE
}
};
let
updater
=
update
.
getOnlineUpdater
(
upgradeInfo
);
}
catch
(
error
)
{
console
.
error
(
`Fail to get updater error:
${
error
}
`
);
}
};
let
updater
=
update
.
getOnlineUpdater
(
upgradeInfo
);
}
catch
(
error
)
{
console
.
error
(
`Fail to get updater error:
${
error
}
`
);
}
```
## update.getRestorer
...
...
@@ -159,9 +159,9 @@ checkNewVersion(callback: AsyncCallback\<CheckResult>): void
**示例:**
```
ts
updater
.
checkNewVersion
((
err
,
r
esult
)
=>
{
console
.
log
(
`checkNewVersion isExistNewVersion
${
result
?.
isExistNewVersion
}
`
);
});
updater
.
checkNewVersion
((
err
:
BusinessError
,
result
:
update
.
CheckR
esult
)
=>
{
console
.
log
(
`checkNewVersion isExistNewVersion
${
result
?.
isExistNewVersion
}
`
);
});
```
### checkNewVersion
...
...
@@ -191,13 +191,15 @@ checkNewVersion(): Promise\<CheckResult>
**示例:**
```
ts
updater
.
checkNewVersion
().
then
(
result
=>
{
console
.
log
(
`checkNewVersion isExistNewVersion:
${
result
.
isExistNewVersion
}
`
);
// 版本摘要信息
console
.
log
(
`checkNewVersion versionDigestInfo:
${
result
.
newVersionInfo
.
versionDigestInfo
.
versionDigest
}
`
);
}).
catch
(
err
=>
{
console
.
log
(
`checkNewVersion promise error
${
JSON
.
stringify
(
err
)}
`
);
});
updater
.
checkNewVersion
()
.
then
((
result
:
update
.
CheckResult
)
=>
{
console
.
log
(
`checkNewVersion isExistNewVersion:
${
result
.
isExistNewVersion
}
`
);
// 版本摘要信息
console
.
log
(
`checkNewVersion versionDigestInfo:
${
result
.
newVersionInfo
.
versionDigestInfo
.
versionDigest
}
`
);
})
.
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
`checkNewVersion promise error
${
JSON
.
stringify
(
err
)}
`
);
})
```
### getNewVersionInfo
...
...
@@ -227,9 +229,9 @@ getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
**示例:**
```
ts
updater
.
getNewVersionInfo
((
err
,
i
nfo
)
=>
{
console
.
log
(
`info displayVersion =
${
info
?.
versionComponents
[
0
].
displayVersion
}
`
);
console
.
log
(
`info innerVersion =
${
info
?.
versionComponents
[
0
].
innerVersion
}
`
);
updater
.
getNewVersionInfo
((
err
:
BusinessError
,
info
:
update
.
NewVersionI
nfo
)
=>
{
console
.
log
(
`info displayVersion =
${
info
?.
versionComponents
[
0
].
displayVersion
}
`
);
console
.
log
(
`info innerVersion =
${
info
?.
versionComponents
[
0
].
innerVersion
}
`
);
});
```
...
...
@@ -260,11 +262,11 @@ getNewVersionInfo(): Promise\<NewVersionInfo>
**示例:**
```
ts
updater
.
getNewVersionInfo
().
then
(
info
=>
{
console
.
log
(
`info displayVersion =
${
info
.
versionComponents
[
0
].
displayVersion
}
`
);
console
.
log
(
`info innerVersion =
${
info
.
versionComponents
[
0
].
innerVersion
}
`
);
}).
catch
(
err
=>
{
console
.
log
(
`getNewVersionInfo promise error
${
JSON
.
stringify
(
err
)}
`
);
updater
.
getNewVersionInfo
().
then
(
(
info
:
update
.
NewVersionInfo
)
=>
{
console
.
log
(
`info displayVersion =
${
info
.
versionComponents
[
0
].
displayVersion
}
`
);
console
.
log
(
`info innerVersion =
${
info
.
versionComponents
[
0
].
innerVersion
}
`
);
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getNewVersionInfo promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -298,19 +300,20 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 描述文件选项
const
descriptionOptions
=
{
const
descriptionOptions
:
update
.
DescriptionOptions
=
{
format
:
update
.
DescriptionFormat
.
STANDARD
,
// 标准格式
language
:
"
zh-cn
"
// 中文
};
updater
.
getNewVersionDescription
(
versionDigestInfo
,
descriptionOptions
,
(
err
,
info
)
=>
{
console
.
log
(
`getNewVersionDescription info
${
JSON
.
stringify
(
info
)}
`
);
console
.
log
(
`getNewVersionDescription err
${
JSON
.
stringify
(
err
)}
`
);
updater
.
getNewVersionDescription
(
versionDigestInfo
,
descriptionOptions
).
then
((
info
:
Array
<
update
.
ComponentDescription
>
)
=>
{
console
.
log
(
`getNewVersionDescription promise info
${
JSON
.
stringify
(
info
)}
`
);
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
`getNewVersionDescription promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -349,19 +352,19 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 描述文件选项
const
descriptionOptions
=
{
const
descriptionOptions
:
update
.
DescriptionOptions
=
{
format
:
update
.
DescriptionFormat
.
STANDARD
,
// 标准格式
language
:
"
zh-cn
"
// 中文
};
updater
.
getNewVersionDescription
(
versionDigestInfo
,
descriptionOptions
).
then
(
info
=>
{
updater
.
getNewVersionDescription
(
versionDigestInfo
,
descriptionOptions
).
then
(
(
info
:
Array
<
update
.
ComponentDescription
>
)
=>
{
console
.
log
(
`getNewVersionDescription promise info
${
JSON
.
stringify
(
info
)}
`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getNewVersionDescription promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -393,7 +396,7 @@ getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void
**示例:**
```
ts
updater
.
getCurrentVersionInfo
((
err
,
i
nfo
)
=>
{
updater
.
getCurrentVersionInfo
((
err
:
BusinessError
,
info
:
update
.
CurrentVersionI
nfo
)
=>
{
console
.
log
(
`info osVersion =
${
info
?.
osVersion
}
`
);
console
.
log
(
`info deviceName =
${
info
?.
deviceName
}
`
);
console
.
log
(
`info displayVersion =
${
info
?.
versionComponents
[
0
].
displayVersion
}
`
);
...
...
@@ -427,11 +430,11 @@ getCurrentVersionInfo(): Promise\<CurrentVersionInfo>
**示例:**
```
ts
updater
.
getCurrentVersionInfo
().
then
(
info
=>
{
updater
.
getCurrentVersionInfo
().
then
(
(
info
:
update
.
CurrentVersionInfo
)
=>
{
console
.
log
(
`info osVersion =
${
info
.
osVersion
}
`
);
console
.
log
(
`info deviceName =
${
info
.
deviceName
}
`
);
console
.
log
(
`info displayVersion =
${
info
.
versionComponents
[
0
].
displayVersion
}
`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getCurrentVersionInfo promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -465,7 +468,7 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: A
```
ts
// 描述文件选项
const
descriptionOptions
=
{
const
descriptionOptions
:
update
.
DescriptionOptions
=
{
format
:
update
.
DescriptionFormat
.
STANDARD
,
// 标准格式
language
:
"
zh-cn
"
// 中文
};
...
...
@@ -510,14 +513,13 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<A
```
ts
// 描述文件选项
const
descriptionOptions
=
{
const
descriptionOptions
:
update
.
DescriptionOptions
=
{
format
:
update
.
DescriptionFormat
.
STANDARD
,
// 标准格式
language
:
"
zh-cn
"
// 中文
};
updater
.
getCurrentVersionDescription
(
descriptionOptions
).
then
(
info
=>
{
updater
.
getCurrentVersionDescription
(
descriptionOptions
).
then
((
info
:
Array
<
update
.
ComponentDescription
>
)
=>
{
console
.
log
(
`getCurrentVersionDescription promise info
${
JSON
.
stringify
(
info
)}
`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getCurrentVersionDescription promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -549,7 +551,7 @@ getTaskInfo(callback: AsyncCallback\<TaskInfo>): void
**示例:**
```
ts
updater
.
getTaskInfo
((
err
,
i
nfo
)
=>
{
updater
.
getTaskInfo
((
err
:
BusinessError
,
info
:
update
.
TaskI
nfo
)
=>
{
console
.
log
(
`getTaskInfo isexistTask=
${
info
?.
existTask
}
`
);
});
```
...
...
@@ -581,9 +583,9 @@ getTaskInfo(): Promise\<TaskInfo>
**示例:**
```
ts
updater
.
getTaskInfo
().
then
(
info
=>
{
updater
.
getTaskInfo
().
then
(
(
info
:
update
.
TaskInfo
)
=>
{
console
.
log
(
`getTaskInfo isexistTask=
${
info
.
existTask
}
`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getTaskInfo promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -618,16 +620,16 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions,
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 下载选项
const
downloadOptions
=
{
const
downloadOptions
:
update
.
DownloadOptions
=
{
allowNetwork
:
update
.
NetType
.
CELLULAR
,
// 允许数据网络下载
order
:
update
.
Order
.
DOWNLOAD
// 下载
};
updater
.
download
(
versionDigestInfo
,
downloadOptions
,
(
err
)
=>
{
updater
.
download
(
versionDigestInfo
,
downloadOptions
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`download error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -667,18 +669,18 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions)
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 下载选项
const
downloadOptions
=
{
const
downloadOptions
:
update
.
DownloadOptions
=
{
allowNetwork
:
update
.
NetType
.
CELLULAR
,
// 允许数据网络下载
order
:
update
.
Order
.
DOWNLOAD
// 下载
order
:
update
.
Order
.
DOWNLOAD
// 下载
};
updater
.
download
(
versionDigestInfo
,
downloadOptions
).
then
(()
=>
{
console
.
log
(
`download start`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`download error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -713,15 +715,15 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 恢复下载选项
const
resumeDownloadOptions
=
{
const
resumeDownloadOptions
:
update
.
ResumeDownloadOptions
=
{
allowNetwork
:
update
.
NetType
.
CELLULAR
,
// 允许数据网络下载
};
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
,
(
err
)
=>
{
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`resumeDownload error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -761,17 +763,17 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 恢复下载选项
const
resumeDownloadOptions
=
{
const
resumeDownloadOptions
:
update
.
ResumeDownloadOptions
=
{
allowNetwork
:
update
.
NetType
.
CELLULAR
,
// 允许数据网络下载
};
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
).
then
(
value
=>
{
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
).
then
(
()
=>
{
console
.
log
(
`resumeDownload start`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`resumeDownload error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -806,15 +808,15 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 暂停下载选项
const
pauseDownloadOptions
=
{
const
pauseDownloadOptions
:
update
.
PauseDownloadOptions
=
{
isAllowAutoResume
:
true
// 允许自动恢复下载
};
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
,
(
err
)
=>
{
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`pauseDownload error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -854,17 +856,17 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 暂停下载选项
const
pauseDownloadOptions
=
{
const
pauseDownloadOptions
:
update
.
PauseDownloadOptions
=
{
isAllowAutoResume
:
true
// 允许自动恢复下载
};
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
).
then
(
value
=>
{
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
).
then
(
()
=>
{
console
.
log
(
`pauseDownload`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`pauseDownload error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -899,15 +901,15 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, ca
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 安装选项
const
upgradeOptions
=
{
const
upgradeOptions
:
update
.
UpgradeOptions
=
{
order
:
update
.
Order
.
INSTALL
// 安装指令
};
updater
.
upgrade
(
versionDigestInfo
,
upgradeOptions
,
(
err
)
=>
{
updater
.
upgrade
(
versionDigestInfo
,
upgradeOptions
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`upgrade error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -947,17 +949,17 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): P
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 安装选项
const
upgradeOptions
=
{
const
upgradeOptions
:
update
.
UpgradeOptions
=
{
order
:
update
.
Order
.
INSTALL
// 安装指令
};
updater
.
upgrade
(
versionDigestInfo
,
upgradeOptions
).
then
(()
=>
{
console
.
log
(
`upgrade start`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`upgrade error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -992,15 +994,15 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, cal
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 清除选项
const
clearOptions
=
{
const
clearOptions
:
update
.
ClearOptions
=
{
status
:
update
.
UpgradeStatus
.
UPGRADE_FAIL
,
};
updater
.
clearError
(
versionDigestInfo
,
clearOptions
,
(
err
)
=>
{
updater
.
clearError
(
versionDigestInfo
,
clearOptions
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`clearError error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1040,17 +1042,17 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Pr
```
ts
// 版本摘要信息
const
versionDigestInfo
=
{
const
versionDigestInfo
:
update
.
VersionDigestInfo
=
{
versionDigest
:
"
versionDigest
"
// 检测结果中的版本摘要信息
};
// 清除选项
const
clearOptions
=
{
const
clearOptions
:
update
.
ClearOptions
=
{
status
:
update
.
UpgradeStatus
.
UPGRADE_FAIL
,
};
updater
.
clearError
(
versionDigestInfo
,
clearOptions
).
then
(()
=>
{
console
.
log
(
`clearError success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`clearError error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1082,7 +1084,7 @@ getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void
**示例:**
```
ts
updater
.
getUpgradePolicy
(
(
err
,
p
olicy
)
=>
{
updater
.
getUpgradePolicy
(
err
:
BusinessError
,
policy
:
update
.
UpgradeP
olicy
)
=>
{
console
.
log
(
`policy downloadStrategy =
${
policy
?.
downloadStrategy
}
`
);
console
.
log
(
`policy autoUpgradeStrategy =
${
policy
?.
autoUpgradeStrategy
}
`
);
});
...
...
@@ -1115,10 +1117,10 @@ getUpgradePolicy(): Promise\<UpgradePolicy>
**示例:**
```
ts
updater
.
getUpgradePolicy
().
then
(
policy
=>
{
updater
.
getUpgradePolicy
().
then
(
(
policy
:
update
.
UpgradePolicy
)
=>
{
console
.
log
(
`policy downloadStrategy =
${
policy
.
downloadStrategy
}
`
);
console
.
log
(
`policy autoUpgradeStrategy =
${
policy
.
autoUpgradeStrategy
}
`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`getUpgradePolicy promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1151,12 +1153,12 @@ setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void
**示例:**
```
ts
const
policy
=
{
const
policy
:
update
.
UpgradePolicy
=
{
downloadStrategy
:
false
,
autoUpgradeStrategy
:
false
,
autoUpgradePeriods
:
[
{
start
:
120
,
end
:
240
}
]
// 自动升级时间段,用分钟表示
autoUpgradePeriods
:
[
{
start
:
120
,
end
:
240
}
]
// 自动升级时间段,用分钟表示
};
updater
.
setUpgradePolicy
(
policy
,
(
err
)
=>
{
updater
.
setUpgradePolicy
(
policy
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
`setUpgradePolicy result:
${
err
}
`
);
});
```
...
...
@@ -1194,14 +1196,14 @@ setUpgradePolicy(policy: UpgradePolicy): Promise\<void>
**示例:**
```
ts
const
policy
=
{
const
policy
:
update
.
UpgradePolicy
=
{
downloadStrategy
:
false
,
autoUpgradeStrategy
:
false
,
autoUpgradePeriods
:
[
{
start
:
120
,
end
:
240
}
]
// 自动升级时间段,用分钟表示
};
updater
.
setUpgradePolicy
(
policy
).
then
(()
=>
{
console
.
log
(
`setUpgradePolicy success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`setUpgradePolicy promise error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1233,7 +1235,7 @@ terminateUpgrade(callback: AsyncCallback\<void>): void
**示例:**
```
ts
updater
.
terminateUpgrade
((
err
)
=>
{
updater
.
terminateUpgrade
((
err
:
BusinessError
)
=>
{
console
.
log
(
`terminateUpgrade error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1267,7 +1269,7 @@ terminateUpgrade(): Promise\<void>
```
ts
updater
.
terminateUpgrade
().
then
(()
=>
{
console
.
log
(
`terminateUpgrade success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`terminateUpgrade error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1298,12 +1300,12 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi
**示例:**
```
ts
const
eventClassifyInfo
=
{
const
eventClassifyInfo
:
update
.
EventClassifyInfo
=
{
eventClassify
:
update
.
EventClassify
.
TASK
,
// 订阅升级更新事件
extraInfo
:
""
};
updater
.
on
(
eventClassifyInfo
,
(
eventInfo
)
=>
{
updater
.
on
(
eventClassifyInfo
,
(
eventInfo
:
update
.
EventInfo
)
=>
{
console
.
log
(
"
updater on
"
+
JSON
.
stringify
(
eventInfo
));
});
```
...
...
@@ -1333,12 +1335,12 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v
**示例:**
```
ts
const
eventClassifyInfo
=
{
const
eventClassifyInfo
:
update
.
EventClassifyInfo
=
{
eventClassify
:
update
.
EventClassify
.
TASK
,
// 订阅升级更新事件
extraInfo
:
""
};
updater
.
off
(
eventClassifyInfo
,
(
eventInfo
)
=>
{
updater
.
off
(
eventClassifyInfo
,
(
eventInfo
:
update
.
EventInfo
)
=>
{
console
.
log
(
"
updater off
"
+
JSON
.
stringify
(
eventInfo
));
});
```
...
...
@@ -1406,7 +1408,7 @@ factoryReset(): Promise\<void>
```
ts
restorer
.
factoryReset
().
then
(()
=>
{
console
.
log
(
`factoryReset success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`factoryReset error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1442,7 +1444,7 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: Asyn
**示例:**
```
ts
const
upgradeFile
=
{
const
upgradeFile
:
update
.
UpgradeFile
=
{
fileType
:
update
.
ComponentType
.
OTA
,
// OTA包
filePath
:
"
path
"
// 本地升级包路径
};
...
...
@@ -1486,13 +1488,13 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void
**示例:**
```
ts
const
upgradeFile
=
{
const
upgradeFile
:
update
.
UpgradeFile
=
{
fileType
:
update
.
ComponentType
.
OTA
,
// OTA包
filePath
:
"
path
"
// 本地升级包路径
};
localUpdater
.
verifyUpgradePackage
(
upgradeFile
,
"
cerstFilePath
"
).
then
(()
=>
{
console
.
log
(
`verifyUpgradePackage success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`verifyUpgradePackage error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1524,7 +1526,7 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: Asyn
**示例:**
```
ts
const
upgradeFiles
=
[{
const
upgradeFiles
:
Array
<
update
.
UpgradeFile
>
=
[{
fileType
:
update
.
ComponentType
.
OTA
,
// OTA包
filePath
:
"
path
"
// 本地升级包路径
}];
...
...
@@ -1561,13 +1563,13 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void
**示例:**
```
ts
const
upgradeFiles
=
[{
const
upgradeFiles
:
Array
<
update
.
UpgradeFile
>
=
[{
fileType
:
update
.
ComponentType
.
OTA
,
// OTA包
filePath
:
"
path
"
// 本地升级包路径
}];
localUpdater
.
applyNewVersion
(
upgradeFiles
).
then
(()
=>
{
console
.
log
(
`applyNewVersion success`
);
}).
catch
(
err
=>
{
}).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
log
(
`applyNewVersion error
${
JSON
.
stringify
(
err
)}
`
);
});
```
...
...
@@ -1597,14 +1599,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi
**示例:**
```
ts
const
eventClassifyInfo
=
{
const
eventClassifyInfo
:
update
.
EventClassifyInfo
=
{
eventClassify
:
update
.
EventClassify
.
TASK
,
// 订阅升级更新事件
extraInfo
:
""
};
function
onTaskUpdate
(
eventInfo
)
{
let
onTaskUpdate
:
update
.
UpgradeTaskCallback
=
(
eventInfo
:
update
.
EventInfo
)
=>
{
console
.
log
(
`on eventInfo id `
,
eventInfo
.
eventId
);
}
}
;
localUpdater
.
on
(
eventClassifyInfo
,
onTaskUpdate
);
```
...
...
@@ -1634,14 +1636,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v
**示例:**
```
ts
const
eventClassifyInfo
=
{
const
eventClassifyInfo
:
update
.
EventClassifyInfo
=
{
eventClassify
:
update
.
EventClassify
.
TASK
,
// 订阅升级更新事件
extraInfo
:
""
};
function
onTaskUpdate
(
eventInfo
)
{
let
onTaskUpdate
:
update
.
UpgradeTaskCallback
=
(
eventInfo
:
update
.
EventInfo
)
=>
{
console
.
log
(
`on eventInfo id `
,
eventInfo
.
eventId
);
}
}
;
localUpdater
.
off
(
eventClassifyInfo
,
onTaskUpdate
);
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录