From 7118bf929a97e202df9e32e288dc6ddd468aad74 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Tue, 6 Dec 2022 22:07:32 +0000 Subject: [PATCH] Pass JobParameters into JobService APIs. The JobParameters are needed for apps to differentiate between running jobs and must be passed into all JobService APIs. Bug: 255371817 Test: Android builds Change-Id: I15469609c0b96292b3d66335070c11e60b5015ec --- .../java/android/app/job/JobService.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apex/jobscheduler/framework/java/android/app/job/JobService.java b/apex/jobscheduler/framework/java/android/app/job/JobService.java index bad641cf8bf63..00a61a2fe17da 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobService.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobService.java @@ -84,9 +84,9 @@ public abstract class JobService extends Service { public long getTransferredDownloadBytes(@NonNull JobParameters params, @Nullable JobWorkItem item) { if (item == null) { - return JobService.this.getTransferredDownloadBytes(); + return JobService.this.getTransferredDownloadBytes(params); } else { - return JobService.this.getTransferredDownloadBytes(item); + return JobService.this.getTransferredDownloadBytes(params, item); } } @@ -95,9 +95,9 @@ public abstract class JobService extends Service { public long getTransferredUploadBytes(@NonNull JobParameters params, @Nullable JobWorkItem item) { if (item == null) { - return JobService.this.getTransferredUploadBytes(); + return JobService.this.getTransferredUploadBytes(params); } else { - return JobService.this.getTransferredUploadBytes(item); + return JobService.this.getTransferredUploadBytes(params, item); } } }; @@ -274,7 +274,7 @@ public abstract class JobService extends Service { */ // TODO(255371817): specify the actual time JS will wait for progress before requesting @BytesLong - public long getTransferredDownloadBytes() { + public long getTransferredDownloadBytes(@NonNull JobParameters params) { if (Compatibility.isChangeEnabled(THROW_ON_INVALID_DATA_TRANSFER_IMPLEMENTATION)) { // Regular jobs don't have to implement this and JobScheduler won't call this API for // non-data transfer jobs. @@ -298,7 +298,7 @@ public abstract class JobService extends Service { */ // TODO(255371817): specify the actual time JS will wait for progress before requesting @BytesLong - public long getTransferredUploadBytes() { + public long getTransferredUploadBytes(@NonNull JobParameters params) { if (Compatibility.isChangeEnabled(THROW_ON_INVALID_DATA_TRANSFER_IMPLEMENTATION)) { // Regular jobs don't have to implement this and JobScheduler won't call this API for // non-data transfer jobs. @@ -324,9 +324,10 @@ public abstract class JobService extends Service { */ // TODO(255371817): specify the actual time JS will wait for progress before requesting @BytesLong - public long getTransferredDownloadBytes(@NonNull JobWorkItem item) { + public long getTransferredDownloadBytes(@NonNull JobParameters params, + @NonNull JobWorkItem item) { if (item == null) { - return getTransferredDownloadBytes(); + return getTransferredDownloadBytes(params); } if (Compatibility.isChangeEnabled(THROW_ON_INVALID_DATA_TRANSFER_IMPLEMENTATION)) { // Regular jobs don't have to implement this and JobScheduler won't call this API for @@ -353,9 +354,10 @@ public abstract class JobService extends Service { */ // TODO(255371817): specify the actual time JS will wait for progress before requesting @BytesLong - public long getTransferredUploadBytes(@NonNull JobWorkItem item) { + public long getTransferredUploadBytes(@NonNull JobParameters params, + @NonNull JobWorkItem item) { if (item == null) { - return getTransferredUploadBytes(); + return getTransferredUploadBytes(params); } if (Compatibility.isChangeEnabled(THROW_ON_INVALID_DATA_TRANSFER_IMPLEMENTATION)) { // Regular jobs don't have to implement this and JobScheduler won't call this API for