Skip to content

ADFA-3033 Flag file in /sdcard/Download/CodeOnTheGo.lc for Leak Canary#1084

Merged
hal-eisen-adfa merged 3 commits into
stagefrom
ADFA-3033-enable-disable-leakcanary-flag
Mar 18, 2026
Merged

ADFA-3033 Flag file in /sdcard/Download/CodeOnTheGo.lc for Leak Canary#1084
hal-eisen-adfa merged 3 commits into
stagefrom
ADFA-3033-enable-disable-leakcanary-flag

Conversation

@hal-eisen-adfa
Copy link
Copy Markdown
Collaborator

The fun part was adding two files:

  • app/src/debug/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
  • app/src/release/java/com/itsaky/androidide/app/LeakCanaryConfig.kt

Since Leak Canary has implicit startup instead of explicit, and we need to set dumpHeap in the case where LeakCanary exists (debug builds) and do nothing in the case where LeakCanary does not exist (release builds).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 801c9c41-6273-42b3-ba3c-e92d69cce4ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2cf712e and b22bca8.

📒 Files selected for processing (3)
  • app/build.gradle.kts
  • app/src/main/java/com/itsaky/androidide/app/CredentialProtectedApplicationLoader.kt
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
✅ Files skipped from review due to trivial changes (1)
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt

📝 Walkthrough

Release Notes

Features

  • LeakCanary heap-dump control: Added platform-specific LeakCanary configuration files enabling conditional heap-dump behavior across build types
    • Debug builds: Enable heap-dumps via LeakCanary for memory leak detection
    • Release builds: Disable heap-dumps via no-op configuration
  • Feature flag for LeakCanary dump inhibition: New isLeakCanaryDumpInhibited feature flag (default: false) that reads configuration from /sdcard/Download/CodeOnTheGo.lc
  • Automatic LeakCanary configuration: LeakCanary settings are applied automatically during application startup via CredentialProtectedApplicationLoader.LeakCanaryConfig.applyFromFeatureFlags()
  • Build optimization: Added Sentry Proguard mapping configuration

Risks & Best Practice Violations

  • External storage dependency: Configuration reads from external device storage (/sdcard/Download/CodeOnTheGo.lc), introducing potential runtime failures:

    • Requires appropriate storage read permissions
    • Silent failures if file doesn't exist (mitigated by safe default value)
    • Vulnerable to unexpected external modifications
    • Path availability may vary across device configurations
  • Timing-dependent behavior: LeakCanary configuration is applied at runtime after FeatureFlags initialization, potentially after LeakCanary has already been implicitly initialized by the framework, which could result in configuration not being applied as expected

  • Code duplication: Separate debug and release LeakCanaryConfig.kt files create maintenance overhead; consider using build configuration abstractions or feature flags with platform-specific defaults instead

  • Missing documentation: No comments or documentation explaining the CodeOnTheGo.lc file format, expected location, or how to properly configure this feature for end users

Walkthrough

Adds a build-variant-aware LeakCanary configuration tied to a new feature flag (read from "CodeOnTheGo.lc"). Debug variant disables heap dumps when the flag is set; release variant is a no-op. The config is applied during app initialization; feature flag storage and a Sentry build setting were also added.

Changes

Cohort / File(s) Summary
LeakCanary Config (debug)
app/src/debug/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
New internal object LeakCanaryConfig with applyFromFeatureFlags() that checks FeatureFlags.isLeakCanaryDumpInhibited and sets LeakCanary.config.dumpHeap = false when inhibited.
LeakCanary Config (release)
app/src/release/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
New internal object LeakCanaryConfig with applyFromFeatureFlags() implemented as a no-op for release builds.
Feature Flags
common/src/main/java/com/itsaky/androidide/utils/FeatureFlags.kt
Adds leakCanaryDumpInhibited to FlagsCache, introduces LEAKCANARY_FILE_NAME = "CodeOnTheGo.lc", reads the flag during initialization, and exposes isLeakCanaryDumpInhibited accessor.
App initialization change
app/src/main/java/com/itsaky/androidide/app/CredentialProtectedApplicationLoader.kt
Calls LeakCanaryConfig.applyFromFeatureFlags() immediately after FeatureFlags.initialize() during application load.
Minor formatting
app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
Whitespace/indentation adjustment only in StrictModeConfig block; no behavioral change.
Build config
app/build.gradle.kts
Adds Sentry configuration to disable Proguard mapping upload (preserves existing kapt argument changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • itsaky-adfa
  • Daniel-ADFA
  • jomen-adfa

Poem

🐇 I chewed a flag beneath the tree,

LeakCanary listens now to me,
Debug I hush the noisy heap,
Release stays quiet, tucked in sleep,
Hooray, a soft and tidy leak!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a feature flag file for controlling LeakCanary behavior across different build types.
Description check ✅ Passed The description is directly related to the changeset, explaining why the dual LeakCanaryConfig files were added and how they interact with LeakCanary's implicit startup behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-3033-enable-disable-leakcanary-flag
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt`:
- Line 67: The code currently hardcodes isReprieveEnabled = true which bypasses
runtime feature flag control; update the assignment to read from the feature
flag (e.g., set isReprieveEnabled = FeatureFlags.isReprieveEnabled or the
appropriate accessor) in the DeviceProtectedApplicationLoader initialization so
reprieve behavior is driven by FeatureFlags instead of a literal true; ensure
any imports or references to FeatureFlags are present and that the symbol name
matches the project's flag API.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6001c5e4-d463-4a12-8ad6-bdb8c6adb544

📥 Commits

Reviewing files that changed from the base of the PR and between b5b55d4 and 2cf712e.

📒 Files selected for processing (4)
  • app/src/debug/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
  • app/src/release/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
  • common/src/main/java/com/itsaky/androidide/utils/FeatureFlags.kt

@hal-eisen-adfa hal-eisen-adfa changed the title Flag file in /sdcard/Download/CodeOnTheGo.lc for Leak Canary ADFA-3033 Flag file in /sdcard/Download/CodeOnTheGo.lc for Leak Canary Mar 17, 2026
Comment thread app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt Outdated
Comment thread app/src/release/java/com/itsaky/androidide/app/LeakCanaryConfig.kt
Comment thread app/build.gradle.kts
@hal-eisen-adfa hal-eisen-adfa merged commit bfd285b into stage Mar 18, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-3033-enable-disable-leakcanary-flag branch March 18, 2026 17:24
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.

2 participants