Status: Implemented and tested

Battery & Power Subsystem

Battery diagnostics encompasses chemical health, charging rates, instantaneous voltage, thermal status, manufacturer design capacity, and modern OEM charge-limiting protection features.

Design Capacity vs. Current Full-Charge Capacity

Standard Android APIs only report the battery's current percentage (0–100%). They do not expose the manufacturer design capacity (e.g. 4,500 mAh) in standard userspace calls. Voodoo queries the internal framework com.android.internal.os.PowerProfile class via reflection to read the nominal factory capacity, and cross-checks Linux sysfs fuel-gauge nodes (/sys/class/power_supply/battery/charge_full_design) where accessible.

OEM Charge Protection Modes

Many modern smartphones (Samsung "Protect Battery", Pixel "Shield", Sony "Battery Care") cap maximum charge at 80% or 85% to preserve lithium cell lifespan. Naive apps may misinterpret this cap as severe battery degradation. Voodoo inspects settings flags to detect active charge protection policies.

Instantaneous Current (mA)

On Android 5.0+ (API 21+), BatteryManager.BATTERY_PROPERTY_CURRENT_NOW reports instantaneous electrical current draw or charge input in microamperes. A negative value indicates discharging, while a positive value confirms active charging.

How Voodoo Inspects Battery Subsystems

1. Primary Call & API-Level Fallback Chain

Extracted from BatteryCollector.kt. Uses sticky broadcast intents (Intent.ACTION_BATTERY_CHANGED) for universal metrics, queries BatteryManager properties on API 21+, and inspects PowerProfile:

// Excerpt from com.tool3.hardwareinfo.categories.battery.BatteryCollector.kt
val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
val batteryStatus = context.registerReceiver(null, filter)

val level = batteryStatus?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1
val scale = batteryStatus?.getIntExtra(BatteryManager.EXTRA_SCALE, -1) ?: -1
val tempTenths = batteryStatus?.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0) ?: 0
val voltageMv = batteryStatus?.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0) ?: 0

// Instantaneous Current & Charge Counter (API 21+)
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val currentNowUa = if (Build.VERSION.SDK_INT >= 21) {
    batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW)
} else null

// Manufacturer Design Capacity via PowerProfile Reflection
val designCapacityMah = PowerProfileHelper.getBatteryCapacity(context)

2. Permission & Privilege Gate

Querying the sticky battery broadcast and BatteryManager properties requires zero permissions. Reading protected kernel battery registers in /sys/class/power_supply/battery/ may require root on locked OEM kernels.

3. Interpretation & Normalization Logic

  • Temperature Conversion: Raw tenths of a degree Celsius (e.g. 315) are normalized into readable Celsius (31.5°C) and Fahrenheit (88.7°F).
  • Charging Source: Extra bits in EXTRA_PLUGGED map to AC, USB, or Wireless (Qi).
  • Health Mapping: Status integers map to official AOSP health states: Good, Overheat, Dead, Over Voltage, Unspecified Failure.

4. Availability-State Triggers

  • BATTERY_PROPERTY_CURRENT_NOW on Android < 5.0 triggers AvailabilityState.UNSUPPORTED.
  • When the fuel-gauge driver does not expose instantaneous current, returns AvailabilityState.UNAVAILABLE without crashing.

Subsystem Field Inventory

Field ID Display Name Type Primary Source / API Min API
battery.level_percent Charge Level (%) INTEGER Intent.EXTRA_LEVEL / EXTRA_SCALE API 1
battery.design_capacity Design Capacity (mAh) FLOAT PowerProfile reflection / sysfs charge_full_design API 1
battery.voltage_mv Battery Voltage (mV) INTEGER Intent.EXTRA_VOLTAGE API 1
battery.temperature_c Temperature (°C) FLOAT Intent.EXTRA_TEMPERATURE / 10.0 API 1
battery.current_now_ma Instantaneous Current (mA) FLOAT BatteryManager.BATTERY_PROPERTY_CURRENT_NOW API 21
battery.charge_protection OEM Charge Protection STRING BatteryProtectionDetector (Samsung 85%, etc.) API 17