Skip to content

ityulong/LegitKeepAlive

LegitKeepAlive

Android CI Release License

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.

Features

  • Reusable keepalive-core Android 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.

Install

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.

Usage

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)

Optional Permissions

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.

Supported OEMs

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.

Repository Structure

.
├── 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

Build And Verify

./gradlew clean test lint assembleRelease
./gradlew :keepalive-core:publishReleasePublicationToMavenLocal

The sample app is intended for testing navigation on physical OEM devices:

./gradlew :app:assembleDebug

Contributing

Real-device reports and OEM rule improvements are especially useful. Read CONTRIBUTING.md before submitting a change and update the support matrix when compatibility changes.

Scope

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.

License

Licensed under the Apache License 2.0.

About

Open-source Android toolkit for lawful background reliability on fragmented OEM ROMs.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages