diff options
author | Christopher Tate <ctate@google.com> | 2009-06-02 16:11:00 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2009-06-03 20:42:15 -0700 |
commit | 043dadc7516d20c3b3ccbcb20c53aaeef076a237 (patch) | |
tree | 4ff8692d43447a1416b3d605e386237c8b97e9d3 /core | |
parent | 4ee0a751682e713d3d6ca97fa1271df12d352ee0 (diff) | |
download | frameworks_base-043dadc7516d20c3b3ccbcb20c53aaeef076a237.zip frameworks_base-043dadc7516d20c3b3ccbcb20c53aaeef076a237.tar.gz frameworks_base-043dadc7516d20c3b3ccbcb20c53aaeef076a237.tar.bz2 |
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.
Diffstat (limited to 'core')
5 files changed, 75 insertions, 4 deletions
diff --git a/core/java/android/backup/BackupManager.java b/core/java/android/backup/BackupManager.java index 6f0b2ee..30f781e 100644 --- a/core/java/android/backup/BackupManager.java +++ b/core/java/android/backup/BackupManager.java @@ -42,6 +42,12 @@ public class BackupManager { 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. * diff --git a/core/java/android/backup/IBackupManager.aidl b/core/java/android/backup/IBackupManager.aidl index 3468d70..f5b82fe 100644 --- a/core/java/android/backup/IBackupManager.aidl +++ b/core/java/android/backup/IBackupManager.aidl @@ -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); } diff --git a/core/java/com/android/internal/backup/AdbTransport.java b/core/java/com/android/internal/backup/AdbTransport.java new file mode 100644 index 0000000..acb3273 --- /dev/null +++ b/core/java/com/android/internal/backup/AdbTransport.java @@ -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; + } +} diff --git a/core/java/com/android/internal/backup/GoogleTransport.java b/core/java/com/android/internal/backup/GoogleTransport.java new file mode 100644 index 0000000..85ab21e --- /dev/null +++ b/core/java/com/android/internal/backup/GoogleTransport.java @@ -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; + } + +} diff --git a/core/java/com/android/internal/backup/IBackupTransport.aidl b/core/java/com/android/internal/backup/IBackupTransport.aidl index ce39768..2b44fe7 100644 --- a/core/java/com/android/internal/backup/IBackupTransport.aidl +++ b/core/java/com/android/internal/backup/IBackupTransport.aidl @@ -16,6 +16,7 @@ package com.android.internal.backup; +import android.os.Bundle; import android.os.ParcelFileDescriptor; /** {@hide} */ |