Treat ANR as an app failure.

Treat an ANR stop as an app failure and back off immediately when that
happens.

Bug: 258236856
Bug: 282784507
Test: atest FrameworksMockingServicesTests:JobSchedulerServiceTest
Change-Id: I3feab21e74d55c4a2940e3ef2ca10175295970a3
This commit is contained in:
Kweku Adams
2023-05-16 19:31:14 +00:00
parent 11cd46966d
commit 6b4693ffa4
2 changed files with 8 additions and 0 deletions

View File

@@ -2595,6 +2595,7 @@ public class JobSchedulerService extends com.android.server.SystemService
// or the user stopped the job somehow.
if (internalStopReason == JobParameters.INTERNAL_STOP_REASON_SUCCESSFUL_FINISH
|| internalStopReason == JobParameters.INTERNAL_STOP_REASON_TIMEOUT
|| internalStopReason == JobParameters.INTERNAL_STOP_REASON_ANR
|| stopReason == JobParameters.STOP_REASON_USER) {
numFailures++;
} else {

View File

@@ -438,6 +438,13 @@ public class JobSchedulerServiceTest {
JobParameters.INTERNAL_STOP_REASON_SUCCESSFUL_FINISH);
assertEquals(nowElapsed + 4 * initialBackoffMs, rescheduledJob.getEarliestRunTime());
assertEquals(JobStatus.NO_LATEST_RUNTIME, rescheduledJob.getLatestRunTimeElapsed());
// failure = 3, systemStop = 2 * SYSTEM_STOP_TO_FAILURE_RATIO
rescheduledJob = mService.getRescheduleJobForFailureLocked(rescheduledJob,
JobParameters.STOP_REASON_UNDEFINED,
JobParameters.INTERNAL_STOP_REASON_ANR);
assertEquals(nowElapsed + 5 * initialBackoffMs, rescheduledJob.getEarliestRunTime());
assertEquals(JobStatus.NO_LATEST_RUNTIME, rescheduledJob.getLatestRunTimeElapsed());
}
/**