js-apis-update.md 71.8 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.update
W
wusongqing 已提交
2

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
> **NOTE**
S
shawn_he 已提交
11 12
> - 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.
S
shawn_he 已提交
13

W
wusongqing 已提交
14 15 16
## Modules to Import

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

S
shawn_he 已提交
20
## update.getOnlineUpdater
S
shawn_he 已提交
21

S
shawn_he 已提交
22
getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
S
shawn_he 已提交
23

S
shawn_he 已提交
24
Obtains an **OnlineUpdater** object.
S
shawn_he 已提交
25

S
shawn_he 已提交
26
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
27 28 29

**Parameters**

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

S
shawn_he 已提交
34
**Return value**
S
shawn_he 已提交
35

S
shawn_he 已提交
36 37 38
| Type                 | Description  |
| ------------------- | ---- |
| [Updater](#updater) | **OnlineUpdater** object.|
S
shawn_he 已提交
39

S
shawn_he 已提交
40 41 42 43 44 45 46 47
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
48 49
**Example**

S
shawn_he 已提交
50
```ts
S
shawn_he 已提交
51
try {
S
shawn_he 已提交
52
  const upgradeInfo = {
S
shawn_he 已提交
53 54 55 56 57
    upgradeApp: "com.ohos.ota.updateclient",
    businessType: {
      vendor: update.BusinessVendor.PUBLIC,
      subType: update.BusinessSubType.FIRMWARE
    }
S
shawn_he 已提交
58
  };
S
shawn_he 已提交
59
  let updater = update.getOnlineUpdater(upgradeInfo);
S
shawn_he 已提交
60
} catch(error) {
S
shawn_he 已提交
61
  console.error(`Fail to get updater error: ${error}`);
S
shawn_he 已提交
62 63 64
}
```

S
shawn_he 已提交
65
## update.getRestorer
S
shawn_he 已提交
66

S
shawn_he 已提交
67
getRestorer(): Restorer
S
shawn_he 已提交
68

S
shawn_he 已提交
69
Obtains a **Restorer** object for restoring factory settings.
S
shawn_he 已提交
70

S
shawn_he 已提交
71
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
72 73


S
shawn_he 已提交
74
**Return value**
S
shawn_he 已提交
75

S
shawn_he 已提交
76 77
| Type                   | Description    |
| --------------------- | ------ |
S
shawn_he 已提交
78
| [Restorer](#restorer) | **Restorer** object for restoring factory settings.|
S
shawn_he 已提交
79

S
shawn_he 已提交
80 81 82 83 84 85 86 87
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
88 89
**Example**

S
shawn_he 已提交
90
```ts
S
shawn_he 已提交
91
try {
S
shawn_he 已提交
92
  let restorer = update.getRestorer();
S
shawn_he 已提交
93
} catch(error) {
S
shawn_he 已提交
94
  console.error(`Fail to get restorer: ${error}`);
S
shawn_he 已提交
95 96 97
}
```

S
shawn_he 已提交
98
## update.getLocalUpdater
S
shawn_he 已提交
99

S
shawn_he 已提交
100
getLocalUpdater(): LocalUpdater
S
shawn_he 已提交
101

S
shawn_he 已提交
102
Obtains a **LocalUpdater** object.
S
shawn_he 已提交
103

S
shawn_he 已提交
104
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
105

S
shawn_he 已提交
106
**Return value**
S
shawn_he 已提交
107

S
shawn_he 已提交
108 109
| Type                           | Description    |
| ----------------------------- | ------ |
S
shawn_he 已提交
110
| [LocalUpdater](#localupdater) | **LocalUpdater** object.|
S
shawn_he 已提交
111

S
shawn_he 已提交
112 113 114 115 116 117 118 119
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
120 121
**Example**

S
shawn_he 已提交
122
```ts
S
shawn_he 已提交
123
try {
S
shawn_he 已提交
124
  let localUpdater = update.getLocalUpdater();
S
shawn_he 已提交
125
} catch(error) {
S
shawn_he 已提交
126
  console.error(`Fail to get localUpdater error: ${error}`);
S
shawn_he 已提交
127
};
S
shawn_he 已提交
128 129
```

W
wusongqing 已提交
130 131
## Updater

S
shawn_he 已提交
132 133 134 135 136 137 138 139 140 141 142 143
### 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**

S
shawn_he 已提交
144 145
| Name     | Type                                      | Mandatory  | Description            |
| -------- | ---------------------------------------- | ---- | -------------- |
S
shawn_he 已提交
146 147
| callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes   | Callback used to return the result.|

S
shawn_he 已提交
148 149 150 151 152 153 154 155
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
156 157
**Example**

S
shawn_he 已提交
158
```ts
S
shawn_he 已提交
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
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**

S
shawn_he 已提交
176 177
| Type                                   | Description                 |
| ------------------------------------- | ------------------- |
S
shawn_he 已提交
178 179
| Promise\<[CheckResult](#checkresult)> | Promise used to return the result.|

S
shawn_he 已提交
180 181 182 183 184 185 186 187
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
188 189
**Example**

S
shawn_he 已提交
190
```ts
S
shawn_he 已提交
191 192 193 194 195 196 197 198 199
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 已提交
200 201 202 203
###  getNewVersionInfo

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

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

S
shawn_he 已提交
206
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
207

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

W
wusongqing 已提交
210 211
**Parameters**

S
shawn_he 已提交
212 213
| Name     | Type                                      | Mandatory  | Description             |
| -------- | ---------------------------------------- | ---- | --------------- |
S
shawn_he 已提交
214
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes   | Callback used to return the result.|
W
wusongqing 已提交
215

S
shawn_he 已提交
216 217 218 219 220 221 222 223
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

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

S
shawn_he 已提交
226
```ts
S
shawn_he 已提交
227 228 229
updater.getNewVersionInfo((err, info) => {
  console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
  console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`);
S
shawn_he 已提交
230
});
W
wusongqing 已提交
231 232 233 234 235 236
```

### getNewVersionInfo

getNewVersionInfo(): Promise\<NewVersionInfo>

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

S
shawn_he 已提交
239
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
240

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

S
shawn_he 已提交
243
**Return value**
S
shawn_he 已提交
244

S
shawn_he 已提交
245 246
| Type                                      | Description                  |
| ---------------------------------------- | -------------------- |
S
shawn_he 已提交
247
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
W
wusongqing 已提交
248

S
shawn_he 已提交
249 250 251 252 253 254 255 256
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
257 258
**Example**

S
shawn_he 已提交
259
```ts
S
shawn_he 已提交
260 261 262
updater.getNewVersionInfo().then(info => {
  console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
  console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`);
S
shawn_he 已提交
263
}).catch(err => {
S
shawn_he 已提交
264
  console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`);
S
shawn_he 已提交
265
});
W
wusongqing 已提交
266 267
```

S
shawn_he 已提交
268
###  getNewVersionDescription
W
wusongqing 已提交
269

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

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

S
shawn_he 已提交
274
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
275

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

W
wusongqing 已提交
278 279
**Parameters**

S
shawn_he 已提交
280 281 282
| Name               | Type                                      | Mandatory  | Description            |
| ------------------ | ---------------------------------------- | ---- | -------------- |
| versionDigestInfo  | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.        |
S
shawn_he 已提交
283 284 285 286 287 288 289 290 291 292
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.       |
| callback           | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>> | Yes   | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
W
wusongqing 已提交
293 294 295

**Example**

S
shawn_he 已提交
296
```ts
S
shawn_he 已提交
297
// Version digest information
S
shawn_he 已提交
298
const versionDigestInfo = {
S
shawn_he 已提交
299
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
300
};
S
shawn_he 已提交
301 302

