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

Commit 97db0e2b authored by Xin Guan's avatar Xin Guan Committed by Android (Google) Code Review
Browse files

Merge "JobScheduler: Fix FlexibilityControllerTest test failures" into main

parents 8a6649fa dee0f3ba
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1426,9 +1426,6 @@ public final class JobStatus {
     * @return true if the exemption status changed
     */
    public boolean updateMediaBackupExemptionStatus() {
        if (mJobSchedulerInternal == null) {
            mJobSchedulerInternal = LocalServices.getService(JobSchedulerInternal.class);
        }
        final boolean hasMediaExemption = hasMediaBackupExemption();
        if (mHasMediaBackupExemption == hasMediaExemption) {
            return false;
@@ -2567,6 +2564,10 @@ public final class JobStatus {
    }

    private boolean hasMediaBackupExemption() {
        if (mJobSchedulerInternal == null) {
            mJobSchedulerInternal = LocalServices.getService(JobSchedulerInternal.class);
        }

        // Check the legacy policy first.
        if (mHasExemptedMediaUrisOnly
                && !job.hasLateConstraint()
+5 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ import android.util.SparseArray;
import com.android.server.AppSchedulingModuleThread;
import com.android.server.DeviceIdleInternal;
import com.android.server.LocalServices;
import com.android.server.job.JobSchedulerInternal;
import com.android.server.job.JobSchedulerService;
import com.android.server.job.JobStore;

@@ -196,6 +197,10 @@ public class FlexibilityControllerTest {
        doReturn(mJobStore).when(mJobSchedulerService).getJobStore();
        // Used in JobStatus.
        doReturn(mIPackageManager).when(AppGlobals::getPackageManager);
        // Used in JobStatus.
        doReturn(mock(JobSchedulerInternal.class))
                .when(() -> LocalServices.getService(JobSchedulerInternal.class));

        // Freeze the clocks at a moment in time
        JobSchedulerService.sSystemClock =
                Clock.fixed(Instant.ofEpochMilli(FROZEN_TIME), ZoneOffset.UTC);