Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97c699e2 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Don't run backups in battery-saver mode" into mnc-dev

parents 74f3d396 ad8a9623
Loading
Loading
Loading
Loading
+26 −11
Original line number Original line Diff line number Diff line
@@ -4411,6 +4411,8 @@ public class BackupManagerService {
     * to perform one app backup per scheduled job execution, and to reschedule the job
     * 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.
     * 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
     * @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.
     *         along as the return value to the scheduled job's onStartJob() callback.
     */
     */
@@ -4430,6 +4432,14 @@ public class BackupManagerService {
            return false;
            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) {
        if (DEBUG_SCHEDULING) {
            Slog.i(TAG, "Beginning scheduled full backup operation");
            Slog.i(TAG, "Beginning scheduled full backup operation");
        }
        }
@@ -8515,6 +8525,10 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
    public void backupNow() {
    public void backupNow() {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, "backupNow");
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, "backupNow");


        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");
            if (DEBUG) Slog.v(TAG, "Scheduling immediate backup pass");
            synchronized (mQueueLock) {
            synchronized (mQueueLock) {
                // Fire the intent that kicks off the whole shebang...
                // Fire the intent that kicks off the whole shebang...
@@ -8529,6 +8543,7 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
                KeyValueBackupJob.cancel(mContext);
                KeyValueBackupJob.cancel(mContext);
            }
            }
        }
        }
    }


    boolean deviceIsProvisioned() {
    boolean deviceIsProvisioned() {
        final ContentResolver resolver = mContext.getContentResolver();
        final ContentResolver resolver = mContext.getContentResolver();