Loading core/java/android/app/JobSchedulerImpl.java +9 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ public class JobSchedulerImpl extends JobScheduler { } } @Override public int scheduleAsPackage(JobInfo job, String packageName, int userId) { try { return mBinder.scheduleAsPackage(job, packageName, userId); } catch (RemoteException e) { return JobScheduler.RESULT_FAILURE; } } @Override public void cancel(int jobId) { try { Loading core/java/android/app/job/IJobScheduler.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.job.JobInfo; */ interface IJobScheduler { int schedule(in JobInfo job); int scheduleAsPackage(in JobInfo job, String packageName, int userId); void cancel(int jobId); void cancelAll(); List<JobInfo> getAllPendingJobs(); Loading core/java/android/app/job/JobScheduler.java +11 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,17 @@ public abstract class JobScheduler { */ public abstract int schedule(JobInfo job); /** * * @param job The job to be scheduled. * @param packageName The package on behalf of which the job is to be scheduled. This will be * used to track battery usage and appIdleState. * @param userId User on behalf of whom this job is to be scheduled. * @return {@link #RESULT_SUCCESS} or {@link #RESULT_FAILURE} * @hide */ public abstract int scheduleAsPackage(JobInfo job, String packageName, int userId); /** * Cancel a job that is pending in the JobScheduler. * @param jobId unique identifier for this job. Obtain this value from the jobs returned by Loading services/core/java/com/android/server/job/JobSchedulerService.java +27 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.Process; import android.util.ArraySet; import android.util.Slog; import android.util.SparseArray; Loading Loading @@ -220,7 +221,14 @@ public class JobSchedulerService extends com.android.server.SystemService * @return Result of this operation. See <code>JobScheduler#RESULT_*</code> return codes. */ public int schedule(JobInfo job, int uId) { return scheduleAsPackage(job, uId, null, -1); } public int scheduleAsPackage(JobInfo job, int uId, String packageName, int userId) { JobStatus jobStatus = new JobStatus(job, uId); if (packageName != null) { jobStatus.setSource(packageName, userId); } cancelJob(uId, job.getId()); try { if (ActivityManagerNative.getDefault().getAppStartMode(uId, Loading Loading @@ -1040,6 +1048,25 @@ public class JobSchedulerService extends com.android.server.SystemService } } @Override public int scheduleAsPackage(JobInfo job, String packageName, int userId) throws RemoteException { if (DEBUG) { Slog.d(TAG, "Scheduling job: " + job.toString() + " on behalf of " + packageName); } final int uid = Binder.getCallingUid(); if (uid != Process.SYSTEM_UID) { throw new IllegalArgumentException("Only system process is allowed" + "to set packageName"); } long ident = Binder.clearCallingIdentity(); try { return JobSchedulerService.this.scheduleAsPackage(job, uid, packageName, userId); } finally { Binder.restoreCallingIdentity(ident); } } @Override public List<JobInfo> getAllPendingJobs() throws RemoteException { final int uid = Binder.getCallingUid(); Loading services/core/java/com/android/server/job/JobServiceContext.java +3 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Binder; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -190,7 +191,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne return false; } try { mBatteryStats.noteJobStart(job.getName(), job.getUid()); mBatteryStats.noteJobStart(job.getName(), job.getSourceUid()); } catch (RemoteException e) { // Whatever. } Loading Loading @@ -566,7 +567,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne } completedJob = mRunningJob; try { mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getUid()); mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getSourceUid()); } catch (RemoteException e) { // Whatever. } Loading Loading
core/java/android/app/JobSchedulerImpl.java +9 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ public class JobSchedulerImpl extends JobScheduler { } } @Override public int scheduleAsPackage(JobInfo job, String packageName, int userId) { try { return mBinder.scheduleAsPackage(job, packageName, userId); } catch (RemoteException e) { return JobScheduler.RESULT_FAILURE; } } @Override public void cancel(int jobId) { try { Loading
core/java/android/app/job/IJobScheduler.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.job.JobInfo; */ interface IJobScheduler { int schedule(in JobInfo job); int scheduleAsPackage(in JobInfo job, String packageName, int userId); void cancel(int jobId); void cancelAll(); List<JobInfo> getAllPendingJobs(); Loading
core/java/android/app/job/JobScheduler.java +11 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,17 @@ public abstract class JobScheduler { */ public abstract int schedule(JobInfo job); /** * * @param job The job to be scheduled. * @param packageName The package on behalf of which the job is to be scheduled. This will be * used to track battery usage and appIdleState. * @param userId User on behalf of whom this job is to be scheduled. * @return {@link #RESULT_SUCCESS} or {@link #RESULT_FAILURE} * @hide */ public abstract int scheduleAsPackage(JobInfo job, String packageName, int userId); /** * Cancel a job that is pending in the JobScheduler. * @param jobId unique identifier for this job. Obtain this value from the jobs returned by Loading
services/core/java/com/android/server/job/JobSchedulerService.java +27 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.Process; import android.util.ArraySet; import android.util.Slog; import android.util.SparseArray; Loading Loading @@ -220,7 +221,14 @@ public class JobSchedulerService extends com.android.server.SystemService * @return Result of this operation. See <code>JobScheduler#RESULT_*</code> return codes. */ public int schedule(JobInfo job, int uId) { return scheduleAsPackage(job, uId, null, -1); } public int scheduleAsPackage(JobInfo job, int uId, String packageName, int userId) { JobStatus jobStatus = new JobStatus(job, uId); if (packageName != null) { jobStatus.setSource(packageName, userId); } cancelJob(uId, job.getId()); try { if (ActivityManagerNative.getDefault().getAppStartMode(uId, Loading Loading @@ -1040,6 +1048,25 @@ public class JobSchedulerService extends com.android.server.SystemService } } @Override public int scheduleAsPackage(JobInfo job, String packageName, int userId) throws RemoteException { if (DEBUG) { Slog.d(TAG, "Scheduling job: " + job.toString() + " on behalf of " + packageName); } final int uid = Binder.getCallingUid(); if (uid != Process.SYSTEM_UID) { throw new IllegalArgumentException("Only system process is allowed" + "to set packageName"); } long ident = Binder.clearCallingIdentity(); try { return JobSchedulerService.this.scheduleAsPackage(job, uid, packageName, userId); } finally { Binder.restoreCallingIdentity(ident); } } @Override public List<JobInfo> getAllPendingJobs() throws RemoteException { final int uid = Binder.getCallingUid(); Loading
services/core/java/com/android/server/job/JobServiceContext.java +3 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Binder; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -190,7 +191,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne return false; } try { mBatteryStats.noteJobStart(job.getName(), job.getUid()); mBatteryStats.noteJobStart(job.getName(), job.getSourceUid()); } catch (RemoteException e) { // Whatever. } Loading Loading @@ -566,7 +567,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne } completedJob = mRunningJob; try { mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getUid()); mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getSourceUid()); } catch (RemoteException e) { // Whatever. } Loading