diff options
author | Matthew Williams <mjwilliams@google.com> | 2014-08-21 13:47:47 -0700 |
---|---|---|
committer | Matthew Williams <mjwilliams@google.com> | 2014-08-21 20:28:12 -0700 |
commit | 9ae3dbeefcd6bc139c74bfe3d51de823e3be4b4b (patch) | |
tree | 9091f11de601187a418a60d579035a2edeb3a33d /tests/JobSchedulerTestApp | |
parent | bfecd904bf0ea8875caaaaafa5e3ae8c44b5175f (diff) | |
download | frameworks_base-9ae3dbeefcd6bc139c74bfe3d51de823e3be4b4b.zip frameworks_base-9ae3dbeefcd6bc139c74bfe3d51de823e3be4b4b.tar.gz frameworks_base-9ae3dbeefcd6bc139c74bfe3d51de823e3be4b4b.tar.bz2 |
JobScheduler only run jobs for started users.
BUG: 12876556
Minor changes to test app to make persisting an option.
Change-Id: I1b40347878ec5ca44cd717ebfeb544f6c58473b5
Diffstat (limited to 'tests/JobSchedulerTestApp')
4 files changed, 20 insertions, 26 deletions
diff --git a/tests/JobSchedulerTestApp/res/layout/activity_main.xml b/tests/JobSchedulerTestApp/res/layout/activity_main.xml index d3429ff..96e1641 100644 --- a/tests/JobSchedulerTestApp/res/layout/activity_main.xml +++ b/tests/JobSchedulerTestApp/res/layout/activity_main.xml @@ -141,6 +141,20 @@ android:id="@+id/checkbox_idle" android:text="@string/idle_mode_text"/> </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/persisted_caption" + android:layout_marginRight="15dp"/> + <CheckBox + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/checkbox_persisted" + android:text="@string/persisted_mode_text"/> + </LinearLayout> </LinearLayout> <Button diff --git a/tests/JobSchedulerTestApp/res/values/strings.xml b/tests/JobSchedulerTestApp/res/values/strings.xml index eebfb19..90dd2b6 100644 --- a/tests/JobSchedulerTestApp/res/values/strings.xml +++ b/tests/JobSchedulerTestApp/res/values/strings.xml @@ -27,6 +27,7 @@ limitations under the License. <string name="charging_caption">Charging:</string> <string name="charging_text">Requires device plugged in.</string> <string name="idle_caption">Idle:</string> + <string name="persisted_caption">Persisted:</string> <string name="constraints">Constraints</string> <string name="connectivity">Connectivity:</string> <string name="any">Any</string> @@ -34,4 +35,5 @@ limitations under the License. <string name="timing">Timing:</string> <string name="delay">Delay:</string> <string name="deadline">Deadline:</string> + <string name="persisted_mode_text">Persisted:</string> </resources> diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java index e15929d..6e5484e 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java @@ -65,6 +65,8 @@ public class MainActivity extends Activity { mAnyConnectivityRadioButton = (RadioButton) findViewById(R.id.checkbox_any); mRequiresChargingCheckBox = (CheckBox) findViewById(R.id.checkbox_charging); mRequiresIdleCheckbox = (CheckBox) findViewById(R.id.checkbox_idle); + mIsPersistedCheckbox = (CheckBox) findViewById(R.id.checkbox_persisted); + mServiceComponent = new ComponentName(this, TestJobService.class); // Start service and provide it a way to communicate with us. Intent startServiceIntent = new Intent(this, TestJobService.class); @@ -85,6 +87,7 @@ public class MainActivity extends Activity { RadioButton mAnyConnectivityRadioButton; CheckBox mRequiresChargingCheckBox; CheckBox mRequiresIdleCheckbox; + CheckBox mIsPersistedCheckbox; ComponentName mServiceComponent; /** Service object to interact scheduled jobs. */ @@ -146,7 +149,7 @@ public class MainActivity extends Activity { } builder.setRequiresDeviceIdle(mRequiresIdleCheckbox.isChecked()); builder.setRequiresCharging(mRequiresChargingCheckBox.isChecked()); - + builder.setIsPersisted(mIsPersistedCheckbox.isChecked()); mTestService.scheduleJob(builder.build()); } 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 e2c3be0..a68e04e 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/service/TestJobService.java @@ -90,31 +90,6 @@ public class TestJobService extends JobService { mActivity.onReceivedStartJob(params); } - // Spin off a new task on a separate thread for a couple seconds. - new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(Void... voids) { - try { - Log.d(TAG, "Sleeping for 3 seconds."); - Thread.sleep(3000L); - } catch (InterruptedException e) {} - final JobParameters params = jobParamsMap.get(currId); - Log.d(TAG, "Pulled :" + currId + " " + params); - jobFinished(params, false); - - Log.d(TAG, "Rescheduling new job: " + params.getJobId()); - scheduleJob( - new JobInfo.Builder(params.getJobId(), - new ComponentName(getBaseContext(), TestJobService.class)) - .setMinimumLatency(2000L) - .setOverrideDeadline(3000L) - .setRequiresCharging(true) - .build() - ); - - return null; - } - }.execute(); return true; } |