summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2009-07-02 11:17:03 -0700
committerChristopher Tate <ctate@google.com>2009-07-02 11:30:29 -0700
commitee0e78af5af3bf23dd928fe5e0ebeb39157eaf66 (patch)
treed364ee20d633ea67a5cf6e82e3f67e1e3bd7feb8 /core
parentc7396025e59524e7ef639fd86fc23123939ee91c (diff)
downloadframeworks_base-ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66.zip
frameworks_base-ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66.tar.gz
frameworks_base-ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66.tar.bz2
Add a "clear backed-up data" method to the backup mechanism
It's now possible to ask that the backup manager wipe the saved data for a given application from the backing store. LocalTransport implements this now but the Google backend does not yet. When the data is wiped, the on-device backup state is also wiped to ensure that the next backup pushes all necessary data. Bmgr has not yet been modified to actually call into this method, but it will be soon.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/backup/IBackupManager.aidl14
-rw-r--r--core/java/com/android/internal/backup/IBackupTransport.aidl18
-rw-r--r--core/java/com/android/internal/backup/LocalTransport.java11
3 files changed, 40 insertions, 3 deletions
diff --git a/core/java/android/backup/IBackupManager.aidl b/core/java/android/backup/IBackupManager.aidl
index 1f11762..d4933ac 100644
--- a/core/java/android/backup/IBackupManager.aidl
+++ b/core/java/android/backup/IBackupManager.aidl
@@ -32,10 +32,24 @@ interface IBackupManager {
/**
* Tell the system service that the caller has made changes to its
* data, and therefore needs to undergo an incremental backup pass.
+ *
+ * Any application can invoke this method for its own package, but
+ * only callers who hold the android.permission.BACKUP permission
+ * may invoke it for arbitrary packages.
*/
void dataChanged(String packageName);
/**
+ * Erase all backed-up data for the given package from the storage
+ * destination.
+ *
+ * Any application can invoke this method for its own package, but
+ * only callers who hold the android.permission.BACKUP permission
+ * may invoke it for arbitrary packages.
+ */
+ void clearBackupData(String packageName);
+
+ /**
* Notifies the Backup Manager Service that an agent has become available. This
* method is only invoked by the Activity Manager.
*/
diff --git a/core/java/com/android/internal/backup/IBackupTransport.aidl b/core/java/com/android/internal/backup/IBackupTransport.aidl
index 4bef265..af06965 100644
--- a/core/java/com/android/internal/backup/IBackupTransport.aidl
+++ b/core/java/com/android/internal/backup/IBackupTransport.aidl
@@ -83,13 +83,25 @@ interface IBackupTransport {
boolean performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd);
/**
- * Finish sending application data to the backup destination. This must be
- * called after {@link #performBackup} to ensure that all data is sent. Only
- * when this method returns true can the backup be assumed to have succeeded.
+ * Erase the give application's data from the backup destination. This clears
+ * out the given package's data from the current backup set, making it as though
+ * 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 false if errors occurred (the backup should be aborted and rescheduled),
* true if everything is OK so far (but {@link #finishBackup} must be called).
*/
+ boolean clearBackupData(in PackageInfo packageInfo);
+
+ /**
+ * Finish sending application data to the backup destination. This must be
+ * called after {@link #performBackup} or {@link clearBackupData} to ensure that
+ * all data is sent. Only when this method returns true can a backup be assumed
+ * to have succeeded.
+ *
+ * @return false if errors occurred (the backup should be aborted and rescheduled),
+ * true if everything is OK.
+ */
boolean finishBackup();
/**
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index c5d9d40..2facce2 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -111,6 +111,17 @@ public class LocalTransport extends IBackupTransport.Stub {
}
}
+ public boolean clearBackupData(PackageInfo packageInfo) {
+ if (DEBUG) Log.v(TAG, "clearBackupData() pkg=" + packageInfo.packageName);
+
+ File packageDir = new File(mDataDir, packageInfo.packageName);
+ for (File f : packageDir.listFiles()) {
+ f.delete();
+ }
+ packageDir.delete();
+ return true;
+ }
+
public boolean finishBackup() throws RemoteException {
if (DEBUG) Log.v(TAG, "finishBackup()");
return true;