• 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
21/*** if arkts 1.1 */
22import type BackupExtensionContext from './@ohos.file.BackupExtensionContext';
23/*** endif */
24
25/**
26 * Describe bundle version
27 *
28 * @interface BundleVersion
29 * @syscap SystemCapability.FileManagement.StorageService.Backup
30 * @StageModelOnly
31 * @since arkts {'1.1':'10', '1.2':'20'}
32 * @arkts 1.1&1.2
33 */
34export interface BundleVersion {
35  /**
36   * Indicates bundle's version code.
37   *
38   * @type { number }
39   * @syscap SystemCapability.FileManagement.StorageService.Backup
40   * @StageModelOnly
41   * @since arkts {'1.1':'10', '1.2':'20'}
42   * @arkts 1.1&1.2
43   */
44  code: number;
45
46  /**
47   * Indicates bundle's version name.
48   *
49   * @type { string }
50   * @syscap SystemCapability.FileManagement.StorageService.Backup
51   * @StageModelOnly
52   * @since arkts {'1.1':'10', '1.2':'20'}
53   * @arkts 1.1&1.2
54   */
55  name: string;
56}
57
58/**
59 * Class to be override for backup extension ability.
60 *
61 * @syscap SystemCapability.FileManagement.StorageService.Backup
62 * @StageModelOnly
63 * @since arkts {'1.1':'10', '1.2':'20'}
64 * @arkts 1.1&1.2
65 */
66declare class BackupExtensionAbility {
67  /**
68   * Indicates backup extension ability context.
69   *
70   * @type { ExtensionContext }
71   * @syscap SystemCapability.FileManagement.StorageService.Backup
72   * @StageModelOnly
73   * @since 11
74   */
75    /**
76   * Indicates backup extension ability context.
77   *
78   * @type { BackupExtensionContext }
79   * @syscap SystemCapability.FileManagement.StorageService.Backup
80   * @StageModelOnly
81   * @since 12
82   */
83  context: BackupExtensionContext;
84
85  /**
86   * Callback to be called when the backup procedure is started.
87   * Developer could override this method to build files to be backup.
88   *
89   * @syscap SystemCapability.FileManagement.StorageService.Backup
90   * @StageModelOnly
91   * @since arkts {'1.1':'10', '1.2':'20'}
92   * @arkts 1.1&1.2
93   */
94  onBackup(): void;
95
96  /**
97   * Callback to be called when the backup procedure is started.
98   * Developer could override this method to restore.
99   *
100   * @param { string } backupInfo BackupInfo to be backup, the param is a JSON string,
101   * it is an array, each array element includes detail and type now.
102   * @returns { string | Promise<string> } Return backup result, support promise, the result is a JSON string,
103   * it includes type, errorCode and errorInfo now.
104   * @syscap SystemCapability.FileManagement.StorageService.Backup
105   * @StageModelOnly
106   * @since 12
107   */
108  onBackupEx(backupInfo: string): string | Promise<string>;
109
110  /**
111   * Callback to be called when the restore procedure is started.
112   * Developer could override this method to restore from copies for various bundle versions.
113   *
114   * @param { BundleVersion } bundleVersion Bundle version to be restore.
115   * @syscap SystemCapability.FileManagement.StorageService.Backup
116   * @StageModelOnly
117   * @since arkts {'1.1':'10', '1.2':'20'}
118   * @arkts 1.1&1.2
119   */
120  onRestore(bundleVersion: BundleVersion): void;
121
122  /**
123   * Callback to be called when the restore procedure is started.
124   * Developer could override this method to restore.
125   *
126   * @param { BundleVersion } bundleVersion Bundle version to be restore.
127   * @param { string } restoreInfo RestoreInfo to be restore, the param is a JSON string,
128   * it is an array, each array element includes detail and type now.
129   * @returns { string | Promise<string> } Return restore result, support promise. the result is a JSON string,
130   * it includes type, errorCode and errorInfo now.
131   * @syscap SystemCapability.FileManagement.StorageService.Backup
132   * @StageModelOnly
133   * @since 12
134   */
135  onRestoreEx(bundleVersion: BundleVersion, restoreInfo: string): string | Promise<string>;
136
137  /**
138    * Callback to be called when getting application backupInfo.
139    * Developer could override this method to provide the backupInfo.
140    *
141    * @returns { string } Return the backup application's info.
142    * @syscap SystemCapability.FileManagement.StorageService.Backup
143    * @systemapi
144    * @StageModelOnly
145    * @since 12
146    */
147  getBackupInfo(): string;
148
149  /**
150    * Callback to be called when getting backup/restore process info.
151    * Developer could override this method to provide the backup/restore process info.
152    *
153    * @returns { string } Return the backup/restore process info.
154    * @syscap SystemCapability.FileManagement.StorageService.Backup
155    * @StageModelOnly
156    * @since 12
157    */
158  onProcess(): string;
159
160  /**
161   * Callback to be called before extension ability exits.
162   * Developer could override this method to clean abnormal data.
163   *
164   * @param { number } scenario - The value 1 indicates backup and the value 2 indicates restoration.
165   * @returns { Promise<void> } the promise returned by the function
166   * @syscap SystemCapability.FileManagement.StorageService.Backup
167   * @StageModelOnly
168   * @since 20
169   */
170  onRelease(scenario: number): Promise<void>;
171
172  /**
173   * Callback to be called when getting application backup compatibilityInfo.
174   * Developer could override this method to provide the backup compatibilityInfo.
175   *
176   * @param { string } extInfo Information about the capabilities of the peer.
177   * @returns { Promise<string> } Return backup compatibilityInfo, support promise.
178   * @syscap SystemCapability.FileManagement.StorageService.Backup
179   * @systemapi
180   * @StageModelOnly
181   * @since 20
182   */
183  getBackupCompatibilityInfo(extInfo: string) : Promise<string>;
184
185  /**
186   * Callback to be called when getting application restore compatibilityInfo.
187   * Developer could override this method to provide the restore compatibilityInfo.
188   *
189   * @param { string } extInfo Information about the capabilities of the peer.
190   * @returns { Promise<string> } Return restore compatibilityInfo, support promise.
191   * @syscap SystemCapability.FileManagement.StorageService.Backup
192   * @systemapi
193   * @StageModelOnly
194   * @since 20
195   */
196  getRestoreCompatibilityInfo(extInfo: string) : Promise<string>;
197}
198
199export default BackupExtensionAbility;
200