summaryrefslogtreecommitdiffstats
path: root/tests/backup
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2009-06-18 20:10:37 -0700
committerJoe Onorato <joeo@android.com>2009-06-22 13:02:24 -0700
commit06290a4bb9b280fa14a2bbeb2d3ceb09396a78c3 (patch)
tree15fccf5ce4e9c42bba3fc7581ac2ddc0d8363dc9 /tests/backup
parenteed76b2a8ddc41af01cd3ae87c4722f3784c975c (diff)
downloadframeworks_base-06290a4bb9b280fa14a2bbeb2d3ceb09396a78c3.zip
frameworks_base-06290a4bb9b280fa14a2bbeb2d3ceb09396a78c3.tar.gz
frameworks_base-06290a4bb9b280fa14a2bbeb2d3ceb09396a78c3.tar.bz2
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.
Diffstat (limited to 'tests/backup')
-rw-r--r--tests/backup/src/com/android/backuptest/BackupTestActivity.java15
-rw-r--r--tests/backup/src/com/android/backuptest/BackupTestAgent.java41
2 files changed, 11 insertions, 45 deletions
diff --git a/tests/backup/src/com/android/backuptest/BackupTestActivity.java b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
index f0c3f93..69da761 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestActivity.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
@@ -17,12 +17,11 @@
package com.android.backuptest;
import android.app.ListActivity;
+import android.backup.BackupHelperDispatcher;
import android.backup.BackupDataInput;
import android.backup.BackupDataOutput;
import android.backup.BackupManager;
import android.backup.FileBackupHelper;
-import android.backup.FileRestoreHelper;
-import android.backup.RestoreHelperDispatcher;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -142,10 +141,10 @@ public class BackupTestActivity extends ListActivity
ParcelFileDescriptor.MODE_READ_WRITE|ParcelFileDescriptor.MODE_CREATE|
ParcelFileDescriptor.MODE_TRUNCATE);
FileBackupHelper h = new FileBackupHelper(BackupTestActivity.this,
- "FileBackupHelper");
+ new String[] { "a", "empty" });
FileOutputStream dataFile = openFileOutput("backup_test", MODE_WORLD_READABLE);
BackupDataOutput data = new BackupDataOutput(dataFile.getFD());
- h.performBackup(null, data, state, new String[] { "a", "empty" });
+ h.performBackup(null, data, state);
dataFile.close();
state.close();
} catch (IOException ex) {
@@ -156,16 +155,16 @@ public class BackupTestActivity extends ListActivity
new Test("Restore Helpers") {
void run() {
try {
- RestoreHelperDispatcher dispatch = new RestoreHelperDispatcher();
- dispatch.addHelper("FileBackupHelper",
- new FileRestoreHelper(BackupTestActivity.this));
+ BackupHelperDispatcher dispatch = new BackupHelperDispatcher();
+ dispatch.addHelper("", new FileBackupHelper(BackupTestActivity.this,
+ new String[] { "a", "empty" }));
FileInputStream dataFile = openFileInput("backup_test");
BackupDataInput data = new BackupDataInput(dataFile.getFD());
ParcelFileDescriptor state = ParcelFileDescriptor.open(
new File(getFilesDir(), "restore_state"),
ParcelFileDescriptor.MODE_READ_WRITE|ParcelFileDescriptor.MODE_CREATE|
ParcelFileDescriptor.MODE_TRUNCATE);
- dispatch.dispatch(data, state);
+ dispatch.performRestore(data, state);
dataFile.close();
state.close();
} catch (IOException ex) {
diff --git a/tests/backup/src/com/android/backuptest/BackupTestAgent.java b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
index 0da4151..c6acc66 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestAgent.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
@@ -16,46 +16,13 @@
package com.android.backuptest;
-import android.app.BackupAgent;
-import android.backup.BackupDataInput;
-import android.backup.BackupDataOutput;
+import android.backup.BackupHelperAgent;
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
+public class BackupTestAgent extends BackupHelperAgent
{
- 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");
-
- (new FileBackupHelper(this, DATA_FILES)).performBackup(oldState, data, newState, FILES);
- }
-
- @Override
- 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, newState);
+ public void onCreate() {
+ addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME));
}
}