Reset backup tracking in response to transport data-wipe notification
When attempting a backup, the transport may inform us that the backend is in an uninitialized state. This typically means that the device's data has been wiped after a period [e.g. 90 days] of inactivity. This means that we need to re-store all data subject to backup, and all of our incremental state tracking on the device is now stale. In response, we wipe all of our recorded backup state and restart the backup pass on all participants.
This commit is contained in:
26
core/java/com/android/internal/backup/BackupConstants.java
Normal file
26
core/java/com/android/internal/backup/BackupConstants.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.backup;
|
||||
|
||||
/**
|
||||
* Constants used internally between the backup manager and its transports
|
||||
*/
|
||||
public class BackupConstants {
|
||||
public static final int TRANSPORT_OK = 0;
|
||||
public static final int TRANSPORT_ERROR = 1;
|
||||
public static final int TRANSPORT_NOT_INITIALIZED = 2;
|
||||
}
|
||||
@@ -81,10 +81,14 @@ interface IBackupTransport {
|
||||
* 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).
|
||||
* @return If everything is okay so far, returns zero (but {@link #finishBackup} must
|
||||
* still be called). If the backend dataset has unexpectedly become unavailable,
|
||||
* such as when it is deleted after a period of device inactivity, returns {@link
|
||||
* BackupManager#DATASET_UNAVAILABLE}; in this case, the transport should be
|
||||
* reinitalized and the entire backup pass restarted. Any other nonzero value is a
|
||||
* fatal error requiring that this package's backup be aborted and rescheduled.
|
||||
*/
|
||||
boolean performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd,
|
||||
int performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor inFd,
|
||||
boolean wipeAllFirst);
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,7 +56,7 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean performBackup(PackageInfo packageInfo, ParcelFileDescriptor data,
|
||||
public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data,
|
||||
boolean wipeAllFirst) throws RemoteException {
|
||||
if (DEBUG) Log.v(TAG, "performBackup() pkg=" + packageInfo.packageName);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
entity.write(buf, 0, dataSize);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to update key file " + entityFile.getAbsolutePath());
|
||||
return false;
|
||||
return BackupConstants.TRANSPORT_ERROR;
|
||||
} finally {
|
||||
entity.close();
|
||||
}
|
||||
@@ -107,11 +107,11 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
entityFile.delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return BackupConstants.TRANSPORT_OK;
|
||||
} catch (IOException e) {
|
||||
// oops, something went wrong. abort the operation and return error.
|
||||
Log.v(TAG, "Exception reading backup input:", e);
|
||||
return false;
|
||||
return BackupConstants.TRANSPORT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user