DEV Community

Shalina Bhargava
Shalina Bhargava

Posted on AI-assisted

Slothie: an on-device Gemma 4 sloth that learns your risky phone hours

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge: Week 3, theme: Slow and Steady.

What I Built

Slothie is a sloth that lives in your Android phone. It works out the hours of the day when you are most likely to reach for the phone, tells you which apps are behind each one, and a few minutes before those hours it sends a nudge with a one-tap nap: Do Not Disturb, held for 30 or 60 minutes, released by itself.

The whole thing is built around one lazy idea: the phone already knows. Android keeps a log of which app was in front and when. Slothie reads that log on the device, slices it into a day-by-hour grid, and asks a simple question of each hour: on what share of days did you spend five or more minutes here? Rank by that chance times the usual minutes, skip the neighbours of a stronger hour, and you get your three risk hours. Mine, the morning I took the screenshots: 2 AM (85% of days, YouTube, Chrome and Netflix), 6 PM (83%, WhatsApp, Chrome and YouTube) and midnight (85%, Chrome, YouTube and WhatsApp). Yesterday these times looked like 3 AM, 7 PM and 10 PM.

To get the mood of the hour, slothie shows 4 moods: asleep when you are barely on the phone, chill at your normal pace, one eye open when a risky hour is close, wide awake with a sweat drop when you are well past normal.

Why not digital wellbeing: The digital wellbeing app gives statistics that might sound scary but also unattainable and actionable, the gentle nudge with slothie actually finds the pattern and gives you a decision.

Demo

Slothie demo: the Today tab, the sloth waking up, a risk-hour nudge and a one-tap nap

Today Hours Apps
Today tab: the sloth, pace against your usual, and the note Gemma wrote Hours tab: the three risk hours with their odds and the apps behind them Apps tab: Gemma sorted the apps into categories, with manual overrides

A word from Slothie: the note Gemma 4 wrote on the phone, from the numbers above it

Code

Slothie 🦥

A sloth that lives in your phone, learns the hours you are most likely to pick it up, and talks you into doing less. Everything, including the language model, runs on the phone.

Slothie reads Android's own usage log (the one Digital Wellbeing reads), turns it into an hour-by-hour picture of your week, and finds your risk hours: the hours of the day when you are most likely to be on the phone, and for how long. A few minutes before each one it sends a nudge with a one-tap nap, which holds Do Not Disturb for a while and lets go by itself.

Gemma 4 E2B, an open-weight model under Apache 2.0, runs on the device through LiteRT-LM. It writes the sloth's daily note and sorts your apps into categories. It never computes a number every statistic is Kotlin, and the model is handed finished…

MIT licensed. Kotlin, Jetpack Compose, no backend, no accounts.

How I Built It

The open-weight part. Slothie runs Gemma 4 E2B on the phone through LiteRT-LM, Google's on-device runtime. The weights are the Apache 2.0 release on Hugging Face, 2.6 GB, downloaded once from inside the app over Wi-Fi (or pushed with adb). The GPU backend is tried first and CPU is the fallback. On a Pixel 9 the first load takes a few seconds and the note streams in at a comfortable reading pace.

Gemma does two jobs:

  1. Writes the sloth's note. It receives a small JSON of integers and app names (today's minutes, usual minutes by this time of day, pickups, longest break, the three risk hours with their odds and apps) and is asked for three short paragraphs: the riskiest hour, one lazy thing to do about it tonight, and one honest line about today.
  2. Sorts your apps. It gets the list of app labels and package names and returns a JSON array of categories: Feed, Video, Game, Chat, Tool, Work, Health. Your own choices always override it.

The deterministic part. Every number is computed in Kotlin from UsageStatsManager.queryEvents. One app is in front at a time, so a resume closes whatever was open; screen-off and lock close everything; blips under three seconds are dropped. Sessions are sliced at hour boundaries into a minutes[day][hour] matrix. Hours that have not happened yet today are not counted as observed, so the morning never drags down the evening. There are unit tests for all of it.

The split is deliberate and it is the same rule I would apply to any assistant that reads personal data: the model is a writer and a sorter, never an accountant. If a figure is not in the JSON it is not in the note. The system prompt says so, and because the weights and the prompt are both open you can check.

Nudges and naps. Inexact AlarmManager windows, twelve minutes before each risk hour, re-armed daily and after reboot. The nap action flips NotificationManager.setInterruptionFilter to priority-only, schedules its own end, and posts an ongoing notification so you can end it early. No accessibility service, no overlay, no app blocking: a sloth does not fight you, it just makes the quiet option the easy one.

Why Does Open Innovation Matter?

A phone usage log is a diary. It says when you sleep, what you doom scroll, when you are at work and when you are not. I did not want to upload that to anyone, including a model provider, and I did not want to pay per token for a sloth to tell me to go to bed.

Open weights make both problems go away. The model is on my phone, so the app works in airplane mode and the INTERNET permission exists for exactly one request: downloading the weights. There is no key to leak, no bill, no rate limit, and no terms-of-service change that can hid it behind a paywall. And because the weights are Apache 2.0, the prompt is in the repo, and the runtime is open source, the promise "the model never invents a number" is something you can read rather than something you have to trust.

A closed API could have written a nicer paragraph. It could not have done it on a phone with the radio off.

The Lazy Payoff

Slothie measures its own payoff with the same log it reads. The "Longest break" tile on the Today tab is the longest stretch since your first pickup without the phone; the risk-hour odds move as the days roll. The honest number from day one on my phone: 7 h 49 m by mid-afternoon against a usual 3 h 50 m, which is why the sloth was wide awake and asked to be put down.

Effort saved: the three risk hours and the apps behind them took Android's own log plus about forty lines of Kotlin to find. I had never noticed the 3 AM one.

Prize Categories

  • Best Use of Gemma

Top comments (0)