If Bitmap.createBitmap() or loadTexture() threw (e.g. OutOfMemoryError)
while building the GLPicture tiles Array, any textures already uploaded
to the GPU in previous iterations were abandoned because the tiles field
was never assigned and recycle() could not be called. Switched from the
Array{} lambda (which only exposes partial state through the exception)
to an explicit loop that tracks created tiles in a List, and added a
catch-rethrow that deletes all partial textures before propagating.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If onStartCommand received a null intent (possible when START_STICKY
restarts a killed service) or an unrecognized action, the service would
start foreground (showing a persistent notification) but never call
stopSelf(), leaving it running indefinitely. Added an else branch to
call stopSelf(startId) immediately in these cases.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ChangeWallpaperUseCase and ReapplyEffectsUseCase both leaked the
processedBitmap when processBitmap() or adaptiveBrightnessAdjustment()
threw an exception — the outer catch returned Result.Error without
recycling the allocated bitmap. Added an inner try-catch-rethrow that
recycles whichever bitmap is live at the point of failure before
re-throwing so the outer handler can record the skip.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- QueueBuilder: convert List.contains to HashSet lookups in mergeWithExistingQueue
and mergeWithExistingQueueDeterministic (O(n²) → O(n))
- AlbumRefreshWorker: load existing folder URIs once per folder with
getExistingWallpaperUris() instead of one DB query per scanned wallpaper (N+1 → 1)
- WallpaperEntity: remove unused cropOffsetX/Y/Scale columns (always null, never read)
- DATABASE_VERSION bumped to 4; fallbackToDestructiveMigration handles upgrade
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Local `val wallpapers` shadowed the `StateFlow<List<Wallpaper>> wallpapers`
class property, making it hard to tell which was being referenced.
Renamed to `newWallpapers` for clarity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- PaperizeLiveWallpaperService: stop permanently deleting wallpapers when
URI is transiently inaccessible; now skips the cycle like ChangeWallpaperUseCase does.
AlbumRefreshWorker handles authoritative URI pruning on its daily run.
- WallpaperEffects/PreferencesManager/WallpaperScreen: rename enableChangeOnScreenOn
→ enableChangeOnScreenOff to match actual trigger (ACTION_SCREEN_OFF).
DataStore key string is unchanged so existing user prefs are preserved.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This position-based delete was superseded by deleteQueueItem (which
deletes by wallpaperId) and has zero call sites. Removing it
eliminates confusion about which dequeue strategy is active.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WallpaperChangeService already guards against the case where home and
lock albums diverge in BOTH mode. WallpaperChangeWorker was using
homeAlbumId unconditionally, silently applying the wrong album to the
lock screen during transient state transitions. Add the same guard
and fall back to independent per-screen changes when albums differ.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fastRoundToInt() can round the inSampleSize ratio UP, causing the
decoded bitmap to be smaller than the target screen dimensions and
requiring upscaling. Integer division always floors, guaranteeing
the decoded bitmap is at least as large as needed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WallpaperChangeService and WallpaperChangeWorker each had their own
private companion-object Mutex, so simultaneous runs (manual change +
scheduled worker) were not mutually excluded. Extract a @Singleton
WallpaperChangeLock and inject it into both so the same Mutex is used
across all wallpaper-change entry points.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>