1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app.backup; 18 19 import android.annotation.SystemApi; 20 import android.content.Intent; 21 import android.content.pm.PackageInfo; 22 import android.os.IBinder; 23 import android.os.ParcelFileDescriptor; 24 import android.os.RemoteException; 25 26 import com.android.internal.backup.IBackupTransport; 27 28 /** 29 * Concrete class that provides a stable-API bridge between IBackupTransport 30 * and its implementations. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public class BackupTransport { 36 // Zero return always means things are okay. If returned from 37 // getNextFullRestoreDataChunk(), it means that no data could be delivered at 38 // this time, but the restore is still running and the caller should simply 39 // retry. 40 public static final int TRANSPORT_OK = 0; 41 42 // -1 is special; it is used in getNextFullRestoreDataChunk() to indicate that 43 // we've delivered the entire data stream for the current restore target. 44 public static final int NO_MORE_DATA = -1; 45 46 // Result codes that indicate real errors are negative and not -1 47 public static final int TRANSPORT_ERROR = -1000; 48 public static final int TRANSPORT_NOT_INITIALIZED = -1001; 49 public static final int TRANSPORT_PACKAGE_REJECTED = -1002; 50 public static final int AGENT_ERROR = -1003; 51 public static final int AGENT_UNKNOWN = -1004; 52 public static final int TRANSPORT_QUOTA_EXCEEDED = -1005; 53 54 // Indicates that operation was initiated by user, not a scheduled one. 55 // Transport should ignore its own moratoriums for call with this flag set. 56 public static final int FLAG_USER_INITIATED = 1; 57 58 IBackupTransport mBinderImpl = new TransportImpl(); 59 getBinder()60 public IBinder getBinder() { 61 return mBinderImpl.asBinder(); 62 } 63 64 // ------------------------------------------------------------------------------------ 65 // Transport self-description and general configuration interfaces 66 // 67 68 /** 69 * Ask the transport for the name under which it should be registered. This will 70 * typically be its host service's component name, but need not be. 71 */ name()72 public String name() { 73 throw new UnsupportedOperationException("Transport name() not implemented"); 74 } 75 76 /** 77 * Ask the transport for an Intent that can be used to launch any internal 78 * configuration Activity that it wishes to present. For example, the transport 79 * may offer a UI for allowing the user to supply login credentials for the 80 * transport's off-device backend. 81 * 82 * <p>If the transport does not supply any user-facing configuration UI, it should 83 * return {@code null} from this method. 84 * 85 * @return An Intent that can be passed to Context.startActivity() in order to 86 * launch the transport's configuration UI. This method will return {@code null} 87 * if the transport does not offer any user-facing configuration UI. 88 */ configurationIntent()89 public Intent configurationIntent() { 90 return null; 91 } 92 93 /** 94 * On demand, supply a one-line string that can be shown to the user that 95 * describes the current backend destination. For example, a transport that 96 * can potentially associate backup data with arbitrary user accounts should 97 * include the name of the currently-active account here. 98 * 99 * @return A string describing the destination to which the transport is currently 100 * sending data. This method should not return null. 101 */ currentDestinationString()102 public String currentDestinationString() { 103 throw new UnsupportedOperationException( 104 "Transport currentDestinationString() not implemented"); 105 } 106 107 /** 108 * Ask the transport for an Intent that can be used to launch a more detailed 109 * secondary data management activity. For example, the configuration intent might 110 * be one for allowing the user to select which account they wish to associate 111 * their backups with, and the management intent might be one which presents a 112 * UI for managing the data on the backend. 113 * 114 * <p>In the Settings UI, the configuration intent will typically be invoked 115 * when the user taps on the preferences item labeled with the current 116 * destination string, and the management intent will be placed in an overflow 117 * menu labelled with the management label string. 118 * 119 * <p>If the transport does not supply any user-facing data management 120 * UI, then it should return {@code null} from this method. 121 * 122 * @return An intent that can be passed to Context.startActivity() in order to 123 * launch the transport's data-management UI. This method will return 124 * {@code null} if the transport does not offer any user-facing data 125 * management UI. 126 */ dataManagementIntent()127 public Intent dataManagementIntent() { 128 return null; 129 } 130 131 /** 132 * On demand, supply a short string that can be shown to the user as the label 133 * on an overflow menu item used to invoked the data management UI. 134 * 135 * @return A string to be used as the label for the transport's data management 136 * affordance. If the transport supplies a data management intent, this 137 * method must not return {@code null}. 138 */ dataManagementLabel()139 public String dataManagementLabel() { 140 throw new UnsupportedOperationException( 141 "Transport dataManagementLabel() not implemented"); 142 } 143 144 /** 145 * Ask the transport where, on local device storage, to keep backup state blobs. 146 * This is per-transport so that mock transports used for testing can coexist with 147 * "live" backup services without interfering with the live bookkeeping. The 148 * returned string should be a name that is expected to be unambiguous among all 149 * available backup transports; the name of the class implementing the transport 150 * is a good choice. 151 * 152 * @return A unique name, suitable for use as a file or directory name, that the 153 * Backup Manager could use to disambiguate state files associated with 154 * different backup transports. 155 */ transportDirName()156 public String transportDirName() { 157 throw new UnsupportedOperationException( 158 "Transport transportDirName() not implemented"); 159 } 160 161 // ------------------------------------------------------------------------------------ 162 // Device-level operations common to both key/value and full-data storage 163 164 /** 165 * Initialize the server side storage for this device, erasing all stored data. 166 * The transport may send the request immediately, or may buffer it. After 167 * this is called, {@link #finishBackup} will be called to ensure the request 168 * is sent and received successfully. 169 * 170 * <p>If the transport returns anything other than TRANSPORT_OK from this method, 171 * the OS will halt the current initialize operation and schedule a retry in the 172 * near future. Even if the transport is in a state such that attempting to 173 * "initialize" the backend storage is meaningless -- for example, if there is 174 * no current live dataset at all, or there is no authenticated account under which 175 * to store the data remotely -- the transport should return TRANSPORT_OK here 176 * and treat the initializeDevice() / finishBackup() pair as a graceful no-op. 177 * 178 * @return One of {@link BackupTransport#TRANSPORT_OK} (OK so far) or 179 * {@link BackupTransport#TRANSPORT_ERROR} (to retry following network error 180 * or other failure). 181 */ initializeDevice()182 public int initializeDevice() { 183 return BackupTransport.TRANSPORT_ERROR; 184 } 185 186 /** 187 * Erase the given application's data from the backup destination. This clears 188 * out the given package's data from the current backup set, making it as though 189 * the app had never yet been backed up. After this is called, {@link finishBackup} 190 * must be called to ensure that the operation is recorded successfully. 191 * 192 * @return the same error codes as {@link #performBackup}. 193 */ clearBackupData(PackageInfo packageInfo)194 public int clearBackupData(PackageInfo packageInfo) { 195 return BackupTransport.TRANSPORT_ERROR; 196 } 197 198 /** 199 * Finish sending application data to the backup destination. This must be 200 * called after {@link #performBackup}, {@link #performFullBackup}, or {@link clearBackupData} 201 * to ensure that all data is sent and the operation properly finalized. Only when this 202 * method returns true can a backup be assumed to have succeeded. 203 * 204 * @return the same error codes as {@link #performBackup} or {@link #performFullBackup}. 205 */ finishBackup()206 public int finishBackup() { 207 return BackupTransport.TRANSPORT_ERROR; 208 } 209 210 // ------------------------------------------------------------------------------------ 211 // Key/value incremental backup support interfaces 212 213 /** 214 * Verify that this is a suitable time for a key/value backup pass. This should return zero 215 * if a backup is reasonable right now, some positive value otherwise. This method 216 * will be called outside of the {@link #performBackup}/{@link #finishBackup} pair. 217 * 218 * <p>If this is not a suitable time for a backup, the transport should return a 219 * backoff delay, in milliseconds, after which the Backup Manager should try again. 220 * 221 * @return Zero if this is a suitable time for a backup pass, or a positive time delay 222 * in milliseconds to suggest deferring the backup pass for a while. 223 */ requestBackupTime()224 public long requestBackupTime() { 225 return 0; 226 } 227 228 /** 229 * Send one application's key/value data update to the backup destination. The 230 * transport may send the data immediately, or may buffer it. If this method returns 231 * {@link #TRANSPORT_OK}, {@link #finishBackup} will then be called to ensure the data 232 * is sent and recorded successfully. 233 * 234 * @param packageInfo The identity of the application whose data is being backed up. 235 * This specifically includes the signature list for the package. 236 * @param inFd Descriptor of file with data that resulted from invoking the application's 237 * BackupService.doBackup() method. This may be a pipe rather than a file on 238 * persistent media, so it may not be seekable. 239 * @param flags {@link BackupTransport#FLAG_USER_INITIATED} or 0. 240 * @return one of {@link BackupTransport#TRANSPORT_OK} (OK so far), 241 * {@link BackupTransport#TRANSPORT_PACKAGE_REJECTED} (to suppress backup of this 242 * specific package, but allow others to proceed), 243 * {@link BackupTransport#TRANSPORT_ERROR} (on network error or other failure), or 244 * {@link BackupTransport#TRANSPORT_NOT_INITIALIZED} (if the backend dataset has 245 * become lost due to inactivity purge or some other reason and needs re-initializing) 246 */ performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags)247 public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags) { 248 return performBackup(packageInfo, inFd); 249 } 250 251 /** 252 * Legacy version of {@link #performBackup(PackageInfo, ParcelFileDescriptor, int)} that 253 * doesn't use flags parameter. 254 */ performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd)255 public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd) { 256 return BackupTransport.TRANSPORT_ERROR; 257 } 258 259 // ------------------------------------------------------------------------------------ 260 // Key/value dataset restore interfaces 261 262 /** 263 * Get the set of all backups currently available over this transport. 264 * 265 * @return Descriptions of the set of restore images available for this device, 266 * or null if an error occurred (the attempt should be rescheduled). 267 **/ getAvailableRestoreSets()268 public RestoreSet[] getAvailableRestoreSets() { 269 return null; 270 } 271 272 /** 273 * Get the identifying token of the backup set currently being stored from 274 * this device. This is used in the case of applications wishing to restore 275 * their last-known-good data. 276 * 277 * @return A token that can be passed to {@link #startRestore}, or 0 if there 278 * is no backup set available corresponding to the current device state. 279 */ getCurrentRestoreSet()280 public long getCurrentRestoreSet() { 281 return 0; 282 } 283 284 /** 285 * Start restoring application data from backup. After calling this function, 286 * alternate calls to {@link #nextRestorePackage} and {@link #nextRestoreData} 287 * to walk through the actual application data. 288 * 289 * @param token A backup token as returned by {@link #getAvailableRestoreSets} 290 * or {@link #getCurrentRestoreSet}. 291 * @param packages List of applications to restore (if data is available). 292 * Application data will be restored in the order given. 293 * @return One of {@link BackupTransport#TRANSPORT_OK} (OK so far, call 294 * {@link #nextRestorePackage}) or {@link BackupTransport#TRANSPORT_ERROR} 295 * (an error occurred, the restore should be aborted and rescheduled). 296 */ startRestore(long token, PackageInfo[] packages)297 public int startRestore(long token, PackageInfo[] packages) { 298 return BackupTransport.TRANSPORT_ERROR; 299 } 300 301 /** 302 * Get the package name of the next application with data in the backup store, plus 303 * a description of the structure of the restored archive: either TYPE_KEY_VALUE for 304 * an original-API key/value dataset, or TYPE_FULL_STREAM for a tarball-type archive stream. 305 * 306 * <p>If the package name in the returned RestoreDescription object is the singleton 307 * {@link RestoreDescription#NO_MORE_PACKAGES}, it indicates that no further data is available 308 * in the current restore session: all packages described in startRestore() have been 309 * processed. 310 * 311 * <p>If this method returns {@code null}, it means that a transport-level error has 312 * occurred and the entire restore operation should be abandoned. 313 * 314 * <p class="note">The OS may call {@link #nextRestorePackage()} multiple times 315 * before calling either {@link #getRestoreData(ParcelFileDescriptor) getRestoreData()} 316 * or {@link #getNextFullRestoreDataChunk(ParcelFileDescriptor) getNextFullRestoreDataChunk()}. 317 * It does this when it has determined that it needs to skip restore of one or more 318 * packages. The transport should not actually transfer any restore data for 319 * the given package in response to {@link #nextRestorePackage()}, but rather wait 320 * for an explicit request before doing so. 321 * 322 * @return A RestoreDescription object containing the name of one of the packages 323 * supplied to {@link #startRestore} plus an indicator of the data type of that 324 * restore data; or {@link RestoreDescription#NO_MORE_PACKAGES} to indicate that 325 * no more packages can be restored in this session; or {@code null} to indicate 326 * a transport-level error. 327 */ nextRestorePackage()328 public RestoreDescription nextRestorePackage() { 329 return null; 330 } 331 332 /** 333 * Get the data for the application returned by {@link #nextRestorePackage}, if that 334 * method reported {@link RestoreDescription#TYPE_KEY_VALUE} as its delivery type. 335 * If the package has only TYPE_FULL_STREAM data, then this method will return an 336 * error. 337 * 338 * @param data An open, writable file into which the key/value backup data should be stored. 339 * @return the same error codes as {@link #startRestore}. 340 */ getRestoreData(ParcelFileDescriptor outFd)341 public int getRestoreData(ParcelFileDescriptor outFd) { 342 return BackupTransport.TRANSPORT_ERROR; 343 } 344 345 /** 346 * End a restore session (aborting any in-process data transfer as necessary), 347 * freeing any resources and connections used during the restore process. 348 */ finishRestore()349 public void finishRestore() { 350 throw new UnsupportedOperationException( 351 "Transport finishRestore() not implemented"); 352 } 353 354 // ------------------------------------------------------------------------------------ 355 // Full backup interfaces 356 357 /** 358 * Verify that this is a suitable time for a full-data backup pass. This should return zero 359 * if a backup is reasonable right now, some positive value otherwise. This method 360 * will be called outside of the {@link #performFullBackup}/{@link #finishBackup} pair. 361 * 362 * <p>If this is not a suitable time for a backup, the transport should return a 363 * backoff delay, in milliseconds, after which the Backup Manager should try again. 364 * 365 * @return Zero if this is a suitable time for a backup pass, or a positive time delay 366 * in milliseconds to suggest deferring the backup pass for a while. 367 * 368 * @see #requestBackupTime() 369 */ requestFullBackupTime()370 public long requestFullBackupTime() { 371 return 0; 372 } 373 374 /** 375 * Begin the process of sending an application's full-data archive to the backend. 376 * The description of the package whose data will be delivered is provided, as well as 377 * the socket file descriptor on which the transport will receive the data itself. 378 * 379 * <p>If the package is not eligible for backup, the transport should return 380 * {@link BackupTransport#TRANSPORT_PACKAGE_REJECTED}. In this case the system will 381 * simply proceed with the next candidate if any, or finish the full backup operation 382 * if all apps have been processed. 383 * 384 * <p>After the transport returns {@link BackupTransport#TRANSPORT_OK} from this 385 * method, the OS will proceed to call {@link #sendBackupData()} one or more times 386 * to deliver the application's data as a streamed tarball. The transport should not 387 * read() from the socket except as instructed to via the {@link #sendBackupData(int)} 388 * method. 389 * 390 * <p>After all data has been delivered to the transport, the system will call 391 * {@link #finishBackup()}. At this point the transport should commit the data to 392 * its datastore, if appropriate, and close the socket that had been provided in 393 * {@link #performFullBackup(PackageInfo, ParcelFileDescriptor)}. 394 * 395 * <p class="note">If the transport returns TRANSPORT_OK from this method, then the 396 * OS will always provide a matching call to {@link #finishBackup()} even if sending 397 * data via {@link #sendBackupData(int)} failed at some point. 398 * 399 * @param targetPackage The package whose data is to follow. 400 * @param socket The socket file descriptor through which the data will be provided. 401 * If the transport returns {@link #TRANSPORT_PACKAGE_REJECTED} here, it must still 402 * close this file descriptor now; otherwise it should be cached for use during 403 * succeeding calls to {@link #sendBackupData(int)}, and closed in response to 404 * {@link #finishBackup()}. 405 * @param flags {@link BackupTransport#FLAG_USER_INITIATED} or 0. 406 * @return TRANSPORT_PACKAGE_REJECTED to indicate that the stated application is not 407 * to be backed up; TRANSPORT_OK to indicate that the OS may proceed with delivering 408 * backup data; TRANSPORT_ERROR to indicate a fatal error condition that precludes 409 * performing a backup at this time. 410 */ performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket, int flags)411 public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket, 412 int flags) { 413 return performFullBackup(targetPackage, socket); 414 } 415 416 /** 417 * Legacy version of {@link #performFullBackup(PackageInfo, ParcelFileDescriptor, int)} that 418 * doesn't use flags parameter. 419 */ performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket)420 public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket) { 421 return BackupTransport.TRANSPORT_PACKAGE_REJECTED; 422 } 423 424 /** 425 * Called after {@link #performFullBackup} to make sure that the transport is willing to 426 * handle a full-data backup operation of the specified size on the current package. 427 * If the transport returns anything other than TRANSPORT_OK, the package's backup 428 * operation will be skipped (and {@link #finishBackup() invoked} with no data for that 429 * package being passed to {@link #sendBackupData}. 430 * 431 * <p class="note">The platform does no size-based rejection of full backup attempts on 432 * its own: it is always the responsibility of the transport to implement its own policy. 433 * In particular, even if the preflighted payload size is zero, the platform will still call 434 * this method and will proceed to back up an archive metadata header with no file content 435 * if this method returns TRANSPORT_OK. To avoid storing such payloads the transport 436 * must recognize this case and return TRANSPORT_PACKAGE_REJECTED. 437 * 438 * Added in {@link android.os.Build.VERSION_CODES#M}. 439 * 440 * @param size The estimated size of the full-data payload for this app. This includes 441 * manifest and archive format overhead, but is not guaranteed to be precise. 442 * @return TRANSPORT_OK if the platform is to proceed with the full-data backup, 443 * TRANSPORT_PACKAGE_REJECTED if the proposed payload size is too large for 444 * the transport to handle, or TRANSPORT_ERROR to indicate a fatal error 445 * condition that means the platform cannot perform a backup at this time. 446 */ checkFullBackupSize(long size)447 public int checkFullBackupSize(long size) { 448 return BackupTransport.TRANSPORT_OK; 449 } 450 451 /** 452 * Tells the transport to read {@code numBytes} bytes of data from the socket file 453 * descriptor provided in the {@link #performFullBackup(PackageInfo, ParcelFileDescriptor)} 454 * call, and deliver those bytes to the datastore. 455 * 456 * @param numBytes The number of bytes of tarball data available to be read from the 457 * socket. 458 * @return TRANSPORT_OK on successful processing of the data; TRANSPORT_ERROR to 459 * indicate a fatal error situation. If an error is returned, the system will 460 * call finishBackup() and stop attempting backups until after a backoff and retry 461 * interval. 462 */ sendBackupData(int numBytes)463 public int sendBackupData(int numBytes) { 464 return BackupTransport.TRANSPORT_ERROR; 465 } 466 467 /** 468 * Tells the transport to cancel the currently-ongoing full backup operation. This 469 * will happen between {@link #performFullBackup()} and {@link #finishBackup()} 470 * if the OS needs to abort the backup operation for any reason, such as a crash in 471 * the application undergoing backup. 472 * 473 * <p>When it receives this call, the transport should discard any partial archive 474 * that it has stored so far. If possible it should also roll back to the previous 475 * known-good archive in its datastore. 476 * 477 * <p>If the transport receives this callback, it will <em>not</em> receive a 478 * call to {@link #finishBackup()}. It needs to tear down any ongoing backup state 479 * here. 480 */ cancelFullBackup()481 public void cancelFullBackup() { 482 throw new UnsupportedOperationException( 483 "Transport cancelFullBackup() not implemented"); 484 } 485 486 /** 487 * Ask the transport whether this app is eligible for backup. 488 * 489 * @param targetPackage The identity of the application. 490 * @param isFullBackup If set, transport should check if app is eligible for full data backup, 491 * otherwise to check if eligible for key-value backup. 492 * @return Whether this app is eligible for backup. 493 */ isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup)494 public boolean isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup) { 495 return true; 496 } 497 498 /** 499 * Ask the transport about current quota for backup size of the package. 500 * 501 * @param packageName ID of package to provide the quota. 502 * @param isFullBackup If set, transport should return limit for full data backup, otherwise 503 * for key-value backup. 504 * @return Current limit on backup size in bytes. 505 */ getBackupQuota(String packageName, boolean isFullBackup)506 public long getBackupQuota(String packageName, boolean isFullBackup) { 507 return Long.MAX_VALUE; 508 } 509 510 // ------------------------------------------------------------------------------------ 511 // Full restore interfaces 512 513 /** 514 * Ask the transport to provide data for the "current" package being restored. This 515 * is the package that was just reported by {@link #nextRestorePackage()} as having 516 * {@link RestoreDescription#TYPE_FULL_STREAM} data. 517 * 518 * The transport writes some data to the socket supplied to this call, and returns 519 * the number of bytes written. The system will then read that many bytes and 520 * stream them to the application's agent for restore, then will call this method again 521 * to receive the next chunk of the archive. This sequence will be repeated until the 522 * transport returns zero indicating that all of the package's data has been delivered 523 * (or returns a negative value indicating some sort of hard error condition at the 524 * transport level). 525 * 526 * <p>After this method returns zero, the system will then call 527 * {@link #nextRestorePackage()} to begin the restore process for the next 528 * application, and the sequence begins again. 529 * 530 * <p>The transport should always close this socket when returning from this method. 531 * Do not cache this socket across multiple calls or you may leak file descriptors. 532 * 533 * @param socket The file descriptor that the transport will use for delivering the 534 * streamed archive. The transport must close this socket in all cases when returning 535 * from this method. 536 * @return {@link #NO_MORE_DATA} when no more data for the current package is available. 537 * A positive value indicates the presence of that many bytes to be delivered to the app. 538 * A value of zero indicates that no data was deliverable at this time, but the restore 539 * is still running and the caller should retry. {@link #TRANSPORT_PACKAGE_REJECTED} 540 * means that the current package's restore operation should be aborted, but that 541 * the transport itself is still in a good state and so a multiple-package restore 542 * sequence can still be continued. Any other negative return value is treated as a 543 * fatal error condition that aborts all further restore operations on the current dataset. 544 */ getNextFullRestoreDataChunk(ParcelFileDescriptor socket)545 public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) { 546 return 0; 547 } 548 549 /** 550 * If the OS encounters an error while processing {@link RestoreDescription#TYPE_FULL_STREAM} 551 * data for restore, it will invoke this method to tell the transport that it should 552 * abandon the data download for the current package. The OS will then either call 553 * {@link #nextRestorePackage()} again to move on to restoring the next package in the 554 * set being iterated over, or will call {@link #finishRestore()} to shut down the restore 555 * operation. 556 * 557 * @return {@link #TRANSPORT_OK} if the transport was successful in shutting down the 558 * current stream cleanly, or {@link #TRANSPORT_ERROR} to indicate a serious 559 * transport-level failure. If the transport reports an error here, the entire restore 560 * operation will immediately be finished with no further attempts to restore app data. 561 */ abortFullRestore()562 public int abortFullRestore() { 563 return BackupTransport.TRANSPORT_OK; 564 } 565 566 /** 567 * Bridge between the actual IBackupTransport implementation and the stable API. If the 568 * binder interface needs to change, we use this layer to translate so that we can 569 * (if appropriate) decouple those framework-side changes from the BackupTransport 570 * implementations. 571 */ 572 class TransportImpl extends IBackupTransport.Stub { 573 574 @Override name()575 public String name() throws RemoteException { 576 return BackupTransport.this.name(); 577 } 578 579 @Override configurationIntent()580 public Intent configurationIntent() throws RemoteException { 581 return BackupTransport.this.configurationIntent(); 582 } 583 584 @Override currentDestinationString()585 public String currentDestinationString() throws RemoteException { 586 return BackupTransport.this.currentDestinationString(); 587 } 588 589 @Override dataManagementIntent()590 public Intent dataManagementIntent() { 591 return BackupTransport.this.dataManagementIntent(); 592 } 593 594 @Override dataManagementLabel()595 public String dataManagementLabel() { 596 return BackupTransport.this.dataManagementLabel(); 597 } 598 599 @Override transportDirName()600 public String transportDirName() throws RemoteException { 601 return BackupTransport.this.transportDirName(); 602 } 603 604 @Override requestBackupTime()605 public long requestBackupTime() throws RemoteException { 606 return BackupTransport.this.requestBackupTime(); 607 } 608 609 @Override initializeDevice()610 public int initializeDevice() throws RemoteException { 611 return BackupTransport.this.initializeDevice(); 612 } 613 614 @Override performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags)615 public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags) 616 throws RemoteException { 617 return BackupTransport.this.performBackup(packageInfo, inFd, flags); 618 } 619 620 @Override clearBackupData(PackageInfo packageInfo)621 public int clearBackupData(PackageInfo packageInfo) throws RemoteException { 622 return BackupTransport.this.clearBackupData(packageInfo); 623 } 624 625 @Override finishBackup()626 public int finishBackup() throws RemoteException { 627 return BackupTransport.this.finishBackup(); 628 } 629 630 @Override getAvailableRestoreSets()631 public RestoreSet[] getAvailableRestoreSets() throws RemoteException { 632 return BackupTransport.this.getAvailableRestoreSets(); 633 } 634 635 @Override getCurrentRestoreSet()636 public long getCurrentRestoreSet() throws RemoteException { 637 return BackupTransport.this.getCurrentRestoreSet(); 638 } 639 640 @Override startRestore(long token, PackageInfo[] packages)641 public int startRestore(long token, PackageInfo[] packages) throws RemoteException { 642 return BackupTransport.this.startRestore(token, packages); 643 } 644 645 @Override nextRestorePackage()646 public RestoreDescription nextRestorePackage() throws RemoteException { 647 return BackupTransport.this.nextRestorePackage(); 648 } 649 650 @Override getRestoreData(ParcelFileDescriptor outFd)651 public int getRestoreData(ParcelFileDescriptor outFd) throws RemoteException { 652 return BackupTransport.this.getRestoreData(outFd); 653 } 654 655 @Override finishRestore()656 public void finishRestore() throws RemoteException { 657 BackupTransport.this.finishRestore(); 658 } 659 660 @Override requestFullBackupTime()661 public long requestFullBackupTime() throws RemoteException { 662 return BackupTransport.this.requestFullBackupTime(); 663 } 664 665 @Override performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket, int flags)666 public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket, 667 int flags) throws RemoteException { 668 return BackupTransport.this.performFullBackup(targetPackage, socket, flags); 669 } 670 671 @Override checkFullBackupSize(long size)672 public int checkFullBackupSize(long size) { 673 return BackupTransport.this.checkFullBackupSize(size); 674 } 675 676 @Override sendBackupData(int numBytes)677 public int sendBackupData(int numBytes) throws RemoteException { 678 return BackupTransport.this.sendBackupData(numBytes); 679 } 680 681 @Override cancelFullBackup()682 public void cancelFullBackup() throws RemoteException { 683 BackupTransport.this.cancelFullBackup(); 684 } 685 686 @Override isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup)687 public boolean isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup) 688 throws RemoteException { 689 return BackupTransport.this.isAppEligibleForBackup(targetPackage, isFullBackup); 690 } 691 692 @Override getBackupQuota(String packageName, boolean isFullBackup)693 public long getBackupQuota(String packageName, boolean isFullBackup) { 694 return BackupTransport.this.getBackupQuota(packageName, isFullBackup); 695 } 696 697 @Override getNextFullRestoreDataChunk(ParcelFileDescriptor socket)698 public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) { 699 return BackupTransport.this.getNextFullRestoreDataChunk(socket); 700 } 701 702 @Override abortFullRestore()703 public int abortFullRestore() { 704 return BackupTransport.this.abortFullRestore(); 705 } 706 } 707 } 708