Commit 76b89239 authored by Paul Miller's avatar Paul Miller Committed by Commit Bot

WebView: Require charging for variations seed download

This follows the advice of go/power-analysis (internal document). The
download frequency is capped at 1/day anyway, so this shouldn't have
much effect on seed freshness.

BUG=733857

Change-Id: Ifceecf6877542af317ea08128af9bdeb5c6fb991
Reviewed-on: https://chromium-review.googlesource.com/1066801Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Paul Miller <paulmiller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560209}
parent 9157c841
......@@ -100,9 +100,11 @@ public class AwVariationsSeedFetcher extends JobService {
ComponentName thisComponent = new ComponentName(
ContextUtils.getApplicationContext(), AwVariationsSeedFetcher.class);
JobInfo.Builder builder = new JobInfo.Builder(JOB_ID, thisComponent);
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
if (scheduler.schedule(builder.build()) != JobScheduler.RESULT_SUCCESS) {
JobInfo job = new JobInfo.Builder(JOB_ID, thisComponent)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setRequiresCharging(true)
.build();
if (scheduler.schedule(job) != JobScheduler.RESULT_SUCCESS) {
Log.e(TAG, "Failed to schedule job");
}
}
......
......@@ -96,6 +96,8 @@ public class AwVariationsSeedFetcherTest {
Assert.assertEquals("Job scheduled with wrong ID", JOB_ID, job.getId());
Assert.assertEquals("Job scheduled with wrong network type",
JobInfo.NETWORK_TYPE_ANY, job.getNetworkType());
Assert.assertTrue("Job scheduled without charging requirement",
job.isRequireCharging());
mJob = job;
return JobScheduler.RESULT_SUCCESS;
}
......@@ -191,7 +193,9 @@ public class AwVariationsSeedFetcherTest {
ComponentName component = new ComponentName(
ContextUtils.getApplicationContext(), AwVariationsSeedFetcher.class);
JobInfo job = new JobInfo.Builder(JOB_ID, component)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).build();
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setRequiresCharging(true)
.build();
mScheduler.schedule(job);
AwVariationsSeedFetcher.scheduleIfNeeded();
// Check that our job object hasn't been replaced (meaning that scheduleIfNeeded didn't
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment