More backup work

* Put in some permission enforcement around agent connection notification
  and full-backup scheduling.
* Full backup now applies to any package, not just backup participants who
  have declared their own android:backupAgent
* The process of running the backup operation on the set of apps who have
  been queued for it is now done in a separate thread, with a notification
  mechanism from the main Backup Manager service to pass along new-agent
  binding knowledge.  There's no longer one do-backup message on the primary
  Handler per target application.
* The new backup thread sets up the desired transport now and passes
  along the newly backed-up data to it for each backup target.  Two
  transports have been defined so far, GoogleTransport and AdbTransport;
  both are stubs at present.

Note that at present the backup data output file seems to be properly
created, but after doBackup() is called on the test app's agent it's
still zero size.
This commit is contained in:
Christopher Tate
2009-06-02 16:11:00 -07:00
parent 4ee0a75168
commit 043dadc751
7 changed files with 308 additions and 65 deletions

View File

@@ -41,6 +41,12 @@ public class BackupManager {
private Context mContext;
private IBackupManager mService;
/**
* Defined backup transports understood by {@link IBackupManager.selectBackupTransport}.
*/
public static final int TRANSPORT_ADB = 1;
public static final int TRANSPORT_GOOGLE = 2;
/**
* Constructs a BackupManager object through which the application can
* communicate with the Android backup system.

View File

@@ -36,20 +36,28 @@ interface IBackupManager {
/**
* Notifies the Backup Manager Service that an agent has become available. This
* method is only invoked by the Activity Manager.
* !!! TODO: permission
*/
oneway void agentConnected(String packageName, IBinder agent);
/**
* Notify the Backup Manager Service that an agent has unexpectedly gone away.
* This method is only invoked by the Activity Manager.
* !!! TODO: permission
*/
oneway void agentDisconnected(String packageName);
/**
* Schedule a full backup of the given package.
* !!! TODO: permission
* Schedule a full backup of the given package. Callers must hold the
* android.permission.BACKUP permission to use this method.
*/
oneway void scheduleFullBackup(String packageName);
/**
* Specify a default backup transport. Callers must hold the
* android.permission.BACKUP permission to use this method.
*
* @param transportID The ID of the transport to select. This should be one
* of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
* @return The ID of the previously selected transport.
*/
int selectBackupTransport(int transportID);
}

View File

@@ -0,0 +1,28 @@
package com.android.internal.backup;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
/**
* Backup transport for full backup over adb. This transport pipes everything to
* a file in a known location in /cache, which 'adb backup' then pulls to the desktop
* (deleting it afterwards).
*/
public class AdbTransport extends IBackupTransport.Stub {
public int startSession() throws RemoteException {
return 0;
}
public int endSession() throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
public int performBackup(String packageName, ParcelFileDescriptor data)
throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
}

View File

@@ -0,0 +1,28 @@
package com.android.internal.backup;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
/**
* Backup transport for saving data to Google cloud storage.
*/
public class GoogleTransport extends IBackupTransport.Stub {
public int endSession() throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
public int performBackup(String packageName, ParcelFileDescriptor data)
throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
public int startSession() throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
}

View File

@@ -16,6 +16,7 @@
package com.android.internal.backup;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
/** {@hide} */