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

Commit 8a02c970 authored by Kweku Adams's avatar Kweku Adams
Browse files

Don't stop jobs on benign network change.

Don't stop jobs immediately just because the default network changed,
especially if the network hasn't been fully set up yet.

Bug: 266286305
Test: atest CtsJobSchedulerTestCases:ConnectivityConstraintTest
Change-Id: Ia222195df4a8d5c023d1c5e93a52ffe6c9f00c2e
parent b14850bd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1129,6 +1129,22 @@ public final class ConnectivityController extends RestrictingController implemen

        final boolean satisfied = isSatisfied(jobStatus, network, capabilities, mConstants);

        if (!satisfied && jobStatus.network != null
                && mService.isCurrentlyRunningLocked(jobStatus)
                && isSatisfied(jobStatus, jobStatus.network,
                        getNetworkCapabilities(jobStatus.network), mConstants)) {
            // A new network became available for a currently running job
            // (and most likely became the default network for the app),
            // but it doesn't yet satisfy the requested constraints and the old network
            // is still available and satisfies the constraints. Don't change the network
            // given to the job for now and let it keep running. We will re-evaluate when
            // the capabilities or connection state of the either network change.
            if (DEBUG) {
                Slog.i(TAG, "Not reassigning network for running job " + jobStatus);
            }
            return false;
        }

        final boolean changed = jobStatus.setConnectivityConstraintSatisfied(nowElapsed, satisfied);

        if (jobStatus.getPreferUnmetered()) {