未验证 提交 31bab43d 编写于 作者: O openharmony_ci 提交者: Gitee

!22985 【轻量级 PR】:update模块arkts语法整改

Merge pull request !22985 from ningning/N/A
...@@ -52,17 +52,17 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater ...@@ -52,17 +52,17 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
```ts ```ts
try { try {
const upgradeInfo = { const upgradeInfo: update.UpgradeInfo = {
upgradeApp: "com.ohos.ota.updateclient", upgradeApp: "com.ohos.ota.updateclient",
businessType: { businessType: {
vendor: update.BusinessVendor.PUBLIC, vendor: update.BusinessVendor.PUBLIC,
subType: update.BusinessSubType.FIRMWARE 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 ## update.getRestorer
...@@ -159,9 +159,9 @@ checkNewVersion(callback: AsyncCallback\<CheckResult>): void ...@@ -159,9 +159,9 @@ checkNewVersion(callback: AsyncCallback\<CheckResult>): void
**示例:** **示例:**
```ts ```ts
updater.checkNewVersion((err, result) => { updater.checkNewVersion((err: BusinessError, result: update.CheckResult) => {
console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`); console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`);
}); });
``` ```
### checkNewVersion ### checkNewVersion
...@@ -191,13 +191,15 @@ checkNewVersion(): Promise\<CheckResult> ...@@ -191,13 +191,15 @@ checkNewVersion(): Promise\<CheckResult>
**示例:** **示例:**
```ts ```ts
updater.checkNewVersion().then(result => { updater.checkNewVersion()
console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`); .then((result: update.CheckResult) => {
// 版本摘要信息 console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`);
console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`); // 版本摘要信息
}).catch(err => { console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`);
console.log(`checkNewVersion promise error ${JSON.stringify(err)}`); })
}); .catch((err: BusinessError)=>{
console.log(`checkNewVersion promise error ${JSON.stringify(err)}`);
})
``` ```
### getNewVersionInfo ### getNewVersionInfo
...@@ -227,9 +229,9 @@ getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void ...@@ -227,9 +229,9 @@ getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
**示例:** **示例:**
```ts ```ts
updater.getNewVersionInfo((err, info) => { updater.getNewVersionInfo((err: BusinessError, info: update.NewVersionInfo) => {
console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`); console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`);
}); });
``` ```
...@@ -260,11 +262,11 @@ getNewVersionInfo(): Promise\<NewVersionInfo> ...@@ -260,11 +262,11 @@ getNewVersionInfo(): Promise\<NewVersionInfo>
**示例:** **示例:**
```ts ```ts
updater.getNewVersionInfo().then(info => { updater.getNewVersionInfo().then((info: update.NewVersionInfo) => {
console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`); console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`); console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -298,19 +300,20 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption ...@@ -298,19 +300,20 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 描述文件选项 // 描述文件选项
const descriptionOptions = { const descriptionOptions: update.DescriptionOptions = {
format: update.DescriptionFormat.STANDARD, // 标准格式 format: update.DescriptionFormat.STANDARD, // 标准格式
language: "zh-cn" // 中文 language: "zh-cn" // 中文
}; };
updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => { updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then((info: Array<update.ComponentDescription>)=> {
console.log(`getNewVersionDescription info ${JSON.stringify(info)}`); console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
console.log(`getNewVersionDescription err ${JSON.stringify(err)}`); }).catch((err: BusinessError) => {
console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -349,19 +352,19 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption ...@@ -349,19 +352,19 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 描述文件选项 // 描述文件选项
const descriptionOptions = { const descriptionOptions: update.DescriptionOptions = {
format: update.DescriptionFormat.STANDARD, // 标准格式 format: update.DescriptionFormat.STANDARD, // 标准格式
language: "zh-cn" // 中文 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)}`); console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`); console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -393,7 +396,7 @@ getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void ...@@ -393,7 +396,7 @@ getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void
**示例:** **示例:**
```ts ```ts
updater.getCurrentVersionInfo((err, info) => { updater.getCurrentVersionInfo((err: BusinessError, info: update.CurrentVersionInfo) => {
console.log(`info osVersion = ${info?.osVersion}`); console.log(`info osVersion = ${info?.osVersion}`);
console.log(`info deviceName = ${info?.deviceName}`); console.log(`info deviceName = ${info?.deviceName}`);
console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
...@@ -427,11 +430,11 @@ getCurrentVersionInfo(): Promise\<CurrentVersionInfo> ...@@ -427,11 +430,11 @@ getCurrentVersionInfo(): Promise\<CurrentVersionInfo>
**示例:** **示例:**
```ts ```ts
updater.getCurrentVersionInfo().then(info => { updater.getCurrentVersionInfo().then((info: update.CurrentVersionInfo) => {
console.log(`info osVersion = ${info.osVersion}`); console.log(`info osVersion = ${info.osVersion}`);
console.log(`info deviceName = ${info.deviceName}`); console.log(`info deviceName = ${info.deviceName}`);
console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`); console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -465,7 +468,7 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: A ...@@ -465,7 +468,7 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: A
```ts ```ts
// 描述文件选项 // 描述文件选项
const descriptionOptions = { const descriptionOptions: update.DescriptionOptions = {
format: update.DescriptionFormat.STANDARD, // 标准格式 format: update.DescriptionFormat.STANDARD, // 标准格式
language: "zh-cn" // 中文 language: "zh-cn" // 中文
}; };
...@@ -510,14 +513,13 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<A ...@@ -510,14 +513,13 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<A
```ts ```ts
// 描述文件选项 // 描述文件选项
const descriptionOptions = { const descriptionOptions: update.DescriptionOptions = {
format: update.DescriptionFormat.STANDARD, // 标准格式 format: update.DescriptionFormat.STANDARD, // 标准格式
language: "zh-cn" // 中文 language: "zh-cn" // 中文
}; };
updater.getCurrentVersionDescription(descriptionOptions).then((info: Array<update.ComponentDescription>) => {
updater.getCurrentVersionDescription(descriptionOptions).then(info => {
console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`); console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`); console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -549,7 +551,7 @@ getTaskInfo(callback: AsyncCallback\<TaskInfo>): void ...@@ -549,7 +551,7 @@ getTaskInfo(callback: AsyncCallback\<TaskInfo>): void
**示例:** **示例:**
```ts ```ts
updater.getTaskInfo((err, info) => { updater.getTaskInfo((err: BusinessError, info: update.TaskInfo) => {
console.log(`getTaskInfo isexistTask= ${info?.existTask}`); console.log(`getTaskInfo isexistTask= ${info?.existTask}`);
}); });
``` ```
...@@ -581,9 +583,9 @@ getTaskInfo(): Promise\<TaskInfo> ...@@ -581,9 +583,9 @@ getTaskInfo(): Promise\<TaskInfo>
**示例:** **示例:**
```ts ```ts
updater.getTaskInfo().then(info => { updater.getTaskInfo().then((info: update.TaskInfo) => {
console.log(`getTaskInfo isexistTask= ${info.existTask}`); console.log(`getTaskInfo isexistTask= ${info.existTask}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getTaskInfo promise error ${JSON.stringify(err)}`); console.log(`getTaskInfo promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -618,16 +620,16 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, ...@@ -618,16 +620,16 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions,
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 下载选项 // 下载选项
const downloadOptions = { const downloadOptions: update.DownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载 allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载
order: update.Order.DOWNLOAD // 下载 order: update.Order.DOWNLOAD // 下载
}; };
updater.download(versionDigestInfo, downloadOptions, (err) => { updater.download(versionDigestInfo, downloadOptions, (err: BusinessError) => {
console.log(`download error ${JSON.stringify(err)}`); console.log(`download error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -667,18 +669,18 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions) ...@@ -667,18 +669,18 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions)
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 下载选项 // 下载选项
const downloadOptions = { const downloadOptions: update.DownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载 allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载
order: update.Order.DOWNLOAD // 下载 order: update.Order.DOWNLOAD // 下载
}; };
updater.download(versionDigestInfo, downloadOptions).then(() => { updater.download(versionDigestInfo, downloadOptions).then(() => {
console.log(`download start`); console.log(`download start`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`download error ${JSON.stringify(err)}`); console.log(`download error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -713,15 +715,15 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu ...@@ -713,15 +715,15 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo : update.VersionDigestInfo= {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 恢复下载选项 // 恢复下载选项
const resumeDownloadOptions = { const resumeDownloadOptions : update.ResumeDownloadOptions= {
allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载 allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载
}; };
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => { updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err: BusinessError) => {
console.log(`resumeDownload error ${JSON.stringify(err)}`); console.log(`resumeDownload error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -761,17 +763,17 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu ...@@ -761,17 +763,17 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 恢复下载选项 // 恢复下载选项
const resumeDownloadOptions = { const resumeDownloadOptions: update.ResumeDownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载 allowNetwork: update.NetType.CELLULAR, // 允许数据网络下载
}; };
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => { updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(() => {
console.log(`resumeDownload start`); console.log(`resumeDownload start`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`resumeDownload error ${JSON.stringify(err)}`); console.log(`resumeDownload error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -806,15 +808,15 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD ...@@ -806,15 +808,15 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 暂停下载选项 // 暂停下载选项
const pauseDownloadOptions = { const pauseDownloadOptions: update.PauseDownloadOptions = {
isAllowAutoResume: true // 允许自动恢复下载 isAllowAutoResume: true // 允许自动恢复下载
}; };
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => { updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err: BusinessError) => {
console.log(`pauseDownload error ${JSON.stringify(err)}`); console.log(`pauseDownload error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -854,17 +856,17 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD ...@@ -854,17 +856,17 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 暂停下载选项 // 暂停下载选项
const pauseDownloadOptions = { const pauseDownloadOptions: update.PauseDownloadOptions = {
isAllowAutoResume: true // 允许自动恢复下载 isAllowAutoResume: true // 允许自动恢复下载
}; };
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => { updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(() => {
console.log(`pauseDownload`); console.log(`pauseDownload`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`pauseDownload error ${JSON.stringify(err)}`); console.log(`pauseDownload error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -899,15 +901,15 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, ca ...@@ -899,15 +901,15 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, ca
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 安装选项 // 安装选项
const upgradeOptions = { const upgradeOptions: update.UpgradeOptions = {
order: update.Order.INSTALL // 安装指令 order: update.Order.INSTALL // 安装指令
}; };
updater.upgrade(versionDigestInfo, upgradeOptions, (err) => { updater.upgrade(versionDigestInfo, upgradeOptions, (err: BusinessError) => {
console.log(`upgrade error ${JSON.stringify(err)}`); console.log(`upgrade error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -947,17 +949,17 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): P ...@@ -947,17 +949,17 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): P
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 安装选项 // 安装选项
const upgradeOptions = { const upgradeOptions: update.UpgradeOptions = {
order: update.Order.INSTALL // 安装指令 order: update.Order.INSTALL // 安装指令
}; };
updater.upgrade(versionDigestInfo, upgradeOptions).then(() => { updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
console.log(`upgrade start`); console.log(`upgrade start`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`upgrade error ${JSON.stringify(err)}`); console.log(`upgrade error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -992,15 +994,15 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, cal ...@@ -992,15 +994,15 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, cal
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 清除选项 // 清除选项
const clearOptions = { const clearOptions: update.ClearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL, status: update.UpgradeStatus.UPGRADE_FAIL,
}; };
updater.clearError(versionDigestInfo, clearOptions, (err) => { updater.clearError(versionDigestInfo, clearOptions, (err: BusinessError) => {
console.log(`clearError error ${JSON.stringify(err)}`); console.log(`clearError error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1040,17 +1042,17 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Pr ...@@ -1040,17 +1042,17 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Pr
```ts ```ts
// 版本摘要信息 // 版本摘要信息
const versionDigestInfo = { const versionDigestInfo: update.VersionDigestInfo = {
versionDigest: "versionDigest" // 检测结果中的版本摘要信息 versionDigest: "versionDigest" // 检测结果中的版本摘要信息
}; };
// 清除选项 // 清除选项
const clearOptions = { const clearOptions: update.ClearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL, status: update.UpgradeStatus.UPGRADE_FAIL,
}; };
updater.clearError(versionDigestInfo, clearOptions).then(() => { updater.clearError(versionDigestInfo, clearOptions).then(() => {
console.log(`clearError success`); console.log(`clearError success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`clearError error ${JSON.stringify(err)}`); console.log(`clearError error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1082,7 +1084,7 @@ getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void ...@@ -1082,7 +1084,7 @@ getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void
**示例:** **示例:**
```ts ```ts
updater.getUpgradePolicy((err, policy) => { updater.getUpgradePolicy(err: BusinessError, policy: update.UpgradePolicy) => {
console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`); console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`);
console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`);
}); });
...@@ -1115,10 +1117,10 @@ getUpgradePolicy(): Promise\<UpgradePolicy> ...@@ -1115,10 +1117,10 @@ getUpgradePolicy(): Promise\<UpgradePolicy>
**示例:** **示例:**
```ts ```ts
updater.getUpgradePolicy().then(policy => { updater.getUpgradePolicy().then((policy: update.UpgradePolicy) => {
console.log(`policy downloadStrategy = ${policy.downloadStrategy}`); console.log(`policy downloadStrategy = ${policy.downloadStrategy}`);
console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`); console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1151,12 +1153,12 @@ setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void ...@@ -1151,12 +1153,12 @@ setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```ts ```ts
const policy = { const policy: update.UpgradePolicy = {
downloadStrategy: false, downloadStrategy: false,
autoUpgradeStrategy: 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}`); console.log(`setUpgradePolicy result: ${err}`);
}); });
``` ```
...@@ -1194,14 +1196,14 @@ setUpgradePolicy(policy: UpgradePolicy): Promise\<void> ...@@ -1194,14 +1196,14 @@ setUpgradePolicy(policy: UpgradePolicy): Promise\<void>
**示例:** **示例:**
```ts ```ts
const policy = { const policy: update.UpgradePolicy = {
downloadStrategy: false, downloadStrategy: false,
autoUpgradeStrategy: false, autoUpgradeStrategy: false,
autoUpgradePeriods: [ { start: 120, end: 240 } ] // 自动升级时间段,用分钟表示 autoUpgradePeriods: [ { start: 120, end: 240 } ] // 自动升级时间段,用分钟表示
}; };
updater.setUpgradePolicy(policy).then(() => { updater.setUpgradePolicy(policy).then(() => {
console.log(`setUpgradePolicy success`); console.log(`setUpgradePolicy success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`); console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1233,7 +1235,7 @@ terminateUpgrade(callback: AsyncCallback\<void>): void ...@@ -1233,7 +1235,7 @@ terminateUpgrade(callback: AsyncCallback\<void>): void
**示例:** **示例:**
```ts ```ts
updater.terminateUpgrade((err) => { updater.terminateUpgrade((err: BusinessError) => {
console.log(`terminateUpgrade error ${JSON.stringify(err)}`); console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1267,7 +1269,7 @@ terminateUpgrade(): Promise\<void> ...@@ -1267,7 +1269,7 @@ terminateUpgrade(): Promise\<void>
```ts ```ts
updater.terminateUpgrade().then(() => { updater.terminateUpgrade().then(() => {
console.log(`terminateUpgrade success`); console.log(`terminateUpgrade success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`terminateUpgrade error ${JSON.stringify(err)}`); console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1298,12 +1300,12 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi ...@@ -1298,12 +1300,12 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi
**示例:** **示例:**
```ts ```ts
const eventClassifyInfo = { const eventClassifyInfo: update.EventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // 订阅升级更新事件 eventClassify: update.EventClassify.TASK, // 订阅升级更新事件
extraInfo: "" extraInfo: ""
}; };
updater.on(eventClassifyInfo, (eventInfo) => { updater.on(eventClassifyInfo, (eventInfo: update.EventInfo) => {
console.log("updater on " + JSON.stringify(eventInfo)); console.log("updater on " + JSON.stringify(eventInfo));
}); });
``` ```
...@@ -1333,12 +1335,12 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v ...@@ -1333,12 +1335,12 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v
**示例:** **示例:**
```ts ```ts
const eventClassifyInfo = { const eventClassifyInfo: update.EventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // 订阅升级更新事件 eventClassify: update.EventClassify.TASK, // 订阅升级更新事件
extraInfo: "" extraInfo: ""
}; };
updater.off(eventClassifyInfo, (eventInfo) => { updater.off(eventClassifyInfo, (eventInfo: update.EventInfo) => {
console.log("updater off " + JSON.stringify(eventInfo)); console.log("updater off " + JSON.stringify(eventInfo));
}); });
``` ```
...@@ -1406,7 +1408,7 @@ factoryReset(): Promise\<void> ...@@ -1406,7 +1408,7 @@ factoryReset(): Promise\<void>
```ts ```ts
restorer.factoryReset().then(() => { restorer.factoryReset().then(() => {
console.log(`factoryReset success`); console.log(`factoryReset success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`factoryReset error ${JSON.stringify(err)}`); console.log(`factoryReset error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1442,7 +1444,7 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: Asyn ...@@ -1442,7 +1444,7 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: Asyn
**示例:** **示例:**
```ts ```ts
const upgradeFile = { const upgradeFile: update.UpgradeFile = {
fileType: update.ComponentType.OTA, // OTA包 fileType: update.ComponentType.OTA, // OTA包
filePath: "path" // 本地升级包路径 filePath: "path" // 本地升级包路径
}; };
...@@ -1486,13 +1488,13 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void ...@@ -1486,13 +1488,13 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void
**示例:** **示例:**
```ts ```ts
const upgradeFile = { const upgradeFile: update.UpgradeFile = {
fileType: update.ComponentType.OTA, // OTA包 fileType: update.ComponentType.OTA, // OTA包
filePath: "path" // 本地升级包路径 filePath: "path" // 本地升级包路径
}; };
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => { localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => {
console.log(`verifyUpgradePackage success`); console.log(`verifyUpgradePackage success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`); console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1524,7 +1526,7 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: Asyn ...@@ -1524,7 +1526,7 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: Asyn
**示例:** **示例:**
```ts ```ts
const upgradeFiles = [{ const upgradeFiles: Array<update.UpgradeFile> = [{
fileType: update.ComponentType.OTA, // OTA包 fileType: update.ComponentType.OTA, // OTA包
filePath: "path" // 本地升级包路径 filePath: "path" // 本地升级包路径
}]; }];
...@@ -1561,13 +1563,13 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void ...@@ -1561,13 +1563,13 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void
**示例:** **示例:**
```ts ```ts
const upgradeFiles = [{ const upgradeFiles: Array<update.UpgradeFile> = [{
fileType: update.ComponentType.OTA, // OTA包 fileType: update.ComponentType.OTA, // OTA包
filePath: "path" // 本地升级包路径 filePath: "path" // 本地升级包路径
}]; }];
localUpdater.applyNewVersion(upgradeFiles).then(() => { localUpdater.applyNewVersion(upgradeFiles).then(() => {
console.log(`applyNewVersion success`); console.log(`applyNewVersion success`);
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`applyNewVersion error ${JSON.stringify(err)}`); console.log(`applyNewVersion error ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1597,14 +1599,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi ...@@ -1597,14 +1599,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi
**示例:** **示例:**
```ts ```ts
const eventClassifyInfo = { const eventClassifyInfo: update.EventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // 订阅升级更新事件 eventClassify: update.EventClassify.TASK, // 订阅升级更新事件
extraInfo: "" extraInfo: ""
}; };
function onTaskUpdate(eventInfo) { let onTaskUpdate: update.UpgradeTaskCallback = (eventInfo: update.EventInfo) => {
console.log(`on eventInfo id `, eventInfo.eventId); console.log(`on eventInfo id `, eventInfo.eventId);
} };
localUpdater.on(eventClassifyInfo, onTaskUpdate); localUpdater.on(eventClassifyInfo, onTaskUpdate);
``` ```
...@@ -1634,14 +1636,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v ...@@ -1634,14 +1636,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v
**示例:** **示例:**
```ts ```ts
const eventClassifyInfo = { const eventClassifyInfo: update.EventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // 订阅升级更新事件 eventClassify: update.EventClassify.TASK, // 订阅升级更新事件
extraInfo: "" extraInfo: ""
}; };
function onTaskUpdate(eventInfo) { let onTaskUpdate: update.UpgradeTaskCallback = (eventInfo: update.EventInfo) => {
console.log(`on eventInfo id `, eventInfo.eventId); console.log(`on eventInfo id `, eventInfo.eventId);
} };
localUpdater.off(eventClassifyInfo, onTaskUpdate); localUpdater.off(eventClassifyInfo, onTaskUpdate);
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册