Class ShadowBackupManager

java.lang.Object
org.robolectric.shadows.ShadowBackupManager

@Implements(android.app.backup.BackupManager.class) public class ShadowBackupManager extends Object
A stub implementation of BackupManager that instead of connecting to a real backup transport and performing restores, stores which packages are restored from which backup set, what the final result should be and can be verified using methods on the shadow like getPackageRestoreToken(String) and getPackageRestoreCount(String).
  • Constructor Details

    • ShadowBackupManager

      public ShadowBackupManager()
  • Method Details

    • reset

      @Resetter public static void reset()
    • __constructor__

      @Implementation protected void __constructor__(Context context)
    • dataChanged

      @Implementation protected void dataChanged()
    • isDataChanged

      public boolean isDataChanged()
      Returns whether dataChanged() was called.
    • getDataChangedCount

      public int getDataChangedCount()
      Returns number of times dataChanged() was called.
    • setBackupEnabled

      @Implementation(minSdk=21) @HiddenApi protected void setBackupEnabled(boolean isEnabled)
    • isBackupEnabled

      @Implementation(minSdk=21) @HiddenApi protected boolean isBackupEnabled()
    • beginRestoreSession

      @Implementation @HiddenApi protected RestoreSession beginRestoreSession()
    • getAvailableRestoreToken

      @Implementation(minSdk=23) @HiddenApi protected long getAvailableRestoreToken(String packageName)
    • getPackageRestoreToken

      public long getPackageRestoreToken(String packageName)
      Returns the last recorded restore token for the given package, or 0 if the package was not restored.
    • getPackageRestoreCount

      public int getPackageRestoreCount(String packageName)
      Returns the number of recorded restores for the given package.
    • addAvailableRestoreSets

      public void addAvailableRestoreSets(long restoreToken, List<String> packages)
      Adds a restore set available to be restored successfully.
    • addAvailableRestoreSets

      public void addAvailableRestoreSets(long restoreToken, List<String> packages, int result)
      Adds a restore set available to be restored and the final result of the restore session.
    • setNullAvailableRestoreSets

      public void setNullAvailableRestoreSets(boolean value)
      Causes the IRestoreObserver.restoreSetsAvailable(android.app.backup.RestoreSet[]) callback to receive null, regardless of whether any restore sets were added to this shadow. Can be used to simulate a failure by the transport to fetch available restore sets.