summaryrefslogtreecommitdiffstats
path: root/tests/backup
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2009-06-17 17:55:20 -0700
committerJoe Onorato <joeo@android.com>2009-06-17 17:57:30 -0700
commit83248c432ffe2e2a17abbc8e4960c26574b46bca (patch)
tree9e8de2f1eb84d52481573c9c1d824c6be4a6fdc0 /tests/backup
parent6ce1983a2b5e9f5e735ac09b270b400084edb7db (diff)
downloadframeworks_base-83248c432ffe2e2a17abbc8e4960c26574b46bca.zip
frameworks_base-83248c432ffe2e2a17abbc8e4960c26574b46bca.tar.gz
frameworks_base-83248c432ffe2e2a17abbc8e4960c26574b46bca.tar.bz2
backup fixes:
- BackupTestAgent calls the DispatchHelper - Make BackupAgent.onRestore take a BackupDataInput, not just a generic ParcelFileDescriptor.
Diffstat (limited to 'tests/backup')
-rw-r--r--tests/backup/src/com/android/backuptest/BackupTestActivity.java3
-rw-r--r--tests/backup/src/com/android/backuptest/BackupTestAgent.java27
2 files changed, 23 insertions, 7 deletions
diff --git a/tests/backup/src/com/android/backuptest/BackupTestActivity.java b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
index aa940ae..d87e85c 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestActivity.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
@@ -144,8 +144,7 @@ public class BackupTestActivity extends ListActivity
FileBackupHelper h = new FileBackupHelper(BackupTestActivity.this,
"FileBackupHelper");
FileOutputStream dataFile = openFileOutput("backup_test", MODE_WORLD_READABLE);
- BackupDataOutput data = new BackupDataOutput(BackupTestActivity.this,
- dataFile.getFD());
+ BackupDataOutput data = new BackupDataOutput(dataFile.getFD());
h.performBackup(null, data, state, new String[] { "a", "empty" });
dataFile.close();
state.close();
diff --git a/tests/backup/src/com/android/backuptest/BackupTestAgent.java b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
index a370d69..e3566ec 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestAgent.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
@@ -17,28 +17,45 @@
package com.android.backuptest;
import android.app.BackupAgent;
+import android.backup.BackupDataInput;
import android.backup.BackupDataOutput;
import android.backup.FileBackupHelper;
+import android.backup.FileRestoreHelper;
+import android.backup.RestoreHelperDispatcher;
import android.os.ParcelFileDescriptor;
import android.util.Log;
+import java.io.IOException;
+
public class BackupTestAgent extends BackupAgent
{
static final String TAG = "BackupTestAgent";
+ static final String SHARED_PREFS = "shared_prefs";
+ static final String DATA_FILES = "data_files";
+ static final String[] FILES = new String[] {
+ BackupTestActivity.FILE_NAME
+ };
+
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) {
Log.d(TAG, "onBackup");
- FileBackupHelper helper = new FileBackupHelper(this);
- helper.performBackup(oldState, data, newState, new String[] {
- BackupTestActivity.FILE_NAME
- });
+
+ (new FileBackupHelper(this, DATA_FILES)).performBackup(oldState, data, newState, FILES);
}
@Override
- public void onRestore(ParcelFileDescriptor data, ParcelFileDescriptor newState) {
+ public void onRestore(BackupDataInput data, ParcelFileDescriptor newState)
+ throws IOException {
Log.d(TAG, "onRestore");
+
+ RestoreHelperDispatcher dispatch = new RestoreHelperDispatcher();
+
+ // dispatch.addHelper(SHARED_PREFS, new SharedPrefsRestoreHelper(this));
+ dispatch.addHelper(DATA_FILES, new FileRestoreHelper(this));
+
+ dispatch.dispatch(data);
}
}