diff options
author | Christopher Tate <ctate@google.com> | 2014-06-19 14:53:18 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2014-06-19 16:18:21 -0700 |
commit | 5a009f9008d1f18b156c142b69e173109f5e218b (patch) | |
tree | 5a8753c7e7a9a63abb184b628c0f71953e556c03 /core/java/android/app/backup | |
parent | 9c46e06478ddd821c9172c77f48fa7f64a870ad0 (diff) | |
download | frameworks_base-5a009f9008d1f18b156c142b69e173109f5e218b.zip frameworks_base-5a009f9008d1f18b156c142b69e173109f5e218b.tar.gz frameworks_base-5a009f9008d1f18b156c142b69e173109f5e218b.tar.bz2 |
Adjust full restore API
Introduces a new constant, BackupTransport.NO_MORE_DATA, defined to
be -1. The transport returns this constant when asked for the next
chunk of streaming full restore data to indicate that it has reached
EOF on the current restore target's archive stream.
If the transport returns TRANSPORT_PACKAGE_REJECTED from that same
method, then the OS will abort the current target's restore operation
and move on to the next package in the overall restore dataset (by
calling nextRestorePackage() on the transport).
If the transport returns zero when asked for the next chunk of
restore stream data, this will be interpreted as meaning that no data
is currently deliverable but the restore download is still running
properly; the caller will then retry until either data is delivered
or the transport reports NO_MORE_DATA (or an error).
Also sketched in the implementation of this latest API in the
test LocalTransport.
Bug 15330073
Change-Id: I81621cb322f831460133b7dced5bb88d2a4124e1
Diffstat (limited to 'core/java/android/app/backup')
-rw-r--r-- | core/java/android/app/backup/BackupTransport.java | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/core/java/android/app/backup/BackupTransport.java b/core/java/android/app/backup/BackupTransport.java index 706ef04..4631323 100644 --- a/core/java/android/app/backup/BackupTransport.java +++ b/core/java/android/app/backup/BackupTransport.java @@ -31,12 +31,22 @@ import com.android.internal.backup.IBackupTransport; * @hide */ public class BackupTransport { + // Zero return always means things are okay. If returned from + // getNextFullRestoreDataChunk(), it means that no data could be delivered at + // this time, but the restore is still running and the caller should simply + // retry. public static final int TRANSPORT_OK = 0; - public static final int TRANSPORT_ERROR = 1; - public static final int TRANSPORT_NOT_INITIALIZED = 2; - public static final int TRANSPORT_PACKAGE_REJECTED = 3; - public static final int AGENT_ERROR = 4; - public static final int AGENT_UNKNOWN = 5; + + // -1 is special; it is used in getNextFullRestoreDataChunk() to indicate that + // we've delivered the entire data stream for the current restore target. + public static final int NO_MORE_DATA = -1; + + // Result codes that indicate real errors are negative and not -1 + public static final int TRANSPORT_ERROR = -1000; + public static final int TRANSPORT_NOT_INITIALIZED = -1001; + public static final int TRANSPORT_PACKAGE_REJECTED = -1002; + public static final int AGENT_ERROR = -1003; + public static final int AGENT_UNKNOWN = -1004; IBackupTransport mBinderImpl = new TransportImpl(); /** @hide */ @@ -370,11 +380,14 @@ public class BackupTransport { * @param socket The file descriptor that the transport will use for delivering the * streamed archive. The transport must close this socket in all cases when returning * from this method. - * @return 0 when no more data for the current package is available. A positive value - * indicates the presence of that many bytes to be delivered to the app. Any negative - * return value is treated as equivalent to {@link BackupTransport#TRANSPORT_ERROR}, - * indicating a fatal error condition that precludes further restore operations - * on the current dataset. + * @return {@link #NO_MORE_DATA} when no more data for the current package is available. + * A positive value indicates the presence of that many bytes to be delivered to the app. + * A value of zero indicates that no data was deliverable at this time, but the restore + * is still running and the caller should retry. {@link #TRANSPORT_PACKAGE_REJECTED} + * means that the current package's restore operation should be aborted, but that + * the transport itself is still in a good state and so a multiple-package restore + * sequence can still be continued. Any other negative return value is treated as a + * fatal error condition that aborts all further restore operations on the current dataset. */ public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) { return 0; |