SmartIndex

Keeps Smart Search's index current, in the background, with nothing for the user to do:

  • Backlog (everything not indexed yet) runs only while charging and the battery isn't low, so a first index of thousands of photos and videos never costs battery; unless the user turns on Index on Battery (Settings → Smart Search), which drops the charger rule.

  • New items: MediaStore wakes Lumen shortly after a photo or video is added; up to NewLimit get indexed right away, charging or not. More than that waits for the charger.

  • Scheduled Indexing (Settings): the backlog runs only in the user's hours (overnight, say), plugged in or not; a small job wakes Lumen at the window's start and end. Both resume where they stopped. Scheduled at app start and when a model finishes downloading.

Types

Link copied to clipboard
Link copied to clipboard

Wakes at a Scheduled Indexing edge: starts or stops the backlog, and arms the next edge.

Properties

Link copied to clipboard
val faceProgress: StateFlow<IndexProgress?>

The same for finding faces (FaceIndexer).

Link copied to clipboard
val progress: StateFlow<IndexProgress?>

Latest counts from a pass (null until one runs in this process).

Link copied to clipboard
val textProgress: StateFlow<IndexProgress?>

The same for reading text in photos (TextIndexer).

Functions

Link copied to clipboard
fun cancel(context: Context)
Link copied to clipboard
fun report(context: Context, indexed: Int, total: Int)
Link copied to clipboard
fun reportFaces(context: Context, done: Int, total: Int)
Link copied to clipboard
fun reportText(context: Context, read: Int, total: Int)
Link copied to clipboard
fun schedule(context: Context, replace: Boolean = false)

Makes sure both jobs are queued, if a search, text or face model is installed. Safe to call often (app start). A backlog job waiting out a back-off is replaced by a fresh one, so opening Lumen restarts a stalled index; a running one is left alone.

Link copied to clipboard
fun startNow(context: Context)

After a model download: start indexing the newest items right away, charging or not.