js-apis-update.md 58.3 KB
Newer Older
W
wusongqing 已提交
1 2
# Update

S
shawn_he 已提交
3
The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications.
W
wusongqing 已提交
4 5 6 7

There are two types of updates: SD card update and over the air (OTA) update.

- The SD card update depends on the update packages and SD cards.
H
HelloCrease 已提交
8
- The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer.
W
wusongqing 已提交
9

S
shawn_he 已提交
10 11 12 13 14 15
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.

W
wusongqing 已提交
16 17 18
## Modules to Import

```js
S
shawn_he 已提交
19
import update from '@ohos.update'
W
wusongqing 已提交
20 21
```

S
shawn_he 已提交
22
## update.getOnlineUpdater
S
shawn_he 已提交
23

S
shawn_he 已提交
24
getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
S
shawn_he 已提交
25

S
shawn_he 已提交
26
Obtains an **OnlineUpdater** object.
S
shawn_he 已提交
27

S
shawn_he 已提交
28
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
29 30 31

**Parameters**

S
shawn_he 已提交
32 33 34
| Name        | Type                         | Mandatory  | Description  |
| ----------- | --------------------------- | ---- | ---- |
| upgradeInfo | [UpgradeInfo](#upgradeinfo)                 | Yes   | **UpgradeInfo** object.|
S
shawn_he 已提交
35

S
shawn_he 已提交
36
**Return value**
S
shawn_he 已提交
37

S
shawn_he 已提交
38 39 40
| Type                 | Description  |
| ------------------- | ---- |
| [Updater](#updater) | **OnlineUpdater** object.|
S
shawn_he 已提交
41 42 43 44 45

**Example**

```
try {
S
shawn_he 已提交
46 47 48 49 50 51 52 53
  var upgradeInfo = {
    upgradeApp: "com.ohos.ota.updateclient",
    businessType: {
      vendor: update.BusinessVendor.PUBLIC,
      subType: update.BusinessSubType.FIRMWARE
    }
  }
  let updater = update.getOnlineUpdater(upgradeInfo);
S
shawn_he 已提交
54
} catch(error) {
S
shawn_he 已提交
55
  console.error(`Fail to get updater error: ${error}`);
S
shawn_he 已提交
56 57 58
}
```

S
shawn_he 已提交
59
## update.getRestorer
S
shawn_he 已提交
60

S
shawn_he 已提交
61
getRestorer(): Restorer
S
shawn_he 已提交
62

S
shawn_he 已提交
63
Obtains a **Restorer** object for restoring factory settings.
S
shawn_he 已提交
64

S
shawn_he 已提交
65
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
66 67


S
shawn_he 已提交
68
**Return value**
S
shawn_he 已提交
69

S
shawn_he 已提交
70 71 72
| Type                 | Description  |
| ------------------- | ---- |
| [Restorer](#restorer) | **Restorer** object for restoring factory settings.|
S
shawn_he 已提交
73 74 75 76 77

**Example**

```
try {
S
shawn_he 已提交
78
  let restorer = update.getRestorer();
S
shawn_he 已提交
79
} catch(error) {
S
shawn_he 已提交
80
  console.error(`Fail to get restorer: ${error}`);
S
shawn_he 已提交
81 82 83
}
```

S
shawn_he 已提交
84
## update.getLocalUpdater
S
shawn_he 已提交
85

S
shawn_he 已提交
86
getLocalUpdater(): LocalUpdater
S
shawn_he 已提交
87

S
shawn_he 已提交
88
Obtains a **LocalUpdater** object.
S
shawn_he 已提交
89

S
shawn_he 已提交
90
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
91

S
shawn_he 已提交
92
**Return value**
S
shawn_he 已提交
93

S
shawn_he 已提交
94 95 96
| Type                 | Description  |
| ------------------- | ---- |
| [LocalUpdater](#localupdater) | **LocalUpdater** object.|
S
shawn_he 已提交
97 98 99 100 101

**Example**

```
try {
S
shawn_he 已提交
102
  let localUpdater = update.getLocalUpdater();
S
shawn_he 已提交
103
} catch(error) {
S
shawn_he 已提交
104
  console.error(`Fail to get localUpdater error: ${error}`);
S
shawn_he 已提交
105 106 107
}
```

W
wusongqing 已提交
108 109
## Updater

S
shawn_he 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
### checkNewVersion

checkNewVersion(callback: AsyncCallback\<CheckResult>): void

Checks whether a new version is available. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes   | Callback used to return the result.|

**Example**

```
updater.checkNewVersion((err, result) => {
  console.log(`checkNewVersion isExistNewVersion  ${result?.isExistNewVersion}`);
});
```

### checkNewVersion

checkNewVersion(): Promise\<CheckResult>

Checks whether a new version is available. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<[CheckResult](#checkresult)> | Promise used to return the result.|

**Example**

```
updater.checkNewVersion().then(result => {
  console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`);
  // Version digest information
  console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`);
}).catch(err => {
  console.log(`checkNewVersion promise error ${JSON.stringify(err)}`);
});
```

W
wusongqing 已提交
162 163 164 165
###  getNewVersionInfo

getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void

S
shawn_he 已提交
166
Obtains information about the new version. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
167

S
shawn_he 已提交
168
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
169

S
shawn_he 已提交
170 171
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
172 173
**Parameters**

S
shawn_he 已提交
174 175 176
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes   | Callback used to return the result.|
W
wusongqing 已提交
177 178 179 180

**Example**

```
S
shawn_he 已提交
181 182 183
updater.getNewVersionInfo((err, info) => {
  console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
  console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`);
S
shawn_he 已提交
184
});
W
wusongqing 已提交
185 186 187 188 189 190
```

### getNewVersionInfo

getNewVersionInfo(): Promise\<NewVersionInfo>

S
shawn_he 已提交
191
Obtains information about the new version. This API uses a promise to return the result.
W
wusongqing 已提交
192

S
shawn_he 已提交
193
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
194

S
shawn_he 已提交
195 196
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

S
shawn_he 已提交
197
**Return value**
S
shawn_he 已提交
198

S
shawn_he 已提交
199 200 201
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
W
wusongqing 已提交
202 203 204 205

**Example**

```
S
shawn_he 已提交
206 207 208
updater.getNewVersionInfo().then(info => {
  console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
  console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`);
S
shawn_he 已提交
209
}).catch(err => {
S
shawn_he 已提交
210
  console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`);
S
shawn_he 已提交
211
});
W
wusongqing 已提交
212 213
```

S
shawn_he 已提交
214
###  getNewVersionDescription
W
wusongqing 已提交
215

S
shawn_he 已提交
216
getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
W
wusongqing 已提交
217

S
shawn_he 已提交
218
Obtains the description file of the new version. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
219

S
shawn_he 已提交
220
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
221

S
shawn_he 已提交
222 223
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
224 225
**Parameters**

S
shawn_he 已提交
226 227 228 229 230
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|
| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes   | Callback used to return the result.|
W
wusongqing 已提交
231 232 233 234

**Example**

```
S
shawn_he 已提交
235 236 237 238 239 240 241 242 243 244 245 246 247 248
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options of the description file
var descriptionOptions = {
  format: DescriptionFormat.STANDARD, // Standard format
  language: "zh-cn" // Chinese
}

updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => {
  console.log(`getNewVersionDescription info ${JSON.stringify(info)}`);
  console.log(`getNewVersionDescription err ${JSON.stringify(err)}`);
S
shawn_he 已提交
249
});
W
wusongqing 已提交
250 251
```

S
shawn_he 已提交
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
### getNewVersionDescription

getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>;

Obtains the description file of the new version. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
276

S
shawn_he 已提交
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
```
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options of the description file
var descriptionOptions = {
  format: DescriptionFormat.STANDARD, // Standard format
  language: "zh-cn" // Chinese
}

updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => {
  console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
}).catch(err => {
  console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
});
```

###  getCurrentVersionInfo

getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void

Obtains information about the current version. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**
W
wusongqing 已提交
307

S
shawn_he 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes   | Callback used to return the result.|

**Example**

```
updater.getCurrentVersionInfo((err, info) => {
  console.log(`info osVersion = ${info?.osVersion}`);
  console.log(`info deviceName = ${info?.deviceName}`);
  console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
});
```

### getCurrentVersionInfo

getCurrentVersionInfo(): Promise\<CurrentVersionInfo>

Obtains information about the current version. This API uses a promise to return the result.
S
shawn_he 已提交
327

S
shawn_he 已提交
328
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
329

S
shawn_he 已提交
330 331
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

S
shawn_he 已提交
332
**Return value**
W
wusongqing 已提交
333

S
shawn_he 已提交
334 335 336
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.|
W
wusongqing 已提交
337 338 339 340

**Example**

```
S
shawn_he 已提交
341 342 343 344
updater.getCurrentVersionInfo().then(info => {
  console.log(`info osVersion = ${info.osVersion}`);
  console.log(`info deviceName = ${info.deviceName}`);
  console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
S
shawn_he 已提交
345
}).catch(err => {
S
shawn_he 已提交
346
  console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`);
S
shawn_he 已提交
347
});
W
wusongqing 已提交
348 349
```

S
shawn_he 已提交
350
###  getCurrentVersionDescription
W
wusongqing 已提交
351

S
shawn_he 已提交
352
getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
W
wusongqing 已提交
353

S
shawn_he 已提交
354
Obtains the description file of the current version. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
355

S
shawn_he 已提交
356
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
357

S
shawn_he 已提交
358 359
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
360 361
**Parameters**

S
shawn_he 已提交
362 363 364 365
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|
| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes   | Callback used to return the result.|
W
wusongqing 已提交
366 367 368 369

**Example**

```
S
shawn_he 已提交
370 371 372 373 374 375 376 377 378
// Options of the description file
var descriptionOptions = {
  format: DescriptionFormat.STANDARD, // Standard format
  language: "zh-cn" // Chinese
}

updater.getCurrentVersionDescription(descriptionOptions, (err, info) => {
  console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`);
  console.log(`getCurrentVersionDescription err ${JSON.stringify(err)}`);
W
wusongqing 已提交
379 380 381
});
```

S
shawn_he 已提交
382
### getCurrentVersionDescription
W
wusongqing 已提交
383

S
shawn_he 已提交
384
getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>
W
wusongqing 已提交
385

S
shawn_he 已提交
386
Obtains the description file of the current version. This API uses a promise to return the result.
W
wusongqing 已提交
387

S
shawn_he 已提交
388
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
389

S
shawn_he 已提交
390 391 392 393 394 395 396 397
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|

S
shawn_he 已提交
398
**Return value**
S
shawn_he 已提交
399

S
shawn_he 已提交
400 401 402
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
W
wusongqing 已提交
403 404 405 406

**Example**

```
S
shawn_he 已提交
407 408 409 410 411 412 413 414
// Options of the description file
var descriptionOptions = {
  format: DescriptionFormat.STANDARD, // Standard format
  language: "zh-cn" // Chinese
}

