Merge commit 'cc1d35e2e5e0c2370361294a64ff0e580856b9d2' into eclair-mr2-plus-aosp * commit 'cc1d35e2e5e0c2370361294a64ff0e580856b9d2': Use setRepeating() rather than setInexactRepeating() for backup scheduling,
This commit is contained in:
@@ -76,6 +76,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
class BackupManagerService extends IBackupManager.Stub {
|
class BackupManagerService extends IBackupManager.Stub {
|
||||||
private static final String TAG = "BackupManagerService";
|
private static final String TAG = "BackupManagerService";
|
||||||
@@ -85,6 +86,9 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
// trigger an immediate pass.
|
// trigger an immediate pass.
|
||||||
private static final long BACKUP_INTERVAL = AlarmManager.INTERVAL_HOUR;
|
private static final long BACKUP_INTERVAL = AlarmManager.INTERVAL_HOUR;
|
||||||
|
|
||||||
|
// Random variation in backup scheduling time to avoid server load spikes
|
||||||
|
private static final int FUZZ_MILLIS = 5 * 60 * 1000;
|
||||||
|
|
||||||
// The amount of time between the initial provisioning of the device and
|
// The amount of time between the initial provisioning of the device and
|
||||||
// the first backup pass.
|
// the first backup pass.
|
||||||
private static final long FIRST_BACKUP_INTERVAL = 12 * AlarmManager.INTERVAL_HOUR;
|
private static final long FIRST_BACKUP_INTERVAL = 12 * AlarmManager.INTERVAL_HOUR;
|
||||||
@@ -1949,9 +1953,15 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startBackupAlarmsLocked(long delayBeforeFirstBackup) {
|
private void startBackupAlarmsLocked(long delayBeforeFirstBackup) {
|
||||||
long when = System.currentTimeMillis() + delayBeforeFirstBackup;
|
// We used to use setInexactRepeating(), but that may be linked to
|
||||||
mAlarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, when,
|
// backups running at :00 more often than not, creating load spikes.
|
||||||
BACKUP_INTERVAL, mRunBackupIntent);
|
// Schedule at an exact time for now, and also add a bit of "fuzz".
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
|
long when = System.currentTimeMillis() + delayBeforeFirstBackup +
|
||||||
|
random.nextInt(FUZZ_MILLIS);
|
||||||
|
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, when,
|
||||||
|
BACKUP_INTERVAL + random.nextInt(FUZZ_MILLIS), mRunBackupIntent);
|
||||||
mNextBackupPass = when;
|
mNextBackupPass = when;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user