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