diff options
| author | Matthew Williams <mjwilliams@google.com> | 2015-08-05 18:27:44 -0700 |
|---|---|---|
| committer | Matthew Williams <mjwilliams@google.com> | 2015-08-06 10:28:08 -0700 |
| commit | b9ebed56e48e91876215a5c51f4562f1c7b0e49b (patch) | |
| tree | 28b706629aaddcaf32c9578cd1d2541f8c3e56ae /core/java | |
| parent | be948f5a9f519210c5522060ec9ee3bc77eb077e (diff) | |
| download | frameworks_base-b9ebed56e48e91876215a5c51f4562f1c7b0e49b.zip frameworks_base-b9ebed56e48e91876215a5c51f4562f1c7b0e49b.tar.gz frameworks_base-b9ebed56e48e91876215a5c51f4562f1c7b0e49b.tar.bz2 | |
Correctly skip files that are excluded from restore
BUG: 22957980
If a file was present in the backup but excluded on restore,
it can result in the restored data being corrupted.
Ensure that FullBackup.restoreFile is called with a
null destination, which will result in the file not
being written to disk, but still properly pulled
from the socket.
Change-Id: Iac882a961b76e687654535aec352678486a08c39
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/backup/BackupAgent.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java index 6fca0de..689283c 100644 --- a/core/java/android/app/backup/BackupAgent.java +++ b/core/java/android/app/backup/BackupAgent.java @@ -605,6 +605,13 @@ public abstract class BackupAgent extends ContextWrapper { public void onRestoreFile(ParcelFileDescriptor data, long size, File destination, int type, long mode, long mtime) throws IOException { + + final boolean accept = isFileEligibleForRestore(destination); + // If we don't accept the file, consume the bytes from the pipe anyway. + FullBackup.restoreFile(data, size, type, mode, mtime, accept ? destination : null); + } + + private boolean isFileEligibleForRestore(File destination) throws IOException { FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this); if (!bs.isFullBackupContentEnabled()) { if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) { @@ -612,8 +619,9 @@ public abstract class BackupAgent extends ContextWrapper { "onRestoreFile \"" + destination.getCanonicalPath() + "\" : fullBackupContent not enabled for " + getPackageName()); } - return; + return false; } + Map<String, Set<String>> includes = null; ArraySet<String> excludes = null; final String destinationCanonicalPath = destination.getCanonicalPath(); @@ -627,7 +635,7 @@ public abstract class BackupAgent extends ContextWrapper { + "\" : Exception trying to parse fullBackupContent xml file!" + " Aborting onRestoreFile.", e); } - return; + return false; } if (excludes != null && @@ -637,7 +645,7 @@ public abstract class BackupAgent extends ContextWrapper { "onRestoreFile: \"" + destinationCanonicalPath + "\": listed in" + " excludes; skipping."); } - return; + return false; } if (includes != null && !includes.isEmpty()) { @@ -657,10 +665,10 @@ public abstract class BackupAgent extends ContextWrapper { + destinationCanonicalPath + "\" but it isn't specified" + " in the included files; skipping."); } - return; + return false; } } - FullBackup.restoreFile(data, size, type, mode, mtime, destination); + return true; } /** |
