diff options
author | Christopher Tate <ctate@google.com> | 2015-06-05 14:17:43 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2015-06-05 14:22:11 -0700 |
commit | ad8a96231680fae6c49bc877074b8af3562e90f1 (patch) | |
tree | 253b468aa1c00f8149f56ed0d0f32bc07c8059ab /services/backup/java/com/android/server/backup/BackupManagerService.java | |
parent | fba7f5d73cce893860faa3af9df7b4099a8565a1 (diff) | |
download | frameworks_base-ad8a96231680fae6c49bc877074b8af3562e90f1.zip frameworks_base-ad8a96231680fae6c49bc877074b8af3562e90f1.tar.gz frameworks_base-ad8a96231680fae6c49bc877074b8af3562e90f1.tar.bz2 |
Don't run backups in battery-saver mode
Defer both full-data and key/value backups while in battery-saver mode.
Bug 21563473
Change-Id: I081b7bcd19af21a4c88ebb434d2d3ef4bc93951f
Diffstat (limited to 'services/backup/java/com/android/server/backup/BackupManagerService.java')
-rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 63bbf24..af83a53 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -4411,6 +4411,8 @@ public class BackupManagerService { * to perform one app backup per scheduled job execution, and to reschedule the job * with zero latency as long as conditions remain right and we still have work to do. * + * <p>This is the "start a full backup operation" entry point called by the scheduled job. + * * @return Whether ongoing work will continue. The return value here will be passed * along as the return value to the scheduled job's onStartJob() callback. */ @@ -4430,6 +4432,14 @@ public class BackupManagerService { return false; } + // Don't run the backup if we're in battery saver mode, but reschedule + // to try again in the not-so-distant future. + if (mPowerManager.isPowerSaveMode()) { + if (DEBUG) Slog.i(TAG, "Deferring scheduled full backups in battery saver mode"); + FullBackupJob.schedule(mContext, KeyValueBackupJob.BATCH_INTERVAL); + return false; + } + if (DEBUG_SCHEDULING) { Slog.i(TAG, "Beginning scheduled full backup operation"); } @@ -8515,18 +8525,23 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF public void backupNow() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, "backupNow"); - if (DEBUG) Slog.v(TAG, "Scheduling immediate backup pass"); - synchronized (mQueueLock) { - // Fire the intent that kicks off the whole shebang... - try { - mRunBackupIntent.send(); - } catch (PendingIntent.CanceledException e) { - // should never happen - Slog.e(TAG, "run-backup intent cancelled!"); - } + if (mPowerManager.isPowerSaveMode()) { + if (DEBUG) Slog.v(TAG, "Not running backup while in battery save mode"); + KeyValueBackupJob.schedule(mContext); // try again in several hours + } else { + if (DEBUG) Slog.v(TAG, "Scheduling immediate backup pass"); + synchronized (mQueueLock) { + // Fire the intent that kicks off the whole shebang... + try { + mRunBackupIntent.send(); + } catch (PendingIntent.CanceledException e) { + // should never happen + Slog.e(TAG, "run-backup intent cancelled!"); + } - // ...and cancel any pending scheduled job, because we've just superseded it - KeyValueBackupJob.cancel(mContext); + // ...and cancel any pending scheduled job, because we've just superseded it + KeyValueBackupJob.cancel(mContext); + } } } |