// Options of the description file
S
shawn_he 已提交
303
const descriptionOptions = {
S
shawn_he 已提交
304
  format: update.DescriptionFormat.STANDARD, // Standard format
S
shawn_he 已提交
305
  language: "zh-cn" // Chinese
S
shawn_he 已提交
306
};
S
shawn_he 已提交
307 308 309 310

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

S
shawn_he 已提交
314 315 316 317 318 319 320 321 322 323 324 325
### 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**

S
shawn_he 已提交
326 327 328
| Name               | Type                                      | Mandatory  | Description    |
| ------------------ | ---------------------------------------- | ---- | ------ |
| versionDigestInfo  | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
S
shawn_he 已提交
329 330 331 332
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|

**Return value**

S
shawn_he 已提交
333 334
| Type                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
335 336
| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|

S
shawn_he 已提交
337 338 339 340 341 342 343 344
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
345
**Example**
W
wusongqing 已提交
346

S
shawn_he 已提交
347
```ts
S
shawn_he 已提交
348
// Version digest information
S
shawn_he 已提交
349
const versionDigestInfo = {
S
shawn_he 已提交
350
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
351
};
S
shawn_he 已提交
352 353

// Options of the description file
S
shawn_he 已提交
354
const descriptionOptions = {
S
shawn_he 已提交
355
  format: update.DescriptionFormat.STANDARD, // Standard format
S
shawn_he 已提交
356
  language: "zh-cn" // Chinese
S
shawn_he 已提交
357
};
S
shawn_he 已提交
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376

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 已提交
377

S
shawn_he 已提交
378 379
| Name     | Type                                      | Mandatory  | Description              |
| -------- | ---------------------------------------- | ---- | ---------------- |
S
shawn_he 已提交
380 381
| callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes   | Callback used to return the result.|

S
shawn_he 已提交
382 383 384 385 386 387 388 389
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
390 391
**Example**

S
shawn_he 已提交
392
```ts
S
shawn_he 已提交
393 394 395 396 397 398 399 400 401 402 403 404
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 已提交
405

S
shawn_he 已提交
406
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
407

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

S
shawn_he 已提交
410
**Return value**
W
wusongqing 已提交
411

S
shawn_he 已提交
412 413
| Type                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
414
| Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.|
W
wusongqing 已提交
415

S
shawn_he 已提交
416 417 418 419 420 421 422 423
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
424 425
**Example**

S
shawn_he 已提交
426
```ts
S
shawn_he 已提交
427 428 429 430
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 已提交
431
}).catch(err => {
S
shawn_he 已提交
432
  console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`);
S
shawn_he 已提交
433
});
W
wusongqing 已提交
434 435
```

S
shawn_he 已提交
436
###  getCurrentVersionDescription
W
wusongqing 已提交
437

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

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

S
shawn_he 已提交
442
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
443

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

W
wusongqing 已提交
446 447
**Parameters**

S
shawn_he 已提交
448 449 450
| Name               | Type                                      | Mandatory  | Description             |
| ------------------ | ---------------------------------------- | ---- | --------------- |
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.         |
S
shawn_he 已提交
451 452 453 454 455 456 457 458 459
| callback           | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>> | Yes   | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
W
wusongqing 已提交
460 461 462

**Example**

S
shawn_he 已提交
463
```ts
S
shawn_he 已提交
464
// Options of the description file
S
shawn_he 已提交
465
const descriptionOptions = {
S
shawn_he 已提交
466
  format: update.DescriptionFormat.STANDARD, // Standard format
S
shawn_he 已提交
467
  language: "zh-cn" // Chinese
S
shawn_he 已提交
468
};
S
shawn_he 已提交
469 470 471 472

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

S
shawn_he 已提交
476
### getCurrentVersionDescription
W
wusongqing 已提交
477

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

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

S
shawn_he 已提交
482
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
483

S
shawn_he 已提交
484 485 486 487
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
488 489
| Name               | Type                                      | Mandatory  | Description    |
| ------------------ | ---------------------------------------- | ---- | ------ |
S
shawn_he 已提交
490 491
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|

S
shawn_he 已提交
492
**Return value**
S
shawn_he 已提交
493

S
shawn_he 已提交
494 495
| Type                                      | Description                  |
| ---------------------------------------- | -------------------- |
S
shawn_he 已提交
496
| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
W
wusongqing 已提交
497

S
shawn_he 已提交
498 499 500 501 502 503 504 505
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
506 507
**Example**

S
shawn_he 已提交
508
```ts
S
shawn_he 已提交
509
// Options of the description file
S
shawn_he 已提交
510
const descriptionOptions = {
S
shawn_he 已提交
511
  format: update.DescriptionFormat.STANDARD, // Standard format
S
shawn_he 已提交
512
  language: "zh-cn" // Chinese
S
shawn_he 已提交
513
};
S
shawn_he 已提交
514 515 516

updater.getCurrentVersionDescription(descriptionOptions).then(info => {
  console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
S
shawn_he 已提交
517
}).catch(err => {
S
shawn_he 已提交
518
  console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`);
