diff options
author | Mathias Agopian <mathias@google.com> | 2009-05-14 22:44:23 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-05-14 22:44:23 -0700 |
commit | 11abc8a36d639775b05a0471c9ea45d83fa19e56 (patch) | |
tree | edf234f013ef3c88507f81dea65b8187cc672564 /core/java/android/backup/FileBackupHelper.java | |
parent | 6ec72e3fa9cdf9e896f3042fb1b1b4f3f6cea541 (diff) | |
parent | e52a5a5fca18348728dfc5609b42b88e9cc7ef98 (diff) | |
download | frameworks_base-11abc8a36d639775b05a0471c9ea45d83fa19e56.zip frameworks_base-11abc8a36d639775b05a0471c9ea45d83fa19e56.tar.gz frameworks_base-11abc8a36d639775b05a0471c9ea45d83fa19e56.tar.bz2 |
Merge commit 'goog/master' into merge_master
Conflicts:
opengl/libagl/Android.mk
opengl/libs/Android.mk
opengl/libs/egl_impl.h
Diffstat (limited to 'core/java/android/backup/FileBackupHelper.java')
-rw-r--r-- | core/java/android/backup/FileBackupHelper.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/core/java/android/backup/FileBackupHelper.java b/core/java/android/backup/FileBackupHelper.java index 3b2122c..05159dc 100644 --- a/core/java/android/backup/FileBackupHelper.java +++ b/core/java/android/backup/FileBackupHelper.java @@ -18,20 +18,24 @@ package android.backup; import android.content.Context; import android.os.ParcelFileDescriptor; +import android.util.Log; import java.io.FileDescriptor; +/** @hide */ public class FileBackupHelper { + private static final String TAG = "FileBackupHelper"; + /** - * Based on oldSnapshot, determine which of the files from the application's data directory - * need to be backed up, write them to the data stream, and fill in newSnapshot with the + * Based on oldState, determine which of the files from the application's data directory + * need to be backed up, write them to the data stream, and fill in newState with the * state as it exists now. */ public static void performBackup(Context context, - ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot, - BackupDataOutput data, String[] files) { + ParcelFileDescriptor oldState, BackupDataOutput data, + ParcelFileDescriptor newState, String[] files) { String basePath = context.getFilesDir().getAbsolutePath(); - performBackup_checked(basePath, oldSnapshot, newSnapshot, data, files); + performBackup_checked(basePath, oldState, data, newState, files); } /** @@ -39,30 +43,31 @@ public class FileBackupHelper { * since it's easier to do that from java. */ static void performBackup_checked(String basePath, - ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot, - BackupDataOutput data, String[] files) { - if (newSnapshot == null) { - throw new NullPointerException("newSnapshot==null"); + ParcelFileDescriptor oldState, BackupDataOutput data, + ParcelFileDescriptor newState, String[] files) { + if (files.length == 0) { + return; } - if (data == null) { - throw new NullPointerException("data==null"); + if (basePath == null) { + throw new NullPointerException(); } + // oldStateFd can be null + FileDescriptor oldStateFd = oldState != null ? oldState.getFileDescriptor() : null; if (data.fd == null) { - throw new NullPointerException("data.fd==null"); + throw new NullPointerException(); } - if (files == null) { - throw new NullPointerException("files==null"); + FileDescriptor newStateFd = newState.getFileDescriptor(); + if (newStateFd == null) { + throw new NullPointerException(); } - int err = performBackup_native(basePath, oldSnapshot.getFileDescriptor(), - newSnapshot.getFileDescriptor(), data.fd, files); + int err = performBackup_native(basePath, oldStateFd, data.fd, newStateFd, files); if (err != 0) { throw new RuntimeException("Backup failed"); // TODO: more here } } - native private static int performBackup_native(String basePath, - FileDescriptor oldSnapshot, FileDescriptor newSnapshot, - FileDescriptor data, String[] files); + native private static int performBackup_native(String basePath, FileDescriptor oldState, + FileDescriptor data, FileDescriptor newState, String[] files); } |