feat: skip puzzle ads in Edition games #192

Closed
midas wants to merge 0 commits from feat/168-edition-game-ads into dev
Owner

Closes #168 (only open point: the device test below).

New named patch Skip puzzle ads (Edition: de Volkskrant, Trouw, Het Parool) with Midas Settings toggle skip_game_ads ("Sla puzzelreclame over", Advertenties en promotie), default on.

Analysis (decompile Het Parool 7.55.0 / 7.54.0, Volkskrant 7.55.0 dex)

  • Every game ad (preroll before a game, rewarded midroll when the game JS sends startAdBreak) goes through GameAdViewModel.bindView: it starts a 5 s load timeout, emits Loading and builds a GameAdPlayer, whose constructor calls AdsLoader.requestAds.
  • The app's error route: IMA error -> GameAdPlayer.reportAdError -> state Error -> view model emits GameAdEvent.Error.Generic. Completed only becomes GameAdEvent.Completed after a started ad, otherwise also Error.Generic, so "completion" can't be faked without faking ad-start tracking.
  • Host reaction to Error.Generic:
    • preroll: onPrerollError -> Playing, nothing reported;
    • rewarded midroll: the game gets AdBreakEnded("reward-rejected"), container -> Playing, snackbar "Probeer later nog eens om een beloning te ontvangen", AdRewardRejected reported via ReportTaPlayerExceptionUsecase.
      The game WebView stays loaded; nothing in the host waits after the error. The game's own reaction to reward-rejected is in remote web code (not in the APK), but it is the same answer it gets on every no-fill and on the app's own timeout.
  • The player4 (pgsdk4) ad-break path is dead code here (Pgsdk4GameContainerViewModel constructor is throw null). Kubus apps have no GameAdPlayer.

Hook

Not in GameAdPlayer as the issue suggested, but one step up: at the start of bindView, GameAds.skipGameAd(mutableEvents, GameAdEvent.Error.Generic.INSTANCE); when true, return-void. The extension posts the event and emits it once the flow has a collector (no replay; bindView runs in the AndroidView factory, before the LaunchedEffect collects). A synchronous reportAdError in the constructor would emit before that collector exists (inferred from Compose ordering) and the game would wait for the 5 s timeout, which also records a GameAdTimeoutException to Crashlytics. Returning early also means no IMA AdsLoader, no ad request, no timeout.

  • Smali: 7 instructions, this copied via move-object/from16, requireLocalRegisters(2), patch-time checks for the mutableEvents field and Error$Generic.INSTANCE.
  • Extension edition/GameAds.java: never-throw wrapper (falls back to the original bindView), 7 unit tests.
  • Stubs: kotlinx.coroutines.flow.MutableSharedFlow / StateFlow in stubs/edition (unobfuscated in the dex).
  • Docs: docs/apps/edition.md, section "Puzzle ads", with evidence labels.

Default on because the decompile shows the host continuing the game on this route in both the preroll and the rewarded case; the only loss is the reward (the toggle brings ads and rewards back, live).

Verification

Check Result
gradlew buildAndroid (incl. contract check) OK
:extensions:extension:testDebugUnitTest OK (GameAdsTest 7/7)
check-stubs.sh Het Parool 7.55.0 / 7.54.0 OK
check-patches.sh Volkskrant 7.55.0 exit 0, 14/14 Applied, incl. Skip puzzle ads
check-patches.sh Trouw 7.55.0 exit 0, 14/14 Applied, incl. Skip puzzle ads
check-patches.sh Volkskrant 7.54.0 exit 0, 14/14 Applied, incl. Skip puzzle ads

Not device-tested. To do: open a puzzle with a preroll (starts straight away?), ask for a rewarded reward (snackbar, puzzle still playable?), logcat MidasSettings (no "no collector" warning).

🤖 Generated with Claude Code

