Keep track of backup state independently for each transport

Backup transports now provide the Backup Manager with a suggested name with
which it can disambiguate any transport-specific bookkeeping that it needs to
maintain.  The Manager keeps separate application backup 'state blobs' for each
transport now, preventing things from getting out of step if the device is
switched among multiple transports.

Also, the metadata backup agent is always invoked now on each backup pass.  This
is cheap when there is nothing to do, but also strongly ensures that we never
wind up in a situation where a given transport destination has not been given
all of the metadata necessary for the backup set.
This commit is contained in:
Christopher Tate
2009-06-25 16:03:14 -07:00
parent 2f437b4c56
commit 5cb400bd72
3 changed files with 57 additions and 37 deletions

View File

@@ -40,6 +40,20 @@ interface IBackupTransport {
- cloud: tear down connection etc
- adb: close the file
*/
/**
* Ask the transport where, on local device storage, to keep backup state blobs.
* This is per-transport so that mock transports used for testing can coexist with
* "live" backup services without interfering with the live bookkeeping. The
* returned string should be a name that is expected to be unambiguous among all
* available backup transports; the name of the class implementing the transport
* is a good choice.
*
* @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.
*/
String transportDirName();
/**
* Verify that this is a suitable time for a backup pass. This should return zero
* if a backup is reasonable right now, some positive value otherwise. This method

View File

@@ -30,6 +30,9 @@ public class LocalTransport extends IBackupTransport.Stub {
private static final String TAG = "LocalTransport";
private static final boolean DEBUG = true;
private static final String TRANSPORT_DIR_NAME
= "com.android.internal.backup.LocalTransport";
private Context mContext;
private PackageManager mPackageManager;
private File mDataDir = new File(Environment.getDownloadCacheDirectory(), "backup");
@@ -43,6 +46,11 @@ public class LocalTransport extends IBackupTransport.Stub {
mPackageManager = context.getPackageManager();
}
public String transportDirName() throws RemoteException {
return TRANSPORT_DIR_NAME;
}
public long requestBackupTime() throws RemoteException {
// any time is a good time for local backup
return 0;