diff options
author | uabdullah <uabdullah@google.com> | 2017-08-16 15:55:36 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-30 15:45:03 +0000 |
commit | b9263861fd78777e4bbc3a2f7716d90a3cfccb26 (patch) | |
tree | 2b615a38431f019a9e3bd4416e3f542db87879f9 /java/com/android/dialer/backup/DialerPersistentBackupAgent.java | |
parent | 0feba780889cb1e67df64a457109fc6134111261 (diff) |
Add support to backup multiple files
Dialer has 3 files which contain preferences, currently we only backup com.google.android.dialer_preferences. This CL adds the support to backup com.google.android.dialer and com.android.dialer preferences.
Bug: 64363054
Test: DialerPersistentBackupAgentTest
PiperOrigin-RevId: 165510264
Change-Id: Icca707377702fafdafe148b791fe323606254345
Diffstat (limited to 'java/com/android/dialer/backup/DialerPersistentBackupAgent.java')
-rw-r--r-- | java/com/android/dialer/backup/DialerPersistentBackupAgent.java | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/java/com/android/dialer/backup/DialerPersistentBackupAgent.java b/java/com/android/dialer/backup/DialerPersistentBackupAgent.java index 085c3433e..18cb084c2 100644 --- a/java/com/android/dialer/backup/DialerPersistentBackupAgent.java +++ b/java/com/android/dialer/backup/DialerPersistentBackupAgent.java @@ -34,18 +34,20 @@ import java.util.Map; /** Implementation of Key/Value Backup that powers Dialer's backup and restore. */ public class DialerPersistentBackupAgent extends PersistentBackupAgentHelper { - private static final String DEFAULT_SHARED_PREFS_NAME = "com.google.android.dialer_preferences"; + private static final String[] BACKUP_NAMED_SHARED_PREFS = { + "com.google.android.dialer_preferences", "com.google.android.dialer", "com.android.dialer" + }; - @NonNull private final String sharedPrefsName; + @NonNull private final String[] sharedPreferencesToBackup; @VisibleForTesting(otherwise = VisibleForTesting.NONE) - DialerPersistentBackupAgent(@NonNull String sharedPreferenceName) { - this.sharedPrefsName = Assert.isNotNull(sharedPreferenceName); + DialerPersistentBackupAgent(@NonNull String[] sharedPrefs) { + this.sharedPreferencesToBackup = Assert.isNotNull(sharedPrefs); Logger.get(this).logImpression(DialerImpression.Type.BACKUP_KEY_VALUE_BACKUP_AGENT_CONSTRUCTOR); } public DialerPersistentBackupAgent() { - this(DEFAULT_SHARED_PREFS_NAME); + this(BACKUP_NAMED_SHARED_PREFS); } @Override @@ -70,10 +72,15 @@ public class DialerPersistentBackupAgent extends PersistentBackupAgentHelper { Logger.get(this).logImpression(DialerImpression.Type.BACKUP_KEY_VALUE_GET_BACKUP_SPECIFICATION); LogUtil.i( "DialerPersistentBackupAgent.getBackupSpecification", - "file being backed up: " + sharedPrefsName); - Map<String, BackupKeyPredicate> backupSpecification = new ArrayMap<>(); - backupSpecification.put(sharedPrefsName, BackupKeyPredicates.alwaysTrue()); - return backupSpecification; + "number of files being backed up: " + sharedPreferencesToBackup.length); + + Map<String, BackupKeyPredicate> arrayMap = new ArrayMap<>(); + for (String fileName : sharedPreferencesToBackup) { + LogUtil.i("DialerPersistentBackupAgent.getBackupSpecification", "arrayMap.put: " + fileName); + arrayMap.put(fileName, BackupKeyPredicates.alwaysTrue()); + } + + return arrayMap; } @Override |