Loading apex/jobscheduler/service/aconfig/job.aconfig +1 −1 Original line number Diff line number Diff line Loading @@ -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 apex/jobscheduler/service/java/com/android/server/job/controllers/ConnectivityController.java +3 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading services/tests/mockingservicestests/src/com/android/server/job/controllers/ConnectivityControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -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))) Loading @@ -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)); Loading Loading
apex/jobscheduler/service/aconfig/job.aconfig +1 −1 Original line number Diff line number Diff line Loading @@ -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
apex/jobscheduler/service/java/com/android/server/job/controllers/ConnectivityController.java +3 −1 Original line number Diff line number Diff line Loading @@ -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; } } Loading
services/tests/mockingservicestests/src/com/android/server/job/controllers/ConnectivityControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -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))) Loading @@ -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)); Loading