W
wusongqing 已提交
519 520 521
});
```

S
shawn_he 已提交
522
###  getTaskInfo
W
wusongqing 已提交
523

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

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

S
shawn_he 已提交
528
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
529

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

W
wusongqing 已提交
532 533
**Parameters**

S
shawn_he 已提交
534 535
| Name     | Type                                   | Mandatory  | Description              |
| -------- | ------------------------------------- | ---- | ---------------- |
S
shawn_he 已提交
536
| callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes   | Callback used to return the result.|
W
wusongqing 已提交
537

S
shawn_he 已提交
538 539 540 541 542 543 544 545
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
546 547
**Example**

S
shawn_he 已提交
548
```ts
S
shawn_he 已提交
549 550
updater.getTaskInfo((err, info) => {
  console.log(`getTaskInfo isexistTask= ${info?.existTask}`);
W
wusongqing 已提交
551 552 553
});
```

S
shawn_he 已提交
554
### getTaskInfo
W
wusongqing 已提交
555

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

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

S
shawn_he 已提交
560
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
561

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

S
shawn_he 已提交
564
**Return value**
S
shawn_he 已提交
565

S
shawn_he 已提交
566 567
| Type                             | Description                 |
| ------------------------------- | ------------------- |
S
shawn_he 已提交
568
| Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.|
W
wusongqing 已提交
569

S
shawn_he 已提交
570 571 572 573 574 575 576 577
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
578 579
**Example**

S
shawn_he 已提交
580
```ts
S
shawn_he 已提交
581 582
updater.getTaskInfo().then(info => {
  console.log(`getTaskInfo isexistTask= ${info.existTask}`);
S
shawn_he 已提交
583
}).catch(err => {
S
shawn_he 已提交
584
  console.log(`getTaskInfo promise error ${JSON.stringify(err)}`);
W
wusongqing 已提交
585 586 587
});
```

S
shawn_he 已提交
588
###  download
W
wusongqing 已提交
589

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

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

S
shawn_he 已提交
594
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
595

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

W
wusongqing 已提交
598 599
**Parameters**

S
shawn_he 已提交
600 601 602 603
| Name              | Type                                     | Mandatory  | Description                                |
| ----------------- | --------------------------------------- | ---- | ---------------------------------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                            |
| downloadOptions   | [DownloadOptions](#downloadoptions)     | Yes   | Download options.                              |
S
shawn_he 已提交
604 605 606 607 608 609 610 611 612
| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
W
wusongqing 已提交
613 614 615

**Example**

S
shawn_he 已提交
616
```ts
S
shawn_he 已提交
617
// Version digest information
S
shawn_he 已提交
618
const versionDigestInfo = {
S
shawn_he 已提交
619
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
620
};
S
shawn_he 已提交
621 622

// Download options
S
shawn_he 已提交
623
const downloadOptions = {
S
shawn_he 已提交
624 625
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
  order: update.Order.DOWNLOAD // Download
S
shawn_he 已提交
626
};
S
shawn_he 已提交
627 628
updater.download(versionDigestInfo, downloadOptions, (err) => {
  console.log(`download error ${JSON.stringify(err)}`);
W
wusongqing 已提交
629 630 631 632 633
});
```

### download

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

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

S
shawn_he 已提交
638
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
639

S
shawn_he 已提交
640 641 642 643
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
644 645
| Name              | Type                                     | Mandatory  | Description    |
| ----------------- | --------------------------------------- | ---- | ------ |
S
shawn_he 已提交
646
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
S
shawn_he 已提交
647
| downloadOptions   | [DownloadOptions](#downloadoptions)     | Yes   | Download options.  |
S
shawn_he 已提交
648 649 650

**Return value**

S
shawn_he 已提交
651 652
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
653 654
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
655 656 657 658 659 660 661 662
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
663 664
**Example**

S
shawn_he 已提交
665
```ts
S
shawn_he 已提交
666
// Version digest information
S
shawn_he 已提交
667
const versionDigestInfo = {
S
shawn_he 已提交
668
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
669
};
S
shawn_he 已提交
670 671

// Download options
S
shawn_he 已提交
672
const downloadOptions = {
S
shawn_he 已提交
673 674
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
  order: update.Order.DOWNLOAD // Download
S
shawn_he 已提交
675
};
S
shawn_he 已提交
676 677 678 679
updater.download(versionDigestInfo, downloadOptions).then(() => {
  console.log(`download start`);
}).catch(err => {
  console.log(`download error ${JSON.stringify(err)}`);
S
shawn_he 已提交
680
});
W
wusongqing 已提交
681 682
```

S
shawn_he 已提交
683 684 685 686 687 688 689 690 691 692 693 694
###  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**

S
shawn_he 已提交
695 696 697 698
| Name                  | Type                                      | Mandatory  | Description                                  |
| --------------------- | ---------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo     | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.                              |
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.                              |
S
shawn_he 已提交
699 700 701 702 703 704 705 706 707
| callback              | AsyncCallback\<void>                     | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
708 709 710

**Example**

S
shawn_he 已提交
711
```ts
S
shawn_he 已提交
712
// Version digest information
S
shawn_he 已提交
713
const versionDigestInfo = {
S
shawn_he 已提交
714
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
715
};
S
shawn_he 已提交
716 717

// Options for resuming download
S
shawn_he 已提交
718
const resumeDownloadOptions = {
S
shawn_he 已提交
719
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
S
shawn_he 已提交
720
};
S
shawn_he 已提交
721 722 723 724
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => {
  console.log(`resumeDownload error ${JSON.stringify(err)}`);
});
```
W
wusongqing 已提交
725

S
shawn_he 已提交
726
### resumeDownload
W
wusongqing 已提交
727

S
shawn_he 已提交
728 729 730
resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void>

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

S
shawn_he 已提交
732
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
733

S
shawn_he 已提交
734 735 736 737
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
738 739 740
| Name                  | Type                                      | Mandatory  | Description    |
| --------------------- | ---------------------------------------- | ---- | ------ |
| versionDigestInfo     | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
S
shawn_he 已提交
741 742 743 744
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.|

**Return value**

S
shawn_he 已提交
745 746
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
747 748
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
749 750 751 752 753 754 755 756
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
757 758
**Example**

S
shawn_he 已提交
759
```ts
S
shawn_he 已提交
760
// Version digest information
S
shawn_he 已提交
761
const versionDigestInfo = {
S
shawn_he 已提交
762
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
763
};
S
shawn_he 已提交
764 765

