Follow-up to [#9804 handle Android push wakes](https://github.com/block/buzz/pull/9804), from its review: a confirmed age restriction now applies to Android push wakes, as it already does on iOS. ## What it does - A new native `AgeRestriction` holds a confirmed restriction for the life of the app process. Like the iOS restriction session, nothing is saved: a later launch starts unrestricted and the age check runs again. - The age gate's purge (`purgeAgeRestrictedNotifications`) now runs on Android. It sets the restriction and cancels every notification Buzz has posted. Restore (`restoreAgeRestrictedNotifications`) clears it. Both were iOS-only before. - On Android the restriction is released only when an age check in the current engine finishes without restricting (allowed, or failing open). The process can outlive the engine, for example after Back from the restricted screen, and a reopened app starts its age state as allowed, so releasing on that first build would lift a restriction the process still holds before the new check answers. A retired check releases nothing. iOS keeps restoring from the push bootstrap as before. - The purge starts as soon as the age check confirms a restriction, not when the restricted screen first draws. The check can answer while Buzz is in the background, where Flutter draws no frames until the user returns, so before this wakes kept posting until then. This also closes the same gap on iOS. The restricted screen still retries a failed purge, and a retry that a resume has replaced stays quiet, so a late failure can't purge again. - While the restriction holds, a push wake is skipped before it fetches anything, the same way as when notifications are turned off. - Every post from a wake (conversations and the generic "New activity") checks the restriction under the same lock the purge takes. So a wake already running when the restriction arrives posts nothing after the purge, and a post already in progress finishes before the purge cancels it. ## Decisions - **Process lifetime, as on iOS.** Wakes run in the app's process, so an in-memory flag covers every wake while the confirming process lives. A wake that starts a fresh process (after the app was killed) is not restricted until the app runs its check again. That matches iOS, where the restriction ends with the process holding its lock. - **No release-config change here.** `BUZZ_AGE_GATING_ENABLED` is still set only for iOS builds, and no build sets the Firebase config yet. Adding either to an Android build is a separate release change. ### Validation Added tests: [`AgeRestrictionTest.kt`](https://github.com/block/buzz/blob/android-push-age-gate/mobile/android/app/src/test/kotlin/xyz/block/buzz/mobile/AgeRestrictionTest.kt) covers restrict, release and a post that is in progress when the restriction arrives. [`push_bridge_test.dart`](https://github.com/block/buzz/blob/android-push-age-gate/mobile/test/shared/push/push_bridge_test.dart) now covers the purge and restore calls on iOS and Android. The age gate's outcome table now runs on Android and counts releases: none while the check is pending, one after an adult, error, malformed or timed-out result, none after a minor. [`age_signal_provider_test.dart`](https://github.com/block/buzz/blob/android-push-age-gate/mobile/test/features/age_gate/age_signal_provider_test.dart)'s upper-bound table now also checks that a confirmed restriction starts the purge with no widget or frame involved. [`age_gate_app_test.dart`](https://github.com/block/buzz/blob/android-push-age-gate/mobile/test/features/age_gate/age_gate_app_test.dart)'s purge retry test now uses the real notifier, with a resume while the first purge is still running. On a Pixel 9a (Android 16), a debug build with a local test relay. A temporary debug hook called the native restrict and release directly, because the phone was locked and Flutter doesn't draw frames behind the lock screen: 1. Allowed: a wake posted the new message. 2. Restrict: the posted notification was removed. 3. While restricted: a wake logged `wake ignored foreground=false restricted=true` and posted nothing. 4. Release: the next wake posted both the message that arrived during the restriction and the new one. The Dart side calling purge and restore is covered by the bridge test above. ## Regressions None expected: without age gating enabled, the restriction is never set on Android. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
Age-check contract
Normal app, relay, and push startup do not depend on an age result. The only operation that can restrict access is a valid under-18 response from the current launch request. Errors, malformed responses, timeout, disposal, and late callbacks leave access allowed. There is one attempt per provider lifecycle, with no blocking retry or restart flow.
Production enforcement remains disabled. Dogfood builds can opt in with the
Flutter define BUZZ_AGE_GATING_ENABLED=true. This enables the same notifier used
by the native-channel and app tests. No real-device build is a PR prerequisite;
actual OS prompts, signing, and account behavior will be checked in pre-release testing.
Automated evidence
age_signal_provider_test.dart: real method-channel codec, allowed/under-18 boundaries, malformed payloads, exceptions, missing plugin, timeout, late completion, concurrent callers, invalidation, disposal, and the build opt-in.age_gate_app_test.dart: full app and push bootstrap remain mounted while the native response is pending or fails, and unmount only for a current under-18 response. Notification restoration failure does not gate app access.- Notification restriction leaves saved snapshots, signing keys, preferences, and remote leases intact. Only the confirming app process holds restriction authority; a later launch does not need storage restoration to allow access.
- Swift and Kotlin adapter tests: platform-specific bounds are normalized conservatively, including contradictory ranges and extreme integers. Android SDK task tests exercise shared access, minor response delivery, both failure stages, and retired callbacks through the production request coordinator.
- iOS simulator RunnerTests: the production method handlers deliver minor/error callbacks, allow notification restoration without app-group storage, and preserve snapshots through restriction, cleanup failure, and restoration.
- Swift notification tests: real cross-process lock contention suppresses presentation. Process exit releases restriction without cleanup. Missing, stale, and inaccessible lock files cannot establish a restriction.
Run the Flutter age-gate suite both with and without the pre-release testing define. A test must fail if pending/error becomes restricted or an expired request can restrict. The implementation was mutation-tested for pending and error blocking.
An already-running platform consent dialog cannot be proven dismissible by Dart unit tests. That behavior remains part of pre-release testing validation before general re-enablement. Old releases that permanently saved push opt-out preferences did not record their cause; this change does not guess which opt-outs to reverse.