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
21import 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 */
31declare 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 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
246   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
247   * @throws { BusinessError } 13600001 - IPC error
248   * @throws { BusinessError } 13900005 - I/O error
249   * @throws { BusinessError } 13900011 - Out of memory
250   * @throws { BusinessError } 13900025 - No space left on device
251   * @throws { BusinessError } 13900042 - Unknown error
252   * @syscap SystemCapability.FileManagement.StorageService.Backup
253   * @systemapi
254   * @since 12
255   */
256  function getLocalCapabilities(dataList: Array<IncrementalBackupTime>): Promise<FileData>;
257
258  /**
259    * Get Backup information from bundle.
260    *
261    * @permission ohos.permission.BACKUP
262    * @param { string } bundleToBackup Bundle to backup.
263    * @returns { string } Return the backup application's info.
264    * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
265    * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
266    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
267    * <br>2. Incorrect parameter types. 3.Parameter verification failed.
268    * @syscap SystemCapability.FileManagement.StorageService.Backup
269    * @systemapi
270    * @since 12
271    */
272  function getBackupInfo(bundleToBackup: string): string;
273
274  /**
275   * Update backup or restore timeout.
276   *
277   * @permission ohos.permission.BACKUP
278   * @param { string } bundleName set update to bundleName app.
279   * @param { number } timeout Update backup or restore timeout(unit:ms).
280   * @returns { boolean } Return update result, true is success, false is fail.
281   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
282   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
283   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
284   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
285   * @syscap SystemCapability.FileManagement.StorageService.Backup
286   * @systemapi
287   * @since 12
288   */
289  function updateTimer(bundleName: string, timeout: number): boolean;
290
291  /**
292   * Update send file fd rate.
293   *
294   * @permission ohos.permission.BACKUP
295   * @param { string } bundleName set update to bundleName app.
296   * @param { number } sendRate set send file fd rate.
297   * @returns { boolean } Return update result, true is success, false is fail.
298   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
299   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
300   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
301   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
302   * @syscap SystemCapability.FileManagement.StorageService.Backup
303   * @systemapi
304   * @since 12
305  */
306  function updateSendRate(bundleName: string, sendRate: number): boolean;
307
308  /**
309   * General callbacks for both backup and restore procedure.
310   * The backup service will notify the client by these callbacks.
311   *
312   * @interface GeneralCallbacks
313   * @syscap SystemCapability.FileManagement.StorageService.Backup
314   * @systemapi
315   * @since 10
316   */
317  interface GeneralCallbacks {
318    /**
319     * Callback called when the backup service tries to send files to the client.
320     * The File argument indicates a file to send to the client.
321     *     The returned file is owned by the backup service and will be cleaned by the service once the file is closed.
322     *
323     * @type { AsyncCallback<File> }
324     * @throws { BusinessError } 13600001 - IPC error
325     * @throws { BusinessError } 13900005 - I/O error
326     * @throws { BusinessError } 13900011 - Out of memory
327     * @throws { BusinessError } 13900020 - Invalid argument
328     * @throws { BusinessError } 13900025 - No space left on device
329     * @throws { BusinessError } 13900042 - Unknown error
330     * @syscap SystemCapability.FileManagement.StorageService.Backup
331     * @systemapi
332     * @since 10
333     */
334    onFileReady: AsyncCallback<File>;
335
336    /**
337     * Callback called when a backup/restore procedure for an bundle is started.
338     * The return string argument indicates the name of the bundle.
339     *
340     * @throws { BusinessError } 13600001 - IPC error
341     * @throws { BusinessError } 13900005 - I/O error
342     * @throws { BusinessError } 13900011 - Out of memory
343     * @throws { BusinessError } 13900020 - Invalid argument
344     * @throws { BusinessError } 13900025 - No space left on device
345     * @throws { BusinessError } 13900042 - Unknown error
346     * @syscap SystemCapability.FileManagement.StorageService.Backup
347     * @systemapi
348     * @since 10
349     */
350    /**
351     * Callback called when a backup/restore procedure for an bundle is started.
352     * The first return string parameter indicates the name of the bundle.
353     * The second return string parameter indicates that when BusinessError errors occur,
354     * the callback data is the name of the bundle.
355     *
356     * @type { AsyncCallback<string, void | string> }
357     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
358     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
359     * @throws { BusinessError } 13500001 - The application is not added to the backup or restore
360     * @throws { BusinessError } 13500002 - Failed to start application extension Procedure
361     * @throws { BusinessError } 13600001 - IPC error
362     * @throws { BusinessError } 13900005 - I/O error
363     * @throws { BusinessError } 13900011 - Out of memory
364     * @throws { BusinessError } 13900025 - No space left on device
365     * @throws { BusinessError } 13900042 - Unknown error
366     * @syscap SystemCapability.FileManagement.StorageService.Backup
367     * @systemapi
368     * @since 12
369     */
370    onBundleBegin: AsyncCallback<string, void | string>;
371
372    /**
373     * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
374     * The return string argument indicates the name of the bundle.
375     *
376     * @throws { BusinessError } 13600001 - IPC error
377     * @throws { BusinessError } 13900005 - I/O error
378     * @throws { BusinessError } 13900011 - Out of memory
379     * @throws { BusinessError } 13900020 - Invalid argument
380     * @throws { BusinessError } 13900025 - No space left on device
381     * @throws { BusinessError } 13900042 - Unknown error
382     * @syscap SystemCapability.FileManagement.StorageService.Backup
383     * @systemapi
384     * @since 10
385     */
386    /**
387     * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
388     * The first return string parameter indicates the name of the bundle.
389     * The second return string parameter indicates that when BusinessError errors occur,
390     * the callback data is the name of the bundle.
391     *
392     * @type { AsyncCallback<string, void | string> }
393     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
394     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
395     * @throws { BusinessError } 13500003 - Backup or restore timed out
396     * @throws { BusinessError } 13500004 - Application extension death
397     * @throws { BusinessError } 13600001 - IPC error
398     * @throws { BusinessError } 13900005 - I/O error
399     * @throws { BusinessError } 13900011 - Out of memory
400     * @throws { BusinessError } 13900025 - No space left on device
401     * @throws { BusinessError } 13900042 - Unknown error
402     * @syscap SystemCapability.FileManagement.StorageService.Backup
403     * @systemapi
404     * @since 12
405     */
406    onBundleEnd: AsyncCallback<string, void | string>;
407
408    /**
409     * Callback called when the all the bundles to backup/restore are done or aborted unexpectedly.
410     *
411     * @type { AsyncCallback<undefined> }
412     * @throws { BusinessError } 13600001 - IPC error
413     * @throws { BusinessError } 13900005 - I/O error
414     * @throws { BusinessError } 13900011 - Out of memory
415     * @throws { BusinessError } 13900020 - Invalid argument
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 10
421     */
422    onAllBundlesEnd: AsyncCallback<undefined>;
423
424    /**
425     * Callback called when the backup service dies unexpectedly.
426     *
427     * @type { Callback<undefined> }
428     * @syscap SystemCapability.FileManagement.StorageService.Backup
429     * @systemapi
430     * @since 10
431     */
432    onBackupServiceDied: Callback<undefined>;
433
434    /**
435     * Callback called when the backup service return result information.
436     * The first return string parameter indicates the bundleName that triggers the callback.
437     * The second return string parameter indicates the result of the bundle.
438     *
439     * @param { string } bundleName the bundleName that triggers the callback.
440     * @param { string } result the result of the bundle.
441     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
442     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
443     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
444     * @throws { BusinessError } 13600001 - IPC error
445     * @throws { BusinessError } 13900005 - I/O error
446     * @throws { BusinessError } 13900011 - Out of memory
447     * @throws { BusinessError } 13900025 - No space left on device
448     * @throws { BusinessError } 13900042 - Unknown error
449     * @syscap SystemCapability.FileManagement.StorageService.Backup
450     * @systemapi
451     * @since 12
452     */
453    onResultReport(bundleName: string, result: string);
454
455    /**
456     * Callback called when the backup_sa service return result information.
457     * The first return string parameter indicates the result of the bundle.
458     *
459     * @param { string } bundleName the bundleName that triggers the callback.
460     * @param { string } process the process info of the bundle.
461     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
462     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
463     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
464     * @throws { BusinessError } 13500006 - Tar error
465     * @throws { BusinessError } 13500008 - Untar error
466     * @throws { BusinessError } 13600001 - IPC error
467     * @throws { BusinessError } 13900001 - Operation not permitted
468     * @throws { BusinessError } 13900005 - I/O error
469     * @throws { BusinessError } 13900011 - Out of memory
470     * @throws { BusinessError } 13900020 - Invalid argument
471     * @throws { BusinessError } 13900025 - No space left on device
472     * @syscap SystemCapability.FileManagement.StorageService.Backup
473     * @systemapi
474     * @since 12
475     */
476    onProcess(bundleName: string, process: string);
477  }
478
479  /**
480   * Control class for backup procedure.
481   *
482   * @syscap SystemCapability.FileManagement.StorageService.Backup
483   * @systemapi
484   * @since 10
485   */
486  class SessionBackup {
487    /**
488     * Constructor for obtaining the instance of the SessionBackup class.
489     *
490     * @permission ohos.permission.BACKUP
491     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
492     * @syscap SystemCapability.FileManagement.StorageService.Backup
493     * @systemapi
494     * @since 10
495     */
496    constructor(callbacks: GeneralCallbacks);
497
498    /**
499     * Append new bundles to backup.
500     *
501     * @permission ohos.permission.BACKUP
502     * @param { string[] } bundlesToBackup Bundles to backup.
503     * @returns { Promise<void> } The promise returned by the function.
504     * @throws { BusinessError } 13600001 - IPC error
505     * @throws { BusinessError } 13900001 - Operation not permitted
506     * @throws { BusinessError } 13900005 - I/O error
507     * @throws { BusinessError } 13900011 - Out of memory
508     * @throws { BusinessError } 13900020 - Invalid argument
509     * @throws { BusinessError } 13900025 - No space left on device
510     * @throws { BusinessError } 13900042 - Unknown error
511     * @syscap SystemCapability.FileManagement.StorageService.Backup
512     * @systemapi
513     * @since 10
514     */
515    /**
516     * Append new bundles and backupInfos to backup.
517     *
518     * @permission ohos.permission.BACKUP
519     * @param { string[] } bundlesToBackup Bundles to backup.
520     * @param { string[] } infos Infos to backup.
521     * @returns { Promise<void> } The promise returned by the function.
522     * @throws { BusinessError } 13600001 - IPC error
523     * @throws { BusinessError } 13900001 - Operation not permitted
524     * @throws { BusinessError } 13900005 - I/O error
525     * @throws { BusinessError } 13900011 - Out of memory
526     * @throws { BusinessError } 13900020 - Invalid argument
527     * @throws { BusinessError } 13900025 - No space left on device
528     * @throws { BusinessError } 13900042 - Unknown error
529     * @syscap SystemCapability.FileManagement.StorageService.Backup
530     * @systemapi
531     * @since 12
532     */
533    appendBundles(bundlesToBackup: string[], infos?: string[]): Promise<void>;
534
535    /**
536     * Append new bundles to backup.
537     *
538     * @permission ohos.permission.BACKUP
539     * @param { string[] } bundlesToBackup Bundles to backup.
540     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
541     * @throws { BusinessError } 13600001 - IPC error
542     * @throws { BusinessError } 13900001 - Operation not permitted
543     * @throws { BusinessError } 13900005 - I/O error
544     * @throws { BusinessError } 13900011 - Out of memory
545     * @throws { BusinessError } 13900020 - Invalid argument
546     * @throws { BusinessError } 13900025 - No space left on device
547     * @throws { BusinessError } 13900042 - Unknown error
548     * @syscap SystemCapability.FileManagement.StorageService.Backup
549     * @systemapi
550     * @since 10
551     */
552    appendBundles(bundlesToBackup: string[], callback: AsyncCallback<void>): void;
553
554    /**
555     * End Backup process
556     *
557     * @permission ohos.permission.BACKUP
558     * @returns { Promise<void> } The promise returned by the function.
559     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
560     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
561     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
562     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
563     * @throws { BusinessError } 13600001 - IPC error
564     * @throws { BusinessError } 13900001 - Operation not permitted
565     * @throws { BusinessError } 13900005 - I/O error
566     * @throws { BusinessError } 13900042 - Unknown error
567     * @syscap SystemCapability.FileManagement.StorageService.Backup
568     * @systemapi
569     * @since 12
570     */
571    release(): Promise<void>;
572  }
573
574  /**
575   * Control class for restore procedure.
576   *
577   * @syscap SystemCapability.FileManagement.StorageService.Backup
578   * @systemapi
579   * @since 10
580   */
581  class SessionRestore {
582    /**
583     * Constructor for obtaining the instance of the SessionBackup class.
584     *
585     * @permission ohos.permission.BACKUP
586     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the restore.
587     * @syscap SystemCapability.FileManagement.StorageService.Backup
588     * @systemapi
589     * @since 10
590     */
591    constructor(callbacks: GeneralCallbacks);
592
593    /**
594     * Append new bundles to be restore up during the restore.
595     *
596     * @permission ohos.permission.BACKUP
597     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
598     *     You can use the getLocalCapabilities method to obtain the value.
599     * @param { string[] } bundlesToBackup Bundles to restore.
600     * @returns { Promise<void> } The promise returned by the function.
601     * @throws { BusinessError } 13600001 - IPC error
602     * @throws { BusinessError } 13900001 - Operation not permitted
603     * @throws { BusinessError } 13900005 - I/O error
604     * @throws { BusinessError } 13900011 - Out of memory
605     * @throws { BusinessError } 13900020 - Invalid argument
606     * @throws { BusinessError } 13900025 - No space left on device
607     * @throws { BusinessError } 13900042 - Unknown error
608     * @syscap SystemCapability.FileManagement.StorageService.Backup
609     * @systemapi
610     * @since 10
611     */
612    /**
613     * Append new bundles and restoreInfos to be restore up during the restore.
614     *
615     * @permission ohos.permission.BACKUP
616     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
617     *     You can use the getLocalCapabilities method to obtain the value.
618     * @param { string[] } bundlesToBackup Bundles to restore.
619     * @param { string[] } [infos] infos to restore
620     * @returns { Promise<void> } The promise returned by the function.
621     * @throws { BusinessError } 13600001 - IPC error
622     * @throws { BusinessError } 13900001 - Operation not permitted
623     * @throws { BusinessError } 13900005 - I/O error
624     * @throws { BusinessError } 13900011 - Out of memory
625     * @throws { BusinessError } 13900020 - Invalid argument
626     * @throws { BusinessError } 13900025 - No space left on device
627     * @throws { BusinessError } 13900042 - Unknown error
628     * @syscap SystemCapability.FileManagement.StorageService.Backup
629     * @systemapi
630     * @since 12
631     */
632    appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], infos?: string[]): Promise<void>;
633
634    /**
635     * Append new bundles to be restore up during the restore.
636     *
637     * @permission ohos.permission.BACKUP
638     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
639     *     You can use the getLocalCapabilities method to obtain the value.
640     * @param { string[] } bundlesToBackup Bundles to restore.
641     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
642     * @throws { BusinessError } 13600001 - IPC error
643     * @throws { BusinessError } 13900001 - Operation not permitted
644     * @throws { BusinessError } 13900005 - I/O error
645     * @throws { BusinessError } 13900011 - Out of memory
646     * @throws { BusinessError } 13900020 - Invalid argument
647     * @throws { BusinessError } 13900025 - No space left on device
648     * @throws { BusinessError } 13900042 - Unknown error
649     * @syscap SystemCapability.FileManagement.StorageService.Backup
650     * @systemapi
651     * @since 10
652     */
653    appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], callback: AsyncCallback<void>): void;
654
655    /**
656     * Publish the file handle to the backup service to make the service aware that the file's content is ready.
657     * This interface is part of the zero-copy feature.
658     *
659     * @permission ohos.permission.BACKUP
660     * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
661     *     this file by calling getFileHandle.
662     * @returns { Promise<void> } The promise returned by the function.
663     * @throws { BusinessError } 13600001 - IPC error
664     * @throws { BusinessError } 13900001 - Operation not permitted
665     * @throws { BusinessError } 13900020 - Invalid argument
666     * @throws { BusinessError } 13900042 - Unknown error
667     * @syscap SystemCapability.FileManagement.StorageService.Backup
668     * @systemapi
669     * @since 10
670     */
671    publishFile(fileMeta: FileMeta): Promise<void>;
672
673    /**
674     * Publish the file handle to the backup service to make the service aware that the file's content is ready.
675     * This interface is part of the zero-copy feature.
676     *
677     * @permission ohos.permission.BACKUP
678     * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
679     *     this file by calling getFileHandle.
680     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when publishFile has finished.
681     * @throws { BusinessError } 13600001 - IPC error
682     * @throws { BusinessError } 13900001 - Operation not permitted
683     * @throws { BusinessError } 13900020 - Invalid argument
684     * @throws { BusinessError } 13900042 - Unknown error
685     * @syscap SystemCapability.FileManagement.StorageService.Backup
686     * @systemapi
687     * @since 10
688     */
689    publishFile(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
690
691    /**
692     * Request to get a shared file from the service. This interface is part of the zero-copy feature.
693     * Developers could get the file through onFileReady callback.
694     * When the client accomplished the file, use publishFile to publish.
695     *
696     * @permission ohos.permission.BACKUP
697     * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
698     *     from the backup procedure or the getLocalCapabilities method.
699     * @returns { Promise<void> } The promise returned by the function.
700     * @throws { BusinessError } 13600001 - IPC error
701     * @throws { BusinessError } 13900001 - Operation not permitted
702     * @throws { BusinessError } 13900020 - Invalid argument
703     * @throws { BusinessError } 13900042 - Unknown error
704     * @syscap SystemCapability.FileManagement.StorageService.Backup
705     * @systemapi
706     * @since 10
707     */
708    getFileHandle(fileMeta: FileMeta): Promise<void>;
709
710    /**
711     * Request to get a shared file from the service. This interface is part of the zero-copy feature.
712     * Developers could get the file through onFileReady callback.
713     * When the client accomplished the file, use publishFile to publish.
714     *
715     * @permission ohos.permission.BACKUP
716     * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
717     *     from the backup procedure or the getLocalCapabilities method.
718     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when getFileHandle has finished.
719     * @throws { BusinessError } 13600001 - IPC error
720     * @throws { BusinessError } 13900001 - Operation not permitted
721     * @throws { BusinessError } 13900020 - Invalid argument
722     * @throws { BusinessError } 13900042 - Unknown error
723     * @syscap SystemCapability.FileManagement.StorageService.Backup
724     * @systemapi
725     * @since 10
726     */
727    getFileHandle(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
728
729    /**
730     * End restore process
731     *
732     * @permission ohos.permission.BACKUP
733     * @returns { Promise<void> } The promise returned by the function.
734     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
735     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
736     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
737     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
738     * @throws { BusinessError } 13600001 - IPC error
739     * @throws { BusinessError } 13900001 - Operation not permitted
740     * @throws { BusinessError } 13900005 - I/O error
741     * @throws { BusinessError } 13900042 - Unknown error
742     * @syscap SystemCapability.FileManagement.StorageService.Backup
743     * @systemapi
744     * @since 12
745     */
746    release(): Promise<void>;
747  }
748
749  /**
750   * Control class for incremental backup procedure.
751   *
752   * @syscap SystemCapability.FileManagement.StorageService.Backup
753   * @systemapi
754   * @since 12
755   */
756  class IncrementalBackupSession {
757    /**
758     * Constructor for obtaining the instance of the IncrementalBackupSession class.
759     *
760     * @permission ohos.permission.BACKUP
761     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
762     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
763     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
764     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
765     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
766     * @syscap SystemCapability.FileManagement.StorageService.Backup
767     * @systemapi
768     * @since 12
769     */
770    constructor(callbacks: GeneralCallbacks);
771
772    /**
773     * Append new bundles to incremental backup.
774     *
775     * @permission ohos.permission.BACKUP
776     * @param { Array<IncrementalBackupData> } bundlesToBackup Bundles to incremental backup.
777     * @returns { Promise<void> } The promise returned by the function.
778     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
779     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
780     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
781     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
782     * @throws { BusinessError } 13600001 - IPC error
783     * @throws { BusinessError } 13900001 - Operation not permitted
784     * @throws { BusinessError } 13900005 - I/O error
785     * @throws { BusinessError } 13900011 - Out of memory
786     * @throws { BusinessError } 13900025 - No space left on device
787     * @throws { BusinessError } 13900042 - Unknown error
788     * @syscap SystemCapability.FileManagement.StorageService.Backup
789     * @systemapi
790     * @since 12
791     */
792    appendBundles(bundlesToBackup: Array<IncrementalBackupData>): Promise<void>;
793
794    /**
795     * Append new bundles to incremental backup.
796     *
797     * @permission ohos.permission.BACKUP
798     * @param { Array<IncrementalBackupData> } bundlesToAppend Bundles to incremental backup.
799     * @param { string[] } infos information of the bundlesToBackup
800     * @returns { Promise<void> } The promise returned by the function.
801     * @throws { BusinessError } 201 - Permission verification failed. This error code is usually the result returned by VerifyAccessToken.
802     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
803     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
804     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
805     * @throws { BusinessError } 13600001 - IPC error
806     * @throws { BusinessError } 13900001 - Operation not permitted
807     * @throws { BusinessError } 13900005 - I/O error
808     * @throws { BusinessError } 13900011 - Out of memory
809     * @throws { BusinessError } 13900025 - No space left on device
810     * @throws { BusinessError } 13900042 - Unknown error
811     * @syscap SystemCapability.FileManagement.StorageService.Backup
812     * @systemapi
813     * @since 12
814     */
815    appendBundles(bundlesToAppend: Array<IncrementalBackupData>, infos: string[]): Promise<void>;
816
817    /**
818     * End backup process
819     *
820     * @permission ohos.permission.BACKUP
821     * @returns { Promise<void> } The promise returned by the function.
822     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
823     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
824     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
825     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
826     * @throws { BusinessError } 13600001 - IPC error
827     * @throws { BusinessError } 13900001 - Operation not permitted
828     * @throws { BusinessError } 13900005 - I/O error
829     * @throws { BusinessError } 13900042 - Unknown error
830     * @syscap SystemCapability.FileManagement.StorageService.Backup
831     * @systemapi
832     * @since 12
833     */
834    release(): Promise<void>;
835  }
836}
837export default backup;
838