• Home
  • History
  • Annotate
  • only in /frameworks/support/work/workmanager/src/androidTest/java/androidx/
History log of /frameworks/support/work/workmanager/src/androidTest/java/androidx/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8dfe54b350e7f8ec3f79c0952460f9f82622d801 08-Jun-2018 Sumir Kataria <sumir@google.com> Add implicit tags to all WorkRequests.

Implicit tags are the worker class's name, in case
you forget to add tags but still want to look up
and cancel your workers in the future.

Change-Id: I7027c9917b86d8e91b29f64f4bf656f1a69c3757
Fixes: 109572351
Fixes: 109675560
Test: Added and ran tests; updated other tests
ork/WorkDatabaseMigrationTest.java
ork/impl/WorkManagerImplTest.java
d865c2cf247d6b73d9f9510045dfd9ccd1f6ef12 08-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Rename `systemIdInfo` table to `SystemIdInfo`.

- Update migration tests, DAO and the schemas.

Test: Unit tests pass.
Change-Id: Ic96751a6edc3498e2a3f8c9bca6642f114f23c8c
ork/WorkDatabaseMigrationTest.java
e326592ec414dfe4c002e2840d9fc4aef0ee8747 08-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Make the scheduler limit configurable.

- on API 23, use half the scheduler limit to take into account of double scheduling.

Test: Unit tests pass on both scheduler implementations.

Change-Id: Ie7ba6e056d9e8911261599ed1fbb1dddf6af99fb
ork/WorkSpecDaoTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplLargeExecutorTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
ork/worker/CheckLimitsWorker.java
e905b169a0734fea2a3e62362c34c901baaacfc8 08-Jun-2018 Sumir Kataria <sumir@google.com> Merge "Add pruneWork(Sync) methods." into pi-preview1-androidx-dev
4e34c1f8146c680986965fa1695cbd530b684121 08-Jun-2018 Sumir Kataria <sumir@google.com> Add pruneWork(Sync) methods.

This method will prune work matching the following criteria:
- Finished (succeeded, failed, cancelled)
- Zero unfinished dependents

This, together with cancelAll, gives the ability for people
to clear jobs and solves the "observation of a growing list
of jobs" problem.

Change-Id: Ied5571f3d143659f5d52cc4e1983e96329e91390
Fixes: 79950952
Test: Added and ran tests.
ork/impl/WorkManagerImplTest.java
d554aebb8aa2aa48222b7b003273b06369d55a89 07-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Migrating existing jobs to non-persistent jobs.

- Starting alpha03, we will no longer use JobScheduler to persist jobs.
- ForceStopRunnable now cancels all pending jobs, & reschedules eligible jobs.

Test: Added unit tests.

Change-Id: I672ad6f4ab8876834317f704234a76abc12b4ec7
ork/impl/utils/ForceStopRunnableTest.java
5c2a50a9c5a3a71fcd5ee8400957a60520fc4ff4 07-Jun-2018 Sumir Kataria <sumir@google.com> Merge "Add ability to query when cancelAll was last called." into pi-preview1-androidx-dev
70a3b26b02be06e63642fa544dfda7cf281c2dfa 06-Jun-2018 Sumir Kataria <sumir@google.com> Add ability to query when cancelAll was last called.

- Add a new API to query the last time this happened
for module and library developers. These methods are
getLastCancelAllTimeMillis(Sync).
- Create a Preferences class to store this data.
- TODO: migrate all SharedPrefs here (right now there
are some in IdGenerator).

Change-Id: I6a34c2d9487e79ad809bf5ce79829d5f490af3f5
Fixes: 73780564
Test: Added and ran tests in WorkManagerImplTest.
ork/impl/WorkManagerImplTest.java
e8143f1fa1ac28fc71b54f632e79142e51fc19ef 05-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Support backward migrations for WorkManager.

* Move to Room 1.1.0 as 1.0.0 has a bug when looking for backward migrations.

Test: Added unit tests.
Change-Id: Ia9ad590037df1b4bf14e1449aae0def7fc7a4e07
ork/WorkDatabaseMigrationTest.java
494b77cd228de249649440c6210bbae1ddf33d76 05-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Use SystemIdInfo to keep track of jobIds.

- Now we have stable ids for a given workSpecId.
- Cancelling a job also removes the relationship in the SystemIdInfo table.
- Don't ask JobScheduler to persist jobs. Instead use the RescheduleReceiver.

Test: Updated unit tests.
Integration Test: https://paste.googleplex.com/6602470222462976
Change-Id: I56bdcfbb560eb34b36bf060438ad70c606ce27e4
ork/impl/SchedulersTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
1340331a9fdcbe89a7c0070dff4064381c740a35 04-Jun-2018 Sumir Kataria <sumir@google.com> Add cancelAllWork(Sync) methods.

This is potentially needed for rare cases like app wipeouts or
user logout.

In a future CL, I will provide the ability to query WHEN this
method was last used in case a library wants to react to its
data in WorkManager being wiped out from under it.

Change-Id: I459ffdee175683d4b33d817e82976f799050b902
Fixes: 73780564
Test: Added and ran tests
ork/impl/WorkManagerImplTest.java
00b6d5087477efae40c99990b8f2194f86e7fdb1 02-Jun-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Migrate `alarmInfo` to `systemIdInfo`." into pi-preview1-androidx-dev
18e0a7e02c1198c5b3b33295b148c1017e32f016 02-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Migrate `alarmInfo` to `systemIdInfo`.

* This is step (1/4) to keep track of job ids so we can de-dupe
requests to schedule jobs in JobScheduler.

Test: Added migration tests.
Change-Id: I2576c8457d36883d3a9bdafe2236751a2154a69b
ork/WorkDatabaseMigrationTest.java
ork/impl/background/systemalarm/AlarmsTest.java
b24ef38a0b526b524e3e6a7849f62f934a6ad58c 01-Jun-2018 Sumir Kataria <sumir@google.com> Expose current run attempt count in Worker.

Developers can use this to implement their own
max retry count behavior. (We don't want to
provide that as a WorkRequest.Builder API
because it's not clear what state work that
has exceeded its max retry count should be in.
Should it be CANCELLED? FAILED? Something
new? It's better to let the developer deal
with this themselves.)

Change-Id: Ifc22207f71a8880fb725c0cec80281bceff1af44
Fixes: 79716516
Test: Added and ran tests
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
11a7c26af63674a21787696e509e9a43d0bd7acf 01-Jun-2018 Sumir Kataria <sumir@google.com> Rename Worker#WorkerResult -> Worker#Result.

