1 Star 0 Fork 5.3K

OpenHarmony-build / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
js-apis-update.md 14.17 KB
一键复制 编辑 原始数据 按行查看 历史
zengyawen 提交于 2021-09-30 20:37 . LTS3.0 update docs

系统恢复

导入模块

import update from '@ohos.update'

权限列表

方法

verifyUpdatePackage(upgradeFile: string, certsFile: string): void

升级前检查升级包是否有效。

参数:

参数名

类型

必填

说明

upgradeFile

string

待校验的升级包路径

certsFile

string

证书路径

返回值:

示例:

var getVar = update.getUpdater();
getVar.on("verifyProgress", function (callback){
    console.info('on verifyProgress ' + callback.percent);
});
getVar.verifyUpdatePackage("XXX", "XXX");
getVar.off("verifyProgress");

rebootAndCleanUserData(): Promise<number>

重启设备并清除用户分区数据。

参数:

返回值:

类型

说明

Promise<number>

Promise示例,用于异步获取结果。

示例:

var getVar = update.getUpdater();
p = getVar.rebootAndCleanUserData();
p.then(function (value) {
    console.info("rebootAndCleanUserData promise success: " + value);
}).catch(function (err) {
    console.info("rebootAndCleanUserData promise error: " + err.code);
});

rebootAndCleanUserData(callback: AsyncCallback<number>): void

重启设备并清除用户分区数据。

参数:

参数名

类型

必填

说明

callback

Function

AsyncCallback<number>

返回值:

示例:

var getVar = update.getUpdater();
getVar.rebootAndCleanUserData(function (err, data) {
    if (err.code == 0) {
        console.info("rebootAndCleanUserData callback success:" + data)
    } else {
        console.info("rebootAndCleanUserData callback err:" + err.code)
    }
});

applyNewVersion(): Promise<number>

重启设备后安装升级包。

参数:

返回值:

类型

说明

Promise<number>

Promise示例,用于异步获取结果。

示例:

var getVar = update.getUpdater();
p.then(function (value) {
    console.info("applyNewVersion promise success: " + value);
}).catch(function (err) {
    console.info("applyNewVersion promise error: " + err.code);
});

applyNewVersion(callback: AsyncCallback<number>): void

重启设备后安装升级包。

参数:

参数名

类型

必填

说明

callback

Function

AsyncCallback<number>

返回值:

示例:

var getVar = update.getUpdater();
getVar.applyNewVersion(function (err, data) {
    if (err.code == 0) {
        console.info("applyNewVersion callback success:" + data)
    } else {
        console.info("applyNewVersion callback err:" + err.code)
    }
});
1
https://gitee.com/openharmony-build/docs.git
git@gitee.com:openharmony-build/docs.git
openharmony-build
docs
docs
master

搜索帮助