feat: turn the paid app into a freemium app with ads and Pro

- add a single AdMob anchored adaptive banner to the free tier
- add UMP consent and a privacy-options entry point before ads load
- add the one-time Play Billing product `pro_no_ads`; Pro removes the banner
  and nothing else, every scan/selection/deletion feature stays free
- cache the entitlement locally, handle pending purchases, acknowledge and
  retry acknowledgement, and restore from Play on resume
- grandfather paid installs through `legacyPro.cutoffEpochMs`, checking both
  the new package and the old paid package declared in <queries>
- move the Play identity to `de.softwareapp_hb.fotodup.finder.free` while
  keeping the Kotlin namespace `de.softwareapp_hb.fotodup.finder`
- add a debug-only Pro toggle and focused monetisation tests
- add AGENTS.md, docs/codemap.md, docs/codemap.mmd and docs/MONETIZATION.md
- update README, PRIVACY, CHANGELOG, ROADMAP, store copy and the Play checklist
- bump to 1.1.0 / versionCode 4
This commit is contained in:
2026-10-20 09:28:29 +02:00
parent 3afa7d777d
commit 22091dd808
36 changed files with 3268 additions and 295 deletions
+40 -31
View File
@@ -6,6 +6,11 @@ only the format is different: an App campaign asset group takes **5 headlines of
characters** and **5 descriptions of at most 90 characters**, and Google rotates and recombines
them, so every asset has to stand on its own.
> **Current model: freemium.** The app is free to download with one small banner; a one-time Pro
> purchase removes it. The copy and rules in this section reflect that. Strategy notes further down
> that still describe the old paid listing are historical — see
> [MONETIZATION](MONETIZATION.md) and [STORE_LISTING › App pricing](STORE_LISTING.md#app-pricing).
Character counts below are **measured**, not estimated, and are the loading figure (spaces and
punctuation included). An em dash and a hyphen are both one character, so swapping `—` for `-`
never changes a count.
@@ -18,26 +23,25 @@ never changes a count.
| 2 | Delete Duplicate Photos | 23 |
| 3 | Duplicate Photo Cleaner | 23 |
| 4 | Reclaim Storage Fast | 20 |
| 5 | No Ads, No Uploads | 18 |
| 5 | Free With One Small Ad | 22 |
Headlines 1–3 carry the search intent (*duplicate photos* — the phrase a user actually types and
the one Play's tag list cannot express, see [STORE_LISTING](STORE_LISTING.md#category-and-tags)),
4 carries the benefit, 5 carries the differentiator that no competitor in this category can copy
without rewriting its APK.
4 carries the benefit, 5 states the free/Pro model without pretending the free tier is ad-free.
## Descriptions (max 90 characters)
| # | Description | Chars |
|---|---|---|
| 1 | Find duplicate and near-duplicate photos, keep the best of each, delete the rest safely. | 88 |
| 2 | Ad-free and fully offline. Scans thousands of photos in seconds. Nothing is ever uploaded. | 90 |
| 2 | Free with one small banner; ad-free with Pro. Scans thousands of photos in seconds. | 83 |
| 3 | Exact copies and visually similar shots, grouped for you. Android confirms every deletion. | 90 |
| 4 | Reclaim gigabytes. Keep the best copy, trash the rest — reversible on demand. | 77 |
| 5 | Pay once, own it — no ads, no subscription, no account. Your photos never leave the phone. | 90 |
| 5 | Free to scan; one-time Pro removes the banner. Your photos never leave the phone. | 81 |
The five cover five different angles on purpose, because Google mixes descriptions with any
headline: what it does (1), speed and privacy (2), accuracy and safety (3), the payoff (4), the
commercial promise (5).
headline: what it does (1), the free/Pro model and speed (2), accuracy and safety (3), the payoff
(4), and privacy plus the upgrade (5).
## Spares for A/B testing
@@ -45,11 +49,11 @@ Rotate these in one at a time and let the campaign decide; they are all in-spec.
| Headline | Chars | Angle |
|---|---|---|
| Pay Once, Own It | 16 | Price honesty, filters out freebie-hunters |
| Works Fully Offline | 19 | Flight-mode reassurance |
| Free Photo Cleanup | 18 | The free tier, stated plainly |
| Ad-Free With Pro | 16 | The upgrade, without hiding the free banner |
| Works Fully Offline | 19 | Flight-mode reassurance for photo scanning |
| Photos Stay On Your Phone | 25 | The privacy promise stated as a fact |
| Find Similar Photos | 19 | Second keyword surface |
| Clean Up Your Gallery | 21 | Plain-language intent |
| Description | Chars | Angle |
|---|---|---|
@@ -57,31 +61,30 @@ Rotate these in one at a time and let the campaign decide; they are all in-spec.
| Resized, recompressed or byte-identical — one scan finds them all and shows the space. | 86 | Why "near-duplicate" matters |
| Faster every re-scan. Remembers file hashes on your phone, never in the cloud. | 78 | The persistent index |
| Keep the best copy of every shot. One tap marks the rest; you always confirm the delete. | 88 | The two-step removal |
| No ads, no account, no internet permission. Clean up your gallery with nothing given up. | 88 | Privacy as the lead |
| No account, no uploads. Free with one banner; a one-time Pro purchase removes it. | 81 | Privacy plus the honest model |
## Rules this copy follows
- **The word "free" is not used, and must not be added.** The app is sold at a single price
([STORE_LISTING › App pricing](STORE_LISTING.md#app-pricing)), so any free claim is simply
false — and both Play's misleading-claims policy and Google Ads' misrepresentation policy treat
that as a violation, not a growth hack. "Reclaim storage" is a benefit; "free" would be a lie.
- **No price, discount or urgency wording.** Same reason the *Short description* alternatives in
[STORE_LISTING](STORE_LISTING.md#short-description-max-80-characters) avoid it: there is no
free tier to promote, and "limited time" reads as a promotion. *Pay once, own it* is a plain
statement of the business model.
- **Every claim is checkable against this repository.** *No ads* — no ad or analytics dependency
in `gradle/libs.versions.toml`. *No internet permission* — nothing in the merged manifest.
*Never uploaded* — same manifest, and [PRIVACY.md](../PRIVACY.md). *Faster every re-scan* — the
persistent hash index in `data/PhotoIndexStore.kt`. *Android confirms every deletion* —
`MediaStore.createDeleteRequest` / `createTrashRequest`, no `MANAGE_EXTERNAL_STORAGE`.
- **“Free” is accurate for the free tier** — the app is free to download and use. Do **not** say
“ad-free” without the Pro qualifier: the free tier shows one banner. “Ad-free with Pro” and
“free with one small banner” are the honest pairings.
- **No discount or urgency wording.** The free/Pro split is a plain statement of the model, not a
promotion. Avoid “limited time”, “50% off” and similar.
- **Every claim is checkable against this repository.** *Free tier with one banner* —
`ui/ads/BannerAdSlot.kt` + `AdPolicy`. *Pro removes it* — `monetization/ProStore.kt` +
`pro_no_ads`. *Your photos never leave the phone* — `PRIVACY.md` and the on-device scan
pipeline. *Faster every re-scan* — the persistent hash index in `data/PhotoIndexStore.kt`.
*Android confirms every deletion* — `MediaStore.createDeleteRequest` / `createTrashRequest`,
no `MANAGE_EXTERNAL_STORAGE`.
- **No editing or video claims.** The app cannot edit or capture photos and does not scan videos
([README › Known limitations](../README.md#known-limitations)); *Photo editor* framing is
deliberately absent for the same reason the tag is not used.
- **No absolutes.** *Finds every duplicate* and *100% safe* are not claims the engine can keep —
the Aggressive policy can miss pairs, EXIF-rotated images do not match, and unreadable files
are skipped. The copy says what the app does, not what it never fails at.
- **"Ad-free" is a feature claim, not a price claim** — it is what a user of the competing
ad-laden cleaners is looking for, and it survives the paid-app rule above.
- **Don't claim “no internet permission”.** The ad/consent and Billing SDKs use the network; the
accurate claim is that **photos** are never uploaded. See
[PRIVACY.md](../PRIVACY.md) and [MONETIZATION](MONETIZATION.md).
## Which asset types to supply (and what to skip)
@@ -153,7 +156,13 @@ results), uploaded to YouTube as **unlisted** and pasted in as a video asset. It
not an ad — a purpose-shot 15 s clip of scan → "43.7 MB reclaimable" would beat it, and a landscape or
square variant would additionally fill the other orientations.
### The gate to pass first: does a sale pay for the ad?
### Historical: the gate that applied to the paid app
> **Superseded paid-app economics.** The sections from here to the end of the budgeting notes were
> written when a Play install *was* a paid purchase. They do not describe the freemium funnel and
> must not be used as current budget or target guidance. The freemium funnel has two different
> conversions — a free install and, later, a Pro upgrade — so its cost-per-install target and
> payback have to be measured separately. The copy and rules above are current.
This app nets ≈ **€2.54** a sale ([STORE_LISTING › The arithmetic](STORE_LISTING.md#app-pricing)) and
a paid app has no free install to optimise towards — Google counts a conversion only after the buyer
@@ -206,7 +215,7 @@ here — delivery is, and the target is what caps it.
| Location | **one market only, to start** | One market means one sticker price and one set of unit economics; mixing VAT rates mixes the arithmetic |
| Audience segments | **leave empty** (see below) | A segment *narrows* delivery, and delivery is already the binding constraint |
| Networks, devices, schedule | leave to Google | App campaigns set these themselves |
| Conversion tracking | **nothing to install** | Google Play reports the purchase. The app has no SDK, no `INTERNET` permission and no analytics ([PRIVACY.md](../PRIVACY.md)); adding one to "fix attribution" would make the listing's central claim false |
| Conversion tracking | **nothing to install** | Google Play reports the purchase. The app has no analytics SDK; photos never leave the device. The freemium build's only network users are ads/UMP/Billing ([PRIVACY.md](../PRIVACY.md)) |
#### Audience segments, if you set one at all
@@ -267,9 +276,9 @@ breaking even — which is what a bounded experiment should look like. Review at
Do not touch the budget or the target mid-flight: both reset learning, and at this volume the model has
little enough data as it is.
Two house rules apply to creatives exactly as to the copy: **no "free"** anywhere — this is a paid app
([why](STORE_LISTING.md#app-pricing)) — and no absolute claims the engine cannot keep (see *Rules this
copy follows* above).
Two house rules apply to creatives exactly as to the copy: **do not claim “ad-free” without the
Pro qualifier** — the free tier shows one banner — and no absolute claims the engine cannot keep
(see *Rules this copy follows* above).
## Re-checking the counts
+5 -5
View File
@@ -166,7 +166,7 @@ release build — re-check with the audit command in `PLAY_RELEASE_CHECKLIST.md`
```bash
adb shell am broadcast -a de.softwareapp_hb.fotodup.finder.debug.START_SCAN \
-n de.softwareapp_hb.fotodup.finder.debug/de.softwareapp_hb.fotodup.finder.debug.DebugScanTrigger
-n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.debug.DebugScanTrigger
```
Add `--es policy exact|balanced|aggressive` to override the default (`balanced`). The receiver
@@ -177,7 +177,7 @@ the final timings are readable without the screen:
adb logcat -s FotoDupDebug
# poll the current state at any time:
adb shell am broadcast -a de.softwareapp_hb.fotodup.finder.debug.REPORT_STATE \
-n de.softwareapp_hb.fotodup.finder.debug/de.softwareapp_hb.fotodup.finder.debug.DebugScanTrigger
-n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.debug.DebugScanTrigger
```
### Granting photo access
@@ -186,9 +186,9 @@ adb shell am broadcast -a de.softwareapp_hb.fotodup.finder.debug.REPORT_STATE \
why the **debug** manifest declares it:
```bash
adb shell appops set de.softwareapp_hb.fotodup.finder.debug MANAGE_EXTERNAL_STORAGE allow
adb shell appops set de.softwareapp_hb.fotodup.finder.free.debug MANAGE_EXTERNAL_STORAGE allow
# ...run the scan, then put it back:
adb shell appops set de.softwareapp_hb.fotodup.finder.debug MANAGE_EXTERNAL_STORAGE default
adb shell appops set de.softwareapp_hb.fotodup.finder.free.debug MANAGE_EXTERNAL_STORAGE default
```
The app's own banner still reads *“Photo access needed”*, because `checkSelfPermission` is
@@ -199,7 +199,7 @@ unaffected by an appops grant. That is expected: it only affects the on-screen p
`jdb` attaches over JDWP to the debug build:
```bash
adb forward tcp:8700 jdwp:$(adb shell pidof de.softwareapp_hb.fotodup.finder.debug | tr -d '\r')
adb forward tcp:8700 jdwp:$(adb shell pidof de.softwareapp_hb.fotodup.finder.free.debug | tr -d '\r')
printf 'suspend\nwhere all\nquit\n' | jdb -attach localhost:8700
```
+274
View File
@@ -0,0 +1,274 @@
# Monetisation — ads, Pro and the Play Console
Foto Dup Finder is **freemium**:
- **Free tier** — every duplicate-finding feature, plus one anchored adaptive AdMob
banner at the bottom of the scanner screen.
- **Pro tier** — the same features with no banner. A one-time, non-consumable Play
Billing product `pro_no_ads`.
There is no subscription, no trial, no feature gate and no account. Photo
processing remains entirely on-device; the only network traffic is AdMob/UMP and
Google Play Billing.
## 1. Dependencies and why
| Dependency | Version | Why |
|---|---|---|
| `com.google.android.gms:play-services-ads` | 25.5.0 | Stable Google Mobile Ads (legacy) SDK; `minSdk 24`, `compileSdk 34+` |
| `com.google.android.ump:user-messaging-platform` | 4.0.0 | Consent form / privacy options for EEA, UK, Switzerland and US states |
| `com.android.billingclient:billing-ktx` | 9.1.0 | Play Billing; one-time products, pending purchases, acknowledgement |
**Legacy vs Next-Gen ads SDK.** Google now recommends the GMA Next-Gen SDK
(`com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.5.0`). This app uses
the stable legacy SDK because its API is widely documented, it has the smaller
permission set (`READ_BASIC_PHONE_STATE` is not needed) and it is sufficient for one
banner. Treat a Next-Gen migration as a separate, tested change — the initialization
and ad-request APIs differ.
## 2. AdMob setup
1. Create an **AdMob account** and add an **Android app** linked to the new Play listing
(`de.softwareapp_hb.fotodup.finder.free`). The AdMob App ID is tied to that package;
do not reuse the old paid app's AdMob app unless the Play listing is the same.
2. Create one **Banner** ad unit. Copy:
- the **App ID** (`ca-app-pub-…~…`);
- the **banner unit ID** (`ca-app-pub-…/…`).
3. Put both in `local.properties` (git-ignored) or pass them to Gradle:
```properties
admob.appId=ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY
admob.bannerUnitId=ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN
```
The defaults in `app/build.gradle.kts` are Google's public **test** ids; they are
safe to click but produce no revenue. The build logs a warning while they are in
use.
4. Create a **UMP message** under *Privacy & messaging* in AdMob, publish it, and
test it with a debug device. The app calls
`requestConsentInfoUpdate()` → `loadAndShowConsentFormIfRequired()` before
`MobileAds.initialize()`.
5. Optional but recommended: publish an `app-ads.txt` on the developer website that
Play points to. It is a website file, not an app asset.
## 3. Play Console setup
### 3.1 Publish the new listing as a free app
The freemium build uses **`applicationId = de.softwareapp_hb.fotodup.finder.free`**, so
it is a **new Play listing**, separate from the old paid app at
`de.softwareapp_hb.fotodup.finder`. Create the new app as **Free** from the start —
new apps are free by default. Do **not** change the old paid listing's price; it can
remain for existing customers or be unpublished once they have migrated. This avoids
Play's irreversible paid → free change entirely.
### 3.2 Create the in-app product
1. *Monetise > Products > In-app products > Create product*.
2. Product ID: **`pro_no_ads`** (must exactly match `ProProduct.ID`).
3. Type: **One-time product** (non-consumable).
4. Set a price; the app displays Play's localized `formattedPrice`, so no code
change is needed to change it.
5. **Activate** the product. An inactive product is not returned by
`queryProductDetailsAsync()`.
### 3.3 Test purchases
1. Add a **license tester** under *Setup > License testing*.
2. Upload the freemium build to an **internal testing** track.
3. Install from the internal-testing link with the tester account.
4. Test: buy, cancel, pending (if available), restore, reinstall, and a second
device with the same account.
5. Use a **promo code** or license-tester purchase, never a real charge, for your
own end-to-end check.
Billing cannot be tested from a local debug APK signed with a debug key and not
installed through Play; `BillingClient` will report `BILLING_UNAVAILABLE` or
`SERVICE_DISCONNECTED`.
## 4. App configuration
`app/build.gradle.kts` reads three values, in order: Gradle property
(`-Padmob.appId=...`), `local.properties`, then the default test value.
| Key | BuildConfig / manifest | Default |
|---|---|---|
| `admob.appId` | `manifestPlaceholders["admobAppId"]` → AdMob `APPLICATION_ID` meta-data | Google test app id |
| `admob.bannerUnitId` | `BuildConfig.ADMOB_BANNER_UNIT_ID` | Google test adaptive-banner unit |
| `legacyPro.cutoffEpochMs` | `BuildConfig.LEGACY_PRO_CUTOFF_EPOCH_MS` | `0` (disabled) |
`local.properties.example` is the template. Never commit the real file.
## 5. Code map
| Class | Role |
|---|---|
| `monetization/ProProduct.kt` | product id + SharedPreferences keys |
| `monetization/ProStore.kt` | Billing connection, product query, purchase, acknowledgement, restore, local cache, legacy migration |
| `monetization/ProState.kt` | UI state (`isPro`, `priceText`, `billingAvailable`, `purchaseInProgress`, `message`) |
| `monetization/LegacyPro.kt` | pure install-time cutoff predicate |
| `monetization/AdsController.kt` | UMP consent + `MobileAds.initialize` + privacy options |
| `monetization/AdsState.kt` | `initialized`, `canRequestAds`, `privacyOptionsRequired`, `error` |
| `monetization/AdPolicy.kt` | pure banner gate |
| `ui/ads/BannerAdSlot.kt` | one adaptive `AdView`, lifecycle, destroy on dispose |
| `ui/pro/ProSheet.kt` | benefits, price, buy, restore, pending/unavailable |
| `ui/scanner/ScannerScreen.kt` | bottom slot, Options menu entry, sheet visibility |
`FotoDupApplication` creates `ProStore` and `AdsController` next to
`ScanController`. `MainActivity` starts consent/ads only for a non-Pro install and
refreshes purchases on resume.
## 6. Consent and purchase flows
### Consent
1. `ConsentInformation.requestConsentInfoUpdate(activity, params, ...)`.
2. On success, `UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity)`.
3. Read `canRequestAds()` and `privacyOptionsRequirementStatus`.
4. Only then `MobileAds.initialize(appContext)`.
5. The banner is composed only when `AdPolicy.shouldShowBanner(...)` is true.
6. If UMP requires it, the Options menu shows **Privacy options**, which calls
`showPrivacyOptionsForm()`.
If the consent request fails (offline, no Play services), the app keeps working and
does not request an ad unless UMP already has a usable answer.
### Purchase
1. `ProSheet` calls `ScannerViewModel.purchasePro(activity)`.
2. `ProStore.purchase()` queries product details if needed, then
`launchBillingFlow(activity, params)`.
3. `onPurchasesUpdated()` filters `pro_no_ads` and requires `PURCHASED`.
4. Pro is granted locally, cached, and the banner disappears immediately.
5. If the purchase is not acknowledged, `KEY_PENDING_ACK` stores the token;
`acknowledgePurchase()` is retried on the next refresh.
6. On app resume, `queryPurchasesAsync()` reconciles the cache with Play.
## 7. Grandfathering paid customers
The app was previously sold as a paid app. Play Billing cannot tell an install
whether it was bought as a paid app, so `LegacyPro` compares
`PackageInfo.firstInstallTime` with a cutoff:
```properties
# Epoch milliseconds of the first freemium release.
legacyPro.cutoffEpochMs=1793491200000 # 2026-11-01T00:00:00Z
```
Because the freemium build has a **new applicationId**
(`de.softwareapp_hb.fotodup.finder.free`), its own first-install time can never
predate the cutoff. `ProStore` therefore reads the earliest first-install time of:
- the new freemium package; and
- the old paid package `de.softwareapp_hb.fotodup.finder`, declared in `<queries>`
in the manifest.
- An install before the cutoff is granted Pro and the decision is persisted in
`KEY_ORIGIN_RESOLVED` / `KEY_LEGACY_PRO`.
- A later successful Play query cannot revoke that grant.
- A cutoff of `0` disables the migration.
- The old paid app must still be installed the first time the freemium app runs.
Uninstalling the old app first, clearing app data, or a restore that resets
`firstInstallTime` loses the signal. For those users, use a promo code or a manual
support flow. A server-side purchase history would be stronger, but it contradicts
the no-account, no-backend design.
Set the cutoff **before** uploading the first freemium build. If the app was never
actually sold, leaving it at `0` is correct.
## 8. Play Console declarations and Data Safety
The freemium build **does** contain ads and **does** use the advertising ID. These
answers change from the pre-freemium listing.
| Console item | Answer |
|---|---|
| **Ads** (*App content*) | **Yes, my app contains ads** |
| **Advertising ID** | **Yes** — the ads SDK merges `AD_ID` and the Privacy Sandbox permissions |
| **Data safety** | Google Mobile Ads collects/shares data for advertising, analytics and fraud prevention (see below) |
| **Photo and video permissions** | unchanged: only `READ_MEDIA_IMAGES` / selected-photos access; the ad SDK never reads photos |
| **App access** | still “all functionality available without special access”; no login |
| **Content rating** | re-confirm; the app is a general-purpose utility, not child-directed |
| **Permissions audit** | re-audit the **merged release manifest**; expect `INTERNET`, `ACCESS_NETWORK_STATE`, `AD_ID`, `ACCESS_ADSERVICES_*`, `WAKE_LOCK`, `com.android.vending.BILLING` and the framework's dynamic-receiver permission in addition to the photo/notification/FGS set |
Google's published disclosure for the Mobile Ads SDK lists:
- **IP address** — may be used to estimate general location;
- **user product interactions** — app launch, taps, video views;
- **diagnostic information** — launch time, hang rate, energy usage;
- **device and account identifiers** — Android advertising ID, app set ID, and
identifiers related to signed-in accounts where applicable.
All of it is encrypted in transit with TLS. Ad ID collection is optional at the
manifest level; this app keeps it because the free tier relies on advertising. The
in-app **Privacy options** entry point and Android's ad-ID controls give users a
way to change their choice.
`PRIVACY.md` must stay consistent with these answers. Purchases are handled entirely
by Google Play; the app never receives payment details.
## 9. Testing matrix
| Case | How |
|---|---|
| Test banner | Debug build with the default test ids; a Play-services device shows a “Test Ad” label |
| No banner for Pro | `DebugProToggle.GRANT_PRO`, or a license-tester purchase |
| Consent required | UMP debug geography / test device; see the UMP docs |
| Privacy options | Menu appears only when `privacyOptionsRequirementStatus == REQUIRED` |
| Purchase | Internal testing track + license tester |
| Cancel | Reopen the Play sheet and press back |
| Restore | Reinstall, then **Restore purchase** with the same account |
| Pending | Use a delayed-payment test instrument if available; Pro must not activate |
| Offline Pro | Turn on airplane mode after a purchase; the cached entitlement keeps ads off |
| Refund/revoke | Refund in the Console, reopen the app; a successful Play query removes Pro unless legacy |
| Billing unavailable | AOSP AVD with no Play services; the sheet says purchases are unavailable and the scanner still works |
| Ad load failure | No network; the banner is absent, the app does not crash |
For UMP testing outside the EEA, temporarily add a debug-only
`ConsentDebugSettings` in `AdsController.ensureInitialized()` before the update:
```kotlin
val debugSettings = ConsentDebugSettings.Builder(activity)
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
.addTestDeviceHashedId("YOUR-HASHED-ID") // from the UMP logcat line
.build()
val params = ConsentRequestParameters.Builder()
.setConsentDebugSettings(debugSettings)
.build()
```
Keep it behind `BuildConfig.DEBUG` and remove it before a release build; the production
path must not force a geography.
## 10. Troubleshooting
| Symptom | Check |
|---|---|
| “Banner failed to load” | AdMob app id / unit id, network, test device, UMP `canRequestAds()` |
| No ad view at all | `isPro`, `AdsState.canRequestAds`, `AdsState.initialized`; the gate is intentional |
| `APPLICATION_ID` missing crash | `admob.appId` placeholder / manifest meta-data |
| `BILLING_UNAVAILABLE` | Play Store installed/updated, app installed from Play internal testing, license tester |
| `queryProductDetails` returns nothing | product `pro_no_ads` exists and is **active**, app uploaded to a testing track |
| Purchase granted but ads return | successful Play query found no purchase (refund/account mismatch) and the install is not legacy |
| Purchase not acknowledged | check `KEY_PENDING_ACK`; the next refresh retries; Play refunds after 3 days |
| Privacy options missing | UMP says the form is not required in this region |
| Ads load on a Pro device | `ProStore` cache/query, then `MainActivity` skip logic; check `DebugProToggle` state |
## 11. Limitations
- Entitlement is **client-side** and can be tampered with on a rooted device. This
is the deliberate cost of having no account/backend.
- A paid customer who uninstalls the old app before the first freemium launch, or who
uninstalls/reinstalls the new app, clears data, or restores to a device that resets
`firstInstallTime`, may lose the legacy grant. Use a promo code/support flow for
those users.
- The legacy ads SDK is in maintenance mode; migrating to GMA Next-Gen is a future
change with a different API.
- Store screenshots and the feature graphic predate the banner and Pro sheet; the
listing needs a re-shoot before the freemium release.
- The AOSP emulators used for tablet screenshots have no Play services, so ads and
Billing cannot be validated there.
+174 -133
View File
@@ -5,34 +5,35 @@ the rest are things you must do in the Play Console / with your own accounts.
## 1. Identity and signing
- [x] Final **application id** chosen: `de.softwareapp_hb.fotodup.finder`
- [x] Final **application id** chosen: `de.softwareapp_hb.fotodup.finder.free`
(`applicationId` in `app/build.gradle.kts`). It can **never be changed after the
first release**, so treat it as locked. `namespace` and the Kotlin package of
the same name are aligned with it; debug builds append `.debug`.
first release**, so treat it as locked. This is a **new Play listing**, separate
from the old paid app at `de.softwareapp_hb.fotodup.finder`; the code package and
`namespace` deliberately stay `de.softwareapp_hb.fotodup.finder`, and debug builds
append `.debug` → `de.softwareapp_hb.fotodup.finder.free.debug`.
- [x] Generate an **upload keystore** (keep it safe; if you lose it you cannot
publish updates) — **[code]** done: `fotodup-upload.jks` in the project root
(git-ignored, `alias upload`), `CN=Hadrian Burkhardt, L=Potsdam, C=DE`.
- [x] Copy `keystore.properties.example` to `keystore.properties` and fill it in.
**[code]** done — the file is in place, and the Gradle build picks it up automatically and
signs release builds; without it the release APK stays unsigned.
- [ ] Enable **Play App Signing** in the Play Console and upload the certificate of
your *upload* key:
- [ ] Enable **Play App Signing** for the **new** app in the Play Console and upload the
certificate of your *upload* key (the same upload key can sign both listings):
```bash
keytool -exportcert -alias upload -keystore fotodup-upload.jks -rfc > upload_cert.pem
```
Upload key fingerprint (SHA-256), to confirm the right key was registered:
`AA:8C:3D:6C:D0:55:46:50:48:ED:04:3E:AF:34:2B:66:B4:13:87:C9:E0:DA:29:70:5A:0D:18:47:08:1A:4C:7A`.
Enrolment happens with the first upload: Google then holds the app signing key and this
one only signs uploads.
Enrolment happens with the first upload of the new listing: Google then holds that
app's signing key and this one only signs uploads.
- [ ] Store the keystore + passwords in a password manager / secure vault. Back it up.
## 2. Versioning
- [x] Set `versionName` (user-visible) **[code]** — `1.0.2` in `app/build.gradle.kts`.
- [x] `versionCode` **[code]** — currently **3**. It is the counter Play orders uploads by, and
every later upload must be higher. **2 is already used**: Play rejects re-uploading the 1.0.1
bundle with *"Version code 2 has already been used. Try another version code."* — 1 was the
1.0.0 build, so 1.0.2 takes **3**.
- [x] Set `versionName` (user-visible) **[code]** — `1.1.0` in `app/build.gradle.kts`.
- [x] `versionCode` **[code]** — currently **4**. It is the counter Play orders uploads by, and
every later upload must be higher. Codes 1–3 were consumed by 1.0.0–1.0.2, so the
freemium build takes **4**.
## 3. Build the release artefacts
@@ -41,14 +42,17 @@ the rest are things you must do in the Play Console / with your own accounts.
./gradlew :app:assembleRelease # -> APK for local testing
```
- [x] **[code]** verified 2026-10-18: `bundleRelease` and `assembleRelease` both succeed.
`app/build/outputs/bundle/release/app-release.aab` is 2,940,935 bytes
(`sha256 534e5ae9c9a62ca13c93dd2da52d8228ec72aed14a1fe830f6e0def17b22e9f5`) and is signed with
the upload key. The release APK reports `versionCode=3 versionName=1.0.2 targetSdk=36` and
exactly the permission set listed in step 5 — **no `INTERNET`**, so "nothing leaves the
device" holds in the shipped artefact, not just in the source manifest.
(The 1.0.1 build is the one Play recorded as `versionCode` 2: 2,944,100 bytes,
`sha256 f8e6a29a…`.)
- [ ] **Build and record the 1.1.0 artefacts.** The 1.0.2 record is historical
(2,940,935 bytes, `sha256 534e5ae9…`). The freemium build adds the ads/UMP/Billing
dependencies and the AdMob manifest entry, so its size and hash must be re-measured
after real AdMob ids are configured. Verify the release APK reports package
`de.softwareapp_hb.fotodup.finder.free`, `versionCode=4 versionName=1.1.0
targetSdk=36` and the permission set in step 5 (including `INTERNET`, `AD_ID` and
`BILLING`).
Local validation with the default test ids (2026-10-20): APK 3,655,562 bytes,
`sha256 931d2b21…`; signed AAB 7,680,301 bytes, `sha256 03abb548…`.
Re-measure both after setting the real ids/cutoff — the ids change the manifest and
therefore the artefacts.
- [ ] Upload the **`.aab`** (not the APK) to the Play Console.
⚠️ **Expect a native-debug-symbols warning here, and ignore it.** Play scans the bundle, finds
`base/lib/<abi>/libandroidx.graphics.path.so`, and reports *"This App Bundle contains native
@@ -79,47 +83,34 @@ Ready-to-paste copy and the generated graphics live in
[docs/STORE_LISTING.md](STORE_LISTING.md) (milestone M10). Everything below is a Console
action except the items marked **[code]**.
- [ ] ⚠️ **Confirm App pricing is set to paid before rolling out — it is the one irreversible
decision.** Play, *Set up your app's prices*: *"You can change your app from paid to free. Once your app has
been offered for free, the app can't be changed to paid. If you want to charge for the app, you
need to create a new app with a new package name and set a price."* **`versionCode` 2 (1.0.1)
has already been uploaded and consumed**, so check *Products > App pricing* before this
rollout: if it still offers **Make your app paid**, do it now — once the app is offered for
free that option is gone for good. In the Console:
1. **Set up a payments profile** with your tax rates (Play asks the first time you set a price).
2. **Products > App pricing** → *"Your app is"* → **Make your app paid**, and enter the base price
**€2.99** (one-time). Leave *"Default price includes tax"* off unless €2.99 is meant to be the
final gross price in the EU — off, the €2.99 is a **net** figure and the buyer is charged the
gross price: **€3.56** in Germany (19% VAT), **€3.59** in a 20% market such as Austria or
France. **Verified live after publishing: the listing reads €3.59** — the Console shows the
price you typed, the storefront shows the price the buyer pays, and Play prices the page for
the country of the viewing account rather than the country you are sitting in. What each
setting does to the sticker and to your payout:
[STORE_LISTING › What the buyer actually pays](STORE_LISTING.md#what-the-buyer-actually-pays).
3. Check the **local prices** Play derives for each country — a country with no price is a
country where the app is unavailable.
4. [ ] **Launch sale: 50% off (€1.49) for 14 days.** A sale can only be created *after* the app is
published (*App pricing > Sales > Create sale*), it can be **live for 1–14 days at most**, and
**30 days must pass between one sale ending and the next starting** — so this is a single
deadline-driven window, not a permanently lower launch price. Percentage discounts must be
between 10% and 100%. The original price is struck through everywhere except in 12 EU member
states and the UK (Germany does show it) — and that crossed-out figure is the **gross** price.
**Verified live:** the sale reads **€1.79** (€1.77 in Germany), the same VAT gross-up as the
base price: 1.49 × 1.20 and 1.49 × 1.19.
5. [ ] **Test the paid listing end to end**: install your own copy through a **promo code**
rather than a real purchase. A giveaway code is the only trial mechanism a paid app has, and
it doubles as the check that a buyer really does receive a working app.
**[code]** nothing to build: no Billing dependency, no `com.android.vending.BILLING` in the
merged manifest. Rationale, the fee arithmetic and the sale rules:
[STORE_LISTING](STORE_LISTING.md) › App pricing.
- [ ] **Freemium Console setup — this replaces the old paid-app step.**
1. Create the **new Play app** for `de.softwareapp_hb.fotodup.finder.free` and
publish it as **Free** (new apps are free by default). Do **not** change the old
paid listing's price; it can stay for existing customers or be unpublished.
2. *Monetise > Products > In-app products* → create **`pro_no_ads`**, type **One-time
product**, set the price, **Activate** it. The product id must match
`ProProduct.ID` exactly; an inactive product is not returned by Play.
3. AdMob → create/link the Android app, one **Banner** unit and a **UMP message**.
Put the ids in `local.properties` (`admob.appId`, `admob.bannerUnitId`) or pass
`-Padmob.appId=...`; never commit them.
4. Set `legacyPro.cutoffEpochMs` to the instant of the first freemium release.
Installs older than that are grandfathered into Pro; a `0` cutoff disables the
migration. Because the new app has a different applicationId, this only works
when the old paid app is still installed on the first freemium launch. Tell
existing customers to keep the old app installed for that first run, or use a
promo code/support flow.
5. Add **license testers**, upload to **internal testing**, and test buy, cancel,
pending, restore, reinstall and a second device with the same account. Use a promo
code or a license-tester purchase, never a real charge.
6. Update the **Ads**, **Advertising ID** and **Data Safety** answers in step 5.
Full steps: [MONETIZATION](MONETIZATION.md); rationale and copy:
[STORE_LISTING › App pricing](STORE_LISTING.md#app-pricing).
- [ ] App name (≤ 30 chars): "Foto Dup Finder" (15 chars).
- [ ] Short description (≤ 80 chars) — two options are drafted and length-checked in
STORE_LISTING.md (69 and 65 chars). **Neither says "free"**: the app is paid, so the claim would
be false, and Play's metadata policy keeps price and promotional wording out of the title,
icon and developer name.
- [ ] Full description (≤ 4000 chars) — drafted and length-checked in STORE_LISTING.md (2 426 chars,
so there is room to grow). The one price line ("Pay once, then own it…") sits in the body for
the same policy reason.
- [ ] Short description (≤ 80 chars) — two freemium options are drafted and length-checked
in STORE_LISTING.md. “Free” is now accurate, but Play's metadata policy still keeps
price and promotional wording out of the title, icon and developer name.
- [ ] Full description (≤ 4000 chars) — drafted in STORE_LISTING.md. It states the free
tier / one-time Pro distinction in the body, not as a promotional gimmick.
- [x] **App icon** 512×512 PNG **[code]** — `tools/make-store-assets.sh` renders it from the
same vectors as the adaptive icon in `res/drawable/ic_launcher_*`.
- [x] **Feature graphic** 1024×500 PNG **[code]** — same script.
@@ -183,23 +174,31 @@ action except the items marked **[code]**.
> the hosted policy. If you want the policy in another language, host a translated
> copy yourself and link it from the listing.
- [ ] Complete the **Data safety** form:
- *Does your app collect or share any required user data types?* → **No**.
- Data types accessed: **Photos** — processed on-device only, not collected.
- *Is all user data encrypted in transit?* → N/A (no transmission).
- *Do you provide a way for users to request data deletion?* → Uninstalling
removes all app data.
- The **paid** model changes none of the above: the purchase happens in the Play Store app, not in
this one. Play's own guidance is that using a payment service such as *"Google Play's billing
system"* to complete transactions does **not** require declaring the data that service collects
in connection with its processing — and this app contains no payment code at all, so it receives
nothing either way. Re-read that if a Billing dependency is ever added
(step 9); the app's own answers would still be "no", but the *purchase handling* would move
into the app and the answers would need a fresh look.
- [x] Confirm the **permission set** the Console will show. **[code]** done 2026-10-13: `aapt2 dump
badging` on the release APK reports exactly the table below (plus
`…DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION`) — and **no `INTERNET`**. Re-check from the
*merged* release manifest rather than the source one after any dependency change, so nothing
a library quietly adds slips past:
- *Does your app collect or share any required user data types?* → **Yes**.
- **Device or other IDs** → collected and shared (advertising ID, app set ID,
account-related identifiers where applicable). Purpose: **Advertising or
marketing**, **Analytics**, **Fraud prevention, security and compliance**.
- **App activity** → collected and shared (app launch, taps, video views) for
advertising/analytics.
- **Diagnostics** → collected and shared (launch time, hang rate, energy usage).
- **Location** → **Approximate location**, collected/shared if the Console treats the
ads SDK's IP-based estimate as location; the app itself requests no location
permission.
- **Photos** → **not collected**: read and processed on-device only.
- *Is all user data encrypted in transit?* → **Yes** (Google states TLS for the ads
SDK; Play Billing is handled by Google).
- *Do you provide a way for users to request data deletion?* → The developer holds
no server-side data. Uninstalling/clearing app storage removes the local index and
Pro cache; users can reset/delete the advertising ID in Android Settings and change
consent through **Privacy options** where UMP requires it.
- **Purchases** are handled entirely by Google Play. The app never receives payment
details; the optional `pro_no_ads` entitlement is cached locally.
- The full data-type list and the source are in
[MONETIZATION › Play Console declarations](MONETIZATION.md#8-play-console-declarations-and-data-safety).
Re-read the form if the AdMob/UMP configuration or the Billing dependency changes.
- [x] Confirm the **permission set** the Console will show. **[code]** the freemium build adds
the ads and Billing permissions; re-check from the *merged* release manifest rather than the
source one after any dependency change, so nothing a library quietly adds slips past:
| Declared permission | Why | From |
|---|---|---|
@@ -209,17 +208,23 @@ action except the items marked **[code]**.
| `WRITE_EXTERNAL_STORAGE` (`maxSdkVersion=29`) | legacy delete on Android 10 only | app |
| `FOREGROUND_SERVICE`, `FOREGROUND_SERVICE_DATA_SYNC` | keep a scan alive | app |
| `POST_NOTIFICATIONS` | scan-progress notification | app |
| `INTERNET`, `ACCESS_NETWORK_STATE` | free-tier ads/consent + Pro purchase | app / Ads SDK |
| `com.google.android.gms.permission.AD_ID` | advertising ID | Ads SDK |
| `ACCESS_ADSERVICES_AD_ID`, `ACCESS_ADSERVICES_ATTRIBUTION`, `ACCESS_ADSERVICES_TOPICS` | Privacy Sandbox | Ads SDK |
| `WAKE_LOCK` | ad rendering | Ads SDK |
| `com.android.vending.BILLING` | one-time `pro_no_ads` purchase | Billing SDK |
| `…DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION` | framework-generated, not user-facing | AndroidX |
Deliberately **absent**: `INTERNET` and `MANAGE_EXTERNAL_STORAGE`. Both are
load-bearing for the "nothing leaves the device" claim, so re-check after any new
dependency:
`MANAGE_EXTERNAL_STORAGE` must remain **absent**. `INTERNET` is load-bearing for ads
and Billing, so the old “no network permission” claim no longer holds; the remaining
promise is narrower and still true: the app's own code never uploads photos,
thumbnails, hashes or filenames. Audit the merged manifest with:
```bash
./gradlew :app:processReleaseMainManifest
grep -A1 '<uses-permission' \
app/build/intermediates/merged_manifests/release/processReleaseManifest/AndroidManifest.xml \
| grep -oE 'android.permission.[A-Z_]+' | sort -u
| grep -oE '[A-Za-z0-9_.]*permission\.[A-Z_]+|com\.android\.vending\.BILLING' | sort -u
```
(Match `<uses-permission` only. A bare `android.permission.` grep also picks up
@@ -270,12 +275,14 @@ action except the items marked **[code]**.
> default; over a hand-picked subset it would be meaningless, because a selection is not a
> sample of the library — it is the part the duplicates are not in.
>
> Nothing is uploaded: the app declares no INTERNET permission and all hashing happens on the
> device. Photos are only read. Any deletion requires an explicit selection by the user and
> always goes through Android's own confirmation dialog (`MediaStore.createDeleteRequest` /
> `createTrashRequest`) — never silently — and the app never requests
> `MANAGE_EXTERNAL_STORAGE`. Partial access (`READ_MEDIA_VISUAL_USER_SELECTED`) is declared
> and supported as a reduced mode for users who prefer to hand over fewer photos.
> Nothing is uploaded: photos are read and hashed entirely on the device. The only
> network use is the free tier's ads/consent SDK and the optional Pro purchase, and
> neither ever receives a photo, thumbnail, hash or filename. Any deletion requires an
> explicit selection by the user and always goes through Android's own confirmation
> dialog (`MediaStore.createDeleteRequest` / `createTrashRequest`) — never silently — and
> the app never requests `MANAGE_EXTERNAL_STORAGE`. Partial access
> (`READ_MEDIA_VISUAL_USER_SELECTED`) is declared and supported as a reduced mode for
> users who prefer to hand over fewer photos.
…and **682 characters**, for a box with less room than that:
@@ -285,8 +292,9 @@ action except the items marked **[code]**.
> duplicates of a picked photo are precisely the files the picker never hands over — a
> selection cannot answer "what is duplicated in my library". The app also calibrates its
> similarity threshold from the library's own pairwise distance distribution, which needs the
> whole library to mean anything. Nothing is uploaded (the app has no INTERNET permission)
> and deletion always goes through Android's confirmation dialog.
> whole library to mean anything. Photos are processed on-device and never uploaded; the
> only network use is ads/consent and the optional Pro purchase, and deletion always goes
> through Android's confirmation dialog.
Nothing in any of them is aspirational — every claim is a place in the code, so it can be
defended if Play comes back with questions:
@@ -298,7 +306,7 @@ action except the items marked **[code]**.
| the threshold is fitted per library | `AdaptiveThreshold.choose()` estimates the unrelated-photo distribution from the scan's own pairwise histogram and returns the widest threshold keeping the *expected* number of accidental matches in budget; under `MIN_SAMPLE` = 200 pairs it falls back to the policy ceiling |
| a selection cannot stand in for a library | that histogram is built from every pair in the scan — the phone's 5,385-photo library fitted to *pHash ≤ 10 bits* and said so on screen, while the 22-photo tablet library was too small to fit and used its ceiling (`(default)`) |
| a constant threshold cannot work | `AdaptiveThreshold` KDoc and README § scan pipeline: the widest pHash threshold with zero false pairs falls from **13 (120 images) to 5 (2 880)** as a library grows |
| nothing leaves the device | no `INTERNET` in the merged release manifest — the `aapt2` audit in the item above |
| photos never leave the device | `ScanEngine` / `PhotoHasher` operate on local bytes and the SQLite index; no photo, thumbnail, hash or filename is sent. Only AdMob/UMP/Billing use the network (see [MONETIZATION](MONETIZATION.md)) |
| deletion is never silent | `MediaDeleter` → `MediaStore.createDeleteRequest` / `createTrashRequest`; no `MANAGE_EXTERNAL_STORAGE` |
| partial access is real, not a gesture | `AppPermissions.MediaAccess.PARTIAL` / `hasPartialAccess()`, with a banner and a prompt to upgrade to full access |
@@ -333,7 +341,8 @@ action except the items marked **[code]**.
> The app finds duplicate photos on the device. The user starts a scan and may leave
> the app while it runs; the foreground service keeps that user-initiated scan alive
> and shows its progress. The scan reads the photo library and writes a small local
> index of file hashes. It performs no network access and transfers no data.
> index of file hashes. The scan service itself performs no network access; ads,
> consent and the optional Pro purchase are separate and never receive photo data.
2. **User impact if the task is deferred or interrupted.** A scan is not deferrable work —
the user is watching for a result — so there is no WorkManager/JobScheduler fallback:
@@ -451,29 +460,27 @@ action except the items marked **[code]**.
typically rated Everyone / 3+).
- [ ] **App access** → *All functionality is available without special access*: no login, no
account, nothing gated.
- [ ] **Ads** → *No, my app does not contain ads* (and no ad SDK in
`gradle/libs.versions.toml` to contradict the answer).
- [ ] **Advertising ID** → *No, my app does not use advertising ID.* The question adds "This
includes any SDKs that your app imports that use advertising ID", so the answer has to come
from the dependency graph rather than from the source: `play-services-ads-identifier` is what
provides the ID and it merges `AD_ID` into the manifest on its own, so adding any ad or
analytics SDK would flip this answer to *Yes* without one line of app code changing. Audited
2026-10-14 against the shipped artefacts rather than against intentions:
- [ ] **Ads** → **Yes, my app contains ads.** The free tier shows one AdMob banner;
Pro removes it. Play asks whether the app *contains* ads, not whether every user
sees them, so the answer is Yes.
- [ ] **Advertising ID** → **Yes, my app uses advertising ID.** The question adds "This
includes any SDKs that your app imports that use advertising ID"; the Google Mobile
Ads SDK merges `AD_ID` and the Privacy Sandbox permissions, and Play Billing merges
`BILLING`. Audited against the merged release manifest, not against intentions:
| Check | Command | Result |
| Check | Command | Expected |
|---|---|---|
| no advertising/analytics SDK, direct **or transitive** | `./gradlew --offline -q :app:dependencies --configuration releaseRuntimeClasspath \| grep -iE 'gms\|firebase\|ads\|billing\|play-services'` | no output |
| no `AD_ID` and no Privacy Sandbox permission in the release APK | `aapt2 dump badging app/build/outputs/apk/release/app-release.apk \| grep -i permission` | exactly the audit table above — 7 requested, plus the framework's `…DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION` |
| the same for the **`.aab`**, which is the artefact Play scans | `unzip -p app/build/outputs/bundle/release/app-release.aab base/manifest/AndroidManifest.xml \| strings \| grep -x 'AD_ID'` | 0 hits |
| no Play Services classes in the shipped code | `unzip -p app/build/outputs/apk/release/app-release.apk classes.dex \| grep -a -c 'com/google/android/gms'` | 0 |
| nothing could be sent even if an ID were read | the permission audit above | no `INTERNET` |
| ads + Billing dependencies, direct or transitive | `./gradlew -q :app:dependencies --configuration releaseRuntimeClasspath \| grep -iE 'play-services-ads\|billing\|user-messaging'` | `play-services-ads`, `billing`, `user-messaging-platform` |
| `AD_ID` and Privacy Sandbox permissions in the release APK | `aapt2 dump badging app/build/outputs/apk/release/app-release.apk \| grep -i permission` | the permission table above, including `AD_ID` and `ACCESS_ADSERVICES_*` |
| the same for the **`.aab`** Play scans | `unzip -p app/build/outputs/bundle/release/app-release.aab base/manifest/AndroidManifest.xml \| strings \| grep -E 'AD_ID\|BILLING'` | both present |
| Play Services classes in the shipped code | `unzip -p app/build/outputs/apk/release/app-release.apk classes.dex \| grep -a -c 'com/google/android/gms'` | greater than 0 (ads SDK) |
| network is possible | the permission audit above | `INTERNET` present |
This is the machine-checked version of what [PRIVACY.md](../PRIVACY.md) promises in words
("does not collect … advertising identifiers", "does not contain advertising SDKs or
third-party trackers"), so re-run the first two rows after **any** dependency change —
including one that looks unrelated. This is the declaration a stray library can answer
wrongly on the app's behalf, and the *Data safety* form's *Device or other IDs* answer is
*No* for the same reason.
This is the machine-checked version of what [PRIVACY.md](../PRIVACY.md) now says:
photos are processed on-device, while Google Mobile Ads collects/shared ad data for
advertising, analytics and fraud prevention. Re-run the audit after **any**
dependency change. The *Data safety* form's *Device or other IDs* answer is
**Yes** for the same reason.
- [ ] Select the target audience (not designed for children).
- [ ] Answer the remaining *App content* declarations **No** / not applicable: news app,
@@ -498,13 +505,25 @@ action except the items marked **[code]**.
- [x] Test with a library of several thousand photos to sanity-check scan time. **[code]** done on
the test device: the 5,363-photo library scans in **20.2 s cold / 11.0 s warm**, and the
screenshot run over 5,385 photos finished in **11.1 s** (6 unreadable files skipped).
- [x] **Freemium build on the real phone** (Xiaomi M2101K7AG, Android 12 / API 31):
**5,373 photos, 19 groups, 47 photos involved, 40.1 MB reclaimable, 25.5 s**
(signatures 2.2 s · exact 42 ms · perceptual 22.1 s), pHash cut fitted to ≤ 10 bits,
6 unreadable. The AdMob **adaptive test banner loaded**, the free/Pro toggle removed
it, the Pro sheet rendered, and **Buy Pro** showed the expected
“purchases unavailable” message because `pro_no_ads` is not active in the Console yet.
No app-level fatal; the only logcat fatal was the separate `uiautomator` dump tool.
**Warm retest on the same phone:** the cached index brings the same **5,373-photo**
library down to **3.0 s** (signatures 675 ms · exact 4 ms · perceptual 939 ms),
still **19 groups / 47 photos / 40.1 MB**. Buy Pro still reports “purchases
unavailable” because this debug build was sideloaded and `pro_no_ads` is not active
on the internal track yet; that is the expected gate, not a crash.
- [ ] Verify no crashes in *Play Console > Quality > Android vitals* after rollout.
## 7. Release notes ("What's new") and rollout
⚠️ **Which block applies:** `versionCode` **2** (1.0.1) is already in Play — its upload is what
consumed the code — so the next upload is **1.0.2 / `versionCode` 3** and takes the 1.0.2 block
below. The initial-release block is kept for the record; it was the 1.0.1 upload.
⚠️ **Which block applies:** `versionCode` **4** (1.1.0) is the freemium build, so paste the
1.1.0 block below. The 1.0.2 and initial-release blocks are kept for the record and are
historical — the initial block still says “no ads”, which was true only of the paid build.
Release notes are **not stored in this repo** — they are typed into the Play Console
@@ -539,7 +558,17 @@ Ready-to-paste block for the first release:
• No ads, no account, works fully offline
</en-US>
Ready-to-paste block for **1.0.2** (the `versionCode` 3 build):
Ready-to-paste block for **1.1.0** (the freemium build, `versionCode` 4):
<en-US>
• Foto Dup Finder is now free to download and use
• The free version is supported by a single banner; a one-time Pro purchase removes it
• Every duplicate-finding feature stays free
• Existing paid customers keep the ad-free experience
• Privacy options are available where required
</en-US>
Ready-to-paste block for **1.0.2** (the `versionCode` 3 build, historical):
<en-US>
• Maintenance release with compatibility fixes
@@ -564,27 +593,39 @@ Ready-to-paste block for **1.0.1** (the scan-robustness patch):
- [ ] Watch for newer AGP; when it supports it, update `compileSdk` to 37 and bump
the Compose BOM and Coil together (see the version note in the README).
- [ ] Optionally add crash reporting later — but note this would change the Data
safety answers, so weigh it against the "no data leaves the device" promise.
safety answers, so weigh it against the “photos never leave the device” promise.
## 9. Monetisation — decided: one-time paid app, no billing
## 9. Monetisation — freemium ads + one-time Pro
**The decision is made: Foto Dup Finder is a one-time paid app** (rationale, the €2.99 base price,
the €1.49 launch sale and the irreversibility rule: [STORE_LISTING](STORE_LISTING.md) › App pricing).
The Console work is in step 4; **nothing in this repository changes**, because a price on the listing
adds no code, no permission and no Data Safety answer — which is exactly what a free app with a Pro
unlock could not claim.
**Current model: freemium.** The app is free to download. The free tier shows one
anchored adaptive AdMob banner; a one-time Play Billing product **`pro_no_ads`**
removes it. Pro removes ads and nothing else — every scan, selection and deletion
feature stays free. Existing paid installs are grandfathered through
`legacyPro.cutoffEpochMs`.
The Console work is in step 4 and the declarations are in step 5; the full setup and
data-disclosure details are in [MONETIZATION](MONETIZATION.md). Rationale and current
copy: [STORE_LISTING › App pricing](STORE_LISTING.md#app-pricing).
Standing rules:
- **Ads: never.** Every ad SDK needs the `INTERNET` permission to fetch anything, and the
merged-manifest check in step 5, [PRIVACY.md](../PRIVACY.md) and the Data Safety answers all rest
on that permission being absent.
- **In-app purchases: deliberately absent.** If that ever changes, the requirement is Play Billing
**8+** (latest published: 9.1.0, with an extension available to Nov 1, 2026). Worth knowing before
the decision is re-litigated: the **Billing Library itself does not add `INTERNET`** —
`com.android.billingclient:billing:9.1.0`'s manifest declares only `com.android.vending.BILLING`
and `<queries>` for the billing service, which was checked by unpacking the AAR. What *would*
change is the store copy (the "pay once" line), `PRIVACY.md`, the acknowledgement/restore flow, and
the fact that a purchase can only be verified on an internal testing track — never locally.
- **Refunds and support** follow Play's policy for a paid app; keep the contact address in
- **One banner, no interstitials.** Do not add an interstitial, app-open, native or
rewarded format without a product decision and a UX/privacy review.
- **Consent before ads.** UMP must resolve before `MobileAds.initialize()`; a refused
or unresolved consent means no ad request. Pro users skip ad initialisation entirely.
- **Pro never gates a feature.** It removes the banner; a scan limit or a locked
deletion flow would change the product promise and the store copy.
- **Billing is one-time and acknowledged.** Play Billing 9.1.0, product `pro_no_ads`,
pending purchases enabled, acknowledgement retried. The entitlement is client-side
and cached; Play re-verifies on resume.
- **Grandfather paid customers.** Keep the install-time cutoff and document its
limitations; uninstall/reinstall can lose it.
- **Keep Data Safety and `PRIVACY.md` in step.** Google Mobile Ads collects/shares ad
data (ad ID, interactions, diagnostics, IP); photos remain on-device. The **Ads** and
**Advertising ID** answers are **Yes**.
- **Secrets stay out of the repo.** Real AdMob ids and the legacy cutoff live in
`local.properties` or CI Gradle properties; test ids may stay in the build defaults.
- **Re-shoot the store assets.** The committed screenshots and feature graphic predate
the banner and Pro sheet; the freemium listing needs new captures.
- **Refunds and support** follow Play policy; keep the contact address in
[PRIVACY.md](../PRIVACY.md) current.
+16 -12
View File
@@ -1,6 +1,6 @@
# Roadmap
Foto Dup Finder is built against a fixed milestone plan (**M0–M10**). This file is the
Foto Dup Finder is built against a fixed milestone plan (**M0–M11**). This file is the
single source of truth for what is done and what remains. Before this file existed the
plan lived only in developer notes, and the [CHANGELOG](../CHANGELOG.md) refers to
milestone labels (`M7`, `M8`).
@@ -20,8 +20,9 @@ Legend: ✅ done · 🚧 in progress · ⏳ not started · 💡 candidate (propo
| M6 | Release config & Play readiness | ✅ | R8/minify, optional signing, `.aab`, [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md), [PRIVACY.md](../PRIVACY.md), README |
| M7 | On-device validation & hardening | ✅ | Foreground `dataSync` service, one failure boundary per file, `core/DecodeMath`, hostile fixtures ([EDGE_CASE_TESTING](EDGE_CASE_TESTING.md)), `versionName` → 1.0.0 |
| M8 | Localisation groundwork | ✅ | Every user-visible string in `res/values/strings.xml` with real `<plurals>`, shared `text/TextRes.kt`; **English is the only locale** |
| M9 | Monetisation | ✅ | **Decided: a one-time paid app** — no free tier, no trial, no subscription and no in-app purchase, so there is **no Billing code** and no new permission. Checked before deciding: `com.android.billingclient:billing:9.1.0`'s manifest declares only `com.android.vending.BILLING`, so IAP would *not* have added `INTERNET` either — but a price on the listing is the one model that changes nothing at all about the "no internet permission" claim. Base price **€2.99** one-time with a **50% launch sale at €1.49**, both set in the Console (*Products > App pricing*). €1 as the *base* price was considered and rejected: a sale can always be added, but a low anchor cannot be undone, and a paid app's first transaction is its only transaction. Free → paid becomes impossible after the first upload, so this had to be settled before release. Rationale, copy changes and Console steps: [STORE_LISTING](STORE_LISTING.md) › App pricing, [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) step 4 |
| M9 | Monetisation | ✅ | **Revised from paid to freemium.** Free tier with one anchored AdMob banner + UMP consent; a one-time Play Billing product (`pro_no_ads`) removes it. Pro only removes ads — every scan/selection/deletion feature stays free. Existing paid installs are grandfathered through `legacyPro.cutoffEpochMs`. Setup, Data Safety and Console steps: [MONETIZATION](MONETIZATION.md) |
| M10 | Store assets | ✅ | `tools/make-store-assets.sh` renders the 512×512 icon and the 1024×500 feature graphic from the app's own vectors; `tools/make-store-screenshots.sh` normalises device captures to Play's 2:1 limit, one directory per form factor (`phone` → 1080×2160, `tablet-7in` → 1200×1920, `tablet-10in` → 1600×2560); `tools/make-demo-photos.py` generates the photo library the results captures are taken over, so no real photos are published; all listing copy is drafted and length-checked in [STORE_LISTING](STORE_LISTING.md). The phone set was re-shot on a real device after a real permission grant, and the two tablet sets were captured on AOSP AVDs (see the blocker below); the finished assets — icon, feature graphic, the twelve normalised screenshots and the demonstration video — are committed, so Gitea serves them publicly and pushing is the deployment step |
| M11 | Freemium implementation | ✅ | AdMob anchor banner + UMP consent, Play Billing `pro_no_ads`, Pro sheet, ad gate, legacy paid-install migration, focused tests, [codemap](codemap.md) / [codemap.mmd](codemap.mmd), [AGENTS.md](../AGENTS.md), [MONETIZATION](MONETIZATION.md), README/PRIVACY/CHANGELOG/store-doc updates. **Remaining:** publish the new free Play listing at `…finder.free`, create/activate `pro_no_ads`, add the AdMob app/unit + UMP message, set the legacy cutoff, update Data Safety / Ads / Advertising ID, and re-shoot the screenshots with the banner and Pro sheet |
## Release blockers (work that is not a numbered milestone)
@@ -30,9 +31,9 @@ Legend: ✅ done · 🚧 in progress · ⏳ not started · 💡 candidate (propo
| ~~Large-library scan stall~~ ✅ **fixed — verified on device** | The 5,363-photo library used to freeze at *“74 / 100 · Comparing file signatures…”* (a **blocked syscall**: zero CPU, workers sleeping). `BoundedCall` now abandons a stuck provider call **and** trips a stall breaker after three consecutive timeouts. **Verified on the real test device (Android 12 / MIUI): the scan completes — 20.2 s cold, 11.0 s warm, 15 groups, 6 unreadable — where it used to hang.** Covered by `BoundedCallTest` and `ScanEngineEndToEndTest` |
| ~~Unreleased `BoundedCall` fix~~ ✅ | The provider-call deadline shipped in **1.0.1** (`versionCode` 2) |
| **Play Console: foreground-service declaration** | Declaring the `dataSync` type (App content › Foreground service permissions) is release-blocking. **[code]** the manifest already declares it, [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) step 5 carries all four things the form asks for (description, defer/interrupt impact, use case **Local processing: Other**, video link), and the **video now exists**: recorded on the test device on 2026-10-14 with `INSTALL=0 WARMUP=0 tools/record-fgs-demo.sh`, then verified frame by frame rather than assumed — intro at 0 s, the scan starting, **~6 s of the shade with the live "Finding duplicate photos / Looking for visually similar photos… / CANCEL" notification while the scan kept running**, and the results at the end. It is committed, and that is what published it — the link is the file's **page** in Gitea (`/src/branch/main/…`), which plays it anonymously. The `/raw/` URL is deliberately not the link: Gitea sends `Content-Security-Policy: default-src 'none'` with raw responses, so a browser navigating to the video sits on a blank tab even though the bytes are perfect. Pasting the page URL into the declaration is all that is left. Two details of the take are recorded in step 5 because they each cost an attempt: a *warm* scan is 5.4 s, shorter than the shade takes to open, so `WARMUP=0` films the cold one; and MIUI refuses `adb install` outright, so `INSTALL=0` records with the build already on the device. On a KVM-less emulator the same video cannot be made at all: every scan start dies as `am_crash … ForegroundServiceDidNotStartInTimeException` → *Force finishing activity* with no `am_kill`, i.e. emulation is too slow to reach `startForeground()` inside Android's budget (QEMU's `-icount` clock dilation made it work once, not reproducibly) |
| **Remaining Play paperwork** | Console actions only, no code: **confirm Play App Signing enrolment from the 1.0.1 upload**, the **hosted privacy policy URL** (the working copy is now published to Gitea as [`fishfacegit/foto-duplicate-finder`](https://gitea.softwareapp-hb.de/fishfacegit/foto-duplicate-finder), so the policy renders at a public, login-free URL and only the Console paste is left), **Data safety**, the **Photo/video permissions** declaration, the **content rating / audience / app access / ads / advertising ID / export** questions, and the **listing copy + the three screenshot sets** (phone, 7-inch and 10-inch, all captured), plus the **paid-app setup**: a payments profile with tax rates, the €2.99 price and the 14-day €1.49 launch sale on *Products > App pricing* — the price must be confirmed before the next rollout, because free → paid is not possible once the app has been offered for free (M9). Keystore, `versionCode`, listing copy, graphics, permission audit and the signed `.aab` (`sha256 534e5ae9…`, `versionCode` 3) are all in place; rollout goes internal → closed → production. Step-by-step: [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) |
| ~~Store screenshots need one re-shoot~~ ✅ **done — verified on device** | The old captures showed the *Photo access needed* banner (an app-op is not a grant) and `03-results.png` showed the developer's own library. After a real grant the set was re-shot over the generated demo library: **01-empty** (no tap needed — results and selection live in `ScannerViewModel`, so force-stop + relaunch returns to the empty state with the grant still in place), **02-scanning** (`5353 / 5385`), **03-results** (**17 groups, 54 of 5385 photos, 83.5 MB reclaimable**; the headline group's 43.1 MB out-ranks the device's own 39.8 MB, so no real photo is in frame) and **04-options**. Captures are taken by watching for UI **text** changes, because MIUI refuses synthetic taps (`INJECT_EVENTS`). The demo library is deleted from the test device afterwards — MediaStore **5,386 → 5,364** rows, and the 22 stale rows it leaves in the hash index are pruned by `PhotoIndexStore.pruneTo` on the next scan. Deliberately not captured: the staged state and the system confirmation dialog, because staging clears the demo group and would put real photos back in frame. Details: [STORE_LISTING](STORE_LISTING.md) |
| ~~Tablet store screenshots outstanding~~ ✅ **done — captured on AVDs** | Play has a **7-inch tablet** and a **10-inch tablet** screenshot slot of its own (asking for **≥ 4** screenshots on large screens). Both are now captured on AOSP Android 12 AVDs — `Nexus 7 2013` (1200×1920, `sw600dp`) and `medium_tablet` (1600×2560, `sw800dp`) — because this machine exposes no `/dev/kvm`: they ran in **pure software emulation** (`-accel off -no-window -gpu swiftshader_indirect`), ≈3 min to boot, with `hide_error_dialogs` on so SystemUI's ANR dialog could not sit in frame. Four screens per tablet over the same generated demo library: empty, scanning (20 / 22), results (**2 groups · 16 of 22 photos · 43.7 MB reclaimable**, 39.7 s / 53.1 s) and Options. `tools/make-store-screenshots.sh` is form-factor aware (`FORM_FACTOR=phone\|tablet-7in\|tablet-10in`) and the tablet form factors crop **0 px** of chrome, because a tablet frame is already inside Play's 2:1 cap. Recipe: [STORE_LISTING](STORE_LISTING.md) |
| **Remaining Play paperwork** | Console actions only, no code: the **hosted privacy policy URL** (the working copy is now published to Gitea as [`fishfacegit/foto-duplicate-finder`](https://gitea.softwareapp-hb.de/fishfacegit/foto-duplicate-finder), so the policy renders at a public, login-free URL and only the Console paste is left), **Data safety**, the **Photo/video permissions** declaration, the **content rating / audience / app access / ads / advertising ID / export** questions, and the **listing copy + the three screenshot sets** (phone, 7-inch and 10-inch, all captured), plus the **freemium setup**: publish the new listing at `de.softwareapp_hb.fotodup.finder.free` as **Free**, create and activate the one-time product `pro_no_ads`, add the AdMob app/banner unit and UMP message, set `legacyPro.cutoffEpochMs` to the first freemium release, and update the **Ads / Advertising ID / Data Safety** answers ([MONETIZATION](MONETIZATION.md)). The old paid listing at `.finder` and its €2.99 price/sale are left untouched. Confirm **Play App Signing for the new app** (the same upload key can sign both listings). Keystore, `versionCode`, listing copy, graphics, permission audit and the signed `.aab` (the 1.0.2 `versionCode` 3 build is historical; the 1.1.0 validation build is in [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) step 3) are in place; rollout goes internal → closed → production. Step-by-step: [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) |
| ~~Store screenshots need one re-shoot~~ ✅ **done for the paid build — freemium re-shoot pending** | The old captures showed the *Photo access needed* banner (an app-op is not a grant) and `03-results.png` showed the developer's own library. After a real grant the set was re-shot over the generated demo library: **01-empty** (no tap needed — results and selection live in `ScannerViewModel`, so force-stop + relaunch returns to the empty state with the grant still in place), **02-scanning** (`5353 / 5385`), **03-results** (**17 groups, 54 of 5385 photos, 83.5 MB reclaimable**; the headline group's 43.1 MB out-ranks the device's own 39.8 MB, so no real photo is in frame) and **04-options**. Captures are taken by watching for UI **text** changes, because MIUI refuses synthetic taps (`INJECT_EVENTS`). The demo library is deleted from the test device afterwards — MediaStore **5,386 → 5,364** rows, and the 22 stale rows it leaves in the hash index are pruned by `PhotoIndexStore.pruneTo` on the next scan. Deliberately not captured: the staged state and the system confirmation dialog, because staging clears the demo group and would put real photos back in frame. **The freemium build additionally needs the banner and the Pro sheet in frame; re-shoot before the 1.1.0 listing.** Details: [STORE_LISTING](STORE_LISTING.md) |
| ~~Tablet store screenshots outstanding~~ ✅ **done for the paid build — freemium re-shoot pending** | Play has a **7-inch tablet** and a **10-inch tablet** screenshot slot of its own (asking for **≥ 4** screenshots on large screens). Both are now captured on AOSP Android 12 AVDs — `Nexus 7 2013` (1200×1920, `sw600dp`) and `medium_tablet` (1600×2560, `sw800dp`) — because this machine exposes no `/dev/kvm`: they ran in **pure software emulation** (`-accel off -no-window -gpu swiftshader_indirect`), ≈3 min to boot, with `hide_error_dialogs` on so SystemUI's ANR dialog could not sit in frame. Four screens per tablet over the same generated demo library: empty, scanning (20 / 22), results (**2 groups · 16 of 22 photos · 43.7 MB reclaimable**, 39.7 s / 53.1 s) and Options. `tools/make-store-screenshots.sh` is form-factor aware (`FORM_FACTOR=phone\|tablet-7in\|tablet-10in`) and the tablet form factors crop **0 px** of chrome, because a tablet frame is already inside Play's 2:1 cap. Recipe: [STORE_LISTING](STORE_LISTING.md) |
| **Device-only verifications** | RAW/DNG files, a *real* iPhone HEIC with a non-upright EXIF orientation, permission revoked mid-scan, and the Android 14 “Selected photos” flow. ✅ The **index-reuse** check is done: after a scan the index holds **5,363 rows, 5,357 with a perceptual hash**, and a second scan runs in **11.0 s vs 20.2 s** cold |
## Candidate milestones (proposed, not scheduled)
@@ -47,8 +48,9 @@ Legend: ✅ done · 🚧 in progress · ⏳ not started · 💡 candidate (propo
## Suggested order
1. ✅ **Done** — the scan-stall hardening and the `BoundedCall` fix shipped as **1.0.1**
(`versionCode` 2). 1.0.2 (`versionCode` 3) is the build to upload, because Play has already
consumed code 2. Only the on-device re-check of the 5,363-photo scan remains.
(`versionCode` 2); **1.0.2** (`versionCode` 3) was the last paid build. The next upload is
**1.1.0** (`versionCode` 4), the freemium build, which also needs the Play Console changes in
[MONETIZATION](MONETIZATION.md). Only the on-device re-check of the 5,363-photo scan remains.
2. Finish the Play Console paperwork and roll out through **internal → closed → production**.
3. ✅ **Done** — **M10 store assets**: the icon and feature graphic are generated from the
app's own vectors, the screenshot normaliser enforces Play's 2:1 limit, the listing copy is
@@ -58,10 +60,12 @@ Legend: ✅ done · 🚧 in progress · ⏳ not started · 💡 candidate (propo
and the 7-inch and 10-inch tablet sets were captured on AOSP AVDs in software emulation
(1200×1920 and 1600×2560), so all three screenshot sets now exist.
4. **Colour signature** — the flat-colour false-positive fix.
5. ✅ **Done** — **M9 monetisation**: decided as a **one-time paid app (€2.99, launched with a 14-day
50% sale at €1.49)**, which needs no code at all. The remaining work is Console-only — a payments
profile, the price and the launch sale on *Products > App pricing* — and the price has to be
confirmed before the next rollout, because free → paid stops being possible once the app has been
offered for free.
5. ✅ **Done — M9/M11 freemium**: free tier with one anchored AdMob banner, one-time
Play Billing `pro_no_ads` removes it, UMP consent, legacy paid-install
grandfathering, tests and docs. The remaining work is Console-only — publish the new
free listing at `.finder.free`, create/activate `pro_no_ads`, add the AdMob app/unit
and UMP message, set the legacy cutoff, update Ads/Advertising ID/Data Safety, and
re-shoot the store screenshots with the banner and Pro sheet. See
[MONETIZATION](MONETIZATION.md).
Deliberately deferred: **video support** and the **“similar shots”** section.
+76 -49
View File
@@ -118,8 +118,8 @@ in `ScannerViewModel` (only the hash index is persisted), so force-stopping and
returns to the empty state with the grant still in place:
```bash
adb shell am force-stop de.softwareapp_hb.fotodup.finder.debug
adb shell am start -n de.softwareapp_hb.fotodup.finder.debug/de.softwareapp_hb.fotodup.finder.MainActivity
adb shell am force-stop de.softwareapp_hb.fotodup.finder.free.debug
adb shell am start -n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.MainActivity
adb exec-out screencap -p > store-assets/raw-screenshots/phone/01-empty.png
```
@@ -192,7 +192,7 @@ adb shell settings put system user_rotation 3 # tablet10 only; the Nexus 7 is
# 4. The phone set's prerequisites: the app, the permission, the demo library.
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb shell pm grant de.softwareapp_hb.fotodup.finder.debug android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant de.softwareapp_hb.fotodup.finder.free.debug android.permission.READ_EXTERNAL_STORAGE
python3 tools/make-demo-photos.py
adb push demo-photos/foto-dup-demo /sdcard/DCIM/foto-dup-demo
adb shell content call --uri content://media --method scan_file --arg /sdcard/DCIM/foto-dup-demo
@@ -200,8 +200,8 @@ adb shell content call --uri content://media --method scan_file --arg /sdcard/DC
# 5. Capture. `01` is one screencap. The other three need a tap, so their coordinates come from
# `uiautomator dump` instead of guesswork, and a screencap burst *started before the tap* is what
# catches the short scanning screen — 22 photos scan in seconds even under emulation.
adb shell am force-stop de.softwareapp_hb.fotodup.finder.debug
adb shell am start -n de.softwareapp_hb.fotodup.finder.debug/de.softwareapp_hb.fotodup.finder.MainActivity
adb shell am force-stop de.softwareapp_hb.fotodup.finder.free.debug
adb shell am start -n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.MainActivity
adb exec-out screencap -p > store-assets/raw-screenshots/tablet-7in/01-empty.png
# ... burst frames into /tmp, tap "Start scan" (7-inch 600 1155, 10-inch 800 1465), keep the frame
# showing "Looking for visually similar photos… N / 22" for 02 and the one after it for 03,
@@ -292,21 +292,40 @@ enough, so the capture never depends on tap timing; that is how `04-options.png`
## App pricing
**Decision: a one-time paid app — a free download is off the table.** Foto Dup Finder is sold on
Google Play at a single price: no free tier, no trial, no subscription, no in-app purchase. Nothing
in this repository changes because of that decision — it lives in the Play Console, and the app
carries **no Billing code at all** (see [PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) step 4).
**Current decision: freemium, as a new listing.** The freemium build uses
`applicationId = de.softwareapp_hb.fotodup.finder.free`, so it is a **new Play
listing**, separate from the old paid app at `de.softwareapp_hb.fotodup.finder`.
Publish it as **Free** (new apps are free by default); do not change the old paid
listing's price. The free tier shows one anchored adaptive AdMob banner; a one-time
in-app purchase (`pro_no_ads`) removes it. There is no subscription, no trial and no
account, and Pro only removes ads — every duplicate-finding, selection and deletion
feature stays free.
Why paid rather than free-with-a-Pro-unlock:
Why freemium replaced the paid listing:
- The app is a **single-purpose utility with no running costs** — no servers, no sync, no accounts —
so there is nothing a subscription would fund and nothing to keep charging for.
- Play Billing would merge `com.android.vending.BILLING` into the manifest and put a purchase screen
into an app whose whole pitch is "no account, no tracking, nothing leaves the device". A price on
the listing costs **zero permissions and changes zero Data Safety answers** — a claim no other
monetisation of this app can make.
- There is no ad SDK and there never will be: an ad SDK adds the `INTERNET` permission, and the
merged-manifest and Data Safety claims below would immediately stop being true.
- A free download is the only way to reach users who will not pay up front for a
single-purpose utility. The ad-supported tier funds the app; Pro gives the people
who value it a clean, ad-free experience.
- The purchase stays **one-time**, matching the old paid-app promise and avoiding a
subscription for something with no running server cost.
- Existing paid customers are grandfathered into Pro through the install-time cutoff
when the old paid app is still installed on the first freemium launch, so going free
does not take anything away from them. Customers who removed the old app need a
promo code or support flow.
- The cost is explicit: the ads SDK adds `INTERNET`, `ACCESS_NETWORK_STATE`, `AD_ID`
and the `ACCESS_ADSERVICES_*` permissions; Billing adds
`com.android.vending.BILLING`. The merged-manifest and Data Safety answers below
reflect that.
**Play Console work:** set *Monetise › Products › App pricing* to **Free**, create
and activate the one-time product `pro_no_ads`, add the AdMob app/banner unit and a
UMP message, and update the **Ads**, **Advertising ID** and **Data Safety**
declarations. Full steps: [MONETIZATION](MONETIZATION.md). The price is read from Play
at runtime, so no code change is needed to change it.
> **Historical record — the paid-app rationale below is superseded.** It is kept for
> the release history, not as current guidance. The app is no longer sold once, does
> carry Billing and ads, and no longer has the "no INTERNET permission" claim.
⚠️ **The choice is only reversible while the app has not been offered for free.** Play's rule, from
*Set up your app's prices*: *“You can change your app from paid to free. Once your app has been
@@ -420,28 +439,38 @@ time. Use a promo code, never a real purchase, for your own end-to-end buying te
### Short description (max 80 characters)
Find and remove duplicate photos. Ad-free, works offline, no uploads.
Find duplicate photos. Free with ads; Pro removes them.
Alternative, if the no-account promise should lead:
Alternative, if the privacy promise should lead:
Find and delete duplicate photos. No ads, no uploads, no account.
Find duplicate photos, offline. Free with ads; optional ad-free Pro.
Neither option may say "free": the app is paid, so the claim would simply be false. Play's metadata
policy also bans price and promotional wording in the **app title, icon and developer name**
("free for limited time only" is its own example), which is why the price story below lives in the
description body and is written as a plain statement of fact — no discounts, no urgency, nothing
that reads as a promotion.
The two options are **55** and **68** characters, both inside Play's 80-character
limit. The app is free to download, so “free” is accurate now. Play's metadata policy
still bans price and promotional wording in the **app title, icon and developer name**
(“free for limited time only” is its own example); the free/Pro distinction belongs
in the description body, stated as fact rather than as an urgency device.
### Full description (max 4000 characters)
Find and remove duplicate photos, then get the space back. Foto Dup Finder does one
job and does it without ads, without an account and without ever uploading anything.
The draft below is **2,701 characters**, leaving room for review or a new feature
paragraph.
Find and remove duplicate photos, then get the space back. Foto Dup Finder does
one job, keeps your photos on your device, and gives you a clean, ad-free
experience with a one-time Pro purchase.
FREE WITH ONE BANNER, PRO WITHOUT ADS
• The free tier has every feature and one small banner at the bottom.
• A one-time Pro purchase removes the banner. No subscription, no account.
• Nothing is locked behind Pro — scanning, selecting and deleting stay free.
WHY IT IS DIFFERENT
• Pay once, then own it. No ads, no banners, no interstitials, no subscriptions and no
in-app purchases — there is nothing else to buy, now or later.
• No internet permission at all, so the app has no way to upload your photos.
• No account, no sign-in, no tracking, no analytics.
• Your photos never leave your device. Only the optional ad/consent SDK and
Google Play Billing use the network.
• No account, no sign-in, no app-level tracking or analytics. The ads SDK's data
use is described in the privacy policy.
• No in-app currency, no subscription, nothing else to buy.
WHAT IT DOES
• Finds exact copies: files that are byte-for-byte identical, even when their names
@@ -468,29 +497,27 @@ that reads as a promotion.
4. Tap "Remove all selected" and confirm once for the whole batch.
YOUR PHOTOS STAY YOURS
Foto Dup Finder declares no internet permission, ships no advertising or analytics
SDKs, and stores nothing besides a local index of file hashes so the next scan can be
quick. No photo ever leaves your phone, and uninstalling the app removes the index
with it.
Foto Dup Finder stores nothing besides a local index of file hashes so the next
scan can be quick. No photo ever leaves your phone, and uninstalling the app
removes the index with it. Ads and purchases need a connection; finding duplicates
does not.
GOOD TO KNOW
• Requires Android 8.0 or newer.
• Sold through Google Play as a one-time purchase — no subscription, no in-app
purchases, no account.
• Free to download. One optional one-time Pro purchase removes the banner.
• Photos moved to the trash can be restored from your gallery app until the trash is
emptied (Android 11 and newer).
• Works fully offline, in flight mode, always.
• Duplicate scanning works fully offline, in flight mode, always.
Every claim above is checkable against this repository: no `INTERNET` permission in the
merged manifest, no ad or analytics dependency in `gradle/libs.versions.toml`, `minSdk 26`
in `app/build.gradle.kts`, and the second-run speed-up is the persistent hash index in
`data/PhotoIndexStore.kt`.
Every claim above is checkable against this repository: the ad/Billing dependencies in
`gradle/libs.versions.toml`, the merged-manifest permissions (including `INTERNET`,
`AD_ID` and `BILLING`), `minSdk 26` in `app/build.gradle.kts`, and the second-run speed-up is
the persistent hash index in `data/PhotoIndexStore.kt`.
The price is the one claim that is *not* in here, because it is a Play Console setting
(`Products > App pricing`) rather than code. What *is* checkable is the rest of the monetisation
story — the absence of it: no Billing dependency in `gradle/libs.versions.toml`, and no
`com.android.vending.BILLING` in the merged manifest (see
[PLAY_RELEASE_CHECKLIST](PLAY_RELEASE_CHECKLIST.md) step 5).
The price is *not* in the app: it is a Play Console setting (and Play's localized
`formattedPrice` is what the Pro sheet shows). The product id **`pro_no_ads`** is in
`monetization/ProProduct.kt`; the free/Pro gate, consent and Data Safety answers are
documented in [MONETIZATION](MONETIZATION.md).
### Category and tags
@@ -510,7 +537,7 @@ story — the absence of it: no Billing dependency in `gradle/libs.versions.toml
| Tag | Verdict | Reason |
|---|---|---|
| **Photography** | ✅ use | The app's subject *is* the user's photo library, and someone who reads "find duplicate photos" sees immediately why the tag is there. This is the only photo-domain tag that applies. Available while the category is *Tools*; if the category is *Photography* it is the category itself and therefore redundant. |
| **Privacy & security** | ⚠️ optional | Defensible: the listing *leads* with "no internet permission at all", "no account, no tracking, no analytics", and that is visible to an unfamiliar user — Google's test. But it pulls in people browsing privacy tools who are not after a photo cleaner. Add it only if that discovery surface is wanted. |
| **Privacy & security** | ⚠️ optional | Defensible: the listing leads with on-device photo processing, “no account, no tracking, no analytics” and “your photos never leave your device”. That is visible to an unfamiliar user — Google's test. But it pulls in people browsing privacy tools who are not after a photo cleaner, and the app now has ads, so the claim is narrower than it used to be. Add it only if that discovery surface is wanted. |
| *anything else* | ❌ | Nothing else in the list describes this app; see below. |
Tags cannot express *"duplicate"* at all, so **search discovery rests on the title and short
+496
View File
@@ -0,0 +1,496 @@
# Foto Dup Finder — Code Map
A navigable map of the freemium Android app: its static dependency structure, the
scan pipeline, the two-step deletion flow, and the free/Pro monetisation paths.
> **Status:** living document. Update it whenever a module, permission, product id,
> scan phase or ownership rule changes. The standalone graph is
> [`codemap.mmd`](codemap.mmd); agent-specific rules live in
> [`../AGENTS.md`](../AGENTS.md).
## 1. Reading guide
| Notation | Meaning |
|---|---|
| Solid arrow `A --> B` | compile-time import/dependency or a direct runtime call |
| Dotted arrow `A -.-> B` | implements a contract, indirect use, or an external SDK/service |
| `subgraph` | architectural layer or feature area |
| `[(...)]` | external resource: MediaStore, SQLite, SharedPreferences, Google services |
| `free`/`pro` | the two monetisation states; they differ **only** by the banner |
Mermaid renders natively on GitHub, GitLab, Gitea and VS Code's Markdown preview.
The full standalone graph is [`codemap.mmd`](codemap.mmd); the diagrams below focus
on the flows that are hard to read from a static graph.
## 2. Layered architecture
```mermaid
flowchart TB
subgraph ENTRY["Entry"]
app["FotoDupApplication<br/>ScanController + ProStore + AdsController"]
main["MainActivity<br/>edge-to-edge, consent, purchase refresh"]
end
subgraph UI["UI — Compose"]
screen["ScannerScreen"]
vm["ScannerViewModel"]
sections["ScannerSections"]
groups["GroupSection"]
banner["BannerAdSlot"]
proSheet["ProSheet"]
end
subgraph DOMAIN["Domain"]
controller["ScanController"]
engine["ScanEngine"]
models["ScanModels"]
end
subgraph DATA["Data"]
source["MediaStorePhotoSource"]
hasher["PhotoHasher"]
index["PhotoIndexStore"]
deleter["MediaDeleter"]
end
subgraph CORE["Core — pure Kotlin"]
hashing["Hashing"]
perceptual["PerceptualHash"]
rgb["RgbDHash"]
grouper["DuplicateGrouper"]
policy["DuplicatePolicy"]
end
subgraph MONETIZATION["Monetization"]
proStore["ProStore"]
ads["AdsController"]
adPolicy["AdPolicy"]
legacy["LegacyPro"]
end
mediaStore[("MediaStore")]
db[("photo_index.db")]
prefs[("pro_entitlement prefs")]
play[("Play Billing")]
admob[("AdMob")]
ump[("UMP")]
main --> app
main --> screen
main --> ads
screen --> vm
screen --> banner
screen --> proSheet
vm --> controller
vm --> proStore
vm --> ads
vm --> deleter
controller --> engine
controller --> models
engine --> source
engine --> hasher
engine --> index
engine --> grouper
engine --> policy
source -.-> mediaStore
hasher -.-> mediaStore
index -.-> db
hasher --> hashing
hasher --> perceptual
hasher --> rgb
grouper --> policy
banner --> adPolicy
proStore --> legacy
proStore -.-> prefs
proStore -.-> play
ads -.-> ump
ads -.-> admob
```
### Layer responsibilities
| Layer | Owns | Must not do |
|---|---|---|
| `core/` | hashing, dHash/pHash, grouping, thresholds, decode maths | import Android |
| `data/` | MediaStore, file reads, SQLite cache, deletion requests, permissions | decide UI policy |
| `domain/` | scan orchestration, process-scoped scan state, progress models | know about Compose |
| `service/` | foreground-service notification for a running scan | contain scan logic |
| `monetization/` | UMP consent, Mobile Ads init, Play Billing entitlement, legacy cutoff | decide scan/delete behaviour |
| `ui/` | Compose screen, selection/staging, ad slot, Pro sheet | hash or delete photos directly |
| `text/` | enum-to-resource mappings shared by UI and notification | contain user-visible literals |
## 3. Compile-time dependency graph
The standalone [`codemap.mmd`](codemap.mmd) is the complete node/edge graph. The
allowed direction of dependencies is intentionally narrow:
| From | May depend on | Notes |
|---|---|---|
| `core/` | Kotlin + `java.security`/`java.io` only | no Android imports; covered by JVM tests |
| `data/` | `core/` | Android framework + MediaStore access lives here |
| `domain/` | `core/`, `data/` | no Compose, no Activity |
| `service/` | `domain/`, `R`, notification APIs | mirrors `ScanController`, no scan logic |
| `monetization/` | Android SDKs, Play Billing, UMP, Ads, `BuildConfig`, `R` | no photo access |
| `ui/` | `core/`, `data/`, `domain/`, `monetization/`, `text/` | the only layer that knows Compose |
| `text/` | `core/`, `domain/`, `R` | maps enums to strings for UI *and* notification |
Two consequences worth preserving:
- `core/` stays testable on a plain JVM. The benchmark and edge-case harnesses rely
on that, as do the fast unit tests.
- The ad/Billing layer never touches the photo pipeline. A failed ad request, a
refused consent or an unavailable Play Store cannot stop a scan or a deletion.
## 4. Scan runtime flow
```mermaid
sequenceDiagram
actor User
participant UI as ScannerScreen
participant VM as ScannerViewModel
participant SC as ScanController
participant SVC as ScanService
participant SE as ScanEngine
participant MS as MediaStorePhotoSource
participant PH as PhotoHasher
participant IDX as PhotoIndexStore
participant DG as DuplicateGrouper
User->>UI: Scan
UI->>VM: startScan()
VM->>SC: start(policy)
SC->>SVC: start foreground service
SC->>SE: scan(policy)
SE->>MS: loadPhotos()
MS-->>SE: List<PhotoRecord>
SE->>IDX: loadAll()
IDX-->>SE: cached IndexEntry rows
SE->>SE: group by size (exact candidates only)
SE->>PH: quick signatures (same-size candidates)
PH->>MS: read first/last 32 KB
SE->>PH: SHA-256 (buckets with 2+ members)
SE->>PH: pHash + RGB dHash (one decode each)
PH->>MS: thumbnail or fallback decode
SE->>IDX: upsert + pruneTo()
SE->>DG: group(exact, perceptual, policy, fit)
DG-->>SE: List<DuplicateGroup>
SE-->>SC: ScanProgress.Finished(ScanResult)
SC-->>VM: StateFlow<ScanState>
VM-->>UI: groups, summary, selection
SC->>SVC: stop foreground service
```
### Phases
| Phase | What runs | Parallel? |
|---|---|---|
| `LOADING` | `MediaStorePhotoSource.loadPhotos()` | no |
| `SIGNATURES` | cheap size + head/tail signature, only same-size candidates | yes, CPU-bound |
| `CONTENT` | full SHA-256, only signature buckets with 2+ members | yes |
| `PERCEPTUAL` | pHash + RGB dHash for every readable photo (skipped for `EXACT_ONLY`) | yes |
| `GROUPING` | union-find clustering, adaptive threshold fit | no |
`ScanController` owns the only running scan. It survives activity recreation and
keeps going when the app is backgrounded because `ScanService` holds a `dataSync`
foreground service for the duration. The ViewModel only mirrors progress; it never
owns the scan.
Three failure boundaries matter:
- `BoundedCall` gives every provider call a deadline, so one wedged file cannot
freeze the scan.
- `withTimeoutOrNull` around per-photo hashing skips a photo that is too expensive
to decode.
- A failed photo is counted in `ScanResult.unreadableCount`; it does not abort the
scan.
## 5. Monetisation flow
### 5.1 Free tier: consent before any ad request
```mermaid
flowchart TD
launch["App launch"] --> cache{"Cached Pro or<br/>legacy paid install?"}
cache -->|yes| noAds["No ad SDK init<br/>BannerAdSlot absent"]
cache -->|no| consent["ConsentInformation<br/>requestConsentInfoUpdate()"]
consent --> form["loadAndShowConsentFormIfRequired()"]
form --> can{"canRequestAds()?"}
can -->|no| noAds
can -->|yes| init["MobileAds.initialize()"]
init --> gate{"AdPolicy.shouldShowBanner()<br/>!isPro && consent && initialized"}
gate -->|true| banner["BannerAdSlot<br/>anchored adaptive AdView"]
gate -->|false| noAds
```
The gate is deliberately conservative. A missing network, a missing Play services
install, a consent refusal or a failed SDK init all end at **no banner**, never at a
crash or a blank placeholder. `AdPolicy` is a pure function and is unit-tested
without Android.
### 5.2 Pro: one-time purchase
```mermaid
sequenceDiagram
actor User
participant Sheet as ProSheet
participant VM as ScannerViewModel
participant Store as ProStore
participant Play as Google Play Billing
User->>Sheet: Buy Pro / Buy for €X
Sheet->>VM: purchasePro(activity)
VM->>Store: purchase(activity)
Store->>Play: queryProductDetailsAsync(pro_no_ads)
Play-->>Store: ProductDetails + formattedPrice
Store->>Play: launchBillingFlow(activity, productDetails)
Play-->>User: Play purchase sheet
Play-->>Store: onPurchasesUpdated(result, purchases)
Store->>Store: filter product id, require PURCHASED
Store->>Play: acknowledgePurchase(token)
Store-->>VM: ProState(isPro = true, priceText = ...)
VM-->>Sheet: state update
Sheet-->>User: closes, banner removed
```
**Purchase states that matter**
| Play result | What `ProStore` does |
|---|---|
| `PURCHASED` | grants Pro locally, acknowledges, removes the banner immediately |
| `PENDING` | does **not** grant Pro; shows `message_purchase_pending` |
| `USER_CANCELED` | no grant, no error message |
| `ITEM_ALREADY_OWNED` | refreshes purchases and grants if Play reports the product |
| `SERVICE_DISCONNECTED` / unavailable | keeps the cached entitlement, shows an unavailable message |
Acknowledgement is retried from `KEY_PENDING_ACK` on the next refresh. Play refunds
an unacknowledged one-time purchase after three days, so this retry is not optional.
### 5.3 Entitlement state machine
```mermaid
stateDiagram-v2
[*] --> Free
Free --> Pending: purchase returns PENDING
Pending --> Pro: Play later reports PURCHASED
Pending --> Free: payment cancelled
Free --> Pro: purchase PURCHASED
Pro --> Free: successful Play query returns no purchase
Pro --> Pro: offline / query failure (cached entitlement kept)
Free --> Pro: legacy install before cutoff
note right of Pro
Legacy Pro is independent of Play.
It is never revoked by a purchase query.
end note
```
### 5.4 Monetisation classes
| Class | Responsibility | Never does |
|---|---|---|
| `ProStore` | Billing connection, product details, purchase, acknowledgement, cached entitlement, legacy migration | read photos or decide UI |
| `AdsController` | UMP consent update/form, `MobileAds.initialize`, privacy-options form | request an ad itself |
| `AdPolicy` | pure banner gate (`!isPro && canRequestAds && initialized`) | touch Android |
| `LegacyPro` | pure install-time cutoff predicate | know about Billing |
| `BannerAdSlot` | one `AdView`, adaptive size, pause/resume/destroy | reload on recomposition |
| `ProSheet` | price, benefits, buy/restore, pending/unavailable states | gate a scan feature |
### 5.5 Legacy paid installs
The app was previously sold as a one-time paid app. Play does not expose "this app
was bought as paid" through Billing, so the best available signal is
`PackageInfo.firstInstallTime`:
- set `legacyPro.cutoffEpochMs` to the instant of the first freemium release;
- every install older than that instant is treated as a paid install and gets Pro;
- `KEY_ORIGIN_RESOLVED` persists the decision so a later Play query cannot revoke it;
- a cutoff of `0` disables the migration.
Known limits: uninstall/reinstall, clearing app data, or a restore that resets
`firstInstallTime` loses the grandfather. A server-side purchase history would be
stronger, but it contradicts the app's no-account, no-backend design.
## 6. Two-step deletion flow
```mermaid
sequenceDiagram
actor User
participant UI as ScannerScreen
participant VM as ScannerViewModel
participant SC as ScanController
participant MD as MediaDeleter
participant OS as Android system dialog
participant MS as MediaStore
User->>UI: Tick photos
UI->>VM: toggleSelected(id)
User->>UI: Remove all selected
UI->>VM: markSelectedForRemoval()
VM->>VM: markedForRemovalIds += selectedIds
Note over VM: rows disappear from the list<br/>nothing is deleted yet
User->>UI: Apply
UI->>VM: applyMarkedForRemoval()
VM->>MD: createDeleteRequest(uris, useTrash)
MD->>OS: createDeleteRequest / createTrashRequest
OS-->>User: one confirmation for the whole batch
User-->>OS: Allow
OS-->>VM: onSystemDeleteResult(confirmed = true)
VM->>SC: removePhotos(deletedIds)
SC-->>VM: result without deleted rows
VM->>MS: rows already removed by the system
VM-->>UI: selected/marked sets pruned
```
Rules that must not change:
- Staging is **not** deletion. No system dialog appears until **Apply**.
- Android 11+ always goes through `MediaStore.createDeleteRequest` or
`createTrashRequest`. The app never requests `MANAGE_EXTERNAL_STORAGE`.
- The banner lives below the action bar and is separated by padding, so it cannot
intercept an Apply tap.
- A fresh scan clears stale staging, because the row ids belong to the old result.
## 7. Local persistence
| Store | Owner | Content | Backup |
|---|---|---|---|
| `photo_index.db` (`photo_index` table) | `PhotoIndexStore` | MediaStore id, size, modified stamp, quick signature, SHA-256, pHash, RGB dHash | **excluded** from backup/transfer; it is device-specific cache |
| `pro_entitlement` SharedPreferences | `ProStore` | `is_pro`, `legacy_pro`, `install_origin_resolved`, `pending_ack_token` | included in Android backup; Play re-verifies on the next connection |
| UMP consent state | Google UMP SDK | consent choices / privacy-options requirement | managed by the SDK |
| AdMob / Billing SDK state | Google SDKs | ad and purchase caches | managed by the SDKs |
| Scan results | `ScanController` (memory only) | groups + record map | lost on process death; a re-scan rebuilds it |
The index is a **cache**, never a source of truth. `DB_VERSION` must be bumped when
the meaning of a stored hash changes; `onUpgrade` drops and rebuilds the table.
Photo pixels are never written to the database or to preferences.
## 8. File index
Paths are relative to `app/src/main/java/de/softwareapp_hb/fotodup/finder/` unless noted.
| File | Responsibility |
|---|---|
| `FotoDupApplication.kt` | creates the three process-scoped singletons: `ScanController`, `ProStore`, `AdsController` |
| `MainActivity.kt` | edge-to-edge, starts consent/ad init for free users, refreshes purchases on resume, hosts `ScannerScreen` |
| **core/** | |
| `core/Hashing.kt` | cheap size/head/tail signature + SHA-256 |
| `core/PerceptualHash.kt` | 64-bit pHash via 32×32 grayscale → DCT → 8×8 block |
| `core/RgbDHash.kt` | one 64-bit difference hash per colour channel |
| `core/PhotoFingerprint.kt` | bundles the pHash and RGB dHash for one photo |
| `core/DuplicateGrouper.kt` | exact + perceptual grouping, banded candidates, union-find, per-scan threshold fit |
| `core/DuplicateGroup.kt` | group model, suggested keep/remove, display order |
| `core/DuplicatePolicy.kt` | Exact / Balanced / Aggressive presets |
| `core/AdaptiveThreshold.kt` | fits the pHash cut to the candidate population |
| `core/DisjointSet.kt` | union-find |
| `core/DecodeMath.kt` | decode/downscale maths shared by the hasher and tests |
| `core/ByteUtils.kt` | bounded stream reads |
| **data/** | |
| `data/MediaStorePhotoSource.kt` | MediaStore query → `PhotoRecord` |
| `data/PhotoRecord.kt` | photo metadata + content URI |
| `data/PhotoHasher.kt` | signature, SHA-256, thumbnail/fallback decode, perceptual hashes |
| `data/PhotoIndexStore.kt` | SQLite `photo_index` cache (`DB_VERSION 3`) |
| `data/MediaDeleter.kt` | `createDeleteRequest` / `createTrashRequest`, legacy API 26–29 delete |
| `data/AppPermissions.kt` | full/partial/none access state and requestable permission list |
| `data/BoundedCall.kt` | hard deadline + stalled-provider breaker |
| **domain/** | |
| `domain/ScanController.kt` | process-scoped scan state, start/cancel, `removePhotos`, error clearing |
| `domain/ScanEngine.kt` | tiered scan pipeline |
| `domain/ScanModels.kt` | `ScanPhase`, `ScanProgress`, `ScanResult`, `ScanTimings` |
| `domain/Parallel.kt` | bounded parallel fan-out for CPU work |
| **service/** | |
| `service/ScanService.kt` | `dataSync` foreground service + progress notification + Cancel action |
| **monetization/** | |
| `monetization/ProProduct.kt` | `pro_no_ads` id and preference keys |
| `monetization/ProStore.kt` | Billing connection, purchase/acknowledge/restore, entitlement cache, legacy migration |
| `monetization/ProState.kt` | Pro UI state |
| `monetization/AdsController.kt` | UMP consent + Mobile Ads init + privacy options |
| `monetization/AdsState.kt` | consent/init state |
| `monetization/AdPolicy.kt` | pure banner gate |
| `monetization/LegacyPro.kt` | pure paid-install cutoff predicate |
| **text/** | |
| `text/TextRes.kt` | `ScanPhase` / `DuplicatePolicy` → string resource |
| **ui/** | |
| `ui/scanner/ScannerScreen.kt` | scaffold, permissions, options menu, Pro entry, bottom slot, Pro sheet |
| `ui/scanner/ScannerViewModel.kt` | selection, staging, deletion, Pro actions, state collection |
| `ui/scanner/ScannerUiState.kt` | all scanner state including `pro` and `ads` |
| `ui/scanner/ScannerSections.kt` | access banner, progress, empty state |
| `ui/scanner/GroupSection.kt` | summary card, group cards, staging buttons |
| `ui/components/PhotoThumbnail.kt` | selectable photo tile |
| `ui/components/ContextExt.kt` | `Context.findActivity()` for Billing/UMP |
| `ui/ads/BannerAdSlot.kt` | adaptive `AdView`, lifecycle, no ad for Pro/refused consent |
| `ui/pro/ProSheet.kt` | benefits, localized price, buy/restore, pending/unavailable |
| `ui/theme/*` | Material 3 theme, colours, type, edge-to-edge |
| **debug/** | |
| `src/debug/.../DebugScanTrigger.kt` | adb-driven scan for the test device |
| `src/debug/.../DebugProToggle.kt` | adb-driven free/Pro switch |
| **tests** | |
| `app/src/test/.../core/*` | hashing, pHash, grouping, threshold, group maths |
| `app/src/test/.../data/BoundedCallTest.kt` | provider deadline/breaker |
| `app/src/test/.../domain/ScanEngineEndToEndTest.kt` | real pipeline against `FakeMediaStoreProvider` |
| `app/src/test/.../monetization/AdPolicyTest.kt` | banner gate |
| `app/src/test/.../monetization/LegacyProTest.kt` | grandfathered-install boundaries |
| `app/src/test/.../bench/*` | opt-in similarity/scale benchmark harness |
## 9. Change-impact matrix
| Change | Primary files | Required checks |
|---|---|---|
| Hash algorithm / signature | `core/Hashing.kt`, `data/PhotoHasher.kt` | `HashingTest`, `ScanEngineEndToEndTest`, `DB_VERSION` bump |
| pHash / RGB dHash | `core/PerceptualHash.kt`, `core/RgbDHash.kt`, `data/PhotoHasher.kt` | `PerceptualHashTest`, benchmark, `DB_VERSION` bump |
| Grouping / threshold fit | `core/DuplicateGrouper.kt`, `core/AdaptiveThreshold.kt`, `core/DuplicatePolicy.kt` | `DuplicateGrouperTest`, `AdaptiveThresholdTest`, `GroupingScaleTest` |
| Scan pipeline stage | `domain/ScanEngine.kt`, `domain/ScanModels.kt`, `text/TextRes.kt`, `strings.xml` | `ScanEngineEndToEndTest`, progress UI/notification |
| SQLite schema | `data/PhotoIndexStore.kt` | `DB_VERSION` bump, end-to-end test, `pruneTo` path |
| Permission set | `AndroidManifest.xml`, `data/AppPermissions.kt` | merged-manifest audit, Play checklist, `PRIVACY.md` |
| Ad placement / format | `ui/ads/BannerAdSlot.kt`, `ui/scanner/ScannerScreen.kt` | `AdPolicyTest`, device with Play services, policy review |
| Consent / privacy options | `monetization/AdsController.kt`, `strings.xml` | UMP debug geography, `PRIVACY.md`, Data Safety |
| Product id / price | `monetization/ProProduct.kt`, Play Console | `MONETIZATION.md`, internal-track purchase, restore test |
| Entitlement / legacy cutoff | `monetization/ProStore.kt`, `monetization/LegacyPro.kt`, build config | `LegacyProTest`, purchase/refund/offline cases |
| Pro UI | `ui/pro/ProSheet.kt`, `ui/scanner/ScannerViewModel.kt` | free/Pro/debug toggle, pending/unavailable states |
| Version / release | `app/build.gradle.kts`, `CHANGELOG.md` | `versionCode` higher, `assembleRelease`, `bundleRelease` |
| Codemap | `docs/codemap.md`, `docs/codemap.mmd` | Mermaid syntax, architecture review |
| Agent rules | `AGENTS.md` | commands and invariants still true |
## 10. Runtime ownership rules
- **ScanController** is the only owner of the running scan and its result. The
ViewModel mirrors it; it must never start a second scan or keep its own result.
- **ScannerViewModel** owns selection, staging, expanded groups and the delete
dialog hand-off. These are UI concerns and survive configuration changes.
- **ProStore** is the only owner of the entitlement. The UI renders
`ProState.isPro`; it must never guess Pro from a local flag or a price string.
- **AdsController** is the only owner of consent and SDK initialisation.
`BannerAdSlot` owns the `AdView` lifecycle and requests exactly one banner.
- **MediaDeleter** owns the system consent request. No other class may delete a
photo or bypass the two-step staging flow.
- **ScanService** mirrors `ScanController`; it contains no scanning logic.
- **core/** stays pure Kotlin. A new Android import there is an architecture bug.
## 11. Keeping the map accurate
When a module, permission, product or flow changes:
1. Update the affected node/edge in [`codemap.mmd`](codemap.mmd).
2. Update the matching diagram, file index and change-impact row here.
3. Update [`../AGENTS.md`](../AGENTS.md) if an architectural rule or command changed.
4. Update `README.md`, `PRIVACY.md`, `CHANGELOG.md`, `docs/ROADMAP.md`,
`docs/MONETIZATION.md`, `docs/STORE_LISTING.md` and
`docs/PLAY_RELEASE_CHECKLIST.md` when the change affects users, permissions,
monetisation or release steps.
5. Verify the Mermaid syntax in a Markdown preview before committing.
6. Run `./gradlew :app:testDebugUnitTest :app:lintDebug :app:assembleDebug`.
> The map describes the current freemium build. Deferred features (video
> duplicates, a separate "similar shots" list, subscriptions) are **not** implied
> by it and must be added explicitly when they land.
+164
View File
@@ -0,0 +1,164 @@
%% Foto Dup Finder — standalone code map
%% Render with a Mermaid-enabled Markdown preview, GitHub/GitLab, or the Mermaid CLI.
%% Full narrative, runtime flows and change-impact matrix: docs/codemap.md
flowchart TB
subgraph ENTRY["App entry"]
app["FotoDupApplication<br/>process singletons"]
main["MainActivity<br/>edge-to-edge + consent"]
theme["FotoDupTheme"]
end
subgraph UI["UI — Jetpack Compose"]
screen["ScannerScreen<br/>permissions, scaffold, menu"]
vm["ScannerViewModel<br/>selection, deletion, Pro actions"]
uiState["ScannerUiState"]
sections["ScannerSections<br/>banner, progress, empty state"]
groups["GroupSection<br/>summary + group cards"]
thumb["PhotoThumbnail"]
banner["BannerAdSlot<br/>adaptive AdView"]
proSheet["ProSheet<br/>one-time purchase"]
textRes["text/TextRes"]
end
subgraph DOMAIN["Domain"]
scanController["ScanController<br/>process-scoped scan owner"]
scanEngine["ScanEngine<br/>tiered pipeline"]
scanModels["ScanModels<br/>progress, result, phase"]
parallel["Parallel<br/>bounded CPU fan-out"]
end
subgraph SERVICE["Service"]
scanService["ScanService<br/>dataSync foreground service"]
end
subgraph DATA["Data — Android"]
mediaSource["MediaStorePhotoSource"]
hasher["PhotoHasher<br/>signature, SHA-256, pHash"]
indexStore["PhotoIndexStore<br/>SQLite hash cache"]
deleter["MediaDeleter<br/>system consent"]
permissions["AppPermissions"]
bounded["BoundedCall<br/>provider deadlines"]
photoRecord["PhotoRecord"]
end
subgraph CORE["Core — pure Kotlin, no Android imports"]
hashing["Hashing<br/>quick + SHA-256"]
phash["PerceptualHash<br/>64-bit pHash"]
rgb["RgbDHash<br/>RGB difference hashes"]
grouper["DuplicateGrouper<br/>union-find + fit"]
policy["DuplicatePolicy"]
adaptive["AdaptiveThreshold"]
group["DuplicateGroup"]
dsu["DisjointSet"]
decode["DecodeMath"]
bytes["ByteUtils"]
fingerprint["PhotoFingerprint"]
end
subgraph MONETIZATION["Monetization"]
proStore["ProStore<br/>Billing + entitlement cache"]
adsController["AdsController<br/>UMP + Mobile Ads"]
proState["ProState"]
adsState["AdsState"]
adPolicy["AdPolicy<br/>banner gate"]
legacy["LegacyPro<br/>paid-install cutoff"]
product["ProProduct<br/>pro_no_ads"]
end
subgraph DEBUG["Debug only"]
debugScan["DebugScanTrigger"]
debugPro["DebugProToggle"]
end
mediaStore[("MediaStore<br/>photo library")]
sqlite[("photo_index.db")]
prefs[("pro_entitlement<br/>SharedPreferences")]
admob[("Google AdMob")]
ump[("Google UMP")]
play[("Google Play Billing")]
notification[("Scan notification")]
app --> scanController
app --> proStore
app --> adsController
main --> app
main --> screen
main --> theme
main --> adsController
screen --> vm
screen --> sections
screen --> groups
screen --> banner
screen --> proSheet
screen --> theme
screen --> textRes
vm --> uiState
vm --> scanController
vm --> proStore
vm --> adsController
vm --> deleter
sections --> uiState
sections --> textRes
groups --> uiState
groups --> thumb
banner --> adPolicy
proSheet --> proState
scanController --> scanEngine
scanController --> scanService
scanController --> scanModels
scanEngine --> scanModels
scanEngine --> parallel
scanEngine --> mediaSource
scanEngine --> hasher
scanEngine --> indexStore
scanEngine --> grouper
scanEngine --> policy
scanEngine --> adaptive
scanEngine --> group
scanService --> scanController
scanService --> notification
mediaSource --> photoRecord
mediaSource --> permissions
mediaSource --> bounded
mediaSource -.->|query| mediaStore
hasher --> hashing
hasher --> phash
hasher --> rgb
hasher --> fingerprint
hasher --> decode
hasher --> bounded
hasher -.->|read bytes and thumbnails| mediaStore
indexStore --> photoRecord
indexStore -.->|SQLite| sqlite
deleter -.->|system delete request| mediaStore
hashing --> bytes
phash --> decode
rgb --> decode
grouper --> group
grouper --> dsu
grouper --> policy
grouper --> adaptive
group --> fingerprint
proStore --> product
proStore --> proState
proStore --> legacy
proStore -.->|query purchases and acknowledge| play
proStore -.->|entitlement cache| prefs
adsController --> adsState
adsController -.->|consent form| ump
adsController -.->|initialize| admob
banner -.->|AdView request| admob
debugScan -.-> scanController
debugPro -.-> proStore