Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 570de574 authored by Xin Guan's avatar Xin Guan
Browse files

JobScheduler: Fix reporting the active job status.

Correctly update the job running list and pending queue before
JS reports the active jobs status so that system can track the
correct idle state.

Bug: 425761099
Test: atest CtsJobSchedulerTestCases
Test: atest FrameworksMockingServicesTests:com.android.server.job
Flag: com.android.server.job.fix_reporting_active_jobs
Change-Id: I39d32dbc6a3bef67fdcf6b79f2fa568260385e1c
parent 0fdbdb2b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -127,3 +127,12 @@ flag {
    }
}

flag {
    name: "fix_reporting_active_jobs"
    namespace: "backstage_power"
    description: "Correctly report the active jobs to idle controller"
    bug: "425761099"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+10 −3
Original line number Diff line number Diff line
@@ -1789,10 +1789,17 @@ public final class JobServiceContext implements ServiceConnection {
        if (completedJob.isUserVisibleJob()) {
            mService.informObserversOfUserVisibleJobChange(this, completedJob, false);
        }

        if (Flags.fixReportingActiveJobs()) {
            mJobConcurrencyManager.onJobCompletedLocked(this, completedJob, workType);
            mCompletedListener.onJobCompletedLocked(completedJob,
                    reschedulingStopReason, reschedulingInternalStopReason, reschedule);
        } else {
            mCompletedListener.onJobCompletedLocked(completedJob,
                    reschedulingStopReason, reschedulingInternalStopReason, reschedule);
            mJobConcurrencyManager.onJobCompletedLocked(this, completedJob, workType);
        }
    }

    private void applyStoppedReasonLocked(@Nullable String reason) {
        if (reason != null && mStoppedReason == null) {