From ca02f078246f6d2b2113da5a589e05f6eb9f8a63 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Mon, 25 Apr 2022 18:00:28 +0000 Subject: [PATCH] Remove wtf. There is currently a legitimate reason why the "unexpected" case could happen. Since we don't want to rewrite too much code right now, remove the wtf and comment on the code flow. Bug: 228334264 Test: N/A Change-Id: I10117888f9984ef725beab6f8f3747ee4bdf53ff --- .../java/com/android/server/job/JobSchedulerService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java index 9e131339595fd..358c32722b8b8 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -1749,8 +1749,13 @@ public class JobSchedulerService extends com.android.server.SystemService if (!removed) { // We never create JobStatus objects for the express purpose of removing them, and this // method is only ever called for jobs that were saved in the JobStore at some point, - // so if we can't find it, something went seriously wrong. - Slog.wtfStack(TAG, "Job didn't exist in JobStore"); + // so if we can't find it, something may be wrong. As of Android T, there is a + // legitimate code path where removed is false --- when an actively running job is + // cancelled (eg. via JobScheduler.cancel() or the app scheduling a new job with the + // same job ID), we remove it from the JobStore and tell the JobServiceContext to stop + // running the job. Once the job stops running, we then call this method again. + // TODO: rework code so we don't intentionally call this method twice for the same job + Slog.w(TAG, "Job didn't exist in JobStore"); } if (mReadyToRock) { for (int i = 0; i < mControllers.size(); i++) {