LegitKeepAlive is a reusable Android library for policy-compliant background reliability guidance on fragmented OEM ROMs.
It detects the current manufacturer and ROM version, resolves configuration-driven recommendations, checks settings when Android exposes a reliable API, and opens the appropriate system settings page. It does not bypass Android policies, use private APIs, or silently change user settings.
- Reusable
keepalive-coreAndroid Library with a small public API. - Configuration-driven OEM and ROM-specific rules.
- Status checks for supported Android and OEM settings.
- Non-throwing settings navigation results.
- Generic Android fallback plus Xiaomi MIUI 12 and Honor MagicOS 9.x rules.
- Unit and Robolectric tests for rule resolution, configuration validity, and intent creation.
The first formal API release is v0.1.0. Add JitPack to settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}Then add the library:
dependencies {
implementation("com.github.ityulong:LegitKeepAlive:v0.1.0")
}The release page also provides the AAR and a sample APK. The Maven publication generated by the project uses io.github.ityulong:legitkeepalive:0.1.0.
private val keepAlive by lazy {
LegitKeepAlive.create(applicationContext)
}
val recommendations = keepAlive.recommendations()
recommendations.forEach { recommendation ->
val enabled: Boolean? = keepAlive.isEnabled(recommendation)
val result = keepAlive.openSettings(this, recommendation)
}isEnabled() returns null when the setting cannot be checked reliably. openSettings() returns OPENED, UNSUPPORTED, or FAILED instead of throwing when an OEM settings page is unavailable.
You can inspect an intent before opening it:
val intent = keepAlive.createSettingsIntent(recommendation)The library only declares ACCESS_NETWORK_STATE. Add the permissions required by the recommendations you present:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />These are special-access flows controlled by the user. Applications should explain why they are needed and request only what is necessary for a real feature.
| OEM | ROM / System | Coverage |
|---|---|---|
| Generic Android | Default fallback | Implemented |
| Xiaomi | MIUI 12 | Implemented |
| Honor | MagicOS 9.x | Implemented |
OEM settings components can change between device and ROM releases. See the support matrix for validation expectations and known coverage.
.
├── keepalive-core/ # Reusable Android Library and bundled OEM rules
├── app/ # Sample app using only the public library API
├── docs/ # Support matrix, roadmap, plans, and release notes
└── .github/ # Issue templates and release/CI workflows
./gradlew clean test lint assembleRelease
./gradlew :keepalive-core:publishReleasePublicationToMavenLocalThe sample app is intended for testing navigation on physical OEM devices:
./gradlew :app:assembleDebugReal-device reports and OEM rule improvements are especially useful. Read CONTRIBUTING.md before submitting a change and update the support matrix when compatibility changes.
This project improves transparent user guidance. It is not a replacement for WorkManager, foreground services, push messaging, or correct Android lifecycle architecture. It intentionally does not implement deceptive or abusive keep-alive techniques.
Licensed under the Apache License 2.0.