1/*
2 * Copyright (c) 2023 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 * Provides the capabilities to control cloud file synchronization.
25 *
26 * @namespace cloudSync
27 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
28 * @since 11
29 */
30declare namespace cloudSync {
31  /**
32   * Describes the Sync state type.
33   *
34   * @enum { number }
35   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
36   * @since 12
37   */
38  enum SyncState {
39    /**
40     * Indicates that the sync state is uploading.
41     *
42     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
43     * @since 12
44     */
45    UPLOADING,
46    /**
47     * Indicates that the sync failed in upload processing.
48     *
49     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
50     * @since 12
51     */
52    UPLOAD_FAILED,
53    /**
54     * Indicates that the sync state is downloading.
55     *
56     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
57     * @since 12
58     */
59    DOWNLOADING,
60    /**
61     * Indicates that the sync failed in download processing.
62     *
63     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
64     * @since 12
65     */
66    DOWNLOAD_FAILED,
67    /**
68     * Indicates that the sync finish.
69     *
70     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
71     * @since 12
72     */
73    COMPLETED,
74    /**
75     * Indicates that the sync has been stopped.
76     *
77     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
78     * @since 12
79     */
80    STOPPED
81  }
82
83  /**
84   * Describes the Sync Error type.
85   *
86   * @enum { number }
87   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
88   * @since 12
89   */
90  enum ErrorType {
91    /**
92     * No error occurred.
93     *
94     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
95     * @since 12
96     */
97    NO_ERROR,
98    /**
99     * Synchronization aborted due to network unavailable.
100     *
101     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
102     * @since 12
103     */
104    NETWORK_UNAVAILABLE,
105    /**
106     * Synchronization aborted due to wifi unavailable.
107     *
108     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
109     * @since 12
110     */
111    WIFI_UNAVAILABLE,
112    /**
113     * Synchronization aborted due to low capacity level.
114     *
115     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
116     * @since 12
117     */
118    BATTERY_LEVEL_LOW,
119    /**
120     * Synchronization aborted due to warning low capacity level.
121     *
122     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
123     * @since 12
124     */
125    BATTERY_LEVEL_WARNING,
126    /**
127     * Synchronization aborted due to cloud storage is full.
128     *
129     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
130     * @since 12
131     */
132    CLOUD_STORAGE_FULL,
133    /**
134     * Synchronization aborted due to local storage is full.
135     *
136     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
137     * @since 12
138     */
139    LOCAL_STORAGE_FULL,
140    /**
141     * Synchronization aborted due to device temperature is too high.
142     *
143     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
144     * @since 12
145     */
146    DEVICE_TEMPERATURE_TOO_HIGH,
147    
148  }
149
150  /**
151   * The SyncProgress data structure.
152   *
153   * @interface SyncProgress
154   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
155   * @since 12
156   */
157  interface SyncProgress {
158    /**
159     * The current sync state.
160     *
161     * @type { SyncState }
162     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
163     * @since 12
164     */
165    state: SyncState;
166    /**
167     * The error type of sync.
168     *
169     * @type { ErrorType }
170     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
171     * @since 12
172     */
173    error: ErrorType;
174  }
175
176  /**
177   * GallerySync object.
178   *
179   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
180   * @systemapi
181   * @since 10
182   */
183  class GallerySync {
184    /**
185     * A constructor used to create a GallerySync object.
186     *
187     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
188     * @systemapi
189     * @since 10
190     */
191    constructor();
192    /**
193     * Subscribes to sync progress change event. This method uses a callback to get sync progress changes.
194     *
195     * @permission ohos.permission.CLOUDFILE_SYNC
196     * @param { 'progress' } evt - event type.
197     * @param { function } callback - callback function with a `SyncProgress` argument.
198     * @throws { BusinessError } 201 - Permission verification failed.
199     * @throws { BusinessError } 202 - The caller is not a system application.
200     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
201     * <br>2.Incorrect parameter types.
202     * @throws { BusinessError } 13600001 - IPC error
203     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
204     * @systemapi
205     * @since 10
206     */
207    on(evt: 'progress', callback: (pg: SyncProgress) => void): void;
208    /**
209     * Unsubscribes from sync progress event.
210     *
211     * @permission ohos.permission.CLOUDFILE_SYNC
212     * @param { 'progress' } evt - event type.
213     * @param { function } callback - callback function with a `SyncProgress` argument.
214     * @throws { BusinessError } 201 - Permission verification failed.
215     * @throws { BusinessError } 202 - The caller is not a system application.
216     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
217     * <br>2.Incorrect parameter types.
218     * @throws { BusinessError } 13600001 - IPC error
219     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
220     * @systemapi
221     * @since 10
222     */
223    off(evt: 'progress', callback: (pg: SyncProgress) => void): void;
224    /**
225     * Unsubscribes all callbacks objects from sync progress event.
226     *
227     * @permission ohos.permission.CLOUDFILE_SYNC
228     * @param { 'progress' } evt - event type.
229     * @throws { BusinessError } 201 - Permission verification failed.
230     * @throws { BusinessError } 202 - The caller is not a system application.
231     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
232     * <br>2.Incorrect parameter types.
233     * @throws { BusinessError } 13600001 - IPC error
234     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
235     * @systemapi
236     * @since 10
237     */
238    off(evt: 'progress'): void;
239    /**
240     * Start the gallery sync task.
241     *
242     * @permission ohos.permission.CLOUDFILE_SYNC
243     * @returns { Promise<void> } - Return Promise.
244     * @throws { BusinessError } 201 - Permission verification failed.
245     * @throws { BusinessError } 202 - The caller is not a system application.
246     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
247     * @throws { BusinessError } 22400001 - Cloud status not ready.
248     * @throws { BusinessError } 22400002 - Network unavailable.
249     * @throws { BusinessError } 22400003 - Low battery level.
250     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
251     * @systemapi
252     * @since 10
253     */
254    start(): Promise<void>;
255    /**
256     * Start the gallery sync task with callback.
257     *
258     * @permission ohos.permission.CLOUDFILE_SYNC
259     * @param { AsyncCallback<void> } [callback] - Callback function.
260     * @throws { BusinessError } 201 - Permission verification failed.
261     * @throws { BusinessError } 202 - The caller is not a system application.
262     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
263     * <br>2.Incorrect parameter types.
264     * @throws { BusinessError } 22400001 - Cloud status not ready.
265     * @throws { BusinessError } 22400002 - Network unavailable.
266     * @throws { BusinessError } 22400003 - Low battery level.
267     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
268     * @systemapi
269     * @since 10
270     */
271    start(callback: AsyncCallback<void>): void;
272    /**
273     * Stop the gallery sync task.
274     *
275     * @permission ohos.permission.CLOUDFILE_SYNC
276     * @returns { Promise<void> } - Return Promise.
277     * @throws { BusinessError } 201 - Permission verification failed.
278     * @throws { BusinessError } 202 - The caller is not a system application.
279     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
280     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
281     * @systemapi
282     * @since 10
283     */
284    stop(): Promise<void>;
285    /**
286     * Stop the gallery sync task with callback.
287     *
288     * @permission ohos.permission.CLOUDFILE_SYNC
289     * @param { AsyncCallback<void> } [callback] - Callback function.
290     * @throws { BusinessError } 201 - Permission verification failed.
291     * @throws { BusinessError } 202 - The caller is not a system application.
292     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
293     * <br>2.Incorrect parameter types.
294     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
295     * @systemapi
296     * @since 10
297     */
298    stop(callback: AsyncCallback<void>): void;
299  }
300
301  /**
302   * Describes the State type of download.
303   *
304   * @enum { number }
305   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
306   * @since 11
307   */
308  enum State {
309    /**
310     * Indicates that the download task in process now.
311     *
312     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
313     * @since 11
314     */
315    RUNNING,
316    /**
317     * Indicates that the download task finished.
318     *
319     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
320     * @since 11
321     */
322    COMPLETED,
323    /**
324     * Indicates that the download task failed.
325     *
326     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
327     * @since 11
328     */
329    FAILED,
330    /**
331     * Indicates that the download task stopped.
332     *
333     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
334     * @since 11
335     */
336    STOPPED
337  }
338
339  /**
340   * Describes the download Error type.
341   *
342   * @enum { number }
343   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
344   * @since 11
345   */
346  enum DownloadErrorType {
347    /**
348     * No error occurred.
349     *
350     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
351     * @since 11
352     */
353    NO_ERROR,
354    /**
355     * download aborted due to unknown error.
356     *
357     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
358     * @since 11
359     */
360    UNKNOWN_ERROR,
361    /**
362     * download aborted due to network unavailable.
363     *
364     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
365     * @since 11
366     */
367    NETWORK_UNAVAILABLE,
368    /**
369     * download aborted due to local storage is full.
370     *
371     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
372     * @since 11
373     */
374    LOCAL_STORAGE_FULL,
375    /**
376     * download aborted due to content is not found in the cloud.
377     *
378     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
379     * @since 11
380     */
381    CONTENT_NOT_FOUND,
382    /**
383     * download aborted due to frequent user requests.
384     *
385     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
386     * @since 11
387     */
388    FREQUENT_USER_REQUESTS,
389  }
390
391  /**
392   * The DownloadProgress data structure.
393   *
394   * @interface DownloadProgress
395   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
396   * @since 11
397   */
398  interface DownloadProgress {
399    /**
400     * The current download state.
401     *
402     * @type { State }
403     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
404     * @since 11
405     */
406    state: State;
407    /**
408     * The processed data size for current file.
409     *
410     * @type { number }
411     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
412     * @since 11
413     */
414    processed: number;
415    /**
416     * The size of current file.
417     *
418     * @type { number }
419     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
420     * @since 11
421     */
422    size: number;
423    /**
424     * The uri of current file.
425     *
426     * @type { string }
427     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
428     * @since 11
429     */
430    uri: string;
431    /**
432     * The error type of download.
433     *
434     * @type { DownloadErrorType }
435     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
436     * @since 11
437     */
438    error: DownloadErrorType;
439  }
440
441  /**
442   * Download object.
443   *
444   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
445   * @systemapi
446   * @since 10
447   */
448  class Download {
449    /**
450     * A constructor used to create a Download object.
451     *
452     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
453     * @systemapi
454     * @since 10
455     */
456    constructor();
457    /**
458     * Subscribes to download progress change event. This method uses a callback to get download progress changes.
459     *
460     * @permission ohos.permission.CLOUDFILE_SYNC
461     * @param { 'progress' } evt - event type.
462     * @param { function } callback - callback function with a `DownloadProgress` argument.
463     * @throws { BusinessError } 201 - Permission verification failed.
464     * @throws { BusinessError } 202 - The caller is not a system application.
465     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
466     * <br>2.Incorrect parameter types.
467     * @throws { BusinessError } 13600001 - IPC error
468     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
469     * @systemapi
470     * @since 10
471     */
472    on(evt: 'progress', callback: (pg: DownloadProgress) => void): void;
473    /**
474     * Unsubscribes from download progress event.
475     *
476     * @permission ohos.permission.CLOUDFILE_SYNC
477     * @param { 'progress' } evt - event type.
478     * @param { function } callback - callback function with a `DownloadProgress` argument.
479     * @throws { BusinessError } 201 - Permission verification failed.
480     * @throws { BusinessError } 202 - The caller is not a system application.
481     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
482     * <br>2.Incorrect parameter types.
483     * @throws { BusinessError } 13600001 - IPC error
484     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
485     * @systemapi
486     * @since 10
487     */
488    off(evt: 'progress', callback: (pg: DownloadProgress) => void): void;
489    /**
490     * Unsubscribes all callbacks objects from download progress event.
491     *
492     * @permission ohos.permission.CLOUDFILE_SYNC
493     * @param { 'progress' } evt - event type.
494     * @throws { BusinessError } 201 - Permission verification failed.
495     * @throws { BusinessError } 202 - The caller is not a system application.
496     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
497     * <br>2.Incorrect parameter types.
498     * @throws { BusinessError } 13600001 - IPC error
499     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
500     * @systemapi
501     * @since 10
502     */
503    off(evt: 'progress'): void;
504    /**
505     * Start the download task.
506     *
507     * @permission ohos.permission.CLOUDFILE_SYNC
508     * @param { string } uri - uri of file.
509     * @returns { Promise<void> } - Return Promise.
510     * @throws { BusinessError } 201 - Permission verification failed.
511     * @throws { BusinessError } 202 - The caller is not a system application.
512     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
513     * <br>2.Incorrect parameter types.
514     * @throws { BusinessError } 13900002 - No such file or directory.
515     * @throws { BusinessError } 13900025 - No space left on device.
516     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
517     * @systemapi
518     * @since 10
519     */
520    start(uri: string): Promise<void>;
521    /**
522     * Start the download task with callback.
523     *
524     * @permission ohos.permission.CLOUDFILE_SYNC
525     * @param { string } uri - uri of file.
526     * @param { AsyncCallback<void> } [callback] - Callback function.
527     * @throws { BusinessError } 201 - Permission verification failed.
528     * @throws { BusinessError } 202 - The caller is not a system application.
529     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
530     * <br>2.Incorrect parameter types.
531     * @throws { BusinessError } 13900002 - No such file or directory.
532     * @throws { BusinessError } 13900025 - No space left on device.
533     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
534     * @systemapi
535     * @since 10
536     */
537    start(uri: string, callback: AsyncCallback<void>): void;
538    /**
539     * Stop the download task.
540     *
541     * @permission ohos.permission.CLOUDFILE_SYNC
542     * @param { string } uri - uri of file.
543     * @returns { Promise<void> } - Return Promise.
544     * @throws { BusinessError } 201 - Permission verification failed.
545     * @throws { BusinessError } 202 - The caller is not a system application.
546     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
547     * <br>2.Incorrect parameter types.
548     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
549     * @systemapi
550     * @since 10
551     */
552    stop(uri: string): Promise<void>;
553    /**
554     * Stop the download task with callback.
555     *
556     * @permission ohos.permission.CLOUDFILE_SYNC
557     * @param { string } uri - uri of file.
558     * @param { AsyncCallback<void> } [callback] - Callback function.
559     * @throws { BusinessError } 201 - Permission verification failed.
560     * @throws { BusinessError } 202 - The caller is not a system application.
561     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
562     * <br>2.Incorrect parameter types.
563     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
564     * @systemapi
565     * @since 10
566     */
567    stop(uri: string, callback: AsyncCallback<void>): void;
568  }
569
570  /**
571   * FileSync object.
572   *
573   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
574   * @since 12
575   */
576  class FileSync {
577    /**
578     * A constructor used to create a FileSync object.
579     *
580     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
581     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
582     * @since 12
583     */
584    constructor();
585    /**
586     * A constructor used to create a FileSync object.
587     *
588     * @param { string } bundleName - Name of the bundle that need to synchronize and subscribe the sync progress event.
589     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
590     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
591     * <br>2.Incorrect parameter types.
592     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
593     * @systemapi
594     * @since 12
595     */
596    constructor(bundleName: string);
597    /**
598     * Subscribes to sync progress change event. This method uses a callback to get sync progress changes.
599     *
600     * @param { 'progress' } event - event type.
601     * @param { Callback<SyncProgress> } callback - callback function with a `SyncProgress` argument.
602     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
603     * <br>2.Incorrect parameter types.
604     * @throws { BusinessError } 13600001 - IPC error
605     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
606     * @since 12
607     */
608    on(event: 'progress', callback: Callback<SyncProgress>): void;
609    /**
610     * Unsubscribes from sync progress event.
611     *
612     * @param { 'progress' } event - event type.
613     * @param { Callback<SyncProgress> } [callback] - callback function with a `SyncProgress` argument.
614     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types.
615     * @throws { BusinessError } 13600001 - IPC error
616     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
617     * @since 12
618     */
619    off(event: 'progress', callback?: Callback<SyncProgress>): void;
620    /**
621     * Start the file sync task.
622     *
623     * @returns { Promise<void> } - Return Promise.
624     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
625     * @throws { BusinessError } 13600001 - IPC error.
626     * @throws { BusinessError } 22400001 - Cloud status not ready.
627     * @throws { BusinessError } 22400002 - Network unavailable.
628     * @throws { BusinessError } 22400003 - Low battery level.
629     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
630     * @since 12
631     */
632    start(): Promise<void>;
633    /**
634     * Start the file sync task with callback.
635     *
636     * @param { AsyncCallback<void> } callback - Callback function.
637     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types.
638     * @throws { BusinessError } 13600001 - IPC error.
639     * @throws { BusinessError } 22400001 - Cloud status not ready.
640     * @throws { BusinessError } 22400002 - Network unavailable.
641     * @throws { BusinessError } 22400003 - Low battery level.
642     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
643     * @since 12
644     */
645    start(callback: AsyncCallback<void>): void;
646    /**
647     * Stop the file sync task.
648     *
649     * @returns { Promise<void> } - Return Promise.
650     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
651     * @throws { BusinessError } 13600001 - IPC error.
652     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
653     * @since 12
654     */
655    stop(): Promise<void>;
656    /**
657     * Stop the file sync task with callback.
658     *
659     * @param { AsyncCallback<void> } callback - Callback function.
660     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
661     * <br>2.Incorrect parameter types.
662     * @throws { BusinessError } 13600001 - IPC error.
663     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
664     * @since 12
665     */
666    stop(callback: AsyncCallback<void>): void;
667    /**
668     * Get the last synchronization time.
669     *
670     * @returns { Promise<number> } - Return the date of last synchronization.
671     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
672     * @throws { BusinessError } 13600001 - IPC error.
673     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
674     * @since 12
675     */
676    getLastSyncTime(): Promise<number>;
677    /**
678     * Get the last synchronization time.
679     *
680     * @param { AsyncCallback<number> } callback - Callback function.
681     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
682     * <br>2.Incorrect parameter types.
683     * @throws { BusinessError } 13600001 - IPC error.
684     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
685     * @since 12
686     */
687    getLastSyncTime(callback: AsyncCallback<number>): void;
688  }
689  /**
690   * CloudFileCache object.
691   *
692   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
693   * @since 11
694   */
695  class CloudFileCache {
696    /**
697     * A constructor used to create a CloudFileCache object.
698     *
699     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types.
700     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
701     * @since 11
702     */
703    constructor();
704    /**
705     * Subscribes to cloud file cache download progress change event. This method uses a callback to get download progress changes.
706     *
707     * @param { 'progress' } event - event type.
708     * @param { Callback<DownloadProgress> } callback - callback function with a `DownloadProgress` argument.
709     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
710     * <br>2.Incorrect parameter types.
711     * @throws { BusinessError } 13600001 - IPC error
712     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
713     * @since 11
714     */
715    on(event: 'progress', callback: Callback<DownloadProgress>): void;
716    /**
717     * Unsubscribes from cloud file cache download progress event.
718     *
719     * @param { 'progress' } event - event type.
720     * @param { Callback<DownloadProgress> } [callback] - callback function with a `DownloadProgress` argument.
721     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
722     * <br>2.Incorrect parameter types.
723     * @throws { BusinessError } 13600001 - IPC error
724     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
725     * @since 11
726     */
727    off(event: 'progress', callback?: Callback<DownloadProgress>): void;
728
729    /**
730     * Start the cloud file cache download task.
731     *
732     * @param { string } uri - uri of file.
733     * @returns { Promise<void> } - Return Promise.
734     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
735     * <br>2.Incorrect parameter types.
736     * @throws { BusinessError } 13600001 - IPC error.
737     * @throws { BusinessError } 13900002 - No such file or directory.
738     * @throws { BusinessError } 13900025 - No space left on device.
739     * @throws { BusinessError } 14000002 - Invalid URI.
740     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
741     * @since 11
742     */
743    start(uri: string): Promise<void>;
744    /**
745     * Start the cloud file cache download task with callback.
746     *
747     * @param { string } uri - uri of file.
748     * @param { AsyncCallback<void> } callback - Callback function.
749     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
750     * <br>2.Incorrect parameter types.
751     * @throws { BusinessError } 13600001 - IPC error.
752     * @throws { BusinessError } 13900002 - No such file or directory.
753     * @throws { BusinessError } 13900025 - No space left on device.
754     * @throws { BusinessError } 14000002 - Invalid URI.
755     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
756     * @since 11
757     */
758    start(uri: string, callback: AsyncCallback<void>): void;
759    /**
760     * Stop the cloud file cache download task.
761     *
762     * @param { string } uri - uri of file.
763     * @returns { Promise<void> } - Return Promise.
764     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
765     * <br>2.Incorrect parameter types.
766     * @throws { BusinessError } 13600001 - IPC error.
767     * @throws { BusinessError } 13900002 - No such file or directory.
768     * @throws { BusinessError } 14000002 - Invalid URI.
769     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
770     * @since 11
771     */
772    /**
773     * Stop the cloud file cache download task.
774     *
775     * @param { string } uri - uri of file.
776     * @param { boolean } [needClean] - whether to delete the file that already downloaded.
777     * @returns { Promise<void> } - Return Promise.
778     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
779     * <br>2.Incorrect parameter types.
780     * @throws { BusinessError } 13600001 - IPC error.
781     * @throws { BusinessError } 13900002 - No such file or directory.
782     * @throws { BusinessError } 14000002 - Invalid URI.
783     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
784     * @since 12
785     */
786    stop(uri: string, needClean?: boolean): Promise<void>;
787    /**
788     * Stop the cloud file cache download task with callback.
789     *
790     * @param { string } uri - uri of file.
791     * @param { AsyncCallback<void> } callback - Callback function.
792     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
793     * <br>2.Incorrect parameter types.
794     * @throws { BusinessError } 13600001 - IPC error.
795     * @throws { BusinessError } 13900002 - No such file or directory.
796     * @throws { BusinessError } 14000002 - Invalid URI.
797     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
798     * @since 11
799     */
800    stop(uri: string, callback: AsyncCallback<void>): void;
801    /**
802     * Clean the local file cache.
803     *
804     * @permission ohos.permission.CLOUDFILE_SYNC
805     * @param { string } uri - uri of file.
806     * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
807     * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
808     * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
809     * <br>2.Incorrect parameter types.
810     * @throws { BusinessError } 13600001 - IPC error.
811     * @throws { BusinessError } 13900002 - No such file or directory.
812     * @throws { BusinessError } 14000002 - Invalid URI.
813     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
814     * @systemapi
815     * @since 11
816     */
817    cleanCache(uri: string): void;
818  }
819
820  /**
821   * Describes the sync state of file.
822   *
823   * @enum { number }
824   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
825   * @systemapi
826   * @since 11
827   */
828  enum FileSyncState {
829    /**
830     * Indicates that the file cache is uploading now.
831     *
832     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
833     * @systemapi
834     * @since 11
835     */
836    UPLOADING,
837    /**
838     * Indicates that the file cache is downloading now.
839     *
840     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
841     * @systemapi
842     * @since 11
843     */
844    DOWNLOADING,
845    /**
846     * Indicates that the file cache sync task finished.
847     *
848     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
849     * @systemapi
850     * @since 11
851     */
852    COMPLETED,
853    /**
854     * Indicates that the file cache sync task stopped.
855     *
856     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
857     * @systemapi
858     * @since 11
859     */
860    STOPPED,
861    /**
862     * Indicates that the file is waiting for upload.
863     *
864     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
865     * @systemapi
866     * @since 12
867     */
868    TO_BE_UPLOADED,
869    /**
870     * Indicates that the file has been already uploaded successfully.
871     *
872     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
873     * @systemapi
874     * @since 12
875     */
876    UPLOAD_SUCCESS,
877    /**
878     * Indicates that the file upload failure.
879     *
880     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
881     * @systemapi
882     * @since 12
883     */
884    UPLOAD_FAILURE,
885  }
886
887  /**
888   * Get the sync state of file.
889   *
890   * @permission ohos.permission.CLOUDFILE_SYNC
891   * @param { Array<string> } uri - uri of files.
892   * @returns { Promise<Array<FileSyncState>> } - Return the sync state of given files.
893   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
894   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
895   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
896   * <br>2.Incorrect parameter types.
897   * @throws { BusinessError } 13600001 - IPC error.
898   * @throws { BusinessError } 13900002 - No such file or directory.
899   * @throws { BusinessError } 14000002 - Invalid URI.
900   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
901   * @systemapi
902   * @since 11
903   */
904  function getFileSyncState(uri: Array<string>): Promise<Array<FileSyncState>>;
905  /**
906   * Get the sync state of file.
907   *
908   * @permission ohos.permission.CLOUDFILE_SYNC
909   * @param { Array<string> } uri - uri of file.
910   * @param { AsyncCallback<Array<FileSyncState>> } callback - The callback is used to return the sync state of given files.
911   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
912   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
913   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
914   * <br>2.Incorrect parameter types.
915   * @throws { BusinessError } 13600001 - IPC error.
916   * @throws { BusinessError } 13900002 - No such file or directory.
917   * @throws { BusinessError } 14000002 - Invalid URI.
918   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
919   * @systemapi
920   * @since 11
921   */
922  function getFileSyncState(uri: Array<string>, callback: AsyncCallback<Array<FileSyncState>>): void;
923  /**
924   * Get the sync state of file.
925   *
926   * @param { string } uri - uri of file.
927   * @returns { FileSyncState } - return the sync state of given files.
928   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
929   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
930   * <br>2.Incorrect parameter types.
931   * @throws { BusinessError } 13900002 - No such file or directory.
932   * @throws { BusinessError } 13900004 - Interrupted system call
933   * @throws { BusinessError } 13900010 - Try again
934   * @throws { BusinessError } 13900012 - Permission denied by the file system
935   * @throws { BusinessError } 13900031 - Function not implemented
936   * @throws { BusinessError } 13900042 - Unknown error 
937   * @throws { BusinessError } 14000002 - Invalid URI.
938   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
939   * @systemapi
940   * @since 12
941   */
942  function getFileSyncState(uri: string): FileSyncState;
943  /**
944   * Register change notify for the specified uri.
945   *
946   * @param { string } uri - uri of file.
947   * @param { boolean } recursion - Whether to monitor the child files.
948   * @param { Callback<ChangeData> } callback - Returns the changed data.
949   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
950   * <br>2.Incorrect parameter types.
951   * @throws { BusinessError } 13900001 - Operation not permitted
952   * @throws { BusinessError } 13900002 - No such file or directory.
953   * @throws { BusinessError } 13900012 - Permission denied
954   * @throws { BusinessError } 14000002 - Invalid URI.
955   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
956   * @since 12
957   */
958  function registerChange(uri: string, recursion: boolean, callback: Callback<ChangeData>): void;
959  /**
960   * Unregister change notify fir the specified uri.
961   *
962   * @param { string } uri - uri of file.
963   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
964   * <br>2.Incorrect parameter types.
965   * @throws { BusinessError } 13900001 - Operation not permitted
966   * @throws { BusinessError } 13900002 - No such file or directory.
967   * @throws { BusinessError } 13900012 - Permission denied
968   * @throws { BusinessError } 14000002 - Invalid URI.
969   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
970   * @since 12
971   */
972  function unregisterChange(uri: string): void;
973
974  /**
975   * Enumeration types of data change.
976   *
977   * @enum { number } NotifyType
978   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
979   * @since 12
980   */
981  enum NotifyType {
982    /**
983     * File has been newly created
984     *
985     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
986     * @since 12
987     */
988    NOTIFY_ADDED,
989    /**
990     * File has been modified.
991     *
992     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
993     * @since 12
994     */
995    NOTIFY_MODIFIED,
996    /**
997     * File has been deleted.
998     *
999     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1000     * @since 12
1001     */
1002    NOTIFY_DELETED,
1003    /**
1004     * File has been renamed or moved.
1005     *
1006     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1007     * @since 12
1008     */
1009    NOTIFY_RENAMED
1010  }
1011
1012  /** 
1013   * Defines the change data
1014   * 
1015   * @interface ChangeData
1016   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1017   * @since 12
1018   */
1019  interface ChangeData {
1020    /**
1021     * The notify type of the change.
1022     * 
1023     * @type {NotifyType}
1024     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1025     * @since 12
1026     */
1027    type: NotifyType;
1028    /**
1029     * Indicates whether the changed uri is directory.
1030     * 
1031     * @type {Array<boolean>}
1032     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1033     * @since 12
1034     */
1035    isDirectory: Array<boolean>;
1036    /**
1037     * The changed uris.
1038     * 
1039     * @type {Array<string>}
1040     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
1041     * @since 12
1042     */
1043    uris: Array<string>;
1044  }
1045}
1046
1047export default cloudSync;
1048