• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback, BusinessError } from "./basic";
17
18/**
19 * A static class to do update for device.
20 *
21 * @since 9
22 * @syscap SystemCapability.Update.UpdateService
23 * @systemapi hide for inner use.
24 */
25declare namespace update {
26    /**
27     * Get online update handler for the calling device.
28     *
29     * @param { UpgradeInfo } upgradeInfo - Indicates client app and business type.
30     * @returns { Updater } online update handler to perform online update.
31     * @since 9
32     */
33    function getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater;
34
35    /**
36     * Get restore handler.
37     *
38     * @returns { Restorer } restore handler to perform factory reset.
39     * @since 9
40     */
41    function getRestorer(): Restorer;
42
43    /**
44     * Get local update handler.
45     *
46     * @returns { LocalUpdater } local update handler to perform local update.
47     * @since 9
48     */
49    function getLocalUpdater(): LocalUpdater;
50
51    /**
52     * A static class to do online update.
53     *
54     * @since 9
55     * @syscap SystemCapability.Update.UpdateService
56     * @systemapi hide for inner use.
57     */
58    export interface Updater {
59        /**
60         * Check new version.
61         *
62         * @permission ohos.permission.UPDATE_SYSTEM
63         * @param { AsyncCallback<CheckResult> } callback - Callback used to return the result.
64         * @throws { BusinessError } 201 - Permission denied.
65         * @throws { BusinessError } 11500104 - IPC error.
66         * @since 9
67         */
68        checkNewVersion(callback: AsyncCallback<CheckResult>): void;
69
70        /**
71         * Check new version.
72         *
73         * @permission ohos.permission.UPDATE_SYSTEM
74         * @returns { Promise<CheckResult> } Promise used to return the result.
75         * @throws { BusinessError } 201 - Permission denied.
76         * @throws { BusinessError } 11500104 - IPC error.
77         * @since 9
78         */
79        checkNewVersion(): Promise<CheckResult>;
80
81        /**
82         * Get new version.
83         *
84         * @permission ohos.permission.UPDATE_SYSTEM
85         * @param { AsyncCallback<CheckResult> } callback - Callback used to return the result.
86         * @throws { BusinessError } 201 - Permission denied.
87         * @throws { BusinessError } 11500104 - IPC error.
88         * @since 9
89         */
90        getNewVersionInfo(callback: AsyncCallback<NewVersionInfo>): void;
91
92        /**
93         * Get new version.
94         *
95         * @permission ohos.permission.UPDATE_SYSTEM
96         * @returns { Promise<NewVersionInfo> } Promise used to return the result.
97         * @throws { BusinessError } 201 - Permission denied.
98         * @throws { BusinessError } 11500104 - IPC error.
99         * @since 9
100         */
101        getNewVersionInfo(): Promise<NewVersionInfo>;
102
103        /**
104         * Get new version description.
105         *
106         * @permission ohos.permission.UPDATE_SYSTEM
107         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
108         * @param { DescriptionOptions } descriptionOptions - Options of the description file.
109         * @param { AsyncCallback<Array<ComponentDescription>> } callback - Callback used to return the result.
110         * @throws { BusinessError } 201 - Permission denied.
111         * @throws { BusinessError } 401 - Parameter error.
112         * @throws { BusinessError } 11500104 - IPC error.
113         * @since 9
114         */
115        getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback<Array<ComponentDescription>>): void;
116
117        /**
118         * Get new version description.
119         *
120         * @permission ohos.permission.UPDATE_SYSTEM
121         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
122         * @param { DescriptionOptions } descriptionOptions - Options of the description file.
123         * @returns { Promise<Array<ComponentDescription>> } Promise used to return the result.
124         * @throws { BusinessError } 201 - Permission denied.
125         * @throws { BusinessError } 401 - Parameter error.
126         * @throws { BusinessError } 11500104 - IPC error.
127         * @since 9
128         */
129        getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise<Array<ComponentDescription>>;
130
131        /**
132         * Get current version.
133         *
134         * @permission ohos.permission.UPDATE_SYSTEM
135         * @param { AsyncCallback<Array<CurrentVersionInfo>> } callback - Callback used to return the result.
136         * @throws { BusinessError } 201 - Permission denied.
137         * @throws { BusinessError } 11500104 - IPC error.
138         * @since 9
139         */
140        getCurrentVersionInfo(callback: AsyncCallback<CurrentVersionInfo>): void;
141
142        /**
143         * Get current version.
144         *
145         * @permission ohos.permission.UPDATE_SYSTEM
146         * @@returns { Promise<Array<CurrentVersionInfo>> } Promise used to return the result.
147         * @throws { BusinessError } 201 - Permission denied.
148         * @throws { BusinessError } 11500104 - IPC error.
149         * @since 9
150         */
151        getCurrentVersionInfo(): Promise<CurrentVersionInfo>;
152
153        /**
154         * Get current version description.
155         *
156         * @permission ohos.permission.UPDATE_SYSTEM
157         * @param { DescriptionOptions } descriptionOptions - Options of the description file.
158         * @param { AsyncCallback<Array<ComponentDescription>> } callback - Callback used to return the result.
159         * @throws { BusinessError } 201 - Permission denied.
160         * @throws { BusinessError } 401 - Parameter error.
161         * @throws { BusinessError } 11500104 - IPC error.
162         * @since 9
163         */
164        getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback<Array<ComponentDescription>>): void;
165
166        /**
167         * Get current version description.
168         *
169         * @permission ohos.permission.UPDATE_SYSTEM
170         * @param { DescriptionOptions } descriptionOptions - Options of the description file.
171         * @returns { Promise<Array<ComponentDescription> } Promise used to return the result.
172         * @throws { BusinessError } 201 - Permission denied.
173         * @throws { BusinessError } 401 - Parameter error.
174         * @throws { BusinessError } 11500104 - IPC error.
175         * @since 9
176         */
177        getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise<Array<ComponentDescription>>;
178
179        /**
180         * Get task info.
181         *
182         * @permission ohos.permission.UPDATE_SYSTEM
183         * @param { AsyncCallback<TaskInfo> } callback - Callback used to return the result.
184         * @throws { BusinessError } 201 - Permission denied.
185         * @throws { BusinessError } 11500104 - IPC error.
186         * @since 9
187         */
188        getTaskInfo(callback: AsyncCallback<TaskInfo>): void;
189
190        /**
191         * Get task info.
192         *
193         * @permission ohos.permission.UPDATE_SYSTEM
194         * @returns { Promise<TaskInfo> } Promise used to return the result.
195         * @throws { BusinessError } 201 - Permission denied.
196         * @throws { BusinessError } 11500104 - IPC error.
197         * @since 9
198         */
199        getTaskInfo(): Promise<TaskInfo>;
200
201        /**
202         * Trigger download new version packages.
203         * Apps should listen to task update event
204         *
205         * @permission ohos.permission.UPDATE_SYSTEM
206         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
207         * @param { DownloadOptions } downloadOptions - Download options.
208         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
209         * @throws { BusinessError } 201 - Permission denied.
210         * @throws { BusinessError } 401 - Parameter error.
211         * @throws { BusinessError } 11500104 - IPC error.
212         * @since 9
213         */
214        download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, callback: AsyncCallback<void>): void;
215
216        /**
217         * Trigger download new version packages.
218         * Apps should listen to task update event
219         *
220         * @permission ohos.permission.UPDATE_SYSTEM
221         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
222         * @param { DownloadOptions } downloadOptions - Download options.
223         * @returns { Promise<void> } Promise that returns no value.
224         * @throws { BusinessError } 201 - Permission denied.
225         * @throws { BusinessError } 401 - Parameter error.
226         * @throws { BusinessError } 11500104 - IPC error.
227         * @since 9
228         */
229        download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions): Promise<void>;
230
231        /**
232         * Resume download new version packages.
233         * Apps should listen to task update event
234         *
235         * @permission ohos.permission.UPDATE_SYSTEM
236         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
237         * @param { ResumeDownloadOptions } resumeDownloadOptions - Options for resume download.
238         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
239         * @throws { BusinessError } 201 - Permission denied.
240         * @throws { BusinessError } 401 - Parameter error.
241         * @throws { BusinessError } 11500104 - IPC error.
242         * @since 9
243         */
244        resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback<void>): void;
245
246        /**
247         * Resume download new version packages.
248         * Apps should listen to task update event
249         *
250         * @permission ohos.permission.UPDATE_SYSTEM
251         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
252         * @param { ResumeDownloadOptions } resumeDownloadOptions - Options for resume download.
253         * @returns { Promise<void> } Promise that returns no value.
254         * @throws { BusinessError } 201 - Permission denied.
255         * @throws { BusinessError } 401 - Parameter error.
256         * @throws { BusinessError } 11500104 - IPC error.
257         * @since 9
258         */
259        resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise<void>;
260
261        /**
262         * Pause download new version packages.
263         * Apps should listen to task update event
264         *
265         * @permission ohos.permission.UPDATE_SYSTEM
266         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
267         * @param { PauseDownloadOptions } pauseDownloadOptions - Options for pause download.
268         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
269         * @throws { BusinessError } 201 - Permission denied.
270         * @throws { BusinessError } 401 - Parameter error.
271         * @throws { BusinessError } 11500104 - IPC error.
272         * @since 9
273         */
274        pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback<void>): void;
275
276        /**
277         * Pause download new version packages.
278         * Apps should listen to task update event
279         *
280         * @permission ohos.permission.UPDATE_SYSTEM
281         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
282         * @param { PauseDownloadOptions } pauseDownloadOptions - Options for pause download.
283         * @returns { Promise<void> } Promise that returns no value.
284         * @throws { BusinessError } 201 - Permission denied.
285         * @throws { BusinessError } 401 - Parameter error.
286         * @throws { BusinessError } 11500104 - IPC error.
287         * @since 9
288         */
289        pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise<void>;
290
291        /**
292         * Install packages for the device.
293         * Apps should listen to task update event
294         *
295         * @permission ohos.permission.UPDATE_SYSTEM
296         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
297         * @param { UpgradeOptions } upgradeOptions - Update options.
298         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
299         * @throws { BusinessError } 201 - Permission denied.
300         * @throws { BusinessError } 401 - Parameter error.
301         * @throws { BusinessError } 11500104 - IPC error.
302         * @since 9
303         */
304        upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, callback: AsyncCallback<void>): void;
305
306        /**
307         * Install packages for the device.
308         * Apps should listen to task update event
309         *
310         * @permission ohos.permission.UPDATE_SYSTEM
311         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
312         * @param { UpgradeOptions } upgradeOptions - Update options.
313         * @param { Promise<void> } Promise that returns no value.
314         * @throws { BusinessError } 201 - Permission denied.
315         * @throws { BusinessError } 401 - Parameter error.
316         * @throws { BusinessError } 11500104 - IPC error.
317         * @since 9
318         */
319        upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): Promise<void>;
320
321        /**
322         * Clear error during upgrade.
323         *
324         * @permission ohos.permission.UPDATE_SYSTEM
325         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
326         * @param { ClearOptions } ClearOptions - Clear options.
327         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
328         * @throws { BusinessError } 201 - Permission denied.
329         * @throws { BusinessError } 401 - Parameter error.
330         * @throws { BusinessError } 11500104 - IPC error.
331         * @since 9
332         */
333        clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback<void>): void;
334
335        /**
336         * Clear error during upgrade.
337         *
338         * @permission ohos.permission.UPDATE_SYSTEM
339         * @param { VersionDigestInfo } versionDigestInfo - Version digest information.
340         * @param { ClearOptions } clearOptions - Clear options.
341         * @returns { Promise<void> } Promise that returns no value.
342         * @throws { BusinessError } 201 - Permission denied.
343         * @throws { BusinessError } 401 - Parameter error.
344         * @throws { BusinessError } 11500104 - IPC error.
345         * @since 9
346         */
347        clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise<void>;
348
349        /**
350         * Get current upgrade policy.
351         *
352         * @permission ohos.permission.UPDATE_SYSTEM
353         * @param { AsyncCallback<UpgradePolicy> } callback - Callback used to return the result.
354         * @throws { BusinessError } 201 - Permission denied.
355         * @throws { BusinessError } 11500104 - IPC error.
356         * @since 9
357         */
358        getUpgradePolicy(callback: AsyncCallback<UpgradePolicy>): void;
359
360        /**
361         * Get current upgrade policy.
362         *
363         * @permission ohos.permission.UPDATE_SYSTEM
364         * @returns { Promise<UpgradePolicy> } Promise used to return the result.
365         * @throws { BusinessError } 201 - Permission denied.
366         * @throws { BusinessError } 11500104 - IPC error.
367         * @since 9
368         */
369        getUpgradePolicy(): Promise<UpgradePolicy>;
370
371        /**
372         * Set upgrade policy.
373         *
374         * @permission ohos.permission.UPDATE_SYSTEM
375         * @param { UpgradePolicy } policy - Update policy.
376         * @param { AsyncCallback<void> } callback - Callback used to return the result.
377         * @throws { BusinessError } 201 - Permission denied.
378         * @throws { BusinessError } 11500104 - IPC error.
379         * @since 9
380         */
381        setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback<void>): void;
382
383        /**
384         * Set upgrade policy.
385         *
386         * @permission ohos.permission.UPDATE_SYSTEM
387         * @param { policy } UpgradePolicy - Update policy.
388         * @returns { Promise<void> } Promise that returns no value.
389         * @throws { BusinessError } 201 - Permission denied.
390         * @throws { BusinessError } 11500104 - IPC error.
391         * @since 9
392         */
393        setUpgradePolicy(policy: UpgradePolicy): Promise<void>;
394
395        /**
396         * Terminate upgrade task.
397         *
398         * @permission ohos.permission.UPDATE_SYSTEM
399         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, 'err' is 'undefined'; otherwise, 'err' is an 'Error' object.
400         * @throws { BusinessError } 201 - Permission denied.
401         * @throws { BusinessError } 11500104 - IPC error.
402         * @since 9
403         */
404        terminateUpgrade(callback: AsyncCallback<void>): void;
405
406        /**
407         * Terminate upgrade task.
408         *
409         * @permission ohos.permission.UPDATE_SYSTEM
410         * @returns { Promise<void> } Promise that returns no value.
411         * @throws { BusinessError } 201 - Permission denied.
412         * @throws { BusinessError } 11500104 - IPC error.
413         * @since 9
414         */
415        terminateUpgrade(): Promise<void>;
416
417        /**
418         * Subscribe task update events
419         *
420         * @param { EventClassifyInfo } eventClassifyInfo - Event information.
421         * @param { UpgradeTaskCallback } taskCallback - Event callback.
422         * @since 9
423         */
424        on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void;
425
426        /**
427         * Unsubscribe task update events
428         *
429         * @param { EventClassifyInfo } eventClassifyInfo - Event information.
430         * @param { UpgradeTaskCallback } taskCallback - Event callback.
431         * @since 9
432         */
433        off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void;
434    }
435
436    /**
437     * A static class to do restore.
438     *
439     * @since 9
440     * @syscap SystemCapability.Update.UpdateService
441     * @systemapi hide for inner use.
442     */
443    export interface Restorer {
444        /**
445         * Reboot and clean user data.
446         *
447         * @permission ohos.permission.FACTORY_RESET
448         * @param { AsyncCallback<void> } callback - Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.
449         * @throws { BusinessError } 201 - Permission denied.
450         * @throws { BusinessError } 11500104 - IPC error.
451         * @since 9
452         */
453        factoryReset(callback: AsyncCallback<void>): void;
454
455        /**
456         * Reboot and clean user data.
457         *
458         * @permission ohos.permission.FACTORY_RESET
459         * @returns { Promise<void> } Promise that returns no value.
460         * @throws { BusinessError } 201 - Permission denied.
461         * @throws { BusinessError } 11500104 - IPC error.
462         * @since 9
463         */
464        factoryReset(): Promise<void>;
465    }
466
467    /**
468     * A static class to do local update.
469     *
470     * @since 9
471     * @syscap SystemCapability.Update.UpdateService
472     * @systemapi hide for inner use.
473     */
474    export interface LocalUpdater {
475        /**
476         * Verify local update package.
477         *
478         * @param { UpgradeFile } upgradeFile - Update file.
479         * @param { string } certsFile - Path of the certificate file.
480         * @param { AsyncCallback<void> } callback - Callback used to return the verify upgrade package result.
481         * @permission ohos.permission.UPDATE_SYSTEM
482         * @throws { BusinessError } 201 - Permission denied.
483         * @throws { BusinessError } 401 - Parameter error.
484         * @throws { BusinessError } 11500104 - IPC error.
485         * @since 9
486         */
487        verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback<void>): void;
488
489        /**
490         * Verify local update package.
491         *
492         * @param { UpgradeFile } upgradeFile - Update file.
493         * @param { string } certsFile - Path of the certificate file.
494         * returns { Promise<void> } Promise that returns no value.
495         * @permission ohos.permission.UPDATE_SYSTEM
496         * @throws { BusinessError } 201 - Permission denied.
497         * @throws { BusinessError } 401 - Parameter error.
498         * @throws { BusinessError } 11500104 - IPC error.
499         * @since 9
500         */
501        verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise<void>;
502
503        /**
504         * Apply local update package.
505         * Apps should listen to task update event
506         *
507         * @permission ohos.permission.UPDATE_SYSTEM
508         * @param { UpgradeFile } upgradeFile - Update file.
509         * @param { AsyncCallback<void> } callback - Callback used to return the apply new version result.
510         * @throws { BusinessError } 201 - Permission denied.
511         * @throws { BusinessError } 401 - Parameter error.
512         * @throws { BusinessError } 11500104 - IPC error.
513         * @since 9
514         */
515        applyNewVersion(upgradeFiles: Array<UpgradeFile>, callback: AsyncCallback<void>): void;
516
517        /**
518         * Apply local update package.
519         * Apps should listen to task update event
520         *
521         * @permission ohos.permission.UPDATE_SYSTEM
522         * @param { UpgradeFile } upgradeFile - Update file.
523         * @returns { Promise<void> } Promise that returns no value.
524         * @throws { BusinessError } 201 - Permission denied.
525         * @throws { BusinessError } 401 - Parameter error.
526         * @throws { BusinessError } 11500104 - IPC error.
527         * @since 9
528         */
529        applyNewVersion(upgradeFiles: Array<UpgradeFile>): Promise<void>;
530
531        /**
532         * Subscribe task update events
533         *
534         * @param { EventClassifyInfo } eventClassifyInfo - Event information.
535         * @param { UpgradeTaskCallback } taskCallback - Event callback.
536         * @since 9
537         */
538        on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void;
539
540        /**
541         * Unsubscribe task update events
542         *
543         * @param { EventClassifyInfo } eventClassifyInfo - Event information.
544         * @param { UpgradeTaskCallback } taskCallback - Event callback.
545         * @since 9
546         */
547        off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void;
548    }
549
550    /**
551     * Represents upgrade info.
552     *
553     * @since 9
554     */
555    export interface UpgradeInfo {
556        /**
557         * Upgrade client package name
558         * @type {string}
559         * @since 9
560         */
561        upgradeApp: string;
562
563        /**
564         * BusinessType of upgrade
565         * @type {BusinessType}
566         * @since 9
567         */
568        businessType: BusinessType;
569    }
570
571    /**
572     * Represents business type.
573     *
574     * @since 9
575     */
576    export interface BusinessType {
577        /**
578         * Vendor of business type
579         * @type {BusinessVendor}
580         * @since 9
581         */
582        vendor: BusinessVendor;
583
584        /**
585         * Update service type
586         * @type {BusinessSubType}
587         * @since 9
588         */
589        subType: BusinessSubType;
590    }
591
592    /**
593     * Represents new version check result.
594     *
595     * @since 9
596     */
597    export interface CheckResult {
598        /**
599         * New version exist or not
600         * @type {boolean}
601         * @since 9
602         */
603        isExistNewVersion: boolean;
604
605        /**
606         * New version info
607         * @type {NewVersionInfo}
608         * @since 9
609         */
610        newVersionInfo: NewVersionInfo;
611    }
612
613    /**
614     * Represents new version info.
615     *
616     * @since 9
617     */
618    export interface NewVersionInfo {
619        /**
620         * Digest info of new version
621         * @type {VersionDigestInfo}
622         * @since 9
623         */
624        versionDigestInfo: VersionDigestInfo;
625
626        /**
627         * New version component array
628         * @type {Array<VersionComponent>}
629         * @since 9
630         */
631        versionComponents: Array<VersionComponent>;
632    }
633
634    /**
635     * Represents version digest info.
636     *
637     * @since 9
638     */
639    export interface VersionDigestInfo {
640        /**
641         * Version digest value
642         * @type {string}
643         * @since 9
644         */
645        versionDigest: string;
646    }
647
648    /**
649     * Represents version component info.
650     *
651     * @since 9
652     */
653    export interface VersionComponent {
654        /**
655         * Version component id
656         * @type {string}
657         * @since 9
658         */
659        componentId: string;
660
661        /**
662         * Version component type
663         * @type {ComponentType}
664         * @since 9
665         */
666        componentType: ComponentType;
667
668        /**
669         * Upgrade action
670         * @type {UpgradeAction}
671         * @since 9
672         */
673        upgradeAction: UpgradeAction;
674
675        /**
676         * Display version number
677         * @type {string}
678         * @since 9
679         */
680        displayVersion: string;
681
682        /**
683         * Internal version number
684         * @type {string}
685         * @since 9
686         */
687        innerVersion: string;
688
689        /**
690         * Update package size
691         * @type {number}
692         * @since 9
693         */
694        size: number;
695
696        /**
697         * Effective mode
698         * @type {EffectiveMode}
699         * @since 9
700         */
701        effectiveMode: EffectiveMode;
702
703        /**
704         * Information about the version description file
705         * @type {DescriptionInfo}
706         * @since 9
707         */
708        descriptionInfo: DescriptionInfo;
709    }
710
711    /**
712     * Represents description options.
713     *
714     * @since 9
715     */
716    export interface DescriptionOptions {
717        /**
718         * Format of the description file
719         * @type {DescriptionFormat}
720         * @since 9
721         */
722        format: DescriptionFormat;
723
724        /**
725         * Language of the description file
726         * @type {string}
727         * @since 9
728         */
729        language: string;
730    }
731
732    /**
733     * Represents version component description.
734     *
735     * @since 9
736     */
737    export interface ComponentDescription {
738        /**
739         * Component id
740         * @type {string}
741         * @since 9
742         */
743        componentId: string;
744
745        /**
746         * Information about the description file
747         * @type {DescriptionInfo}
748         * @since 9
749         */
750        descriptionInfo: DescriptionInfo;
751    }
752
753    /**
754     * Represents new version description information.
755     *
756     * @since 9
757     */
758    export interface DescriptionInfo {
759        /**
760         * Description content type
761         * @type {DescriptionType}
762         * @since 9
763         */
764        descriptionType: DescriptionType;
765
766        /**
767         * Content of the description file
768         * @type {string}
769         * @since 9
770         */
771        content: string;
772    }
773
774    /**
775     * Represents current version info.
776     *
777     * @since 9
778     */
779    export interface CurrentVersionInfo {
780        /**
781         * System version number
782         * @type {string}
783         * @since 9
784         */
785        osVersion: string;
786
787        /**
788         * Device name
789         * @type {string}
790         * @since 9
791         */
792        deviceName: string;
793
794        /**
795         * Current version component array
796         * @type {Array<VersionComponent>}
797         * @since 9
798         */
799        versionComponents: Array<VersionComponent>;
800    }
801
802    /**
803     * Represents download options.
804     *
805     * @since 9
806     */
807    export interface DownloadOptions {
808        /**
809         * Allow download with the network type
810         * @type {NetType}
811         * @since 9
812         */
813        allowNetwork: NetType;
814
815        /**
816         * Upgrade command
817         * @type {Order}
818         * @since 9
819         */
820        order: Order;
821    }
822
823    /**
824     * Represents resume download options.
825     *
826     * @since 9
827     */
828    export interface ResumeDownloadOptions {
829        /**
830         * Allow download with the network type
831         * @type {NetType}
832         * @since 9
833         */
834        allowNetwork: NetType;
835    }
836
837    /**
838     * Represents pause download options.
839     *
840     * @since 9
841     */
842    export interface PauseDownloadOptions {
843        /**
844         * Whether allow auto resume when net available
845         * @type {boolean}
846         * @since 9
847         */
848        isAllowAutoResume: boolean;
849    }
850
851    /**
852     * Represents upgrade options.
853     *
854     * @since 9
855     */
856    export interface UpgradeOptions {
857        /**
858         * Upgrade command
859         * @type {Order}
860         * @since 9
861         */
862        order: Order;
863    }
864
865    /**
866     * Represents clear error options.
867     *
868     * @since 9
869     */
870    export interface ClearOptions {
871        /**
872         * Clear status error
873         * @type {UpgradeStatus}
874         * @since 9
875         */
876        status: UpgradeStatus;
877    }
878
879    /**
880     * Represents upgrade policy.
881     *
882     * @since 9
883     */
884    export interface UpgradePolicy {
885        /**
886         * Download strategy: open or close
887         * @type {boolean}
888         * @since 9
889         */
890        downloadStrategy: boolean;
891
892        /**
893         * Auto upgrade strategy: open or close
894         * @type {boolean}
895         * @since 9
896         */
897        autoUpgradeStrategy: boolean;
898
899        /**
900         * Auto upgrade period
901         * @type {Array<UpgradePeriod>}
902         * @since 9
903         */
904        autoUpgradePeriods: Array<UpgradePeriod>;
905    }
906
907    /**
908     * Represents upgrade period.
909     *
910     * @since 9
911     */
912    export interface UpgradePeriod {
913        /**
914         * Start time of upgrade period
915         * @type {number}
916         * @since 9
917         */
918        start: number;
919
920        /**
921         * End time of upgrade period
922         * @type {number}
923         * @since 9
924         */
925        end: number;
926    }
927
928    /**
929     * Represents task info.
930     *
931     * @since 9
932     */
933    export interface TaskInfo {
934        /**
935         * Whether upgrade task exist
936         * @type {boolean}
937         * @since 9
938         */
939        existTask: boolean;
940
941        /**
942         * Task body info
943         * @type {TaskBody}
944         * @since 9
945         */
946        taskBody: TaskBody;
947    }
948
949    /**
950     * Represents event info.
951     *
952     * @since 9
953     */
954    export interface EventInfo {
955        /**
956         * Event id
957         * @type {EventId}
958         * @since 9
959         */
960        eventId: EventId;
961
962        /**
963         * Task body info
964         * @type {TaskBody}
965         * @since 9
966         */
967        taskBody: TaskBody;
968    }
969
970    /**
971     * Represents task body info.
972     *
973     * @since 9
974     */
975    export interface TaskBody {
976        /**
977         * Digest info of new version
978         * @type {VersionDigestInfo}
979         * @since 9
980         */
981        versionDigestInfo: VersionDigestInfo;
982
983        /**
984         * Upgrade status
985         * @type {UpgradeStatus}
986         * @since 9
987         */
988        status: UpgradeStatus;
989
990        /**
991         * Upgrade sub status
992         * @type {number}
993         * @since 9
994         */
995        subStatus: number;
996
997        /**
998         * Upgrade progress
999         * @type {number}
1000         * @since 9
1001         */
1002        progress: number;
1003
1004        /**
1005         * Install mode
1006         * @type {number}
1007         * @since 9
1008         */
1009        installMode: number;
1010
1011        /**
1012         * Error messages
1013         * @type {Array<ErrorMessage>}
1014         * @since 9
1015         */
1016        errorMessages: Array<ErrorMessage>;
1017
1018        /**
1019         * Version component array
1020         * @type {Array<VersionComponent>}
1021         * @since 9
1022         */
1023        versionComponents: Array<VersionComponent>;
1024    }
1025
1026    /**
1027     * Represents error message.
1028     *
1029     * @since 9
1030     */
1031    export interface ErrorMessage {
1032        /**
1033         * Error code
1034         * @type {number}
1035         * @since 9
1036         */
1037        errorCode: number;
1038
1039        /**
1040         * Error message
1041         * @type {string}
1042         * @since 9
1043         */
1044        errorMessage: string;
1045    }
1046
1047    /**
1048     * Represents event classify info.
1049     *
1050     * @since 9
1051     */
1052    export interface EventClassifyInfo {
1053        /**
1054         * Event classify
1055         * @type {EventClassify}
1056         * @since 9
1057         */
1058        eventClassify: EventClassify;
1059
1060        /**
1061         * Additional information
1062         * @type {string}
1063         * @since 9
1064         */
1065        extraInfo: string;
1066    }
1067
1068    /**
1069     * Represents upgrade file info.
1070     *
1071     * @since 9
1072     */
1073    export interface UpgradeFile {
1074        /**
1075         * Upgrade file type
1076         * @type {ComponentType}
1077         * @since 9
1078         */
1079        fileType: ComponentType;
1080
1081        /**
1082         * Upgrade file path
1083         * @type {string}
1084         * @since 9
1085         */
1086        filePath: string;
1087    }
1088
1089    /**
1090     * Called when upgrade task info changes.
1091     * You need to implement this method in a child class.
1092     *
1093     * @param eventInfo EventInfo: include eventId and taskBody info.
1094     * @since 9
1095     */
1096    export interface UpgradeTaskCallback {
1097        /**
1098         * Event callback.
1099         *
1100         * @param { EventInfo } eventInfo - Event information.
1101         * @since 9
1102         */
1103        (eventInfo: EventInfo): void;
1104    }
1105
1106    /**
1107     * Enumerates business vendor type.
1108     *
1109     * @since 9
1110     */
1111    export enum BusinessVendor {
1112        /**
1113         * Device vendor is open source.
1114         * @since 9
1115         */
1116        PUBLIC = "public"
1117    }
1118
1119    /**
1120     * Enumerates business sub type.
1121     *
1122     * @since 9
1123     */
1124    export enum BusinessSubType {
1125        /**
1126         * Business sub type is Firmware.
1127         * @since 9
1128         */
1129        FIRMWARE = 1
1130    }
1131
1132    /**
1133     * Enumerates component type.
1134     *
1135     * @since 9
1136     */
1137    export enum ComponentType {
1138        /**
1139         * Component type is OTA.
1140         * @since 9
1141         */
1142        OTA = 1,
1143    }
1144
1145    /**
1146     * Enumerates upgrade action type.
1147     *
1148     * @since 9
1149     */
1150    export enum UpgradeAction {
1151        /**
1152         * Differential package.
1153         * @since 9
1154         */
1155        UPGRADE = "upgrade",
1156
1157        /**
1158         * Recovery package.
1159         * @since 9
1160         */
1161        RECOVERY = "recovery"
1162    }
1163
1164    /**
1165     * Enumerates effective mode.
1166     *
1167     * @since 9
1168     */
1169    export enum EffectiveMode {
1170        /**
1171         * Cold update.
1172         * @since 9
1173         */
1174        COLD = 1,
1175
1176        /**
1177         * Live update.
1178         * @since 9
1179         */
1180        LIVE = 2,
1181
1182        /**
1183         * Hybrid live and cold update.
1184         * @since 9
1185         */
1186        LIVE_AND_COLD = 3
1187    }
1188
1189    /**
1190     * Enumerates description type.
1191     *
1192     * @since 9
1193     */
1194    export enum DescriptionType {
1195        /**
1196         * Description type is content.
1197         * @since 9
1198         */
1199        CONTENT = 0,
1200
1201        /**
1202         * Description type is link.
1203         * @since 9
1204         */
1205        URI = 1
1206    }
1207
1208    /**
1209     * Enumerates description format.
1210     *
1211     * @since 9
1212     */
1213    export enum DescriptionFormat {
1214        /**
1215         * Description format is standard format.
1216         * @since 9
1217         */
1218        STANDARD = 0,
1219
1220        /**
1221         * Description format is Simple format.
1222         * @since 9
1223         */
1224        SIMPLIFIED = 1
1225    }
1226
1227    /**
1228     * Enumerates network type.
1229     *
1230     * @since 9
1231     */
1232    export enum NetType {
1233        /**
1234         * Network type is data network.
1235         * @since 9
1236         */
1237        CELLULAR = 1,
1238
1239        /**
1240         * Network type is Wi-Fi hotspot.
1241         * @since 9
1242         */
1243        METERED_WIFI = 2,
1244
1245        /**
1246         * Network type is non Wi-Fi hotspot.
1247         * @since 9
1248         */
1249        NOT_METERED_WIFI = 4,
1250
1251        /**
1252         * Network type is Wi-Fi.
1253         * @since 9
1254         */
1255        WIFI = 6,
1256
1257        /**
1258         * Network type is data network and Wi-Fi.
1259         * @since 9
1260         */
1261        CELLULAR_AND_WIFI = 7
1262    }
1263
1264    /**
1265     * Enumerates upgrade order.
1266     *
1267     * @since 9
1268     */
1269    export enum Order {
1270        /**
1271         * Upgrade order is download.
1272         * @since 9
1273         */
1274        DOWNLOAD = 1,
1275
1276        /**
1277         * Upgrade order is Install.
1278         * @since 9
1279         */
1280        INSTALL = 2,
1281
1282        /**
1283         * Upgrade order is download and install.
1284         * @since 9
1285         */
1286        DOWNLOAD_AND_INSTALL = 3,
1287
1288        /**
1289         * Upgrade order is apply.
1290         * @since 9
1291         */
1292        APPLY = 4,
1293
1294        /**
1295         * Upgrade order is install and apply.
1296         * @since 9
1297         */
1298        INSTALL_AND_APPLY = 6
1299    }
1300
1301    /**
1302     * Enumerates upgrade status.
1303     *
1304     * @since 9
1305     */
1306    export enum UpgradeStatus {
1307        /**
1308         * Upgrade status is waiting for download.
1309         * @since 9
1310         */
1311        WAITING_DOWNLOAD = 20,
1312
1313        /**
1314         * Upgrade status is downloading.
1315         * @since 9
1316         */
1317        DOWNLOADING = 21,
1318
1319        /**
1320         * Upgrade status is download paused.
1321         * @since 9
1322         */
1323        DOWNLOAD_PAUSED = 22,
1324
1325        /**
1326         * Upgrade status is download failed.
1327         * @since 9
1328         */
1329        DOWNLOAD_FAIL = 23,
1330
1331        /**
1332         * Upgrade status is waiting for installation.
1333         * @since 9
1334         */
1335        WAITING_INSTALL = 30,
1336
1337        /**
1338         * Upgrade status is upgrading.
1339         * @since 9
1340         */
1341        UPDATING = 31,
1342
1343        /**
1344         * Upgrade status is waiting for applying the update.
1345         * @since 9
1346         */
1347        WAITING_APPLY = 40,
1348
1349        /**
1350         * Upgrade status is applying the update.
1351         * @since 9
1352         */
1353        APPLYING = 41,
1354
1355        /**
1356         * Upgrade status is update succeeded.
1357         * @since 9
1358         */
1359        UPGRADE_SUCCESS = 50,
1360
1361        /**
1362         * Upgrade status is update failed.
1363         * @since 9
1364         */
1365        UPGRADE_FAIL = 51
1366    }
1367
1368    /**
1369     * Enumerates event classify.
1370     *
1371     * @since 9
1372     */
1373    export enum EventClassify {
1374        /**
1375         * Event classify is task event.
1376         * @since 9
1377         */
1378        TASK = 0x01000000
1379    }
1380
1381    /**
1382     * Enumerates event id.
1383     *
1384     * @since 9
1385     */
1386    export enum EventId {
1387        /**
1388         * Event id is task event.
1389         * @since 9
1390         */
1391        EVENT_TASK_BASE = EventClassify.TASK,
1392
1393        /**
1394         * Event id is task received.
1395         * @since 9
1396         */
1397        EVENT_TASK_RECEIVE,
1398
1399        /**
1400         * Event id is task cancelled.
1401         * @since 9
1402         */
1403        EVENT_TASK_CANCEL,
1404
1405        /**
1406         * Event id is waiting for download.
1407         * @since 9
1408         */
1409        EVENT_DOWNLOAD_WAIT,
1410
1411        /**
1412         * Event id is download started.
1413         * @since 9
1414         */
1415        EVENT_DOWNLOAD_START,
1416
1417        /**
1418         * Event id is download progress update.
1419         * @since 9
1420         */
1421        EVENT_DOWNLOAD_UPDATE,
1422
1423        /**
1424         * Event id is download paused.
1425         * @since 9
1426         */
1427        EVENT_DOWNLOAD_PAUSE,
1428
1429        /**
1430         * Event id is download resumed.
1431         * @since 9
1432         */
1433        EVENT_DOWNLOAD_RESUME,
1434
1435        /**
1436         * Event id is download succeeded.
1437         * @since 9
1438         */
1439        EVENT_DOWNLOAD_SUCCESS,
1440
1441        /**
1442         * Event id is download failed.
1443         * @since 9
1444         */
1445        EVENT_DOWNLOAD_FAIL,
1446
1447        /**
1448         * Event id is waiting for update.
1449         * @since 9
1450         */
1451        EVENT_UPGRADE_WAIT,
1452
1453        /**
1454         * Event id is update started.
1455         * @since 9
1456         */
1457        EVENT_UPGRADE_START,
1458
1459        /**
1460         * Event id is update in progress.
1461         * @since 9
1462         */
1463        EVENT_UPGRADE_UPDATE,
1464
1465        /**
1466         * Event id is waiting for applying the update.
1467         * @since 9
1468         */
1469        EVENT_APPLY_WAIT,
1470
1471        /**
1472         * Event id is applying the update.
1473         * @since 9
1474         */
1475        EVENT_APPLY_START,
1476
1477        /**
1478         * Event id is update succeeded.
1479         * @since 9
1480         */
1481        EVENT_UPGRADE_SUCCESS,
1482
1483        /**
1484         * Event id is update failed.
1485         * @since 9
1486         */
1487        EVENT_UPGRADE_FAIL
1488    }
1489}
1490
1491export default update;