Deel identieke Edition/Kubus-patches, toggle-teksten en het "hook elke return"-patroon #84

Closed
opened 2026-10-14 13:46:16 +02:00 by midas · 1 comment
Owner

Severity: medium · Categorie: architecture · Effort: L

Probleem

Zo'n tien features bestaan twee keer (ads, review prompts, surveys, in-app messages, game promos, preferred source, push suggestions, subscription banners, tracking, Midas Settings). Naam, beschrijving, default, categorie, toggle-key, Nederlandse titel en samenvatting worden daarbij letterlijk herhaald. Hide surveys is in beide platforms identiek. Het patroon "zoek elke return, gooi een exception als er geen is, loop van achter naar voren en voeg in op het control-flow-label" staat in ongeveer 8 patches. De manifest-cleanup staat er per platform los.

Waar

Bewijs

X-arch-3 (patches/src/main/kotlin/nl/midasvo/patches/edition/surveys/HideSurveysPatch.kt)

edition/surveys: dependsOn(disableUsabillaSurveysPatch); dependsOn(midasSettingsPatch); registerToggle(MidasToggle("hide_surveys", "Verberg enquêtes", "Toont geen ongevraagde enquêtes of feedbackvragen.", POPUPS))
kubus/surveys: identical body; only compatibleWith(*KUBUS_COMPATIBILITY) and the variable name (gelderlanderHideSurveysPatch) differ

X-arch-8 (patches/src/main/kotlin/nl/midasvo/patches/edition/reviewprompts/HideReviewPromptsPatch.kt)

method.instructions.withIndex().filter { opcode == Opcode.RETURN_OBJECT }.map { index to (it as OneRegisterInstruction).registerA }.toList()
if (returns.isEmpty()) throw PatchException(...)
returns.asReversed().forEach { (index, register) -> method.addInstructionsAtControlFlowLabel(index, "invoke-static/range ...") }

Impact

Een fix of een tekstwijziging moet op meerdere plekken gebeuren en blijft makkelijk op één plek achter. Bij dat delicate smali-patroon (labels, registers) is dat het grootste risico.

Voorstel

  • Voeg identieke patches samen met compatibleWith(*EDITION_COMPATIBILITY, *KUBUS_COMPATIBILITY), te beginnen met Hide surveys.
  • Maak een toggle-catalogus in shared/settings (key, titel, samenvatting, categorie). Dat sluit aan op de contractcheck.
  • Voeg MutableMethod.hookReturns(opcode) { reg -> smali } (met een wide-variant) en een helper removeManifestEntries(...) toe aan shared/util, en gebruik die in de bestaande patches.

Acceptatiecriteria

  • Hide surveys bestaat één keer en verschijnt nog steeds in alle Edition- en Kubus-apps.
  • Geen patch implementeert meer zelf een return-hook-loop.
  • De patch-lijst (namen, beschrijvingen, packages) blijft gelijk; Applied: op een Edition- en een Kubus-APK.

Code review @ 33e02db (2026-10-14) · findings: X-arch-3, X-arch-8