Closes #168 (only open point: the device test below). New named patch **Skip puzzle ads** (Edition: de Volkskrant, Trouw, Het Parool) with Midas Settings toggle `skip_game_ads` ("Sla puzzelreclame over", Advertenties en promotie), **default on**. ## Analysis (decompile Het Parool 7.55.0 / 7.54.0, Volkskrant 7.55.0 dex) - Every game ad (preroll before a game, rewarded midroll when the game JS sends `startAdBreak`) goes through `GameAdViewModel.bindView`: it starts a 5 s load timeout, emits `Loading` and builds a `GameAdPlayer`, whose constructor calls `AdsLoader.requestAds`. - The app's error route: IMA error -> `GameAdPlayer.reportAdError` -> state `Error` -> view model emits `GameAdEvent.Error.Generic`. `Completed` only becomes `GameAdEvent.Completed` after a started ad, otherwise also `Error.Generic`, so "completion" can't be faked without faking ad-start tracking. - Host reaction to `Error.Generic`: - preroll: `onPrerollError` -> `Playing`, nothing reported; - rewarded midroll: the game gets `AdBreakEnded("reward-rejected")`, container -> `Playing`, snackbar "Probeer later nog eens om een beloning te ontvangen", `AdRewardRejected` reported via `ReportTaPlayerExceptionUsecase`. The game WebView stays loaded; nothing in the host waits after the error. The game's own reaction to `reward-rejected` is in remote web code (not in the APK), but it is the same answer it gets on every no-fill and on the app's own timeout. - The `player4` (pgsdk4) ad-break path is dead code here (`Pgsdk4GameContainerViewModel` constructor is `throw null`). Kubus apps have no `GameAdPlayer`. ## Hook Not in `GameAdPlayer` as the issue suggested, but one step up: at the start of `bindView`, `GameAds.skipGameAd(mutableEvents, GameAdEvent.Error.Generic.INSTANCE)`; when true, `return-void`. The extension posts the event and emits it once the flow has a collector (no replay; `bindView` runs in the `AndroidView` factory, before the `LaunchedEffect` collects). A synchronous `reportAdError` in the constructor would emit before that collector exists (inferred from Compose ordering) and the game would wait for the 5 s timeout, which also records a `GameAdTimeoutException` to Crashlytics. Returning early also means no IMA `AdsLoader`, no ad request, no timeout. - Smali: 7 instructions, `this` copied via `move-object/from16`, `requireLocalRegisters(2)`, patch-time checks for the `mutableEvents` field and `Error$Generic.INSTANCE`. - Extension `edition/GameAds.java`: never-throw wrapper (falls back to the original `bindView`), 7 unit tests. - Stubs: `kotlinx.coroutines.flow.MutableSharedFlow` / `StateFlow` in `stubs/edition` (unobfuscated in the dex). - Docs: `docs/apps/edition.md`, section "Puzzle ads", with evidence labels. **Default on** because the decompile shows the host continuing the game on this route in both the preroll and the rewarded case; the only loss is the reward (the toggle brings ads and rewards back, live). ## Verification | Check | Result | | --- | --- | | `gradlew buildAndroid` (incl. contract check) | OK | | `:extensions:extension:testDebugUnitTest` | OK (GameAdsTest 7/7) | | `check-stubs.sh` Het Parool 7.55.0 / 7.54.0 | OK | | `check-patches.sh` Volkskrant 7.55.0 | exit 0, 14/14 Applied, incl. Skip puzzle ads | | `check-patches.sh` Trouw 7.55.0 | exit 0, 14/14 Applied, incl. Skip puzzle ads | | `check-patches.sh` Volkskrant 7.54.0 | exit 0, 14/14 Applied, incl. Skip puzzle ads | **Not device-tested.** To do: open a puzzle with a preroll (starts straight away?), ask for a rewarded reward (snackbar, puzzle still playable?), logcat `MidasSettings` (no "no collector" warning). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
New patch "Skip puzzle ads" (#168): the puzzle SDK's IMA video ads (preroll and
rewarded midroll) are skipped by returning from GameAdViewModel.bindView and
delivering the app's own GameAdEvent.Error.Generic once the event flow has a
collector. Preroll goes straight to the game; a rewarded midroll gets
reward-rejected. Midas Settings toggle skip_game_ads, default on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/dev' into feat/168-edition-game-ads
All checks were successful
CI / Build (pull_request) Successful in 4m42s
CI / Patch check (pull_request) Successful in 8m15s
c416abf167
midas closed this pull request 2026-11-17 15:34:01 +01:00
Author
Owner

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.
All checks were successful
CI / Build (pull_request) Successful in 4m42s
Required
Details
CI / Patch check (pull_request) Successful in 8m15s

Pull request closed

Sign in to join this conversation.
No description provided.