The rotation service now responds to screen on/off events via a dedicated ScreenOnRotationService, reducing background work and avoiding perpetual wakeful states. Manifest and receiver logic were adjusted to align with the new behavior and energy constraints. Scheduling and enablement now consistently use timed-based rules and screen-on preferences, with the boot and alarm paths updated to honor these settings. This avoids unnecessary foreground services and keeps the app compliant with Doze and battery optimizations. Immich image handling improvements include throttled progress updates, larger cache allowances, and a connectivity-aware automatic download check to avoid unwanted network usage. - Use ScreenOnRotationService for screen-on based rotation scheduling - Centralize enablement via timed-enabled paths and AlarmManager windowing - Improve Immich cache and progress reporting with connectivity checks
32 lines
1023 B
Kotlin
32 lines
1023 B
Kotlin
package de.wechselbild.wallpaper
|
|
|
|
import android.content.Context
|
|
import androidx.work.ExistingWorkPolicy
|
|
import androidx.work.Constraints
|
|
import androidx.work.OneTimeWorkRequestBuilder
|
|
import androidx.work.WorkManager
|
|
import androidx.work.Worker
|
|
import androidx.work.WorkerParameters
|
|
|
|
class WallpaperRotationWorker(context: Context, parameters: WorkerParameters) : Worker(context, parameters) {
|
|
override fun doWork(): Result {
|
|
if (!WallpaperStore.timedEnabled(applicationContext)) return Result.success()
|
|
WallpaperStore.applyNext(applicationContext, automatic = true)
|
|
return Result.success()
|
|
}
|
|
|
|
companion object {
|
|
private const val WORK_NAME = "wallpaper-rotation"
|
|
|
|
fun enqueue(context: Context) {
|
|
WorkManager.getInstance(context).enqueueUniqueWork(
|
|
WORK_NAME,
|
|
ExistingWorkPolicy.KEEP,
|
|
OneTimeWorkRequestBuilder<WallpaperRotationWorker>()
|
|
.setConstraints(Constraints.Builder().setRequiresBatteryNotLow(true).build())
|
|
.build(),
|
|
)
|
|
}
|
|
}
|
|
}
|