Add rough-draft restore API set to IBackupTransport
* getAvailableBackups returns the list of backup sets available for restore * getAppSet() returns the set of apps available from a given backup set * getRestoreData() streams the full backup data for a given application (within a given backup set) into a FD; that data will be handed to the app's backup agent for processing.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.android.internal.backup;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
|
||||
@@ -27,4 +28,24 @@ public class AdbTransport extends IBackupTransport.Stub {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Restore handling
|
||||
public Bundle getAvailableBackups() throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
Bundle b = new Bundle();
|
||||
b.putIntArray("tokens", new int[0]);
|
||||
b.putStringArray("names", new String[0]);
|
||||
return b;
|
||||
}
|
||||
|
||||
public PackageInfo[] getAppSet(int token) throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
return new PackageInfo[0];
|
||||
}
|
||||
|
||||
public int getRestoreData(int token, PackageInfo packageInfo, ParcelFileDescriptor data)
|
||||
throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.android.internal.backup;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
|
||||
@@ -26,4 +27,23 @@ public class GoogleTransport extends IBackupTransport.Stub {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Restore handling
|
||||
public Bundle getAvailableBackups() throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
Bundle b = new Bundle();
|
||||
b.putIntArray("tokens", new int[0]);
|
||||
b.putStringArray("names", new String[0]);
|
||||
return b;
|
||||
}
|
||||
|
||||
public PackageInfo[] getAppSet(int token) throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
return new PackageInfo[0];
|
||||
}
|
||||
|
||||
public int getRestoreData(int token, PackageInfo packageInfo, ParcelFileDescriptor data)
|
||||
throws android.os.RemoteException {
|
||||
// !!! TODO: real implementation
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.backup;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
/** {@hide} */
|
||||
@@ -51,8 +52,8 @@ interface IBackupTransport {
|
||||
/**
|
||||
* Send one application's data to the backup destination.
|
||||
*
|
||||
* @param package The identity of the application whose data is being backed up. This
|
||||
* specifically includes the signature list for the package.
|
||||
* @param packageInfo The identity of the application whose data is being backed up.
|
||||
* This specifically includes the signature list for the package.
|
||||
* @param data The data stream that resulted from invoking the application's
|
||||
* BackupService.doBackup() method. This may be a pipe rather than a file on
|
||||
* persistent media, so it may not be seekable.
|
||||
@@ -60,6 +61,40 @@ interface IBackupTransport {
|
||||
*/
|
||||
int performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor data);
|
||||
|
||||
/**
|
||||
* Get the set of backups currently available over this transport.
|
||||
*
|
||||
* @return backups A bundle containing two elements: an int array under the key
|
||||
* "tokens" whose entries are a transport-private identifier for each backup set;
|
||||
* and a String array under the key "names" whose entries are the user-meaningful
|
||||
* names corresponding to the backup sets at each index in the tokens array.
|
||||
**/
|
||||
Bundle getAvailableBackups();
|
||||
|
||||
/**
|
||||
* Get the set of applications from a given backup image.
|
||||
*
|
||||
* @param token A backup token as returned by {@link availableBackups}.
|
||||
* @return An array of PackageInfo objects describing all of the applications
|
||||
* available for restore from the given backup set. This should include the list
|
||||
* of signatures for each package so that the Backup Manager can filter using that
|
||||
* information.
|
||||
*/
|
||||
PackageInfo[] getAppSet(int token);
|
||||
|
||||
/**
|
||||
* Retrieve one application's data from the backup destination.
|
||||
*
|
||||
* @param token The backup record from which a restore is being requested.
|
||||
* @param packageInfo The identity of the application whose data is being restored.
|
||||
* This must include the signature list for the package; it is up to the transport
|
||||
* to verify that the requested app's signatures match the saved backup record
|
||||
* because the transport cannot necessarily trust the client device.
|
||||
* @param data An open, writeable file into which the backup image should be stored.
|
||||
* @return Zero on success; a nonzero error code on failure.
|
||||
*/
|
||||
int getRestoreData(int token, in PackageInfo packageInfo, in ParcelFileDescriptor data);
|
||||
|
||||
/**
|
||||
* Terminate the backup session, closing files, freeing memory, and cleaning up whatever
|
||||
* other state the transport required.
|
||||
|
||||
Reference in New Issue
Block a user