Change-Id: Icbe7b588a933412b277e8ee8902b86254d701a61
Fixes: 80217775
Test: Ran tests.
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/worker/ChainedArgumentWorker.java
ork/worker/EchoingWorker.java
ork/worker/ExceptionWorker.java
ork/worker/FailureWorker.java
ork/worker/InfiniteTestWorker.java
ork/worker/InterruptionAwareWorker.java
ork/worker/LongRunningWorker.java
ork/worker/RetryWorker.java
ork/worker/SleepTestWorker.java
ork/worker/TestWorker.java
ab3e56b9f28946bfd198d632eecfcc417c27557b 01-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Merge "Move tests around Scheduler#MAX_SCHEDULER_LIMITs to a seperate Test Suite." into pi-preview1-androidx-dev
170ba43e442a28b0091f764e2eec288bbab99fbd 01-Jun-2018 Sumir Kataria <sumir@google.com> Merge "Add Network to Worker/RuntimeExtras." into pi-preview1-androidx-dev
4a880dc1b57b3c4d52ead5fa927cf5afbb65cf15 01-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Move tests around Scheduler#MAX_SCHEDULER_LIMITs to a seperate Test Suite.

* This uses a large Executor. That way we actually exhaust the number
of workers that can be scheduled.

Test: Unit tests pass.
Change-Id: I327a51ecb572a5886db4e3ddbec94a377f806c28
ork/impl/WorkManagerImplLargeExecutorTest.java
ork/impl/WorkManagerImplTest.java
7103c51f348cc4400758b004a343937f1987ead7 01-Jun-2018 Rahul Ravikumar <rahulrav@google.com> Merge "Add WorkContinuation#getStatusesSync() API." into pi-preview1-androidx-dev
eda66d6e6b83e6f68717be95ec10e7ad8f070a83 01-Jun-2018 Sumir Kataria <sumir@google.com> Add Network to Worker/RuntimeExtras.

Change-Id: I7c32502700444a9f2109b70791db2192836ba539
Fixes: 74404811
Test: Added and ran tests.
ork/impl/background/systemjob/SystemJobServiceTest.java
ef5649cbfdae238e02a3ef55997140ae7704cbd8 31-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update tests that push scheduler limits (MAX_SCHEDULER_LIMIT is inclusive)." into pi-preview1-androidx-dev
5a4ced8020d8a3ee4b9100b97559db3d1fb5132b 31-May-2018 Rahul Ravikumar <rahulrav@google.com> Add WorkContinuation#getStatusesSync() API.

Test: Added unit tests.
Change-Id: I8e2aa99bf510329c823689e566550ca65152dcfd
Fixes: b/80314157
ork/impl/WorkContinuationImplTest.java
5d373d376edddb57cd822dd06ed54f97ef949586 31-May-2018 Sumir Kataria <sumir@google.com> Breaking change: Tell Worker if it's been cancelled.

Currently, Worker#onStopped doesn't know if it's been
cancelled or merely pre-empted by the system. b/79632247
points out some reasons why an explicit signal for
cancellation may be useful. #onStopped now gets a
boolean argument indicating if the Worker has been
cancelled and will never run again. A new method,
Worker#isCancelled, is also provided.

Change-Id: I19424fe718c95e2fd374f40b0afc8a79194c6100
Fixes: 79632247
Test: Added and ran tests.
ork/impl/WorkerWrapperTest.java
22499da21adf6c36e4f20938ba5296933e0c099a 30-May-2018 Rahul Ravikumar <rahulrav@google.com> Update tests that push scheduler limits (MAX_SCHEDULER_LIMIT is inclusive).

Test: Updated existing tests.
Change-Id: Ic35d4879a718c7a6de81fd35cceba25884e580d6
ork/impl/WorkManagerImplTest.java
3d294577af0185017a882f9050fcad90c9160e66 30-May-2018 Rahul Ravikumar <rahulrav@google.com> Add a test which pushes the `Scheduler#MAX_SCHEDULER_LIMIT`s.

Test: Existing tests pass.
Change-Id: Ieb2a385e137440a986bbed801d5030ff494f6d9f
ork/impl/WorkManagerImplTest.java
c443aebdc19f4961ee5ff4860f3c9a59c2f672d1 26-May-2018 Rahul Ravikumar <rahulrav@google.com> Marking SystemAlarmDispatcherTest#testDelayMet_withUnMetConstraint() a @LargeTest.

- This test is a bit flaky but its hard to tell why as I am not being
able to reproduce this locally.

- There is a pending bug b/80308475 in Trade-fed, which might
tell us why this test is flaky.

Test: Existing tests pass.
Change-Id: I0b58ba2bbd48dbdadefb99117d93068e85d6c7cb
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
8e6884a76498f5d12862e93c62e878721a41e322 26-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add enqueueUniquePeriodicWork(Sync)." into pi-preview1-androidx-dev
1bffc919a167a732f24cf4216664374087628e15 26-May-2018 Sumir Kataria <sumir@google.com> Add enqueueUniquePeriodicWork(Sync).

Unlike OneTimeWorkRequests, this API does not provide
begin/then syntax because you can't chain periodic work.
Internally, the implementation is identical to one-time
work, but since ExistingWorkPolicy.APPEND does not make
sense for PeriodicWork, I created a new enum for it,
ExistingPeriodicWorkPolicy.

I'm not totally satisfied with having two different
enums that are similar, so we can explore the potential
ramifications in the future.

Change-Id: Ic43289c6654bd2c031a432692a52cc5fb25e1991
Fixes: 79600647
Test: Added and ran tests.
ork/impl/WorkManagerImplTest.java
6a4bdac9db459b971d11490de6d64cff35c4834b 25-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add the ability to ask WorkManager to use jobIds in a specified range." into pi-preview1-androidx-dev
22a8129c2b3313100f851460f7da9e56ca98bd8f 25-May-2018 Rahul Ravikumar <rahulrav@google.com> Add the ability to ask WorkManager to use jobIds in a specified range.

- Configuration.Builder#setJobSchedulerJobIdRange(int minInclusive, int maxExclusive)
specifies the range of job ids to be used by JobScheduler.

Test: Added Unit tests for IdGenerator.
Change-Id: I30f4fc379e0a4df99deb66be52aa1b086828dcef
Fixes: b/79996760
ork/impl/SchedulersTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/utils/IdGeneratorTest.java
dd5f33cd6b98eba208ac7c69d3d6314d3115e2d2 24-May-2018 Sumir Kataria <sumir@google.com> Breaking change: Worker.getId now returns a UUID.

This was an artifact of the old API that never got
fixed.

Also added Javadoc.

Test: Reran tests.
Change-Id: I9173ab1e58c5262f4767a426f53f388faadaf1a4
ork/impl/WorkerWrapperTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
11c59a053ff3ea65f6e27d77ca54f35b7ea9f4fd 23-May-2018 Sumir Kataria <sumir@google.com> Add Duration methods to WorkRequest Builders.

Duration methods are only supported on API 26+.

