From 06f0852ead5524c09987fc9da5129390a2dba251 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 13 Jun 2017 12:12:09 -0700 Subject: Fix #62545908 : 'metered' network jobs run without network Test: JobSchedulerTestApp Change-Id: I9c15022f5542163a27c6aaa4c3ee6b677cffd699 --- tests/JobSchedulerTestApp/res/layout/activity_main.xml | 8 ++++++++ tests/JobSchedulerTestApp/res/values/strings.xml | 2 ++ .../src/com/android/demo/jobSchedulerApp/MainActivity.java | 5 +++++ .../com/android/demo/jobSchedulerApp/service/TestJobService.java | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'tests/JobSchedulerTestApp') diff --git a/tests/JobSchedulerTestApp/res/layout/activity_main.xml b/tests/JobSchedulerTestApp/res/layout/activity_main.xml index 96e164103bce..41f977707097 100644 --- a/tests/JobSchedulerTestApp/res/layout/activity_main.xml +++ b/tests/JobSchedulerTestApp/res/layout/activity_main.xml @@ -73,10 +73,18 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> + + Persisted: Constraints Connectivity: + None Any + Metered WiFi Timing: Delay: diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java index 51cdbb585659..3dfdba719ce5 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java @@ -63,6 +63,7 @@ public class MainActivity extends Activity { mDeadlineEditText = findViewById(R.id.deadline_time); mWiFiConnectivityRadioButton = findViewById(R.id.checkbox_unmetered); mAnyConnectivityRadioButton = findViewById(R.id.checkbox_any); + mCellConnectivityRadioButton = findViewById(R.id.checkbox_metered); mRequiresChargingCheckBox = findViewById(R.id.checkbox_charging); mRequiresIdleCheckbox = findViewById(R.id.checkbox_idle); mIsPersistedCheckbox = findViewById(R.id.checkbox_persisted); @@ -85,6 +86,7 @@ public class MainActivity extends Activity { EditText mDeadlineEditText; RadioButton mWiFiConnectivityRadioButton; RadioButton mAnyConnectivityRadioButton; + RadioButton mCellConnectivityRadioButton; CheckBox mRequiresChargingCheckBox; CheckBox mRequiresIdleCheckbox; CheckBox mIsPersistedCheckbox; @@ -141,9 +143,12 @@ public class MainActivity extends Activity { builder.setOverrideDeadline(Long.parseLong(deadline) * 1000); } boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked(); + boolean requiresMetered = mCellConnectivityRadioButton.isChecked(); boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked(); if (requiresUnmetered) { builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED); + } else if (requiresMetered) { + builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_METERED); } else if (requiresAnyConnectivity) { builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); } diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java index 9df11fe90553..b698a3a53ff1 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java @@ -81,7 +81,8 @@ public class TestJobService extends JobService { @Override public boolean onStartJob(JobParameters params) { - Log.i(TAG, "on start job: " + params.getJobId()); + Log.i(TAG, "on start job: " + params.getJobId() + + " deadline?=" + params.isOverrideDeadlineExpired()); currentId++; jobParamsMap.put(currentId, params); final int currId = this.currentId; -- cgit v1.2.3-59-g8ed1b