161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit CoreFileKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Module providing backup and restore capabilities.
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace backup
2761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.StorageService.Backup
2861847f8eSopenharmony_ci * @systemapi
2961847f8eSopenharmony_ci * @since 10
3061847f8eSopenharmony_ci */
3161847f8eSopenharmony_cideclare namespace backup {
3261847f8eSopenharmony_ci  /**
3361847f8eSopenharmony_ci   * Corresponding to a file's metadata. FileMeta is useful when doing IPC with the backup service.
3461847f8eSopenharmony_ci   *
3561847f8eSopenharmony_ci   * @interface FileMeta
3661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
3761847f8eSopenharmony_ci   * @systemapi
3861847f8eSopenharmony_ci   * @since 10
3961847f8eSopenharmony_ci   */
4061847f8eSopenharmony_ci  interface FileMeta {
4161847f8eSopenharmony_ci    /**
4261847f8eSopenharmony_ci     * Indicates the name of a bundle.
4361847f8eSopenharmony_ci     *
4461847f8eSopenharmony_ci     * @type { string }
4561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
4661847f8eSopenharmony_ci     * @systemapi
4761847f8eSopenharmony_ci     * @since 10
4861847f8eSopenharmony_ci     */
4961847f8eSopenharmony_ci    bundleName: string;
5061847f8eSopenharmony_ci
5161847f8eSopenharmony_ci    /**
5261847f8eSopenharmony_ci     * Indicates a uri to a file.
5361847f8eSopenharmony_ci     *
5461847f8eSopenharmony_ci     * @type { string }
5561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
5661847f8eSopenharmony_ci     * @systemapi
5761847f8eSopenharmony_ci     * @since 10
5861847f8eSopenharmony_ci     */
5961847f8eSopenharmony_ci    uri: string;
6061847f8eSopenharmony_ci  }
6161847f8eSopenharmony_ci
6261847f8eSopenharmony_ci  /**
6361847f8eSopenharmony_ci   * Corresponding to a file's data. Filedata is useful when doing IPC with the backup service.
6461847f8eSopenharmony_ci   *
6561847f8eSopenharmony_ci   * @interface FileData
6661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
6761847f8eSopenharmony_ci   * @systemapi
6861847f8eSopenharmony_ci   * @since 10
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  interface FileData {
7161847f8eSopenharmony_ci    /**
7261847f8eSopenharmony_ci     * Indicates a native file descriptor typically retrieved from the backup service to hold the file's content.
7361847f8eSopenharmony_ci     *
7461847f8eSopenharmony_ci     * @type { number }
7561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
7661847f8eSopenharmony_ci     * @systemapi
7761847f8eSopenharmony_ci     * @since 10
7861847f8eSopenharmony_ci     */
7961847f8eSopenharmony_ci    fd: number;
8061847f8eSopenharmony_ci  }
8161847f8eSopenharmony_ci
8261847f8eSopenharmony_ci  /**
8361847f8eSopenharmony_ci   * Save the time information of the incremental backup. IncrementalBackupTime is useful when doing IPC with the backup service.
8461847f8eSopenharmony_ci   *
8561847f8eSopenharmony_ci   * @interface IncrementalBackupTime
8661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
8761847f8eSopenharmony_ci   * @systemapi
8861847f8eSopenharmony_ci   * @since 12
8961847f8eSopenharmony_ci   */
9061847f8eSopenharmony_ci  interface IncrementalBackupTime {
9161847f8eSopenharmony_ci    /**
9261847f8eSopenharmony_ci     * Indicates the name of a bundle.
9361847f8eSopenharmony_ci     *
9461847f8eSopenharmony_ci     * @type { string }
9561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
9661847f8eSopenharmony_ci     * @systemapi
9761847f8eSopenharmony_ci     * @since 12
9861847f8eSopenharmony_ci     */
9961847f8eSopenharmony_ci    bundleName: string;
10061847f8eSopenharmony_ci
10161847f8eSopenharmony_ci    /**
10261847f8eSopenharmony_ci     * Time of the last incremental backup
10361847f8eSopenharmony_ci     *
10461847f8eSopenharmony_ci     * @type { number }
10561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
10661847f8eSopenharmony_ci     * @systemapi
10761847f8eSopenharmony_ci     * @since 12
10861847f8eSopenharmony_ci     */
10961847f8eSopenharmony_ci    lastIncrementalTime: number;
11061847f8eSopenharmony_ci  }
11161847f8eSopenharmony_ci
11261847f8eSopenharmony_ci  /**
11361847f8eSopenharmony_ci   * Manifest file information in incremental data. FileManifestData is useful when doing IPC with the backup service.
11461847f8eSopenharmony_ci   *
11561847f8eSopenharmony_ci   * @interface FileManifestData
11661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
11761847f8eSopenharmony_ci   * @systemapi
11861847f8eSopenharmony_ci   * @since 12
11961847f8eSopenharmony_ci   */
12061847f8eSopenharmony_ci  interface FileManifestData {
12161847f8eSopenharmony_ci    /**
12261847f8eSopenharmony_ci     * A file descriptor for the manifest file that holds the data
12361847f8eSopenharmony_ci     *
12461847f8eSopenharmony_ci     * @type { number }
12561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
12661847f8eSopenharmony_ci     * @systemapi
12761847f8eSopenharmony_ci     * @since 12
12861847f8eSopenharmony_ci     */
12961847f8eSopenharmony_ci    manifestFd: number;
13061847f8eSopenharmony_ci  }
13161847f8eSopenharmony_ci
13261847f8eSopenharmony_ci  /**
13361847f8eSopenharmony_ci   * Provides configuration parameters for backup and restore.
13461847f8eSopenharmony_ci   *
13561847f8eSopenharmony_ci   * @interface BackupParams
13661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
13761847f8eSopenharmony_ci   * @systemapi
13861847f8eSopenharmony_ci   * @since 12
13961847f8eSopenharmony_ci   */
14061847f8eSopenharmony_ci  interface BackupParams {
14161847f8eSopenharmony_ci    /**
14261847f8eSopenharmony_ci     * The optional parameters a json strings in the form of key value in backup or restore.
14361847f8eSopenharmony_ci     *
14461847f8eSopenharmony_ci     * @type { ?string }
14561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
14661847f8eSopenharmony_ci     * @systemapi
14761847f8eSopenharmony_ci     * @since 12
14861847f8eSopenharmony_ci     */
14961847f8eSopenharmony_ci    parameters?: string;
15061847f8eSopenharmony_ci  }
15161847f8eSopenharmony_ci
15261847f8eSopenharmony_ci  /**
15361847f8eSopenharmony_ci   * Control backup and restore priority sequence
15461847f8eSopenharmony_ci   *
15561847f8eSopenharmony_ci   * @interface BackupPriority
15661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
15761847f8eSopenharmony_ci   * @systemapi
15861847f8eSopenharmony_ci   * @since 12
15961847f8eSopenharmony_ci   */
16061847f8eSopenharmony_ci  interface BackupPriority {
16161847f8eSopenharmony_ci    /**
16261847f8eSopenharmony_ci     * Indicates the priority of a bundle.
16361847f8eSopenharmony_ci     *
16461847f8eSopenharmony_ci     * @type { ?number }
16561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
16661847f8eSopenharmony_ci     * @systemapi
16761847f8eSopenharmony_ci     * @since 12
16861847f8eSopenharmony_ci     */
16961847f8eSopenharmony_ci    priority?: number;
17061847f8eSopenharmony_ci  }
17161847f8eSopenharmony_ci
17261847f8eSopenharmony_ci  /**
17361847f8eSopenharmony_ci   * Corresponds to an incremental application, including its last incremental time and incremental list.
17461847f8eSopenharmony_ci   *
17561847f8eSopenharmony_ci   * @interface IncrementalBackupData
17661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
17761847f8eSopenharmony_ci   * @systemapi
17861847f8eSopenharmony_ci   * @since 12
17961847f8eSopenharmony_ci   */
18061847f8eSopenharmony_ci  interface IncrementalBackupData extends IncrementalBackupTime, FileManifestData, BackupParams, BackupPriority {}
18161847f8eSopenharmony_ci
18261847f8eSopenharmony_ci  /**
18361847f8eSopenharmony_ci   * Corresponding to a file, including its metadata and data.
18461847f8eSopenharmony_ci   * File is useful when doing IPC with the backup service.
18561847f8eSopenharmony_ci   *
18661847f8eSopenharmony_ci   * @interface File
18761847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
18861847f8eSopenharmony_ci   * @systemapi
18961847f8eSopenharmony_ci   * @since 10
19061847f8eSopenharmony_ci   */
19161847f8eSopenharmony_ci  /**
19261847f8eSopenharmony_ci   * Corresponds to a file, including its metadata and data and the file's manifest data.
19361847f8eSopenharmony_ci   * Files are useful as IPC and backup services.
19461847f8eSopenharmony_ci   *
19561847f8eSopenharmony_ci   * @interface File
19661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
19761847f8eSopenharmony_ci   * @systemapi
19861847f8eSopenharmony_ci   * @since 12
19961847f8eSopenharmony_ci   */
20061847f8eSopenharmony_ci  interface File extends FileMeta, FileData, FileManifestData {}
20161847f8eSopenharmony_ci
20261847f8eSopenharmony_ci  /**
20361847f8eSopenharmony_ci   * Obtain a Json file that describes local capabilities.
20461847f8eSopenharmony_ci   *
20561847f8eSopenharmony_ci   * @permission ohos.permission.BACKUP
20661847f8eSopenharmony_ci   * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be
20761847f8eSopenharmony_ci   *     deleted automatically when closed.
20861847f8eSopenharmony_ci   * @throws { BusinessError } 13600001 - IPC error
20961847f8eSopenharmony_ci   * @throws { BusinessError } 13900005 - I/O error
21061847f8eSopenharmony_ci   * @throws { BusinessError } 13900011 - Out of memory
21161847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
21261847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
21361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
21461847f8eSopenharmony_ci   * @systemapi
21561847f8eSopenharmony_ci   * @since 10
21661847f8eSopenharmony_ci   */
21761847f8eSopenharmony_ci  function getLocalCapabilities(): Promise<FileData>;
21861847f8eSopenharmony_ci
21961847f8eSopenharmony_ci  /**
22061847f8eSopenharmony_ci   * Obtain a Json file that describes local capabilities.
22161847f8eSopenharmony_ci   *
22261847f8eSopenharmony_ci   * @permission ohos.permission.BACKUP
22361847f8eSopenharmony_ci   * @param { AsyncCallback<FileData> } callback A callback method, the argument FileData will holding all the local capabilities.
22461847f8eSopenharmony_ci   *     The returned file is a temporal file that will be deleted automatically when closed.
22561847f8eSopenharmony_ci   * @throws { BusinessError } 13600001 - IPC error
22661847f8eSopenharmony_ci   * @throws { BusinessError } 13900005 - I/O error
22761847f8eSopenharmony_ci   * @throws { BusinessError } 13900011 - Out of memory
22861847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
22961847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
23061847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
23161847f8eSopenharmony_ci   * @systemapi
23261847f8eSopenharmony_ci   * @since 10
23361847f8eSopenharmony_ci   */
23461847f8eSopenharmony_ci  function getLocalCapabilities(callback: AsyncCallback<FileData>): void;
23561847f8eSopenharmony_ci
23661847f8eSopenharmony_ci  /**
23761847f8eSopenharmony_ci   * Obtain a json file that describes local capabilities.
23861847f8eSopenharmony_ci   *
23961847f8eSopenharmony_ci   * @permission ohos.permission.BACKUP
24061847f8eSopenharmony_ci   * @param { Array<IncrementalBackupTime> } dataList
24161847f8eSopenharmony_ci   * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be
24261847f8eSopenharmony_ci   * deleted automatically when closed.
24361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
24461847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
24561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
24661847f8eSopenharmony_ci   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
24761847f8eSopenharmony_ci   * @throws { BusinessError } 13600001 - IPC error
24861847f8eSopenharmony_ci   * @throws { BusinessError } 13900005 - I/O error
24961847f8eSopenharmony_ci   * @throws { BusinessError } 13900011 - Out of memory
25061847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
25161847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
25261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
25361847f8eSopenharmony_ci   * @systemapi
25461847f8eSopenharmony_ci   * @since 12
25561847f8eSopenharmony_ci   */
25661847f8eSopenharmony_ci  function getLocalCapabilities(dataList: Array<IncrementalBackupTime>): Promise<FileData>;
25761847f8eSopenharmony_ci
25861847f8eSopenharmony_ci  /**
25961847f8eSopenharmony_ci    * Get Backup information from bundle.
26061847f8eSopenharmony_ci    *
26161847f8eSopenharmony_ci    * @permission ohos.permission.BACKUP
26261847f8eSopenharmony_ci    * @param { string } bundleToBackup Bundle to backup.
26361847f8eSopenharmony_ci    * @returns { string } Return the backup application's info.
26461847f8eSopenharmony_ci    * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
26561847f8eSopenharmony_ci    * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
26661847f8eSopenharmony_ci    * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
26761847f8eSopenharmony_ci    * <br>2. Incorrect parameter types. 3.Parameter verification failed.
26861847f8eSopenharmony_ci    * @syscap SystemCapability.FileManagement.StorageService.Backup
26961847f8eSopenharmony_ci    * @systemapi
27061847f8eSopenharmony_ci    * @since 12
27161847f8eSopenharmony_ci    */
27261847f8eSopenharmony_ci  function getBackupInfo(bundleToBackup: string): string;
27361847f8eSopenharmony_ci
27461847f8eSopenharmony_ci  /**
27561847f8eSopenharmony_ci   * Update backup or restore timeout.
27661847f8eSopenharmony_ci   *
27761847f8eSopenharmony_ci   * @permission ohos.permission.BACKUP
27861847f8eSopenharmony_ci   * @param { string } bundleName set update to bundleName app.
27961847f8eSopenharmony_ci   * @param { number } timeout Update backup or restore timeout(unit:ms).
28061847f8eSopenharmony_ci   * @returns { boolean } Return update result, true is success, false is fail.
28161847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
28261847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
28361847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
28461847f8eSopenharmony_ci   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
28561847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
28661847f8eSopenharmony_ci   * @systemapi
28761847f8eSopenharmony_ci   * @since 12
28861847f8eSopenharmony_ci   */
28961847f8eSopenharmony_ci  function updateTimer(bundleName: string, timeout: number): boolean;
29061847f8eSopenharmony_ci
29161847f8eSopenharmony_ci  /**
29261847f8eSopenharmony_ci   * Update send file fd rate.
29361847f8eSopenharmony_ci   *
29461847f8eSopenharmony_ci   * @permission ohos.permission.BACKUP
29561847f8eSopenharmony_ci   * @param { string } bundleName set update to bundleName app.
29661847f8eSopenharmony_ci   * @param { number } sendRate set send file fd rate.
29761847f8eSopenharmony_ci   * @returns { boolean } Return update result, true is success, false is fail.
29861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
29961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
30061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
30161847f8eSopenharmony_ci   * <br>2. Incorrect parameter types. 3.Parameter verification failed.
30261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
30361847f8eSopenharmony_ci   * @systemapi
30461847f8eSopenharmony_ci   * @since 12
30561847f8eSopenharmony_ci  */
30661847f8eSopenharmony_ci  function updateSendRate(bundleName: string, sendRate: number): boolean;
30761847f8eSopenharmony_ci
30861847f8eSopenharmony_ci  /**
30961847f8eSopenharmony_ci   * General callbacks for both backup and restore procedure.
31061847f8eSopenharmony_ci   * The backup service will notify the client by these callbacks.
31161847f8eSopenharmony_ci   *
31261847f8eSopenharmony_ci   * @interface GeneralCallbacks
31361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
31461847f8eSopenharmony_ci   * @systemapi
31561847f8eSopenharmony_ci   * @since 10
31661847f8eSopenharmony_ci   */
31761847f8eSopenharmony_ci  interface GeneralCallbacks {
31861847f8eSopenharmony_ci    /**
31961847f8eSopenharmony_ci     * Callback called when the backup service tries to send files to the client.
32061847f8eSopenharmony_ci     * The File argument indicates a file to send to the client.
32161847f8eSopenharmony_ci     *     The returned file is owned by the backup service and will be cleaned by the service once the file is closed.
32261847f8eSopenharmony_ci     *
32361847f8eSopenharmony_ci     * @type { AsyncCallback<File> }
32461847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
32561847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
32661847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
32761847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
32861847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
32961847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
33061847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
33161847f8eSopenharmony_ci     * @systemapi
33261847f8eSopenharmony_ci     * @since 10
33361847f8eSopenharmony_ci     */
33461847f8eSopenharmony_ci    onFileReady: AsyncCallback<File>;
33561847f8eSopenharmony_ci
33661847f8eSopenharmony_ci    /**
33761847f8eSopenharmony_ci     * Callback called when a backup/restore procedure for an bundle is started.
33861847f8eSopenharmony_ci     * The return string argument indicates the name of the bundle.
33961847f8eSopenharmony_ci     *
34061847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
34161847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
34261847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
34361847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
34461847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
34561847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
34661847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
34761847f8eSopenharmony_ci     * @systemapi
34861847f8eSopenharmony_ci     * @since 10
34961847f8eSopenharmony_ci     */
35061847f8eSopenharmony_ci    /**
35161847f8eSopenharmony_ci     * Callback called when a backup/restore procedure for an bundle is started.
35261847f8eSopenharmony_ci     * The first return string parameter indicates the name of the bundle.
35361847f8eSopenharmony_ci     * The second return string parameter indicates that when BusinessError errors occur,
35461847f8eSopenharmony_ci     * the callback data is the name of the bundle.
35561847f8eSopenharmony_ci     *
35661847f8eSopenharmony_ci     * @type { AsyncCallback<string, void | string> }
35761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
35861847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
35961847f8eSopenharmony_ci     * @throws { BusinessError } 13500001 - The application is not added to the backup or restore
36061847f8eSopenharmony_ci     * @throws { BusinessError } 13500002 - Failed to start application extension Procedure
36161847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
36261847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
36361847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
36461847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
36561847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
36661847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
36761847f8eSopenharmony_ci     * @systemapi
36861847f8eSopenharmony_ci     * @since 12
36961847f8eSopenharmony_ci     */
37061847f8eSopenharmony_ci    onBundleBegin: AsyncCallback<string, void | string>;
37161847f8eSopenharmony_ci
37261847f8eSopenharmony_ci    /**
37361847f8eSopenharmony_ci     * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
37461847f8eSopenharmony_ci     * The return string argument indicates the name of the bundle.
37561847f8eSopenharmony_ci     *
37661847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
37761847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
37861847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
37961847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
38061847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
38161847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
38261847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
38361847f8eSopenharmony_ci     * @systemapi
38461847f8eSopenharmony_ci     * @since 10
38561847f8eSopenharmony_ci     */
38661847f8eSopenharmony_ci    /**
38761847f8eSopenharmony_ci     * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly.
38861847f8eSopenharmony_ci     * The first return string parameter indicates the name of the bundle.
38961847f8eSopenharmony_ci     * The second return string parameter indicates that when BusinessError errors occur,
39061847f8eSopenharmony_ci     * the callback data is the name of the bundle.
39161847f8eSopenharmony_ci     *
39261847f8eSopenharmony_ci     * @type { AsyncCallback<string, void | string> }
39361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
39461847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
39561847f8eSopenharmony_ci     * @throws { BusinessError } 13500003 - Backup or restore timed out
39661847f8eSopenharmony_ci     * @throws { BusinessError } 13500004 - Application extension death
39761847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
39861847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
39961847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
40061847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
40161847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
40261847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
40361847f8eSopenharmony_ci     * @systemapi
40461847f8eSopenharmony_ci     * @since 12
40561847f8eSopenharmony_ci     */
40661847f8eSopenharmony_ci    onBundleEnd: AsyncCallback<string, void | string>;
40761847f8eSopenharmony_ci
40861847f8eSopenharmony_ci    /**
40961847f8eSopenharmony_ci     * Callback called when the all the bundles to backup/restore are done or aborted unexpectedly.
41061847f8eSopenharmony_ci     *
41161847f8eSopenharmony_ci     * @type { AsyncCallback<undefined> }
41261847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
41361847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
41461847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
41561847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
41661847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
41761847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
41861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
41961847f8eSopenharmony_ci     * @systemapi
42061847f8eSopenharmony_ci     * @since 10
42161847f8eSopenharmony_ci     */
42261847f8eSopenharmony_ci    onAllBundlesEnd: AsyncCallback<undefined>;
42361847f8eSopenharmony_ci
42461847f8eSopenharmony_ci    /**
42561847f8eSopenharmony_ci     * Callback called when the backup service dies unexpectedly.
42661847f8eSopenharmony_ci     *
42761847f8eSopenharmony_ci     * @type { Callback<undefined> }
42861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
42961847f8eSopenharmony_ci     * @systemapi
43061847f8eSopenharmony_ci     * @since 10
43161847f8eSopenharmony_ci     */
43261847f8eSopenharmony_ci    onBackupServiceDied: Callback<undefined>;
43361847f8eSopenharmony_ci
43461847f8eSopenharmony_ci    /**
43561847f8eSopenharmony_ci     * Callback called when the backup service return result information.
43661847f8eSopenharmony_ci     * The first return string parameter indicates the bundleName that triggers the callback.
43761847f8eSopenharmony_ci     * The second return string parameter indicates the result of the bundle.
43861847f8eSopenharmony_ci     *
43961847f8eSopenharmony_ci     * @param { string } bundleName the bundleName that triggers the callback.
44061847f8eSopenharmony_ci     * @param { string } result the result of the bundle.
44161847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
44261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
44361847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
44461847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
44561847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
44661847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
44761847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
44861847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
44961847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
45061847f8eSopenharmony_ci     * @systemapi
45161847f8eSopenharmony_ci     * @since 12
45261847f8eSopenharmony_ci     */
45361847f8eSopenharmony_ci    onResultReport(bundleName: string, result: string);
45461847f8eSopenharmony_ci
45561847f8eSopenharmony_ci    /**
45661847f8eSopenharmony_ci     * Callback called when the backup_sa service return result information.
45761847f8eSopenharmony_ci     * The first return string parameter indicates the result of the bundle.
45861847f8eSopenharmony_ci     *
45961847f8eSopenharmony_ci     * @param { string } bundleName the bundleName that triggers the callback.
46061847f8eSopenharmony_ci     * @param { string } process the process info of the bundle.
46161847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
46261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
46361847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
46461847f8eSopenharmony_ci     * @throws { BusinessError } 13500006 - Tar error
46561847f8eSopenharmony_ci     * @throws { BusinessError } 13500008 - Untar error
46661847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
46761847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
46861847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
46961847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
47061847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
47161847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
47261847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
47361847f8eSopenharmony_ci     * @systemapi
47461847f8eSopenharmony_ci     * @since 12
47561847f8eSopenharmony_ci     */
47661847f8eSopenharmony_ci    onProcess(bundleName: string, process: string);
47761847f8eSopenharmony_ci  }
47861847f8eSopenharmony_ci
47961847f8eSopenharmony_ci  /**
48061847f8eSopenharmony_ci   * Control class for backup procedure.
48161847f8eSopenharmony_ci   *
48261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
48361847f8eSopenharmony_ci   * @systemapi
48461847f8eSopenharmony_ci   * @since 10
48561847f8eSopenharmony_ci   */
48661847f8eSopenharmony_ci  class SessionBackup {
48761847f8eSopenharmony_ci    /**
48861847f8eSopenharmony_ci     * Constructor for obtaining the instance of the SessionBackup class.
48961847f8eSopenharmony_ci     *
49061847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
49161847f8eSopenharmony_ci     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
49261847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
49361847f8eSopenharmony_ci     * @systemapi
49461847f8eSopenharmony_ci     * @since 10
49561847f8eSopenharmony_ci     */
49661847f8eSopenharmony_ci    constructor(callbacks: GeneralCallbacks);
49761847f8eSopenharmony_ci
49861847f8eSopenharmony_ci    /**
49961847f8eSopenharmony_ci     * Append new bundles to backup.
50061847f8eSopenharmony_ci     *
50161847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
50261847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to backup.
50361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
50461847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
50561847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
50661847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
50761847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
50861847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
50961847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
51061847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
51161847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
51261847f8eSopenharmony_ci     * @systemapi
51361847f8eSopenharmony_ci     * @since 10
51461847f8eSopenharmony_ci     */
51561847f8eSopenharmony_ci    /**
51661847f8eSopenharmony_ci     * Append new bundles and backupInfos to backup.
51761847f8eSopenharmony_ci     *
51861847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
51961847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to backup.
52061847f8eSopenharmony_ci     * @param { string[] } infos Infos to backup.
52161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
52261847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
52361847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
52461847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
52561847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
52661847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
52761847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
52861847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
52961847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
53061847f8eSopenharmony_ci     * @systemapi
53161847f8eSopenharmony_ci     * @since 12
53261847f8eSopenharmony_ci     */
53361847f8eSopenharmony_ci    appendBundles(bundlesToBackup: string[], infos?: string[]): Promise<void>;
53461847f8eSopenharmony_ci
53561847f8eSopenharmony_ci    /**
53661847f8eSopenharmony_ci     * Append new bundles to backup.
53761847f8eSopenharmony_ci     *
53861847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
53961847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to backup.
54061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
54161847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
54261847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
54361847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
54461847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
54561847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
54661847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
54761847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
54861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
54961847f8eSopenharmony_ci     * @systemapi
55061847f8eSopenharmony_ci     * @since 10
55161847f8eSopenharmony_ci     */
55261847f8eSopenharmony_ci    appendBundles(bundlesToBackup: string[], callback: AsyncCallback<void>): void;
55361847f8eSopenharmony_ci
55461847f8eSopenharmony_ci    /**
55561847f8eSopenharmony_ci     * End Backup process
55661847f8eSopenharmony_ci     *
55761847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
55861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
55961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
56061847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
56161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
56261847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
56361847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
56461847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
56561847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
56661847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
56761847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
56861847f8eSopenharmony_ci     * @systemapi
56961847f8eSopenharmony_ci     * @since 12
57061847f8eSopenharmony_ci     */
57161847f8eSopenharmony_ci    release(): Promise<void>;
57261847f8eSopenharmony_ci  }
57361847f8eSopenharmony_ci
57461847f8eSopenharmony_ci  /**
57561847f8eSopenharmony_ci   * Control class for restore procedure.
57661847f8eSopenharmony_ci   *
57761847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
57861847f8eSopenharmony_ci   * @systemapi
57961847f8eSopenharmony_ci   * @since 10
58061847f8eSopenharmony_ci   */
58161847f8eSopenharmony_ci  class SessionRestore {
58261847f8eSopenharmony_ci    /**
58361847f8eSopenharmony_ci     * Constructor for obtaining the instance of the SessionBackup class.
58461847f8eSopenharmony_ci     *
58561847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
58661847f8eSopenharmony_ci     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the restore.
58761847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
58861847f8eSopenharmony_ci     * @systemapi
58961847f8eSopenharmony_ci     * @since 10
59061847f8eSopenharmony_ci     */
59161847f8eSopenharmony_ci    constructor(callbacks: GeneralCallbacks);
59261847f8eSopenharmony_ci
59361847f8eSopenharmony_ci    /**
59461847f8eSopenharmony_ci     * Append new bundles to be restore up during the restore.
59561847f8eSopenharmony_ci     *
59661847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
59761847f8eSopenharmony_ci     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
59861847f8eSopenharmony_ci     *     You can use the getLocalCapabilities method to obtain the value.
59961847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to restore.
60061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
60161847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
60261847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
60361847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
60461847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
60561847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
60661847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
60761847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
60861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
60961847f8eSopenharmony_ci     * @systemapi
61061847f8eSopenharmony_ci     * @since 10
61161847f8eSopenharmony_ci     */
61261847f8eSopenharmony_ci    /**
61361847f8eSopenharmony_ci     * Append new bundles and restoreInfos to be restore up during the restore.
61461847f8eSopenharmony_ci     *
61561847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
61661847f8eSopenharmony_ci     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
61761847f8eSopenharmony_ci     *     You can use the getLocalCapabilities method to obtain the value.
61861847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to restore.
61961847f8eSopenharmony_ci     * @param { string[] } [infos] infos to restore
62061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
62161847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
62261847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
62361847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
62461847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
62561847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
62661847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
62761847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
62861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
62961847f8eSopenharmony_ci     * @systemapi
63061847f8eSopenharmony_ci     * @since 12
63161847f8eSopenharmony_ci     */
63261847f8eSopenharmony_ci    appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], infos?: string[]): Promise<void>;
63361847f8eSopenharmony_ci
63461847f8eSopenharmony_ci    /**
63561847f8eSopenharmony_ci     * Append new bundles to be restore up during the restore.
63661847f8eSopenharmony_ci     *
63761847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
63861847f8eSopenharmony_ci     * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities.
63961847f8eSopenharmony_ci     *     You can use the getLocalCapabilities method to obtain the value.
64061847f8eSopenharmony_ci     * @param { string[] } bundlesToBackup Bundles to restore.
64161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished.
64261847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
64361847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
64461847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
64561847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
64661847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
64761847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
64861847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
64961847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
65061847f8eSopenharmony_ci     * @systemapi
65161847f8eSopenharmony_ci     * @since 10
65261847f8eSopenharmony_ci     */
65361847f8eSopenharmony_ci    appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], callback: AsyncCallback<void>): void;
65461847f8eSopenharmony_ci
65561847f8eSopenharmony_ci    /**
65661847f8eSopenharmony_ci     * Publish the file handle to the backup service to make the service aware that the file's content is ready.
65761847f8eSopenharmony_ci     * This interface is part of the zero-copy feature.
65861847f8eSopenharmony_ci     *
65961847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
66061847f8eSopenharmony_ci     * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
66161847f8eSopenharmony_ci     *     this file by calling getFileHandle.
66261847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
66361847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
66461847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
66561847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
66661847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
66761847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
66861847f8eSopenharmony_ci     * @systemapi
66961847f8eSopenharmony_ci     * @since 10
67061847f8eSopenharmony_ci     */
67161847f8eSopenharmony_ci    publishFile(fileMeta: FileMeta): Promise<void>;
67261847f8eSopenharmony_ci
67361847f8eSopenharmony_ci    /**
67461847f8eSopenharmony_ci     * Publish the file handle to the backup service to make the service aware that the file's content is ready.
67561847f8eSopenharmony_ci     * This interface is part of the zero-copy feature.
67661847f8eSopenharmony_ci     *
67761847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
67861847f8eSopenharmony_ci     * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds
67961847f8eSopenharmony_ci     *     this file by calling getFileHandle.
68061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when publishFile has finished.
68161847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
68261847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
68361847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
68461847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
68561847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
68661847f8eSopenharmony_ci     * @systemapi
68761847f8eSopenharmony_ci     * @since 10
68861847f8eSopenharmony_ci     */
68961847f8eSopenharmony_ci    publishFile(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
69061847f8eSopenharmony_ci
69161847f8eSopenharmony_ci    /**
69261847f8eSopenharmony_ci     * Request to get a shared file from the service. This interface is part of the zero-copy feature.
69361847f8eSopenharmony_ci     * Developers could get the file through onFileReady callback.
69461847f8eSopenharmony_ci     * When the client accomplished the file, use publishFile to publish.
69561847f8eSopenharmony_ci     *
69661847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
69761847f8eSopenharmony_ci     * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
69861847f8eSopenharmony_ci     *     from the backup procedure or the getLocalCapabilities method.
69961847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
70061847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
70161847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
70261847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
70361847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
70461847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
70561847f8eSopenharmony_ci     * @systemapi
70661847f8eSopenharmony_ci     * @since 10
70761847f8eSopenharmony_ci     */
70861847f8eSopenharmony_ci    getFileHandle(fileMeta: FileMeta): Promise<void>;
70961847f8eSopenharmony_ci
71061847f8eSopenharmony_ci    /**
71161847f8eSopenharmony_ci     * Request to get a shared file from the service. This interface is part of the zero-copy feature.
71261847f8eSopenharmony_ci     * Developers could get the file through onFileReady callback.
71361847f8eSopenharmony_ci     * When the client accomplished the file, use publishFile to publish.
71461847f8eSopenharmony_ci     *
71561847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
71661847f8eSopenharmony_ci     * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come
71761847f8eSopenharmony_ci     *     from the backup procedure or the getLocalCapabilities method.
71861847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback Asynchronous callback to be called when getFileHandle has finished.
71961847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
72061847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
72161847f8eSopenharmony_ci     * @throws { BusinessError } 13900020 - Invalid argument
72261847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
72361847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
72461847f8eSopenharmony_ci     * @systemapi
72561847f8eSopenharmony_ci     * @since 10
72661847f8eSopenharmony_ci     */
72761847f8eSopenharmony_ci    getFileHandle(fileMeta: FileMeta, callback: AsyncCallback<void>): void;
72861847f8eSopenharmony_ci
72961847f8eSopenharmony_ci    /**
73061847f8eSopenharmony_ci     * End restore process
73161847f8eSopenharmony_ci     *
73261847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
73361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
73461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
73561847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
73661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
73761847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
73861847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
73961847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
74061847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
74161847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
74261847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
74361847f8eSopenharmony_ci     * @systemapi
74461847f8eSopenharmony_ci     * @since 12
74561847f8eSopenharmony_ci     */
74661847f8eSopenharmony_ci    release(): Promise<void>;
74761847f8eSopenharmony_ci  }
74861847f8eSopenharmony_ci
74961847f8eSopenharmony_ci  /**
75061847f8eSopenharmony_ci   * Control class for incremental backup procedure.
75161847f8eSopenharmony_ci   *
75261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
75361847f8eSopenharmony_ci   * @systemapi
75461847f8eSopenharmony_ci   * @since 12
75561847f8eSopenharmony_ci   */
75661847f8eSopenharmony_ci  class IncrementalBackupSession {
75761847f8eSopenharmony_ci    /**
75861847f8eSopenharmony_ci     * Constructor for obtaining the instance of the IncrementalBackupSession class.
75961847f8eSopenharmony_ci     *
76061847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
76161847f8eSopenharmony_ci     * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup.
76261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
76361847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
76461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
76561847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
76661847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
76761847f8eSopenharmony_ci     * @systemapi
76861847f8eSopenharmony_ci     * @since 12
76961847f8eSopenharmony_ci     */
77061847f8eSopenharmony_ci    constructor(callbacks: GeneralCallbacks);
77161847f8eSopenharmony_ci
77261847f8eSopenharmony_ci    /**
77361847f8eSopenharmony_ci     * Append new bundles to incremental backup.
77461847f8eSopenharmony_ci     *
77561847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
77661847f8eSopenharmony_ci     * @param { Array<IncrementalBackupData> } bundlesToBackup Bundles to incremental backup.
77761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
77861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
77961847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
78061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
78161847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
78261847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
78361847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
78461847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
78561847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
78661847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
78761847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
78861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
78961847f8eSopenharmony_ci     * @systemapi
79061847f8eSopenharmony_ci     * @since 12
79161847f8eSopenharmony_ci     */
79261847f8eSopenharmony_ci    appendBundles(bundlesToBackup: Array<IncrementalBackupData>): Promise<void>;
79361847f8eSopenharmony_ci
79461847f8eSopenharmony_ci    /**
79561847f8eSopenharmony_ci     * Append new bundles to incremental backup.
79661847f8eSopenharmony_ci     *
79761847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
79861847f8eSopenharmony_ci     * @param { Array<IncrementalBackupData> } bundlesToAppend Bundles to incremental backup.
79961847f8eSopenharmony_ci     * @param { string[] } infos information of the bundlesToBackup
80061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
80161847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed. This error code is usually the result returned by VerifyAccessToken.
80261847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
80361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
80461847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
80561847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
80661847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
80761847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
80861847f8eSopenharmony_ci     * @throws { BusinessError } 13900011 - Out of memory
80961847f8eSopenharmony_ci     * @throws { BusinessError } 13900025 - No space left on device
81061847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
81161847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
81261847f8eSopenharmony_ci     * @systemapi
81361847f8eSopenharmony_ci     * @since 12
81461847f8eSopenharmony_ci     */
81561847f8eSopenharmony_ci    appendBundles(bundlesToAppend: Array<IncrementalBackupData>, infos: string[]): Promise<void>;
81661847f8eSopenharmony_ci
81761847f8eSopenharmony_ci    /**
81861847f8eSopenharmony_ci     * End backup process
81961847f8eSopenharmony_ci     *
82061847f8eSopenharmony_ci     * @permission ohos.permission.BACKUP
82161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
82261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
82361847f8eSopenharmony_ci     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
82461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
82561847f8eSopenharmony_ci     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
82661847f8eSopenharmony_ci     * @throws { BusinessError } 13600001 - IPC error
82761847f8eSopenharmony_ci     * @throws { BusinessError } 13900001 - Operation not permitted
82861847f8eSopenharmony_ci     * @throws { BusinessError } 13900005 - I/O error
82961847f8eSopenharmony_ci     * @throws { BusinessError } 13900042 - Unknown error
83061847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.StorageService.Backup
83161847f8eSopenharmony_ci     * @systemapi
83261847f8eSopenharmony_ci     * @since 12
83361847f8eSopenharmony_ci     */
83461847f8eSopenharmony_ci    release(): Promise<void>;
83561847f8eSopenharmony_ci  }
83661847f8eSopenharmony_ci}
83761847f8eSopenharmony_ciexport default backup;
838