Battery Testing with ADB Notes By ShariqSP

Battery Testing with ADB

Battery testing ensures that the application performs optimally under varying battery levels and power modes. Using ADB commands, developers can simulate different battery levels and test app behavior in normal and power-saving modes.

Example: Battery Testing with Candy Crush APK

Download the Candy Crush APK from shariqsp.com/apk/candycrush.apk. Once installed, use the following commands to simulate battery conditions and test the app’s behavior.

1. Battery Level Simulation

Simulate different battery levels to test how the app responds to low or high battery conditions:

  1. Set Battery Level to 100%: Simulate a fully charged battery:
    adb shell dumpsys battery set level 100
  2. Set Battery Level to 50%: Simulate a half-charged battery:
    adb shell dumpsys battery set level 50
  3. Set Battery Level to 1%: Simulate an almost drained battery:
    adb shell dumpsys battery set level 1
  4. Reset Battery Level to Normal: Return the battery simulation to actual device levels:
    adb shell dumpsys battery reset

2. Power Mode Testing

Test the app’s behavior in different power modes, such as normal and super power-saving modes.

  1. Enable Normal Power Mode: Simulate normal device operation:
    adb shell settings put global low_power 0
  2. Enable Power-Saving Mode: Test how the app performs in battery-saving mode:
    adb shell settings put global low_power 1
  3. Enable Super Power-Saving Mode: Some devices support ultra-saving modes, which can be activated with OEM-specific commands. For example:
    adb shell am broadcast -a com.android.powersavingmode.enable
    *(Note: Replace with the actual broadcast action if specific to the OEM.)*

3. Examples for Battery Testing with Candy Crush APK

Here are specific scenarios to test the Candy Crush APK under different battery conditions:

  • Low Battery Warning: Set battery to 1% and observe if the app handles low battery notifications gracefully:
    adb shell dumpsys battery set level 1
  • Gameplay in Power-Saving Mode: Enable power-saving mode and check for any performance degradation:
    adb shell settings put global low_power 1
  • Battery Consumption Tracking: Monitor the app’s battery usage using:
    adb shell dumpsys batterystats
    Filter the output for the app's package name (e.g., com.king.candycrushsaga).
  • Behavior During Charging: Simulate charging and verify if the app responds correctly:
    adb shell dumpsys battery set status 2
  • Battery Optimization Check: Verify if the app is affected by battery optimization settings:
    adb shell dumpsys deviceidle whitelist

4. Additional Battery Testing Scenarios

Here are other scenarios to include in your battery testing:

  • Test app functionality when switching between power modes during gameplay.
  • Verify if push notifications are delayed in low-power or ultra-saving modes.
  • Check the app’s behavior under rapid battery level changes (e.g., simulating a sudden drop from 50% to 5%).
  • Simulate thermal throttling by combining low battery and high CPU usage (requires additional commands).
  • Ensure the app doesn’t crash when the device enters "Doze Mode" in idle conditions.