1/* 2 * Copyright (c) 2023-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 { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Module providing backup and restore capabilities. 25 * 26 * @namespace backup 27 * @syscap SystemCapability.FileManagement.StorageService.Backup 28 * @systemapi 29 * @since 10 30 */ 31declare namespace backup { 32 /** 33 * Corresponding to a file's metadata. FileMeta is useful when doing IPC with the backup service. 34 * 35 * @interface FileMeta 36 * @syscap SystemCapability.FileManagement.StorageService.Backup 37 * @systemapi 38 * @since 10 39 */ 40 interface FileMeta { 41 /** 42 * Indicates the name of a bundle. 43 * 44 * @type { string } 45 * @syscap SystemCapability.FileManagement.StorageService.Backup 46 * @systemapi 47 * @since 10 48 */ 49 bundleName: string; 50 51 /** 52 * Indicates a uri to a file. 53 * 54 * @type { string } 55 * @syscap SystemCapability.FileManagement.StorageService.Backup 56 * @systemapi 57 * @since 10 58 */ 59 uri: string; 60 } 61 62 /** 63 * Corresponding to a file's data. Filedata is useful when doing IPC with the backup service. 64 * 65 * @interface FileData 66 * @syscap SystemCapability.FileManagement.StorageService.Backup 67 * @systemapi 68 * @since 10 69 */ 70 interface FileData { 71 /** 72 * Indicates a native file descriptor typically retrieved from the backup service to hold the file's content. 73 * 74 * @type { number } 75 * @syscap SystemCapability.FileManagement.StorageService.Backup 76 * @systemapi 77 * @since 10 78 */ 79 fd: number; 80 } 81 82 /** 83 * Save the time information of the incremental backup. IncrementalBackupTime is useful when doing IPC with the backup service. 84 * 85 * @interface IncrementalBackupTime 86 * @syscap SystemCapability.FileManagement.StorageService.Backup 87 * @systemapi 88 * @since 12 89 */ 90 interface IncrementalBackupTime { 91 /** 92 * Indicates the name of a bundle. 93 * 94 * @type { string } 95 * @syscap SystemCapability.FileManagement.StorageService.Backup 96 * @systemapi 97 * @since 12 98 */ 99 bundleName: string; 100 101 /** 102 * Time of the last incremental backup 103 * 104 * @type { number } 105 * @syscap SystemCapability.FileManagement.StorageService.Backup 106 * @systemapi 107 * @since 12 108 */ 109 lastIncrementalTime: number; 110 } 111 112 /** 113 * Manifest file information in incremental data. FileManifestData is useful when doing IPC with the backup service. 114 * 115 * @interface FileManifestData 116 * @syscap SystemCapability.FileManagement.StorageService.Backup 117 * @systemapi 118 * @since 12 119 */ 120 interface FileManifestData { 121 /** 122 * A file descriptor for the manifest file that holds the data 123 * 124 * @type { number } 125 * @syscap SystemCapability.FileManagement.StorageService.Backup 126 * @systemapi 127 * @since 12 128 */ 129 manifestFd: number; 130 } 131 132 /** 133 * Provides configuration parameters for backup and restore. 134 * 135 * @interface BackupParams 136 * @syscap SystemCapability.FileManagement.StorageService.Backup 137 * @systemapi 138 * @since 12 139 */ 140 interface BackupParams { 141 /** 142 * The optional parameters a json strings in the form of key value in backup or restore. 143 * 144 * @type { ?string } 145 * @syscap SystemCapability.FileManagement.StorageService.Backup 146 * @systemapi 147 * @since 12 148 */ 149 parameters?: string; 150 } 151 152 /** 153 * Control backup and restore priority sequence 154 * 155 * @interface BackupPriority 156 * @syscap SystemCapability.FileManagement.StorageService.Backup 157 * @systemapi 158 * @since 12 159 */ 160 interface BackupPriority { 161 /** 162 * Indicates the priority of a bundle. 163 * 164 * @type { ?number } 165 * @syscap SystemCapability.FileManagement.StorageService.Backup 166 * @systemapi 167 * @since 12 168 */ 169 priority?: number; 170 } 171 172 /** 173 * Corresponds to an incremental application, including its last incremental time and incremental list. 174 * 175 * @extends IncrementalBackupTime, FileManifestData, BackupParams, BackupPriority 176 * @interface IncrementalBackupData 177 * @syscap SystemCapability.FileManagement.StorageService.Backup 178 * @systemapi 179 * @since 12 180 */ 181 interface IncrementalBackupData extends IncrementalBackupTime, FileManifestData, BackupParams, BackupPriority {} 182 183 /** 184 * Corresponding to a file, including its metadata and data. 185 * File is useful when doing IPC with the backup service. 186 * 187 * @extends FileMeta, FileData, FileManifestData 188 * @interface File 189 * @syscap SystemCapability.FileManagement.StorageService.Backup 190 * @systemapi 191 * @since 10 192 */ 193 /** 194 * Corresponds to a file, including its metadata and data and the file's manifest data. 195 * Files are useful as IPC and backup services. 196 * 197 * @extends FileMeta, FileData, FileManifestData 198 * @interface File 199 * @syscap SystemCapability.FileManagement.StorageService.Backup 200 * @systemapi 201 * @since 12 202 */ 203 interface File extends FileMeta, FileData, FileManifestData {} 204 205 /** 206 * Obtain a Json file that describes local capabilities. 207 * 208 * @permission ohos.permission.BACKUP 209 * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be 210 * deleted automatically when closed. 211 * @throws { BusinessError } 13600001 - IPC error 212 * @throws { BusinessError } 13900005 - I/O error 213 * @throws { BusinessError } 13900011 - Out of memory 214 * @throws { BusinessError } 13900025 - No space left on device 215 * @throws { BusinessError } 13900042 - Unknown error 216 * @syscap SystemCapability.FileManagement.StorageService.Backup 217 * @systemapi 218 * @since 10 219 */ 220 function getLocalCapabilities(): Promise<FileData>; 221 222 /** 223 * Obtain a Json file that describes local capabilities. 224 * 225 * @permission ohos.permission.BACKUP 226 * @param { AsyncCallback<FileData> } callback A callback method, the argument FileData will holding all the local capabilities. 227 * The returned file is a temporal file that will be deleted automatically when closed. 228 * @throws { BusinessError } 13600001 - IPC error 229 * @throws { BusinessError } 13900005 - I/O error 230 * @throws { BusinessError } 13900011 - Out of memory 231 * @throws { BusinessError } 13900025 - No space left on device 232 * @throws { BusinessError } 13900042 - Unknown error 233 * @syscap SystemCapability.FileManagement.StorageService.Backup 234 * @systemapi 235 * @since 10 236 */ 237 function getLocalCapabilities(callback: AsyncCallback<FileData>): void; 238 239 /** 240 * Obtain a json file that describes local capabilities. 241 * 242 * @permission ohos.permission.BACKUP 243 * @param { Array<IncrementalBackupTime> } dataList 244 * @returns { Promise<FileData> } A FileData holding all the local capabilities. The returned file is a temporal file that will be 245 * deleted automatically when closed. 246 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 247 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 248 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 249 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 250 * @throws { BusinessError } 13600001 - IPC error 251 * @throws { BusinessError } 13900005 - I/O error 252 * @throws { BusinessError } 13900011 - Out of memory 253 * @throws { BusinessError } 13900025 - No space left on device 254 * @throws { BusinessError } 13900042 - Unknown error 255 * @syscap SystemCapability.FileManagement.StorageService.Backup 256 * @systemapi 257 * @since 12 258 */ 259 function getLocalCapabilities(dataList: Array<IncrementalBackupTime>): Promise<FileData>; 260 261 /** 262 * Get Backup information from bundle. 263 * 264 * @permission ohos.permission.BACKUP 265 * @param { string } bundleToBackup Bundle to backup. 266 * @returns { string } Return the backup application's info. 267 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 268 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 269 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 270 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 271 * @syscap SystemCapability.FileManagement.StorageService.Backup 272 * @systemapi 273 * @since 12 274 */ 275 function getBackupInfo(bundleToBackup: string): string; 276 277 /** 278 * Update backup or restore timeout. 279 * 280 * @permission ohos.permission.BACKUP 281 * @param { string } bundleName set update to bundleName app. 282 * @param { number } timeout Update backup or restore timeout(unit:ms). 283 * @returns { boolean } Return update result, true is success, false is fail. 284 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 285 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 286 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 287 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 288 * @syscap SystemCapability.FileManagement.StorageService.Backup 289 * @systemapi 290 * @since 12 291 */ 292 function updateTimer(bundleName: string, timeout: number): boolean; 293 294 /** 295 * Update send file fd rate. 296 * 297 * @permission ohos.permission.BACKUP 298 * @param { string } bundleName set update to bundleName app. 299 * @param { number } sendRate set send file fd rate. 300 * @returns { boolean } Return update result, true is success, false is fail. 301 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 302 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 303 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 304 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 305 * @syscap SystemCapability.FileManagement.StorageService.Backup 306 * @systemapi 307 * @since 12 308 */ 309 function updateSendRate(bundleName: string, sendRate: number): boolean; 310 311 /** 312 * General callbacks for both backup and restore procedure. 313 * The backup service will notify the client by these callbacks. 314 * 315 * @interface GeneralCallbacks 316 * @syscap SystemCapability.FileManagement.StorageService.Backup 317 * @systemapi 318 * @since 10 319 */ 320 interface GeneralCallbacks { 321 /** 322 * Callback called when the backup service tries to send files to the client. 323 * The File argument indicates a file to send to the client. 324 * The returned file is owned by the backup service and will be cleaned by the service once the file is closed. 325 * 326 * @type { AsyncCallback<File> } 327 * @throws { BusinessError } 13600001 - IPC error 328 * @throws { BusinessError } 13900005 - I/O error 329 * @throws { BusinessError } 13900011 - Out of memory 330 * @throws { BusinessError } 13900020 - Invalid argument 331 * @throws { BusinessError } 13900025 - No space left on device 332 * @throws { BusinessError } 13900042 - Unknown error 333 * @syscap SystemCapability.FileManagement.StorageService.Backup 334 * @systemapi 335 * @since 10 336 */ 337 onFileReady: AsyncCallback<File>; 338 339 /** 340 * Callback called when a backup/restore procedure for an bundle is started. 341 * The return string argument indicates the name of the bundle. 342 * 343 * @throws { BusinessError } 13600001 - IPC error 344 * @throws { BusinessError } 13900005 - I/O error 345 * @throws { BusinessError } 13900011 - Out of memory 346 * @throws { BusinessError } 13900020 - Invalid argument 347 * @throws { BusinessError } 13900025 - No space left on device 348 * @throws { BusinessError } 13900042 - Unknown error 349 * @syscap SystemCapability.FileManagement.StorageService.Backup 350 * @systemapi 351 * @since 10 352 */ 353 /** 354 * Callback called when a backup/restore procedure for an bundle is started. 355 * The first return string parameter indicates the name of the bundle. 356 * The second return string parameter indicates that when BusinessError errors occur, 357 * the callback data is the name of the bundle. 358 * 359 * @type { AsyncCallback<string, void | string> } 360 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 361 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 362 * @throws { BusinessError } 13500001 - The application is not added to the backup or restore 363 * @throws { BusinessError } 13500002 - Failed to start application extension Procedure 364 * @throws { BusinessError } 13600001 - IPC error 365 * @throws { BusinessError } 13900005 - I/O error 366 * @throws { BusinessError } 13900011 - Out of memory 367 * @throws { BusinessError } 13900025 - No space left on device 368 * @throws { BusinessError } 13900042 - Unknown error 369 * @syscap SystemCapability.FileManagement.StorageService.Backup 370 * @systemapi 371 * @since 12 372 */ 373 onBundleBegin: AsyncCallback<string, void | string>; 374 375 /** 376 * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly. 377 * The return string argument indicates the name of the bundle. 378 * 379 * @throws { BusinessError } 13600001 - IPC error 380 * @throws { BusinessError } 13900005 - I/O error 381 * @throws { BusinessError } 13900011 - Out of memory 382 * @throws { BusinessError } 13900020 - Invalid argument 383 * @throws { BusinessError } 13900025 - No space left on device 384 * @throws { BusinessError } 13900042 - Unknown error 385 * @syscap SystemCapability.FileManagement.StorageService.Backup 386 * @systemapi 387 * @since 10 388 */ 389 /** 390 * Callback called when a backup/restore procedure for an bundle ends successfully or gets aborted unexpectedly. 391 * The first return string parameter indicates the name of the bundle. 392 * The second return string parameter indicates that when BusinessError errors occur, 393 * the callback data is the name of the bundle. 394 * 395 * @type { AsyncCallback<string, void | string> } 396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 397 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 398 * @throws { BusinessError } 13500003 - Backup or restore timed out 399 * @throws { BusinessError } 13500004 - Application extension death 400 * @throws { BusinessError } 13600001 - IPC error 401 * @throws { BusinessError } 13900005 - I/O error 402 * @throws { BusinessError } 13900011 - Out of memory 403 * @throws { BusinessError } 13900025 - No space left on device 404 * @throws { BusinessError } 13900042 - Unknown error 405 * @syscap SystemCapability.FileManagement.StorageService.Backup 406 * @systemapi 407 * @since 12 408 */ 409 onBundleEnd: AsyncCallback<string, void | string>; 410 411 /** 412 * Callback called when the all the bundles to backup/restore are done or aborted unexpectedly. 413 * 414 * @type { AsyncCallback<undefined> } 415 * @throws { BusinessError } 13600001 - IPC error 416 * @throws { BusinessError } 13900005 - I/O error 417 * @throws { BusinessError } 13900011 - Out of memory 418 * @throws { BusinessError } 13900020 - Invalid argument 419 * @throws { BusinessError } 13900025 - No space left on device 420 * @throws { BusinessError } 13900042 - Unknown error 421 * @syscap SystemCapability.FileManagement.StorageService.Backup 422 * @systemapi 423 * @since 10 424 */ 425 onAllBundlesEnd: AsyncCallback<undefined>; 426 427 /** 428 * Callback called when the backup service dies unexpectedly. 429 * 430 * @type { Callback<undefined> } 431 * @syscap SystemCapability.FileManagement.StorageService.Backup 432 * @systemapi 433 * @since 10 434 */ 435 onBackupServiceDied: Callback<undefined>; 436 437 /** 438 * Callback called when the backup service return result information. 439 * The first return string parameter indicates the bundleName that triggers the callback. 440 * The second return string parameter indicates the result of the bundle. 441 * 442 * @param { string } bundleName the bundleName that triggers the callback. 443 * @param { string } result the result of the bundle. 444 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 445 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 446 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 447 * @throws { BusinessError } 13600001 - IPC error 448 * @throws { BusinessError } 13900005 - I/O error 449 * @throws { BusinessError } 13900011 - Out of memory 450 * @throws { BusinessError } 13900025 - No space left on device 451 * @throws { BusinessError } 13900042 - Unknown error 452 * @syscap SystemCapability.FileManagement.StorageService.Backup 453 * @systemapi 454 * @since 12 455 */ 456 onResultReport(bundleName: string, result: string); 457 458 /** 459 * Callback called when the backup_sa service return result information. 460 * The first return string parameter indicates the result of the bundle. 461 * 462 * @param { string } bundleName the bundleName that triggers the callback. 463 * @param { string } process the process info of the bundle. 464 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 466 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 467 * @throws { BusinessError } 13500006 - Tar error 468 * @throws { BusinessError } 13500008 - Untar error 469 * @throws { BusinessError } 13600001 - IPC error 470 * @throws { BusinessError } 13900001 - Operation not permitted 471 * @throws { BusinessError } 13900005 - I/O error 472 * @throws { BusinessError } 13900011 - Out of memory 473 * @throws { BusinessError } 13900020 - Invalid argument 474 * @throws { BusinessError } 13900025 - No space left on device 475 * @syscap SystemCapability.FileManagement.StorageService.Backup 476 * @systemapi 477 * @since 12 478 */ 479 onProcess(bundleName: string, process: string); 480 } 481 482 /** 483 * Control class for backup procedure. 484 * 485 * @syscap SystemCapability.FileManagement.StorageService.Backup 486 * @systemapi 487 * @since 10 488 */ 489 class SessionBackup { 490 /** 491 * Constructor for obtaining the instance of the SessionBackup class. 492 * 493 * @permission ohos.permission.BACKUP 494 * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup. 495 * @syscap SystemCapability.FileManagement.StorageService.Backup 496 * @systemapi 497 * @since 10 498 */ 499 constructor(callbacks: GeneralCallbacks); 500 501 /** 502 * Append new bundles to backup. 503 * 504 * @permission ohos.permission.BACKUP 505 * @param { string[] } bundlesToBackup Bundles to backup. 506 * @returns { Promise<void> } The promise returned by the function. 507 * @throws { BusinessError } 13600001 - IPC error 508 * @throws { BusinessError } 13900001 - Operation not permitted 509 * @throws { BusinessError } 13900005 - I/O error 510 * @throws { BusinessError } 13900011 - Out of memory 511 * @throws { BusinessError } 13900020 - Invalid argument 512 * @throws { BusinessError } 13900025 - No space left on device 513 * @throws { BusinessError } 13900042 - Unknown error 514 * @syscap SystemCapability.FileManagement.StorageService.Backup 515 * @systemapi 516 * @since 10 517 */ 518 /** 519 * Append new bundles and backupInfos to backup. 520 * 521 * @permission ohos.permission.BACKUP 522 * @param { string[] } bundlesToBackup Bundles to backup. 523 * @param { string[] } infos Infos to backup. 524 * @returns { Promise<void> } The promise returned by the function. 525 * @throws { BusinessError } 13600001 - IPC error 526 * @throws { BusinessError } 13900001 - Operation not permitted 527 * @throws { BusinessError } 13900005 - I/O error 528 * @throws { BusinessError } 13900011 - Out of memory 529 * @throws { BusinessError } 13900020 - Invalid argument 530 * @throws { BusinessError } 13900025 - No space left on device 531 * @throws { BusinessError } 13900042 - Unknown error 532 * @syscap SystemCapability.FileManagement.StorageService.Backup 533 * @systemapi 534 * @since 12 535 */ 536 appendBundles(bundlesToBackup: string[], infos?: string[]): Promise<void>; 537 538 /** 539 * Append new bundles to backup. 540 * 541 * @permission ohos.permission.BACKUP 542 * @param { string[] } bundlesToBackup Bundles to backup. 543 * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished. 544 * @throws { BusinessError } 13600001 - IPC error 545 * @throws { BusinessError } 13900001 - Operation not permitted 546 * @throws { BusinessError } 13900005 - I/O error 547 * @throws { BusinessError } 13900011 - Out of memory 548 * @throws { BusinessError } 13900020 - Invalid argument 549 * @throws { BusinessError } 13900025 - No space left on device 550 * @throws { BusinessError } 13900042 - Unknown error 551 * @syscap SystemCapability.FileManagement.StorageService.Backup 552 * @systemapi 553 * @since 10 554 */ 555 appendBundles(bundlesToBackup: string[], callback: AsyncCallback<void>): void; 556 557 /** 558 * End Backup process 559 * 560 * @permission ohos.permission.BACKUP 561 * @returns { Promise<void> } The promise returned by the function. 562 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 563 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 564 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 565 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 566 * @throws { BusinessError } 13600001 - IPC error 567 * @throws { BusinessError } 13900001 - Operation not permitted 568 * @throws { BusinessError } 13900005 - I/O error 569 * @throws { BusinessError } 13900042 - Unknown error 570 * @syscap SystemCapability.FileManagement.StorageService.Backup 571 * @systemapi 572 * @since 12 573 */ 574 release(): Promise<void>; 575 } 576 577 /** 578 * Control class for restore procedure. 579 * 580 * @syscap SystemCapability.FileManagement.StorageService.Backup 581 * @systemapi 582 * @since 10 583 */ 584 class SessionRestore { 585 /** 586 * Constructor for obtaining the instance of the SessionBackup class. 587 * 588 * @permission ohos.permission.BACKUP 589 * @param { GeneralCallbacks } callbacks Callbacks to be registered for the restore. 590 * @syscap SystemCapability.FileManagement.StorageService.Backup 591 * @systemapi 592 * @since 10 593 */ 594 constructor(callbacks: GeneralCallbacks); 595 596 /** 597 * Append new bundles to be restore up during the restore. 598 * 599 * @permission ohos.permission.BACKUP 600 * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities. 601 * You can use the getLocalCapabilities method to obtain the value. 602 * @param { string[] } bundlesToBackup Bundles to restore. 603 * @returns { Promise<void> } The promise returned by the function. 604 * @throws { BusinessError } 13600001 - IPC error 605 * @throws { BusinessError } 13900001 - Operation not permitted 606 * @throws { BusinessError } 13900005 - I/O error 607 * @throws { BusinessError } 13900011 - Out of memory 608 * @throws { BusinessError } 13900020 - Invalid argument 609 * @throws { BusinessError } 13900025 - No space left on device 610 * @throws { BusinessError } 13900042 - Unknown error 611 * @syscap SystemCapability.FileManagement.StorageService.Backup 612 * @systemapi 613 * @since 10 614 */ 615 /** 616 * Append new bundles and restoreInfos to be restore up during the restore. 617 * 618 * @permission ohos.permission.BACKUP 619 * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities. 620 * You can use the getLocalCapabilities method to obtain the value. 621 * @param { string[] } bundlesToBackup Bundles to restore. 622 * @param { string[] } [infos] infos to restore 623 * @returns { Promise<void> } The promise returned by the function. 624 * @throws { BusinessError } 13600001 - IPC error 625 * @throws { BusinessError } 13900001 - Operation not permitted 626 * @throws { BusinessError } 13900005 - I/O error 627 * @throws { BusinessError } 13900011 - Out of memory 628 * @throws { BusinessError } 13900020 - Invalid argument 629 * @throws { BusinessError } 13900025 - No space left on device 630 * @throws { BusinessError } 13900042 - Unknown error 631 * @syscap SystemCapability.FileManagement.StorageService.Backup 632 * @systemapi 633 * @since 12 634 */ 635 appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], infos?: string[]): Promise<void>; 636 637 /** 638 * Append new bundles to be restore up during the restore. 639 * 640 * @permission ohos.permission.BACKUP 641 * @param { number } remoteCapabilitiesFd Opened JSON file that stores remote device capabilities. 642 * You can use the getLocalCapabilities method to obtain the value. 643 * @param { string[] } bundlesToBackup Bundles to restore. 644 * @param { AsyncCallback<void> } callback Asynchronous callback to be called when appendBundles has finished. 645 * @throws { BusinessError } 13600001 - IPC error 646 * @throws { BusinessError } 13900001 - Operation not permitted 647 * @throws { BusinessError } 13900005 - I/O error 648 * @throws { BusinessError } 13900011 - Out of memory 649 * @throws { BusinessError } 13900020 - Invalid argument 650 * @throws { BusinessError } 13900025 - No space left on device 651 * @throws { BusinessError } 13900042 - Unknown error 652 * @syscap SystemCapability.FileManagement.StorageService.Backup 653 * @systemapi 654 * @since 10 655 */ 656 appendBundles(remoteCapabilitiesFd: number, bundlesToBackup: string[], callback: AsyncCallback<void>): void; 657 658 /** 659 * Publish the file handle to the backup service to make the service aware that the file's content is ready. 660 * This interface is part of the zero-copy feature. 661 * 662 * @permission ohos.permission.BACKUP 663 * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds 664 * this file by calling getFileHandle. 665 * @returns { Promise<void> } The promise returned by the function. 666 * @throws { BusinessError } 13600001 - IPC error 667 * @throws { BusinessError } 13900001 - Operation not permitted 668 * @throws { BusinessError } 13900020 - Invalid argument 669 * @throws { BusinessError } 13900042 - Unknown error 670 * @syscap SystemCapability.FileManagement.StorageService.Backup 671 * @systemapi 672 * @since 10 673 */ 674 publishFile(fileMeta: FileMeta): Promise<void>; 675 676 /** 677 * Publish the file handle to the backup service to make the service aware that the file's content is ready. 678 * This interface is part of the zero-copy feature. 679 * 680 * @permission ohos.permission.BACKUP 681 * @param { FileMeta } fileMeta Metadata of the file to be sent. Make sure that the backup framework holds 682 * this file by calling getFileHandle. 683 * @param { AsyncCallback<void> } callback Asynchronous callback to be called when publishFile has finished. 684 * @throws { BusinessError } 13600001 - IPC error 685 * @throws { BusinessError } 13900001 - Operation not permitted 686 * @throws { BusinessError } 13900020 - Invalid argument 687 * @throws { BusinessError } 13900042 - Unknown error 688 * @syscap SystemCapability.FileManagement.StorageService.Backup 689 * @systemapi 690 * @since 10 691 */ 692 publishFile(fileMeta: FileMeta, callback: AsyncCallback<void>): void; 693 694 /** 695 * Request to get a shared file from the service. This interface is part of the zero-copy feature. 696 * Developers could get the file through onFileReady callback. 697 * When the client accomplished the file, use publishFile to publish. 698 * 699 * @permission ohos.permission.BACKUP 700 * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come 701 * from the backup procedure or the getLocalCapabilities method. 702 * @returns { Promise<void> } The promise returned by the function. 703 * @throws { BusinessError } 13600001 - IPC error 704 * @throws { BusinessError } 13900001 - Operation not permitted 705 * @throws { BusinessError } 13900020 - Invalid argument 706 * @throws { BusinessError } 13900042 - Unknown error 707 * @syscap SystemCapability.FileManagement.StorageService.Backup 708 * @systemapi 709 * @since 10 710 */ 711 getFileHandle(fileMeta: FileMeta): Promise<void>; 712 713 /** 714 * Request to get a shared file from the service. This interface is part of the zero-copy feature. 715 * Developers could get the file through onFileReady callback. 716 * When the client accomplished the file, use publishFile to publish. 717 * 718 * @permission ohos.permission.BACKUP 719 * @param { FileMeta } fileMeta Metadata of the file to be sent. Note that all the files should come 720 * from the backup procedure or the getLocalCapabilities method. 721 * @param { AsyncCallback<void> } callback Asynchronous callback to be called when getFileHandle has finished. 722 * @throws { BusinessError } 13600001 - IPC error 723 * @throws { BusinessError } 13900001 - Operation not permitted 724 * @throws { BusinessError } 13900020 - Invalid argument 725 * @throws { BusinessError } 13900042 - Unknown error 726 * @syscap SystemCapability.FileManagement.StorageService.Backup 727 * @systemapi 728 * @since 10 729 */ 730 getFileHandle(fileMeta: FileMeta, callback: AsyncCallback<void>): void; 731 732 /** 733 * End restore process 734 * 735 * @permission ohos.permission.BACKUP 736 * @returns { Promise<void> } The promise returned by the function. 737 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 738 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 739 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 740 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 741 * @throws { BusinessError } 13600001 - IPC error 742 * @throws { BusinessError } 13900001 - Operation not permitted 743 * @throws { BusinessError } 13900005 - I/O error 744 * @throws { BusinessError } 13900042 - Unknown error 745 * @syscap SystemCapability.FileManagement.StorageService.Backup 746 * @systemapi 747 * @since 12 748 */ 749 release(): Promise<void>; 750 } 751 752 /** 753 * Control class for incremental backup procedure. 754 * 755 * @syscap SystemCapability.FileManagement.StorageService.Backup 756 * @systemapi 757 * @since 12 758 */ 759 class IncrementalBackupSession { 760 /** 761 * Constructor for obtaining the instance of the IncrementalBackupSession class. 762 * 763 * @permission ohos.permission.BACKUP 764 * @param { GeneralCallbacks } callbacks Callbacks to be registered for the backup. 765 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 766 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 767 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 768 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 769 * @syscap SystemCapability.FileManagement.StorageService.Backup 770 * @systemapi 771 * @since 12 772 */ 773 constructor(callbacks: GeneralCallbacks); 774 775 /** 776 * Append new bundles to incremental backup. 777 * 778 * @permission ohos.permission.BACKUP 779 * @param { Array<IncrementalBackupData> } bundlesToBackup Bundles to incremental backup. 780 * @returns { Promise<void> } The promise returned by the function. 781 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 782 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 783 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 784 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 785 * @throws { BusinessError } 13600001 - IPC error 786 * @throws { BusinessError } 13900001 - Operation not permitted 787 * @throws { BusinessError } 13900005 - I/O error 788 * @throws { BusinessError } 13900011 - Out of memory 789 * @throws { BusinessError } 13900025 - No space left on device 790 * @throws { BusinessError } 13900042 - Unknown error 791 * @syscap SystemCapability.FileManagement.StorageService.Backup 792 * @systemapi 793 * @since 12 794 */ 795 appendBundles(bundlesToBackup: Array<IncrementalBackupData>): Promise<void>; 796 797 /** 798 * Append new bundles to incremental backup. 799 * 800 * @permission ohos.permission.BACKUP 801 * @param { Array<IncrementalBackupData> } bundlesToAppend Bundles to incremental backup. 802 * @param { string[] } infos information of the bundlesToBackup 803 * @returns { Promise<void> } The promise returned by the function. 804 * @throws { BusinessError } 201 - Permission verification failed. This error code is usually the result returned by VerifyAccessToken. 805 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 806 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 807 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 808 * @throws { BusinessError } 13600001 - IPC error 809 * @throws { BusinessError } 13900001 - Operation not permitted 810 * @throws { BusinessError } 13900005 - I/O error 811 * @throws { BusinessError } 13900011 - Out of memory 812 * @throws { BusinessError } 13900025 - No space left on device 813 * @throws { BusinessError } 13900042 - Unknown error 814 * @syscap SystemCapability.FileManagement.StorageService.Backup 815 * @systemapi 816 * @since 12 817 */ 818 appendBundles(bundlesToAppend: Array<IncrementalBackupData>, infos: string[]): Promise<void>; 819 820 /** 821 * End backup process 822 * 823 * @permission ohos.permission.BACKUP 824 * @returns { Promise<void> } The promise returned by the function. 825 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 826 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 827 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 828 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 829 * @throws { BusinessError } 13600001 - IPC error 830 * @throws { BusinessError } 13900001 - Operation not permitted 831 * @throws { BusinessError } 13900005 - I/O error 832 * @throws { BusinessError } 13900042 - Unknown error 833 * @syscap SystemCapability.FileManagement.StorageService.Backup 834 * @systemapi 835 * @since 12 836 */ 837 release(): Promise<void>; 838 } 839} 840export default backup; 841