// Options for resuming download
S
shawn_he 已提交
766
const resumeDownloadOptions = {
S
shawn_he 已提交
767
  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
S
shawn_he 已提交
768
};
S
shawn_he 已提交
769 770 771 772
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => {
  console.log(`resumeDownload start`);
}).catch(err => {
  console.log(`resumeDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
773
});
W
wusongqing 已提交
774 775
```

S
shawn_he 已提交
776
###  pauseDownload
W
wusongqing 已提交
777

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

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

S
shawn_he 已提交
782
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
783

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

W
wusongqing 已提交
786 787
**Parameters**

S
shawn_he 已提交
788 789 790 791
| Name                 | Type                                      | Mandatory  | Description                                  |
| -------------------- | ---------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo    | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.                              |
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.                              |
S
shawn_he 已提交
792 793 794 795 796 797 798 799 800
| callback             | AsyncCallback\<void>                     | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
W
wusongqing 已提交
801 802 803

**Example**

S
shawn_he 已提交
804
```ts
S
shawn_he 已提交
805
// Version digest information
S
shawn_he 已提交
806
const versionDigestInfo = {
S
shawn_he 已提交
807
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
808
};
S
shawn_he 已提交
809 810

// Options for pausing download
S
shawn_he 已提交
811
const pauseDownloadOptions = {
S
shawn_he 已提交
812
  isAllowAutoResume: true // Whether to allow automatic resuming of download
S
shawn_he 已提交
813
};
S
shawn_he 已提交
814 815
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => {
  console.log(`pauseDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
816
});
W
wusongqing 已提交
817 818
```

S
shawn_he 已提交
819
### pauseDownload
W
wusongqing 已提交
820

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

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

S
shawn_he 已提交
825
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
826

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

W
wusongqing 已提交
829 830
**Parameters**

S
shawn_he 已提交
831 832 833
| Name                 | Type                                      | Mandatory  | Description    |
| -------------------- | ---------------------------------------- | ---- | ------ |
| versionDigestInfo    | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
S
shawn_he 已提交
834
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.|
W
wusongqing 已提交
835

S
shawn_he 已提交
836
**Return value**
W
wusongqing 已提交
837

S
shawn_he 已提交
838 839
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
840
| Promise\<void> | Promise that returns no value.|
W
wusongqing 已提交
841

S
shawn_he 已提交
842 843 844 845 846 847 848 849
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
850 851
**Example**

S
shawn_he 已提交
852
```ts
S
shawn_he 已提交
853
// Version digest information
S
shawn_he 已提交
854
const versionDigestInfo = {
S
shawn_he 已提交
855
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
856
};
S
shawn_he 已提交
857 858

// Options for pausing download
S
shawn_he 已提交
859
const pauseDownloadOptions = {
S
shawn_he 已提交
860
  isAllowAutoResume: true // Whether to allow automatic resuming of download
S
shawn_he 已提交
861
};
S
shawn_he 已提交
862 863 864 865
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => {
  console.log(`pauseDownload`);
}).catch(err => {
  console.log(`pauseDownload error ${JSON.stringify(err)}`);
S
shawn_he 已提交
866
});
W
wusongqing 已提交
867 868
```

S
shawn_he 已提交
869
###  upgrade
W
wusongqing 已提交
870

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

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

S
shawn_he 已提交
875
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
876

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

W
wusongqing 已提交
879 880
**Parameters**

S
shawn_he 已提交
881 882 883 884
| Name              | Type                                     | Mandatory  | Description                                  |
| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                              |
| upgradeOptions    | [UpgradeOptions](#upgradeoptions)       | Yes   | Update options.                                |
S
shawn_he 已提交
885 886 887 888 889 890 891 892 893
| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
W
wusongqing 已提交
894 895 896

**Example**

S
shawn_he 已提交
897
```ts
S
shawn_he 已提交
898
// Version digest information
S
shawn_he 已提交
899
const versionDigestInfo = {
S
shawn_he 已提交
900
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
901
};
S
shawn_he 已提交
902 903

// Installation options
S
shawn_he 已提交
904
const upgradeOptions = {
S
shawn_he 已提交
905
  order: update.Order.INSTALL // Installation command
S
shawn_he 已提交
906
};
S
shawn_he 已提交
907 908
updater.upgrade(versionDigestInfo, upgradeOptions, (err) => {
  console.log(`upgrade error ${JSON.stringify(err)}`);
S
shawn_he 已提交
909
});
W
wusongqing 已提交
910 911
```

S
shawn_he 已提交
912
### upgrade
W
wusongqing 已提交
913

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

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

S
shawn_he 已提交
918
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
919

S
shawn_he 已提交
920 921 922 923
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
924 925
| Name              | Type                                     | Mandatory  | Description    |
| ----------------- | --------------------------------------- | ---- | ------ |
S
shawn_he 已提交
926
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
S
shawn_he 已提交
927
| upgradeOptions    | [UpgradeOptions](#upgradeoptions)       | Yes   | Update options.  |
S
shawn_he 已提交
928

S
shawn_he 已提交
929
**Return value**
S
shawn_he 已提交
930

S
shawn_he 已提交
931 932
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
933
| Promise\<void> | Promise that returns no value.|
W
wusongqing 已提交
934

S
shawn_he 已提交
935 936 937 938 939 940 941 942
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

W
wusongqing 已提交
943 944
**Example**

S
shawn_he 已提交
945
```ts
S
shawn_he 已提交
946
// Version digest information
S
shawn_he 已提交
947
const versionDigestInfo = {
S
shawn_he 已提交
948
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
949
};
S
shawn_he 已提交
950 951

// Installation options
S
shawn_he 已提交
952
const upgradeOptions = {
S
shawn_he 已提交
953
  order: update.Order.INSTALL // Installation command
S
shawn_he 已提交
954
};
S
shawn_he 已提交
955 956
updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
  console.log(`upgrade start`);
S
shawn_he 已提交
957
}).catch(err => {
S
shawn_he 已提交
958
  console.log(`upgrade error ${JSON.stringify(err)}`);
S
shawn_he 已提交
959
});
W
wusongqing 已提交
960 961
```

S
shawn_he 已提交
962 963 964
###  clearError

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

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

S
shawn_he 已提交
968 969
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
970 971 972 973
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
974 975 976 977
| Name              | Type                                     | Mandatory  | Description                                  |
| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                              |
| clearOptions      | [ClearOptions](#clearoptions)           | Yes   | Clear options.                                |
S
shawn_he 已提交
978 979 980 981 982 983 984 985 986
| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
987 988 989

**Example**

S
shawn_he 已提交
990
```ts
S
shawn_he 已提交
991
// Version digest information
S
shawn_he 已提交
992
const versionDigestInfo = {
S
shawn_he 已提交
993
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
994
};
S
shawn_he 已提交
995 996

// Options for clearing errors
S
shawn_he 已提交
997
const clearOptions = {
S
shawn_he 已提交
998
  status: update.UpgradeStatus.UPGRADE_FAIL,
S
shawn_he 已提交
999
};
S
shawn_he 已提交
1000 1001 1002 1003
updater.clearError(versionDigestInfo, clearOptions, (err) => {
  console.log(`clearError error ${JSON.stringify(err)}`);
});
```
W
wusongqing 已提交
1004

S
shawn_he 已提交
1005
### clearError
W
wusongqing 已提交
1006

S
shawn_he 已提交
1007 1008 1009
clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void>

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

S
shawn_he 已提交
1011 1012
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
1013 1014 1015 1016
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
1017 1018
| Name              | Type                                     | Mandatory  | Description    |
| ----------------- | --------------------------------------- | ---- | ------ |
S
shawn_he 已提交
1019
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
S
shawn_he 已提交
1020
| clearOptions      | [ClearOptions](#clearoptions)           | Yes   | Update options.  |
S
shawn_he 已提交
1021 1022 1023

**Return value**

S
shawn_he 已提交
1024 1025
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
1026 1027
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
1028 1029 1030 1031 1032 1033 1034 1035
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1036 1037
**Example**

S
shawn_he 已提交
1038
```ts
S
shawn_he 已提交
1039
// Version digest information
S
shawn_he 已提交
1040
const versionDigestInfo = {
S
shawn_he 已提交
1041
  versionDigest: "versionDigest" // Version digest information in the check result
S
shawn_he 已提交
1042
};
S
shawn_he 已提交
1043 1044

