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

Commit 4b111442 authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am 8ac64af6: am 9cd88b91: am 7c98ecd3: Schedule full backups

* commit '8ac64af6236b03e0af6ee95bd579612a6d1ef4d4':
  Schedule full backups
parents e468f299 083bdc68
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3023,6 +3023,11 @@
                 android:permission="android.permission.BIND_JOB_SERVICE" >
        </service>

        <service android:name="com.android.server.backup.FullBackupJob"
                 android:exported="true"
                 android:permission="android.permission.BIND_JOB_SERVICE" >
        </service>

        <service
            android:name="com.android.server.pm.BackgroundDexOptService"
            android:exported="true"
+456 −94

File changed.

Preview size limit exceeded, changes collapsed.

+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.backup;

import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.app.job.JobInfo.NetworkType;
import android.content.ComponentName;
import android.content.Context;
import android.util.Slog;

public class FullBackupJob extends JobService {
    private static final String TAG = "FullBackupJob";
    private static final boolean DEBUG = true;

    private static ComponentName sIdleService =
            new ComponentName("android", FullBackupJob.class.getName());

    private static final int JOB_ID = 0x5038;

    JobParameters mParams;

    public static void schedule(Context ctx, long minDelay) {
        JobScheduler js = (JobScheduler) ctx.getSystemService(Context.JOB_SCHEDULER_SERVICE);
        JobInfo.Builder builder = new JobInfo.Builder(JOB_ID, sIdleService)
                .setRequiresDeviceIdle(true)
                .setRequiredNetworkCapabilities(NetworkType.UNMETERED)
                .setRequiresCharging(true);
        if (minDelay > 0) {
            builder.setMinimumLatency(minDelay);
        }
        js.schedule(builder.build());
    }

    // callback from the Backup Manager Service: it's finished its work for this pass
    public void finishBackupPass() {
        if (mParams != null) {
            jobFinished(mParams, false);
            mParams = null;
        }
    }

    // ----- scheduled job interface -----

    @Override
    public boolean onStartJob(JobParameters params) {
        mParams = params;
        BackupManagerService service = BackupManagerService.getInstance();
        return service.beginFullBackup(this);
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        if (mParams != null) {
            mParams = null;
            BackupManagerService service = BackupManagerService.getInstance();
            service.endFullBackup();
        }
        return false;
    }

}
+11 −1
Original line number Diff line number Diff line
@@ -184,6 +184,16 @@ public class IdleController extends StateController {

    @Override
    public void dumpControllerState(PrintWriter pw) {

        synchronized (mTrackedTasks) {
            pw.print("Idle: ");
            pw.println(mIdleTracker.isIdle() ? "true" : "false");
            pw.println(mTrackedTasks.size());
            for (int i = 0; i < mTrackedTasks.size(); i++) {
                final JobStatus js = mTrackedTasks.get(i);
                pw.print("  ");
                pw.print(String.valueOf(js.hashCode()).substring(0, 3));
                pw.println("..");
            }
        }
    }
}