JobSchedulerInternal.java revision d117b293aec3fc2de0f6508cb8975af4dbd6a6a3
1/* 2 * Copyright (C) 2016 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 17package com.android.server.job; 18 19import android.app.job.JobInfo; 20 21import java.util.List; 22 23/** 24 * JobScheduler local system service interface. 25 * {@hide} Only for use within the system server. 26 */ 27public interface JobSchedulerInternal { 28 29 // Bookkeeping about app standby bucket scheduling 30 31 /** 32 * The current bucket heartbeat ordinal 33 */ 34 long currentHeartbeat(); 35 36 /** 37 * Heartbeat ordinal at which the given standby bucket's jobs next become runnable 38 */ 39 long nextHeartbeatForBucket(int bucket); 40 41 /** 42 * Returns a list of pending jobs scheduled by the system service. 43 */ 44 List<JobInfo> getSystemScheduledPendingJobs(); 45 46 /** 47 * Cancel the jobs for a given uid (e.g. when app data is cleared) 48 */ 49 void cancelJobsForUid(int uid, String reason); 50 51 /** 52 * These are for activity manager to communicate to use what is currently performing backups. 53 */ 54 void addBackingUpUid(int uid); 55 void removeBackingUpUid(int uid); 56 void clearAllBackingUpUids(); 57 58 /** 59 * The user has started interacting with the app. Take any appropriate action. 60 */ 61 void reportAppUsage(String packageName, int userId); 62 63 /** 64 * Report a snapshot of sync-related jobs back to the sync manager 65 */ 66 JobStorePersistStats getPersistStats(); 67 68 /** 69 * Stats about the first load after boot and the most recent save. 70 * STOPSHIP Remove it and the relevant code once b/64536115 is fixed. 71 */ 72 public class JobStorePersistStats { 73 public int countAllJobsLoaded = -1; 74 public int countSystemServerJobsLoaded = -1; 75 public int countSystemSyncManagerJobsLoaded = -1; 76 77 public int countAllJobsSaved = -1; 78 public int countSystemServerJobsSaved = -1; 79 public int countSystemSyncManagerJobsSaved = -1; 80 81 public JobStorePersistStats() { 82 } 83 84 public JobStorePersistStats(JobStorePersistStats source) { 85 countAllJobsLoaded = source.countAllJobsLoaded; 86 countSystemServerJobsLoaded = source.countSystemServerJobsLoaded; 87 countSystemSyncManagerJobsLoaded = source.countSystemSyncManagerJobsLoaded; 88 89 countAllJobsSaved = source.countAllJobsSaved; 90 countSystemServerJobsSaved = source.countSystemServerJobsSaved; 91 countSystemSyncManagerJobsSaved = source.countSystemSyncManagerJobsSaved; 92 } 93 94 @Override 95 public String toString() { 96 return "FirstLoad: " 97 + countAllJobsLoaded + "/" 98 + countSystemServerJobsLoaded + "/" 99 + countSystemSyncManagerJobsLoaded 100 + " LastSave: " 101 + countAllJobsSaved + "/" 102 + countSystemServerJobsSaved + "/" 103 + countSystemSyncManagerJobsSaved; 104 } 105 } 106} 107