Change-Id: Ic628a04fc38ff52337f983389f906989440f17f4
Fixes: 78287016,78286839
Test: Added and ran new tests.
ork/PeriodicWorkTest.java
ork/WorkTest.java
34b8d565bd08e929ea367646b1468710df89c521 22-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add Configuration.Builder#setExecutor()." into pi-preview1-androidx-dev
bf4f4f72fd27f110b95cc9867fb5dc695d2689b1 22-May-2018 Sumir Kataria <sumir@google.com> Add Worker interruption-related methods.

- Worker#isStopped indicates if the Worker is
currently considered interrupted and should stop
its processing.
- Worker#onStopped is called upon interruption
for lightweight cleanup operations.

Change-Id: Idb656029f6594fe6b9953571113c972f39e43cd6
Fixes: 79632247
Test: Added and a ran testInterruption_isMarkedOnRunningWorker
ork/impl/WorkerWrapperTest.java
ork/worker/InterruptionAwareWorker.java
b9490b789c8cba57b58cb8404463c0b83fb89074 22-May-2018 Rahul Ravikumar <rahulrav@google.com> Add Configuration.Builder#setExecutor().

- Deprecate Configuration.Builder#withExecutor().

Test: Updated tests.
Change-Id: I99bb3557268be4cf1c7293b17b376b09de34d574
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
2cedb0ebeb876a38c03822d78915fc6f3559f84e 22-May-2018 Sumir Kataria <sumir@google.com> Merge "Expose tags in Worker." into pi-preview1-androidx-dev
7b5c560e4098585f73564951621060de708e441f 22-May-2018 Sumir Kataria <sumir@google.com> Expose tags in Worker.

Plumb tags all the way through. Change the signature
of internalInit so it takes one data-holding parameter
(Extras, which now contains input Data, tags, and
RuntimeExtras). This way, we don't need to change the
internalInit signature. This means we won't need
dagger updates.

Change-Id: I4deff0dda7518d8c253b899922eee647cccef756
Fixes: 79631815
Test: Added and ran tests.
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
ork/worker/LongRunningWorker.java
f21e8d4fc292ca752467f45e9db740ec505d45e8 22-May-2018 Sumir Kataria <sumir@google.com> Merge "Explicitly check for minSdk in SystemJobServiceTests." into pi-preview1-androidx-dev
aa73f022f0b1caf9f6e9427306c486f6a6da9618 21-May-2018 Sumir Kataria <sumir@google.com> Explicitly check for minSdk in SystemJobServiceTests.

We can't figure out why the flakes are happening on API 17
devices, which shouldn't run these tests. Explicitly
check and return from tests when they shouldn't be running.
We will continue to investigate why this is actually
happening.

Test: Ran tests on API 17.
Change-Id: I0dd3d508f23e2aaa6822e3ae5fc8f5f17838b153
ork/impl/background/systemjob/SystemJobServiceTest.java
f7e9a8de361bbc8eb854fc83ff566033c8e75277 19-May-2018 Rahul Ravikumar <rahulrav@google.com> Removes the lock contention on CommandHandler#onExecuted().

- If there were too many workers completing work at the same time,
there would be a lot of lock contention on the main thread because
WorkerWrapper calls onExecuted() on the main thread.

- To solve this, we offload the handling of onExecuted() to the
command processor queue.

```
DALVIK THREADS (65):
"main" prio=5 tid=1 Blocked
| group="main" sCount=1 dsCount=0 obj=0x740c9000 self=0xb4025800
| sysTid=14462 nice=0 cgrp=default sched=0/0 handle=0xb77e2ea0
| state=S schedstat=( 0 0 0 ) utm=22 stm=51 core=3 HZ=100
| stack=0xbf4f1000-0xbf4f3000 stackSize=8MB
| held mutexes=
at androidx.work.impl.background.systemalarm.CommandHandler.onExecuted(CommandHandler.java:111)
- waiting to lock <0x05d42e2d> (a java.lang.Object) held by thread 34
at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.onExecuted(SystemAlarmDispatcher.java:101)
at androidx.work.impl.Processor.onExecuted(Processor.java:186)
- locked <0x05378f62> (a androidx.work.impl.Processor)
at androidx.work.impl.WorkerWrapper$1.run(WorkerWrapper.java:218)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke!(Native method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
```

Test: Updated unit tests, added integration tests.

Change-Id: Ib58047e603b95e50872d0171d8fa2fbced467230
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
70c57725ae84e0e8f8981c076876f67560059111 18-May-2018 Rahul Ravikumar <rahulrav@google.com> Remove unused constants from WorkManagerImplTest.

Test: Existing tests pass.
Change-Id: I97b4bc3450ef0f21f67f7d833f72f79163947f73
ork/impl/WorkManagerImplTest.java
694b8e47053d383b6b53ae4edb643a7f7578f36d 17-May-2018 Rahul Ravikumar <rahulrav@google.com> Fix NetworkStateTrackerTest.
- API < 16 treats a `null` NetworkInfo as metered.

Test: Unit tests pass.
Change-Id: I24036e0b73c7a260f9f159aea33dfe6045b3968c
Fixes: b/79694483
ork/impl/constraints/trackers/NetworkStateTrackerTest.java
850226438f7ff51724f86cc7cc1c5c03afe91399 15-May-2018 Rahul Ravikumar <rahulrav@google.com> Fixes a bug in ForceStopRunnable, Schedulers which causes workers to be rescheduled.

- ForceStopRunnable now creates alarms for a designated receiver.
- WorkSpecDao ensures eligible WorkSpecs have not been marked scheduled.
- Update WorkSpecDaoTests & SystemAlarmDispatcherTests.

Fixes: b/79660657, b/79497378
Test: Updated unit tests & integration test app.

Change-Id: I23b17acafbac843b71b2b73d3755ade2404e4bd0
ork/WorkSpecDaoTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/utils/ForceStopRunnableTest.java
b49a9b9d093821c6f2c36fba1f13c0226aa503f9 15-May-2018 Sumir Kataria <sumir@google.com> Merge "Fix Javadoc formatting for ArrayCreatingIM." into pi-preview1-androidx-dev
2574ac4ac18d2bb4ceeae795a213d86c3a70fc68 14-May-2018 Rahul Ravikumar <rahulrav@google.com> Mark all tests with a Thread.sleep() as large tests.

- This is to make the tests less flaky.

Test: Unit tests continue to pass.

Change-Id: I3d47081168dc3c10f01340f8920288d103adc4b0
ork/impl/WorkContinuationImplTest.java
ork/impl/background/systemalarm/WorkTimerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
0e0da94119315b8388bc1fb055efcf0416c15f0c 11-May-2018 Sumir Kataria <sumir@google.com> Fix Javadoc formatting for ArrayCreatingIM.

Test: genDocs and checked output.
Change-Id: Ife257fcf313eb766a1a12e972a0cb773461b32c8
ork/impl/WorkManagerImplTest.java
1eea8579f62b48e3897e900fedf4ef1620180ba8 12-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Don't disable FJS if not present." into pi-preview1-androidx-dev
6aa349fecb357634a176b8ca3343231eefcee249 11-May-2018 Sumir Kataria <sumir@google.com> Don't disable FJS if not present.

Also remove unused InternalLogger.

Change-Id: I71eaeeb63df6344ad27c17a4acb0d35b9814862f
Fixes: 79306274
Test: Ran and logged test app.
ork/impl/WorkManagerImplTest.java
ork/impl/logger/InternalLoggerTest.java
d874811ee5f3275e6022115a03aa6001dc1830a9 11-May-2018 Sumir Kataria <sumir@google.com> Handle WorkSpec deletion in WorkerWrapper.

Change-Id: I85a1bd4b5c75ba778851408a30c690144997570a
Fixes: 79550068
Test: Added testWorkerWrapper_handlesWorkSpecDeletion
ork/impl/WorkerWrapperTest.java
3f0c0fbaf4be127488fc900d915d1c966813a4e6 08-May-2018 Sumir Kataria <sumir@google.com> Treat exceptions and errors in Worker#doWork as failures.

Change-Id: Iea7712c1916084894f89334e0ec808c2f6910406
Fixes: 79374987
Test: Added and ran tests.
ork/impl/WorkerWrapperTest.java
ork/worker/ExceptionWorker.java
25727dfbb55bef6bb9f96f62e85af67282fdc967 07-May-2018 Rahul Ravikumar <rahulrav@google.com> Fix flaky tests.

- Mark FirebaseJobServiceTest#testOnStopJob_ResetsWorkStatus() as a @LargeTest.
- Give WorkTimer#testStopTimer_withCleanUp() a bit more time.

Test: Existing tests pass.
Change-Id: If29fb1fa762858b27584c17ed8509501dda0ff62
ork/impl/background/systemalarm/WorkTimerTest.java
5b84f5ce59c65703ce6d5cdb1133185cd93e1862 04-May-2018 Sumir Kataria <sumir@google.com> Revert "Change `CANCELLED` to `CANCELED`."

This reverts commit 8586b66cab89a0bef12fd5e5d097a6d0e31fb9e7.

Reason for revert: Matching AsyncTask.isCancelled and other
async cancellations.

Change-Id: Ib95ccf193e5b4de87e4615595282fb24b52c8fd4
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
8586b66cab89a0bef12fd5e5d097a6d0e31fb9e7 04-May-2018 Rahul Ravikumar <rahulrav@google.com> Change `CANCELLED` to `CANCELED`.

Test: Unit tests pass.
Change-Id: I908c8e2c253ccee894e7c41cb9df7e6b6eca03e3
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
62a7e773945d980084dfc5d00c724de2e27dc22d 24-Apr-2018 Sumir Kataria <sumir@google.com> Change WorkRequest.Builder to use set.

Also, make getThis package-private
(otherwise you have to put @hide on
each overridden version).

Test: Ran tests.
Change-Id: I270ff8bd86b2de404e1e7e3229943947930734e6
ork/PeriodicWorkTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
bf8c43a111e5b5ea9f274882280c57e06a2ea4d3 24-Apr-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes I66e833cb,If9e5d740 into pi-preview1-androidx-dev

* changes:
Add a TestScheduler for tests.
Switch WorkRequest/WorkStatus id's to UUIDs.
d0d61c5aa317685f06802a202a2f46c71e1da962 20-Apr-2018 Rahul Ravikumar <rahulrav@google.com> Rename Worker#getAppContext to Worker#getApplicationContext()

Test: Existing unit tests pass.
Change-Id: I17e4a8596d43c942c37485833a8eb007587582a4
Fixes: b/78288767
(cherry picked from commit f80b700a707b5c29592dc06b3c4ae70f57e8a456)
ork/impl/WorkerWrapperTest.java
fa284c943bd003ff03f1934370d70bd4a5e034c3 23-Apr-2018 Sumir Kataria <sumir@google.com> Switch WorkRequest/WorkStatus id's to UUIDs.

Per API council feedback.

I chose not to change the internal WorkSpec id type
because that would lead to a lot of TypeConversions
that really aren't needed at runtime (as most of our
queries deal with id's).

To make testing a little easier, I included a new
method in WorkRequest called getStringId.

Change-Id: If9e5d7409834465704ac28cd7f1589425e936544
Fixes: 78288868
Test: Ran tests.
ork/WorkSpecDaoTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemalarm/AlarmsTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
55a030183e5b974f3ebf04ef5cd9ab83f3557dad 23-Apr-2018 Sumir Kataria <sumir@google.com> Rename WorkContinuation join to combine.

As per API council, this better matches CompletableFuture.

Change-Id: I6b93896d385734244ffd7b3b45573c32ca28d8dc
Fixes: 78287319
Test: Ran tests.
ork/impl/WorkContinuationImplTest.java
62e0be94ea7e54ca9227564b14c1c6736ae770f7 23-Apr-2018 Sumir Kataria <sumir@google.com> Rename "blocking" to "synchronous" per API council.

Change-Id: Ia0c049be831d075905e4459ac57caa929c936234
Fixes: 78286857
Test: Ran tests.
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
7031a0fbe12b8159ab2dc6d9c50be5b3f38477fa 19-Apr-2018 Rahul Ravikumar <rahulrav@google.com> Rename BaseWorkRequest to WorkRequest, and WorkRequest to OneTimeWorkRequest.

- API council feedback.


Test: All unit tests continue to pass.
Fixes: b/78287721
Change-Id: Ifc00fc74cf9c42aeb44c3f4cb3244b5d445b8d0d
ork/DatabaseTest.java
ork/WorkManagerTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemalarm/AlarmsTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
a1733dfc3fe8e5dfb6d39258e5f0a9d2fd8b75f7 17-Apr-2018 Sumir Kataria <sumir@google.com> Swtch from ExecutorService to Executor.

Fixed a couple of tests to be less flaky.

Test: Ran tests.
Change-Id: Id853222316dd42f443e32b2c8e75116d31f7dfb6
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
b0a0d7b4910f8733c04bc9dd98ec05da7247bdce 17-Apr-2018 Sumir Kataria <sumir@google.com> Add WorkerWrapper interruption; remove usage of Futures.

This is part 1 of removing ExecutorService and using
Executor instead. Here we add an explicit interrupt()
method to WorkerWrapper and check it when deciding if
the work finished successfully.

Also cleaned up a broken state where ALL non-cancelled
states could lead to handleResult being called.

Removed blocking cancellation in WorkManagerImplTests
due to thread contention issues because of synchronous
execution rules.

