Skip to content

fix: refresh widgets after idle#978

Draft
ovitrif wants to merge 1 commit into
masterfrom
codex/github-mention-bug]-android-os-widgets-show-stale-data-af
Draft

fix: refresh widgets after idle#978
ovitrif wants to merge 1 commit into
masterfrom
codex/github-mention-bug]-android-os-widgets-show-stale-data-af

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented May 31, 2026

Motivation

  • Android home-screen widgets could show stale data after the device stayed idle because periodic WorkManager refreshes are deferred by the OS and there was no catch-up on unlock or idle-exit.

Description

  • Add AppWidgetRefreshReceiver that enqueues a one-shot widget catch-up when Intent.ACTION_USER_PRESENT or PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED (idle exit) occurs.
  • Add enqueueCatchUp one-time WorkManager path to AppWidgetRefreshWorker and hasActiveWidgets/cancel logic so catch-up runs only when OS widgets are installed and the catch-up work is cancelled when no widgets remain.
  • Register the receiver at app startup (App.registerAppWidgetRefreshReceiver) and trigger the same catch-up when the app returns to foreground (AppWidgetRefreshWorker.enqueueCatchUp(context) in ContentView ON_START handler).
  • Add Context.powerManager extension and a changelog fragment changelog.d/next/os-widget-idle.fixed.md describing the user-facing fix.

Testing

  • git diff --check was run and produced no whitespace errors.
  • Attempted ./gradlew compileDevDebugKotlin, ./gradlew testDevDebugUnitTest, and ./gradlew detekt, but they failed to run in this environment due to inability to resolve the Gradle plugin org.gradle.toolchains.foojay-resolver-convention:1.0.0 from configured repositories.
  • No unit or detekt results were produced because of the plugin resolution failure.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant