Make IBackupTransport AIDL async

Make the transport AIDL async and introduce a callback AIDL for passing
back results. A follow-up CL will implement the client-side portion of
the callback class and update BackupTransportClient to use it.

Bug: 202716271
Test: m -j
Change-Id: I79cb376bd2a805bf2739470a3f538207ae6bd9a0
This commit is contained in:
Ruslan Tkhakokhov
2021-12-15 10:25:51 +00:00
parent d77c92a3f1
commit 16a8f596d5
3 changed files with 356 additions and 188 deletions

View File

@@ -25,6 +25,11 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import com.android.internal.backup.IBackupTransport;
import com.android.internal.backup.ITransportStatusCallback;
import com.android.internal.infra.AndroidFuture;
import java.util.Arrays;
import java.util.List;
/**
* Concrete class that provides a stable-API bridge between IBackupTransport
@@ -659,141 +664,185 @@ public class BackupTransport {
class TransportImpl extends IBackupTransport.Stub {
@Override
public String name() throws RemoteException {
return BackupTransport.this.name();
public void name(AndroidFuture<String> resultFuture) throws RemoteException {
String result = BackupTransport.this.name();
resultFuture.complete(result);
}
@Override
public Intent configurationIntent() throws RemoteException {
return BackupTransport.this.configurationIntent();
}
@Override
public String currentDestinationString() throws RemoteException {
return BackupTransport.this.currentDestinationString();
}
@Override
public Intent dataManagementIntent() {
return BackupTransport.this.dataManagementIntent();
}
@Override
public CharSequence dataManagementIntentLabel() {
return BackupTransport.this.dataManagementIntentLabel();
}
@Override
public String transportDirName() throws RemoteException {
return BackupTransport.this.transportDirName();
}
@Override
public long requestBackupTime() throws RemoteException {
return BackupTransport.this.requestBackupTime();
}
@Override
public int initializeDevice() throws RemoteException {
return BackupTransport.this.initializeDevice();
}
@Override
public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags)
public void configurationIntent(AndroidFuture<Intent> resultFuture)
throws RemoteException {
return BackupTransport.this.performBackup(packageInfo, inFd, flags);
Intent result = BackupTransport.this.configurationIntent();
resultFuture.complete(result);
}
@Override
public int clearBackupData(PackageInfo packageInfo) throws RemoteException {
return BackupTransport.this.clearBackupData(packageInfo);
public void currentDestinationString(AndroidFuture<String> resultFuture)
throws RemoteException {
String result = BackupTransport.this.currentDestinationString();
resultFuture.complete(result);
}
@Override
public int finishBackup() throws RemoteException {
return BackupTransport.this.finishBackup();
public void dataManagementIntent(AndroidFuture<Intent> resultFuture)
throws RemoteException {
Intent result = BackupTransport.this.dataManagementIntent();
resultFuture.complete(result);
}
@Override
public RestoreSet[] getAvailableRestoreSets() throws RemoteException {
return BackupTransport.this.getAvailableRestoreSets();
public void dataManagementIntentLabel(AndroidFuture<CharSequence> resultFuture)
throws RemoteException {
CharSequence result = BackupTransport.this.dataManagementIntentLabel();
resultFuture.complete(result);
}
@Override
public long getCurrentRestoreSet() throws RemoteException {
return BackupTransport.this.getCurrentRestoreSet();
public void transportDirName(AndroidFuture<String> resultFuture) throws RemoteException {
String result = BackupTransport.this.transportDirName();
resultFuture.complete(result);
}
@Override
public int startRestore(long token, PackageInfo[] packages) throws RemoteException {
return BackupTransport.this.startRestore(token, packages);
public void requestBackupTime(AndroidFuture<Long> resultFuture) throws RemoteException {
long result = BackupTransport.this.requestBackupTime();
resultFuture.complete(result);
}
@Override
public RestoreDescription nextRestorePackage() throws RemoteException {
return BackupTransport.this.nextRestorePackage();
public void initializeDevice(ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.initializeDevice();
callback.onOperationCompleteWithStatus(result);
}
@Override
public int getRestoreData(ParcelFileDescriptor outFd) throws RemoteException {
return BackupTransport.this.getRestoreData(outFd);
public void performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags,
ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.performBackup(packageInfo, inFd, flags);
callback.onOperationCompleteWithStatus(result);
}
@Override
public void finishRestore() throws RemoteException {
public void clearBackupData(PackageInfo packageInfo, ITransportStatusCallback callback)
throws RemoteException {
int result = BackupTransport.this.clearBackupData(packageInfo);
callback.onOperationCompleteWithStatus(result);
}
@Override
public void finishBackup(ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.finishBackup();
callback.onOperationCompleteWithStatus(result);
}
@Override
public void getAvailableRestoreSets(AndroidFuture<List<RestoreSet>> resultFuture)
throws RemoteException {
RestoreSet[] result = BackupTransport.this.getAvailableRestoreSets();
resultFuture.complete(Arrays.asList(result));
}
@Override
public void getCurrentRestoreSet(AndroidFuture<Long> resultFuture)
throws RemoteException {
long result = BackupTransport.this.getCurrentRestoreSet();
resultFuture.complete(result);
}
@Override
public void startRestore(long token, PackageInfo[] packages,
ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.startRestore(token, packages);
callback.onOperationCompleteWithStatus(result);
}
@Override
public void nextRestorePackage(AndroidFuture<RestoreDescription> resultFuture)
throws RemoteException {
RestoreDescription result = BackupTransport.this.nextRestorePackage();
resultFuture.complete(result);
}
@Override
public void getRestoreData(ParcelFileDescriptor outFd,
ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.getRestoreData(outFd);
callback.onOperationCompleteWithStatus(result);
}
@Override
public void finishRestore(ITransportStatusCallback callback)
throws RemoteException {
BackupTransport.this.finishRestore();
callback.onOperationComplete();
}
@Override
public long requestFullBackupTime() throws RemoteException {
return BackupTransport.this.requestFullBackupTime();
}
@Override
public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket,
int flags) throws RemoteException {
return BackupTransport.this.performFullBackup(targetPackage, socket, flags);
}
@Override
public int checkFullBackupSize(long size) {
return BackupTransport.this.checkFullBackupSize(size);
}
@Override
public int sendBackupData(int numBytes) throws RemoteException {
return BackupTransport.this.sendBackupData(numBytes);
}
@Override
public void cancelFullBackup() throws RemoteException {
BackupTransport.this.cancelFullBackup();
}
@Override
public boolean isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup)
public void requestFullBackupTime(AndroidFuture<Long> resultFuture)
throws RemoteException {
return BackupTransport.this.isAppEligibleForBackup(targetPackage, isFullBackup);
long result = BackupTransport.this.requestFullBackupTime();
resultFuture.complete(result);
}
@Override
public long getBackupQuota(String packageName, boolean isFullBackup) {
return BackupTransport.this.getBackupQuota(packageName, isFullBackup);
public void performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket,
int flags, ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.performFullBackup(targetPackage, socket, flags);
callback.onOperationCompleteWithStatus(result);
}
@Override
public int getTransportFlags() {
return BackupTransport.this.getTransportFlags();
public void checkFullBackupSize(long size, ITransportStatusCallback callback)
throws RemoteException {
int result = BackupTransport.this.checkFullBackupSize(size);
callback.onOperationCompleteWithStatus(result);
}
@Override
public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) {
return BackupTransport.this.getNextFullRestoreDataChunk(socket);
public void sendBackupData(int numBytes, ITransportStatusCallback callback)
throws RemoteException {
int result = BackupTransport.this.sendBackupData(numBytes);
callback.onOperationCompleteWithStatus(result);
}
@Override
public int abortFullRestore() {
return BackupTransport.this.abortFullRestore();
public void cancelFullBackup(ITransportStatusCallback callback) throws RemoteException {
BackupTransport.this.cancelFullBackup();
callback.onOperationComplete();
}
@Override
public void isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup,
AndroidFuture<Boolean> resultFuture) throws RemoteException {
boolean result = BackupTransport.this.isAppEligibleForBackup(targetPackage,
isFullBackup);
resultFuture.complete(result);
}
@Override
public void getBackupQuota(String packageName, boolean isFullBackup,
AndroidFuture<Long> resultFuture) throws RemoteException {
long result = BackupTransport.this.getBackupQuota(packageName, isFullBackup);
resultFuture.complete(result);
}
@Override
public void getTransportFlags(AndroidFuture<Integer> resultFuture) throws RemoteException {
int result = BackupTransport.this.getTransportFlags();
resultFuture.complete(result);
}
@Override
public void getNextFullRestoreDataChunk(ParcelFileDescriptor socket,
ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.getNextFullRestoreDataChunk(socket);
callback.onOperationCompleteWithStatus(result);
}
@Override
public void abortFullRestore(ITransportStatusCallback callback) throws RemoteException {
int result = BackupTransport.this.abortFullRestore();
callback.onOperationCompleteWithStatus(result);
}
}
}

View File

@@ -22,39 +22,46 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.os.ParcelFileDescriptor;
import com.android.internal.backup.ITransportStatusCallback;
import com.android.internal.infra.AndroidFuture;
/** {@hide} */
interface IBackupTransport {
oneway interface IBackupTransport {
/**
* Ask the transport for the name under which it should be registered. This will
* Ask the transport for the String name under which it should be registered. This will
* typically be its host service's component name, but need not be.
*
* @param resultFuture an {@link AndroidFuture} that is completed with the {@code String} name
* of the transport.
*/
String name();
void name(in AndroidFuture<String> result);
/**
* Ask the transport for an Intent that can be used to launch any internal
* configuration Activity that it wishes to present. For example, the transport
* may offer a UI for allowing the user to supply login credentials for the
* transport's off-device backend.
*
* If the transport does not supply any user-facing configuration UI, it should
* return null from this method.
*
* @return An Intent that can be passed to Context.startActivity() in order to
* launch the transport's configuration UI. This method will return null
* if the transport does not offer any user-facing configuration UI.
*/
Intent configurationIntent();
/**
* Ask the transport for an Intent that can be used to launch any internal
* configuration Activity that it wishes to present. For example, the transport
* may offer a UI for allowing the user to supply login credentials for the
* transport's off-device backend.
*
* If the transport does not supply any user-facing configuration UI, it should
* return null from this method.
*
* @param resultFuture an {@link AndroidFuture} that is completed with an {@code Intent} that
* can be passed to Context.startActivity() in order to launch the transport's
* configuration UI. This future will complete with null if the transport does not
* offer any user-facing configuration UI.
*/
void configurationIntent(in AndroidFuture<Intent> resultFuture);
/**
* On demand, supply a one-line string that can be shown to the user that
* describes the current backend destination. For example, a transport that
* can potentially associate backup data with arbitrary user accounts should
* include the name of the currently-active account here.
*
* @return A string describing the destination to which the transport is currently
* sending data. This method should not return null.
*/
String currentDestinationString();
/**
* Ask the transport for a one-line string that can be shown to the user that
* describes the current backend destination. For example, a transport that
* can potentially associate backup data with arbitrary user accounts should
* include the name of the currently-active account here.
*
* @param resultFuture an {@link AndroidFuture} that is completed with a {@code String}
* describing the destination to which the transport is currently sending data.
*/
void currentDestinationString(in AndroidFuture<String> resultFuture);
/**
* Ask the transport for an Intent that can be used to launch a more detailed
@@ -71,22 +78,23 @@ interface IBackupTransport {
* <p>If the transport does not supply any user-facing data management
* UI, then it should return {@code null} from this method.
*
* @return An intent that can be passed to Context.startActivity() in order to
* launch the transport's data-management UI. This method will return
* {@code null} if the transport does not offer any user-facing data
* management UI.
* @param resultFuture an {@link AndroidFuture} that is completed with an {@code Intent} that
* can be passed to Context.startActivity() in order to launch the transport's
* data-management UI. The callback will supply {@code null} if the transport does not
* offer any user-facing data management UI.
*/
Intent dataManagementIntent();
void dataManagementIntent(in AndroidFuture<Intent> resultFuture);
/**
* On demand, supply a short {@link CharSequence} that can be shown to the user as the label on
* an overflow menu item used to invoke the data management UI.
* Ask the transport for a short {@link CharSequence} that can be shown to the user as the label
* on an overflow menu item used to invoke the data management UI.
*
* @return A {@link CharSequence} to be used as the label for the transport's data management
* affordance. If the transport supplies a data management intent, this
* method must not return {@code null}.
* @param resultFuture an {@link AndroidFuture} that is completed with a {@code CharSequence}
* to be used as the label for the transport's data management affordance. If the
* transport supplies a data management Intent via {@link #dataManagementIntent},
* this method must not return {@code null}.
*/
CharSequence dataManagementIntentLabel();
void dataManagementIntentLabel(in AndroidFuture<CharSequence> resultFuture);
/**
* Ask the transport where, on local device storage, to keep backup state blobs.
@@ -96,11 +104,11 @@ interface IBackupTransport {
* available backup transports; the name of the class implementing the transport
* is a good choice. This MUST be constant.
*
* @return A unique name, suitable for use as a file or directory name, that the
* Backup Manager could use to disambiguate state files associated with
* different backup transports.
* @param resultFuture an {@link AndroidFuture} that is completed with a unique {@code String}
* name, suitable for use as a file or directory name, that the Backup Manager could use
* to disambiguate state files associated with different backup transports.
*/
String transportDirName();
void transportDirName(in AndroidFuture<String> resultFuture);
/**
* Verify that this is a suitable time for a backup pass. This should return zero
@@ -110,10 +118,11 @@ interface IBackupTransport {
* <p>If this is not a suitable time for a backup, the transport should return a
* backoff delay, in milliseconds, after which the Backup Manager should try again.
*
* @return Zero if this is a suitable time for a backup pass, or a positive time delay
* in milliseconds to suggest deferring the backup pass for a while.
* @param resultFuture an {@link AndroidFuture} that is completed with {@code int}: zero if
* this is a suitable time for a backup pass, or a positive time delay in milliseconds
* to suggest deferring the backup pass for a while.
*/
long requestBackupTime();
void requestBackupTime(in AndroidFuture<long> resultFuture);
/**
* Initialize the server side storage for this device, erasing all stored data.
@@ -121,10 +130,11 @@ interface IBackupTransport {
* this is called, {@link #finishBackup} must be called to ensure the request
* is sent and received successfully.
*
* @return One of {@link BackupConstants#TRANSPORT_OK} (OK so far) or
* {@link BackupConstants#TRANSPORT_ERROR} (on network error or other failure).
* @param callback a callback that is completed with a {@code int} which is one
* of {@link BackupConstants#TRANSPORT_OK} (OK so far) or
* {@link BackupConstants#TRANSPORT_ERROR} (on network error or other failure).
*/
int initializeDevice();
void initializeDevice(in ITransportStatusCallback callback);
/**
* Send one application's data to the backup destination. The transport may send
@@ -137,12 +147,14 @@ interface IBackupTransport {
* BackupService.doBackup() method. This may be a pipe rather than a file on
* persistent media, so it may not be seekable.
* @param flags Some of {@link BackupTransport#FLAG_USER_INITIATED}.
* @return one of {@link BackupConstants#TRANSPORT_OK} (OK so far),
* {@link BackupConstants#TRANSPORT_ERROR} (on network error or other failure), or
* {@link BackupConstants#TRANSPORT_NOT_INITIALIZED} (if the backend dataset has
* become lost due to inactive expiry or some other reason and needs re-initializing)
* @param callback a callback that is completed with a {@code int} which is one
* of {@link BackupConstants#TRANSPORT_OK}(OK so far), {@link BackupConstants#TRANSPORT_ERROR}
* (on network error or other failure), or {@link BackupConstants#TRANSPORT_NOT_INITIALIZED}
* (if the backend dataset has become lost due to inactive expiry or some other reason and
* needs re-initializing).
*/
int performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd, int flags);
void performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd, int flags,
in ITransportStatusCallback callback);
/**
* Erase the give application's data from the backup destination. This clears
@@ -150,9 +162,10 @@ interface IBackupTransport {
* the app had never yet been backed up. After this is called, {@link finishBackup}
* must be called to ensure that the operation is recorded successfully.
*
* @return the same error codes as {@link #performBackup}.
* @param callback a callback that is completed with the same error codes as
* {@link #performBackup}.
*/
int clearBackupData(in PackageInfo packageInfo);
void clearBackupData(in PackageInfo packageInfo, in ITransportStatusCallback callback);
/**
* Finish sending application data to the backup destination. This must be
@@ -160,27 +173,30 @@ interface IBackupTransport {
* all data is sent. Only when this method returns true can a backup be assumed
* to have succeeded.
*
* @return the same error codes as {@link #performBackup}.
* @param callback a callback that is completed with the same error codes as
* {@link #performBackup}.
*/
int finishBackup();
void finishBackup(in ITransportStatusCallback callback);
/**
* Get the set of all backups currently available over this transport.
*
* @return Descriptions of the set of restore images available for this device,
* or null if an error occurred (the attempt should be rescheduled).
* @param resultFuture an {@link AndroidFuture} that is completed with {@code List<RestoreSet>}:
* the descriptions of a set of restore images available for this device, or null if an
* error occurred (the attempt should be rescheduled).
**/
RestoreSet[] getAvailableRestoreSets();
void getAvailableRestoreSets(in AndroidFuture<List<RestoreSet>> resultFuture);
/**
* Get the identifying token of the backup set currently being stored from
* this device. This is used in the case of applications wishing to restore
* their last-known-good data.
*
* @return A token that can be passed to {@link #startRestore}, or 0 if there
* is no backup set available corresponding to the current device state.
* @param resultFuture an {@link AndroidFuture} that is completed with a {@code long}: a token
* that can be passed to {@link #startRestore}, or 0 if there is no backup set available
* corresponding to the current device state.
*/
long getCurrentRestoreSet();
void getCurrentRestoreSet(in AndroidFuture<long> resultFuture);
/**
* Start restoring application data from backup. After calling this function,
@@ -191,11 +207,12 @@ interface IBackupTransport {
* or {@link #getCurrentRestoreSet}.
* @param packages List of applications to restore (if data is available).
* Application data will be restored in the order given.
* @return One of {@link BackupConstants#TRANSPORT_OK} (OK so far, call
* {@link #nextRestorePackage}) or {@link BackupConstants#TRANSPORT_ERROR}
* (an error occurred, the restore should be aborted and rescheduled).
* @param callback a callback that is completed with one of
* {@link BackupConstants#TRANSPORT_OK} (OK so far, call {@link #nextRestorePackage}) or
* {@link BackupConstants#TRANSPORT_ERROR} (an error occurred, the restore should be aborted
* and rescheduled).
*/
int startRestore(long token, in PackageInfo[] packages);
void startRestore(long token, in PackageInfo[] packages, in ITransportStatusCallback callback);
/**
* Get the package name of the next application with data in the backup store, plus
@@ -210,34 +227,95 @@ interface IBackupTransport {
* <p>If this method returns {@code null}, it means that a transport-level error has
* occurred and the entire restore operation should be abandoned.
*
* @return A RestoreDescription object containing the name of one of the packages
* supplied to {@link #startRestore} plus an indicator of the data type of that
* restore data; or {@link RestoreDescription#NO_MORE_PACKAGES} to indicate that
* no more packages can be restored in this session; or {@code null} to indicate
* a transport-level error.
* @param resultFuture an {@link AndroidFuture} that is completed with a
* {@link RestoreDescription} object containing the name of one of the packages supplied to
* {@link #startRestore} plus an indicator of the data type of that restore data; or
* {@link RestoreDescription#NO_MORE_PACKAGES} to indicate that no more packages can be
* restored in this session; or {@code null} to indicate a transport-level error.
*/
RestoreDescription nextRestorePackage();
void nextRestorePackage(in AndroidFuture<RestoreDescription> resultFuture);
/**
* Get the data for the application returned by {@link #nextRestorePackage}.
* @param data An open, writable file into which the backup data should be stored.
* @return the same error codes as {@link #startRestore}.
*
* @param callback a callback that is completed with the same error codes as
* {@link #startRestore}.
*/
int getRestoreData(in ParcelFileDescriptor outFd);
void getRestoreData(in ParcelFileDescriptor outFd, in ITransportStatusCallback callback);
/**
* End a restore session (aborting any in-process data transfer as necessary),
* freeing any resources and connections used during the restore process.
*
* @param callback a callback to signal that restore has been finished on transport side.
*/
void finishRestore();
void finishRestore(in ITransportStatusCallback callback);
// full backup stuff
long requestFullBackupTime();
int performFullBackup(in PackageInfo targetPackage, in ParcelFileDescriptor socket, int flags);
int checkFullBackupSize(long size);
int sendBackupData(int numBytes);
void cancelFullBackup();
/**
* Verify that this is a suitable time for a full-data backup pass.
*
* @param resultFuture an {@link AndroidFuture} that is completed with {@code long}: 0 if this
* is a suitable time for a backup pass, or a positive time delay in milliseconds to
* suggest deferring the backup pass for a while.
*/
void requestFullBackupTime(in AndroidFuture<long> resultFuture);
/**
* Begin the process of sending an application's full-data archive to the backend.
*
* @param targetPackage The package whose data is to follow.
* @param socket The socket file descriptor through which the data will be provided.
* @param flags {@link BackupTransport#FLAG_USER_INITIATED} or 0.
* @param callback callback to return a {@code int} which is one of:
* {@link BackupTransport#TRANSPORT_PACKAGE_REJECTED} to indicate that the stated
* application is not to be backed up; {@link BackupTransport#TRANSPORT_OK} to indicate
* that the OS may proceed with delivering backup data;
* {@link BackupTransport#TRANSPORT_ERROR to indicate a fatal error condition that
* precludes performing a backup at this time.
*/
void performFullBackup(in PackageInfo targetPackage, in ParcelFileDescriptor socket, int flags,
in ITransportStatusCallback callback);
/**
* Called after {@link #performFullBackup} to make sure that the transport is willing to
* handle a full-data backup operation of the specified size on the current package.
*
* @param size The estimated size of the full-data payload for this app. This includes
* manifest and archive format overhead, but is not guaranteed to be precise.
* @param callback a callback that is completed with a {@code int} which is
* one of: {@link BackupTransport#TRANSPORT_OK} if the platform is to proceed with the
* full-data {@link BackupTransport#TRANSPORT_PACKAGE_REJECTED} if the proposed payload
* size is backup, too large for the transport to handle, or
* {@link BackupTransport#TRANSPORT_ERROR} to indicate a fatal error condition that
* means the platform cannot perform a backup at this time.
*/
void checkFullBackupSize(long size, in ITransportStatusCallback callback);
/**
* Tells the transport to read {@code numBytes} bytes of data from the socket file
* descriptor provided in the {@link #performFullBackup(PackageInfo, ParcelFileDescriptor)}
* call, and deliver those bytes to the datastore.
*
* @param numBytes The number of bytes of tarball data available to be read from the
* socket.
* @param callback a callback that is completed with a {@code int} which is
* one of: {@link BackupTransport#TRANSPORT_OK} on successful processing of the data,
* {@link BackupTransport#TRANSPORT_ERROR} to indicate a fatal error situation. If an
* error is returned, the system will call finishBackup() and stop attempting backups
* until after a backoff and retry interval.
*/
void sendBackupData(int numBytes, in ITransportStatusCallback callback);
/**
* Tells the transport to cancel the currently-ongoing full backup operation.
*
* @param callback a callback to indicate that transport has cancelled the operation,
* does not return any value (see {@link ITransportCallback#onVoidReceived}).
*/
void cancelFullBackup(in ITransportStatusCallback callback);
/**
* Ask the transport whether this app is eligible for backup.
@@ -245,9 +323,11 @@ interface IBackupTransport {
* @param targetPackage The identity of the application.
* @param isFullBackup If set, transport should check if app is eligible for full data backup,
* otherwise to check if eligible for key-value backup.
* @return Whether this app is eligible for backup.
* @param resultFuture an {@link AndroidFuture} that is completed with a {@code boolean}
* indicating whether this app is eligible for backup.
*/
boolean isAppEligibleForBackup(in PackageInfo targetPackage, boolean isFullBackup);
void isAppEligibleForBackup(in PackageInfo targetPackage, boolean isFullBackup,
in AndroidFuture<boolean> resultFuture);
/**
* Ask the transport about current quota for backup size of the package.
@@ -255,9 +335,11 @@ interface IBackupTransport {
* @param packageName ID of package to provide the quota.
* @param isFullBackup If set, transport should return limit for full data backup, otherwise
* for key-value backup.
* @return Current limit on full data backup size in bytes.
* @param resultFuture an {@link AndroidFuture} that is completed with a {@code long}: current
* limit on full data backup size in bytes.
*/
long getBackupQuota(String packageName, boolean isFullBackup);
void getBackupQuota(String packageName, boolean isFullBackup,
in AndroidFuture<long> resultFuture);
// full restore stuff
@@ -284,13 +366,14 @@ interface IBackupTransport {
* @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.
* @param callback a callback that is completed with an {@code int}: 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.
*/
int getNextFullRestoreDataChunk(in ParcelFileDescriptor socket);
void getNextFullRestoreDataChunk(in ParcelFileDescriptor socket,
in ITransportStatusCallback callback);
/**
* If the OS encounters an error while processing {@link RestoreDescription#TYPE_FULL_STREAM}
@@ -300,19 +383,21 @@ interface IBackupTransport {
* set being iterated over, or will call {@link #finishRestore()} to shut down the restore
* operation.
*
* @return {@link #TRANSPORT_OK} if the transport was successful in shutting down the
* current stream cleanly, or {@link #TRANSPORT_ERROR} to indicate a serious
* transport-level failure. If the transport reports an error here, the entire restore
* operation will immediately be finished with no further attempts to restore app data.
* @param callback a callback that is completed with {@code int}, which is
* one of: {@link #TRANSPORT_OK} if the transport was successful in shutting down the current
* stream cleanly, or {@link #TRANSPORT_ERROR} to indicate a serious transport-level failure.
* If the transport reports an error here, the entire restore operation will immediately be
* finished with no further attempts to restore app data.
*/
int abortFullRestore();
void abortFullRestore(in ITransportStatusCallback callback);
/**
* Returns flags with additional information about the transport, which is accessible to the
* @param resultFuture an {@link AndroidFuture} that is completed with an {@code int}: flags
* with additional information about the transport, which is accessible to the
* {@link android.app.backup.BackupAgent}. This allows the agent to decide what to backup or
* restore based on properties of the transport.
*
* <p>For supported flags see {@link android.app.backup.BackupAgent}.
*/
int getTransportFlags();
void getTransportFlags(in AndroidFuture<int> resultFuture);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.backup;
/**
* A callback class for {@link IBackupTransport}
*
* {@hide}
*/
oneway interface ITransportStatusCallback {
/**
* Callback for methods that complete with an {@code int} status.
*/
void onOperationCompleteWithStatus(int status);
/**
* Callback for methods that complete without a value.
*/
void onOperationComplete();
}