Skip to content

Debug menu: reset only debug-injected cycles, not real tracking (#29)#39

Merged
almothafar merged 2 commits into
masterfrom
feature/29-debug-reset-scope
Jul 2, 2026
Merged

Debug menu: reset only debug-injected cycles, not real tracking (#29)#39
almothafar merged 2 commits into
masterfrom
feature/29-debug-reset-scope

Conversation

@almothafar

Copy link
Copy Markdown
Owner

Closes #29. Follow-up from the debug-menu review (#14 / #21).

Problem

The debug "Reset All Data" wiped everything — first-use date (so "Days in Use" → 0) and any real accumulated charge cycles. And addTestChargeCycles added straight into the same PREF_CHARGE_CYCLES counter as real cycles, so injected and real cycles were indistinguishable.

Change

Track debug-injected cycles in a separate PREF_DEBUG_CHARGE_CYCLES offset:

  • addTestChargeCycles writes to the debug offset; getEffectiveCycleCount adds it on top of the real/OS count, so injection still visibly affects the display and health estimate.
  • New resetDebugData() clears only the injected offset — first-use date and real cycles untouched. Debug menu action: "Reset debug data".
  • resetHealthData() (menu: "Reset ALL (incl. real data)") still does the full wipe, now including the debug offset.
  • getDebugInfo reports real vs debug-injected vs effective counts.

Acceptance criteria

  • After injecting dummy cycles then "Reset debug data", "Days in Use" and the real cycle count are unchanged; only injected cycles are removed.

Testing

./gradlew :app:assembleDebug :app:testDebugUnitTest — build + tests pass. (An automated regression test for the debug offset wants the Robolectric infra from #38, which isn't on master yet; can add once that lands.) Not device-verified.

🤖 Generated with Claude Code

Debug-injected cycles were added straight into the real PREF_CHARGE_CYCLES
counter, and "Reset All Data" wiped everything — first-use date and genuine
cycles included — so testing destroyed real tracking.

Track injected cycles in a separate PREF_DEBUG_CHARGE_CYCLES offset:
- addTestChargeCycles writes to the debug offset; getEffectiveCycleCount adds
  it on top of the real/OS count so injection still visibly affects the display
  and health estimate.
- New resetDebugData() clears only the injected offset, leaving first-use date
  and real cycles intact. The debug menu's "Reset debug data" uses it.
- resetHealthData() (now labelled "Reset ALL (incl. real data)") still wipes
  everything, including the debug offset.
- getDebugInfo shows real vs debug-injected vs effective counts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	app/src/main/java/com/almothafar/simplebatterynotifier/service/BatteryHealthTracker.java
#	app/src/main/java/com/almothafar/simplebatterynotifier/ui/BatteryInsightsActivity.java
@almothafar almothafar merged commit b9d23f7 into master Jul 2, 2026
2 checks passed
@almothafar almothafar deleted the feature/29-debug-reset-scope branch July 2, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug menu: 'Reset' should only clear debug-injected data, not real tracking

1 participant