Android-job: Injecting time externally

Created on 17 Jul 2018  路  3Comments  路  Source: evernote/android-job

This library uses time from com.evernote.android.job.util.Clock instances, and defaults to Clock.DEFAULT which uses System.currentTimeMillis() - that can be inaccurate as user can change their device clock.

We're looking to use TrueTime (https://github.com/instacart/truetime-android), which has an API like TrueTimeRx.now() to get currentTimeMillis. Is there a way to use TrueTime with Android-Job?

There's a JobConfig#setClock(Clock) method, but with @VisibleForTesting scope. Is it the correct hook to implement this functionality?

question

Most helpful comment

Deprecated doesn't mean it stops working ;-) I'm pretty sure that we'll use both in our code base for a longer time.

All 3 comments

Yes, that's the right hook, but it's not a supported API. You can try it, though. FYI, I also don't plan to expose this API as most people don't need it and this library will be deprecated sooner rather than later.

Sad that this library will be deprecated, as WorkManager doesn't have many features like exact jobs, daily jobs etc. 馃槥

Deprecated doesn't mean it stops working ;-) I'm pretty sure that we'll use both in our code base for a longer time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karntrehan picture karntrehan  路  5Comments

froesmatheus picture froesmatheus  路  4Comments

ruhul015 picture ruhul015  路  4Comments

mohamadk picture mohamadk  路  6Comments

krokyze picture krokyze  路  3Comments