Skip to content

Add debug-only fake steps mode and reactive step screens - #90

Open
sjaramillo10 wants to merge 8 commits into
developfrom
feature/debug-fake-steps
Open

sjaramillo10 wants to merge 8 commits into
developfrom
feature/debug-fake-steps

Conversation

@sjaramillo10

@sjaramillo10 sjaramillo10 commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Debug builds can now use deterministic sample step history without Health Connect permissions or a step-counter sensor. Debug installs alongside release with a separate application ID and a launcher icon marked with a D.

  • Add a persistent debug-only fake steps toggle that refreshes the last 30 days in the shared Room cache. Release continues to use phone-recorded Health Connect steps.
  • Defer Health Connect client initialization and report unavailable or missing-permission states while retaining cached history.
  • Keep Home data in a ViewModel and observe Room changes on Home and Stats so synchronization and CSV imports update both screens. Switching units immediately refreshes Home values and charts.
  • Serialize provider changes with synchronization, including the toggle decision, so rapid taps cannot lose a mode change or mix cache commits.

Fake steps can overwrite real or imported debug history in the recent 30-day window; sample counts can remain cached after fake mode is disabled until real data replaces them. The README documents this behavior.

Validation: ./gradlew build passed with all 22 unit tests, including regression coverage for retained Home data and queued toggles. ./gradlew ktlintCheck and ./gradlew :app:testDebugUnitTest --tests 'dev.sjaramillo.pedometer.data.StepsCsvTest' also passed. Device UI behavior has not been manually verified.

Summary by CodeRabbit

  • New Features

    • Debug builds now include a menu option to switch between phone step data and persistent fake step data, with a repeatable 30-day sample history.
    • The app reports when Health Connect is unavailable or requires permission.
    • Home and statistics screens update as step history changes.
    • Debug and release builds use distinct app identities.
  • Documentation

    • Added guidance for debug builds, fake-step mode, verification, and the unfinished release-signing setup.
  • Tests

    • Added coverage for provider switching, sync behavior, and live step-history and statistics updates.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0a3d109d-8df5-425f-b597-c45d89c347cd
📥 Commits

Reviewing files that changed from the base of the PR and between 042e26e and a1e234b.

📒 Files selected for processing (28)
  • README.md
  • app/build.gradle.kts
  • app/src/debug/kotlin/dev/sjaramillo/pedometer/data/DebugStepsProvider.kt
  • app/src/debug/kotlin/dev/sjaramillo/pedometer/data/FakeStepsProvider.kt
  • app/src/debug/kotlin/dev/sjaramillo/pedometer/di/module/StepsProviderModule.kt
  • app/src/debug/kotlin/dev/sjaramillo/pedometer/ui/DebugStepsMenu.kt
  • app/src/debug/res/drawable/ic_launcher_foreground.xml
  • app/src/debug/res/values/debug.xml
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/DailyStepsDao.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/HealthConnectStepCacheSynchronizer.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/HealthConnectSyncCoordinator.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/PhoneStepsDataSource.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/StepsProvider.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/data/StepsRepository.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/di/module/PersistenceModule.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/ui/HomeFragment.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/ui/HomeViewModel.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/ui/MainActivity.kt
  • app/src/main/kotlin/dev/sjaramillo/pedometer/ui/stats/StatsViewModel.kt
  • app/src/main/res/values/strings.xml
  • app/src/release/kotlin/dev/sjaramillo/pedometer/di/module/StepsProviderModule.kt
  • app/src/release/kotlin/dev/sjaramillo/pedometer/ui/DebugStepsMenu.kt
  • app/src/test/kotlin/dev/sjaramillo/pedometer/data/HealthConnectSyncCoordinatorTest.kt
  • app/src/test/kotlin/dev/sjaramillo/pedometer/ui/HomeViewModelTest.kt
  • app/src/test/kotlin/dev/sjaramillo/pedometer/ui/stats/StatsViewModelTest.kt
  • app/src/testDebug/kotlin/dev/sjaramillo/pedometer/data/DebugStepsProviderTest.kt
  • app/src/testDebug/kotlin/dev/sjaramillo/pedometer/data/FakeStepsProviderTest.kt
  • gradle/libs.versions.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds provider-based step access and cache synchronization, a persisted fake-step mode for debug builds, and observable cached history for the home and statistics screens. It also adds access-state handling, serialized provider changes, tests, and build and usage documentation.

Changes

Step history and debug mode