updater.getCurrentVersionDescription(descriptionOptions).then(info => {
  console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
S
shawn_he 已提交
415
}).catch(err => {
S
shawn_he 已提交
416
  console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`);
W
wusongqing 已提交
417 418 419
});
```

S
shawn_he 已提交
420
###  getTaskInfo
W
wusongqing 已提交
421

S
shawn_he 已提交
422
getTaskInfo(callback: AsyncCallback\<TaskInfo>): void
W
wusongqing 已提交
423

S
shawn_he 已提交
424
Obtains information about the update task. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
425

S
shawn_he 已提交
426
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
427

S
shawn_he 已提交
428 429
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
430 431
**Parameters**

S
shawn_he 已提交
432 433 434
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes   | Callback used to return the result.|
W
wusongqing 已提交
435 436 437 438

**Example**

```
S
shawn_he 已提交
439 440
updater.getTaskInfo((err, info) => {
  console.log(`getTaskInfo isexistTask= ${info?.existTask}`);
W
wusongqing 已提交
441 442 443
});
```

S
shawn_he 已提交
444
### getTaskInfo
W
wusongqing 已提交
445

S
shawn_he 已提交
446
getTaskInfo(): Promise\<TaskInfo>
W
wusongqing 已提交
447

S
shawn_he 已提交
448
Obtains information about the update task. This API uses a promise to return the result.
W
wusongqing 已提交
449

S
shawn_he 已提交
450
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
451

S
shawn_he 已提交
452 453
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

S
shawn_he 已提交
454
**Return value**
S
shawn_he 已提交
455

S
shawn_he 已提交
456 457 458
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.|
W
wusongqing 已提交
459 460 461 462

**Example**

```
S
shawn_he 已提交
463 464
updater.getTaskInfo().then(info => {
  console.log(`getTaskInfo isexistTask= ${info.existTask}`);
S
shawn_he 已提交
465
}).catch(err => {
S
shawn_he 已提交
466
  console.log(`getTaskInfo promise error ${JSON.stringify(err)}`);
W
wusongqing 已提交
467 468 469
});
```

S
shawn_he 已提交
470
###  download
W
wusongqing 已提交
471

S
shawn_he 已提交
472
download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
473

S
shawn_he 已提交
474
Downloads the new version. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
475

S
shawn_he 已提交
476
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
477

S
shawn_he 已提交
478 479
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
480 481
**Parameters**

S
shawn_he 已提交
482 483 484 485 486
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| downloadOptions | [DownloadOptions](#downloadoptions) | Yes   | Download options.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
W
wusongqing 已提交
487 488 489 490

**Example**

```
S
shawn_he 已提交
491 492 493 494 495 496 497 498 499 500 501 502
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Download options
var downloadOptions = {
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
  order: update.Order.DOWNLOAD // Download
}
updater.download(versionDigestInfo, downloadOptions, (err) => {
  console.log(`download error ${JSON.stringify(err)}`);
W
wusongqing 已提交
503 504 505 506 507
});
```

### download

S
shawn_he 已提交
508
download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions): Promise\<void>
W
wusongqing 已提交
509

S
shawn_he 已提交
510
Downloads the new version. This API uses a promise to return the result.
W
wusongqing 已提交
511

S
shawn_he 已提交
512
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
513

S
shawn_he 已提交
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| downloadOptions | [DownloadOptions](#downloadoptions) | Yes   | Download options.|

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

W
wusongqing 已提交
529 530 531
**Example**

```
S
shawn_he 已提交
532 533 534 535 536 537 538 539 540 541 542 543 544 545
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Download options
var downloadOptions = {
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
  order: update.Order.DOWNLOAD // Download
}
updater.download(versionDigestInfo, downloadOptions).then(() => {
  console.log(`download start`);
}).catch(err => {
  console.log(`download error ${JSON.stringify(err)}`);
S
shawn_he 已提交
546
});
W
wusongqing 已提交
547 548
```

S
shawn_he 已提交
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
###  resumeDownload

resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback\<void>): void

Resumes download of the new version. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Example**

```
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for resuming download
var resumeDownloadOptions = {
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
}
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => {
  console.log(`resumeDownload error ${JSON.stringify(err)}`);
});
```
W
wusongqing 已提交
583

S
shawn_he 已提交
584
### resumeDownload
W
wusongqing 已提交
585

S
shawn_he 已提交
586 587 588
resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void>

Resumes download of the new version. This API uses a promise to return the result.
W
wusongqing 已提交
589

S
shawn_he 已提交
590
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
591

S
shawn_he 已提交
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.|

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

W
wusongqing 已提交
607 608 609
**Example**

```
S
shawn_he 已提交
610 611 612 613 614 615 616 617 618 619 620 621 622
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for resuming download
var resumeDownloadOptions = {
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
}
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => {
  console.log(`resumeDownload start`);
}).catch(err => {
  console.log(`resumeDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
623
});
W
wusongqing 已提交
624 625
```

S
shawn_he 已提交
626
###  pauseDownload
W
wusongqing 已提交
627

S
shawn_he 已提交
628
pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
629

S
shawn_he 已提交
630
Pauses download of the new version. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
631

S
shawn_he 已提交
632
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
633

S
shawn_he 已提交
634 635
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
636 637
**Parameters**

S
shawn_he 已提交
638 639 640 641 642
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
W
wusongqing 已提交
643 644 645 646

**Example**

```
S
shawn_he 已提交
647 648 649 650 651 652 653 654
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for pausing download
var pauseDownloadOptions = {
  isAllowAutoResume: true // Whether to allow automatic resuming of download
W
wusongqing 已提交
655
}
S
shawn_he 已提交
656 657
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => {
  console.log(`pauseDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
658
});
W
wusongqing 已提交
659 660
```

S
shawn_he 已提交
661
### pauseDownload
W
wusongqing 已提交
662

S
shawn_he 已提交
663
pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise\<void>
W
wusongqing 已提交
664

S
shawn_he 已提交
665
Resumes download of the new version. This API uses a promise to return the result.
S
shawn_he 已提交
666

S
shawn_he 已提交
667
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
668

S
shawn_he 已提交
669 670
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
671 672
**Parameters**

S
shawn_he 已提交
673 674 675 676
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.|
W
wusongqing 已提交
677

S
shawn_he 已提交
678
**Return value**
W
wusongqing 已提交
679

S
shawn_he 已提交
680 681 682
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|
W
wusongqing 已提交
683 684 685 686

**Example**

```
S
shawn_he 已提交
687 688 689 690 691 692 693 694
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for pausing download
var pauseDownloadOptions = {
  isAllowAutoResume: true // Whether to allow automatic resuming of download
W
wusongqing 已提交
695
}
S
shawn_he 已提交
696 697 698 699
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => {
  console.log(`pauseDownload`);
}).catch(err => {
  console.log(`pauseDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
700
});
W
wusongqing 已提交
701 702
```

S
shawn_he 已提交
703
###  upgrade
W
wusongqing 已提交
704

S
shawn_he 已提交
705
upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
706

S
shawn_he 已提交
707
Updates the version. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
708

S
shawn_he 已提交
709
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
710

S
shawn_he 已提交
711 712
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

W
wusongqing 已提交
713 714
**Parameters**

S
shawn_he 已提交
715 716 717 718 719
| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes   | Update options.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
W
wusongqing 已提交
720 721 722 723

**Example**

```
S
shawn_he 已提交
724 725 726 727 728 729 730 731 732 733 734
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Installation options
var upgradeOptions = {
  order: update.Order.INSTALL // Installation command
}
updater.upgrade(versionDigestInfo, upgradeOptions, (err) => {
  console.log(`upgrade error ${JSON.stringify(err)}`);
S
shawn_he 已提交
735
});
W
wusongqing 已提交
736 737
```

S
shawn_he 已提交
738
### upgrade
W
wusongqing 已提交
739

S
shawn_he 已提交
740
upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): Promise\<void>
W
wusongqing 已提交
741

S
shawn_he 已提交
742
Updates the version. This API uses a promise to return the result.
W
wusongqing 已提交
743

S
shawn_he 已提交
744
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
745

S
shawn_he 已提交
746 747 748 749 750 751 752 753 754
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes   | Update options.|

S
shawn_he 已提交
755
**Return value**
S
shawn_he 已提交
756

S
shawn_he 已提交
757 758 759
| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|
W
wusongqing 已提交
760 761 762 763

**Example**

```
S
shawn_he 已提交
764 765 766 767 768 769 770 771 772 773 774
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Installation options
var upgradeOptions = {
  order: update.Order.INSTALL // Installation command
}
updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
  console.log(`upgrade start`);