Removed Worker.isInterrupted. Need to come up with a
suitable alternative.

Removed Processor.stopWork's second argument (may
interrupt thread) because it's not relevant anymore.

Test: Added and ran tests.
Change-Id: I28de5081e8d30c3d9147b1d74008ab931963fa81
ork/impl/ProcessorTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/worker/InfiniteTestWorker.java
ork/worker/LongRunningWorker.java
c0cdcc4dd56871adda73862153063f49925fbc04 17-Apr-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Use the standard Android (android.util.Log) logger." into flatfoot-background
697d6a4a3797bc71d0dd8685937a318e9934066b 17-Apr-2018 Rahul Ravikumar <rahulrav@google.com> Use the standard Android (android.util.Log) logger.

- Rename Logger to InternalLogger so we can start adding internal only
logs.
- Remove redundant logs in AlarmManager based implementation.

Test: Existing tests pass.
Change-Id: I44babc42dafbce0311f439ffaca6bf40fc058be0
ork/WorkManagerTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/logger/InternalLoggerTest.java
ork/impl/logger/LoggerTest.java
b9701e2752b53221501cfaeb247256f1ae12baec 17-Apr-2018 Sumir Kataria <sumir@google.com> Add nullability annotations to Worker.

Set output to Data.EMPTY by default and
made it mandatory to be @NonNull to match
input.

Test: Ran tests.
Change-Id: Iacd38c755200cf018a212c2616861454418e270d
ork/worker/ChainedArgumentWorker.java
ork/worker/EchoingWorker.java
ork/worker/FailureWorker.java
ork/worker/InfiniteTestWorker.java
ork/worker/RetryWorker.java
ork/worker/SleepTestWorker.java
ork/worker/TestWorker.java
dcbf20db18e3e93a13e9fa75fa4b723255b87c54 16-Apr-2018 Sumir Kataria <sumir@google.com> Change WW.setRunning to check the current state.

Since we don't want to do input merging in the middle
of a transaction, we need to verify we are still
enqueued before starting the work and setting the
state to running.

Test: Updated tests.

Change-Id: I9c4dc8d8ba41098ae68bdc7de267d3bf811894a6
ork/impl/WorkerWrapperTest.java
d10e117c33577004a903b3f9184d93cc36467285 14-Apr-2018 Sumir Kataria <sumir@google.com> Rename name -> uniqueWork in method names/Javadoc.

Also fix a few Javadoc comments from previous CL.

Test: Ran tests.
Change-Id: Ifef53db4dbc5123adce931c5c352ed35ff73892a
ork/impl/WorkManagerImplTest.java
8b3284fa4a62568df91f706b0b2334284794008f 13-Apr-2018 Sumir Kataria <sumir@google.com> Change *Work -> *WorkRequest.

Test: Ran tests.
Change-Id: Ice89bfb633105ab2b60e2d5a83cdf11e92595553
ork/DatabaseTest.java
ork/PeriodicWorkTest.java
ork/WorkManagerTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemalarm/AlarmsTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
7f44b37e7640e4b91656e024d1754fa7a062a833 10-Apr-2018 Sumir Kataria <sumir@google.com> Update and expose WorkManager Configuration.

If the user disables the WorkManagerInitializer, they can
manually initialize WorkManager with their own configuration.
Right now, configurations only contain a user-specified
ExecutorService.

- Rename /impl/WorkManagerConfiguration -> /Configuration
- WorkManager now has two initialization methods
- initialize(Context) uses a default configuration
- initialize(Context, Configuration) accepts a custom config
- They both delegate to WorkManagerImpl's versions of those
methods
- Configuration no longer relies on an explicit useTestDatabase;
the value from resources is always correct anyway
- Added Builder for Configuration; made constructor private
- Moved background scheduler creation into Schedulers.java
- Moved DB creation into WorkManagerImpl

Test: Updated and ran tests.
Change-Id: Ie1fa78f55be94eb3088dc85e82459124d8e96d52
ork/impl/SchedulersTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerConfigurationTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
0c252a21d65ac58c2a19540bd6af9ffdd77b1e94 07-Apr-2018 Rahul Ravikumar <rahulrav@google.com> Bugfix: EnqueueRunnable now correctly schedules workers.

- EnqueueRunnable previously checked if only the leaf continuation
could be scheduled. Now it correctly checks all the continuations
in the graph.

- Updated WorkContinuationImplTest to check that unblocked workSpecIds
are scheduled upon enqueue() correctly.

Test: Updated unit tests.
Change-Id: I8d75a95b1cd47020a53ae9e3044b3e52ab95e75b
ork/impl/WorkContinuationImplTest.java
addaa43020e280181c1b49cae944452505d5c827 03-Apr-2018 Rahul Ravikumar <rahulrav@google.com> Add enqueueBlocking() APIs on BlockingWorkManager.

Test: Updated unit tests. All pass.
Change-Id: I7129470692ce368a36762a233eafeefee9980bb6
Fixes: b/77484497
ork/impl/WorkManagerImplTest.java
c7077ec99a2bf4884a6e4f297398eb3f6df83d6f 30-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Add WorkManagerInitializer that initializes WorkManager.

- This fixes the problem where force stopped workers are not rescheduled
until we get a call to WorkManager.getInstance(context).

Test: Unit tests pass.
Change-Id: I4592d791636295c5d04361eb4087053ec4c14eb2
Fixes: b/74444877
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
bd094ee03e5ea7d768c62d76a1f980f6a3b0853d 29-Mar-2018 Sumir Kataria <sumir@google.com> Update flatfoot-background to use API 28.

Test: Updated and ran tests.
Change-Id: I49fda42ca3814a742a4587a0ac3ed736cf115955
ork/WorkSpecTest.java
64e6bd86c786f1cb1b0c3dbc2b5307cca5c0d1f6 29-Mar-2018 Sumir Kataria <sumir@google.com> Rename Arguments to Data.

- Rename setOutput to setOutputData
- Rename BaseWork.Builder.withArguments to withInputData.

Change-Id: Idf490663c9639b9a90d0327d7f164534b0a0b2a4
Fixes: 76438322
Test: Updated and ran tests.
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
ork/worker/ChainedArgumentWorker.java
ork/worker/EchoingWorker.java
01be39a1286efd2f3b60c366e0c0b7e9ba2c87c1 29-Mar-2018 Sumir Kataria <sumir@google.com> Merge "Have Arguments expose primitive types only." into flatfoot-background
5f5e7072d763d88253de1f3f092957b67f4cd8e4 28-Mar-2018 Sumir Kataria <sumir@google.com> Have Arguments expose primitive types only.

Also add support for boolean[], float, and float[].

Test: Updated and ran tests.
Change-Id: Ib988a30ed639f8742a4d6b12a67ab865637d875d
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
2ca6b2dec030049de439acaa719e321252af4413 28-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Check for cycles in a WorkContinuation before enqueueing.

Test: Added unit tests.
Fixes: b/74409639

Change-Id: Ieaac2209a777b4d8213ada078c037f6242d2d09a
ork/impl/WorkContinuationImplTest.java
cc86a28f45a8393bb14b1945dfe5b35ec44a190b 26-Mar-2018 Sumir Kataria <sumir@google.com> Add delegate to WorkManagerImpl.

Test: Updated and ran tests.
Change-Id: Ie0af8fb8d95ff3eef6f3171d8c8c34457161636f
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
1c59c3abb41961321d514539195c3935dd45918d 22-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Keep track of the number of scheduled workers." into flatfoot-background
9f91ee8c71606f36a51177cd0b5c3005834be1ff 21-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Keep track of the number of scheduled workers.

- Scheduling of workers (via the Scheduler) should honor the
Scheduler#MAX_SCHEDULER_LIMIT.
- If we exceed the MAX_SCHEDULER_LIMIT, schedule_requested_at remains at -1.
- WorkerWrapper on succeeding or failing should try and schedule workers
which were pending execution previously.
- Cancelling of work via Scheduler#cancel() should try and schedule
work that was pending to be scheduled.
- Force stops should reset the scheduling bits, and try and
reschedule everything while honoring the MAX_SCHEDULER_LIMIT.

Test: Added unit tests, and existing tests pass.
Fixes: b/73730203

Change-Id: Icc30045ea058a9f27ca07297771d9062fca8beec
ork/WorkSpecDaoTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/utils/EnqueueRunnableTest.java
ork/impl/utils/ForceStopRunnableTest.java
681a8d809fe41189c9d590d33b986b98170e4963 21-Mar-2018 Sumir Kataria <sumir@google.com> Create RuntimeExtras. Put content uri info in it.

RuntimeExtras contains information that is not cacheable and
is only available when we decide to run a job. In this case,
the class contains triggered content URI information; in the
future, the triggered Network info will also be available
here.

RuntimeExtras is piped all the way to the Worker.

Change-Id: I24b73da267d16f661a138b4aa652f34bdb9cedf5
Fixes: 71909029
Test: Added and ran tests.
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
4401f79faa35469c257262b85b1cdc808c266c4b 20-Mar-2018 Sumir Kataria <sumir@google.com> Dedupe and map WorkStatusPojos on a background thread.

This should help prevent potential ANRs/framerate drops.

Fixes: 74437130
Test: Updated and added tests.
Change-Id: I480416e6b73afa4d17d246d4c841b983fabe31e2
ork/impl/utils/LiveDataUtilsTest.java
b5728f4e1a4b3f4f1fabf033b1363ca6b1cffdef 19-Mar-2018 Sumir Kataria <sumir@google.com> Remove WorkSpec getters/setters.

The war on method count continues.

Test: Updated and ran tests.
Change-Id: Idaf80b08e415beab107c3f564d02b846a987008a
ork/DatabaseTest.java
ork/PeriodicWorkTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerConfigurationTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/constraints/WorkConstraintsTrackerTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
ork/impl/constraints/trackers/BatteryChargingTrackerTest.java
ork/impl/constraints/trackers/BatteryNotLowTrackerTest.java
ork/impl/constraints/trackers/ConstraintTrackerTest.java
ork/impl/constraints/trackers/NetworkStateTrackerTest.java
ork/impl/constraints/trackers/StorageNotLowTrackerTest.java
ork/impl/utils/EnqueueRunnableTest.java
ork/impl/utils/ForceStopRunnableTest.java
ork/impl/utils/IdGeneratorTest.java
ork/impl/utils/LiveDataUtilsTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
31099f8c34e2e4ba4760ca643c7f6cdb51791c4e 17-Mar-2018 Sumir Kataria <sumir@google.com> Remove WorkImpl and PeriodicWorkImpl.

More method savings, yay.

Test: Updated and ran tests.
Change-Id: Ide0bf1ed1da68d7a4947f13560134eaa46a5188a
ork/PeriodicWorkTest.java
ork/WorkManagerTest.java
ork/WorkTest.java
ork/impl/WorkManagerImplTest.java
87e8dc0458781cd41a5ee990be811790ac7f4e88 16-Mar-2018 Sumir Kataria <sumir@google.com> JoinWorker should pass inputs along.

Test: Added and ran tests.
Change-Id: Ib9a5d783a50aaeb89e52b9d42cdeacdb61b24577
ork/impl/WorkContinuationImplTest.java
6e977b1149cb8bca49f7db301a5f158326482f89 15-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Remove getters/setters from AlarmInfo." into flatfoot-background
135be0609e7873243ea6325a63256827d7b6839d 14-Mar-2018 Sumir Kataria <sumir@google.com> Remove getters/setters from AlarmInfo.

Short proof-of-concept of lowering method count in entities.

Test: Updated and ran tests.
Change-Id: I1911d1c8ab3356a183d0652a5c9bb4e3fb0d7c75
ork/impl/background/systemalarm/AlarmsTest.java
707219fe57da2c3b270035c109ab865f01287ae9 14-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Rename methods to be more consistent.
Test: Unit tests pass

Change-Id: If3679adb1d3c47a0c961a40787d9049d7b719c88
ork/impl/WorkManagerImplTest.java
1afd3cb3685451cf522c3ad54e1c9a2afe5a9549 14-Mar-2018 Sumir Kataria <sumir@google.com> Fix *name tests.

Insert the initial set of information using db operations
to prevent execution edge cases.

Also add some helper methods.

Test: Updated and ran tests.
Change-Id: Ia323387832c17be8c740938b90371846754460a4
ork/impl/WorkManagerImplTest.java
ba75070d771776b067cbe65d5f9e361683a026d6 13-Mar-2018 Sumir Kataria <sumir@google.com> Add getStatusesByName(Sync) methods.

Cleaned up some documentation too.

Change-Id: Icfb20ee34be921672dc11917a7d602dc49ad4653
Fixes: 74406787
Test: Added and ran tests.
ork/impl/WorkManagerImplTest.java
ccb268038bc044d0c357c7b17fa66dd1832cca5c 13-Mar-2018 Sumir Kataria <sumir@google.com> Add testCancelWorkForName(Sync) methods.

Updated codeStyleSettings to reflect ag/3730943 which
didn't get auto-merged in.

Bug: 74406787
Test: Added and ran tests.
Change-Id: Iaec64aefda9649633bbb9f9404f72edaa945fb15
ork/impl/WorkManagerImplTest.java
3665b829af9706f7f85c53e4ef5a0825228f4d7a 13-Mar-2018 Sumir Kataria <sumir@google.com> Switch beginWithUniqueTag to beginWithName.