Layer / File(s) Summary
Step access and serialized cache refresh
app/src/main/kotlin/dev/sjaramillo/pedometer/data/StepsProvider.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/data/PhoneStepsDataSource.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/data/HealthConnectStepCacheSynchronizer.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/data/HealthConnectSyncCoordinator.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/di/module/PersistenceModule.kt, app/src/release/kotlin/dev/sjaramillo/pedometer/di/module/StepsProviderModule.kt, app/src/test/kotlin/dev/sjaramillo/pedometer/data/HealthConnectSyncCoordinatorTest.kt
Step-provider and cache-synchronizer contracts define access states, reads, and synchronization. The phone source reports Health Connect access. The coordinator serializes refreshes and sets state according to access and synchronization outcomes. Tests cover access states, errors, cancellation, and queued provider changes.
Debug fake-step selection
app/src/debug/kotlin/dev/sjaramillo/pedometer/data/FakeStepsProvider.kt, app/src/debug/kotlin/dev/sjaramillo/pedometer/data/DebugStepsProvider.kt, app/src/debug/kotlin/dev/sjaramillo/pedometer/di/module/StepsProviderModule.kt, app/src/debug/kotlin/dev/sjaramillo/pedometer/ui/DebugStepsMenu.kt, app/src/debug/res/values/debug.xml, app/src/debug/res/drawable/ic_launcher_foreground.xml, app/src/release/kotlin/dev/sjaramillo/pedometer/ui/DebugStepsMenu.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/ui/MainActivity.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/ui/HomeFragment.kt, app/src/main/res/values/strings.xml, app/build.gradle.kts, README.md, app/src/testDebug/kotlin/dev/sjaramillo/pedometer/data/*
Debug builds add a persisted fake-step selection, a checkable menu item, and a fake provider that returns deterministic daily samples. Selecting fake mode refreshes the cache. Release builds use an inactive menu implementation and bind the phone provider. The build suffix, resources, documentation, and tests support these changes.
Observable cached history in the screens
app/src/main/kotlin/dev/sjaramillo/pedometer/data/DailyStepsDao.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/data/StepsRepository.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/ui/HomeViewModel.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/ui/HomeFragment.kt, app/src/main/kotlin/dev/sjaramillo/pedometer/ui/stats/StatsViewModel.kt, app/src/test/kotlin/dev/sjaramillo/pedometer/ui/HomeViewModelTest.kt, app/src/test/kotlin/dev/sjaramillo/pedometer/ui/stats/StatsViewModelTest.kt, app/build.gradle.kts, gradle/libs.versions.toml
The DAO and repository expose daily-step history as a flow. The home screen renders collected entries, and the statistics view model recalculates statistics as entries change. Tests validate updates; the coroutine test dependency supports the coroutine tests.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MainActivity
  participant DebugStepsMenu
  participant HealthConnectSyncCoordinator
  participant DebugStepsProvider
  participant FakeStepsProvider
  participant HealthConnectStepCacheSynchronizer
  MainActivity->>DebugStepsMenu: select fake-steps menu item
  DebugStepsMenu->>HealthConnectSyncCoordinator: refreshAfter provider change
  HealthConnectSyncCoordinator->>DebugStepsProvider: setFakeSteps
  HealthConnectSyncCoordinator->>DebugStepsProvider: access
  HealthConnectSyncCoordinator->>HealthConnectStepCacheSynchronizer: sync when access is available
  HealthConnectStepCacheSynchronizer->>DebugStepsProvider: readDailySteps
  DebugStepsProvider->>FakeStepsProvider: delegate reads when fake mode is enabled
Loading

Merge Risk: ⚪ Minimal · up to a1e23

No actionable merge-blocking issue is established. The documented fake-step cache behavior may remain until real data replaces it.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a1e23

Release continues to use permission-gated Health Connect data, while sample generation is confined to a separately installed debug app. The main residual risk is debug data integrity: sample counts can overwrite recent history and remain visible or exportable after fake mode is disabled. No introduced security bypass was established, but runtime and crash-recovery behavior are not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated fake-data write scope is the separately installed debug app's recent 30-day history. Those values propagate to Home, Stats, and user-initiated CSV export. Release's source binding excludes fake generation; no cross-app cache sharing is demonstrated.

Security Findings and Attack Paths

  • inferred — The inspected launcher code does not accept an intent-supplied provider mode. Fake selection is reached through a debug menu callback, while real acquisition runs through the coordinator's access gate. No introduced caller-controlled permission bypass was established in these source paths; generated and deployed entrypoint coverage remains unverified.

Trust Boundaries and Controls

  • observed — Fake mode avoids Health Connect access by selecting a sample generator, not by granting permission to the real provider. Cached history remains available when real access is denied or unavailable, so permission state governs acquisition rather than purging previously cached data.

Resilience and Maintainability Implications

  • inferred — The mutex and Room transaction contain overlapping refreshes and partial cache replacement. They do not create an atomic commit spanning provider preference and cached history, so failure or interruption can leave mode and data provenance different. Documented debug residue and release isolation limit this to debug history integrity rather than an established privilege escalation.

Hardening Proposals

  • proposed — If debug exports must distinguish samples from recorded history, persist provenance with cached rows and expose it in exports instead of inferring origin from the current fake-mode toggle. This is optional hardening beyond the documented mixed-cache behavior, not a verified vulnerability.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 23 files. (5 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: a debug-only fake-steps mode and reactive step screens.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 23 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant