diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-06-22 19:37:29 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-22 19:37:29 +0000 |
commit | b7ed6f24cc051391b44ba58d24508905a462cd7f (patch) | |
tree | 5241820c837ea3c8f31f19ba31a965af74af11b8 | |
parent | 6a8a12844b98749aa98fc8fa233215a9f77a105b (diff) | |
parent | 07c50f1e60407083113bacf7c39b8bda67523b2b (diff) | |
download | android_packages_providers_DownloadProvider-b7ed6f24cc051391b44ba58d24508905a462cd7f.tar.gz android_packages_providers_DownloadProvider-b7ed6f24cc051391b44ba58d24508905a462cd7f.tar.bz2 android_packages_providers_DownloadProvider-b7ed6f24cc051391b44ba58d24508905a462cd7f.zip |
Update notifications when no jobs are scheduled.
am: 07c50f1e60
Change-Id: I8a9193df9643922020d25139447da3951643b8ba
-rw-r--r-- | src/com/android/providers/downloads/Helpers.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java index d43e1022..e9549052 100644 --- a/src/com/android/providers/downloads/Helpers.java +++ b/src/com/android/providers/downloads/Helpers.java @@ -112,15 +112,21 @@ public class Helpers { } public static void scheduleJob(Context context, long downloadId) { - scheduleJob(context, DownloadInfo.queryDownloadInfo(context, downloadId)); + final boolean scheduled = scheduleJob(context, + DownloadInfo.queryDownloadInfo(context, downloadId)); + if (!scheduled) { + // If we didn't schedule a future job, kick off a notification + // update pass immediately + getDownloadNotifier(context).update(); + } } /** * Schedule (or reschedule) a job for the given {@link DownloadInfo} using * its current state to define job constraints. */ - public static void scheduleJob(Context context, DownloadInfo info) { - if (info == null) return; + public static boolean scheduleJob(Context context, DownloadInfo info) { + if (info == null) return false; final JobScheduler scheduler = context.getSystemService(JobScheduler.class); @@ -129,7 +135,7 @@ public class Helpers { scheduler.cancel(jobId); // Skip scheduling if download is paused or finished - if (!info.isReadyToSchedule()) return; + if (!info.isReadyToSchedule()) return false; final JobInfo.Builder builder = new JobInfo.Builder(jobId, new ComponentName(context, DownloadJobService.class)); @@ -166,6 +172,7 @@ public class Helpers { } scheduler.scheduleAsPackage(builder.build(), packageName, UserHandle.myUserId(), TAG); + return true; } /* |