Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class BootReceiver : BroadcastReceiver() {
Logger.i { "BootReceiver: Device booted, update check disabled — skipping" }
UpdateScheduler.cancel(context)
}
} catch (t: Throwable) {
// Don't let scheduling failures crash the framework's
// broadcast pipeline — propagation triggers a second
// `sendFinished` from the platform after our own
// `pendingResult.finish()` and surfaces as
// `IllegalStateException: Broadcast already finished`.
Logger.e(t) { "BootReceiver: scheduling failed; dropped" }
} finally {
pendingResult.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ object UpdateScheduler {
request = request,
)

// Note: an expedited request CANNOT carry an initial delay —
// WorkManager throws `IllegalArgumentException: Expedited jobs
// cannot be delayed` at build time. Drop the cold-start backoff
// and let the OS scheduler dispatch as soon as the network
// constraint is satisfied; on aggressive-OEM ROMs the expedited
// tier is what actually gets the work to run.
val immediateRequest =
OneTimeWorkRequestBuilder<UpdateCheckWorker>()
.setConstraints(constraints)
.setInitialDelay(1, TimeUnit.MINUTES)
// Aggressive-OEM ROMs (Oppo / OnePlus / Realme / Xiaomi)
// throttle generic background work hard. Expedited tier
// gets more headroom; fall back to non-expedited when
// the system has no expedited budget left so the work
// still runs eventually rather than failing outright.
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.build()

Expand Down