Repository navigation
v0.4.4
AltShift v0.4.4 — feature and hardening release for Android 8.0+ since v0.4.2. It adds unlock-resilient recovery via USER_PRESENT, a temporary specialUse foreground-service watchdog that survives the Android 12+ Cached Apps Freezer, a theme-aware responsive Dynamic Island, split inactive-keyboard alerts, shortcut conflict prevention, and off-main-thread onboarding and app-picker loading with lazy icon decoding and no QUERY_ALL_PACKAGES. Transliteration, hotkey dispatch, and the zero-daemon typing path are unchanged.
🧊 Standby Watchdog & Unlock Recovery
KeyboardWatchdogService(specialUse): Keeps the process unfrozen while onboarding is complete, AltShift is enabled but another IME is selected, and at least one switch/overlay/alert path is usable. Stops immediately viastopSelf()once AltShift becomes the active IME, onboarding is reset, or no reconnect/alert path remains.- State-aware silent status: Posts on
altshift_keyboard_watchdog(IMPORTANCE_MIN, ongoing,FOREGROUND_SERVICE_IMMEDIATEon API 31+), showing "Waiting for physical keyboard" when detached and "Monitoring keyboard connection" while attached with another IME active. Updates vianotify()only on state changes; uses zero polling, timers, or wake locks, with guardedstartForegroundService()/startForeground()calls. - Disconnect & reconnect cleanup: Detach cancels any stale "AltShift is inactive" alert and reconciles with
present = false; attach either stops the watchdog (if AltShift switched back) or reconciles withpresent = trueand shows the Dynamic Island again. USER_PRESENTwake-up: Handled in the manifest and via a process-local receiver registered inAltShiftApplication.onCreate()(RECEIVER_EXPORTEDon Android 13+) so screen unlock wakes frozen processes and restores AltShift (or surfaces the Dynamic Island) whenever a physical keyboard is attached.
📱 Responsive Dynamic Island & Split Alerts
- Theme-aware capsule:
KeyboardPromptOverlayapplies the persistedThemeMode(LIGHT/DARK/FOLLOW_SYSTEM) before inflating, uses dedicatedprompt_surface(#F4F3FA/#252630) andprompt_stroke(#1F1B1B21/#24FFFFFF) tokens, applies explicitsetImageTintList()for icons, and renders a4dpshadow inside clip-free24dp/14dp/28dppadding aty = max(0, bottomInset() - 20dp). - Phone & tablet sizing: Phones use the inset width (
0dpminWidth) and ellipsize the message before clipping actions;sw600dp+uses an exact420dpcapsule with Switch back and[X]pinned to the right12dpedge. Repeated prompts refresh callbacks and reset the 12-second timer, with cleanup on inflation/window failures. - Split inactive alerts (shared id
1001): Dismissing ([X]) or timing out posts a dismissibleIMPORTANCE_DEFAULTreminder onaltshift_keyboard_alerts_v2; cancelling the system IME picker fromSwitchBackActivitywithout selecting AltShift posts anIMPORTANCE_HIGHheads-up onaltshift_keyboard_alerts_urgent(withoutsetOnlyAlertOnce(true)). Cancelled automatically when AltShift activates or the keyboard detaches.
🔐 Permissions, Performance & Integrity
QUERY_ALL_PACKAGESremoved: Replaced with a narrow launcher<queries>block. Still declares noINTERNETpermission; addsFOREGROUND_SERVICEandFOREGROUND_SERVICE_SPECIAL_USE.- Off-main-thread UI & lazy icons: Onboarding IME checks and app-picker label queries run on background executors.
AppPickerDialogandHotkeyAdaptermigrate toListAdapter+DiffUtiland decode icons lazily per bound row with boundedLruCaches (48/32entries, 2 daemon threads) and clean teardown. - Shortcut conflict prevention: Pure-JVM
HotkeyBindingStoreandHotkeyBinding.conflictsWith()prevent app hotkeys and the language switch from sharing a combination (with modifier-order equivalence). - Lifecycle & guidance:
BootReceiverfilters strictly forBOOT_COMPLETED/USER_PRESENT;HardwareInputServicereconciles the watchdog on IME release and logs nullInputConnectionreturns; onboarding and README note the OEM Auto-start toggle for Lenovo ZUI, Xiaomi HyperOS, and ColorOS.
🧪 Build, Tests & Verification
- Version & cleanup:
versionCode 11,versionName '0.4.4'(AltShift-v0.4.4.apk/AltShift-v0.4.4-debug.apk). Toolchain unchanged (minSdk 26,targetSdk 34, Java 21, Gradle 8.9, AGP 8.7.3). Removed obsoletebg_prompt_pill.xml; updatedREADME.md(with measured memory/CPU breakdown) andSTYLEGUIDE.md(watchdog,USER_PRESENT,≤ 64 MBPSS budget, overlay, and alert contracts). - Automated checks:
./gradlew clean test lintDebug assembleDebugand post-merge./gradlew test lintDebug assembleDebugpassed with 0 Lint issues and expandedHotkeyBindingStoreTestandModelTestJVM suites. - Device verification (Lenovo TB710FU, Android 16, 2000×3200, 400 dpi, debug APK):
- Typing (active IME):
2041 KBJava heap,7382 KBnative heap,41773 KBTotal PSS,0 KBGraphics, 0.0% idle CPU. - Standby watchdog (detached):
3629 KBJava heap,9171 KBnative heap,52601 KBTotal PSS,0 KBGraphics, 0.0% idle CPU. - App picker peak:
5153 KBJava heap,50832 KBnative heap,360592 KBTotal PSS. - Verified Light/Dark Dynamic Island override,
420dptablet alignment,8dpinset clearance, 12s timeout and[X]standard reminders, cancelled-picker heads-up alert, and physical pogo-pin detach/reattach transitions.
- Typing (active IME):
- Remaining manual checks: Phone-width (
< 600dp) ellipsis with updated outer padding and attach/detach on non-Lenovo OEMs.
📥 Installation
| Asset | Description |
|---|---|
AltShift-v0.4.4.apk |
Release build, R8-minified, signed with the CI release keystore. |
AltShift-v0.4.4-debug.apk |
Debug build, unminified, signed with the local debug key. |
adb install -r AltShift-v0.4.4.apk
adb shell ime enable ru.b1sted.altshift/.service.HardwareInputService
adb shell ime set ru.b1sted.altshift/.service.HardwareInputServiceOptional provisioning grants:
adb shell pm grant ru.b1sted.altshift android.permission.WRITE_SECURE_SETTINGS
adb shell pm grant ru.b1sted.altshift android.permission.POST_NOTIFICATIONS
adb shell appops set ru.b1sted.altshift SYSTEM_ALERT_WINDOW allow
adb shell cmd deviceidle whitelist +ru.b1sted.altshiftNote: Debug and release APKs use different signing keys (
adb uninstall ru.b1sted.altshiftis required when switching between them). Uninstalling clearsaltshift_prefs,WRITE_SECURE_SETTINGS, and the battery exemption.
🔨 Building from Source
Requires JDK 21, Android SDK Platform 34 (Build-Tools 34.0.0), and sdk.dir in local.properties:
./gradlew test lintDebug assembleDebug
# Or signed release (with KEYSTORE_FILE / KEYSTORE_PASSWORD / KEY_ALIAS / KEY_PASSWORD or scripts/build-release.sh):
./gradlew assembleRelease⚠️ Notes & Limitations
- Temporary watchdog: Runs only while AltShift is enabled and another IME is active, using
specialUseinstead ofconnectedDeviceto avoid Bluetooth/USB/Wi-Fi permissions; stops immediately once AltShift becomes active. - Platform & OEM scope: Cached Apps Freezer handling targets Android 12+ while remaining compatible with Android 8.0+; OEM background and FGS restrictions are logged without crashing the IME.
- No hot-path or backup changes: Key dispatch/transliteration are untouched, and
allowBackup="false"resets preferences on uninstall orpm clear.
🛡️ Security & Analysis (AltShift-v0.4.4.apk)
- VirusTotal: Scan report
- Pithus: Static analysis
Full Changelog: v0.4.2...v0.4.4