Merge change 25992 into eclair
* changes: Add an 'init everything' operation to the first backup pass
This commit is contained in:
@@ -77,10 +77,15 @@ interface IBackupTransport {
|
||||
* @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.
|
||||
* @param wipeAllFirst When true, <i>all</i> backed-up data for the current device/account
|
||||
* will be erased prior to the storage of the data provided here. The purpose of this
|
||||
* is to provide a guarantee that no stale data exists in the restore set when the
|
||||
* device begins providing backups.
|
||||
* @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 performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd);
|
||||
boolean performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd,
|
||||
boolean wipeAllFirst);
|
||||
|
||||
/**
|
||||
* Erase the give application's data from the backup destination. This clears
|
||||
|
||||
@@ -56,12 +56,16 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean performBackup(PackageInfo packageInfo, ParcelFileDescriptor data)
|
||||
throws RemoteException {
|
||||
public boolean performBackup(PackageInfo packageInfo, ParcelFileDescriptor data,
|
||||
boolean wipeAllFirst) throws RemoteException {
|
||||
if (DEBUG) Log.v(TAG, "performBackup() pkg=" + packageInfo.packageName);
|
||||
|
||||
File packageDir = new File(mDataDir, packageInfo.packageName);
|
||||
packageDir.mkdirs();
|
||||
if (wipeAllFirst) {
|
||||
if (DEBUG) Log.v(TAG, "wiping all data first");
|
||||
deleteContents(mDataDir);
|
||||
}
|
||||
|
||||
// Each 'record' in the restore set is kept in its own file, named by
|
||||
// the record key. Wind through the data file, extracting individual
|
||||
@@ -111,6 +115,21 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes the contents but not the given directory
|
||||
private void deleteContents(File dirname) {
|
||||
File[] contents = dirname.listFiles();
|
||||
if (contents != null) {
|
||||
for (File f : contents) {
|
||||
if (f.isDirectory()) {
|
||||
// delete the directory's contents then fall through
|
||||
// and delete the directory itself.
|
||||
deleteContents(f);
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean clearBackupData(PackageInfo packageInfo) {
|
||||
if (DEBUG) Log.v(TAG, "clearBackupData() pkg=" + packageInfo.packageName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user