// Options for clearing errors
S
shawn_he 已提交
1045
const clearOptions = {
S
shawn_he 已提交
1046
  status: update.UpgradeStatus.UPGRADE_FAIL,
S
shawn_he 已提交
1047
};
S
shawn_he 已提交
1048 1049 1050 1051 1052 1053 1054 1055
updater.clearError(versionDigestInfo, clearOptions).then(() => {
  console.log(`clearError success`);
}).catch(err => {
  console.log(`clearError error ${JSON.stringify(err)}`);
});
```

### getUpgradePolicy
W
wusongqing 已提交
1056

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

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

S
shawn_he 已提交
1061 1062
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
1063 1064 1065 1066
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Parameters**

S
shawn_he 已提交
1067 1068
| Name     | Type                                      | Mandatory  | Description             |
| -------- | ---------------------------------------- | ---- | --------------- |
S
shawn_he 已提交
1069 1070
| callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes   | Callback used to return the result.|

S
shawn_he 已提交
1071 1072 1073 1074 1075 1076 1077 1078
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1079 1080
**Example**

S
shawn_he 已提交
1081
```ts
S
shawn_he 已提交
1082 1083 1084 1085 1086 1087 1088
updater.getUpgradePolicy((err, policy) => {
  console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`);
  console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`);
});
```

### getUpgradePolicy
W
wusongqing 已提交
1089

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

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

S
shawn_he 已提交
1094 1095
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
1096 1097 1098 1099
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)

**Return value**

S
shawn_he 已提交
1100 1101
| Type                                      | Description                   |
| ---------------------------------------- | --------------------- |
S
shawn_he 已提交
1102 1103
| Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.|

S
shawn_he 已提交
1104 1105 1106 1107 1108 1109 1110 1111
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1112 1113
**Example**

S
shawn_he 已提交
1114
```ts
S
shawn_he 已提交
1115 1116 1117 1118 1119 1120 1121
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 已提交
1122

S
shawn_he 已提交
1123
### setUpgradePolicy
W
wusongqing 已提交
1124

S
shawn_he 已提交
1125 1126 1127
setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void

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

S
shawn_he 已提交
1129 1130
**System capability**: SystemCapability.Update.UpdateService

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

S
shawn_he 已提交
1133 1134
**Parameters**

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

S
shawn_he 已提交
1140 1141 1142 1143 1144 1145 1146 1147
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1148 1149
**Example**

S
shawn_he 已提交
1150
```ts
S
shawn_he 已提交
1151
const policy = {
S
shawn_he 已提交
1152 1153 1154
  downloadStrategy: false,
  autoUpgradeStrategy: false,
  autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
S
shawn_he 已提交
1155
};
S
shawn_he 已提交
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165
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 已提交
1166

S
shawn_he 已提交
1167 1168
**System capability**: SystemCapability.Update.UpdateService

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

S
shawn_he 已提交
1171 1172
**Parameters**

S
shawn_he 已提交
1173 1174
| Name   | Type                             | Mandatory  | Description  |
| ------ | ------------------------------- | ---- | ---- |
S
shawn_he 已提交
1175 1176 1177 1178
| policy | [UpgradePolicy](#upgradepolicy) | Yes   | Update policy.|

**Return value**

S
shawn_he 已提交
1179 1180
| Type            | Description                 |
| -------------- | ------------------- |
S
shawn_he 已提交
1181
| Promise\<void> | Promise used to return the result.|
W
wusongqing 已提交
1182

S
shawn_he 已提交
1183 1184 1185 1186 1187 1188 1189 1190
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1191 1192
**Example**

S
shawn_he 已提交
1193
```ts
S
shawn_he 已提交
1194
const policy = {
S
shawn_he 已提交
1195 1196 1197
  downloadStrategy: false,
  autoUpgradeStrategy: false,
  autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
S
shawn_he 已提交
1198
};
S
shawn_he 已提交
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
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 已提交
1211

S
shawn_he 已提交
1212 1213
**System capability**: SystemCapability.Update.UpdateService

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

S
shawn_he 已提交
1216 1217
**Parameters**

S
shawn_he 已提交
1218 1219
| Name     | Type                  | Mandatory  | Description                                    |
| -------- | -------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
1220 1221 1222 1223 1224 1225 1226 1227 1228
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
1229 1230 1231

**Example**

S
shawn_he 已提交
1232
```ts
S
shawn_he 已提交
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
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**

S
shawn_he 已提交
1250 1251
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
1252 1253
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
1254 1255 1256 1257 1258 1259 1260 1261
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1262 1263
**Example**

S
shawn_he 已提交
1264
```ts
S
shawn_he 已提交
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
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**

S
shawn_he 已提交
1282 1283 1284 1285
| Name              | Type                                      | Mandatory  | Description  |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|
S
shawn_he 已提交
1286

S
shawn_he 已提交
1287 1288 1289 1290 1291 1292 1293 1294
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1295 1296
**Example**

S
shawn_he 已提交
1297
```ts
S
shawn_he 已提交
1298
const eventClassifyInfo = {
S
shawn_he 已提交
1299 1300
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
S
shawn_he 已提交
1301
};
S
shawn_he 已提交
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316

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**

S
shawn_he 已提交
1317 1318 1319 1320
| Name              | Type                                      | Mandatory  | Description  |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | No   | Event callback.|
S
shawn_he 已提交
1321

S
shawn_he 已提交
1322 1323 1324 1325 1326 1327 1328 1329
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1330 1331
**Example**

S
shawn_he 已提交
1332
```ts
S
shawn_he 已提交
1333
const eventClassifyInfo = {
S
shawn_he 已提交
1334 1335
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
S
shawn_he 已提交
1336
};
S
shawn_he 已提交
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348

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

## Restorer

### factoryReset

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

S
shawn_he 已提交
1349
Restores the scale to its factory settings. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1350 1351 1352 1353 1354 1355 1356

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

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

**Parameters**

S
shawn_he 已提交
1357 1358
| Name     | Type                  | Mandatory  | Description                                    |
| -------- | -------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
1359 1360 1361 1362 1363 1364 1365 1366 1367
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
1368 1369 1370

**Example**

S
shawn_he 已提交
1371
```ts
S
shawn_he 已提交
1372 1373 1374 1375 1376 1377 1378 1379 1380
restorer.factoryReset((err) => {
  console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```

### factoryReset

factoryReset(): Promise\<void>

S
shawn_he 已提交
1381
Restores the scale to its factory settings. This API uses a promise to return the result.
S
shawn_he 已提交
1382 1383 1384 1385 1386 1387 1388

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

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

**Return value**

S
shawn_he 已提交
1389 1390
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
1391 1392
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
1393 1394 1395 1396 1397 1398 1399 1400
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1401 1402
**Example**

S
shawn_he 已提交
1403
```ts
S
shawn_he 已提交
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
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**

S
shawn_he 已提交
1425 1426 1427 1428 1429
| 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.|
S
shawn_he 已提交
1430

S
shawn_he 已提交
1431 1432 1433 1434 1435 1436 1437 1438
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1439 1440
**Example**

S
shawn_he 已提交
1441
```ts
S
shawn_he 已提交
1442
const upgradeFile = {
S
shawn_he 已提交
1443 1444
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
S
shawn_he 已提交
1445
};
S
shawn_he 已提交
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463

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**

