summaryrefslogtreecommitdiffstats
path: root/services/backup
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2015-03-27 17:58:18 -0700
committerChristopher Tate <ctate@google.com>2015-03-27 17:58:18 -0700
commita7f038c9c3715bf29aec194bf079bf061502b1d9 (patch)
treeac811fc46fc297c50a01187af817cbfbabb9aad6 /services/backup
parent6e6af0d34eb08a810cd399de64c1ade21fe866a9 (diff)
downloadframeworks_base-a7f038c9c3715bf29aec194bf079bf061502b1d9.zip
frameworks_base-a7f038c9c3715bf29aec194bf079bf061502b1d9.tar.gz
frameworks_base-a7f038c9c3715bf29aec194bf079bf061502b1d9.tar.bz2
Respect the transport's requestFullBackupTime() backoff
We now make sure to pause by at least requestFullBackupTime() between full-data backup operations, to give the transport the ability to apply traffic control while we're running the queue of eligible packages. Also, we now reset a package's queue position whenever a full-data backup for that package is run explicitly via adb. Bug 19732890 Change-Id: I6cf24495ad18eebd55557f229d11c703e5b7f529
Diffstat (limited to 'services/backup')
-rw-r--r--services/backup/java/com/android/server/backup/BackupManagerService.java33
1 files changed, 25 insertions, 8 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 1a71fad..45b0fb2 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -371,7 +371,7 @@ public class BackupManagerService {
// we're now good to go, so start the backup alarms
if (MORE_DEBUG) Slog.d(TAG, "Now provisioned, so starting backups");
KeyValueBackupJob.schedule(mContext);
- scheduleNextFullBackupJob();
+ scheduleNextFullBackupJob(0);
}
}
}
@@ -1786,7 +1786,7 @@ public class BackupManagerService {
PackageInfo app = mPackageManager.getPackageInfo(packageName, 0);
if (appGetsFullBackup(app) && appIsEligibleForBackup(app.applicationInfo)) {
enqueueFullBackup(packageName, now);
- scheduleNextFullBackupJob();
+ scheduleNextFullBackupJob(0);
}
// Transport maintenance: rebind to known existing transports that have
@@ -3919,6 +3919,7 @@ public class BackupManagerService {
ParcelFileDescriptor[] transportPipes = null;
PackageInfo currentPackage;
+ long backoff = 0;
try {
if (!mEnabled || !mProvisioned) {
@@ -4033,6 +4034,14 @@ public class BackupManagerService {
Slog.e(TAG, "Error " + result
+ " backing up " + currentPackage.packageName);
}
+
+ // Also ask the transport how long it wants us to wait before
+ // moving on to the next package, if any.
+ backoff = transport.requestFullBackupTime();
+ if (DEBUG_SCHEDULING) {
+ Slog.i(TAG, "Transport suggested backoff=" + backoff);
+ }
+
}
// Roll this package to the end of the backup queue if we're
@@ -4090,7 +4099,7 @@ public class BackupManagerService {
// Now that we're actually done with schedule-driven work, reschedule
// the next pass based on the new queue state.
if (mUpdateSchedule) {
- scheduleNextFullBackupJob();
+ scheduleNextFullBackupJob(backoff);
}
}
}
@@ -4223,16 +4232,17 @@ public class BackupManagerService {
/**
* Schedule a job to tell us when it's a good time to run a full backup
*/
- void scheduleNextFullBackupJob() {
+ void scheduleNextFullBackupJob(long transportMinLatency) {
synchronized (mQueueLock) {
if (mFullBackupQueue.size() > 0) {
// schedule the next job at the point in the future when the least-recently
// backed up app comes due for backup again; or immediately if it's already
// due.
- long upcomingLastBackup = mFullBackupQueue.get(0).lastBackup;
- long timeSinceLast = System.currentTimeMillis() - upcomingLastBackup;
- final long latency = (timeSinceLast < MIN_FULL_BACKUP_INTERVAL)
+ final long upcomingLastBackup = mFullBackupQueue.get(0).lastBackup;
+ final long timeSinceLast = System.currentTimeMillis() - upcomingLastBackup;
+ final long appLatency = (timeSinceLast < MIN_FULL_BACKUP_INTERVAL)
? (MIN_FULL_BACKUP_INTERVAL - timeSinceLast) : 0;
+ final long latency = Math.min(transportMinLatency, appLatency);
Runnable r = new Runnable() {
@Override public void run() {
FullBackupJob.schedule(mContext, latency);
@@ -8495,6 +8505,13 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
// Just go back to waiting for the latch to indicate completion
}
} while (true);
+
+ // We just ran a backup on these packages, so kick them to the end of the queue
+ final long now = System.currentTimeMillis();
+ for (String pkg : pkgNames) {
+ enqueueFullBackup(pkg, now);
+ }
+
if (DEBUG) {
Slog.d(TAG, "Done with full transport backup.");
}
@@ -8664,7 +8681,7 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
if (enable && !wasEnabled && mProvisioned) {
// if we've just been enabled, start scheduling backup passes
KeyValueBackupJob.schedule(mContext);
- scheduleNextFullBackupJob();
+ scheduleNextFullBackupJob(0);
} else if (!enable) {
// No longer enabled, so stop running backups
if (DEBUG) Slog.i(TAG, "Opting out of backup");