DO NOT MERGE: Backport N backup/restore stability work to M

This is a squashed rollup of backup/restore infrastructural work in
the N release.  It intentionally omits semantic/API changes such
as the introduction of the onQuotaExceeded() callback.

This patchset should not be merged beyond M maintenance releases.

Bug 29617908
Bug 29848715

Change-Id: I1eb25ad07f3bbf1132198d8a233722c41f1ac4cc
This commit is contained in:
Christopher Tate
2016-07-29 16:01:31 -07:00
parent 7abd7ba093
commit d6f3a11107
3 changed files with 983 additions and 321 deletions

View File

@@ -59,6 +59,68 @@ import android.util.Log;
public class BackupManager {
private static final String TAG = "BackupManager";
// BackupObserver status codes
/**
* Indicates that backup succeeded.
*
* @hide
*/
public static final int SUCCESS = 0;
/**
* Indicates that backup is either not enabled at all or
* backup for the package was rejected by backup service
* or backup transport,
*
* @hide
*/
public static final int ERROR_BACKUP_NOT_ALLOWED = -2001;
/**
* The requested app is not installed on the device.
*
* @hide
*/
public static final int ERROR_PACKAGE_NOT_FOUND = -2002;
/**
* The transport for some reason was not in a good state and
* aborted the entire backup request. This is a transient
* failure and should not be retried immediately.
*
* @hide
*/
public static final int ERROR_TRANSPORT_ABORTED = BackupTransport.TRANSPORT_ERROR;
/**
* Returned when the transport was unable to process the
* backup request for a given package, for example if the
* transport hit a transient network failure. The remaining
* packages provided to {@link #requestBackup(String[], BackupObserver)}
* will still be attempted.
*
* @hide
*/
public static final int ERROR_TRANSPORT_PACKAGE_REJECTED =
BackupTransport.TRANSPORT_PACKAGE_REJECTED;
/**
* Returned when the transport reject the attempt to backup because
* backup data size exceeded current quota limit for this package.
*
* @hide
*/
public static final int ERROR_TRANSPORT_QUOTA_EXCEEDED =
BackupTransport.TRANSPORT_QUOTA_EXCEEDED;
/**
* The {@link BackupAgent} for the requested package failed for some reason
* and didn't provide appropriate backup data.
*
* @hide
*/
public static final int ERROR_AGENT_FAILURE = BackupTransport.AGENT_ERROR;
private Context mContext;
private static IBackupManager sService;

View File

@@ -49,6 +49,8 @@ public class BackupTransport {
public static final int TRANSPORT_PACKAGE_REJECTED = -1002;
public static final int AGENT_ERROR = -1003;
public static final int AGENT_UNKNOWN = -1004;
/** @hide */
public static final int TRANSPORT_QUOTA_EXCEEDED = -1005;
IBackupTransport mBinderImpl = new TransportImpl();