Names are totally separated from tags: they are stored
in their own database table and they have nothing to do
with tags. This provides a firm separation between the
two and will prevent the user from shooting themselves
in the foot by being able to separately add work with
"unique" tags and screwing up their internal state.
Now, everything goes through the beginWithName methods.

In doing this work, I also cleaned up CancelWorkRunnable
so that it doesn't have an uber-constructor.

Future CLs will add cancelByName(Sync) and
getStatusesByName(Sync).

Bug: 74406787
Test: Updated and ran tests.
Change-Id: I36a284de36c87262dfbdad96236daa4a99b3abb4
ork/impl/WorkManagerImplTest.java
cc5ae8c86fd7aca80917de26548646b0a9acc498 12-Mar-2018 Sumir Kataria <sumir@google.com> Add tags to WorkStatus.

Also do some cleanup and consolidate some code around tags.

Change-Id: I48c78046899774fa0008a4977e720d90e2c16515
Fixes: 74406470
Test: Updated and ran tests.
ork/impl/WorkManagerImplTest.java
332f9d58172ad35f034bd0a08069ad733d5beeaa 10-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Check for application force-stops and reschedule workers when necessary." into flatfoot-background
21e16f32d901aee5e399832703fb935b9be63ae7 09-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Check for application force-stops and reschedule workers when necessary.

- Starting Eclair MR1, AlarmManager alarms are cancelled when the application is force-stopped by the user.
- Starting N-MR1 (API 25) JobScheduler does the same for pending jobs.
- When an instance of WorkManager is created, now WorkManager checks for force stops by using a long lived PendingIntent which won't survive force-stops and reschedules workers as required.

Test: Added unit tests. Ran Integration test app and verified behavior
Fixes: b/74407597

Change-Id: I9fe3683077325369f891c8000da7ff494382bbdd
ork/WorkSpecDaoTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/utils/ForceStopRunnableTest.java
4484814aab16eec8d004c9e560ed5e25e0272d4d 09-Mar-2018 Sumir Kataria <sumir@google.com> Split blocking methods into their own classes.

Also rename "sync" to "blocking" in method names.

This simplifies the top-level API considerably.

Test: Updated and ran tests.
Change-Id: Ib653e3759c12ba2db14b154568267c3e1226ed07
ork/impl/WorkManagerImplTest.java
19ae799361a8911480519c1c2b2e0e042e3a6239 09-Mar-2018 Sumir Kataria <sumir@google.com> Add getStatusesByTag(Sync) methods.

Renamed getStatus methods to make it clear they operate on id's.

Fixes: 74407426
Test: Added and ran tests.
Change-Id: I84602b5f9240eb35f922aff0c205d232f180d48e
ork/impl/WorkManagerImplTest.java
d64a1a65bd138cfeeb9ae6a595120b85e77a57f6 07-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Add support requiresStorageNotLow() and requiresBatteryNotLow() in API 23-25.
- API 23-25, JobScheduler does not support these constraints. So we delegate the work to a ConstraintTrackingWorker, which
uses WorkConstraintTracker to delegate to the real worker.
Test: Added unit tests.
Fixes: b/73786136

Change-Id: I47a21b790b0b9943963df780bdc888b7fc89d54b
ork/PeriodicWorkTest.java
ork/WorkTest.java
ork/impl/workers/ConstraintTrackingWorkerTest.java
19cf60893b27ea1302ddc9c9bb61897d0bd2cfd6 08-Mar-2018 Sumir Kataria <sumir@google.com> Fix NPE in getStatusSync.

Test: Added and ran tests.
Change-Id: Ifb5f9fcd9b1d5776161644e8ec0f7efc23ee478c
ork/impl/WorkManagerImplTest.java
84354e3e9958815315af523a5d169bd2ed2857be 08-Mar-2018 Sumir Kataria <sumir@google.com> Set correct initial state on enqueue.

Work with failed prerequisites should be set to failed.
Work with cancelled prerequisites should be set to
cancelled.

Test: added and ran tests.
Change-Id: Ib09da6736e6358c03f34e15cbaad16ca31e1349a
ork/impl/WorkManagerImplTest.java
3d5949e3e18fe4a190a83079bef180fae6dcb318 06-Mar-2018 Sumir Kataria <sumir@google.com> Change prune criteria.

- Add and enforce minimum retention time.
- Don't delete work if it has active dependents.

Test: added and ran tests.

Change-Id: Ia67dca28db23f60c5686eef8176fd66c44bf0db5
ork/impl/WorkManagerImplTest.java
c1ba633e4668bbf02097a76261ebcee8f3b59e06 07-Mar-2018 Sumir Kataria <sumir@google.com> Recursively fail dependents on work failure.

Work failures should trickle downstream just like cancellations.
This is also going to be needed in an upcoming CL where we will
add a minimum time to retain. Since this CL removes the need
for explicit checking of dangling blocked work when starting
WorkDatabase, we will be able to change the prune code to be:

prune if timeToRetain < now
&& (cancelled|failed|succeeded)
&& dependents.size() == 0

Test: Updated and ran tests.
Change-Id: I630898e906ac3aa3c601124ba7a816619ddbe573
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
f4ae2b7ec2f6d21ac6a7ee974fa363049ba6d12e 06-Mar-2018 Sumir Kataria <sumir@google.com> Add TimeUnits to all time-related args.

Test: Updated and ran tests.
Change-Id: I4ec8baceb0e8b8291ed8526eb68c474dac1d4a38
ork/PeriodicWorkTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/greedy/GreedySchedulerTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
d70f977a2a312353a82ffefeeef67bb23941f78e 03-Mar-2018 Rahul Ravikumar <rahulrav@google.com> Keep track of alarmIds when using SystemAlarmManager.
- When scheduling an alarm for a given WorkSpec, we now ensure that pending alarms are cancelled before creating a new alarm.
- When stopping work, alarms are also cancelled correctly now.
Test: Added unit tests.
Fixes: b/73785511

Change-Id: I163da615571b1cd6fdf14950a08e03d38ae8bb7f
ork/impl/background/systemalarm/AlarmsTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
9598ea6e2427580e555919657530dc18d237c962 23-Feb-2018 Rahul Ravikumar <rahulrav@google.com> Add RequiresApi(23) to setRequiresDeviceIdle().
- This API is only supported on API 23+.

Test: Existing unit tests pass.

Change-Id: Ib695f96e0aaccb61561e0e96c2514ea6632d8805
ork/PeriodicWorkTest.java
ork/WorkTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
df55ec7f797caa24839ed110d7a53135b7d17b0e 21-Feb-2018 Sumir Kataria <sumir@google.com> Remove PruneDatabase.

Test: Updated and ran tests.

