• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 
16 /**
17  * @file
18  * @kit CoreFileKit
19  */
20 
21 import type { AsyncCallback, Callback } from './@ohos.base';
22 
23 /**
24  * Module providing backup and restore capabilities.
25  *
26  * @namespace backup
27  * @syscap SystemCapability.FileManagement.StorageService.Backup
28  * @systemapi
29  * @since 10
30  */
31 declare namespace backup {
32   /**
33    * Corresponding to a file's metadata. FileMeta is useful when doing IPC with the backup service.
34    *
35    * @interface FileMeta
36    * @syscap SystemCapability.FileManagement.StorageService.Backup
37    * @systemapi
38    * @since 10
39    */
40   interface FileMeta {
41     /**
42      * Indicates the name of a bundle.
43      *
44      * @type { string }
45      * @syscap SystemCapability.FileManagement.StorageService.Backup
46      * @systemapi
47      * @since 10
48      */
49     bundleName: string;
50 
51     /**
52      * Indicates a uri to a file.
53      *
54      * @type { string }
55      * @syscap SystemCapability.FileManagement.StorageService.Backup
56      * @systemapi
57      * @since 10
58      */
59     uri: string;
60   }
61 
62   /**
63    * Corresponding to a file's data. Filedata is useful when doing IPC with the backup service.
64    *
65    * @interface FileData
66    * @syscap SystemCapability.FileManagement.StorageService.Backup
67    * @systemapi
68    * @since 10
69    */
70   interface FileData {
71     /**
72      * Indicates a native file descriptor typically retrieved from the backup service to hold the file's content.
73      *
74      * @type { number }
75      * @syscap SystemCapability.FileManagement.StorageService.Backup
76      * @systemapi
77      * @since 10
78      */
79     fd: number;
80   }
81 
82   /**
83    * Save the time information of the incremental backup. IncrementalBackupTime is useful when doing IPC with the backup service.
84    *
85    * @interface IncrementalBackupTime
86    * @syscap SystemCapability.FileManagement.StorageService.Backup
87    * @systemapi
88    * @since 12
89    */
90   interface IncrementalBackupTime {
91     /**
92      * Indicates the name of a bundle.
93      *
94      * @type { string }
95      * @syscap SystemCapability.FileManagement.StorageService.Backup
96      * @systemapi
97      * @since 12
98      */
99     bundleName: string;
100 
101     /**
102      * Time of the last incremental backup
103      *
104      * @type { number }
105      * @syscap SystemCapability.FileManagement.StorageService.Backup
106      * @systemapi
107      * @since 12
108      */
109     lastIncrementalTime: number;
110   }
111 
112   /**
113    * Manifest file information in incremental data. FileManifestData is useful when doing IPC with the backup service.
114    *
115    * @interface FileManifestData
116    * @syscap SystemCapability.FileManagement.StorageService.Backup
117    * @systemapi
118    * @since 12
119    */
120   interface FileManifestData {
121     /**
122      * A file descriptor for the manifest file that holds the data
123      *
124      * @type { number }
125      * @syscap SystemCapability.FileManagement.StorageService.Backup
126      * @systemapi
127      * @since 12
128      */
129     manifestFd: number;
130   }
131 
132   /**
133    * Provides configuration parameters for backup and restore.
134    *
135    * @interface BackupParams
136    * @syscap SystemCapability.FileManagement.StorageService.Backup
137    * @systemapi
138    * @since 12
139    */
140   interface BackupParams {
141     /**
142      * The optional parameters a json strings in the form of key value in backup or restore.
143      *
144      * @type { ?string }
145      * @syscap SystemCapability.FileManagement.StorageService.Backup
146      * @systemapi
147      * @since 12
148      */
149     parameters?: string;
150   }
151 
152   /**
153    * Control backup and restore priority sequence
154    *
155    * @interface BackupPriority
156    * @syscap SystemCapability.FileManagement.StorageService.Backup
157    * @systemapi
158    * @since 12
159    */
160   interface BackupPriority {
161     /**
162      * Indicates the priority of a bundle.
163      *
164      * @type { ?number }
165      * @syscap SystemCapability.FileManagement.StorageService.Backup
166      * @systemapi
167      * @since 12
168      */
169     priority?: number;
170   }
171 
172   /**
173    * Corresponds to an incremental application, including its last incremental time and incremental list.
174    *
175    * @interface IncrementalBackupData
176    * @syscap SystemCapability.FileManagement.StorageService.Backup
177    * @systemapi
178    * @since 12
179    */
180   interface IncrementalBackupData extends IncrementalBackupTime, FileManifestData, BackupParams, BackupPriority {}
181 
182   /**
183    * Corresponding to a file, including its metadata and data.
184    * File is useful when doing IPC with the backup service.
185    *
186    * @interface File
187    * @syscap SystemCapability.FileManagement.StorageService.Backup
188    * @systemapi
189    * @since 10
190    */
191   /**
192    * Corresponds to a file, including its metadata and data and the file's manifest data.
193    * Files are useful as IPC and backup services.
194    *
195    * @interface File
196    * @syscap SystemCapability.FileManagement.StorageService.Backup
197    * @systemapi
198    * @since 12
199    */
200   interface File extends FileMeta, FileData, FileManifestData {}
201 
202   /**
203    * Obtain a Json file that describes local capabilities.
204    *
205    * @permission ohos.permission.BACKUP
206    * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be
207    *     deleted automatically when closed.
208    * @throws { BusinessError } 13600001 - IPC error
209    * @throws { BusinessError } 13900005 - I/O error
210    * @throws { BusinessError } 13900011 - Out of memory
211    * @throws { BusinessError } 13900025 - No space left on device
212    * @throws { BusinessError } 13900042 - Unknown error
213    * @syscap SystemCapability.FileManagement.StorageService.Backup
214    * @systemapi
215    * @since 10
216    */
217   function getLocalCapabilities(): Promise<FileData>;
218 
219   /**
220    * Obtain a Json file that describes local capabilities.
221    *
222    * @permission ohos.permission.BACKUP
223    * @param { AsyncCallback<FileData> } callback A callback method, the argument FileData will holding all the local capabilities.
224    *     The returned file is a temporal file that will be deleted automatically when closed.
225    * @throws { BusinessError } 13600001 - IPC error
226    * @throws { BusinessError } 13900005 - I/O error
227    * @throws { BusinessError } 13900011 - Out of memory
228    * @throws { BusinessError } 13900025 - No space left on device
229    * @throws { BusinessError } 13900042 - Unknown error
230    * @syscap SystemCapability.FileManagement.StorageService.Backup
231    * @systemapi
232    * @since 10
233    */
234   function getLocalCapabilities(callback: AsyncCallback<FileData>): void;
235 
236   /**
237    * Obtain a json file that describes local capabilities.
238    *
239    * @permission ohos.permission.BACKUP
240    * @param { Array<IncrementalBackupTime> } dataList
241    * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be
242    * deleted automatically when closed.
243    * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
244    * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
245    * @throws { BusinessError } 401 - The input parameter is invalid.
246    * @throws { BusinessError } 13600001 - IPC error
247    * @throws { BusinessError } 13900005 - I/O error
248    * @throws { BusinessError } 13900011 - Out of memory
249    * @throws { BusinessError } 13900025 - No space left on device
250    * @throws { BusinessError } 13900042 - Unknown error
251    * @syscap SystemCapability.FileManagement.StorageService.Backup
252    * @systemapi
253    * @since 12
254    */
255   function getLocalCapabilities(dataList: Array<IncrementalBackupTime>): Promise<FileData>;
256 
257   /**
258     * Get Backup information from bundle.
259     *
260     * @permission ohos.permission.BACKUP
261     * @param { string } bundleToBackup Bundle to backup.
262     * @returns { string } Return the backup application's info.
263     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
264     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
265     * @throws { BusinessError } 401 - The input parameter is invalid.
266     * @syscap SystemCapability.FileManagement.StorageService.Backup
267     * @systemapi
268     * @since 12
269     */
270   function getBackupInfo(bundleToBackup: string): string;
271 
272   /**
273    * Update backup or restore timeout.
274    *
275    * @permission ohos.permission.BACKUP
276    * @param { string } bundleName set update to bundleName app.
277    * @param { number } timeout Update backup or restore timeout(unit:ms).
278    * @returns { boolean } Return update result, true is success, false is fail.
279    * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
280    * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
281    * @throws { BusinessError } 401 - The input parameter is invalid.
282    * @syscap SystemCapability.FileManagement.StorageService.Backup
283    * @systemapi
284    * @since 12
285    */
286   function updateTimer(bundleName: string, timeout: number): boolean;
287 
288   /**
289    * General callbacks for both backup and restore procedure.
290    * The backup service will notify the client by these callbacks.
291    *
292    * @interface GeneralCallbacks
293    * @syscap SystemCapability.FileManagement.StorageService.Backup
294    * @systemapi
295    * @since 10
296    */
297   interface GeneralCallbacks {
298     /**
299      * Callback called when the backup service tries to send files to the client.
300      * The File argument indicates a file to send to the client.
301      *     The returned file is owned by the backup service and will be cleaned by the service once the file is closed.
302      *
303      * @throws { BusinessError } 13600001 - IPC error
304      * @throws { BusinessError } 13900005 - I/O error
305      * @throws { BusinessError } 13900011 - Out of memory
306      * @throws { BusinessError } 13900020 - Invalid argument
307      * @throws { BusinessError } 13900025 - No space left on device
308      * @throws { BusinessError } 13900042 - Unknown error
309      * @syscap SystemCapability.FileManagement.StorageService.Backup
310      * @systemapi
311      * @since 10
312      */
313     onFileReady: AsyncCallback<File>;
314 
315     /**
316      * Callback called when a backup/restore procedure for an bundle is started.
317      * The return string argument indicates the name of the bundle.
318      *
319      * @throws { BusinessError } 13600001 - IPC error
320      * @throws { BusinessError } 13900005 - I/O error
321      * @throws { BusinessError } 13900011 - Out of memory
322      * @throws { BusinessError } 13900020 - Invalid argument
323      * @throws { BusinessError } 13900025 - No space left on device
324      * @throws { BusinessError } 13900042 - Unknown error
325      * @syscap SystemCapability.FileManagement.StorageService.Backup
326      * @systemapi
327      * @since 10
328      */
329     /**
330      * Callback called when a backup/restore procedure for an bundle is started.
331      * The first return string parameter indicates the name of the bundle.
332      * The second return string parameter indicates that when BusinessError errors occur,
333      * the callback data is the name of the bundle.
334      *
335      * @throws { BusinessError } 401 - The input parameter is invalid.
336      * @throws { BusinessError } 13500001 - The application is not added to the backup or restore
337      * @throws { BusinessError } 13500002 - Failed to start application extension Procedure
338      * @throws { BusinessError } 13600001 - IPC error
339      * @throws { BusinessError } 13900005 - I/O error
340      * @throws { BusinessError } 13900011 - Out of memory
341      * @throws { BusinessError } 13900025 - No space left on device
342      * @throws { BusinessError } 13900042 - Unknown error
343      * @syscap SystemCapability.FileManagement.StorageService.Backup
344      * @systemapi
345      * @since 12
346      */
347     onBundleBegin: AsyncCallback<string, void | string>;
348 
349     /**
350      * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
351      * The return string argument indicates the name of the bundle.
352      *
353      * @throws { BusinessError } 13600001 - IPC error
354      * @throws { BusinessError } 13900005 - I/O error
355      * @throws { BusinessError } 13900011 - Out of memory
356      * @throws { BusinessError } 13900020 - Invalid argument
357      * @throws { BusinessError } 13900025 - No space left on device
358      * @throws { BusinessError } 13900042 - Unknown error
359      * @syscap SystemCapability.FileManagement.StorageService.Backup
360      * @systemapi
361      * @since 10
362      */
363     /**
364      * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
365      * The first return string parameter indicates the name of the bundle.
366      * The second return string parameter indicates that when BusinessError errors occur,
367      * the callback data is the name of the bundle.
368      *
369      * @throws { BusinessError } 401 - The input parameter is invalid.
370      * @throws { BusinessError } 13500003 - Backup or restore timed out
371      * @throws { BusinessError } 13500004 - Application extension death
372      * @throws { BusinessError } 13600001 - IPC error
373      * @throws { BusinessError } 13900005 - I/O error
374      * @throws { BusinessError } 13900011 - Out of memory
375      * @throws { BusinessError } 13900025 - No space left on device
376      * @throws { BusinessError } 13900042 - Unknown error
377      * @syscap SystemCapability.FileManagement.StorageService.Backup
378      * @systemapi
379      * @since 12
380      */
381     onBundleEnd: AsyncCallback<string, void | string>;
382 
383     /**
384      * Callback called when the all the bundles to backup/restore are done or aborted unexpectedly.
385      *
386      * @throws { BusinessError } 13600001 - IPC error
387      * @throws { BusinessError } 13900005 - I/O error
388      * @throws { BusinessError } 13900011 - Out of memory
389      * @throws { BusinessError } 13900020 - Invalid argument
390      * @throws { BusinessError } 13900025 - No space left on device
391      * @throws { BusinessError } 13900042 - Unknown error
392      * @syscap SystemCapability.FileManagement.StorageService.Backup
393      * @systemapi
394      * @since 10
395      */
396     onAllBundlesEnd: AsyncCallback<undefined>;
397 
398     /**
399      * Callback called when the backup service dies unexpectedly.
400      *
401      * @syscap SystemCapability.FileManagement.StorageService.Backup
402      * @systemapi
403      * @since 10
404      */
405     onBackupServiceDied: Callback<undefined>;
406 
407     /**
408      * Callback called when the backup service return result information.
409      * The first return string parameter indicates the result of the bundle.
410      *
411      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
412      * @throws { BusinessError } 401 - The input parameter is invalid.
413      * @throws { BusinessError } 13600001 - IPC error
414      * @throws { BusinessError } 13900005 - I/O error
415      * @throws { BusinessError } 13900011 - Out of memory
416      * @throws { BusinessError } 13900025 - No space left on device
417      * @throws { BusinessError } 13900042 - Unknown error
418      * @syscap SystemCapability.FileManagement.StorageService.Backup
419      * @systemapi
420      * @since 12
421      */
422     onResultReport: AsyncCallback<string>;
423   }
424 
425   /**
426    * Control class for backup procedure.
427    *
428    * @syscap SystemCapability.FileManagement.StorageService.Backup
429    * @systemapi
430    * @since 10
431    */
432   class SessionBackup {
433     /**
434      * Constructor for obtaining the instance of the SessionBackup class.
435      *
436      * @permission ohos.permission.BACKUP
437      * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
438      * @syscap SystemCapability.FileManagement.StorageService.Backup
439      * @systemapi
440      * @since 10
441      */
442     constructor(callbacks: GeneralCallbacks);
443 
444     /**
445      * Append new bundles to backup.
446      *
447      * @permission ohos.permission.BACKUP
448      * @param { string[] } bundlesToBackup Bundles to backup.
449      * @returns { Promise<void> } The promise returned by the function.
450      * @throws { BusinessError } 13600001 - IPC error
451      * @throws { BusinessError } 13900001 - Operation not permitted
452      * @throws { BusinessError } 13900005 - I/O error
453      * @throws { BusinessError } 13900011 - Out of memory
454      * @throws { BusinessError } 13900020 - Invalid argument
455      * @throws { BusinessError } 13900025 - No space left on device
456      * @throws { BusinessError } 13900042 - Unknown error
457      * @syscap SystemCapability.FileManagement.StorageService.Backup
458      * @systemapi
459      * @since 10
460      */
461     /**
462      * Append new bundles and backupInfos to backup.
463      *
464      * @permission ohos.permission.BACKUP
465      * @param { string[] } bundlesToBackup Bundles to backup.
466      * @param { string[] } infos Infos to backup.
467      * @returns { Promise<void> } The promise returned by the function.
468      * @throws { BusinessError } 13600001 - IPC error
469      * @throws { BusinessError } 13900001 - Operation not permitted
470      * @throws { BusinessError } 13900005 - I/O error
471      * @throws { BusinessError } 13900011 - Out of memory
472      * @throws { BusinessError } 13900020 - Invalid argument
473      * @throws { BusinessError } 13900025 - No space left on device
474      * @throws { BusinessError } 13900042 - Unknown error
475      * @syscap SystemCapability.FileManagement.StorageService.Backup
476      * @systemapi
477      * @since 12
478      */
479     appendBundles(bundlesToBackup: string[], infos?: string[]): Promise<void>;
480 
481     /**
482      * Append new bundles to backup.
483      *
484      * @permission ohos.permission.BACKUP
485      * @param { string[] } bundlesToBackup Bundles to backup.
486      * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
487      * @throws { BusinessError } 13600001 - IPC error
488      * @throws { BusinessError } 13900001 - Operation not permitted
489      * @throws { BusinessError } 13900005 - I/O error
490      * @throws { BusinessError } 13900011 - Out of memory
491      * @throws { BusinessError } 13900020 - Invalid argument
492      * @throws { BusinessError } 13900025 - No space left on device
493      * @throws { BusinessError } 13900042 - Unknown error
494      * @syscap SystemCapability.FileManagement.StorageService.Backup
495      * @systemapi
496      * @since 10
497      */
498     appendBundles(bundlesToBackup: string[], callback: AsyncCallback<void>): void;
499 
500     /**
501      * End Backup process
502      *
503      * @permission ohos.permission.BACKUP
504      * @returns { Promise<void> } The promise returned by the function.
505      * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
506      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
507      * @throws { BusinessError } 401 - The input parameter is invalid.
508      * @throws { BusinessError } 13600001 - IPC error
509      * @throws { BusinessError } 13900001 - Operation not permitted
510      * @throws { BusinessError } 13900005 - I/O error
511      * @throws { BusinessError } 13900042 - Unknown error
512      * @syscap SystemCapability.FileManagement.StorageService.Backup
513      * @systemapi
514      * @since 12
515      */
516     release(): Promise<void>;
517   }
518 
519   /**
520    * Control class for restore procedure.
521    *
522    * @syscap SystemCapability.FileManagement.StorageService.Backup
523    * @systemapi
524    * @since 10
525    */
526   class SessionRestore {
527     /**
528      * Constructor for obtaining the instance of the SessionBackup class.
529      *
530      * @permission ohos.permission.BACKUP
531      * @param { GeneralCallbacks } callbacks Callbacks to be registered for the restore.
532      * @syscap SystemCapability.FileManagement.StorageService.Backup
533      * @systemapi
534      * @since 10
535      */
536     constructor(callbacks: GeneralCallbacks);
537 
538     /**
539      * Append new bundles to be restore up during the restore.
540      *
541      * @permission ohos.permission.BACKUP
542      * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
543      *     You can use the getLocalCapabilities method to obtain the value.
544      * @param { string[] } bundlesToBackup Bundles to restore.
545      * @returns { Promise<void> } The promise returned by the function.
546      * @throws { BusinessError } 13600001 - IPC error
547      * @throws { BusinessError } 13900001 - Operation not permitted
548      * @throws { BusinessError } 13900005 - I/O error
549      * @throws { BusinessError } 13900011 - Out of memory
550      * @throws { BusinessError } 13900020 - Invalid argument
551      * @throws { BusinessError } 13900025 - No space left on device
552      * @throws { BusinessError } 13900042 - Unknown error
553      * @syscap SystemCapability.FileManagement.StorageService.Backup
554      * @systemapi
555      * @since 10
556      */
557     /**
558      * Append new bundles and restoreInfos to be restore up during the restore.
559      *
560      * @permission ohos.permission.BACKUP
561      * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
562      *     You can use the getLocalCapabilities method to obtain the value.
563      * @param { string[] } bundlesToBackup Bundles to restore.
564      * @param { string[] } [infos] infos to restore
565      * @returns { Promise<void> } The promise returned by the function.
566      * @throws { BusinessError } 13600001 - IPC error
567      * @throws { BusinessError } 13900001 - Operation not permitted
568      * @throws { BusinessError } 13900005 - I/O error
569      * @throws { BusinessError } 13900011 - Out of memory
570      * @throws { BusinessError } 13900020 - Invalid argument
571      * @throws { BusinessError } 13900025 - No space left on device
572      * @throws { BusinessError } 13900042 - Unknown error
573      * @syscap SystemCapability.FileManagement.StorageService.Backup
574      * @systemapi
575      * @since 12
576      */
577     appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], infos?: string[]): Promise<void>;
578 
579     /**
580      * Append new bundles to be restore up during the restore.
581      *
582      * @permission ohos.permission.BACKUP
583      * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
584      *     You can use the getLocalCapabilities method to obtain the value.
585      * @param { string[] } bundlesToBackup Bundles to restore.
586      * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
587      * @throws { BusinessError } 13600001 - IPC error
588      * @throws { BusinessError } 13900001 - Operation not permitted
589      * @throws { BusinessError } 13900005 - I/O error
590      * @throws { BusinessError } 13900011 - Out of memory
591      * @throws { BusinessError } 13900020 - Invalid argument
592      * @throws { BusinessError } 13900025 - No space left on device
593      * @throws { BusinessError } 13900042 - Unknown error
594      * @syscap SystemCapability.FileManagement.StorageService.Backup
595      * @systemapi
596      * @since 10
597      */
598     appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], callback: AsyncCallback<void>): void;
599 
600     /**
601      * Publish the file handle to the backup service to make the service aware that the file's content is ready.
602      * This interface is part of the zero-copy feature.
603      *
604      * @permission ohos.permission.BACKUP
605      * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
606      *     this file by calling getFileHandle.
607      * @returns { Promise<void> } The promise returned by the function.
608      * @throws { BusinessError } 13600001 - IPC error
609      * @throws { BusinessError } 13900001 - Operation not permitted
610      * @throws { BusinessError } 13900020 - Invalid argument
611      * @throws { BusinessError } 13900042 - Unknown error
612      * @syscap SystemCapability.FileManagement.StorageService.Backup
613      * @systemapi
614      * @since 10
615      */
616     publishFile(fileMeta: FileMeta): Promise<void>;
617 
618     /**
619      * Publish the file handle to the backup service to make the service aware that the file's content is ready.
620      * This interface is part of the zero-copy feature.
621      *
622      * @permission ohos.permission.BACKUP
623      * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
624      *     this file by calling getFileHandle.
625      * @param { AsyncCallback<void> } callback Asynchronous callback to be called when publishFile has finished.
626      * @throws { BusinessError } 13600001 - IPC error
627      * @throws { BusinessError } 13900001 - Operation not permitted
628      * @throws { BusinessError } 13900020 - Invalid argument
629      * @throws { BusinessError } 13900042 - Unknown error
630      * @syscap SystemCapability.FileManagement.StorageService.Backup
631      * @systemapi
632      * @since 10
633      */
634     publishFile(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
635 
636     /**
637      * Request to get a shared file from the service. This interface is part of the zero-copy feature.
638      * Developers could get the file through onFileReady callback.
639      * When the client accomplished the file, use publishFile to publish.
640      *
641      * @permission ohos.permission.BACKUP
642      * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
643      *     from the backup procedure or the getLocalCapabilities method.
644      * @returns { Promise<void> } The promise returned by the function.
645      * @throws { BusinessError } 13600001 - IPC error
646      * @throws { BusinessError } 13900001 - Operation not permitted
647      * @throws { BusinessError } 13900020 - Invalid argument
648      * @throws { BusinessError } 13900042 - Unknown error
649      * @syscap SystemCapability.FileManagement.StorageService.Backup
650      * @systemapi
651      * @since 10
652      */
653     getFileHandle(fileMeta: FileMeta): Promise<void>;
654 
655     /**
656      * Request to get a shared file from the service. This interface is part of the zero-copy feature.
657      * Developers could get the file through onFileReady callback.
658      * When the client accomplished the file, use publishFile to publish.
659      *
660      * @permission ohos.permission.BACKUP
661      * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
662      *     from the backup procedure or the getLocalCapabilities method.
663      * @param { AsyncCallback<void> } callback Asynchronous callback to be called when getFileHandle has finished.
664      * @throws { BusinessError } 13600001 - IPC error
665      * @throws { BusinessError } 13900001 - Operation not permitted
666      * @throws { BusinessError } 13900020 - Invalid argument
667      * @throws { BusinessError } 13900042 - Unknown error
668      * @syscap SystemCapability.FileManagement.StorageService.Backup
669      * @systemapi
670      * @since 10
671      */
672     getFileHandle(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
673 
674     /**
675      * End restore process
676      *
677      * @permission ohos.permission.BACKUP
678      * @returns { Promise<void> } The promise returned by the function.
679      * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
680      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
681      * @throws { BusinessError } 401 - The input parameter is invalid.
682      * @throws { BusinessError } 13600001 - IPC error
683      * @throws { BusinessError } 13900001 - Operation not permitted
684      * @throws { BusinessError } 13900005 - I/O error
685      * @throws { BusinessError } 13900042 - Unknown error
686      * @syscap SystemCapability.FileManagement.StorageService.Backup
687      * @systemapi
688      * @since 12
689      */
690     release(): Promise<void>;
691   }
692 
693   /**
694    * Control class for incremental backup procedure.
695    *
696    * @syscap SystemCapability.FileManagement.StorageService.Backup
697    * @systemapi
698    * @since 12
699    */
700   class IncrementalBackupSession {
701     /**
702      * Constructor for obtaining the instance of the IncrementalBackupSession class.
703      *
704      * @permission ohos.permission.BACKUP
705      * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
706      * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
707      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
708      * @throws { BusinessError } 401 - The input parameter is invalid.
709      * @syscap SystemCapability.FileManagement.StorageService.Backup
710      * @systemapi
711      * @since 12
712      */
713     constructor(callbacks: GeneralCallbacks);
714 
715     /**
716      * Append new bundles to incremental backup.
717      *
718      * @permission ohos.permission.BACKUP
719      * @param { Array<IncrementalBackupData> } bundlesToBackup Bundles to incremental backup.
720      * @returns { Promise<void> } The promise returned by the function.
721      * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
722      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
723      * @throws { BusinessError } 401 - The input parameter is invalid.
724      * @throws { BusinessError } 13600001 - IPC error
725      * @throws { BusinessError } 13900001 - Operation not permitted
726      * @throws { BusinessError } 13900005 - I/O error
727      * @throws { BusinessError } 13900011 - Out of memory
728      * @throws { BusinessError } 13900025 - No space left on device
729      * @throws { BusinessError } 13900042 - Unknown error
730      * @syscap SystemCapability.FileManagement.StorageService.Backup
731      * @systemapi
732      * @since 12
733      */
734     appendBundles(bundlesToBackup: Array<IncrementalBackupData>): Promise<void>;
735 
736     /**
737      * End backup process
738      *
739      * @permission ohos.permission.BACKUP
740      * @returns { Promise<void> } The promise returned by the function.
741      * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
742      * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
743      * @throws { BusinessError } 401 - The input parameter is invalid.
744      * @throws { BusinessError } 13600001 - IPC error
745      * @throws { BusinessError } 13900001 - Operation not permitted
746      * @throws { BusinessError } 13900005 - I/O error
747      * @throws { BusinessError } 13900042 - Unknown error
748      * @syscap SystemCapability.FileManagement.StorageService.Backup
749      * @systemapi
750      * @since 12
751      */
752     release(): Promise<void>;
753   }
754 }
755 export default backup;
756