Context
The PocketClaw dashboard displays a process list showing running Android services and their memory usage. On the Moto E2's 4.5-inch 540x960 screen, space is extremely limited. Raw Android package names like com.google.android.gms.persistent or com.motorola.android.providers.settings take up most of the screen width, leaving no room for memory values.
Android package names follow a reverse-domain convention that adds 15-30 characters of redundant prefix to every name. A cleanup pass makes the dashboard actually usable.
Implementation
Apply a regex chain to each process name before displaying it. The chain strips common prefixes in order from most specific to least:
// In dashboard rendering code (hijack.js or launcher):
function cleanProcessName(name) {
return name
.replace(/^com\.android\./, "")
.replace(/^android\.process\./, "")
.replace(/^com\.motorola\./, "moto.")
.replace(/^com\.google\.android\./, "goog.")
.replace(/^com\.pocketclaw\./, "")
.replace(/^com\.qualcomm\./, "qc.")
.replace(/^com\.termux\.?/, "termux");
}
// Examples:
// "com.android.systemui" -> "systemui"
// "com.google.android.gms.persistent" -> "goog.gms.persistent"
// "com.motorola.process.system" -> "moto.process.system"
// "com.pocketclaw.launcher" -> "launcher"
// "com.termux" -> "termux"
// "com.qualcomm.qcrilmsgtunnel" -> "qc.qcrilmsgtunnel"The order matters — more specific prefixes are checked first so com.google.android.* matches before the fallthrough.
Verification
# Check the dashboard output on port 9003:
curl -s http://localhost:9003/dashboard | grep -o 'class="proc-name">[^<]*'
# Expected: cleaned names like "systemui", "goog.gms", "termux"
# Verify no raw "com.android" names remain:
curl -s http://localhost:9003/dashboard | grep "com\.android\."
# Expected: no output (all names cleaned)Gotchas
- The regex chain must be applied in order. If you check
com.android.beforecom.google.android., Google packages won't match their specific prefix - Some package names don't follow the
com.*convention (e.g.,android.process.media). Theandroid.process.rule catches these - On the native launcher (Hack #40), the cleanup runs in Java. The regex is the same but uses Java's
String.replaceFirst()syntax - Don't strip too aggressively — names like
system_serverorzygoteshould remain as-is (they don't match any prefix)
Result
| Metric | Before | After |
|---|---|---|
| Avg name length | ~35 chars | ~12 chars |
| Readable on 4.5" screen | No | Yes |
| Process list visible | 3-4 entries | 8-10 entries |