Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 7.15 KB

CLAUDE.md

File metadata and controls

44 lines (31 loc) · 7.15 KB

Redact

Android app (Java, minSdk 31, targetSdk 37) that removes metadata from photos and videos, converts formats and censors parts of photos, all on the phone. Its job is that private data never leaves a file or the phone, so a change that drops a check is a regression, never a simplification.

Privacy rules

  • Never weaken a check that a cleaned file is clean (CleanVerifier: verifyMetadataRemoval, requireSameContent, requireVideoMetadataClean, VideoStreamMetadata.scan, the container scans), even where it repeats work. Code that fails closed (returns null, throws or re-encodes when it cannot vouch for a file) stays that way.
  • Never loosen .github/scripts/check_release_manifest.py, which fails CI when the release manifest grants a permission, exported component or application flag that app/release-manifest.txt does not list. Add a line there only for a change that is meant to ship, after ./gradlew bundleRelease exportReleaseManifest and --update.
  • Keep SecureDelete on anything that may hold original media, the inbound URI checks in MainActivity and ShareHandlerActivity, SentryPrivacyScrubber and the before* callbacks in SentryInitializer.
  • Sentry may collect every technical detail it offers (sessions, breadcrumbs, threads, view hierarchy, traces, profiles, logs, metrics), with two hard limits: nothing that can tie reports to one phone or person (install ID, distinct ID, user, boot time, time zone, kernel version, IP address), and nothing about a file (URI, path, name, contents, metadata value) or typed text. Never screenshots or session replay. Section 6 of legal/redact.html and the consent strings must describe what is sent.
  • Everything the app reports itself goes through SentryManager. Its names follow one scheme, written above SentryManager's key lists and enforced by SentryNamingTest: lower-case area breadcrumb categories, area.event[.measure] metrics, and group.field tag keys beside the bare outcome, reason and error_type. What the SDK collects on its own goes through the before* callbacks and SentryPrivacyScrubber.
  • The "What Send Crash Reports captures" tables in README.md and site/index.html (id crash-reports) say exactly what Sentry receives and what it never does, and their Names in Sentry tables (id sentry-names) list every tag, metric and breadcrumb category; SentryNamingTest fails on a name missing there. Any change to what is sent (a Sentry option, a scrubber rule, a tag key, an AppMetrics metric, an SDK upgrade that collects something new) updates both tables, Section 6 of legal/redact.html and, when it changes what someone agrees to, the consent strings in all 13 strings.xml files, in the same commit.

Code

  • MetadataStripper is the entry point for cleaning and holds the shared state (context, progress, cancellation); the work is in ImageCleaner, VideoCleaner and CleanVerifier, each created by it.
  • Reuse the helpers before writing new ones: MediaSizeLimits.copyStream, SecureDelete, MediaFileNames, MediaUriResolver, MediaStoreWrites, OutputDestination, InboundSnapshots (copies of shared-in files), BatchRun (the loop Clean, Convert and Share run a batch through), SentryManager, and AppMetrics for every metric.
  • The release build leaves out Sentry's session-replay module (exclude in app/build.gradle), library translations the app doesn't have (localeFilters) and logging (proguard-rules.pro strips every Log call and treats Log.isLoggable as false). Keep them out when upgrading.
  • ImageCleaner, CleanVerifier, MetadataDisplayer, CleanStats and AlreadyCleanCheck find EXIF tags by reflection over ExifInterface.TAG_*, so grep alone does not show every use; proguard-rules.pro keeps those names.
  • Every user-visible string goes into values/ and all 12 locales (ar de es fr hi it ja ko pt ru zh-rCN zh-rTW); StringTranslationsTest checks it. The Play listing text in fastlane/metadata/android/<locale>/ follows the English too.
  • A setting that is removed leaves its saved value in place; do not add code to clear it.

Build and test

  • ./gradlew :app:testDebugUnitTest (Robolectric), :app:jacocoTestCoverageVerification for the 90% line gate CI enforces, :app:lintRelease, and :app:bundleRelease to catch R8 problems the debug tests miss. From PowerShell use gradlew.bat.
  • Never run two Gradle builds of this project at once: they fight over the same build locks. The daemon is on locally; CI turns it off.
  • Python scripts that need Pillow (.claude/scripts/make_test_media.py, check_media.py) run with python3; plain python has no Pillow. check_media.py also needs pillow-heif to read HEIC; without it a HEIC fails as not checked.

Emulators

  • Test emulator: the Pixel_10_Pro AVD (Play Store image, API 37.2). /test and /verifyclean boot it headless; /generatescreenshots uses its window. Never use a physical device.
  • Profile emulator: Pixel_10_Pro_Profiles, Gradle-managed (Google APIs API 37.0, defined in baselineprofile/build.gradle). Gradle starts and stops it for :app:generateBaselineProfile. Its journeys are in Profiles (startup feeds the startup profile, generate the baseline profile).
  • Clean test emulator: Pixel_10_Pro_Clean, Gradle-managed (Google APIs API 37.0, defined in app/build.gradle). ./gradlew :app:Pixel_10_Pro_CleanDebugAndroidTest runs CleanOnDeviceTest, which cleans the fixtures in app/src/androidTest/assets/media (made by .claude/scripts/make_instrumented_media.py) with real codecs and checks them like check_media.py. CI does not run it: on a headless managed emulator the goldfish video decoders fail to configure, so its two video tests fail there. Run it locally before a release.
  • Benchmark emulator: Pixel_10_Pro_Benchmark, Gradle-managed (Automated Test Device image, API 37.0, stripped of most system apps), used only by StartupBenchmark through /benchmark.
  • The managed emulators stay on 37.0: AGP 9.5's managed devices take only whole API levels, and no stripped-down image exists for 37.2. While running, adb shows them under a generated AVD name such as dev37_google_apis_x86_64_Pixel_10_Pro, so pick the test emulator by its exact AVD name, Pixel_10_Pro.
  • Keep the profile generator class name (Profiles) and the managed device names short: they go into the paths of the profile files copied back from the emulator, and adb on Windows fails on paths over 260 characters. When every copy fails, the run finds no rules and deletes the committed profiles; restore them with git checkout.

Commands

/prerelease runs the whole release check and calls the others: /translate, /dependencies, /sentry, /sentrycoverage, /cleanup, /lint, /bump, /releasenotes, /test, /coverage, /generateprofiles, /generatescreenshots. Also /verifyclean (quick emulator check after touching cleaning code), /benchmark (startup with and without the profile), /generateall and /release. Each one's file in .claude/commands/ is the source of truth for how it works.

Git

Work on dev; main is what ships, through /release. Commit to the current branch when a command says to, and never push unless asked. Leave .idea/ files alone.