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

Commit 72d472c2 authored by Kweku Adams's avatar Kweku Adams
Browse files

Add battery-not-low requirement for constraint relaxation.

Don't relax the prefetch connectivity constraint requirement unless the
battery is also not low.

Bug: 299329948
Test: atest FrameworksMockingServicesTests:PrefetchControllerTest
Test: atest FrameworksMockingServicesTests:ConnectivityControllerTest
Change-Id: I4b2c0905fb15277c63ae57284a2139858998d68b
parent 8943b729
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@ package: "com.android.server.job"
flag {
    name: "relax_prefetch_connectivity_constraint_only_on_charger"
    namespace: "backstage_power"
    description: "Only relax a prefetch job's connectivity constraint when the device is charging"
    description: "Only relax a prefetch job's connectivity constraint when the device is charging and battery is not low"
    bug: "299329948"
}
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -932,7 +932,9 @@ public final class ConnectivityController extends RestrictingController implemen
            return false;
        }
        if (relaxPrefetchConnectivityConstraintOnlyOnCharger()) {
            if (!mService.isBatteryCharging()) {
            // Since the constraint relaxation isn't required by the job, only do it when the
            // device is charging and the battery level is above the "low battery" threshold.
            if (!mService.isBatteryCharging() || !mService.isBatteryNotLow()) {
                return false;
            }
        }
+7 −0
Original line number Diff line number Diff line
@@ -919,6 +919,7 @@ public class ConnectivityControllerTest {
            assertFalse(controller.isSatisfied(latePrefetchUnknownUp, net, caps, mConstants));
            mSetFlagsRule.disableFlags(FLAG_RELAX_PREFETCH_CONNECTIVITY_CONSTRAINT_ONLY_ON_CHARGER);
            when(mService.isBatteryCharging()).thenReturn(false);
            when(mService.isBatteryNotLow()).thenReturn(false);

            when(mNetPolicyManagerInternal.getSubscriptionOpportunisticQuota(
                    any(), eq(NetworkPolicyManagerInternal.QUOTA_TYPE_JOBS)))
@@ -938,6 +939,12 @@ public class ConnectivityControllerTest {
            assertFalse(controller.isSatisfied(latePrefetchUnknownUp, net, caps, mConstants));

            when(mService.isBatteryCharging()).thenReturn(true);
            assertFalse(controller.isSatisfied(latePrefetch, net, caps, mConstants));
            // Only relax restrictions when we at least know the estimated download bytes.
            assertFalse(controller.isSatisfied(latePrefetchUnknownDown, net, caps, mConstants));
            assertFalse(controller.isSatisfied(latePrefetchUnknownUp, net, caps, mConstants));

            when(mService.isBatteryNotLow()).thenReturn(true);
            assertTrue(controller.isSatisfied(latePrefetch, net, caps, mConstants));
            // Only relax restrictions when we at least know the estimated download bytes.
            assertFalse(controller.isSatisfied(latePrefetchUnknownDown, net, caps, mConstants));