1# @ohos.update (Update)
2
3The **update** module implements update of the entire system, including built-in resources and preset applications, but not third-party applications.
4
5There are two types of updates: SD card update and over the air (OTA) update.
6
7- The SD card update depends on the update packages and SD cards.
8
9- 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.
10
11> **NOTE**
12>
13> 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.
14>
15> The APIs provided by this module are system APIs.
16
17## Modules to Import
18
19```js
20import { update } from '@kit.BasicServicesKit';
21```
22
23## update.getOnlineUpdater
24
25getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
26
27Obtains an **OnlineUpdater** object.
28
29**System capability**: SystemCapability.Update.UpdateService
30
31**Parameters**
32
33| Name        | Type                         | Mandatory  | Description    |
34| ----------- | --------------------------- | ---- | ------ |
35| upgradeInfo | [UpgradeInfo](#upgradeinfo) | Yes   | **OnlineUpdater** object information.|
36
37**Return value**
38
39| Type                 | Description  |
40| ------------------- | ---- |
41| [Updater](#updater) | **OnlineUpdater** object.|
42
43**Example**
44
45```ts
46try {
47      const upgradeInfo: update.UpgradeInfo = {
48        upgradeApp: "com.ohos.ota.updateclient",
49        businessType: {
50          vendor: update.BusinessVendor.PUBLIC,
51          subType: update.BusinessSubType.FIRMWARE
52        }
53      };
54      let updater = update.getOnlineUpdater(upgradeInfo);
55    } catch(error) {
56      console.error(`Fail to get updater error: ${error}`);
57    }
58```
59
60## update.getRestorer
61
62getRestorer(): Restorer
63
64Obtains a **Restorer** object for restoring factory settings.
65
66**System capability**: SystemCapability.Update.UpdateService
67
68
69**Return value**
70
71| Type                   | Description    |
72| --------------------- | ------ |
73| [Restorer](#restorer) | **Restorer** object for restoring factory settings.|
74
75
76**Example**
77
78```ts
79try {
80  let restorer = update.getRestorer();
81} catch(error) {
82  console.error(`Fail to get restorer: ${error}`);
83}
84```
85
86## update.getLocalUpdater
87
88getLocalUpdater(): LocalUpdater
89
90Obtains a **LocalUpdater** object.
91
92**System capability**: SystemCapability.Update.UpdateService
93
94**Return value**
95
96| Type                           | Description    |
97| ----------------------------- | ------ |
98| [LocalUpdater](#localupdater) | **LocalUpdater** object.|
99
100
101**Example**
102
103```ts
104try {
105  let localUpdater = update.getLocalUpdater();
106} catch(error) {
107  console.error(`Fail to get localUpdater error: ${error}`);
108};
109```
110
111## Updater
112
113### checkNewVersion
114
115checkNewVersion(callback: AsyncCallback\<CheckResult>): void
116
117Checks whether a new version is available. This API uses an asynchronous callback to return the result.
118
119**System capability**: SystemCapability.Update.UpdateService
120
121**Required permission**: ohos.permission.UPDATE_SYSTEM
122
123**Parameters**
124
125| Name     | Type                                      | Mandatory  | Description            |
126| -------- | ---------------------------------------- | ---- | -------------- |
127| callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes   | Callback used to return the result.|
128
129**Error codes**
130
131For details about the error codes, see [Update Error Codes](errorcode-update.md).
132
133| ID      | Error Message                                                 |
134| -------  | ---------------------------------------------------- |
135| 201      | Permission denied.       |
136| 11500104 | IPC error.               |
137
138**Example**
139
140```ts
141import { BusinessError } from '@kit.BasicServicesKit';
142
143updater.checkNewVersion((err: BusinessError, result: update.CheckResult) => {
144      console.log(`checkNewVersion isExistNewVersion  ${result?.isExistNewVersion}`);
145    });
146```
147
148### checkNewVersion
149
150checkNewVersion(): Promise\<CheckResult>
151
152Checks whether a new version is available. This API uses a promise to return the result.
153
154**System capability**: SystemCapability.Update.UpdateService
155
156**Required permission**: ohos.permission.UPDATE_SYSTEM
157
158**Return value**
159
160| Type                                   | Description                 |
161| ------------------------------------- | ------------------- |
162| Promise\<[CheckResult](#checkresult)> | Promise used to return the result.|
163
164**Error codes**
165
166For details about the error codes, see [Update Error Codes](errorcode-update.md).
167
168| ID      | Error Message                                                 |
169| -------  | ---------------------------------------------------- |
170| 201      | Permission denied.       |
171| 11500104 | IPC error.               |
172
173**Example**
174
175```ts
176import { BusinessError } from '@kit.BasicServicesKit';
177
178updater.checkNewVersion()
179      .then((result: update.CheckResult) => {
180        console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`);
181        // Version digest information
182        console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`);
183      })
184      .catch((err: BusinessError)=>{
185        console.log(`checkNewVersion promise error ${JSON.stringify(err)}`);
186      })
187```
188
189###  getNewVersionInfo
190
191getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
192
193Obtains information about the new version. This API uses an asynchronous callback to return the result.
194
195**System capability**: SystemCapability.Update.UpdateService
196
197**Required permission**: ohos.permission.UPDATE_SYSTEM
198
199**Parameters**
200
201| Name     | Type                                      | Mandatory  | Description             |
202| -------- | ---------------------------------------- | ---- | --------------- |
203| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes   | Callback used to return the result.|
204
205**Error codes**
206
207For details about the error codes, see [Update Error Codes](errorcode-update.md).
208
209| ID      | Error Message                                                 |
210| -------  | ---------------------------------------------------- |
211| 201      | Permission denied.       |
212| 11500104 | IPC error.               |
213
214**Example**
215
216```ts
217import { BusinessError } from '@kit.BasicServicesKit';
218
219updater.getNewVersionInfo((err: BusinessError, info: update.NewVersionInfo) => {
220      console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
221      console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`);
222});
223```
224
225### getNewVersionInfo
226
227getNewVersionInfo(): Promise\<NewVersionInfo>
228
229Obtains information about the new version. This API uses a promise to return the result.
230
231**System capability**: SystemCapability.Update.UpdateService
232
233**Required permission**: ohos.permission.UPDATE_SYSTEM
234
235**Return value**
236
237| Type                                      | Description                  |
238| ---------------------------------------- | -------------------- |
239| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
240
241**Error codes**
242
243For details about the error codes, see [Update Error Codes](errorcode-update.md).
244
245| ID      | Error Message                                                 |
246| -------  | ---------------------------------------------------- |
247| 201      | Permission denied.       |
248| 11500104 | IPC error.               |
249
250**Example**
251
252```ts
253import { BusinessError } from '@kit.BasicServicesKit';
254
255updater.getNewVersionInfo().then((info: update.NewVersionInfo) => {
256    console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
257    console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`);
258}).catch((err: BusinessError) => {
259    console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`);
260});
261```
262
263###  getNewVersionDescription
264
265getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
266
267Obtains the description file of the new version. This API uses an asynchronous callback to return the result.
268
269**System capability**: SystemCapability.Update.UpdateService
270
271**Required permission**: ohos.permission.UPDATE_SYSTEM
272
273**Parameters**
274
275| Name               | Type                                      | Mandatory  | Description            |
276| ------------------ | ---------------------------------------- | ---- | -------------- |
277| versionDigestInfo  | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.        |
278| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.       |
279| callback           | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>> | Yes   | Callback used to return the result.|
280
281**Error codes**
282
283For details about the error codes, see [Update Error Codes](errorcode-update.md).
284
285| ID      | Error Message                                                 |
286| -------  | ---------------------------------------------------- |
287| 201      | Permission denied.       |
288| 401      | Parameter verification failed.    |
289| 11500104 | IPC error.               |
290
291**Example**
292
293```ts
294import { BusinessError } from '@kit.BasicServicesKit';
295
296// Version digest information
297const versionDigestInfo: update.VersionDigestInfo = {
298  versionDigest: "versionDigest" // Version digest information in the check result
299};
300
301// Options of the description file
302const descriptionOptions: update.DescriptionOptions = {
303  format: update.DescriptionFormat.STANDARD, // Standard format
304  language: "zh-cn" // Chinese
305};
306
307updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then((info: Array<update.ComponentDescription>)=> {
308  console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
309}).catch((err: BusinessError) => {
310  console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
311});
312```
313
314### getNewVersionDescription
315
316getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>;
317
318Obtains the description file of the new version. This API uses a promise to return the result.
319
320**System capability**: SystemCapability.Update.UpdateService
321
322**Required permission**: ohos.permission.UPDATE_SYSTEM
323
324**Parameters**
325
326| Name               | Type                                      | Mandatory  | Description    |
327| ------------------ | ---------------------------------------- | ---- | ------ |
328| versionDigestInfo  | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
329| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|
330
331**Return value**
332
333| Type                                      | Description                 |
334| ---------------------------------------- | ------------------- |
335| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
336
337**Error codes**
338
339For details about the error codes, see [Update Error Codes](errorcode-update.md).
340
341| ID      | Error Message                                                 |
342| -------  | ---------------------------------------------------- |
343| 201      | Permission denied.       |
344| 401      | Parameter verification failed.    |
345| 11500104 | IPC error.               |
346
347**Example**
348
349```ts
350import { BusinessError } from '@kit.BasicServicesKit';
351
352// Version digest information
353const versionDigestInfo: update.VersionDigestInfo = {
354  versionDigest: "versionDigest" // Version digest information in the check result
355};
356
357// Options of the description file
358const descriptionOptions: update.DescriptionOptions = {
359  format: update.DescriptionFormat.STANDARD, // Standard format
360  language: "zh-cn" // Chinese
361};
362
363updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then((info: Array<update.ComponentDescription>)=> {
364  console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
365}).catch((err: BusinessError) => {
366  console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
367});
368```
369
370###  getCurrentVersionInfo
371
372getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void
373
374Obtains information about the current version. This API uses an asynchronous callback to return the result.
375
376**System capability**: SystemCapability.Update.UpdateService
377
378**Required permission**: ohos.permission.UPDATE_SYSTEM
379
380**Parameters**
381
382| Name     | Type                                      | Mandatory  | Description              |
383| -------- | ---------------------------------------- | ---- | ---------------- |
384| callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes   | Callback used to return the result.|
385
386**Error codes**
387
388For details about the error codes, see [Update Error Codes](errorcode-update.md).
389
390| ID      | Error Message                                                 |
391| -------  | ---------------------------------------------------- |
392| 201      | Permission denied.       |
393| 11500104 | IPC error.               |
394
395**Example**
396
397```ts
398import { BusinessError } from '@kit.BasicServicesKit';
399
400updater.getCurrentVersionInfo((err: BusinessError, info: update.CurrentVersionInfo) => {
401  console.log(`info osVersion = ${info?.osVersion}`);
402  console.log(`info deviceName = ${info?.deviceName}`);
403  console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
404});
405```
406
407### getCurrentVersionInfo
408
409getCurrentVersionInfo(): Promise\<CurrentVersionInfo>
410
411Obtains information about the current version. This API uses a promise to return the result.
412
413**System capability**: SystemCapability.Update.UpdateService
414
415**Required permission**: ohos.permission.UPDATE_SYSTEM
416
417**Return value**
418
419| Type                                      | Description                 |
420| ---------------------------------------- | ------------------- |
421| Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.|
422
423**Error codes**
424
425For details about the error codes, see [Update Error Codes](errorcode-update.md).
426
427| ID      | Error Message                                                 |
428| -------  | ---------------------------------------------------- |
429| 201      | Permission denied.       |
430| 11500104 | IPC error.               |
431
432**Example**
433
434```ts
435import { BusinessError } from '@kit.BasicServicesKit';
436
437updater.getCurrentVersionInfo().then((info: update.CurrentVersionInfo) => {
438  console.log(`info osVersion = ${info.osVersion}`);
439  console.log(`info deviceName = ${info.deviceName}`);
440  console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
441}).catch((err: BusinessError) => {
442  console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`);
443});
444```
445
446###  getCurrentVersionDescription
447
448getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
449
450Obtains the description file of the current version. This API uses an asynchronous callback to return the result.
451
452**System capability**: SystemCapability.Update.UpdateService
453
454**Required permission**: ohos.permission.UPDATE_SYSTEM
455
456**Parameters**
457
458| Name               | Type                                      | Mandatory  | Description             |
459| ------------------ | ---------------------------------------- | ---- | --------------- |
460| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.         |
461| callback           | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>> | Yes   | Callback used to return the result.|
462
463**Error codes**
464
465For details about the error codes, see [Update Error Codes](errorcode-update.md).
466
467| ID      | Error Message                                                 |
468| -------  | ---------------------------------------------------- |
469| 201      | Permission denied.       |
470| 401      | Parameter verification failed.    |
471| 11500104 | IPC error.               |
472
473**Example**
474
475```ts
476// Options of the description file
477const descriptionOptions: update.DescriptionOptions = {
478  format: update.DescriptionFormat.STANDARD, // Standard format
479  language: "zh-cn" // Chinese
480};
481
482updater.getCurrentVersionDescription(descriptionOptions, (err, info) => {
483  console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`);
484  console.log(`getCurrentVersionDescription err ${JSON.stringify(err)}`);
485});
486```
487
488### getCurrentVersionDescription
489
490getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>
491
492Obtains the description file of the current version. This API uses a promise to return the result.
493
494**System capability**: SystemCapability.Update.UpdateService
495
496**Required permission**: ohos.permission.UPDATE_SYSTEM
497
498**Parameters**
499
500| Name               | Type                                      | Mandatory  | Description    |
501| ------------------ | ---------------------------------------- | ---- | ------ |
502| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes   | Options of the description file.|
503
504**Return value**
505
506| Type                                      | Description                  |
507| ---------------------------------------- | -------------------- |
508| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
509
510**Error codes**
511
512For details about the error codes, see [Update Error Codes](errorcode-update.md).
513
514| ID      | Error Message                                                 |
515| -------  | ---------------------------------------------------- |
516| 201      | Permission denied.       |
517| 401      | Parameter verification failed.    |
518| 11500104 | IPC error.               |
519
520**Example**
521
522```ts
523import { BusinessError } from '@kit.BasicServicesKit';
524// Options of the description file
525const descriptionOptions: update.DescriptionOptions = {
526  format: update.DescriptionFormat.STANDARD, // Standard format
527  language: "zh-cn" // Chinese
528};
529updater.getCurrentVersionDescription(descriptionOptions).then((info: Array<update.ComponentDescription>) => {
530  console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
531}).catch((err: BusinessError) => {
532  console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`);
533});
534```
535
536###  getTaskInfo
537
538getTaskInfo(callback: AsyncCallback\<TaskInfo>): void
539
540Obtains information about the update task. This API uses an asynchronous callback to return the result.
541
542**System capability**: SystemCapability.Update.UpdateService
543
544**Required permission**: ohos.permission.UPDATE_SYSTEM
545
546**Parameters**
547
548| Name     | Type                                   | Mandatory  | Description              |
549| -------- | ------------------------------------- | ---- | ---------------- |
550| callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes   | Callback used to return the result.|
551
552**Error codes**
553
554For details about the error codes, see [Update Error Codes](errorcode-update.md).
555
556| ID      | Error Message                                                 |
557| -------  | ---------------------------------------------------- |
558| 201      | Permission denied.       |
559| 11500104 | IPC error.               |
560
561**Example**
562
563```ts
564import { BusinessError } from '@kit.BasicServicesKit';
565
566updater.getTaskInfo((err: BusinessError, info: update.TaskInfo) => {
567  console.log(`getTaskInfo isexistTask= ${info?.existTask}`);
568});
569```
570
571### getTaskInfo
572
573getTaskInfo(): Promise\<TaskInfo>
574
575Obtains information about the update task. This API uses a promise to return the result.
576
577**System capability**: SystemCapability.Update.UpdateService
578
579**Required permission**: ohos.permission.UPDATE_SYSTEM
580
581**Return value**
582
583| Type                             | Description                 |
584| ------------------------------- | ------------------- |
585| Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.|
586
587**Error codes**
588
589For details about the error codes, see [Update Error Codes](errorcode-update.md).
590
591| ID      | Error Message                                                 |
592| -------  | ---------------------------------------------------- |
593| 201      | Permission denied.       |
594| 11500104 | IPC error.               |
595
596**Example**
597
598```ts
599import { BusinessError } from '@kit.BasicServicesKit';
600
601updater.getTaskInfo().then((info: update.TaskInfo) => {
602  console.log(`getTaskInfo isexistTask= ${info.existTask}`);
603}).catch((err: BusinessError) => {
604  console.log(`getTaskInfo promise error ${JSON.stringify(err)}`);
605});
606```
607
608###  download
609
610download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, callback: AsyncCallback\<void>): void
611
612Downloads the new version. This API uses an asynchronous callback to return the result.
613
614**System capability**: SystemCapability.Update.UpdateService
615
616**Required permission**: ohos.permission.UPDATE_SYSTEM
617
618**Parameters**
619
620| Name              | Type                                     | Mandatory  | Description                                |
621| ----------------- | --------------------------------------- | ---- | ---------------------------------- |
622| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                            |
623| downloadOptions   | [DownloadOptions](#downloadoptions)     | Yes   | Download options.                              |
624| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
625
626**Error codes**
627
628For details about the error codes, see [Update Error Codes](errorcode-update.md).
629
630| ID      | Error Message                                                 |
631| -------  | ---------------------------------------------------- |
632| 201      | Permission denied.       |
633| 401      | Parameter verification failed.    |
634| 11500104 | IPC error.               |
635
636**Example**
637
638```ts
639import { BusinessError } from '@kit.BasicServicesKit';
640
641// Version digest information
642const versionDigestInfo: update.VersionDigestInfo = {
643  versionDigest: "versionDigest" // Version digest information in the check result
644};
645
646// Download options
647const downloadOptions: update.DownloadOptions = {
648  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
649  order: update.Order.DOWNLOAD // Download
650};
651updater.download(versionDigestInfo, downloadOptions, (err: BusinessError) => {
652  console.log(`download error ${JSON.stringify(err)}`);
653});
654```
655
656### download
657
658download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions): Promise\<void>
659
660Downloads the new version. This API uses a promise to return the result.
661
662**System capability**: SystemCapability.Update.UpdateService
663
664**Required permission**: ohos.permission.UPDATE_SYSTEM
665
666**Parameters**
667
668| Name              | Type                                     | Mandatory  | Description    |
669| ----------------- | --------------------------------------- | ---- | ------ |
670| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
671| downloadOptions   | [DownloadOptions](#downloadoptions)     | Yes   | Download options.  |
672
673**Return value**
674
675| Type            | Description                        |
676| -------------- | -------------------------- |
677| Promise\<void> | Promise that returns no value.|
678
679**Error codes**
680
681For details about the error codes, see [Update Error Codes](errorcode-update.md).
682
683| ID      | Error Message                                                 |
684| -------  | ---------------------------------------------------- |
685| 201      | Permission denied.       |
686| 401      | Parameter verification failed.    |
687| 11500104 | IPC error.               |
688
689**Example**
690
691```ts
692import { BusinessError } from '@kit.BasicServicesKit';
693
694// Version digest information
695const versionDigestInfo: update.VersionDigestInfo = {
696  versionDigest: "versionDigest" // Version digest information in the check result
697};
698
699// Download options
700const downloadOptions: update.DownloadOptions = {
701  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
702   order: update.Order.DOWNLOAD // Download
703};
704updater.download(versionDigestInfo, downloadOptions).then(() => {
705  console.log(`download start`);
706}).catch((err: BusinessError) => {
707  console.log(`download error ${JSON.stringify(err)}`);
708});
709```
710
711###  resumeDownload
712
713resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback\<void>): void
714
715Resumes download of the new version. This API uses an asynchronous callback to return the result.
716
717**System capability**: SystemCapability.Update.UpdateService
718
719**Required permission**: ohos.permission.UPDATE_SYSTEM
720
721**Parameters**
722
723| Name                  | Type                                      | Mandatory  | Description                                  |
724| --------------------- | ---------------------------------------- | ---- | ------------------------------------ |
725| versionDigestInfo     | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.                              |
726| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.                              |
727| callback              | AsyncCallback\<void>                     | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
728
729**Error codes**
730
731For details about the error codes, see [Update Error Codes](errorcode-update.md).
732
733| ID      | Error Message                                                 |
734| -------  | ---------------------------------------------------- |
735| 201      | Permission denied.       |
736| 401      | Parameter verification failed.    |
737| 11500104 | IPC error.               |
738
739**Example**
740
741```ts
742import { BusinessError } from '@kit.BasicServicesKit';
743
744// Version digest information
745const versionDigestInfo : update.VersionDigestInfo= {
746  versionDigest: "versionDigest" // Version digest information in the check result
747};
748
749// Options for resuming download
750const resumeDownloadOptions : update.ResumeDownloadOptions= {
751  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
752};
753updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err: BusinessError) => {
754  console.log(`resumeDownload error ${JSON.stringify(err)}`);
755});
756```
757
758### resumeDownload
759
760resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void>
761
762Resumes download of the new version. This API uses a promise to return the result.
763
764**System capability**: SystemCapability.Update.UpdateService
765
766**Required permission**: ohos.permission.UPDATE_SYSTEM
767
768**Parameters**
769
770| Name                  | Type                                      | Mandatory  | Description    |
771| --------------------- | ---------------------------------------- | ---- | ------ |
772| versionDigestInfo     | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
773| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes   | Options for resuming download.|
774
775**Return value**
776
777| Type            | Description                        |
778| -------------- | -------------------------- |
779| Promise\<void> | Promise that returns no value.|
780
781**Error codes**
782
783For details about the error codes, see [Update Error Codes](errorcode-update.md).
784
785| ID      | Error Message                                                 |
786| -------  | ---------------------------------------------------- |
787| 201      | Permission denied.       |
788| 401      | Parameter verification failed.    |
789| 11500104 | IPC error.               |
790
791**Example**
792
793```ts
794import { BusinessError } from '@kit.BasicServicesKit';
795
796// Version digest information
797const versionDigestInfo: update.VersionDigestInfo = {
798  versionDigest: "versionDigest" // Version digest information in the check result
799};
800
801// Options for resuming download
802const resumeDownloadOptions: update.ResumeDownloadOptions = {
803  allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
804};
805updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(() => {
806  console.log(`resumeDownload start`);
807}).catch((err: BusinessError) => {
808  console.log(`resumeDownload error ${JSON.stringify(err)}`);
809});
810```
811
812###  pauseDownload
813
814pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback\<void>): void
815
816Pauses download of the new version. This API uses an asynchronous callback to return the result.
817
818**System capability**: SystemCapability.Update.UpdateService
819
820**Required permission**: ohos.permission.UPDATE_SYSTEM
821
822**Parameters**
823
824| Name                 | Type                                      | Mandatory  | Description                                  |
825| -------------------- | ---------------------------------------- | ---- | ------------------------------------ |
826| versionDigestInfo    | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.                              |
827| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.                              |
828| callback             | AsyncCallback\<void>                     | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
829
830**Error codes**
831
832For details about the error codes, see [Update Error Codes](errorcode-update.md).
833
834| ID      | Error Message                                                 |
835| -------  | ---------------------------------------------------- |
836| 201      | Permission denied.       |
837| 401      | Parameter verification failed.    |
838| 11500104 | IPC error.               |
839
840**Example**
841
842```ts
843import { BusinessError } from '@kit.BasicServicesKit';
844
845// Version digest information
846const versionDigestInfo: update.VersionDigestInfo = {
847  versionDigest: "versionDigest" // Version digest information in the check result
848};
849
850// Options for pausing download
851const pauseDownloadOptions: update.PauseDownloadOptions = {
852  isAllowAutoResume: true // Whether to allow automatic resuming of download
853};
854updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err: BusinessError) => {
855  console.log(`pauseDownload error ${JSON.stringify(err)}`);
856});
857```
858
859### pauseDownload
860
861pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise\<void>
862
863Resumes download of the new version. This API uses a promise to return the result.
864
865**System capability**: SystemCapability.Update.UpdateService
866
867**Required permission**: ohos.permission.UPDATE_SYSTEM
868
869**Parameters**
870
871| Name                 | Type                                      | Mandatory  | Description    |
872| -------------------- | ---------------------------------------- | ---- | ------ |
873| versionDigestInfo    | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
874| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes   | Options for pausing download.|
875
876**Return value**
877
878| Type            | Description                        |
879| -------------- | -------------------------- |
880| Promise\<void> | Promise that returns no value.|
881
882**Error codes**
883
884For details about the error codes, see [Update Error Codes](errorcode-update.md).
885
886| ID      | Error Message                                                 |
887| -------  | ---------------------------------------------------- |
888| 201      | Permission denied.       |
889| 401      | Parameter verification failed.    |
890| 11500104 | IPC error.               |
891
892**Example**
893
894```ts
895import { BusinessError } from '@kit.BasicServicesKit';
896
897// Version digest information
898const versionDigestInfo: update.VersionDigestInfo = {
899  versionDigest: "versionDigest" // Version digest information in the check result
900};
901
902// Options for pausing download
903const pauseDownloadOptions: update.PauseDownloadOptions = {
904  isAllowAutoResume: true // Whether to allow automatic resuming of download
905};
906updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(() => {
907  console.log(`pauseDownload`);
908}).catch((err: BusinessError)  => {
909  console.log(`pauseDownload error ${JSON.stringify(err)}`);
910});
911```
912
913###  upgrade
914
915upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, callback: AsyncCallback\<void>): void
916
917Updates the version. This API uses an asynchronous callback to return the result.
918
919**System capability**: SystemCapability.Update.UpdateService
920
921**Required permission**: ohos.permission.UPDATE_SYSTEM
922
923**Parameters**
924
925| Name              | Type                                     | Mandatory  | Description                                  |
926| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
927| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                              |
928| upgradeOptions    | [UpgradeOptions](#upgradeoptions)       | Yes   | Update options.                                |
929| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
930
931**Error codes**
932
933For details about the error codes, see [Update Error Codes](errorcode-update.md).
934
935| ID      | Error Message                                                 |
936| -------  | ---------------------------------------------------- |
937| 201      | Permission denied.       |
938| 401      | Parameter verification failed.    |
939| 11500104 | IPC error.               |
940
941**Example**
942
943```ts
944import { BusinessError } from '@kit.BasicServicesKit';
945
946// Version digest information
947const versionDigestInfo: update.VersionDigestInfo = {
948  versionDigest: "versionDigest" // Version digest information in the check result
949};
950
951// Installation options
952const upgradeOptions: update.UpgradeOptions = {
953  order: update.Order.INSTALL // Installation command
954};
955updater.upgrade(versionDigestInfo, upgradeOptions, (err: BusinessError) => {
956  console.log(`upgrade error ${JSON.stringify(err)}`);
957});
958```
959
960### upgrade
961
962upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): Promise\<void>
963
964Updates the version. This API uses a promise to return the result.
965
966**System capability**: SystemCapability.Update.UpdateService
967
968**Required permission**: ohos.permission.UPDATE_SYSTEM
969
970**Parameters**
971
972| Name              | Type                                     | Mandatory  | Description    |
973| ----------------- | --------------------------------------- | ---- | ------ |
974| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
975| upgradeOptions    | [UpgradeOptions](#upgradeoptions)       | Yes   | Update options.  |
976
977**Return value**
978
979| Type            | Description                        |
980| -------------- | -------------------------- |
981| Promise\<void> | Promise that returns no value.|
982
983**Error codes**
984
985For details about the error codes, see [Update Error Codes](errorcode-update.md).
986
987| ID      | Error Message                                                 |
988| -------  | ---------------------------------------------------- |
989| 201      | Permission denied.       |
990| 401      | Parameter verification failed.    |
991| 11500104 | IPC error.               |
992
993**Example**
994
995```ts
996import { BusinessError } from '@kit.BasicServicesKit';
997
998// Version digest information
999const versionDigestInfo: update.VersionDigestInfo = {
1000  versionDigest: "versionDigest" // Version digest information in the check result
1001};
1002
1003// Installation options
1004const upgradeOptions: update.UpgradeOptions = {
1005  order: update.Order.INSTALL // Installation command
1006};
1007updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
1008  console.log(`upgrade start`);
1009}).catch((err: BusinessError) => {
1010  console.log(`upgrade error ${JSON.stringify(err)}`);
1011});
1012```
1013
1014###  clearError
1015
1016clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback\<void>): void
1017
1018Clears errors. This API uses an asynchronous callback to return the result.
1019
1020**System capability**: SystemCapability.Update.UpdateService
1021
1022**Required permission**: ohos.permission.UPDATE_SYSTEM
1023
1024**Parameters**
1025
1026| Name              | Type                                     | Mandatory  | Description                                  |
1027| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
1028| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.                              |
1029| clearOptions      | [ClearOptions](#clearoptions)           | Yes   | Clear options.                                |
1030| callback          | AsyncCallback\<void>                    | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
1031
1032**Error codes**
1033
1034For details about the error codes, see [Update Error Codes](errorcode-update.md).
1035
1036| ID      | Error Message                                                 |
1037| -------  | ---------------------------------------------------- |
1038| 201      | Permission denied.       |
1039| 401      | Parameter verification failed.    |
1040| 11500104 | IPC error.               |
1041
1042**Example**
1043
1044```ts
1045import { BusinessError } from '@kit.BasicServicesKit';
1046
1047// Version digest information
1048const versionDigestInfo: update.VersionDigestInfo = {
1049  versionDigest: "versionDigest" // Version digest information in the check result
1050};
1051
1052// Options for clearing errors
1053const clearOptions: update.ClearOptions = {
1054  status: update.UpgradeStatus.UPGRADE_FAIL,
1055};
1056updater.clearError(versionDigestInfo, clearOptions, (err: BusinessError) => {
1057  console.log(`clearError error ${JSON.stringify(err)}`);
1058});
1059```
1060
1061### clearError
1062
1063clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void>
1064
1065Clears errors. This API uses a promise to return the result.
1066
1067**System capability**: SystemCapability.Update.UpdateService
1068
1069**Required permission**: ohos.permission.UPDATE_SYSTEM
1070
1071**Parameters**
1072
1073| Name              | Type                                     | Mandatory  | Description    |
1074| ----------------- | --------------------------------------- | ---- | ------ |
1075| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes   | Version digest information.|
1076| clearOptions      | [ClearOptions](#clearoptions)           | Yes   | Update options.  |
1077
1078**Return value**
1079
1080| Type            | Description                        |
1081| -------------- | -------------------------- |
1082| Promise\<void> | Promise that returns no value.|
1083
1084**Error codes**
1085
1086For details about the error codes, see [Update Error Codes](errorcode-update.md).
1087
1088| ID      | Error Message                                                 |
1089| -------  | ---------------------------------------------------- |
1090| 201      | Permission denied.       |
1091| 401      | Parameter verification failed.    |
1092| 11500104 | IPC error.               |
1093
1094**Example**
1095
1096```ts
1097import { BusinessError } from '@kit.BasicServicesKit';
1098
1099// Version digest information
1100const versionDigestInfo: update.VersionDigestInfo = {
1101  versionDigest: "versionDigest" // Version digest information in the check result
1102};
1103
1104// Options for clearing errors
1105const clearOptions: update.ClearOptions = {
1106  status: update.UpgradeStatus.UPGRADE_FAIL,
1107};
1108updater.clearError(versionDigestInfo, clearOptions).then(() => {
1109  console.log(`clearError success`);
1110}).catch((err: BusinessError) => {
1111  console.log(`clearError error ${JSON.stringify(err)}`);
1112});
1113```
1114
1115### getUpgradePolicy
1116
1117getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void
1118
1119Obtains the update policy. This API uses an asynchronous callback to return the result.
1120
1121**System capability**: SystemCapability.Update.UpdateService
1122
1123**Required permission**: ohos.permission.UPDATE_SYSTEM
1124
1125**Parameters**
1126
1127| Name     | Type                                      | Mandatory  | Description             |
1128| -------- | ---------------------------------------- | ---- | --------------- |
1129| callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes   | Callback used to return the result.|
1130
1131**Error codes**
1132
1133For details about the error codes, see [Update Error Codes](errorcode-update.md).
1134
1135| ID      | Error Message                                                 |
1136| -------  | ---------------------------------------------------- |
1137| 201      | Permission denied.       |
1138| 11500104 | IPC error.               |
1139
1140**Example**
1141
1142```ts
1143import { BusinessError } from '@kit.BasicServicesKit';
1144
1145updater.getUpgradePolicy(err: BusinessError, policy: update.UpgradePolicy) => {
1146  console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`);
1147  console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`);
1148});
1149```
1150
1151### getUpgradePolicy
1152
1153getUpgradePolicy(): Promise\<UpgradePolicy>
1154
1155Obtains the update policy. This API uses a promise to return the result.
1156
1157**System capability**: SystemCapability.Update.UpdateService
1158
1159**Required permission**: ohos.permission.UPDATE_SYSTEM
1160
1161**Return value**
1162
1163| Type                                      | Description                   |
1164| ---------------------------------------- | --------------------- |
1165| Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.|
1166
1167**Error codes**
1168
1169For details about the error codes, see [Update Error Codes](errorcode-update.md).
1170
1171| ID      | Error Message                                                 |
1172| -------  | ---------------------------------------------------- |
1173| 201      | Permission denied.       |
1174| 11500104 | IPC error.               |
1175
1176**Example**
1177
1178```ts
1179import { BusinessError } from '@kit.BasicServicesKit';
1180
1181updater.getUpgradePolicy().then((policy: update.UpgradePolicy) => {
1182  console.log(`policy downloadStrategy = ${policy.downloadStrategy}`);
1183  console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`);
1184}).catch((err: BusinessError)  => {
1185  console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`);
1186});
1187```
1188
1189### setUpgradePolicy
1190
1191setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void
1192
1193Sets the update policy. This API uses an asynchronous callback to return the result.
1194
1195**System capability**: SystemCapability.Update.UpdateService
1196
1197**Required permission**: ohos.permission.UPDATE_SYSTEM
1198
1199**Parameters**
1200
1201| Name     | Type                             | Mandatory  | Description           |
1202| -------- | ------------------------------- | ---- | ------------- |
1203| policy   | [UpgradePolicy](#upgradepolicy) | Yes   | Update policy.         |
1204| callback | AsyncCallback\<void>            | Yes   | Callback used to return the result.|
1205
1206**Error codes**
1207
1208For details about the error codes, see [Update Error Codes](errorcode-update.md).
1209
1210| ID      | Error Message                                                 |
1211| -------  | ---------------------------------------------------- |
1212| 201      | Permission denied.       |
1213| 11500104 | IPC error.               |
1214
1215**Example**
1216
1217```ts
1218import { BusinessError } from '@kit.BasicServicesKit';
1219
1220const policy: update.UpgradePolicy = {
1221  downloadStrategy: false,
1222  autoUpgradeStrategy: false,
1223  autoUpgradePeriods: [ { start: 120, end: 240 }] // Automatic update period, in minutes
1224};
1225updater.setUpgradePolicy(policy, (err: BusinessError) => {
1226  console.log(`setUpgradePolicy result: ${err}`);
1227});
1228```
1229
1230### setUpgradePolicy
1231
1232setUpgradePolicy(policy: UpgradePolicy): Promise\<void>
1233
1234Sets the update policy. This API uses a promise to return the result.
1235
1236**System capability**: SystemCapability.Update.UpdateService
1237
1238**Required permission**: ohos.permission.UPDATE_SYSTEM
1239
1240**Parameters**
1241
1242| Name   | Type                             | Mandatory  | Description  |
1243| ------ | ------------------------------- | ---- | ---- |
1244| policy | [UpgradePolicy](#upgradepolicy) | Yes   | Update policy.|
1245
1246**Return value**
1247
1248| Type            | Description                 |
1249| -------------- | ------------------- |
1250| Promise\<void> | Promise that returns no value.|
1251
1252**Error codes**
1253
1254For details about the error codes, see [Update Error Codes](errorcode-update.md).
1255
1256| ID      | Error Message                                                 |
1257| -------  | ---------------------------------------------------- |
1258| 201      | Permission denied.       |
1259| 11500104 | IPC error.               |
1260
1261**Example**
1262
1263```ts
1264import { BusinessError } from '@kit.BasicServicesKit';
1265
1266const policy: update.UpgradePolicy = {
1267  downloadStrategy: false,
1268  autoUpgradeStrategy: false,
1269  autoUpgradePeriods: [ { start: 120, end: 240 }] // Automatic update period, in minutes
1270};
1271updater.setUpgradePolicy(policy).then(() => {
1272  console.log(`setUpgradePolicy success`);
1273}).catch((err: BusinessError) => {
1274  console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`);
1275});
1276```
1277
1278###  terminateUpgrade
1279
1280terminateUpgrade(callback: AsyncCallback\<void>): void
1281
1282Terminates the update. This API uses an asynchronous callback to return the result.
1283
1284**System capability**: SystemCapability.Update.UpdateService
1285
1286**Required permission**: ohos.permission.UPDATE_SYSTEM
1287
1288**Parameters**
1289
1290| Name     | Type                  | Mandatory  | Description                                    |
1291| -------- | -------------------- | ---- | -------------------------------------- |
1292| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
1293
1294**Error codes**
1295
1296For details about the error codes, see [Update Error Codes](errorcode-update.md).
1297
1298| ID      | Error Message                                                 |
1299| -------  | ---------------------------------------------------- |
1300| 201      | Permission denied.       |
1301| 11500104 | IPC error.               |
1302
1303**Example**
1304
1305```ts
1306import { BusinessError } from '@kit.BasicServicesKit';
1307
1308updater.terminateUpgrade((err: BusinessError) => {
1309  console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
1310});
1311```
1312
1313### terminateUpgrade
1314
1315terminateUpgrade(): Promise\<void>
1316
1317Terminates the update. This API uses a promise to return the result.
1318
1319**System capability**: SystemCapability.Update.UpdateService
1320
1321**Required permission**: ohos.permission.UPDATE_SYSTEM
1322
1323**Return value**
1324
1325| Type            | Description                        |
1326| -------------- | -------------------------- |
1327| Promise\<void> | Promise that returns no value.|
1328
1329**Error codes**
1330
1331For details about the error codes, see [Update Error Codes](errorcode-update.md).
1332
1333| ID      | Error Message                                                 |
1334| -------  | ---------------------------------------------------- |
1335| 201      | Permission denied.       |
1336| 11500104 | IPC error.               |
1337
1338**Example**
1339
1340```ts
1341import { BusinessError } from '@kit.BasicServicesKit';
1342
1343updater.terminateUpgrade().then(() => {
1344  console.log(`terminateUpgrade success`);
1345}).catch((err: BusinessError) => {
1346  console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
1347});
1348```
1349
1350
1351### on
1352on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void
1353
1354Enables listening for update events. This API uses an asynchronous callback to return the result.
1355
1356**System capability**: SystemCapability.Update.UpdateService
1357
1358**Parameters**
1359
1360| Name              | Type                                      | Mandatory  | Description  |
1361| ----------------- | ---------------------------------------- | ---- | ---- |
1362| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
1363| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|
1364
1365
1366**Example**
1367
1368```ts
1369const eventClassifyInfo: update.EventClassifyInfo = {
1370  eventClassify: update.EventClassify.TASK, // Listening for update events
1371  extraInfo: ""
1372};
1373
1374updater.on(eventClassifyInfo, (eventInfo: update.EventInfo) => {
1375  console.log("updater on " + JSON.stringify(eventInfo));
1376});
1377```
1378
1379### off
1380off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void
1381
1382Disables listening for update events. This API uses an asynchronous callback to return the result.
1383
1384**System capability**: SystemCapability.Update.UpdateService
1385
1386**Parameters**
1387
1388| Name              | Type                                      | Mandatory  | Description  |
1389| ----------------- | ---------------------------------------- | ---- | ---- |
1390| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
1391| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | No   | Event callback.|
1392
1393
1394**Example**
1395
1396```ts
1397const eventClassifyInfo: update.EventClassifyInfo = {
1398  eventClassify: update.EventClassify.TASK, // Listening for update events
1399  extraInfo: ""
1400};
1401
1402updater.off(eventClassifyInfo, (eventInfo: update.EventInfo) => {
1403  console.log("updater off " + JSON.stringify(eventInfo));
1404});
1405```
1406
1407## Restorer
1408
1409### factoryReset
1410
1411factoryReset(callback: AsyncCallback\<void>): void
1412
1413Restores the scale to its factory settings. This API uses an asynchronous callback to return the result.
1414
1415**System capability**: SystemCapability.Update.UpdateService
1416
1417**Required permission**: ohos.permission.FACTORY_RESET
1418
1419**Parameters**
1420
1421| Name     | Type                  | Mandatory  | Description                                    |
1422| -------- | -------------------- | ---- | -------------------------------------- |
1423| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the operation fails, **err** is an error object and a callback is returned. If the the operation is successful, **err** is undefined and no callback is returned.|
1424
1425**Error codes**
1426
1427For details about the error codes, see [Update Error Codes](errorcode-update.md).
1428
1429| ID      | Error Message                                                 |
1430| -------  | ---------------------------------------------------- |
1431| 201      | Permission denied.       |
1432| 11500104 | IPC error.               |
1433
1434**Example**
1435
1436```ts
1437restorer.factoryReset((err) => {
1438  console.log(`factoryReset error ${JSON.stringify(err)}`);
1439});
1440```
1441
1442### factoryReset
1443
1444factoryReset(): Promise\<void>
1445
1446Restores the scale to its factory settings. This API uses a promise to return the result.
1447
1448**System capability**: SystemCapability.Update.UpdateService
1449
1450**Required permission**: ohos.permission.FACTORY_RESET
1451
1452**Return value**
1453
1454| Type            | Description                        |
1455| -------------- | -------------------------- |
1456| Promise\<void> | Promise that returns no value. If the operation fails, a callback is returned. If the the operation is successful, no callback is returned.|
1457
1458**Error codes**
1459
1460For details about the error codes, see [Update Error Codes](errorcode-update.md).
1461
1462| ID      | Error Message                                                 |
1463| -------  | ---------------------------------------------------- |
1464| 201      | Permission denied.       |
1465| 11500104 | IPC error.               |
1466
1467**Example**
1468
1469```ts
1470import { BusinessError } from '@kit.BasicServicesKit';
1471
1472restorer.factoryReset().then(() => {
1473  console.log(`factoryReset success`);
1474}).catch((err: BusinessError) => {
1475  console.log(`factoryReset error ${JSON.stringify(err)}`);
1476});
1477```
1478
1479## LocalUpdater
1480
1481### verifyUpgradePackage
1482
1483verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<void>): void
1484
1485Verifies the update package. This API uses an asynchronous callback to return the result.
1486
1487**System capability**: SystemCapability.Update.UpdateService
1488
1489**Required permission**: ohos.permission.UPDATE_SYSTEM
1490
1491**Parameters**
1492
1493| Name        | Type                         | Mandatory  | Description              |
1494| ----------- | --------------------------- | ---- | ---------------- |
1495| upgradeFile | [UpgradeFile](#upgradefile) | Yes   | Update file.            |
1496| certsFile   | string                      | Yes   | Path of the certificate file.          |
1497| callback    | AsyncCallback\<void>        | Yes   | Callback used to return the result.|
1498
1499**Error codes**
1500
1501For details about the error codes, see [Update Error Codes](errorcode-update.md).
1502
1503| ID      | Error Message                                                 |
1504| -------  | ---------------------------------------------------- |
1505| 201      | Permission denied.       |
1506| 401      | Parameter verification failed.    |
1507| 11500104 | IPC error.               |
1508
1509**Example**
1510
1511```ts
1512const upgradeFile: update.UpgradeFile = {
1513  fileType: update.ComponentType.OTA, // OTA package
1514  filePath: "path" // Path of the local update package
1515};
1516
1517localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => {
1518  console.log(`factoryReset error ${JSON.stringify(err)}`);
1519});
1520```
1521
1522### verifyUpgradePackage
1523
1524verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void>
1525
1526Verifies the update package. This API uses a promise to return the result.
1527
1528**System capability**: SystemCapability.Update.UpdateService
1529
1530**Required permission**: ohos.permission.UPDATE_SYSTEM
1531
1532**Parameters**
1533
1534| Name        | Type                         | Mandatory  | Description    |
1535| ----------- | --------------------------- | ---- | ------ |
1536| upgradeFile | [UpgradeFile](#upgradefile) | Yes   | Update file.  |
1537| certsFile   | string                      | Yes   | Path of the certificate file.|
1538
1539**Return value**
1540
1541| Type            | Description                    |
1542| -------------- | ---------------------- |
1543| Promise\<void> | Promise used to return the result.|
1544
1545**Error codes**
1546
1547For details about the error codes, see [Update Error Codes](errorcode-update.md).
1548
1549| ID      | Error Message                                                 |
1550| -------  | ---------------------------------------------------- |
1551| 201      | Permission denied.       |
1552| 401      | Parameter verification failed.    |
1553| 11500104 | IPC error.               |
1554
1555**Example**
1556
1557```ts
1558import { BusinessError } from '@kit.BasicServicesKit';
1559
1560const upgradeFile: update.UpgradeFile = {
1561  fileType: update.ComponentType.OTA, // OTA package
1562  filePath: "path" // Path of the local update package
1563};
1564localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => {
1565  console.log(`verifyUpgradePackage success`);
1566}).catch((err: BusinessError) => {
1567  console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`);
1568});
1569```
1570
1571### applyNewVersion
1572applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: AsyncCallback\<void>): void
1573
1574Installs the update package. This API uses an asynchronous callback to return the result.
1575
1576**System capability**: SystemCapability.Update.UpdateService
1577
1578**Required permission**: ohos.permission.UPDATE_SYSTEM
1579
1580**Parameters**
1581
1582| Name        | Type                                | Mandatory  | Description                                     |
1583| ----------- | ---------------------------------- | ---- | --------------------------------------- |
1584| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes   | Update file.                                   |
1585| callback    | AsyncCallback\<void>               | Yes   | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
1586
1587**Error codes**
1588
1589For details about the error codes, see [Update Error Codes](errorcode-update.md).
1590
1591| ID      | Error Message                                                 |
1592| -------  | ---------------------------------------------------- |
1593| 201      | Permission denied.       |
1594| 401      | Parameter verification failed.    |
1595| 11500104 | IPC error.               |
1596
1597**Example**
1598
1599```ts
1600const upgradeFiles: Array<update.UpgradeFile> = [{
1601  fileType: update.ComponentType.OTA, // OTA package
1602  filePath: "path" // Path of the local update package
1603}];
1604
1605localUpdater.applyNewVersion(upgradeFiles, (err) => {
1606  console.log(`applyNewVersion error ${JSON.stringify(err)}`);
1607});
1608```
1609
1610### applyNewVersion
1611
1612applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void>
1613
1614Installs the update package. This API uses a promise to return the result.
1615
1616**System capability**: SystemCapability.Update.UpdateService
1617
1618**Required permission**: ohos.permission.UPDATE_SYSTEM
1619
1620**Return value**
1621
1622| Type            | Description                        |
1623| -------------- | -------------------------- |
1624| Promise\<void> | Promise that returns no value.|
1625
1626**Error codes**
1627
1628For details about the error codes, see [Update Error Codes](errorcode-update.md).
1629
1630| ID      | Error Message                                                 |
1631| -------  | ---------------------------------------------------- |
1632| 201      | Permission denied.       |
1633| 401      | Parameter verification failed.    |
1634| 11500104 | IPC error.               |
1635
1636**Example**
1637
1638```ts
1639import { BusinessError } from '@kit.BasicServicesKit';
1640
1641const upgradeFiles: Array<update.UpgradeFile> = [{
1642  fileType: update.ComponentType.OTA, // OTA package
1643  filePath: "path" // Path of the local update package
1644}];
1645localUpdater.applyNewVersion(upgradeFiles).then(() => {
1646  console.log(`applyNewVersion success`);
1647}).catch((err: BusinessError) => {
1648  console.log(`applyNewVersion error ${JSON.stringify(err)}`);
1649});
1650```
1651
1652### on
1653on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void
1654
1655Enables listening for update events. This API uses an asynchronous callback to return the result.
1656
1657**System capability**: SystemCapability.Update.UpdateService
1658
1659**Parameters**
1660
1661| Name              | Type                                      | Mandatory  | Description  |
1662| ----------------- | ---------------------------------------- | ---- | ---- |
1663| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
1664| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | Yes   | Event callback.|
1665
1666
1667**Example**
1668
1669```ts
1670const eventClassifyInfo: update.EventClassifyInfo = {
1671  eventClassify: update.EventClassify.TASK, // Listening for update events
1672  extraInfo: ""
1673};
1674
1675let onTaskUpdate: update.UpgradeTaskCallback = (eventInfo: update.EventInfo) => {
1676  console.log(`on eventInfo id `, eventInfo.eventId);
1677};
1678
1679localUpdater.on(eventClassifyInfo, onTaskUpdate);
1680```
1681
1682### off
1683off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void
1684
1685Disables listening for update events. This API uses an asynchronous callback to return the result.
1686
1687**System capability**: SystemCapability.Update.UpdateService
1688
1689**Parameters**
1690
1691| Name              | Type                                      | Mandatory  | Description  |
1692| ----------------- | ---------------------------------------- | ---- | ---- |
1693| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo)  | Yes   | Event information.|
1694| taskCallback      | [UpgradeTaskCallback](#upgradetaskcallback) | No   | Event callback.|
1695
1696
1697**Example**
1698
1699```ts
1700const eventClassifyInfo: update.EventClassifyInfo = {
1701  eventClassify: update.EventClassify.TASK, // Listening for update events
1702  extraInfo: ""
1703};
1704
1705let onTaskUpdate: update.UpgradeTaskCallback = (eventInfo: update.EventInfo) => {
1706  console.log(`on eventInfo id `, eventInfo.eventId);
1707};
1708
1709localUpdater.off(eventClassifyInfo, onTaskUpdate);
1710```
1711
1712## UpgradeInfo
1713
1714Represents update information.
1715
1716**System capability**: SystemCapability.Update.UpdateService
1717
1718| Name          | Type                         | Mandatory  | Description    |
1719| ------------ | ----------------------------- | ---- | ------ |
1720| upgradeApp   | string                        | Yes   | Application package name. |
1721| businessType | [BusinessType](#businesstype) | Yes   | Update service type.|
1722
1723## BusinessType
1724
1725Enumerates update service types.
1726
1727**System capability**: SystemCapability.Update.UpdateService
1728
1729| Name     | Type                               | Mandatory  | Description  |
1730| ------- | ----------------------------------- | ---- | ---- |
1731| vendor  | [BusinessVendor](#businessvendor)   | Yes   | Supplier or vendor. |
1732| subType | [BusinessSubType](#businesssubtype) | Yes   | Represents an update type. |
1733
1734## CheckResult
1735
1736Represents the package check result.
1737
1738**System capability**: SystemCapability.Update.UpdateService
1739
1740| Name               | Type                             | Mandatory  | Description    |
1741| ----------------- | --------------------------------- | ---- | ------ |
1742| isExistNewVersion | boolean                              | Yes   | Whether a new version is available.<br>The value **true** indicates that a new version is available, and the value **false** indicates the opposite.|
1743| newVersionInfo    | [NewVersionInfo](#newversioninfo) | No   | Information about the new version. |
1744
1745## NewVersionInfo
1746
1747Represents information about the new version.
1748
1749**System capability**: SystemCapability.Update.UpdateService
1750
1751| Name               | Type                                    | Mandatory  | Description  |
1752| ----------------- | ---------------------------------------- | ---- | ---- |
1753| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
1754| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes   | Version components.|
1755
1756## VersionDigestInfo
1757
1758Represents version digest information.
1759
1760**System capability**: SystemCapability.Update.UpdateService
1761
1762| Name           | Type  | Mandatory  | Description  |
1763| ------------- | ------ | ---- | ---- |
1764| versionDigest | string | Yes   | Version digest information.|
1765
1766## VersionComponent
1767
1768Represents a version component.
1769
1770**System capability**: SystemCapability.Update.UpdateService
1771
1772| Name             | Type                               | Mandatory  | Description      |
1773| --------------- | ----------------------------------- | ---- | -------- |
1774| componentId     | string                              | Yes   | Component ID.    |
1775| componentType   | [ComponentType](#componenttype)     | Yes   | Component type.    |
1776| upgradeAction   | [UpgradeAction](#upgradeaction)     | Yes   | Update mode.    |
1777| displayVersion  | string                              | Yes   | Display version number.   |
1778| innerVersion    | string                              | Yes   | Internal version number.     |
1779| size            | number                              | Yes   | Size of the update package, in bytes.   |
1780| effectiveMode   | [EffectiveMode](#effectivemode)     | Yes   | Effective mode.    |
1781| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes   | Information about the version description file.|
1782
1783## DescriptionOptions
1784
1785Represents options of the description file.
1786
1787**System capability**: SystemCapability.Update.UpdateService
1788
1789| Name      | Type                                   | Mandatory  | Description    |
1790| -------- | --------------------------------------- | ---- | ------ |
1791| format   | [DescriptionFormat](#descriptionformat) | Yes   | Format of the description file.|
1792| language | string                                  | Yes   | Language of the description file.|
1793
1794## ComponentDescription
1795
1796Represents a component description file.
1797
1798**System capability**: SystemCapability.Update.UpdateService
1799
1800| Name             | Type                               | Mandatory  | Description    |
1801| --------------- | ----------------------------------- | ---- | ------ |
1802| componentId     | string                              | Yes   | Component ID.  |
1803| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes   | Information about the description file.|
1804
1805## DescriptionInfo
1806
1807Represents information about the version description file.
1808
1809**System capability**: SystemCapability.Update.UpdateService
1810
1811| Name             | Type                               | Mandatory  | Description    |
1812| --------------- | ----------------------------------- | ---- | ------ |
1813| descriptionType | [DescriptionType](#descriptiontype) | Yes   | Type of the description file.|
1814| content         | string                              | Yes   | Content of the description file.|
1815
1816## CurrentVersionInfo
1817
1818Represents information about the current version.
1819
1820**System capability**: SystemCapability.Update.UpdateService
1821
1822| Name               | Type                                    | Mandatory  | Description   |
1823| ----------------- | ---------------------------------------- | ---- | ----- |
1824| osVersion         | string                                   | Yes   | System version number.|
1825| deviceName        | string                                   | Yes   | Device name.  |
1826| versionComponents | Array\<[VersionComponent](#versioncomponent)> | No   | Version components. |
1827
1828## DownloadOptions
1829
1830Represents download options.
1831
1832**System capability**: SystemCapability.Update.UpdateService
1833
1834| Name          | Type               | Mandatory  | Description  |
1835| ------------ | ------------------- | ---- | ---- |
1836| allowNetwork | [NetType](#nettype) | Yes   | Network type.|
1837| order        | [Order](#order)     | Yes   | Update command.|
1838
1839## ResumeDownloadOptions
1840
1841Represents options for resuming download.
1842
1843**System capability**: SystemCapability.Update.UpdateService
1844
1845| Name          | Type               | Mandatory  | Description  |
1846| ------------ | ------------------- | ---- | ---- |
1847| allowNetwork | [NetType](#nettype) | Yes   | Network type.|
1848
1849## PauseDownloadOptions
1850
1851Represents options for pausing download.
1852
1853**System capability**: SystemCapability.Update.UpdateService
1854
1855| Name               | Type| Mandatory  | Description      |
1856| ----------------- | ---- | ---- | -------- |
1857| isAllowAutoResume | boolean | Yes   | Whether to allow automatic resuming of download.<br>The value **true** indicates that automatic resuming is allowed, and the value **false** indicates the opposite.|
1858
1859## UpgradeOptions
1860
1861Represents update options.
1862
1863**System capability**: SystemCapability.Update.UpdateService
1864
1865| Name   | Type           | Mandatory  | Description  |
1866| ----- | --------------- | ---- | ---- |
1867| order | [Order](#order) | Yes   | Update command.|
1868
1869## ClearOptions
1870
1871Represents options for clearing errors.
1872
1873**System capability**: SystemCapability.Update.UpdateService
1874
1875| Name    | Type                           | Mandatory  | Description  |
1876| ------ | ------------------------------- | ---- | ---- |
1877| status | [UpgradeStatus](#upgradestatus) | Yes   | Error status.|
1878
1879## UpgradePolicy
1880
1881Represents an update policy.
1882
1883**System capability**: SystemCapability.Update.UpdateService
1884
1885| Name                 | Type                                   | Mandatory  | Description     |
1886| ------------------- | --------------------------------------- | ---- | ------- |
1887| downloadStrategy    | boolean                        | Yes   | Automatic download policy.<br>The value **true** indicates that automatic download is supported, and the value **false** indicates the opposite.|
1888| autoUpgradeStrategy | boolean                        | Yes   | Automatic update policy.<br>The value **true** indicates that automatic update is supported, and the value **false** indicates the opposite.|
1889| autoUpgradePeriods  | Array\<[UpgradePeriod](#upgradeperiod)> | Yes   | Automatic update period.|
1890
1891## UpgradePeriod
1892
1893Represents an automatic update period.
1894
1895**System capability**: SystemCapability.Update.UpdateService
1896
1897| Name   | Type  | Mandatory  | Description  |
1898| ----- | ------ | ---- | ---- |
1899| start | number | Yes   | Start time.|
1900| end   | number | Yes   | End time.|
1901
1902## TaskInfo
1903
1904Task information.
1905
1906**System capability**: SystemCapability.Update.UpdateService
1907
1908| Name       | Type                 | Mandatory  | Description    |
1909| --------- | --------------------- | ---- | ------ |
1910| existTask |  boolean                  | Yes   | Whether a task exists.<br>The value **true** indicates that the task exists, and the value **false** indicates the opposite.|
1911| taskBody  | [TaskBody](#taskbody) | Yes   | Task data.  |
1912
1913## EventInfo
1914
1915Represents event information.
1916
1917**System capability**: SystemCapability.Update.UpdateService
1918
1919| Name      | Type                 | Mandatory  | Description  |
1920| -------- | --------------------- | ---- | ---- |
1921| eventId  | [EventId](#eventid)   | Yes   | Event ID.|
1922| taskBody | [TaskBody](#taskbody) | Yes   | Task data.|
1923
1924## TaskBody
1925
1926Represents task data.
1927
1928**System capability**: SystemCapability.Update.UpdateService
1929
1930| Name               | Type                                    | Mandatory  | Description  |
1931| ----------------- | ---------------------------------------- | ---- | ---- |
1932| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo)  | Yes   | Version digest information.|
1933| status            | [UpgradeStatus](#upgradestatus)          | Yes   | Update status.|
1934| subStatus         | number                                   | No   | Sub-status. |
1935| progress          | number                                   | Yes   | Progress.  |
1936| installMode       | number                                   | Yes   | Installation mode.|
1937| errorMessages     | Array\<[ErrorMessage](#errormessage)>    | No   | Error message.|
1938| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes   | Version components.|
1939
1940## ErrorMessage
1941
1942Represents an error message.
1943
1944**System capability**: SystemCapability.Update.UpdateService
1945
1946| Name          | Type  | Mandatory  | Description  |
1947| ------------ | ------ | ---- | ---- |
1948| errorCode    | number | Yes   | Error code. |
1949| errorMessage | string | Yes   | Error message.|
1950
1951## EventClassifyInfo
1952
1953Represents event type information.
1954
1955**System capability**: SystemCapability.Update.UpdateService
1956
1957| Name           | Type                           | Mandatory  | Description  |
1958| ------------- | ------------------------------- | ---- | ---- |
1959| eventClassify | [EventClassify](#eventclassify) | Yes   | Event type.|
1960| extraInfo     | string                          | Yes   | Additional information.|
1961
1962## UpgradeFile
1963
1964Represents an update file.
1965
1966**System capability**: SystemCapability.Update.UpdateService
1967
1968| Name      | Type                           | Mandatory  | Description  |
1969| -------- | ------------------------------- | ---- | ---- |
1970| fileType | [ComponentType](#componenttype) | Yes   | File type.|
1971| filePath | string                          | Yes   | File path.|
1972
1973## UpgradeTaskCallback
1974
1975(eventInfo: EventInfo): void
1976
1977Represents an event callback.
1978
1979**System capability**: SystemCapability.Update.UpdateService
1980
1981| Name       | Type                   | Mandatory  | Description  |
1982| --------- | ----------------------- | ---- | ---- |
1983| eventInfo | [EventInfo](#eventinfo) | Yes   | Event information.|
1984
1985## BusinessVendor
1986
1987Represents a device vendor.
1988
1989**System capability**: SystemCapability.Update.UpdateService
1990
1991| Name   | Value     | Description  |
1992| ------ | -------- | ---- |
1993| PUBLIC | "public" | Open source.  |
1994
1995## BusinessSubType
1996
1997Represents an update type.
1998
1999**System capability**: SystemCapability.Update.UpdateService
2000
2001| Name     | Value | Description  |
2002| -------- | ---- | ---- |
2003| FIRMWARE | 1    | Firmware.  |
2004
2005## ComponentType
2006
2007Represents a component type.
2008
2009**System capability**: SystemCapability.Update.UpdateService
2010
2011| Name | Value | Description  |
2012| ---- | ---- | ---- |
2013| OTA  | 1    | Firmware.  |
2014
2015## UpgradeAction
2016
2017Represents an update mode.
2018
2019**System capability**: SystemCapability.Update.UpdateService
2020
2021| Name     | Value       | Description  |
2022| -------- | ---------- | ---- |
2023| UPGRADE  | "upgrade"  | Differential package. |
2024| RECOVERY | "recovery" | Recovery package. |
2025
2026## EffectiveMode
2027
2028Represents an effective mode.
2029
2030**System capability**: SystemCapability.Update.UpdateService
2031
2032| Name          | Value | Description  |
2033| ------------- | ---- | ---- |
2034| COLD          | 1    | Cold update. |
2035| LIVE          | 2    | Live update. |
2036| LIVE_AND_COLD | 3    | Hybrid live and cold update.|
2037
2038## DescriptionType
2039
2040Represents a description file type.
2041
2042**System capability**: SystemCapability.Update.UpdateService
2043
2044| Name    | Value | Description  |
2045| ------- | ---- | ---- |
2046| CONTENT | 0    | Content.  |
2047| URI     | 1    | Link.  |
2048
2049## DescriptionFormat
2050
2051Represents a description file format.
2052
2053**System capability**: SystemCapability.Update.UpdateService
2054
2055| Name       | Value | Description  |
2056| ---------- | ---- | ---- |
2057| STANDARD   | 0    | Standard format.|
2058| SIMPLIFIED | 1    | Simple format.|
2059
2060## NetType
2061
2062Represents a network type.
2063
2064**System capability**: SystemCapability.Update.UpdateService
2065
2066| Name              | Value | Description       |
2067| ----------------- | ---- | --------- |
2068| CELLULAR          | 1    | Data network.     |
2069| METERED_WIFI      | 2    | Wi-Fi hotspot.   |
2070| NOT_METERED_WIFI  | 4    | Non Wi-Fi hotspot.  |
2071| WIFI              | 6    | Wi-Fi.     |
2072| CELLULAR_AND_WIFI | 7    | Data network and Wi-Fi.|
2073
2074## Order
2075
2076Represents an update command.
2077
2078**System capability**: SystemCapability.Update.UpdateService
2079
2080| Name                 | Value | Description   |
2081| -------------------- | ---- | ----- |
2082| DOWNLOAD             | 1    | Download.   |
2083| INSTALL              | 2    | Install.   |
2084| DOWNLOAD_AND_INSTALL | 3    | Download and install.|
2085| APPLY                | 4    | Apply.   |
2086| INSTALL_AND_APPLY    | 6    | Install and apply.|
2087
2088## UpgradeStatus
2089
2090Enumerates update states.
2091
2092**System capability**: SystemCapability.Update.UpdateService
2093
2094| Name             | Value | Description  |
2095| ---------------- | ---- | ---- |
2096| WAITING_DOWNLOAD | 20   | Waiting for download. |
2097| DOWNLOADING      | 21   | Downloading. |
2098| DOWNLOAD_PAUSED  | 22   | Download paused.|
2099| DOWNLOAD_FAIL    | 23   | Download failed.|
2100| WAITING_INSTALL  | 30   | Waiting for installation. |
2101| UPDATING         | 31   | Updating. |
2102| WAITING_APPLY    | 40   | Waiting for applying the update. |
2103| APPLYING         | 41   | Applying the update. |
2104| UPGRADE_SUCCESS  | 50   | Update succeeded.|
2105| UPGRADE_FAIL     | 51   | Update failed.|
2106
2107## EventClassify
2108
2109Represents an event type.
2110
2111**System capability**: SystemCapability.Update.UpdateService
2112
2113| Name  | Value       | Description  |
2114| ---- | ---------- | ---- |
2115| TASK | 0x01000000 | Task event.|
2116
2117## EventId
2118
2119Enumerates event IDs.
2120
2121**System capability**: SystemCapability.Update.UpdateService
2122
2123| Name                    | Value       | Description    |
2124| ---------------------- | ---------- | ------ |
2125| EVENT_TASK_BASE        | EventClassify.TASK | Task event.  |
2126| EVENT_TASK_RECEIVE     | 0x01000001 | Task received.  |
2127| EVENT_TASK_CANCEL      | 0x01000002 | Task cancelled.  |
2128| EVENT_DOWNLOAD_WAIT    | 0x01000003 | Waiting for download.   |
2129| EVENT_DOWNLOAD_START   | 0x01000004 | Download started.  |
2130| EVENT_DOWNLOAD_UPDATE  | 0x01000005 | Download progress update.|
2131| EVENT_DOWNLOAD_PAUSE   | 0x01000006 | Download paused.  |
2132| EVENT_DOWNLOAD_RESUME  | 0x01000007 | Download resumed.  |
2133| EVENT_DOWNLOAD_SUCCESS | 0x01000008 | Download succeeded.  |
2134| EVENT_DOWNLOAD_FAIL    | 0x01000009 | Download failed.  |
2135| EVENT_UPGRADE_WAIT     | 0x0100000A | Waiting for update.   |
2136| EVENT_UPGRADE_START    | 0x0100000B | Update started.  |
2137| EVENT_UPGRADE_UPDATE   | 0x0100000C | Update in progress.   |
2138| EVENT_APPLY_WAIT       | 0x0100000D | Waiting for applying the update.   |
2139| EVENT_APPLY_START      | 0x0100000E | Applying the update.  |
2140| EVENT_UPGRADE_SUCCESS  | 0x0100000F | Update succeeded.  |
2141| EVENT_UPGRADE_FAIL     | 0x01000010 | Update failed.  |
2142