From 06290a4bb9b280fa14a2bbeb2d3ceb09396a78c3 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Thu, 18 Jun 2009 20:10:37 -0700 Subject: Helper API cleanup. Allows multiple helpers to function, because they'll always go in the same order, and this lets us not have to write headers to keep them paired. --- core/java/android/backup/FileBackupHelper.java | 83 ++++++-------------------- 1 file changed, 18 insertions(+), 65 deletions(-) (limited to 'core/java/android/backup/FileBackupHelper.java') diff --git a/core/java/android/backup/FileBackupHelper.java b/core/java/android/backup/FileBackupHelper.java index ed840bb..4058497 100644 --- a/core/java/android/backup/FileBackupHelper.java +++ b/core/java/android/backup/FileBackupHelper.java @@ -24,19 +24,19 @@ import java.io.File; import java.io.FileDescriptor; /** @hide */ -public class FileBackupHelper { +public class FileBackupHelper extends FileBackupHelperBase implements BackupHelper { private static final String TAG = "FileBackupHelper"; Context mContext; - String mKeyPrefix; + File mFilesDir; + String[] mFiles; - public FileBackupHelper(Context context) { - mContext = context; - } + public FileBackupHelper(Context context, String... files) { + super(context); - public FileBackupHelper(Context context, String keyPrefix) { mContext = context; - mKeyPrefix = keyPrefix; + mFilesDir = context.getFilesDir(); + mFiles = files; } /** @@ -45,8 +45,9 @@ public class FileBackupHelper { * state as it exists now. */ public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data, - ParcelFileDescriptor newState, String[] files) { + ParcelFileDescriptor newState) { // file names + String[] files = mFiles; File base = mContext.getFilesDir(); final int N = files.length; String[] fullPaths = new String[N]; @@ -54,66 +55,18 @@ public class FileBackupHelper { fullPaths[i] = (new File(base, files[i])).getAbsolutePath(); } - // keys - String[] keys = makeKeys(mKeyPrefix, files); - // go - performBackup_checked(oldState, data, newState, fullPaths, keys); + performBackup_checked(oldState, data, newState, fullPaths, files); } - /** - * If keyPrefix is not null, prepend it to each of the strings in original; - * otherwise, return original. - */ - static String[] makeKeys(String keyPrefix, String[] original) { - if (keyPrefix != null) { - String[] keys; - final int N = original.length; - keys = new String[N]; - for (int i=0; i