1 package com.google.android.libraries.backup.shadow; 2 3 import android.app.backup.BackupHelper; 4 import android.app.backup.FileBackupHelper; 5 import android.content.Context; 6 import com.google.common.base.Preconditions; 7 8 /** 9 * Class which simulates backup & restore functionality of a {@link BackupHelper}. 10 */ 11 public abstract class BackupHelperSimulator { 12 13 /** Prefix key of the corresponding {@link FileBackupHelper}. */ 14 protected final String keyPrefix; 15 BackupHelperSimulator(String keyPrefix)16 public BackupHelperSimulator(String keyPrefix) { 17 this.keyPrefix = Preconditions.checkNotNull(keyPrefix); 18 } 19 20 /** Perform backup into an {@link Object}, which is then returned by the method. */ backup(Context context)21 public abstract Object backup(Context context); 22 23 /** 24 * Perform restore from the provided {@link Object}, which must have the same type as the one 25 * returned by {@link #backup}. 26 */ restore(Context context, Object data)27 public abstract void restore(Context context, Object data); 28 } 29