1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.server.job; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.net.Network; 22 import android.util.ArraySet; 23 24 import com.android.server.job.controllers.JobStatus; 25 import com.android.server.job.restrictions.JobRestriction; 26 27 import java.util.List; 28 29 /** 30 * Interface through which a {@link com.android.server.job.controllers.StateController} informs 31 * the {@link com.android.server.job.JobSchedulerService} that there are some tasks potentially 32 * ready to be run. 33 */ 34 public interface StateChangedListener { 35 /** 36 * Called by the controller to notify the JobScheduler that it should check on the state of a 37 * set of jobs. If {@code changedJobs} is null, then all registered jobs will be evaluated. 38 */ onControllerStateChanged(@ullable ArraySet<JobStatus> changedJobs)39 void onControllerStateChanged(@Nullable ArraySet<JobStatus> changedJobs); 40 41 /** 42 * Called by a {@link com.android.server.job.restrictions.JobRestriction} to notify the 43 * JobScheduler that it should check on the state of all jobs. 44 * 45 * @param stopOvertimeJobs Whether to stop any jobs that have run for more than their minimum 46 * execution guarantee and are restricted by the changed restriction 47 */ onRestrictionStateChanged(@onNull JobRestriction restriction, boolean stopOvertimeJobs)48 void onRestrictionStateChanged(@NonNull JobRestriction restriction, 49 boolean stopOvertimeJobs); 50 51 /** 52 * Called by the controller to notify the JobManager that regardless of the state of the task, 53 * it must be run immediately. 54 * @param jobStatus The state of the task which is to be run immediately. <strong>null 55 * indicates to the scheduler that any ready jobs should be flushed.</strong> 56 */ onRunJobNow(JobStatus jobStatus)57 public void onRunJobNow(JobStatus jobStatus); 58 onDeviceIdleStateChanged(boolean deviceIdle)59 public void onDeviceIdleStateChanged(boolean deviceIdle); 60 onNetworkChanged(JobStatus jobStatus, Network newNetwork)61 void onNetworkChanged(JobStatus jobStatus, Network newNetwork); 62 63 /** 64 * Called when these jobs are added or removed from the 65 * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket. 66 */ onRestrictedBucketChanged(@onNull List<JobStatus> jobs)67 void onRestrictedBucketChanged(@NonNull List<JobStatus> jobs); 68 } 69