Skip to content

mobile: sync personal wildcards in the background, match from SQLite - #385

Open
haumacher wants to merge 1 commit into
masterfrom
mobile-wildcard-background-sync
Open

mobile: sync personal wildcards in the background, match from SQLite#385
haumacher wants to merge 1 commit into
masterfrom
mobile-wildcard-background-sync

Conversation

@haumacher

Copy link
Copy Markdown
Owner

Problem

Persönliche Wildcard-Blocklist-Einträge (#377, PERSONALIZATION.WILDCARD) wurden in der App nur dann mit dem Server abgeglichen, wenn der Nutzer die Blacklist-Ansicht öffnete. Der tägliche WorkManager-Hintergrundtask synchronisierte ausschließlich die globale Community-Blocklist. Eine auf der Website (oder einem anderen Gerät) angelegte Wildcard erreichte das Handy also nur, wenn die Blacklist-Seite zufällig geöffnet wurde.

Der Server kann persönliche Prefix-Wildcards bei der anonymisierten SHA1-Online-Abfrage prinzipbedingt nicht prüfen — das Matching muss daher bei jedem Anruf lokal erfolgen (tat es bereits über den gemeinsamen decideAndRespond-Pfad), und der lokale Bestand muss aktuell gehalten werden.

Blocker für einen Hintergrund-Abgleich: Das WorkManager-Isolate hat keine Activity, daher konnte der bisherige Weg SQLite → SharedPreferences (setWildcardPrefixes via MethodChannel) → CallChecker dort nicht abschließen.

Lösung

  • CallChecker liest Wildcard-Prefixe jetzt direkt aus der SQLite-Tabelle wildcard_blocks (analog zum bestehenden lookupLocalBlocklist). SQLite ist damit die einzige Quelle und der MethodChannel-Umweg entfällt.
  • Der tägliche WorkManager-Task gleicht die persönlichen Wildcards mit ab — über die neue kontextfreie syncPersonalWildcards()/reconcileWildcards(), ausgelagert aus der früheren State-Methode _syncWildcards().
  • Toten Code entfernt: syncWildcardPrefixesToNative(), die nativen setWildcardPrefixes/getWildcardPrefixes-Handler und -Methoden sowie den ungenutzten Dart-getWildcardPrefixes()-DB-Helper.

Aktualität nach dieser Änderung

  1. Blacklist-Ansicht öffnen → sofortiger Abgleich (bestehend, unverändert).
  2. Täglicher Hintergrund-Task → gleicht jetzt ebenfalls ab (neu).

Bewusst kein Push-Trigger: Es bleibt ein Restfenster von bis zu ~24 h, falls der Nutzer die Ansicht nie öffnet und in diesem Zeitraum ein passender Anruf eingeht. Bei der niedrigen Frequenz persönlicher Wildcards ist das akzeptabel.

Verifikation

  • flutter analyze der geänderten Dart-Dateien: keine neuen Issues.
  • ./gradlew :app:compileDebugJavaWithJavac: erfolgreich.

🤖 Generated with Claude Code

User asked whether the recently added server-side wildcard blocklist entries
(#377, PERSONALIZATION.WILDCARD) are synced with the app. They were only
reconciled when the blacklist page was opened; the daily WorkManager task
synced just the global community blocklist. So a wildcard added on the website
or another device only reached the phone when the user happened to open the
blacklist view.

The server cannot evaluate personal prefix wildcards during the anonymized
SHA1 online check, so the match must happen locally on every call (it already
did, via the unified decideAndRespond path) and the local set must stay fresh.

The blocker for a background refresh: the WorkManager isolate has no Activity,
so the previous SQLite -> SharedPreferences (via setWildcardPrefixes
MethodChannel) -> CallChecker propagation could not complete there.

Fix:
- CallChecker now reads wildcard prefixes directly from the wildcard_blocks
  SQLite table (mirroring the existing lookupLocalBlocklist read), making
  SQLite the single source of truth and removing the MethodChannel dependency.
- The daily WorkManager task also reconciles personal wildcards via a new
  context-free syncPersonalWildcards()/reconcileWildcards() pair, extracted
  from the former _syncWildcards() State method.
- Removed the now-dead SharedPreferences path: syncWildcardPrefixesToNative(),
  the native setWildcardPrefixes/getWildcardPrefixes handlers and methods, and
  the unused Dart getWildcardPrefixes() DB helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@haumacher haumacher added the pb-mobile Related to the PhoneBlock Mobile app for Android. label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pb-mobile Related to the PhoneBlock Mobile app for Android.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant