• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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 BackupExtensionContext from './@ohos.file.BackupExtensionContext';
22
23/**
24 * Describe bundle version
25 *
26 * @interface BundleVersion
27 * @syscap SystemCapability.FileManagement.StorageService.Backup
28 * @StageModelOnly
29 * @since 10
30 */
31export interface BundleVersion {
32  /**
33   * Indicates bundle's version code.
34   *
35   * @type { number }
36   * @syscap SystemCapability.FileManagement.StorageService.Backup
37   * @StageModelOnly
38   * @since 10
39   */
40  code: number;
41
42  /**
43   * Indicates bundle's version name.
44   *
45   * @type { string }
46   * @syscap SystemCapability.FileManagement.StorageService.Backup
47   * @StageModelOnly
48   * @since 10
49   */
50  name: string;
51}
52
53/**
54 * Class to be override for backup extension ability.
55 *
56 * @syscap SystemCapability.FileManagement.StorageService.Backup
57 * @StageModelOnly
58 * @since 10
59 */
60export default class BackupExtensionAbility {
61  /**
62   * Indicates backup extension ability context.
63   *
64   * @type { ExtensionContext }
65   * @syscap SystemCapability.FileManagement.StorageService.Backup
66   * @StageModelOnly
67   * @since 11
68   */
69    /**
70   * Indicates backup extension ability context.
71   *
72   * @type { BackupExtensionContext }
73   * @syscap SystemCapability.FileManagement.StorageService.Backup
74   * @StageModelOnly
75   * @since 12
76   */
77  context: BackupExtensionContext;
78
79  /**
80   * Callback to be called when the backup procedure is started.
81   * Developer could override this method to build files to be backup.
82   *
83   * @syscap SystemCapability.FileManagement.StorageService.Backup
84   * @StageModelOnly
85   * @since 10
86   */
87  onBackup(): void;
88
89  /**
90   * Callback to be called when the backup procedure is started.
91   * Developer could override this method to restore.
92   *
93   * @param { string } backupInfo BackupInfo to be backup, the param is a JSON string,
94   * it is an array, each array element includes detail and type now.
95   * @returns { string | Promise<string> } Return backup result, support promise, the result is a JSON string,
96   * it includes type, errorCode and errorInfo now.
97   * @syscap SystemCapability.FileManagement.StorageService.Backup
98   * @StageModelOnly
99   * @since 12
100   */
101  onBackupEx(backupInfo: string): string | Promise<string>;
102
103  /**
104   * Callback to be called when the restore procedure is started.
105   * Developer could override this method to restore from copies for various bundle versions.
106   *
107   * @param { BundleVersion } bundleVersion Bundle version to be restore.
108   * @syscap SystemCapability.FileManagement.StorageService.Backup
109   * @StageModelOnly
110   * @since 10
111   */
112  onRestore(bundleVersion: BundleVersion): void;
113
114  /**
115   * Callback to be called when the restore procedure is started.
116   * Developer could override this method to restore.
117   *
118   * @param { BundleVersion } bundleVersion Bundle version to be restore.
119   * @param { string } restoreInfo RestoreInfo to be restore, the param is a JSON string,
120   * it is an array, each array element includes detail and type now.
121   * @returns { string | Promise<string> } Return restore result, support promise. the result is a JSON string,
122   * it includes type, errorCode and errorInfo now.
123   * @syscap SystemCapability.FileManagement.StorageService.Backup
124   * @StageModelOnly
125   * @since 12
126   */
127  onRestoreEx(bundleVersion: BundleVersion, restoreInfo: string): string | Promise<string>;
128
129  /**
130    * Callback to be called when getting application backupInfo.
131    * Developer could override this method to provide the backupInfo.
132    *
133    * @returns { string } Return the backup application's info.
134    * @syscap SystemCapability.FileManagement.StorageService.Backup
135    * @systemapi
136    * @StageModelOnly
137    * @since 12
138    */
139  getBackupInfo(): string;
140
141  /**
142    * Callback to be called when getting backup/restore process info.
143    * Developer could override this method to provide the backup/restore process info.
144    *
145    * @returns { string } Return the backup/restore process info.
146    * @syscap SystemCapability.FileManagement.StorageService.Backup
147    * @StageModelOnly
148    * @since 12
149    */
150  onProcess(): string;
151}
152