am bee49807
: Merge "Support single-package backup rejection by the transport" into lmp-mr1-dev
* commit 'bee49807dde9f19d5163e87b71fe17392bfe857c': Support single-package backup rejection by the transport
This commit is contained in:
@ -213,8 +213,9 @@ public class BackupTransport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send one application's key/value data update to the backup destination. The
|
* Send one application's key/value data update to the backup destination. The
|
||||||
* transport may send the data immediately, or may buffer it. After this is called,
|
* transport may send the data immediately, or may buffer it. If this method returns
|
||||||
* {@link #finishBackup} will be called to ensure the data is sent and recorded successfully.
|
* {@link #TRANSPORT_OK}, {@link #finishBackup} will then be called to ensure the data
|
||||||
|
* is sent and recorded successfully.
|
||||||
*
|
*
|
||||||
* @param packageInfo The identity of the application whose data is being backed up.
|
* @param packageInfo The identity of the application whose data is being backed up.
|
||||||
* This specifically includes the signature list for the package.
|
* This specifically includes the signature list for the package.
|
||||||
@ -226,6 +227,8 @@ public class BackupTransport {
|
|||||||
* is to provide a guarantee that no stale data exists in the restore set when the
|
* is to provide a guarantee that no stale data exists in the restore set when the
|
||||||
* device begins providing incremental backups.
|
* device begins providing incremental backups.
|
||||||
* @return one of {@link BackupTransport#TRANSPORT_OK} (OK so far),
|
* @return one of {@link BackupTransport#TRANSPORT_OK} (OK so far),
|
||||||
|
* {@link BackupTransport#TRANSPORT_PACKAGE_REJECTED} (to suppress backup of this
|
||||||
|
* specific package, but allow others to proceed),
|
||||||
* {@link BackupTransport#TRANSPORT_ERROR} (on network error or other failure), or
|
* {@link BackupTransport#TRANSPORT_ERROR} (on network error or other failure), or
|
||||||
* {@link BackupTransport#TRANSPORT_NOT_INITIALIZED} (if the backend dataset has
|
* {@link BackupTransport#TRANSPORT_NOT_INITIALIZED} (if the backend dataset has
|
||||||
* become lost due to inactivity purge or some other reason and needs re-initializing)
|
* become lost due to inactivity purge or some other reason and needs re-initializing)
|
||||||
|
@ -2786,21 +2786,30 @@ public class BackupManagerService {
|
|||||||
addBackupTrace("finishing op on transport");
|
addBackupTrace("finishing op on transport");
|
||||||
mStatus = mTransport.finishBackup();
|
mStatus = mTransport.finishBackup();
|
||||||
addBackupTrace("finished: " + mStatus);
|
addBackupTrace("finished: " + mStatus);
|
||||||
|
} else if (mStatus == BackupTransport.TRANSPORT_PACKAGE_REJECTED) {
|
||||||
|
addBackupTrace("transport rejected package");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) Slog.i(TAG, "no backup data written; not calling transport");
|
if (DEBUG) Slog.i(TAG, "no backup data written; not calling transport");
|
||||||
addBackupTrace("no data to send");
|
addBackupTrace("no data to send");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mStatus == BackupTransport.TRANSPORT_OK) {
|
||||||
// After successful transport, delete the now-stale data
|
// After successful transport, delete the now-stale data
|
||||||
// and juggle the files so that next time we supply the agent
|
// and juggle the files so that next time we supply the agent
|
||||||
// with the new state file it just created.
|
// with the new state file it just created.
|
||||||
if (mStatus == BackupTransport.TRANSPORT_OK) {
|
|
||||||
mBackupDataName.delete();
|
mBackupDataName.delete();
|
||||||
mNewStateName.renameTo(mSavedStateName);
|
mNewStateName.renameTo(mSavedStateName);
|
||||||
EventLog.writeEvent(EventLogTags.BACKUP_PACKAGE, pkgName, size);
|
EventLog.writeEvent(EventLogTags.BACKUP_PACKAGE, pkgName, size);
|
||||||
logBackupComplete(pkgName);
|
logBackupComplete(pkgName);
|
||||||
|
} else if (mStatus == BackupTransport.TRANSPORT_PACKAGE_REJECTED) {
|
||||||
|
// The transport has rejected backup of this specific package. Roll it
|
||||||
|
// back but proceed with running the rest of the queue.
|
||||||
|
mBackupDataName.delete();
|
||||||
|
mNewStateName.delete();
|
||||||
|
EventLogTags.writeBackupAgentFailure(pkgName, "Transport rejected");
|
||||||
} else {
|
} else {
|
||||||
|
// Actual transport-level failure to communicate the data to the backend
|
||||||
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, pkgName);
|
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, pkgName);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -2811,15 +2820,17 @@ public class BackupManagerService {
|
|||||||
try { if (backupData != null) backupData.close(); } catch (IOException e) {}
|
try { if (backupData != null) backupData.close(); } catch (IOException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we encountered an error here it's a transport-level failure. That
|
|
||||||
// means we need to halt everything and reschedule everything for next time.
|
|
||||||
final BackupState nextState;
|
final BackupState nextState;
|
||||||
if (mStatus != BackupTransport.TRANSPORT_OK) {
|
if (mStatus == BackupTransport.TRANSPORT_OK
|
||||||
|
|| mStatus == BackupTransport.TRANSPORT_PACKAGE_REJECTED) {
|
||||||
|
// Success or single-package rejection. Proceed with the next app if any,
|
||||||
|
// otherwise we're done.
|
||||||
|
nextState = (mQueue.isEmpty()) ? BackupState.FINAL : BackupState.RUNNING_QUEUE;
|
||||||
|
} else {
|
||||||
|
// Any other error here indicates a transport-level failure. That means
|
||||||
|
// we need to halt everything and reschedule everything for next time.
|
||||||
revertAndEndBackup();
|
revertAndEndBackup();
|
||||||
nextState = BackupState.FINAL;
|
nextState = BackupState.FINAL;
|
||||||
} else {
|
|
||||||
// Success! Proceed with the next app if any, otherwise we're done.
|
|
||||||
nextState = (mQueue.isEmpty()) ? BackupState.FINAL : BackupState.RUNNING_QUEUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
executeNextState(nextState);
|
executeNextState(nextState);
|
||||||
|
Reference in New Issue
Block a user