提交 e391ed76 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 c7ec364f
# Update # Update
The update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications.
There are two types of updates: SD card update and over the air (OTA) update. There are two types of updates: SD card update and over the air (OTA) update.
...@@ -10,109 +10,212 @@ There are two types of updates: SD card update and over the air (OTA) update. ...@@ -10,109 +10,212 @@ There are two types of updates: SD card update and over the air (OTA) update.
## Modules to Import ## Modules to Import
```js ```js
import client from '@ohos.update' import update from '@ohos.update'
``` ```
## Required Permissions ## Required Permissions
None None
## Obtains an **Updater** object.
### update.getUpdater
getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater
Obtains the **Updater** object for local update.
**System capability**: SystemCapability.Updater.update_service
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | -------- |
| upgradeFile | string | Yes | Update file.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.|
**Return value**
| Type | Description |
| ------------------- | -------- |
| [Updater](#updater) | **Updater** object.|
**Example**
```
try {
let updater = update.getUpdater('/data/updater/updater.zip', 'OTA');
} catch(error) {
console.error(" Fail to get updater error: " + error);
}
```
### update.getUpdaterForOther
getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater
Obtains the **Updater** object for the device to be updated.
**System capability**: SystemCapability.Updater.update_service
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return value**
| Type | Description |
| ------------------- | -------- |
| [Updater](#updater) | **Updater** object.|
**Example**
```
try {
let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
console.error(" Fail to get updater error: " + error);
}
```
### update.getUpdaterFromOther
getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater
Obtains the **Updater** object from another device for the device to be updated.
**System capability**: SystemCapability.Updater.update_service
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return value**
| Type | Description |
| ------------------- | -------- |
| [Updater](#updater) | **Updater** object.|
**Example**
```
try {
let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
console.error(" Fail to get updater error: " + error);
}
```
## Updater ## Updater
### getNewVersionInfo ### getNewVersionInfo
getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
Obtains the new version information. This method uses an asynchronous callback to return the result. Obtains the new version information. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ------------------ | | -------- | ------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No| Callback used to return the new version information.| | callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example** **Example**
``` ```
updater.getNewVersionInfo(info => { update.getNewVersionInfo(info => {
console.log("getNewVersionInfo success " + info.status); console.log("getNewVersionInfo success " + info.status);
console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionName = ` + info.result[0].versionName);
console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info versionCode = ` + info.result[0].versionCode);
console.log(`info verifyInfo = ` + info.result[0].verifyInfo); console.log(`info verifyInfo = ` + info.result[0].verifyInfo);
)}; });
``` ```
### getNewVersionInfo ### getNewVersionInfo
getNewVersionInfo(): Promise\<NewVersionInfo> getNewVersionInfo(): Promise\<NewVersionInfo>
Obtains the new version information. This method uses a promise to return the result. Obtains the new version information. This function uses a promise to return the result.
**Return values** **System capability**: SystemCapability.Updater.update_service
| Type| Description| **Return value**
| Type | Description |
| ------------------------------------------- | ------------------------- | | ------------------------------------------- | ------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example** **Example**
``` ```
var p = updater.getNewVersionInfo(); updater.getNewVersionInfo().then(value => {
p.then(function (value) {
console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionName = ` + value.result[0].versionName);
console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info versionCode = ` + value.result[0].versionCode);
console.log(`info verifyInfo = ` + value.result[0].verifyInfo); console.log(`info verifyInfo = ` + value.result[0].verifyInfo);
}).catch(function (err) { }).catch(err => {
console.log("getNewVersionInfo promise error: " + err.code); console.log("getNewVersionInfo promise error: " + err.code);
)}; });
``` ```
### checkNewVersion ### checkNewVersion
checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void
Checks whether the current version is the latest. This method uses an asynchronous callback to return the result. Checks whether the current version is the latest. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ | | -------- | ------------------------------------------------- | ---- | ------------------ |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No| Callback used to return the new version information.| | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example** **Example**
``` ```
updater.checkNewVersion(info => { update.checkNewVersion(info => {
console.log("checkNewVersion success " + info.status); console.log("checkNewVersion success " + info.status);
console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionName = ` + info.result[0].versionName);
console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info versionCode = ` + info.result[0].versionCode);
console.log(`info verifyInfo = ` + info.result[0].verifyInfo); console.log(`info verifyInfo = ` + info.result[0].verifyInfo);
)}; });
``` ```
### checkNewVersion ### checkNewVersion
checkNewVersion(): Promise\<NewVersionInfo> checkNewVersion(): Promise\<NewVersionInfo>
Checks whether the current version is the latest. This method uses a promise to return the result. Checks whether the current version is the latest. This function uses a promise to return the result.
**System capability**: SystemCapability.Updater.update_service
**Return values** **Return value**
| Type| Description| | Type | Description |
| ------------------------------------------- | ------------------------- | | ------------------------------------------- | ------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example** **Example**
``` ```
var p = updater.checkNewVersion(); update.checkNewVersion().then(value => {
p.then(function (value) {
console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionName = ` + value.result[0].versionName);
console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info versionCode = ` + value.result[0].versionCode);
console.log(`info verifyInfo = ` + value.result[0].verifyInfo); console.log(`info verifyInfo = ` + value.result[0].verifyInfo);
}).catch(function (err) { }).catch(err => {
console.log("checkNewVersion promise error: " + err.code); console.log("checkNewVersion promise error: " + err.code);
)}; });
``` ```
### verifyUpdatePackage ### verifyUpdatePackage
...@@ -121,45 +224,45 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void ...@@ -121,45 +224,45 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void
Verifies whether the update package is valid. Verifies whether the update package is valid.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------ | | ----------- | ------ | ---- | ------------------ |
| upgradeFile | string | Yes| Path of the update package to be verified.| | upgradeFile | string | Yes | Path of the update package to be verified.|
| certsFile | string | Yes| Certificate path.| | certsFile | string | Yes | Certificate path. |
**Example** **Example**
``` ```
var getVar = update.getUpdater(); update.on("verifyProgress", callback => {
getVar.on("verifyProgress", function (callback){ console.info('on verifyProgress ' + callback.percent);
console.info('on verifyProgress ' + callback.percent);
}); });
getVar.verifyUpdatePackage("XXX", "XXX"); update.verifyUpdatePackage("XXX", "XXX");
getVar.off("verifyProgress");
``` ```
### rebootAndCleanUserData ### rebootAndCleanUserData
rebootAndCleanUserData(): Promise\<number> rebootAndCleanUserData(): Promise\<number>
Reboots the device and clears the user partition data. This method uses a promise to return the result. Reboots the device and clears the user partition data. This function uses a promise to return the result.
**Return values** **System capability**: SystemCapability.Updater.update_service
| Type| Description| **Return value**
| Type | Description |
| ---------------- | ------------------------------- | | ---------------- | ------------------------------- |
| Promise\<number> | Promise used to return the execution result.| | Promise\<number> | Promise used to return the execution result.|
**Example** **Example**
``` ```
var getVar = update.getUpdater(); update.rebootAndCleanUserData().then(result => {
p = getVar.rebootAndCleanUserData(); console.log("rebootAndCleanUserData " + result);
p.then(function (value) { }).catch(err => {
console.info("rebootAndCleanUserData promise success: " + value); console.info("rebootAndCleanUserData promise error: " + err.code);
}).catch(function (err) {
console.info("rebootAndCleanUserData promise error: " + err.code);
}); });
``` ```
...@@ -167,24 +270,21 @@ p.then(function (value) { ...@@ -167,24 +270,21 @@ p.then(function (value) {
rebootAndCleanUserData(callback: AsyncCallback\<number>): void rebootAndCleanUserData(callback: AsyncCallback\<number>): void
Reboots the device and clears the user partition data. This method uses an asynchronous callback to return the result. Reboots the device and clears the user partition data. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------- | | -------- | -------- | ---- | ---------------------- |
| callback | Function | Yes| AsyncCallback\<number> | | callback | AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example** **Example**
``` ```
var getVar = update.getUpdater(); update.rebootAndCleanUserData(result => {
getVar.rebootAndCleanUserData(function (err, data) { console.log("rebootAndCleanUserData ", result)
if (err.code == 0) {
console.info("rebootAndCleanUserData callback success:" + data)
} else {
console.info("rebootAndCleanUserData callback err:" + err.code)
}
}); });
``` ```
...@@ -192,21 +292,22 @@ getVar.rebootAndCleanUserData(function (err, data) { ...@@ -192,21 +292,22 @@ getVar.rebootAndCleanUserData(function (err, data) {
applyNewVersion(): Promise\<number> applyNewVersion(): Promise\<number>
Installs the update package. This method uses a promise to return the result. Installs the update package. This function uses a promise to return the result.
**Return values** **System capability**: SystemCapability.Updater.update_service
| Type| Description| **Return value**
| Type | Description |
| ---------------- | ------------------------------- | | ---------------- | ------------------------------- |
| Promise\<number> | Promise used to return the execution result.| | Promise\<number> | Promise used to return the execution result.|
**Example** **Example**
``` ```
var getVar = update.getUpdater(); update.applyNewVersion().then(result => {
p.then(function (value) { console.log("appVewVersion ", result)
console.info("applyNewVersion promise success: " + value); }).catch(err => {
}).catch(function (err) {
console.info("applyNewVersion promise error: " + err.code); console.info("applyNewVersion promise error: " + err.code);
}); });
``` ```
...@@ -215,24 +316,21 @@ p.then(function (value) { ...@@ -215,24 +316,21 @@ p.then(function (value) {
applyNewVersion(callback: AsyncCallback\<number>): void applyNewVersion(callback: AsyncCallback\<number>): void
Installs the update package. This method uses an asynchronous callback to return the result. Installs the update package. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------- | | -------- | -------- | ---- | ---------------------- |
| callback | Function | Yes| AsyncCallback\<number> | | callback| AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example** **Example**
``` ```
var getVar = update.getUpdater(); update.applyNewVersion(result => {
getVar.applyNewVersion(function (err, data) { console.log("applyNewVersion ", result)
if (err.code == 0) {
console.info("applyNewVersion callback success:" + data)
} else {
console.info("applyNewVersion callback err:" + err.code)
}
}); });
``` ```
...@@ -242,6 +340,8 @@ download(): void ...@@ -242,6 +340,8 @@ download(): void
Downloads the new version and displays the download process. Downloads the new version and displays the download process.
**System capability**: SystemCapability.Updater.update_service
**Example** **Example**
``` ```
...@@ -249,7 +349,7 @@ updater.on("downloadProgress", progress => { ...@@ -249,7 +349,7 @@ updater.on("downloadProgress", progress => {
console.log("downloadProgress on" + progress); console.log("downloadProgress on" + progress);
console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress status: ` + progress.status);
console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress percent: ` + progress.percent);
)}; });
updater.download(); updater.download();
``` ```
...@@ -259,6 +359,8 @@ updater.upgrade():void ...@@ -259,6 +359,8 @@ updater.upgrade():void
Starts an update. Starts an update.
**System capability**: SystemCapability.Updater.update_service
**Example** **Example**
``` ```
...@@ -266,7 +368,7 @@ updater.on("upgradeProgress", progress => { ...@@ -266,7 +368,7 @@ updater.on("upgradeProgress", progress => {
console.log("upgradeProgress on" + progress); console.log("upgradeProgress on" + progress);
console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress status: ` + progress.status);
console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress percent: ` + progress.percent);
)}; });
updater.upgrade(); updater.upgrade();
``` ```
...@@ -274,45 +376,50 @@ updater.upgrade(); ...@@ -274,45 +376,50 @@ updater.upgrade();
setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void
Sets the update policy. This method uses an asynchronous callback to return the result. Sets the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------ | | -------- | ----------------------------- | ---- | ------------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes| Update policy to set.| | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the execution result.| | callback | AsyncCallback\<number> | Yes | Callback used to return the execution result.|
**Example** **Example**
``` ```
// Set the update policy. // Set the update policy.
let policy = { let policy = {
autoDownload: false, autoDownload: false,
autoDownloadNet: true, autoDownloadNet: true,
mode: 2, mode: 2,
autoUpgradeInterval: [ 2, 3 ], autoUpgradeInterval: [ 2, 3 ],
autoUpgradeCondition: 2 autoUpgradeCondition: 2
} }
updater.setUpdatePolicy(policy, function(result) { update.setUpdatePolicy(policy, result => {
console.log("setUpdatePolicy ", result)}); console.log("setUpdatePolicy ", result)
});
``` ```
### setUpdatePolicy ### setUpdatePolicy
setUpdatePolicy(policy: UpdatePolicy): Promise\<number> setUpdatePolicy(policy: UpdatePolicy): Promise\<number>
Sets the update policy. This method uses a promise to return the result. Sets the update policy. This function uses a promise to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | ------------ | | ------ | ----------------------------- | ---- | ------------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes| Update policy to set.| | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
**Return values** **Return value**
| Type| Description| | Type | Description |
| ---------------- | ----------------------- | | ---------------- | ----------------------- |
| Promise\<number> | Promise used to return the execution result.| | Promise\<number> | Promise used to return the execution result.|
...@@ -320,238 +427,153 @@ Sets the update policy. This method uses a promise to return the result. ...@@ -320,238 +427,153 @@ Sets the update policy. This method uses a promise to return the result.
``` ```
let policy = { let policy = {
autoDownload: false, autoDownload: false,
autoDownloadNet: true, autoDownloadNet: true,
mode: 2, mode: 2,
autoUpgradeInterval: [ 2, 3 ], autoUpgradeInterval: [ 2, 3 ],
autoUpgradeCondition: 2 autoUpgradeCondition: 2
} }
updater.setUpdatePolicy(policy) update.setUpdatePolicy(policy).then(result =>
.then(data=> console.log("setUpdatePolicy ", result)
console.log('Policy set successfully') ).catch(err => {
) console.log("setUpdatePolicy promise error: " + err.code);
});
``` ```
### getUpdatePolicy ### getUpdatePolicy
getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void
Obtains the update policy. This method uses an asynchronous callback to return the result. Obtains the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Updater.update_service
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------- | ---- | -------------------- | | -------- | --------------------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No| Callback used to return the update policy.| | callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy.|
**Example** **Example**
``` ```
updater.getUpdatePolicy(policy => { update.getUpdatePolicy(policy => {
console.log("getUpdatePolicy success"); console.log("getUpdatePolicy success");
console.log(`policy autoDownload = ` + policy.autoDownload); console.log(`policy autoDownload = ` + policy.autoDownload);
console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet);
console.log(`policy mode = ` + policy.mode); console.log(`policy mode = ` + policy.mode);
)}; });
``` ```
### getUpdatePolicy ### getUpdatePolicy
getUpdatePolicy(): Promise\<UpdatePolicy> getUpdatePolicy(): Promise\<UpdatePolicy>
Obtains the update policy. This method uses a promise to return the result. Obtains the update policy. This function uses a promise to return the result.
**Return values** **System capability**: SystemCapability.Updater.update_service
| Type| Description| **Return value**
| Type | Description |
| --------------------------------------- | --------------------------- | | --------------------------------------- | --------------------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.| | Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.|
**Example** **Example**
``` ```
p = updater.getUpdatePolicy(); update.getUpdatePolicy().then(value => {
p.then(function (value) {
console.log(`info autoDownload = ` + value.autoDownload); console.log(`info autoDownload = ` + value.autoDownload);
console.log(`info autoDownloadNet = ` + value.autoDownloadNet); console.log(`info autoDownloadNet = ` + value.autoDownloadNet);
console.log(`info mode = ` + value.mode); console.log(`info mode = ` + value.mode);
}).catch(function (err) { }).catch(err => {
console.log("getUpdatePolicy promise error: " + err.code); console.log("getUpdatePolicy promise error: " + err.code);
)}; });
```
## update.getUpdater
getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater
Obtains the updater for the local update.
**Parameters**
| Name| Type| Mandatory| Description|
| ----------- | --------------------------- | ---- | -------- |
| upgradeFile | string | Yes| Update file.|
| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.|
**Return values**
| Type| Description|
| ------------------- | -------- |
| [Updater](#updater) | Updater object.|
**Example**
```
try {
page.data.updater = update.getUpdater('/data/updater/updater.zip', 'OTA');
} catch(error) {
console.error("Failed to get updater. Error: " + error);
}
```
## update.getUpdaterForOther
getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater
Obtains the updater for the device to be updated.
**Parameters**
| Name| Type| Mandatory| Description|
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes| Update file.|
| device | string | Yes| Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.|
**Return values**
| Type| Description|
| ------------------- | -------- |
| [Updater](#updater) | Updater object.|
**Example**
```
try {
page.data.updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
console.error("Failed to get updater. Error: " + error);
}
```
## update.getUpdaterFromOther
getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater
Obtains the updater from another device for the device to be updated.
**Parameters**
| Name| Type| Mandatory| Description|
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes| Update file.|
| device | string | Yes| Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.|
**Return values**
| Type| Description|
| ------------------- | -------- |
| [Updater](#updater) | Updater object.|
**Example**
```
try {
page.data.updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
console.error("Failed to get updater. Error: " + error);
}
``` ```
## UpdateTypes ## UpdateTypes
Describes the update type. Enumerates update types.
| Name| Description| | Name| Description |
| ------ | -------- | | ------ | -------- |
| OTA | OTA update.| | OTA | OTA update.<br>**System capability**: SystemCapability.Updater.update_service|
| patch | Patch update.| | patch | Patch update.<br>**System capability**: SystemCapability.Updater.update_service|
## PackageTypes ## PackageTypes
Enumerates the update package types. Enumerates update package types.
| Name| Default Value| Description| | Name | Default Value| Description |
| -------------------- | ------ | -------------- | | -------------------- | ------ | -------------- |
| PACKAGE_TYPE_NORMAL | 1 | Common update package.| | PACKAGE_TYPE_NORMAL | 1 | Common update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_BASE | 2 | Basic update package.| | PACKAGE_TYPE_BASE | 2 | Basic update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_CUST | 3 | Custom update package.| | PACKAGE_TYPE_CUST | 3 | Custom update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package.| | PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.| | PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_VERSION | 6 | Version update package.| | PACKAGE_TYPE_VERSION | 6 | Version update package.<br>**System capability**: SystemCapability.Updater.update_service|
| PACKAGE_TYPE_PATCH | 7 | Patch package.| | PACKAGE_TYPE_PATCH | 7 | Patch package.<br>**System capability**: SystemCapability.Updater.update_service|
## InstallMode ## InstallMode
Enumerates the update modes. Enumerates update modes.
| Name| Default Value| Description| | Name | Default Value| Description |
| ------------------- | ------ | -------- | | ------------------- | ------ | -------- |
| INSTALL_MODE_NORMAL | 0 | Normal update.| | INSTALL_MODE_NORMAL | 0 | Normal update.<br>**System capability**: SystemCapability.Updater.update_service|
| INSTALL_MODE_NIGHT | 1 | Update at night.| | INSTALL_MODE_NIGHT | 1 | Update at night.<br>**System capability**: SystemCapability.Updater.update_service|
| INSTALL_MODE_AUTO | 2 | Automatic update.| | INSTALL_MODE_AUTO | 2 | Automatic update.<br>**System capability**: SystemCapability.Updater.update_service|
## NewVersionStatus ## NewVersionStatus
Enumerates the new version check results. Enumerates new version check results.
| Name| Default Value| Description| | Name | Default Value| Description |
| ------------------- | ------ | ---------------- | | ------------------- | ------ | ---------------- |
| VERSION_STATUS_ERR | -1 | System error while checking for the new version.| | VERSION_STATUS_ERR | -1 | System error while checking for the new version.<br>**System capability**: SystemCapability.Updater.update_service|
| VERSION_STATUS_NEW | 0 | New version detected.| | VERSION_STATUS_NEW | 0 | New version detected.<br>**System capability**: SystemCapability.Updater.update_service|
| VERSION_STATUS_NONE | 1 | No new version detected.| | VERSION_STATUS_NONE | 1 | No new version detected.<br>**System capability**: SystemCapability.Updater.update_service|
| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version.| | VERSION_STATUS_BUSY | 2 | System busy while checking for the new version.<br>**System capability**: SystemCapability.Updater.update_service|
## UpdatePolicy ## UpdatePolicy
Defines the update policy. Defines the update policy.
| Name| Parameter type.| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------------------- | --------------------------- | ---- | -------------- | | ------------------- | --------------------------- | ---- | -------------- |
| autoDownload | bool | Yes| Automatic update switch.| | autoDownload | bool | Yes | Automatic update switch.<br>**System capability**: SystemCapability.Updater.update_service|
| installMode | [InstallMode](#installmode) | Yes| Update mode.| | installMode | [InstallMode](#installmode) | Yes | Update mode.<br>**System capability**: SystemCapability.Updater.update_service|
| autoUpgradeInterval | Array\<number> | Yes| Period of time for automatic update.| | autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update.<br>**System capability**: SystemCapability.Updater.update_service|
## NewVersionInfo ## NewVersionInfo
Defines the new version information. Defines the new version information.
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------- | ---- | -------- | | --------------- | ------------------------------------------- | ---- | -------- |
| status | [NewVersionStatus](#newversionstatus) | Yes| Update status.| | status | [NewVersionStatus](#newversionstatus) | Yes | Update status.<br>**System capability**: SystemCapability.Updater.update_service|
| errMsg | string | Yes| Error message.| | errMsg | string | Yes | Error message.<br>**System capability**: SystemCapability.Updater.update_service|
| checkResults | Array<[CheckResult](#checkresult)> | Yes| Check result.| | checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.<br>**System capability**: SystemCapability.Updater.update_service|
| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes| Description.| | descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.<br>**System capability**: SystemCapability.Updater.update_service|
## CheckResult ## CheckResult
Defines the check result. Defines the version check result.
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------------- | ----------------------------- | ---- | ------------ | | ------------- | ----------------------------- | ---- | ------------ |
| versionName | string | Yes| Version name.| | versionName | string | Yes | Version name.<br>**System capability**: SystemCapability.Updater.update_service|
| versionCode | number | Yes| Version code.| | versionCode | number | Yes | Version code.<br>**System capability**: SystemCapability.Updater.update_service|
| size | number | Yes| Version size.| | size | number | Yes | Version size.<br>**System capability**: SystemCapability.Updater.update_service|
| verifyInfo | string | Yes| Version verification information.| | verifyInfo | string | Yes | Version verification information.<br>**System capability**: SystemCapability.Updater.update_service|
| packageType | [PackageTypes](#packagetypes) | Yes| Version type.| | packageType | [PackageTypes](#packagetypes) | Yes | Version type.<br>**System capability**: SystemCapability.Updater.update_service|
| descriptionId | string | Yes| Version description.| | descriptionId | string | Yes | Version description information.<br>**System capability**: SystemCapability.Updater.update_service|
## DescriptionInfo ## DescriptionInfo
Defines the version description information. Defines the version description information.
| Name| Type| Mandatory| Description| | Name | Type| Mandatory| Description |
| ------------- | -------- | ---- | ----------------- | | ------------- | -------- | ---- | ----------------- |
| descriptionId | string | Yes| Version ID information.| | descriptionId | string | Yes | Version ID information.<br>**System capability**: SystemCapability.Updater.update_service|
| content | string | Yes| Version changelog information.| | content | string | Yes | Version changelog information.<br>**System capability**: SystemCapability.Updater.update_service|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册