S
shawn_he 已提交
775
}).catch(err => {
S
shawn_he 已提交
776
  console.log(`upgrade error ${JSON.stringify(err)}`);
S
shawn_he 已提交
777
});
W
wusongqing 已提交
778 779
```

S
shawn_he 已提交
780 781 782
###  clearError

clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
783

S
shawn_he 已提交
784
Clears errors. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
785

S
shawn_he 已提交
786 787
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| clearOptions | [ClearOptions](#clearoptions) | Yes   | Clear options.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Example**

```
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for clearing errors
var clearOptions = {
  status: update.UpgradeStatus.UPGRADE_FAIL,
}
updater.clearError(versionDigestInfo, clearOptions, (err) => {
  console.log(`clearError error ${JSON.stringify(err)}`);
});
```
W
wusongqing 已提交
814

S
shawn_he 已提交
815
### clearError
W
wusongqing 已提交
816

S
shawn_he 已提交
817 818 819
clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void>

Clears errors. This API uses a promise to return the result.
W
wusongqing 已提交
820

S
shawn_he 已提交
821 822
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
| clearOptions | [ClearOptions](#clearoptions) | Yes   | Update options.|

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

**Example**

```
// Version digest information
var versionDigestInfo = {
  versionDigest: "versionDigest" // Version digest information in the check result
}

