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

S
shawn_he 已提交
3
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
S
shawn_he 已提交
4 5
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.

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

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 已提交
11
- 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 已提交
12 13 14 15

## Modules to Import

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

## Required Permissions

None

S
shawn_he 已提交
23
## update.getUpdater
S
shawn_he 已提交
24 25 26 27 28

getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater

Obtains the **Updater** object for local update.

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

**Parameters**

H
HelloCrease 已提交
33 34 35 36
| Name        | Type                        | Mandatory | Description  |
| ----------- | --------------------------- | --------- | ------------ |
| upgradeFile | string                      | Yes       | Update file. |
| updateType  | [UpdateTypes](#updatetypes) | Yes       | Update type. |
S
shawn_he 已提交
37

S
shawn_he 已提交
38
**Return value**
S
shawn_he 已提交
39

H
HelloCrease 已提交
40 41 42
| Type                | Description         |
| ------------------- | ------------------- |
| [Updater](#updater) | **Updater** object. |
S
shawn_he 已提交
43 44 45 46 47 48 49 50 51 52 53

**Example**

```
try {
  let updater = update.getUpdater('/data/updater/updater.zip', 'OTA');
} catch(error) {
  console.error(" Fail to get updater error: " + error);
}
```

S
shawn_he 已提交
54
## update.getUpdaterForOther
S
shawn_he 已提交
55 56 57 58 59

getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater

Obtains the **Updater** object for the device to be updated.

S
shawn_he 已提交
60
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
61 62 63

**Parameters**

H
HelloCrease 已提交
64 65 66 67 68
| Name        | Type                        | Mandatory | Description           |
| ----------- | --------------------------- | --------- | --------------------- |
| upgradeFile | string                      | Yes       | Update file.          |
| device      | string                      | Yes       | Device to be updated. |
| updateType  | [UpdateTypes](#updatetypes) | Yes       | Update type.          |
S
shawn_he 已提交
69

S
shawn_he 已提交
70
**Return value**
S
shawn_he 已提交
71

H
HelloCrease 已提交
72 73 74
| Type                | Description         |
| ------------------- | ------------------- |
| [Updater](#updater) | **Updater** object. |
S
shawn_he 已提交
75 76 77 78 79 80 81 82 83 84 85

**Example**

```
try {
  let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
  console.error(" Fail to get updater error: " + error);
}
```

S
shawn_he 已提交
86
## update.getUpdaterFromOther
S
shawn_he 已提交
87 88 89 90 91

getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater

Obtains the **Updater** object from another device for the device to be updated.

S
shawn_he 已提交
92
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
93 94 95

**Parameters**

H
HelloCrease 已提交
96 97 98 99 100
| Name        | Type                        | Mandatory | Description           |
| ----------- | --------------------------- | --------- | --------------------- |
| upgradeFile | string                      | Yes       | Update file.          |
| device      | string                      | Yes       | Device to be updated. |
| updateType  | [UpdateTypes](#updatetypes) | Yes       | Update type.          |
S
shawn_he 已提交
101

S
shawn_he 已提交
102
**Return value**
S
shawn_he 已提交
103

H
HelloCrease 已提交
104 105 106
| Type                | Description         |
| ------------------- | ------------------- |
| [Updater](#updater) | **Updater** object. |
S
shawn_he 已提交
107 108 109 110 111 112 113 114 115 116 117

**Example**

```
try {
  let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA');
} catch(error) {
  console.error(" Fail to get updater error: " + error);
}
```

W
wusongqing 已提交
118 119 120 121 122 123
## Updater

###  getNewVersionInfo

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

S
shawn_he 已提交
124
Obtains the new version information. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
125

S
shawn_he 已提交
126
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
127 128 129

**Parameters**

H
HelloCrease 已提交
130 131 132
| Name     | Type                                     | Mandatory | Description                              |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No        | Callback used to return the new version information. |
W
wusongqing 已提交
133 134 135 136

**Example**

```
S
shawn_he 已提交
137
updater.getNewVersionInfo(info => {
W
wusongqing 已提交
138
  console.log("getNewVersionInfo success  " + info.status);
S
shawn_he 已提交
139 140 141
  console.log(`info versionName = ` + info.checkResult[0].versionName);
  console.log(`info versionCode = ` + info.checkResult[0].versionCode);
  console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
S
shawn_he 已提交
142
});
W
wusongqing 已提交
143 144 145 146 147 148
```

### getNewVersionInfo

getNewVersionInfo(): Promise\<NewVersionInfo>

S
shawn_he 已提交
149
Obtains the new version information. This function uses a promise to return the result.
W
wusongqing 已提交
150

S
shawn_he 已提交
151
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
152

S
shawn_he 已提交
153
**Return value**
S
shawn_he 已提交
154

H
HelloCrease 已提交
155 156 157
| Type                                     | Description                              |
| ---------------------------------------- | ---------------------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. |
W
wusongqing 已提交
158 159 160 161

**Example**

```
S
shawn_he 已提交
162
updater.getNewVersionInfo().then(value => {
S
shawn_he 已提交
163 164 165
  console.log(`info versionName = ` + value.checkResult[0].versionName);
  console.log(`info versionCode = ` + value.checkResult[0].versionCode);
  console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo);
S
shawn_he 已提交
166
}).catch(err => {
W
wusongqing 已提交
167
  console.log("getNewVersionInfo promise error: " + err.code);
S
shawn_he 已提交
168
});
W
wusongqing 已提交
169 170 171 172 173 174
```

### checkNewVersion

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

S
shawn_he 已提交
175
Checks whether the current version is the latest. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
176

S
shawn_he 已提交
177
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
178 179 180

**Parameters**

H
HelloCrease 已提交
181 182 183
| Name     | Type                                     | Mandatory | Description                              |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No        | Callback used to return the new version information. |
W
wusongqing 已提交
184 185 186 187

**Example**

```
S
shawn_he 已提交
188
updater.checkNewVersion(info => {
W
wusongqing 已提交
189
  console.log("checkNewVersion success  " + info.status);
S
shawn_he 已提交
190 191 192
  console.log(`info versionName = ` + info.checkResult[0].versionName);
  console.log(`info versionCode = ` + info.checkResult[0].versionCode);
  console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
S
shawn_he 已提交
193
});
W
wusongqing 已提交
194 195 196 197 198 199
```

### checkNewVersion

checkNewVersion(): Promise\<NewVersionInfo>

S
shawn_he 已提交
200
Checks whether the current version is the latest. This function uses a promise to return the result.
S
shawn_he 已提交
201

S
shawn_he 已提交
202
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
203

S
shawn_he 已提交
204
**Return value**
W
wusongqing 已提交
205

H
HelloCrease 已提交
206 207 208
| Type                                     | Description                              |
| ---------------------------------------- | ---------------------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. |
W
wusongqing 已提交
209 210 211 212

**Example**

```
S
shawn_he 已提交
213 214 215 216
updater.checkNewVersion().then(value => {
  console.log(`info versionName = ` + value.checkResult[0].versionName);
  console.log(`info versionCode = ` + value.checkResult[0].versionCode);
  console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo);
S
shawn_he 已提交
217
}).catch(err => {
W
wusongqing 已提交
218
  console.log("checkNewVersion promise error: " + err.code);
S
shawn_he 已提交
219
});
W
wusongqing 已提交
220 221 222 223 224 225 226 227
```

### verifyUpdatePackage

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

Verifies whether the update package is valid.

S
shawn_he 已提交
228
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
229

W
wusongqing 已提交
230 231
**Parameters**

H
HelloCrease 已提交
232 233 234 235
| Name        | Type   | Mandatory | Description                              |
| ----------- | ------ | --------- | ---------------------------------------- |
| upgradeFile | string | Yes       | Path of the update package to be verified. |
| certsFile   | string | Yes       | Certificate path.                        |
W
wusongqing 已提交
236 237 238 239

**Example**

```
S
shawn_he 已提交
240
updater.on("verifyProgress", callback => {
S
shawn_he 已提交
241
  console.info('on verifyProgress ' + callback.percent);
W
wusongqing 已提交
242
});
S
shawn_he 已提交
243
update.verifyUpdatePackage("XXX", "XXX");
W
wusongqing 已提交
244 245
```

S
shawn_he 已提交
246
### rebootAndCleanUserData<sup>8+</sup>
W
wusongqing 已提交
247 248 249

rebootAndCleanUserData(): Promise\<number>

S
shawn_he 已提交
250
Reboots the device and clears the user partition data. This function uses a promise to return the result.
W
wusongqing 已提交
251

S
shawn_he 已提交
252
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
253

S
shawn_he 已提交
254
**Return value**
S
shawn_he 已提交
255

H
HelloCrease 已提交
256 257 258
| Type             | Description                              |
| ---------------- | ---------------------------------------- |
| Promise\<number> | Promise used to return the execution result. |
W
wusongqing 已提交
259 260 261 262

**Example**

```
S
shawn_he 已提交
263
updater.rebootAndCleanUserData().then(result => {
S
shawn_he 已提交
264 265 266
  console.log("rebootAndCleanUserData " + result);
}).catch(err => {
  console.info("rebootAndCleanUserData promise error: " + err.code);
W
wusongqing 已提交
267 268 269
});
```

S
shawn_he 已提交
270
### rebootAndCleanUserData<sup>8+</sup>
W
wusongqing 已提交
271 272 273

rebootAndCleanUserData(callback: AsyncCallback\<number>): void

S
shawn_he 已提交
274
Reboots the device and clears the user partition data. This function uses a promise to return the result.
S
shawn_he 已提交
275

S
shawn_he 已提交
276
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
277 278 279

**Parameters**

H
HelloCrease 已提交
280 281 282
| Name     | Type                   | Mandatory | Description                              |
| -------- | ---------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback\<number> | Yes       | Callback used to return the execution result. |
W
wusongqing 已提交
283 284 285 286

**Example**

```
S
shawn_he 已提交
287
updater.rebootAndCleanUserData(result => {
S
shawn_he 已提交
288
  console.log("rebootAndCleanUserData ", result)
W
wusongqing 已提交
289 290 291 292 293 294 295
});
```

### applyNewVersion

applyNewVersion(): Promise\<number>

S
shawn_he 已提交
296
Installs the update package. This function uses a promise to return the result.
W
wusongqing 已提交
297

S
shawn_he 已提交
298
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
299

S
shawn_he 已提交
300
**Return value**
S
shawn_he 已提交
301

H
HelloCrease 已提交
302 303 304
| Type             | Description                              |
| ---------------- | ---------------------------------------- |
| Promise\<number> | Promise used to return the execution result. |
W
wusongqing 已提交
305 306 307 308

**Example**

```
S
shawn_he 已提交
309
updater.applyNewVersion().then(result => {
S
shawn_he 已提交
310 311
    console.log("appVewVersion ", result)
}).catch(err => {
W
wusongqing 已提交
312 313 314 315 316 317 318 319
    console.info("applyNewVersion promise error: " + err.code);
});
```

### applyNewVersion

applyNewVersion(callback: AsyncCallback\<number>): void

S
shawn_he 已提交
320
Installs the update package. This function uses a promise to return the result.
S
shawn_he 已提交
321

S
shawn_he 已提交
322
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
323 324 325

**Parameters**

H
HelloCrease 已提交
326 327 328
| Name     | Type                   | Mandatory | Description                              |
| -------- | ---------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback\<number> | Yes       | Callback used to return the execution result. |
W
wusongqing 已提交
329 330 331 332

**Example**

```
S
shawn_he 已提交
333
updater.applyNewVersion(result => {
S
shawn_he 已提交
334
  console.log("applyNewVersion ", result)
W
wusongqing 已提交
335 336 337 338 339 340 341 342 343
});
```

### download

download(): void

Downloads the new version and displays the download process.

S
shawn_he 已提交
344
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
345

W
wusongqing 已提交
346 347 348 349 350 351 352
**Example**

```
updater.on("downloadProgress", progress => {
  console.log("downloadProgress on" + progress);
  console.log(`downloadProgress status: ` + progress.status);
  console.log(`downloadProgress percent: ` + progress.percent);
S
shawn_he 已提交
353
});
W
wusongqing 已提交
354 355 356 357 358
updater.download();
```

### upgrade

S
shawn_he 已提交
359
upgrade():void
W
wusongqing 已提交
360 361 362

Starts an update.

S
shawn_he 已提交
363
**System capability**: SystemCapability.Update.UpdateService
S
shawn_he 已提交
364

W
wusongqing 已提交
365 366 367 368 369 370 371
**Example**

```
updater.on("upgradeProgress", progress => {
  console.log("upgradeProgress on" + progress);
  console.log(`upgradeProgress status: ` + progress.status);
  console.log(`upgradeProgress percent: ` + progress.percent);
S
shawn_he 已提交
372
});
W
wusongqing 已提交
373 374 375 376 377 378 379
updater.upgrade();
```

### setUpdatePolicy

setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void

S
shawn_he 已提交
380
Sets the update policy. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
381

S
shawn_he 已提交
382
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
383 384 385

**Parameters**

H
HelloCrease 已提交
386 387 388 389
| Name     | Type                                     | Mandatory | Description                              |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- |
| policy   | [UpdatePolicy](#updatepolicy)            | Yes       | Update policy to set.                    |
| callback | Callback used to return the execution result. | Yes       | Callback used to return the execution result. |
W
wusongqing 已提交
390 391 392 393 394 395

**Example**

```
// Set the update policy.
let policy = {
S
shawn_he 已提交
396 397 398 399 400
  autoDownload: false,
  autoDownloadNet: true,
  mode: 2,
  autoUpgradeInterval: [ 2, 3 ],
  autoUpgradeCondition: 2
W
wusongqing 已提交
401
}
S
shawn_he 已提交
402
updater.setUpdatePolicy(policy, result => {
S
shawn_he 已提交
403 404
  console.log("setUpdatePolicy ", result)
});
W
wusongqing 已提交
405 406 407 408 409 410
```

### setUpdatePolicy

setUpdatePolicy(policy: UpdatePolicy): Promise\<number>

S
shawn_he 已提交
411
Sets the update policy. This function uses a promise to return the result.
S
shawn_he 已提交
412

S
shawn_he 已提交
413
**System capability**: SystemCapability.Update.UpdateService
W
wusongqing 已提交
414 415 416

**Parameters**

H
HelloCrease 已提交
417 418 419
| Name   | Type                          | Mandatory | Description           |
| ------ | ----------------------------- | --------- | --------------------- |
| policy | [UpdatePolicy](#updatepolicy) | Yes       | Update policy to set. |
W
wusongqing 已提交
420

S
shawn_he 已提交
421
**Return value**
W
wusongqing 已提交
422

H
HelloCrease 已提交
423 424 425
| Type             | Description                              |
| ---------------- | ---------------------------------------- |
| Promise\<number> | Promise used to return the execution result. |
W
wusongqing 已提交
426 427 428 429 430

**Example**

```
let policy = {
S
shawn_he 已提交
431 432 433 434 435
  autoDownload: false,
  autoDownloadNet: true,
  mode: 2,
  autoUpgradeInterval: [ 2, 3 ],
  autoUpgradeCondition: 2
W
wusongqing 已提交
436
}
S
shawn_he 已提交
437
updater.setUpdatePolicy(policy).then(result => 
S
shawn_he 已提交
438 439 440 441
  console.log("setUpdatePolicy ", result)
).catch(err => {
  console.log("setUpdatePolicy promise error: " + err.code);
});
W
wusongqing 已提交
442 443 444 445 446 447
```

### getUpdatePolicy

getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void

S
shawn_he 已提交
448
Obtains the update policy. This function uses an asynchronous callback to return the result.
S
shawn_he 已提交
449

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

**Parameters**

H
HelloCrease 已提交
454 455 456
| Name     | Type                                     | Mandatory | Description                              |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No        | Callback used to return the update policy. |
W
wusongqing 已提交
457 458 459 460

**Example**

```
S
shawn_he 已提交
461
updater.getUpdatePolicy(policy => {
W
wusongqing 已提交
462 463 464 465
  console.log("getUpdatePolicy success");
  console.log(`policy autoDownload = ` + policy.autoDownload);
  console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet);
  console.log(`policy mode = ` + policy.mode);
S
shawn_he 已提交
466
});
W
wusongqing 已提交
467 468 469 470 471 472
```

### getUpdatePolicy

getUpdatePolicy(): Promise\<UpdatePolicy>

S
shawn_he 已提交
473
Obtains the update policy. This function uses a promise to return the result.
W
wusongqing 已提交
474

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

S
shawn_he 已提交
477
**Return value**
S
shawn_he 已提交
478

H
HelloCrease 已提交
479 480 481
| Type                                    | Description                              |
| --------------------------------------- | ---------------------------------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy. |
W
wusongqing 已提交
482 483 484 485

**Example**

```
S
shawn_he 已提交
486
updater.getUpdatePolicy().then(value => {
W
wusongqing 已提交
487 488 489
  console.log(`info autoDownload = ` + value.autoDownload);
  console.log(`info autoDownloadNet = ` + value.autoDownloadNet);
  console.log(`info mode = ` + value.mode);
S
shawn_he 已提交
490
}).catch(err => {
W
wusongqing 已提交
491
  console.log("getUpdatePolicy promise error: " + err.code);
S
shawn_he 已提交
492
});
W
wusongqing 已提交
493 494 495 496
```

## UpdateTypes

S
shawn_he 已提交
497
Enumerates update types.
W
wusongqing 已提交
498

S
shawn_he 已提交
499 500
**System capability**: SystemCapability.Update.UpdateService

S
shawn_he 已提交
501
| Name  | Description   |
H
HelloCrease 已提交
502 503
| ----- | ------------- |
| OTA   | OTA update.   |
S
shawn_he 已提交
504
| patch | Patch update. |
W
wusongqing 已提交
505 506 507

## PackageTypes

S
shawn_he 已提交
508
Enumerates update package types.
W
wusongqing 已提交
509

S
shawn_he 已提交
510 511
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
512 513 514 515 516 517 518 519 520
| Name                 | Default Value | Description                             |
| -------------------- | ------------- | --------------------------------------- |
| PACKAGE_TYPE_NORMAL  | 1             | Common update package.                  |
| PACKAGE_TYPE_BASE    | 2             | Basic update package.                   |
| PACKAGE_TYPE_CUST    | 3             | Custom update package.                  |
| PACKAGE_TYPE_PRELOAD | 4             | Preinstalled update package.            |
| PACKAGE_TYPE_COTA    | 5             | Parameter configuration update package. |
| PACKAGE_TYPE_VERSION | 6             | Version update package.                 |
| PACKAGE_TYPE_PATCH   | 7             | Patch package.                          |
W
wusongqing 已提交
521 522 523

## InstallMode

S
shawn_he 已提交
524
Enumerates update modes.
W
wusongqing 已提交
525

S
shawn_he 已提交
526 527
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
528 529 530 531 532
| Name                | Default Value | Description       |
| ------------------- | ------------- | ----------------- |
| INSTALL_MODE_NORMAL | 0             | Normal update.    |
| INSTALL_MODE_NIGHT  | 1             | Update at night.  |
| INSTALL_MODE_AUTO   | 2             | Automatic update. |
W
wusongqing 已提交
533 534 535

## NewVersionStatus

S
shawn_he 已提交
536
Enumerates new version check results.
W
wusongqing 已提交
537

S
shawn_he 已提交
538 539
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
540 541 542 543 544 545
| Name                | Default Value | Description                              |
| ------------------- | ------------- | ---------------------------------------- |
| VERSION_STATUS_ERR  | -1            | System error while checking for the new version. |
| VERSION_STATUS_NEW  | 0             | New version detected.                    |
| VERSION_STATUS_NONE | 1             | No new version detected.                 |
| VERSION_STATUS_BUSY | 2             | System busy while checking for the new version. |
W
wusongqing 已提交
546 547 548 549 550

## UpdatePolicy

Defines the update policy.

S
shawn_he 已提交
551 552
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
553 554 555 556 557
| Name                | Type                        | Mandatory | Description                          |
| ------------------- | --------------------------- | --------- | ------------------------------------ |
| autoDownload        | bool                        | Yes       | Automatic update switch.             |
| installMode         | [InstallMode](#installmode) | Yes       | Update mode.                         |
| autoUpgradeInterval | Array\<number>              | Yes       | Period of time for automatic update. |
W
wusongqing 已提交
558 559 560 561 562

## NewVersionInfo

Defines the new version information.

S
shawn_he 已提交
563 564
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
565 566 567 568 569 570
| Name            | Type                                     | Mandatory | Description                      |
| --------------- | ---------------------------------------- | --------- | -------------------------------- |
| status          | [NewVersionStatus](#newversionstatus)    | Yes       | Update status.                   |
| errMsg          | string                                   | Yes       | Error message.                   |
| checkResults    | Array<[CheckResult](#checkresult)>       | Yes       | Version check result.            |
| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes       | Version description information. |
W
wusongqing 已提交
571 572 573

## CheckResult

S
shawn_he 已提交
574
Defines the version check result.
W
wusongqing 已提交
575

S
shawn_he 已提交
576 577
**System capability**: SystemCapability.Update.UpdateService

H
HelloCrease 已提交
578 579 580 581 582 583 584 585
| Name          | Type                          | Mandatory | Description                       |
| ------------- | ----------------------------- | --------- | --------------------------------- |
| versionName   | string                        | Yes       | Version name.                     |
| versionCode   | number                        | Yes       | Version code.                     |
| size          | number                        | Yes       | Version size.                     |
| verifyInfo    | string                        | Yes       | Version verification information. |
| packageType   | [PackageTypes](#packagetypes) | Yes       | Version type.                     |
| descriptionId | string                        | Yes       | Version description information.  |
W
wusongqing 已提交
586 587 588 589 590

## DescriptionInfo

Defines the version description information.

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

H
HelloCrease 已提交
593 594 595 596
| Name          | Type   | Mandatory | Description                    |
| ------------- | ------ | --------- | ------------------------------ |
| descriptionId | string | Yes       | Version ID information.        |
| content       | string | Yes       | Version changelog information. |