Fix issue #63095854: adb shell cmd jobscheduler timeout reports...
..."No matching executing jobs found"
We were not noticing that we actually stopped some jobs.
Also print a message about which jobs we stop, and fix recording
of why a job stopped for this case.
Test: bit CtsJobSchedulerTestCases:*
Change-Id: I178ad2119af4c3187d8c9d4d07a7277bc8a49905
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 98c65fd..3fea51f 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -2052,7 +2052,15 @@
synchronized (mLock) {
boolean foundSome = false;
for (int i=0; i<mActiveServices.size(); i++) {
- mActiveServices.get(i).timeoutIfExecutingLocked(pkgName, userId, hasJobId, jobId);
+ final JobServiceContext jc = mActiveServices.get(i);
+ final JobStatus js = jc.getRunningJobLocked();
+ if (jc.timeoutIfExecutingLocked(pkgName, userId, hasJobId, jobId)) {
+ foundSome = true;
+ pw.print("Timing out: ");
+ js.printUniqueId(pw);
+ pw.print(" ");
+ pw.println(js.getServiceComponent().flattenToShortString());
+ }
}
if (!foundSome) {
pw.println("No matching executing jobs found.");
diff --git a/services/core/java/com/android/server/job/JobServiceContext.java b/services/core/java/com/android/server/job/JobServiceContext.java
index a0dfd4d..a34e251 100644
--- a/services/core/java/com/android/server/job/JobServiceContext.java
+++ b/services/core/java/com/android/server/job/JobServiceContext.java
@@ -681,6 +681,7 @@
return;
}
try {
+ applyStoppedReasonLocked(reason);
mVerb = VERB_STOPPING;
scheduleOpTimeOutLocked();
service.stopJob(mParams);