161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 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 BackupExtensionContext from './@ohos.file.BackupExtensionContext';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Describe bundle version
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @interface BundleVersion
2761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.StorageService.Backup
2861847f8eSopenharmony_ci * @StageModelOnly
2961847f8eSopenharmony_ci * @since 10
3061847f8eSopenharmony_ci */
3161847f8eSopenharmony_ciexport interface BundleVersion {
3261847f8eSopenharmony_ci  /**
3361847f8eSopenharmony_ci   * Indicates bundle's version code.
3461847f8eSopenharmony_ci   *
3561847f8eSopenharmony_ci   * @type { number }
3661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
3761847f8eSopenharmony_ci   * @StageModelOnly
3861847f8eSopenharmony_ci   * @since 10
3961847f8eSopenharmony_ci   */
4061847f8eSopenharmony_ci  code: number;
4161847f8eSopenharmony_ci
4261847f8eSopenharmony_ci  /**
4361847f8eSopenharmony_ci   * Indicates bundle's version name.
4461847f8eSopenharmony_ci   *
4561847f8eSopenharmony_ci   * @type { string }
4661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
4761847f8eSopenharmony_ci   * @StageModelOnly
4861847f8eSopenharmony_ci   * @since 10
4961847f8eSopenharmony_ci   */
5061847f8eSopenharmony_ci  name: string;
5161847f8eSopenharmony_ci}
5261847f8eSopenharmony_ci
5361847f8eSopenharmony_ci/**
5461847f8eSopenharmony_ci * Class to be override for backup extension ability.
5561847f8eSopenharmony_ci *
5661847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.StorageService.Backup
5761847f8eSopenharmony_ci * @StageModelOnly
5861847f8eSopenharmony_ci * @since 10
5961847f8eSopenharmony_ci */
6061847f8eSopenharmony_ciexport default class BackupExtensionAbility {
6161847f8eSopenharmony_ci  /**
6261847f8eSopenharmony_ci   * Indicates backup extension ability context.
6361847f8eSopenharmony_ci   *
6461847f8eSopenharmony_ci   * @type { ExtensionContext }
6561847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
6661847f8eSopenharmony_ci   * @StageModelOnly
6761847f8eSopenharmony_ci   * @since 11
6861847f8eSopenharmony_ci   */
6961847f8eSopenharmony_ci    /**
7061847f8eSopenharmony_ci   * Indicates backup extension ability context.
7161847f8eSopenharmony_ci   *
7261847f8eSopenharmony_ci   * @type { BackupExtensionContext }
7361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
7461847f8eSopenharmony_ci   * @StageModelOnly
7561847f8eSopenharmony_ci   * @since 12
7661847f8eSopenharmony_ci   */
7761847f8eSopenharmony_ci  context: BackupExtensionContext;
7861847f8eSopenharmony_ci
7961847f8eSopenharmony_ci  /**
8061847f8eSopenharmony_ci   * Callback to be called when the backup procedure is started.
8161847f8eSopenharmony_ci   * Developer could override this method to build files to be backup.
8261847f8eSopenharmony_ci   *
8361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
8461847f8eSopenharmony_ci   * @StageModelOnly
8561847f8eSopenharmony_ci   * @since 10
8661847f8eSopenharmony_ci   */
8761847f8eSopenharmony_ci  onBackup(): void;
8861847f8eSopenharmony_ci
8961847f8eSopenharmony_ci  /**
9061847f8eSopenharmony_ci   * Callback to be called when the backup procedure is started.
9161847f8eSopenharmony_ci   * Developer could override this method to restore.
9261847f8eSopenharmony_ci   *
9361847f8eSopenharmony_ci   * @param { string } backupInfo BackupInfo to be backup, the param is a JSON string,
9461847f8eSopenharmony_ci   * it is an array, each array element includes detail and type now.
9561847f8eSopenharmony_ci   * @returns { string | Promise<string> } Return backup result, support promise, the result is a JSON string,
9661847f8eSopenharmony_ci   * it includes type, errorCode and errorInfo now.
9761847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
9861847f8eSopenharmony_ci   * @StageModelOnly
9961847f8eSopenharmony_ci   * @since 12
10061847f8eSopenharmony_ci   */
10161847f8eSopenharmony_ci  onBackupEx(backupInfo: string): string | Promise<string>;
10261847f8eSopenharmony_ci
10361847f8eSopenharmony_ci  /**
10461847f8eSopenharmony_ci   * Callback to be called when the restore procedure is started.
10561847f8eSopenharmony_ci   * Developer could override this method to restore from copies for various bundle versions.
10661847f8eSopenharmony_ci   *
10761847f8eSopenharmony_ci   * @param { BundleVersion } bundleVersion Bundle version to be restore.
10861847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
10961847f8eSopenharmony_ci   * @StageModelOnly
11061847f8eSopenharmony_ci   * @since 10
11161847f8eSopenharmony_ci   */
11261847f8eSopenharmony_ci  onRestore(bundleVersion: BundleVersion): void;
11361847f8eSopenharmony_ci
11461847f8eSopenharmony_ci  /**
11561847f8eSopenharmony_ci   * Callback to be called when the restore procedure is started.
11661847f8eSopenharmony_ci   * Developer could override this method to restore.
11761847f8eSopenharmony_ci   *
11861847f8eSopenharmony_ci   * @param { BundleVersion } bundleVersion Bundle version to be restore.
11961847f8eSopenharmony_ci   * @param { string } restoreInfo RestoreInfo to be restore, the param is a JSON string,
12061847f8eSopenharmony_ci   * it is an array, each array element includes detail and type now.
12161847f8eSopenharmony_ci   * @returns { string | Promise<string> } Return restore result, support promise. the result is a JSON string,
12261847f8eSopenharmony_ci   * it includes type, errorCode and errorInfo now.
12361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.StorageService.Backup
12461847f8eSopenharmony_ci   * @StageModelOnly
12561847f8eSopenharmony_ci   * @since 12
12661847f8eSopenharmony_ci   */
12761847f8eSopenharmony_ci  onRestoreEx(bundleVersion: BundleVersion, restoreInfo: string): string | Promise<string>;
12861847f8eSopenharmony_ci
12961847f8eSopenharmony_ci  /**
13061847f8eSopenharmony_ci    * Callback to be called when getting application backupInfo.
13161847f8eSopenharmony_ci    * Developer could override this method to provide the backupInfo.
13261847f8eSopenharmony_ci    *
13361847f8eSopenharmony_ci    * @returns { string } Return the backup application's info.
13461847f8eSopenharmony_ci    * @syscap SystemCapability.FileManagement.StorageService.Backup
13561847f8eSopenharmony_ci    * @systemapi
13661847f8eSopenharmony_ci    * @StageModelOnly
13761847f8eSopenharmony_ci    * @since 12
13861847f8eSopenharmony_ci    */
13961847f8eSopenharmony_ci  getBackupInfo(): string;
14061847f8eSopenharmony_ci
14161847f8eSopenharmony_ci  /**
14261847f8eSopenharmony_ci    * Callback to be called when getting backup/restore process info.
14361847f8eSopenharmony_ci    * Developer could override this method to provide the backup/restore process info.
14461847f8eSopenharmony_ci    * 
14561847f8eSopenharmony_ci    * @returns { string } Return the backup/restore process info.
14661847f8eSopenharmony_ci    * @syscap SystemCapability.FileManagement.StorageService.Backup
14761847f8eSopenharmony_ci    * @StageModelOnly
14861847f8eSopenharmony_ci    * @since 12
14961847f8eSopenharmony_ci    */
15061847f8eSopenharmony_ci  onProcess(): string;
15161847f8eSopenharmony_ci}
152