Change-Id: I0666da36a7957161ff960e00c832b1d2406af384
ork/WorkSpecDaoTest.java
ork/impl/WorkManagerImplTest.java
eb13c8f7bca80e372c700925e2bfcfac0c908be4 22-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Rename a couple of methods." into flatfoot-background
f312aba9be105731a852edd6f8b0ce1e0b62cc70 22-Feb-2018 Sumir Kataria <sumir@google.com> Fix some bugs causing tests to fail.

1. Add missing try/catch around db transaction.
2. GreedyScheduler should listen to work execution status
to update the constraints tracker.
3. Unconstrained work should run immediately; constrained
work should not.

Test: ran tests.
Change-Id: I41a6bec90ceffdc1ef8effe3b08460453e394f90
ork/impl/background/greedy/GreedySchedulerTest.java
27b63c02cbd14fae2cbf81abd64535ff7bc1ee18 21-Feb-2018 Sumir Kataria <sumir@google.com> Rename a couple of methods.

- cancelWorkForId* -> cancelWorkById*
- getOutput -> getOutputArguments

This is based on Funtimes meeting feedback.

Test: ran tests
Change-Id: Ib0bc92ae86238f0d11515730b6c8e3aca0b0b3ed
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
4073bcac9dfc26f02133eb1e2c38ee8249b1b7f5 21-Feb-2018 Sumir Kataria <sumir@google.com> Allow GreedyScheduler to schedule work with constraints.

GreedyScheduler now matches the old ForegroundProcessor:
it takes in constrained work, but not anything dealing
with timing (periodic or initial delay work).

Test: added and ran tests.
Change-Id: Ic587d419e3ed0a21000cd9de44e2d99a212f5364
ork/impl/background/greedy/GreedySchedulerTest.java
6537acb60e0e48aab7f56ac975fda30c6a3c68cc 21-Feb-2018 Sumir Kataria <sumir@google.com> Merge "Change getInstance() to getInstance(Context)." into flatfoot-background
ff2aa51dd252afd6f7d1c3516a06a1f1cf3e9e7d 21-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Reschedules alarms when BOOT_COMPLETED, TIMEZONE_CHANGED, and TIME_SET. Test: Updated unit tests. Fixes: b/73313567" into flatfoot-background
c70260475b81e588a94c6e5826291d4e7f1849f8 17-Feb-2018 Rahul Ravikumar <rahulrav@google.com> Reschedules alarms when BOOT_COMPLETED, TIMEZONE_CHANGED, and TIME_SET.
Test: Updated unit tests.
Fixes: b/73313567

Change-Id: I5b81cd67e475816e727286d354a8f491e100ed94
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
c68c7cd32c73a927f4bb73272a11d82ee7890add 21-Feb-2018 Sumir Kataria <sumir@google.com> Double-schedule jobs on API 23 to overcome bugs.

API 23 JobScheduler only kicked off jobs if there
were at least two jobs in the queue, even if the
job constraints were met. This behavior was
considered undesirable and later changed in
Marshmallow MR1. To match the new behavior, we
double-schedule jobs on API 23 and dedupe them
in SystemJobService as needed.

The JobScheduler behavior was fixed in ag/794033.

Change-Id: I5dc3049f65e5716258ab6de02b53d502e670f389
Fixes: 73383970
Test: Added and ran tests.
ork/impl/background/systemjob/SystemJobSchedulerTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
515ed7401d62081fb2cdd34fc8df325ed8943719 20-Feb-2018 Sumir Kataria <sumir@google.com> Change getInstance() to getInstance(Context).

This removes the ContentProvider-initialized singleton in the
manifest. In general, we are prioritizing faster startup over
the marginal readability improvement. There was some concern
in previous Googler studies about "which context", "will it
be cached and scoped to this lifecycle", etc. We believe that
the documentation is sufficiently clear on this. In addition,
this follows a common pattern in Android apps.

Test: Updated and ran tests.

Change-Id: I5f24724934ed1e16bddb0d9906326ad2e54e398d
ork/impl/background/systemjob/SystemJobServiceTest.java
587711f9d58878042a4f1ba399bd428be55d2314 20-Feb-2018 Sumir Kataria <sumir@google.com> Mark content uri methods as @RequiresApi(24).

Test: ran tests.
Change-Id: I83f4908b19221ff064aa04c7be8f546fb31e1757
ork/impl/WorkManagerImplTest.java
c4de263bc3abaf06ee41a2835c471752a1825e0c 15-Feb-2018 Sumir Kataria <sumir@google.com> Change min JobScheduler API level back to 23.

There is a bug we need to fix for API 23 that
will happen in another CL. (See b/73383970.)

Bug: 73383970
Test: Ran tests.
Change-Id: I35096bfc11a06f10bc9d53f16741243c86ec6e5e
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
188b6fb0e5da3723f28c23289b5b55086210e82c 16-Feb-2018 Sumir Kataria <sumir@google.com> Rename directories and references from background -> work.

Test: Ran tests.

Change-Id: Ibde6b2f3c7ecbc2490d4225418a1e24119e4a72a
ork/DatabaseTest.java
ork/PeriodicWorkTest.java
ork/TestLifecycleOwner.java
ork/WorkManagerTest.java
ork/WorkSpecDaoTest.java
ork/WorkSpecTest.java
ork/WorkTest.java
ork/impl/ProcessorTest.java
ork/impl/WorkContinuationImplTest.java
ork/impl/WorkManagerConfigurationTest.java
ork/impl/WorkManagerImplTest.java
ork/impl/WorkerWrapperTest.java
ork/impl/background/systemalarm/SystemAlarmDispatcherTest.java
ork/impl/background/systemalarm/WorkTimerTest.java
ork/impl/background/systemjob/SystemJobInfoConverterTest.java
ork/impl/background/systemjob/SystemJobServiceTest.java
ork/impl/constraints/WorkConstraintsTrackerTest.java
ork/impl/constraints/controllers/ConstraintControllerTest.java
ork/impl/constraints/trackers/BatteryChargingTrackerTest.java
ork/impl/constraints/trackers/BatteryNotLowTrackerTest.java
ork/impl/constraints/trackers/ConstraintTrackerTest.java
ork/impl/constraints/trackers/NetworkStateTrackerTest.java
ork/impl/constraints/trackers/StorageNotLowTrackerTest.java
ork/impl/logger/LoggerTest.java
ork/impl/utils/EnqueueRunnableTest.java
ork/impl/utils/IdGeneratorTest.java
ork/impl/utils/LiveDataUtilsTest.java
ork/impl/utils/taskexecutor/InstantTaskExecutorRule.java
ork/worker/ChainedArgumentWorker.java
ork/worker/EchoingWorker.java
ork/worker/FailureWorker.java
ork/worker/InfiniteTestWorker.java
ork/worker/RetryWorker.java
ork/worker/SleepTestWorker.java
ork/worker/TestWorker.java