**Severity:** medium · **Categorie:** architecture · **Effort:** L ## Probleem Zo'n tien features bestaan twee keer (ads, review prompts, surveys, in-app messages, game promos, preferred source, push suggestions, subscription banners, tracking, Midas Settings). Naam, beschrijving, default, categorie, toggle-key, Nederlandse titel en samenvatting worden daarbij letterlijk herhaald. Hide surveys is in beide platforms identiek. Het patroon "zoek elke `return`, gooi een exception als er geen is, loop van achter naar voren en voeg in op het control-flow-label" staat in ongeveer 8 patches. De manifest-cleanup staat er per platform los. ## Waar - [`patches/src/main/kotlin/nl/midasvo/patches/edition/surveys/HideSurveysPatch.kt#L12-37`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/surveys/HideSurveysPatch.kt#L12-L37) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/surveys/HideSurveysPatch.kt#L12-37`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/surveys/HideSurveysPatch.kt#L12-L37) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/games/HideGamePromosPatch.kt#L12-34`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/games/HideGamePromosPatch.kt#L12-L34) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/games/HideGamePromosPatch.kt#L12-39`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/games/HideGamePromosPatch.kt#L12-L39) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/inappmessaging/HideInAppMessagesPatch.kt#L33-53`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/inappmessaging/HideInAppMessagesPatch.kt#L33-L53) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/inappmessaging/HideInAppMessagesPatch.kt#L44-66`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/inappmessaging/HideInAppMessagesPatch.kt#L44-L66) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/settings/MidasSettingsPatch.kt#L97-101`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/settings/MidasSettingsPatch.kt#L97-L101) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L33-37`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L33-L37) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/settings/MidasSettingsPatch.kt#L32-36`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/settings/MidasSettingsPatch.kt#L32-L36) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/reviewprompts/HideReviewPromptsPatch.kt#L47-67`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/reviewprompts/HideReviewPromptsPatch.kt#L47-L67) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L51-70`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L51-L70) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/contentfilters/ContentFilterPatches.kt#L105-125`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/contentfilters/ContentFilterPatches.kt#L105-L125) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/assets/LogVideoAssetsPatch.kt#L44-60`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/assets/LogVideoAssetsPatch.kt#L44-L60) - [`patches/src/main/kotlin/nl/midasvo/patches/videoland/quality/ForceHdPatch.kt#L98-114`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/videoland/quality/ForceHdPatch.kt#L98-L114) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/EditionManifestCleanupPatch.kt#L8-56`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/tracking/EditionManifestCleanupPatch.kt#L8-L56) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/tracking/KubusManifestCleanupPatch.kt#L1-45`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/tracking/KubusManifestCleanupPatch.kt#L1-L45) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt#L34`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/markdown/CopyArticleMarkdownPatch.kt#L34) ## Bewijs _X-arch-3 (patches/src/main/kotlin/nl/midasvo/patches/edition/surveys/HideSurveysPatch.kt)_ ```kotlin edition/surveys: dependsOn(disableUsabillaSurveysPatch); dependsOn(midasSettingsPatch); registerToggle(MidasToggle("hide_surveys", "Verberg enquêtes", "Toont geen ongevraagde enquêtes of feedbackvragen.", POPUPS)) kubus/surveys: identical body; only compatibleWith(*KUBUS_COMPATIBILITY) and the variable name (gelderlanderHideSurveysPatch) differ ``` _X-arch-8 (patches/src/main/kotlin/nl/midasvo/patches/edition/reviewprompts/HideReviewPromptsPatch.kt)_ ```kotlin method.instructions.withIndex().filter { opcode == Opcode.RETURN_OBJECT }.map { index to (it as OneRegisterInstruction).registerA }.toList() if (returns.isEmpty()) throw PatchException(...) returns.asReversed().forEach { (index, register) -> method.addInstructionsAtControlFlowLabel(index, "invoke-static/range ...") } ``` ## Impact Een fix of een tekstwijziging moet op meerdere plekken gebeuren en blijft makkelijk op één plek achter. Bij dat delicate smali-patroon (labels, registers) is dat het grootste risico. ## Voorstel - Voeg identieke patches samen met `compatibleWith(*EDITION_COMPATIBILITY, *KUBUS_COMPATIBILITY)`, te beginnen met Hide surveys. - Maak een toggle-catalogus in `shared/settings` (key, titel, samenvatting, categorie). Dat sluit aan op de contractcheck. - Voeg `MutableMethod.hookReturns(opcode) { reg -> smali }` (met een wide-variant) en een helper `removeManifestEntries(...)` toe aan `shared/util`, en gebruik die in de bestaande patches. ## Acceptatiecriteria - [ ] Hide surveys bestaat één keer en verschijnt nog steeds in alle Edition- en Kubus-apps. - [ ] Geen patch implementeert meer zelf een return-hook-loop. - [ ] De patch-lijst (namen, beschrijvingen, packages) blijft gelijk; `Applied:` op een Edition- en een Kubus-APK. _Code review @ 33e02db (2026-10-14) · findings: X-arch-3, X-arch-8_
Author
Owner

Opgelost in PR #123, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).

Opgelost in PR #123, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).
midas closed this issue 2026-10-17 21:22:38 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/midas-patches#84
No description provided.