Android app: expedited tasks fail on Android 11 and below, so channel import never starts
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: release-v0.20.x
Observed behavior
- On Android 11 (API 30), Device > Channels > IMPORT > Kolibri Studio (online) > CONTINUE > SELECT RESOURCES stays on "Generating channel listing. This could take a few minutes" indefinitely, including after a force-stop and relaunch.
- Every expedited task that is not
longRunningfails as soon as WorkManager starts it. This includeskolibri.core.content.tasks.remotechannelimportand the startup jobskolibri:job:1000andkolibri:job:1001. Task.javaL50-71 callssetExpeditedonBackgroundWorker, andBackgroundWorkerdoes not overridegetForegroundInfo(). On API < 31, WorkManager runs expedited work as a foreground service and calls that method.
Errors and logs
D Kolibri.Task: Enqueued unique task d974e6ab89bb483e823eafcea39ba9dd (func=kolibri.core.content.tasks.remotechannelimport, delay=0.0s, expedite=true, longRunning=false)
E WM-WorkerWrapper: Work [ id=8c4dd841-..., tags={ kolibri:job:d974e6ab89bb483e823eafcea39ba9dd,org.learningequality.Kolibri.workers.BackgroundWorker } ] failed because it threw an exception/error
E WM-WorkerWrapper: java.lang.IllegalStateException: Expedited WorkRequests require a Worker to provide an implementation for `getForegroundInfo()`
E WM-WorkerWrapper: at androidx.work.Worker.getForegroundInfo(Worker.kt:86)
User-facing consequences
- Admins on Android 7–11 devices (
minSdkis 24) cannot import channels from Studio or a peer Kolibri server (both runremotechannelimport), so learners have no content.
Steps to reproduce
- Install the Android app on an API 30 emulator and complete setup.
- Open Device > Channels > IMPORT, choose Kolibri Studio (online), tap CONTINUE.
- Tap SELECT RESOURCES on any channel.
- Run
adb logcat | grep WM-WorkerWrapper.
Context
- Kolibri
0.20.0a2.dev1733+g730552a93, Android app debug build,androidx.work:work-runtime:2.11.0. - Emulator: Android 11 (API 30), x86_64.
Acceptance Criteria
- [ ] On API 30, SELECT RESOURCES on a Studio channel finishes generating the listing and shows the channel's topics.
- [ ] On API 30, importing a channel from Studio completes, and its resources open in Learn.
- [ ] logcat on API 30 shows no
Expedited WorkRequests require a Worker to provide an implementationerror for any Kolibri task, startup jobs included. - [ ] Expedited tasks still run expedited on API 31+.
- [ ] A test fails without the fix on API < 31.
AI usage
Claude Code found this during manual QA of the Android API 36 branch on an API 30 emulator, read the logcat, traced the failure to Task.java/BackgroundWorker, and drafted this issue.
Cause: regression from the Chaquopy migration.
- Before: the p4a
Builder.getWorkerClass()sentlongRunning || expeditetasks toForegroundWorker, which implementsgetForegroundInfo(). - After:
Task.javapicks the worker fromlongRunningalone, so expedited short tasks land onBackgroundWorker. - API 31+ runs expedited work as JobScheduler expedited jobs and never calls
getForegroundInfo(), so only API 24–30 breaks. work-runtimewas 2.11.0 before and after.
Fix: restore longRunning || expedite in the worker class selection in Task.java.
Plan: Expedited Kolibri tasks run on API 24–30 instead of failing with Expedited WorkRequests require a Worker to provide an implementation for getForegroundInfo().
- [ ] Select ForegroundWorker for expedited tasks, with a regression test
- [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
expedite=truewithdelay>0still routes toForegroundWorker(p4a parity); if that is wrong, delayed high-priority tasks show a needless notification and the rule should belongRunning || (expedite && delay <= 0).- Test reaches the request via a new package-private
Task.buildWorkRequest; if refactoringenqueueOnceis unwanted, the test must mockRemoteWorkManagerto capture the request. - Adds test-only dep
androidx.work:work-testing:2.11.0on a release branch; if unwanted, the test asserts the WorkSpec's worker class name instead ofgetForegroundInfoAsync(). - API 30 channel-import ACs are verified by human QA on the CI-built APK; if an agent must show them, it needs an emulator the sandbox can't provide.
Written by rtibblesbot, an LLM-based coding agent.
Fixed in #15766