diff options
| author | Christopher Tate <ctate@google.com> | 2009-07-08 13:48:56 -0700 |
|---|---|---|
| committer | Christopher Tate <ctate@google.com> | 2009-07-08 13:52:50 -0700 |
| commit | b407f22c9d960b48ed49ed2a1cee0042d9f2a92e (patch) | |
| tree | 710029aab33400cee638316fdf2de016e45c6b0f /services/java | |
| parent | f9c228a51fba54e80826fb6aa5d53f43a2e86042 (diff) | |
| download | frameworks_base-b407f22c9d960b48ed49ed2a1cee0042d9f2a92e.zip frameworks_base-b407f22c9d960b48ed49ed2a1cee0042d9f2a92e.tar.gz frameworks_base-b407f22c9d960b48ed49ed2a1cee0042d9f2a92e.tar.bz2 | |
Don't invoke the transport if doBackup supplied no data
If there's no data to be backed up, we no longer invoke the transport. We *DO*
still require that the agent have emitted a valid new state file, however.
This change also finally uncomments the code that removes the backup data file
after it has been sent to the transport, so there will be no more
packagename.data files lying around in the staging area.
Diffstat (limited to 'services/java')
| -rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 3b82284..6e28515 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -810,17 +810,25 @@ class BackupManagerService extends IBackupManager.Stub { // Now propagate the newly-backed-up data to the transport if (success) { - if (DEBUG) Log.v(TAG, "doBackup() success; calling transport"); - backupData = - ParcelFileDescriptor.open(backupDataName, ParcelFileDescriptor.MODE_READ_ONLY); - if (!transport.performBackup(packInfo, backupData)) { - // STOPSHIP TODO: handle errors - Log.e(TAG, "Backup failure in performBackup()"); + if (DEBUG) Log.v(TAG, "doBackup() success"); + if (backupDataName.length() > 0) { + backupData = + ParcelFileDescriptor.open(backupDataName, + ParcelFileDescriptor.MODE_READ_ONLY); + if (!transport.performBackup(packInfo, backupData)) { + // STOPSHIP TODO: handle errors + Log.e(TAG, "Backup failure in performBackup()"); + } + } else { + if (DEBUG) { + Log.i(TAG, "no backup data written; not calling transport"); + } } - // !!! TODO: After successful transport, delete the now-stale data - // and juggle the files so that next time the new state is passed - //backupDataName.delete(); + // After successful transport, delete the now-stale data + // and juggle the files so that next time we supply the agent + // with the new state file it just created. + backupDataName.delete(); newStateName.renameTo(savedStateName); } } catch (Exception e) { |
