diff options
| author | Amith Yamasani <yamasani@google.com> | 2017-11-23 00:00:23 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-11-23 00:00:23 +0000 |
| commit | 5719bceb4eae5c51f50630623bf83febfc9b39ab (patch) | |
| tree | 53f2148faf112a181e606f855a9a16dd16c87e52 /core/java/android | |
| parent | 6f813c6a98151fe7370619c9456fbfb265f6af68 (diff) | |
| parent | a732f014c5743af0dbb7eb2e63474a7147576f9d (diff) | |
Merge "The job scheduler now backs off jobs based on standby bucketing"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/job/JobService.java | 54 | ||||
| -rw-r--r-- | core/java/android/app/usage/UsageStatsManagerInternal.java | 14 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageManagerInternal.java | 8 |
3 files changed, 49 insertions, 27 deletions
diff --git a/core/java/android/app/job/JobService.java b/core/java/android/app/job/JobService.java index 69afed205de1..61afadab9b0c 100644 --- a/core/java/android/app/job/JobService.java +++ b/core/java/android/app/job/JobService.java @@ -72,6 +72,33 @@ public abstract class JobService extends Service { } /** + * Call this to inform the JobScheduler that the job has finished its work. When the + * system receives this message, it releases the wakelock being held for the job. + * <p> + * You can request that the job be scheduled again by passing {@code true} as + * the <code>wantsReschedule</code> parameter. This will apply back-off policy + * for the job; this policy can be adjusted through the + * {@link android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)} method + * when the job is originally scheduled. The job's initial + * requirements are preserved when jobs are rescheduled, regardless of backed-off + * policy. + * <p class="note"> + * A job running while the device is dozing will not be rescheduled with the normal back-off + * policy. Instead, the job will be re-added to the queue and executed again during + * a future idle maintenance window. + * </p> + * + * @param params The parameters identifying this job, as supplied to + * the job in the {@link #onStartJob(JobParameters)} callback. + * @param wantsReschedule {@code true} if this job should be rescheduled according + * to the back-off criteria specified when it was first scheduled; {@code false} + * otherwise. + */ + public final void jobFinished(JobParameters params, boolean wantsReschedule) { + mEngine.jobFinished(params, wantsReschedule); + } + + /** * Called to indicate that the job has begun executing. Override this method with the * logic for your job. Like all other component lifecycle callbacks, this method executes * on your application's main thread. @@ -127,31 +154,4 @@ public abstract class JobService extends Service { * to end the job entirely. Regardless of the value returned, your job must stop executing. */ public abstract boolean onStopJob(JobParameters params); - - /** - * Call this to inform the JobScheduler that the job has finished its work. When the - * system receives this message, it releases the wakelock being held for the job. - * <p> - * You can request that the job be scheduled again by passing {@code true} as - * the <code>wantsReschedule</code> parameter. This will apply back-off policy - * for the job; this policy can be adjusted through the - * {@link android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)} method - * when the job is originally scheduled. The job's initial - * requirements are preserved when jobs are rescheduled, regardless of backed-off - * policy. - * <p class="note"> - * A job running while the device is dozing will not be rescheduled with the normal back-off - * policy. Instead, the job will be re-added to the queue and executed again during - * a future idle maintenance window. - * </p> - * - * @param params The parameters identifying this job, as supplied to - * the job in the {@link #onStartJob(JobParameters)} callback. - * @param wantsReschedule {@code true} if this job should be rescheduled according - * to the back-off criteria specified when it was first scheduled; {@code false} - * otherwise. - */ - public final void jobFinished(JobParameters params, boolean wantsReschedule) { - mEngine.jobFinished(params, wantsReschedule); - } } diff --git a/core/java/android/app/usage/UsageStatsManagerInternal.java b/core/java/android/app/usage/UsageStatsManagerInternal.java index 29e7439f69e2..9954484f2bb0 100644 --- a/core/java/android/app/usage/UsageStatsManagerInternal.java +++ b/core/java/android/app/usage/UsageStatsManagerInternal.java @@ -16,6 +16,7 @@ package android.app.usage; +import android.app.usage.AppStandby.StandbyBuckets; import android.content.ComponentName; import android.content.res.Configuration; @@ -91,6 +92,19 @@ public abstract class UsageStatsManagerInternal { public abstract boolean isAppIdle(String packageName, int uidForAppId, int userId); /** + * Returns the app standby bucket that the app is currently in. This accessor does + * <em>not</em> obfuscate instant apps. + * + * @param packageName + * @param userId + * @param nowElapsed The current time, in the elapsedRealtime time base + * @return the AppStandby bucket code the app currently resides in. If the app is + * unknown in the given user, STANDBY_BUCKET_NEVER is returned. + */ + @StandbyBuckets public abstract int getAppStandbyBucket(String packageName, int userId, + long nowElapsed); + + /** * Returns all of the uids for a given user where all packages associating with that uid * are in the app idle state -- there are no associated apps that are not idle. This means * all of the returned uids can be safely considered app idle. diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java index 14cf8557477b..713cd109ef87 100644 --- a/core/java/android/content/pm/PackageManagerInternal.java +++ b/core/java/android/content/pm/PackageManagerInternal.java @@ -164,6 +164,14 @@ public abstract class PackageManagerInternal { @PackageInfoFlags int flags, int filterCallingUid, int userId); /** + * Do a straight uid lookup for the given package/application in the given user. + * @see PackageManager#getPackageUidAsUser(String, int, int) + * @return The app's uid, or < 0 if the package was not found in that user + */ + public abstract int getPackageUid(String packageName, + @PackageInfoFlags int flags, int userId); + + /** * Retrieve all of the information we know about a particular package/application. * @param filterCallingUid The results will be filtered in the context of this UID instead * of the calling UID. |
