Pass null as savedState to indicate a full backup is required
This commit is contained in:
@@ -39,7 +39,7 @@ import android.util.Log;
|
|||||||
* <!-- Use the class "MyBackupService" to perform backups for my app -->
|
* <!-- Use the class "MyBackupService" to perform backups for my app -->
|
||||||
* <service android:name=".MyBackupService">
|
* <service android:name=".MyBackupService">
|
||||||
* <intent-filter>
|
* <intent-filter>
|
||||||
* <action android:name="android.service.action.BACKUP" />
|
* <action android:name="android.backup.BackupService.SERVICE" />
|
||||||
* </intent-filter>
|
* </intent-filter>
|
||||||
* </service></pre>
|
* </service></pre>
|
||||||
*
|
*
|
||||||
@@ -54,19 +54,18 @@ public abstract class BackupService extends Service {
|
|||||||
* IntentFilter} that accepts this action.
|
* IntentFilter} that accepts this action.
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.SERVICE_ACTION)
|
@SdkConstant(SdkConstantType.SERVICE_ACTION)
|
||||||
public static final String SERVICE_ACTION = "android.backup.BackupService";
|
public static final String SERVICE_ACTION = "android.backup.BackupService.SERVICE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application is being asked to write any data changed since the
|
* The application is being asked to write any data changed since the
|
||||||
* last time it performed a backup operation. The state data recorded
|
* last time it performed a backup operation. The state data recorded
|
||||||
* during the last backup pass is provided in the oldStateFd file descriptor.
|
* during the last backup pass is provided in the oldState file descriptor.
|
||||||
* If oldState.getStatSize() is zero or negative, no old state is available
|
* If oldState is null, no old state is available and the application should perform
|
||||||
* and the application should perform a full backup. In both cases, a representation
|
* a full backup. In both cases, a representation of the final backup state after
|
||||||
* of the final backup state after this pass should be written to the file pointed
|
* this pass should be written to the file pointed to by the newStateFd file descriptor.
|
||||||
* to by the newStateFd file descriptor.
|
|
||||||
*
|
*
|
||||||
* @param oldState An open, read-only ParcelFileDescriptor pointing to the last backup
|
* @param oldState An open, read-only ParcelFileDescriptor pointing to the last backup
|
||||||
* state provided by the application. May be empty or invalid, in which
|
* state provided by the application. May be null, in which
|
||||||
* case no prior state is being provided and the application should
|
* case no prior state is being provided and the application should
|
||||||
* perform a full backup.
|
* perform a full backup.
|
||||||
* @param data An open, read/write ParcelFileDescriptor pointing to the backup data
|
* @param data An open, read/write ParcelFileDescriptor pointing to the backup data
|
||||||
|
|||||||
@@ -119,18 +119,15 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// one backup service per package
|
// one backup service per package
|
||||||
File savedStateName = new File(mStateDir,
|
File savedStateName = new File(mStateDir,
|
||||||
request.service.packageName);
|
request.service.packageName);
|
||||||
File dummyName = new File(mStateDir, "#####");
|
|
||||||
File backupDataName = new File(mDataDir,
|
File backupDataName = new File(mDataDir,
|
||||||
request.service.packageName + ".data");
|
request.service.packageName + ".data");
|
||||||
File newStateName = new File(mStateDir,
|
File newStateName = new File(mStateDir,
|
||||||
request.service.packageName + ".new");
|
request.service.packageName + ".new");
|
||||||
|
|
||||||
// In a full backup, we pass a file that is never writeable, hence
|
// In a full backup, we pass a null ParcelFileDescriptor as
|
||||||
// is always zero-sized, as a sentinel to the callee that they must
|
// the saved-state "file"
|
||||||
// write all of their data.
|
ParcelFileDescriptor savedState = (request.fullBackup) ? null
|
||||||
ParcelFileDescriptor savedState =
|
: ParcelFileDescriptor.open(savedStateName,
|
||||||
ParcelFileDescriptor.open(
|
|
||||||
(request.fullBackup) ? savedStateName : dummyName,
|
|
||||||
ParcelFileDescriptor.MODE_READ_ONLY |
|
ParcelFileDescriptor.MODE_READ_ONLY |
|
||||||
ParcelFileDescriptor.MODE_CREATE);
|
ParcelFileDescriptor.MODE_CREATE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user