Repository navigation
v0.4.1
AltShift v0.4.1 — patch release for Android 8.0+ since v0.4. It adds a first-class battery optimization exemption flow to the onboarding wizard so the IME and keyboard monitor survive Doze and OEM process killers during long idle periods, rebuilds Step 3 as a Material 3 permission card with an in-app rationale dialog, fixes live Step 2 IME selection and cold-start auto-switch conflicts, constrains onboarding content to a readable tablet column, and makes Re-run Setup Wizard start from Step 1. No input, transliteration, or hotkey behavior changed.
🔋 Background Execution & Doze
BatteryHelper(ru.b1sted.altshift.util.BatteryHelper):isIgnoringBatteryOptimizations()queriesPowerManager.isIgnoringBatteryOptimizations(packageName)(treating a missing power service as restricted).requestIgnoreBatteryOptimizations()launchesSettings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONSwith apackage:URI and falls back sequentially toACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGSif the OEM hides the per-package dialog.- Manifest & safety guards: Declares
REQUEST_IGNORE_BATTERY_OPTIMIZATIONSinAndroidManifest.xml(annotated withBatteryLifelint suppression; treated as user-revocable, never permanent), addsFLAG_ACTIVITY_NEW_TASKonly for non-Activitycontexts, and wraps intent launches intry/catch (RuntimeException)withLog.w. - Doze scope: Moves AltShift out of standard Doze/App Standby restrictions during multi-day idle periods while leaving IME binding,
KeyboardMonitor, and boot recovery unchanged.
🎨 Onboarding & Permission UX
- Step 3 Material 3 card: Displays
Overlay access,Notifications, andBackground executionwith colored status dots.ALLOW BACKGROUND RUNNINGand its description appear only while restricted, collapsing to✓ Unrestricted(brand_success) once granted. - In-app rationale & resume refresh: Tapping
ALLOW BACKGROUND RUNNINGopens a Material 3 rationale dialog (CONTINUEtriggers the system prompt;CANCELleaves state untouched), andOnboardingActivity.onResume()re-readsBatteryHelperto update the card immediately on return. - Live Step 2 selection & cold-start guard: Registers a
ContentObserveronSettings.Secure.DEFAULT_INPUT_METHOD(onStart–onStop) plusonWindowFocusChanged(), updating the row toAltShift is the active keyboard/CONTINUEwithout requiring a second tap.HardwareInputService.setAutoSwitchSuppressed(true)while the wizard is active keepsKeyboardMonitor.applyKeyboardDetached()from immediately switching back to the soft keyboard when no hardware keyboard is attached. - Rerun & preserved flows:
EXTRA_RERUN(About → Re-run Setup Wizard) always starts atSTEP_ENABLE(Step 1), while first-time launches resume at the first incomplete step. Overlay (ACTION_MANAGE_OVERLAY_PERMISSION) and Android 13+ notification (POST_NOTIFICATIONS) flows are preserved.
📱 Responsive Layout
- Readable tablet measure: Constrains titles, descriptions (
640dpmax text measure), and the permission card to a centered column viaonboarding_content_side_margin(0dpphones,48dpsw600dp,96dpsw800dp,240dpsw800dp-land) rather than stretching across1280dpdisplays. - Centered layout & Material 3 widgets:
fillViewportwithgravity="center"balances all three steps (Step 3 fits without scrolling at1280×800dpand scrolls cleanly at larger font scales), using a96dpicon,16dpcard radius/padding,12dpdividers, and existingMaterialCardView/MaterialButton/bg_status_dotcomponents.
🧪 Build, Tests & Verification
- Version & docs:
versionCode 8,versionName '0.4.1'(AltShift-v0.4.1.apk/AltShift-v0.4.1-debug.apk). Toolchain unchanged (minSdk 26,targetSdk 34, Java 21, Gradle 8.9, AGP 8.7.3). Added theVersion-0.4.1badge and background-execution summary toREADME.md;RELEASE-NOTES.mdremains local/untracked; additive change with no DI or architecture modifications. - Automated checks:
./gradlew test lintDebugand./gradlew assembleDebugpassed (BUILD SUCCESSFUL), gated by the existingModelTest,TransliterationTableTest,ThemeModeTest, andKeyLabelFormatterTestJVM suites (no instrumentation tests added). - Device verification (Lenovo TB710FU, Android 16 ZUI, ADB): Verified Steps 1–3 in portrait/landscape,
Re-run Setup Wizardstarting at Step 1, rationale → native prompt →✓ Unrestricted(dumpsys deviceidle whitelistconfirmeduser,ru.b1sted.altshift), live Step 2 picker update toCONTINUE, and cold-startOnboardingActivitylaunch with Gboard active and no hardware keyboard attached (present=falsewithout auto-switching back). System exemption dialog, Settings fallback, and OEM battery-manager behavior remain manually verified.
📥 Installation
| Asset | Description |
|---|---|
AltShift-v0.4.1.apk |
Release build, R8-minified, signed with the CI release keystore. |
AltShift-v0.4.1-debug.apk |
Debug build, unminified, signed with the local debug key. |
adb install -r AltShift-v0.4.1.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
- System dialog contrast & Settings toggle: The native
Let app always run in background?prompt (com.android.settings) shows low-contrast body text in Android 16 dark mode (ZUI), mitigated by AltShift's pre-dialog rationale. On verified firmware,App battery usage → Allow background usagedoes not populatedeviceidlewhitelist—only the native prompt orcmd deviceidle whitelistmakesisIgnoringBatteryOptimizations()returntrue. - OEM process killers & revocability: Exemption covers AOSP Doze/App Standby, while vendor task killers can still intervene (lock AltShift in Recents on ZUI for multi-day idle survival); users can revoke the exemption at any time and the onboarding row only reflects state.
- Distribution & manual scope:
REQUEST_IGNORE_BATTERY_OPTIMIZATIONStargets sideload/F-Droid builds (a Play-distributed build should use the settings-list fallback); Settings intent resolution and OEM battery UI are verified manually rather than by instrumentation tests. - No v0.4 input-path or backup changes: Transliteration, hotkeys, Dynamic Island geometry, notification channels, and keyboard monitor behavior are untouched, and
allowBackup="false"resets preferences,WRITE_SECURE_SETTINGS, and the battery exemption on uninstall orpm clear.
🛡️ Security & Analysis (AltShift-v0.4.1.apk)
- VirusTotal: Scan report
- Pithus: Static analysis
Full Changelog: v0.4...v0.4.1