// Options for clearing errors
var clearOptions = {
  status: update.UpgradeStatus.UPGRADE_FAIL,
}
updater.clearError(versionDigestInfo, clearOptions).then(() => {
  console.log(`clearError success`);
}).catch(err => {
  console.log(`clearError error ${JSON.stringify(err)}`);
});
```

### getUpgradePolicy
W
wusongqing 已提交
858

S
shawn_he 已提交
859
getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void
W
wusongqing 已提交
860

S
shawn_he 已提交
861
Obtains the update policy. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
862

S
shawn_he 已提交
863 864
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description        |
| -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes   | Callback used to return the result.|

**Example**

```
updater.getUpgradePolicy((err, policy) => {
  console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`);
  console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`);
});
```

### getUpgradePolicy
W
wusongqing 已提交
883

S
shawn_he 已提交
884
getUpgradePolicy(): Promise\<UpgradePolicy>
W
wusongqing 已提交
885

S
shawn_he 已提交
886
Obtains the update policy. This API uses a promise to return the result.
W
wusongqing 已提交
887

S
shawn_he 已提交
888 889
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Return value**

| Type                                     | Description               |
| --------------------------------------- | ----------------- |
| Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.|

**Example**

```
updater.getUpgradePolicy().then(policy => {
  console.log(`policy downloadStrategy = ${policy.downloadStrategy}`);
  console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`);
}).catch(err => {
  console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`);
});
```
W
wusongqing 已提交
908

S
shawn_he 已提交
909
### setUpgradePolicy
W
wusongqing 已提交
910

S
shawn_he 已提交
911 912 913
setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void

Sets the update policy. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
914

S
shawn_he 已提交
915 916
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
917
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
W
wusongqing 已提交
918

S
shawn_he 已提交
919 920 921 922 923 924
**Parameters**

| Name     | Type                                      | Mandatory  | Description        |
| -------- | ---------------------------------------- | ---- | ---------- |
| policy | [UpgradePolicy](#upgradepolicy) | Yes   | Update policy.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result.|
W
wusongqing 已提交
925

S
shawn_he 已提交
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
**Example**

```
let policy = {
  downloadStrategy: false,
  autoUpgradeStrategy: false,
  autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
}
updater.setUpgradePolicy(policy, (err) => {
  console.log(`setUpgradePolicy result: ${err}`);
});
```

### setUpgradePolicy

setUpgradePolicy(policy: UpgradePolicy): Promise\<void>

Sets the update policy. This API uses a promise to return the result.
W
wusongqing 已提交
944

S
shawn_he 已提交
945 946
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
947
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
W
wusongqing 已提交
948

S
shawn_he 已提交
949 950 951 952 953 954 955 956 957 958 959
**Parameters**

| Name   | Type                           | Mandatory  | Description    |
| ------ | ----------------------------- | ---- | ------ |
| policy | [UpgradePolicy](#upgradepolicy) | Yes   | Update policy.|

**Return value**

| Type              | Description             |
| ---------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
W
wusongqing 已提交
960

S
shawn_he 已提交
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
**Example**

```
let policy = {
  downloadStrategy: false,
  autoUpgradeStrategy: false,
  autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
}
updater.setUpgradePolicy(policy).then(() => {
  console.log(`setUpgradePolicy success`);
}).catch(err => {
  console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`);
});
```

###  terminateUpgrade

terminateUpgrade(callback: AsyncCallback\<void>): void

Terminates the update. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
981

S
shawn_he 已提交
982 983
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
984
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
W
wusongqing 已提交
985

S
shawn_he 已提交
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Example**

```
updater.terminateUpgrade((err) => {
  console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
});
```

### terminateUpgrade

terminateUpgrade(): Promise\<void>

Terminates the update. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

**Example**

```
updater.terminateUpgrade().then(() => {
  console.log(`terminateUpgrade success`);
}).catch(err => {
  console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
});
```


### on
on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void

Enables listening for update events. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes   | Event information.|
| taskCallback |  [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|

**Example**

```
var eventClassifyInfo = {
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
}

updater.on(eventClassifyInfo, (eventInfo) => {
  console.log("updater on " + JSON.stringify(eventInfo));
});
```

### off
off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void

Disables listening for update events. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes   | Event information.|
| taskCallback |  [UpgradeTaskCallback](#upgradetaskcallback) | No   | Event callback.|

**Example**

```
var eventClassifyInfo = {
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
}

updater.off(eventClassifyInfo, (eventInfo) => {
  console.log("updater off " + JSON.stringify(eventInfo));
});
```

## Restorer

### factoryReset

factoryReset(callback: AsyncCallback\<void>): void

Restores factory settings. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.FACTORY_RESET (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Example**

```
restorer.factoryReset((err) => {
  console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```

### factoryReset

factoryReset(): Promise\<void>

Restores factory settings. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.FACTORY_RESET (a system permission)

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

**Example**

```
restorer.factoryReset().then(() => {
  console.log(`factoryReset success`);
}).catch(err => {
  console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```

## LocalUpdater

### verifyUpgradePackage

verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<void>): void

Verifies the update package. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| upgradeFile | [UpgradeFile](#upgradefile) | Yes   | Update file.|
| certsFile | string | Yes   | Path of the certificate file.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result.|

**Example**

```
var upgradeFile = {
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
}

localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => {
  console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```

### verifyUpgradePackage

verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void>

Verifies the update package. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| upgradeFile | [UpgradeFile](#upgradefile) | Yes   | Update file.|
| certsFile | string | Yes   | Path of the certificate file.|

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```
var upgradeFile = {
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
}
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => {
  console.log(`verifyUpgradePackage success`);
}).catch(err => {
  console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`);
});
```

### applyNewVersion
applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: AsyncCallback\<void>): void

Installs the update package. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes   | Update file.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Example**

```
var upgradeFiles = [{
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
}]

localUpdater.applyNewVersion(upgradeFiles, (err) => {
  console.log(`applyNewVersion error ${JSON.stringify(err)}`);
});
```

### applyNewVersion

applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void>

Installs the update package. This API uses a promise to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Return value**

| Type                                      | Description              |
| ---------------------------------------- | ---------------- |
| Promise\<void> | Promise that returns no value.|

**Example**

```
var upgradeFiles = [{
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
}]
localUpdater.applyNewVersion(upgradeFiles).then(() => {
  console.log(`applyNewVersion success`);
}).catch(err => {
  console.log(`applyNewVersion error ${JSON.stringify(err)}`);
});
```

### on
on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void

Enables listening for update events. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes   | Event information.|
| taskCallback |  [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|

**Example**

```
var eventClassifyInfo = {
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
}

function onTaskUpdate(eventInfo) {
  console.log(`on eventInfo id `, eventInfo.eventId);
}

localUpdater.on(eventClassifyInfo, onTaskUpdate);
```

### off
off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void

Disables listening for update events. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Update.UpdateService

**Parameters**

| Name     | Type                                      | Mandatory  | Description       |
| -------- | ---------------------------------------- | ---- | --------- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes   | Event information.|
| taskCallback |  [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|

**Example**

```
var eventClassifyInfo = {
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
}

function onTaskUpdate(eventInfo) {
  console.log(`on eventInfo id `, eventInfo.eventId);
}

localUpdater.off(eventClassifyInfo, onTaskUpdate);
```

## UpgradeInfo

Represents update information.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| upgradeApp          | string                      | Yes   | Application package name. |
| businessType        | [BusinessType](#businesstype) | Yes   | Update service type.   |

## BusinessType

Enumerates update service types.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| vendor              | [BusinessVendor](#businessvendor)   | Yes   | Application vendor. |
| subType             | [BusinessSubType](#businesssubtype) | Yes   | Update service sub-type.   |

## CheckResult

Represents the package check result.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| isExistNewVersion              | bool   | Yes   | Whether a new version is available. |
| newVersionInfo             | [NewVersionInfo](#newversioninfo) | No   | Information about the new version.   |

## NewVersionInfo

Represents information about the new version.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| versionDigestInfo              | [VersionDigestInfo](#versiondigestinfo)   | Yes   | Version digest information. |
| versionComponents             | Array\<[VersionComponent](#versioncomponent)>  | Yes   | Version components.   |

## VersionDigestInfo

Represents version digest information.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| versionDigest              | string   | Yes   | Version digest information. |

## VersionComponent

Represents a version component.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| componentId              | number   | Yes   | Component ID. |
| componentType              | [ComponentType](#componentyype)   | Yes   | Component type. |
| upgradeAction              | [UpgradeAction](#upgradeaction)   | Yes   | Update mode. |
| displayVersion              | string   | Yes   | Display version number. |
| innerVersion              | string   | Yes   | Internal version number. |
| size              | number   | Yes   | Update package size. |
| effectiveMode              | [EffectiveMode](#effectivemode)   | Yes   | Effective mode. |
| descriptionInfo              | [DescriptionInfo](#descriptioninfo)   | Yes   | Information about the version description file. |

## DescriptionOptions

Represents options of the description file.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| format              | [DescriptionFormat](#descriptionformat)   | Yes   | Format of the description file. |
| language              |  string  | Yes   | Language of the description file. |

## ComponentDescription

Represents a component description file.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| componentId              |  string  | Yes   | Component ID. |
| descriptionInfo              |  [DescriptionInfo](#descriptioninfo)  | Yes   | Information about the description file. |

## DescriptionInfo

Represents information about the version description file.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| descriptionType              | [DescriptionType](#descriptiontype)   | Yes   | Type of the description file. |
| content              |  string  | Yes   | Content of the description file. |

## CurrentVersionInfo

Represents information about the current version.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| osVersion              | string   | Yes   | System version number. |
| deviceName              | string   | Yes   | Device name. |
| versionComponents              | Array\<[VersionComponent](#vesioncomponent)>   | No   | Version components. |

## DownloadOptions

Represents download options.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| allowNetwork              | [NetType](#nettype)   | Yes   | Network type. |
| order              | [Order](#order)   | Yes   | Update command. |

## ResumeDownloadOptions

Represents options for resuming download.

**System capability**: SystemCapability.Update.UpdateService

| Parameter                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| allowNetwork              | [NetType](#nettype)   | Yes   | Network type. |

## PauseDownloadOptions

Represents options for pausing download.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| isAllowAutoResume              | bool   | Yes   | Whether to allow automatic resuming of download. |

## UpgradeOptions

Represents update options.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| order              | [Order](#order)   | Yes   | Update command. |

## ClearOptions

Represents options for clearing errors.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| status              | [UpgradeStatus](#upgradestatus)   | Yes   | Error status. |

## UpgradePolicy

Represents an update policy.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| downloadStrategy        | bool                        | Yes   | Automatic download policy. |
| autoUpgradeStrategy         | bool | Yes   | Automatic update policy.   |
| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)>              | Yes   | Automatic update period.|

## UpgradePeriod

Represents a period for automatic update.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| start        | number                        | Yes   | Start time. |
| end         | number | Yes   | End time.   |

## TaskInfo

Represents task information.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| existTask        | bool                        | Yes   | Whether a task exists. |
| taskBody         | [TaskBody](#taskinfo) | Yes   | Task data.   |

## EventInfo

Represents event information.

**System capability**: SystemCapability.Update.UpdateService

| Parameter                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| eventId        |   [EventId](#eventid)    | Yes   | Event ID. |
| taskBody         | [TaskBody](#taskinfo) | Yes   | Task data.   |

## TaskBody

Represents task data.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| versionDigestInfo        |   [VersionDigestInfo](#versiondigestinfo)    | Yes   | Version digest information. |
| status         | [UpgradeStatus](#upgradestatus) | Yes   | Update status.   |
| subStatus         | number | No   | Sub-status.   |
| progress         | number | Yes   | Progress.   |
| installMode         | number | Yes   | Installation mode.   |
| errorMessages         |  Array\<[ErrorMessage](#errormessage)>  | No   | Error message.   |
| versionComponents         | Array\<[VersionComponent](#versioncomponent)> | Yes   | Version components.   |

## ErrorMessage

Represents an error message.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| errorCode        |   number   | Yes   | Error code. |
| errorMessage         | string | Yes   | Error description.   |

## EventClassifyInfo

Represents event type information.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| eventClassify        |   [EventClassify](#eventclassify)   | Yes   | Event type. |
| extraInfo         | string | Yes   | Additional information.   |

## UpgradeFile

Represents an update file.

**System capability**: SystemCapability.Update.UpdateService

| Name                 | Type                       | Mandatory  | Description     |
| ------------------- | --------------------------- | ---- | ------- |
| fileType        |   [ComponentType](#componenttype)   | Yes   | File type. |
| filePath         | string | Yes   | File path.   |

## UpgradeTaskCallback

### (eventInfo: [EventInfo](#eventinfo)): void

Event callback.

**System capability**: SystemCapability.Update.UpdateService

| Parameter             | Type                                    | Mandatory  | Description  |
| --------------- | ---------------------------------------- | ---- | ---- |
| eventInfo          | [EventInfo](#eventinfo)     | Yes   | Event information.|

## BusinessVendor

Device vendor.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| PUBLIC   | "public" | Open source. |

## BusinessSubType

Represents an update type.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| FIRMWARE   | 1 | Firmware. |

## ComponentType

Represents a component type.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| OTA   | 1 | Firmware. |

## UpgradeAction

Represents an update mode.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| UPGRADE   | "upgrade" | Differential package. |
| RECOVERY   | "recovery" | Recovery package. |

## EffectiveMode

Represents an effective mode.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| COLD   | 1 | Cold update. |
| LIVE   | 2 | Live update. |
| LIVE_AND_COLD   | 3 | Hybrid live and cold update. |

## DescriptionType

Represents a description file type.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| CONTENT   | 0 | Content. |
| URI   | 1 | Link. |

## DescriptionFormat

Represents a description file format.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| STANDARD   | 0 | Standard format. |
| SIMPLIFIED   | 1 | Simple format. |

## NetType

Enumerates network types.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| CELLULAR   | 1 | Data network. |
| METERED_WIFI   | 2 | Wi-Fi hotspot. |
| NOT_METERED_WIFI   | 4 | Non Wi-Fi hotspot. |
| WIFI   | 6 | WIFI  |
| CELLULAR_AND_WIFI   | 7 | Data network and Wi-Fi. |

## Order

Represents an update command.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| DOWNLOAD   | 1 | Download. |
| INSTALL   | 2 | Install. |
| DOWNLOAD_AND_INSTALL   | 3 | Download and install. |
| APPLY   | 4 | Apply. |
| INSTALL_AND_APPLY   | 6 | Install and apply. |

## UpgradeStatus

Enumerates update states.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| WAITING_DOWNLOAD   | 20 | Waiting for download. |
| DOWNLOADING   | 21 | Downloading. |
| DOWNLOAD_PAUSED   | 22 | Download paused. |
| DOWNLOAD_FAIL   | 23 | Download failed. |
| WAITING_INSTALL   | 30 | Waiting for installation. |
| UPDATING   | 31 | Updating. |
| WAITING_APPLY   | 40 | Waiting for applying the update. |
| APPLYING   | 21 | Applying the update. |
| UPGRADE_SUCCESS   | 50 | Update succeeded. |
| UPGRADE_FAIL   | 51 | Update failed. |

## EventClassify

Represents an event type.

**System capability**: SystemCapability.Update.UpdateService

| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| TASK   | 0x01000000 | Task event. |

## EventId
W
wusongqing 已提交
1726

S
shawn_he 已提交
1727
Enumerates event IDs.
W
wusongqing 已提交
1728

S
shawn_he 已提交
1729 1730
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749
| Name                | Default Value | Description      |
| ------------------- | ---- | -------- |
| EVENT_TASK_BASE   | 0x01000000 | Indicates a task event. |
| EVENT_TASK_RECEIVE   | 0x01000001 | Indicates that a task is received. |
| EVENT_TASK_CANCEL   | 0x01000010 | Indicates that a task is cancelled. |
| EVENT_DOWNLOAD_WAIT   | 0x01000011 | Indicates the state of waiting for the download. |
| EVENT_DOWNLOAD_START   | 0x01000100 | Indicates that the download starts. |
| EVENT_DOWNLOAD_UPDATE   | 0x01000101 | Indicates the download progress update. |
| EVENT_DOWNLOAD_PAUSE   | 0x01000110 | Indicates that the download is paused. |
| EVENT_DOWNLOAD_RESUME   | 0x01000111 | Indicates that the download is resumed. |
| EVENT_DOWNLOAD_SUCCESS   | 0x01001000 | Indicates that the download succeeded. |
| EVENT_DOWNLOAD_FAIL   | 0x01001001 | Indicates that the download failed. |
| EVENT_UPGRADE_WAIT   | 0x01001010 | Indicates the state of waiting for the update. |
| EVENT_UPGRADE_START   | 0x01001011 | Indicates that the update starts. |
| EVENT_UPGRADE_UPDATE   | 0x01001100 | Indicates that the update is in progress. |
| EVENT_APPLY_WAIT   | 0x01001101 | Indicates the state of waiting for applying the update. |
| EVENT_APPLY_START   | 0x01001110 | Indicates the state of applying the update. |
| EVENT_UPGRADE_SUCCESS   | 0x01001111 | Indicates that the update succeeded. |
| EVENT_UPGRADE_FAIL   | 0x01010000 | Indicates that the update failed. |