# 系统恢复 ## 导入模块 ``` 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 重启设备并清除用户分区数据。 **参数:** 无 **返回值:**

类型

说明

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\): 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 重启设备后安装升级包。 **参数:** 无 **返回值:**

类型

说明

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\): 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) } }); ```