2

Since my App has to be available for Android versions 4.x I cannot rely solely on the JobScheduler for background activity. The Firebase JobDispatcher is backwards compatible with the versions I need, so I tested it a bit.

My expectation was, that its using Google Play Services when on Android <5 and the JobScheduler API when 5+, as seen on this slide from the Android battery and memory optimizations talk on Google I/O 2016.

Jobs which I schedule in my own app using the JobDispatcher and the testapp, which comes with the Firebase JobDispatcher, do work. I don't see any activity when calling adb shell dumpsys jobscheduler. When I am using the JobScheduler directly I can see the jobs there without a problem.

So I guess the slide I linked above is wrong? Is it possible to let the JobDispatcher use the JobScheduler when on Android 5+? Maybe with a custom driver?

Henning
  • 2,202
  • 1
  • 17
  • 38
  • 1
    Well there is hope that google delivers a JobScheduler driver: https://github.com/firebase/firebase-jobdispatcher-android/issues/32#issuecomment-249266296 – Henning Sep 28 '16 at 07:30

1 Answers1

0

I get console output on Android 7.1.1 ...not too less:

adb shell dumpsys jobscheduler | grep x\ active

On past SDK versions dumpsys jobscheduler probably just cannot dump what is not there (booting such SDK versions and then issuing the command would show, since when it works).

While since Android 7.0.0 there is a new command for the jobscheduler:

adb shell cmd jobscheduler help

Job scheduler (jobscheduler) commands:
  help
    Print this help text.
  run [-f | --force] [-u | --user USER_ID] PACKAGE JOB_ID
    Trigger immediate execution of a specific scheduled job.
    Options:
      -f or --force: run the job even if technical constraints such as connectivity are not currently met
      -u or --user: specify which users job is to be run; the default is the primary or system user

The job scheduler and the job dispatcher are two whole different things; the dispatcher already is the driver for backwards-compatibility (therefore one can not expect the OS to have the scheduler).

See JobSchedulerShellCommand.java or this answer might explain it further.

The android-job library also does quite the same, in general.

Community
  • 1
  • 1
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Thank you for your answer. With 'I don't see any activity in the shell' I meant for my app. Without a proper JobScheduler Driver the JobDispatcher ist pretty useless right now. I build a rudimentary Scheduler-Driver for it myself but I am dissapointed nonetheless. There is close to no activity on the GitHub project and the promised functionality are [still missing a year later](https://github.com/firebase/firebase-jobdispatcher-android/issues/32). In hindsight I should have used the Evernote Android-Job library. – Henning Mar 17 '17 at 12:28