Loading core/java/android/backup/SharedPreferencesBackupHelper.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,7 @@ public class SharedPreferencesBackupHelper extends FileBackupHelperBase implemen private Context mContext; private Context mContext; private String[] mPrefGroups; private String[] mPrefGroups; public SharedPreferencesBackupHelper(Context context, String[] prefGroups) { public SharedPreferencesBackupHelper(Context context, String... prefGroups) { super(context); super(context); mContext = context; mContext = context; Loading tests/backup/src/com/android/backuptest/BackupTestAgent.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.backuptest; import android.backup.BackupHelperAgent; import android.backup.BackupHelperAgent; import android.backup.FileBackupHelper; import android.backup.FileBackupHelper; import android.backup.SharedPreferencesBackupHelper; public class BackupTestAgent extends BackupHelperAgent public class BackupTestAgent extends BackupHelperAgent { { Loading @@ -25,6 +26,7 @@ public class BackupTestAgent extends BackupHelperAgent addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME)); addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME)); addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt", addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt", "empty.txt")); "empty.txt")); addHelper("shared_prefs", new SharedPreferencesBackupHelper(this, "settings", "raw")); } } } } tests/backup/test_backup.sh +5 −0 Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,8 @@ adb shell bmgr transport 1 adb shell "rm /data/data/com.android.backuptest/files/* ; \ adb shell "rm /data/data/com.android.backuptest/files/* ; \ mkdir /data/data/com.android.backuptest ; \ mkdir /data/data/com.android.backuptest ; \ mkdir /data/data/com.android.backuptest/files ; \ mkdir /data/data/com.android.backuptest/files ; \ mkdir /data/data/com.android.backuptest/shared_prefs ; \ echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" > /data/data/com.android.backuptest/shared_prefs/raw.xml ; \ echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ Loading @@ -20,3 +22,6 @@ adb shell bmgr backup com.android.backuptest # run the backup # run the backup adb shell bmgr run adb shell bmgr run tests/backup/test_restore.sh +13 −6 Original line number Original line Diff line number Diff line Loading @@ -2,7 +2,7 @@ function check_file function check_file { { data=$(adb shell cat /data/data/com.android.backuptest/files/$1) data=$(adb shell cat /data/data/com.android.backuptest/$1) if [ "$data" = "$2" ] ; then if [ "$data" = "$2" ] ; then echo "$1 has correct value [$2]" echo "$1 has correct value [$2]" else else Loading @@ -16,8 +16,12 @@ function check_file echo --- Previous files echo --- Previous files adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "rm /data/data/com.android.backuptest/files/*" adb shell "rm /data/data/com.android.backuptest/files/*" echo --- Erased files echo --- Previous shared_prefs adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" adb shell "rm /data/data/com.android.backuptest/shared_prefs/*" echo --- Erased files and shared_prefs adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" echo --- echo --- echo echo Loading @@ -32,15 +36,18 @@ echo echo echo # check the results # check the results check_file file.txt "first file" check_file files/file.txt "first file" check_file another_file.txt "asdf" check_file files/another_file.txt "asdf" check_file 3.txt "3" check_file files/3.txt "3" check_file empty.txt "" check_file files/empty.txt "" check_file shared_prefs/raw.xml '<map><int name="pref" value="1" /></map>' echo echo echo echo echo echo echo --- Restored files echo --- Restored files adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" echo --- Restored shared_prefs adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" echo --- echo --- echo echo Loading
core/java/android/backup/SharedPreferencesBackupHelper.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,7 @@ public class SharedPreferencesBackupHelper extends FileBackupHelperBase implemen private Context mContext; private Context mContext; private String[] mPrefGroups; private String[] mPrefGroups; public SharedPreferencesBackupHelper(Context context, String[] prefGroups) { public SharedPreferencesBackupHelper(Context context, String... prefGroups) { super(context); super(context); mContext = context; mContext = context; Loading
tests/backup/src/com/android/backuptest/BackupTestAgent.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.backuptest; import android.backup.BackupHelperAgent; import android.backup.BackupHelperAgent; import android.backup.FileBackupHelper; import android.backup.FileBackupHelper; import android.backup.SharedPreferencesBackupHelper; public class BackupTestAgent extends BackupHelperAgent public class BackupTestAgent extends BackupHelperAgent { { Loading @@ -25,6 +26,7 @@ public class BackupTestAgent extends BackupHelperAgent addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME)); addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME)); addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt", addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt", "empty.txt")); "empty.txt")); addHelper("shared_prefs", new SharedPreferencesBackupHelper(this, "settings", "raw")); } } } }
tests/backup/test_backup.sh +5 −0 Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,8 @@ adb shell bmgr transport 1 adb shell "rm /data/data/com.android.backuptest/files/* ; \ adb shell "rm /data/data/com.android.backuptest/files/* ; \ mkdir /data/data/com.android.backuptest ; \ mkdir /data/data/com.android.backuptest ; \ mkdir /data/data/com.android.backuptest/files ; \ mkdir /data/data/com.android.backuptest/files ; \ mkdir /data/data/com.android.backuptest/shared_prefs ; \ echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" > /data/data/com.android.backuptest/shared_prefs/raw.xml ; \ echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ Loading @@ -20,3 +22,6 @@ adb shell bmgr backup com.android.backuptest # run the backup # run the backup adb shell bmgr run adb shell bmgr run
tests/backup/test_restore.sh +13 −6 Original line number Original line Diff line number Diff line Loading @@ -2,7 +2,7 @@ function check_file function check_file { { data=$(adb shell cat /data/data/com.android.backuptest/files/$1) data=$(adb shell cat /data/data/com.android.backuptest/$1) if [ "$data" = "$2" ] ; then if [ "$data" = "$2" ] ; then echo "$1 has correct value [$2]" echo "$1 has correct value [$2]" else else Loading @@ -16,8 +16,12 @@ function check_file echo --- Previous files echo --- Previous files adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "rm /data/data/com.android.backuptest/files/*" adb shell "rm /data/data/com.android.backuptest/files/*" echo --- Erased files echo --- Previous shared_prefs adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" adb shell "rm /data/data/com.android.backuptest/shared_prefs/*" echo --- Erased files and shared_prefs adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" echo --- echo --- echo echo Loading @@ -32,15 +36,18 @@ echo echo echo # check the results # check the results check_file file.txt "first file" check_file files/file.txt "first file" check_file another_file.txt "asdf" check_file files/another_file.txt "asdf" check_file 3.txt "3" check_file files/3.txt "3" check_file empty.txt "" check_file files/empty.txt "" check_file shared_prefs/raw.xml '<map><int name="pref" value="1" /></map>' echo echo echo echo echo echo echo --- Restored files echo --- Restored files adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "ls -l /data/data/com.android.backuptest/files" echo --- Restored shared_prefs adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" echo --- echo --- echo echo