Debug menu: reset only debug-injected cycles, not real tracking (#29)#39
Merged
Conversation
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>
This was referenced Jul 2, 2026
# Conflicts: # app/src/main/java/com/almothafar/simplebatterynotifier/service/BatteryHealthTracker.java # app/src/main/java/com/almothafar/simplebatterynotifier/ui/BatteryInsightsActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
addTestChargeCyclesadded straight into the samePREF_CHARGE_CYCLEScounter as real cycles, so injected and real cycles were indistinguishable.Change
Track debug-injected cycles in a separate
PREF_DEBUG_CHARGE_CYCLESoffset:addTestChargeCycleswrites to the debug offset;getEffectiveCycleCountadds it on top of the real/OS count, so injection still visibly affects the display and health estimate.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.getDebugInforeports real vs debug-injected vs effective counts.Acceptance criteria
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