S
shawn_he 已提交
1464 1465 1466 1467
| Name        | Type                         | Mandatory  | Description    |
| ----------- | --------------------------- | ---- | ------ |
| upgradeFile | [UpgradeFile](#upgradefile) | Yes   | Update file.  |
| certsFile   | string                      | Yes   | Path of the certificate file.|
S
shawn_he 已提交
1468 1469 1470

**Return value**

S
shawn_he 已提交
1471 1472
| Type            | Description                    |
| -------------- | ---------------------- |
S
shawn_he 已提交
1473 1474
| Promise\<void> | Promise used to return the result.|

S
shawn_he 已提交
1475 1476 1477 1478 1479 1480 1481 1482
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1483 1484
**Example**

S
shawn_he 已提交
1485
```ts
S
shawn_he 已提交
1486
const upgradeFile = {
S
shawn_he 已提交
1487 1488
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
S
shawn_he 已提交
1489
};
S
shawn_he 已提交
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507
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**

S
shawn_he 已提交
1508 1509 1510
| Name        | Type                                | Mandatory  | Description                                     |
| ----------- | ---------------------------------- | ---- | --------------------------------------- |
| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes   | Update file.                                   |
S
shawn_he 已提交
1511 1512 1513 1514 1515 1516 1517 1518 1519
| callback    | AsyncCallback\<void>               | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
1520 1521 1522

**Example**

S
shawn_he 已提交
1523
```ts
S
shawn_he 已提交
1524
const upgradeFiles = [{
S
shawn_he 已提交
1525 1526
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
S
shawn_he 已提交
1527
}];
S
shawn_he 已提交
1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545

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**

S
shawn_he 已提交
1546 1547
| Type            | Description                        |
| -------------- | -------------------------- |
S
shawn_he 已提交
1548 1549
| Promise\<void> | Promise that returns no value.|

S
shawn_he 已提交
1550 1551 1552 1553 1554 1555 1556 1557
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1558 1559
**Example**

S
shawn_he 已提交
1560
```ts
S
shawn_he 已提交
1561
const upgradeFiles = [{
S
shawn_he 已提交
1562 1563
  fileType: update.ComponentType.OTA, // OTA package
  filePath: "path" // Path of the local update package
S
shawn_he 已提交
1564
}];
S
shawn_he 已提交
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580
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**

S
shawn_he 已提交
1581 1582 1583 1584
| Name              | Type                                      | Mandatory  | Description  |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|
S
shawn_he 已提交
1585

S
shawn_he 已提交
1586 1587 1588 1589 1590 1591 1592 1593
**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |

S
shawn_he 已提交
1594 1595
**Example**

S
shawn_he 已提交
1596
```ts
S
shawn_he 已提交
1597
const eventClassifyInfo = {
S
shawn_he 已提交
1598 1599
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
S
shawn_he 已提交
1600
};
S
shawn_he 已提交
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617

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**

S
shawn_he 已提交
1618 1619 1620
| Name              | Type                                      | Mandatory  | Description  |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
S
shawn_he 已提交
1621 1622 1623 1624 1625 1626 1627 1628 1629
| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | No   | Event callback.|

**Error codes**

For details about the error codes, see [Update Error Codes](../errorcodes/errorcode-update.md).

| ID      | Error Message                                                 |
| -------  | ---------------------------------------------------- |
| 11500104 | BusinessError 11500104: IPC error.                   |
S
shawn_he 已提交
1630 1631 1632

**Example**

S
shawn_he 已提交
1633
```ts
S
shawn_he 已提交
1634
const eventClassifyInfo = {
S
shawn_he 已提交
1635 1636
  eventClassify: update.EventClassify.TASK, // Listening for update events
  extraInfo: ""
S
shawn_he 已提交
1637
};
S
shawn_he 已提交
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651

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

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

## UpgradeInfo

Represents update information.

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

S
shawn_he 已提交
1652 1653 1654 1655
| Name          | Type                         | Mandatory  | Description    |
| ------------ | ----------------------------- | ---- | ------ |
| upgradeApp   | string                        | Yes   | Application package name. |
| businessType | [BusinessType](#businesstype) | Yes   | Update service type.|
S
shawn_he 已提交
1656 1657 1658 1659 1660 1661 1662

## BusinessType

Enumerates update service types.

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

S
shawn_he 已提交
1663 1664 1665
| Name     | Type                               | Mandatory  | Description  |
| ------- | ----------------------------------- | ---- | ---- |
| vendor  | [BusinessVendor](#businessvendor)   | Yes   | Application vendor. |
S
shawn_he 已提交
1666
| subType | [BusinessSubType](#businesssubtype) | Yes   | Update service type.  |
S
shawn_he 已提交
1667 1668 1669 1670 1671 1672 1673

## CheckResult

Represents the package check result.

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

S
shawn_he 已提交
1674 1675 1676 1677
| Name               | Type                             | Mandatory  | Description    |
| ----------------- | --------------------------------- | ---- | ------ |
| isExistNewVersion | bool                              | Yes   | Whether a new version is available.|
| newVersionInfo    | [NewVersionInfo](#newversioninfo) | No   | Information about the new version. |
S
shawn_he 已提交
1678 1679 1680 1681 1682 1683 1684

## NewVersionInfo

Represents information about the new version.

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

S
shawn_he 已提交
1685 1686 1687 1688
| Name               | Type                                    | Mandatory  | Description  |
| ----------------- | ---------------------------------------- | ---- | ---- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes   | Version components.|
S
shawn_he 已提交
1689 1690 1691 1692 1693 1694 1695

## VersionDigestInfo

Represents version digest information.

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

S
shawn_he 已提交
1696 1697 1698
| Name           | Type  | Mandatory  | Description  |
| ------------- | ------ | ---- | ---- |
| versionDigest | string | Yes   | Version digest information.|
S
shawn_he 已提交
1699 1700 1701 1702 1703 1704 1705

## VersionComponent

Represents a version component.

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

S
shawn_he 已提交
1706
| Name             | Type                               | Mandatory  | Description      |
S
shawn_he 已提交
1707
| --------------- | ----------------------------------- | ---- | -------- |
S
shawn_he 已提交
1708
| componentId     | string                              | Yes   | Component ID.    |
S
shawn_he 已提交
1709 1710 1711 1712 1713 1714 1715
| componentType   | [ComponentType](#componenttype)     | 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.|
S
shawn_he 已提交
1716 1717 1718 1719 1720 1721 1722

## DescriptionOptions

Represents options of the description file.

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

S
shawn_he 已提交
1723 1724 1725 1726
| Name      | Type                                   | Mandatory  | Description    |
| -------- | --------------------------------------- | ---- | ------ |
| format   | [DescriptionFormat](#descriptionformat) | Yes   | Format of the description file.|
| language | string                                  | Yes   | Language of the description file.|
S
shawn_he 已提交
1727 1728 1729 1730 1731 1732 1733

## ComponentDescription

Represents a component description file.

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

S
shawn_he 已提交
1734 1735 1736 1737
| Name             | Type                               | Mandatory  | Description    |
| --------------- | ----------------------------------- | ---- | ------ |
| componentId     | string                              | Yes   | Component ID.  |
| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes   | Information about the description file.|
S
shawn_he 已提交
1738 1739 1740 1741 1742 1743 1744

## DescriptionInfo

Represents information about the version description file.

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

S
shawn_he 已提交
1745 1746 1747 1748
| Name             | Type                               | Mandatory  | Description    |
| --------------- | ----------------------------------- | ---- | ------ |
| descriptionType | [DescriptionType](#descriptiontype) | Yes   | Type of the description file.|
| content         | string                              | Yes   | Content of the description file.|
S
shawn_he 已提交
1749 1750 1751 1752 1753 1754 1755

## CurrentVersionInfo

Represents information about the current version.

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

S
shawn_he 已提交
1756 1757 1758 1759 1760
| Name               | Type                                    | Mandatory  | Description   |
| ----------------- | ---------------------------------------- | ---- | ----- |
| osVersion         | string                                   | Yes   | System version number.|
| deviceName        | string                                   | Yes   | Device name.  |
| versionComponents | Array\<[VersionComponent](#versioncomponent)> | No   | Version components. |
S
shawn_he 已提交
1761 1762 1763 1764 1765 1766 1767

## DownloadOptions

Represents download options.

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

S
shawn_he 已提交
1768 1769 1770 1771
| Name          | Type               | Mandatory  | Description  |
| ------------ | ------------------- | ---- | ---- |
| allowNetwork | [NetType](#nettype) | Yes   | Network type.|
| order        | [Order](#order)     | Yes   | Update command.|
S
shawn_he 已提交
1772 1773 1774 1775 1776 1777 1778

## ResumeDownloadOptions

Represents options for resuming download.

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

S
shawn_he 已提交
1779 1780 1781
| Name          | Type               | Mandatory  | Description  |
| ------------ | ------------------- | ---- | ---- |
| allowNetwork | [NetType](#nettype) | Yes   | Network type.|
S
shawn_he 已提交
1782 1783 1784 1785 1786 1787 1788

## PauseDownloadOptions

Represents options for pausing download.

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

S
shawn_he 已提交
1789 1790 1791
| Name               | Type| Mandatory  | Description      |
| ----------------- | ---- | ---- | -------- |
| isAllowAutoResume | bool | Yes   | Whether to allow automatic resuming of download.|
S
shawn_he 已提交
1792 1793 1794 1795 1796 1797 1798

## UpgradeOptions

Represents update options.

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

S
shawn_he 已提交
1799 1800 1801
| Name   | Type           | Mandatory  | Description  |
| ----- | --------------- | ---- | ---- |
| order | [Order](#order) | Yes   | Update command.|
S
shawn_he 已提交
1802 1803 1804 1805 1806 1807 1808

## ClearOptions

Represents options for clearing errors.

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

S
shawn_he 已提交
1809 1810 1811
| Name    | Type                           | Mandatory  | Description  |
| ------ | ------------------------------- | ---- | ---- |
| status | [UpgradeStatus](#upgradestatus) | Yes   | Error status.|
S
shawn_he 已提交
1812 1813 1814 1815 1816 1817 1818

## UpgradePolicy

Represents an update policy.

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

S
shawn_he 已提交
1819 1820 1821 1822 1823
| Name                 | Type                                   | Mandatory  | Description     |
| ------------------- | --------------------------------------- | ---- | ------- |
| downloadStrategy    | bool                                    | Yes   | Automatic download policy. |
| autoUpgradeStrategy | bool                                    | Yes   | Automatic update policy. |
| autoUpgradePeriods  | Array\<[UpgradePeriod](#upgradeperiod)> | Yes   | Automatic update period.|
S
shawn_he 已提交
1824 1825 1826

## UpgradePeriod

S
shawn_he 已提交
1827
Represents an automatic update period.
S
shawn_he 已提交
1828 1829 1830

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

S
shawn_he 已提交
1831 1832 1833 1834
| Name   | Type  | Mandatory  | Description  |
| ----- | ------ | ---- | ---- |
| start | number | Yes   | Start time.|
| end   | number | Yes   | End time.|
S
shawn_he 已提交
1835 1836 1837

## TaskInfo

S
shawn_he 已提交
1838
Task information.
S
shawn_he 已提交
1839 1840 1841

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

S
shawn_he 已提交
1842 1843 1844 1845
| Name       | Type                 | Mandatory  | Description    |
| --------- | --------------------- | ---- | ------ |
| existTask | bool                  | Yes   | Whether a task exists.|
| taskBody  | [TaskBody](#taskinfo) | Yes   | Task data.  |
S
shawn_he 已提交
1846 1847 1848

## EventInfo

S
shawn_he 已提交
1849
Represents event information.
S
shawn_he 已提交
1850 1851 1852

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

S
shawn_he 已提交
1853 1854 1855 1856
| Name      | Type                 | Mandatory  | Description  |
| -------- | --------------------- | ---- | ---- |
| eventId  | [EventId](#eventid)   | Yes   | Event ID.|
| taskBody | [TaskBody](#taskinfo) | Yes   | Task data.|
S
shawn_he 已提交
1857 1858 1859 1860 1861 1862 1863

## TaskBody

Represents task data.

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

S
shawn_he 已提交
1864 1865 1866 1867 1868 1869 1870 1871 1872
| 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.|
S
shawn_he 已提交
1873 1874 1875 1876 1877 1878 1879

## ErrorMessage

Represents an error message.

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

S
shawn_he 已提交
1880 1881 1882
| Name          | Type  | Mandatory  | Description  |
| ------------ | ------ | ---- | ---- |
| errorCode    | number | Yes   | Error code. |
S
shawn_he 已提交
1883
| errorMessage | string | Yes   | Error message.|
S
shawn_he 已提交
1884 1885 1886 1887 1888 1889 1890

## EventClassifyInfo

Represents event type information.

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

S
shawn_he 已提交
1891 1892 1893 1894
| Name           | Type                           | Mandatory  | Description  |
| ------------- | ------------------------------- | ---- | ---- |
| eventClassify | [EventClassify](#eventclassify) | Yes   | Event type.|
| extraInfo     | string                          | Yes   | Additional information.|
S
shawn_he 已提交
1895 1896 1897 1898 1899 1900 1901

## UpgradeFile

Represents an update file.

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

S
shawn_he 已提交
1902 1903 1904 1905
| Name      | Type                           | Mandatory  | Description  |
| -------- | ------------------------------- | ---- | ---- |
| fileType | [ComponentType](#componenttype) | Yes   | File type.|
| filePath | string                          | Yes   | File path.|
S
shawn_he 已提交
1906 1907 1908

## UpgradeTaskCallback

S
shawn_he 已提交
1909
(eventInfo: EventInfo): void
S
shawn_he 已提交
1910

S
shawn_he 已提交
1911
Represents an event callback.
S
shawn_he 已提交
1912 1913 1914

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

S
shawn_he 已提交
1915 1916 1917
| Name       | Type                   | Mandatory  | Description  |
| --------- | ----------------------- | ---- | ---- |
| eventInfo | [EventInfo](#eventinfo) | Yes   | Event information.|
S
shawn_he 已提交
1918 1919 1920

## BusinessVendor

S
shawn_he 已提交
1921
Represents a device vendor.
S
shawn_he 已提交
1922 1923 1924

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

S
shawn_he 已提交
1925
| Name   | Value     | Description  |
S
shawn_he 已提交
1926 1927
| ------ | -------- | ---- |
| PUBLIC | "public" | Open source.  |
S
shawn_he 已提交
1928 1929 1930 1931 1932 1933 1934

## BusinessSubType

Represents an update type.

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

S
shawn_he 已提交
1935
| Name     | Value | Description  |
S
shawn_he 已提交
1936 1937
| -------- | ---- | ---- |
| FIRMWARE | 1    | Firmware.  |
S
shawn_he 已提交
1938 1939 1940 1941 1942 1943 1944

## ComponentType

Represents a component type.

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

S
shawn_he 已提交
1945
| Name | Value | Description  |
S
shawn_he 已提交
1946 1947
| ---- | ---- | ---- |
| OTA  | 1    | Firmware.  |
S
shawn_he 已提交
1948 1949 1950 1951 1952 1953 1954

## UpgradeAction

Represents an update mode.

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

S
shawn_he 已提交
1955
| Name     | Value       | Description  |
S
shawn_he 已提交
1956 1957 1958
| -------- | ---------- | ---- |
| UPGRADE  | "upgrade"  | Differential package. |
| RECOVERY | "recovery" | Recovery package. |
S
shawn_he 已提交
1959 1960 1961 1962 1963 1964 1965

## EffectiveMode

Represents an effective mode.

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

S
shawn_he 已提交
1966
| Name          | Value | Description  |
S
shawn_he 已提交
1967 1968 1969 1970
| ------------- | ---- | ---- |
| COLD          | 1    | Cold update. |
| LIVE          | 2    | Live update. |
| LIVE_AND_COLD | 3    | Hybrid live and cold update.|
S
shawn_he 已提交
1971 1972 1973 1974 1975 1976 1977

## DescriptionType

Represents a description file type.

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

S
shawn_he 已提交
1978
| Name    | Value | Description  |
S
shawn_he 已提交
1979 1980 1981
| ------- | ---- | ---- |
| CONTENT | 0    | Content.  |
| URI     | 1    | Link.  |
S
shawn_he 已提交
1982 1983 1984 1985 1986 1987 1988

## DescriptionFormat

Represents a description file format.

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

S
shawn_he 已提交
1989
| Name       | Value | Description  |
S
shawn_he 已提交
1990 1991 1992
| ---------- | ---- | ---- |
| STANDARD   | 0    | Standard format.|
| SIMPLIFIED | 1    | Simple format.|
S
shawn_he 已提交
1993 1994 1995

## NetType

S
shawn_he 已提交
1996
Represents a network type.
S
shawn_he 已提交
1997 1998 1999

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

S
shawn_he 已提交
2000
| Name              | Value | Description       |
S
shawn_he 已提交
2001 2002 2003 2004 2005 2006
| ----------------- | ---- | --------- |
| CELLULAR          | 1    | Data network.     |
| METERED_WIFI      | 2    | Wi-Fi hotspot.   |
| NOT_METERED_WIFI  | 4    | Non Wi-Fi hotspot.  |
| WIFI              | 6    | Wi-Fi.     |
| CELLULAR_AND_WIFI | 7    | Data network and Wi-Fi.|
S
shawn_he 已提交
2007 2008 2009 2010 2011 2012 2013

## Order

Represents an update command.

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

S
shawn_he 已提交
2014
| Name                 | Value | Description   |
S
shawn_he 已提交
2015 2016 2017 2018 2019 2020
| -------------------- | ---- | ----- |
| DOWNLOAD             | 1    | Download.   |
| INSTALL              | 2    | Install.   |
| DOWNLOAD_AND_INSTALL | 3    | Download and install.|
| APPLY                | 4    | Apply.   |
| INSTALL_AND_APPLY    | 6    | Install and apply.|
S
shawn_he 已提交
2021 2022 2023 2024 2025 2026 2027

## UpgradeStatus

Enumerates update states.

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

S
shawn_he 已提交
2028
| Name             | Value | Description  |
S
shawn_he 已提交
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039
| ---------------- | ---- | ---- |
| 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.|
S
shawn_he 已提交
2040 2041 2042 2043 2044 2045 2046

## EventClassify

Represents an event type.

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

S
shawn_he 已提交
2047
| Name  | Value       | Description  |
S
shawn_he 已提交
2048 2049
| ---- | ---------- | ---- |
| TASK | 0x01000000 | Task event.|
S
shawn_he 已提交
2050 2051

## EventId
W
wusongqing 已提交
2052

S
shawn_he 已提交
2053
Enumerates event IDs.
W
wusongqing 已提交
2054

S
shawn_he 已提交
2055 2056
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
2057
| Name                    | Value       | Description    |
S
shawn_he 已提交
2058
| ---------------------- | ---------- | ------ |
S
shawn_he 已提交
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075
| EVENT_TASK_BASE        | 0x01000000 | Task event.  |
| EVENT_TASK_RECEIVE     | 0x01000001 | Task received.  |
| EVENT_TASK_CANCEL      | 0x01000010 | Task cancelled.  |
| EVENT_DOWNLOAD_WAIT    | 0x01000011 | Waiting for download.   |
| EVENT_DOWNLOAD_START   | 0x01000100 | Download started.  |
| EVENT_DOWNLOAD_UPDATE  | 0x01000101 | Download progress update.|
| EVENT_DOWNLOAD_PAUSE   | 0x01000110 | Download paused.  |
| EVENT_DOWNLOAD_RESUME  | 0x01000111 | Download resumed.  |
| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | Download succeeded.  |
| EVENT_DOWNLOAD_FAIL    | 0x01001001 | Download failed.  |
| EVENT_UPGRADE_WAIT     | 0x01001010 | Waiting for update.   |
| EVENT_UPGRADE_START    | 0x01001011 | Update started.  |
| EVENT_UPGRADE_UPDATE   | 0x01001100 | Update in progress.   |
| EVENT_APPLY_WAIT       | 0x01001101 | Waiting for applying the update.   |
| EVENT_APPLY_START      | 0x01001110 | Applying the update.  |
| EVENT_UPGRADE_SUCCESS  | 0x01001111 | Update succeeded.  |
| EVENT_UPGRADE_FAIL     | 0x01010000 | Update failed.  |