fix(android): process lifecycle, foreground pushes and quick replies - #29676
Merged
chrisnojima merged 7 commits intoSep 23, 2026
Merged
Conversation
…he main thread One lifecycle reporter: AppLifecycleReporter (ProcessLifecycleOwner) talks to Go and JS through a LifecycleBind seam so the mapping runs in JVM tests. MainActivity resume/finishing-destroy go through it too. Pushes always reach Go. In the foreground master returned before calling handleBackgroundNotification, so a foreground push was never unboxed or acked; now Go handles it with a notifier that does not display while the app is in the foreground. In the background Go is held in BACKGROUNDACTIVE around the work, then appDidEnterBackground decides whether to keep running. Quick reply runs on a worker thread under goAsync with a status notification, is not sent when logged out or for a negative message id (Go sends before it checks either and swallows the send's error), and is sent in the foreground too (master skipped it). Also: one unique periodic background sync job (legacy duplicates cancelled once), share intents handed over when JS registers instead of polling, and the Kotlin seen-set capped at 100. Flush audit (calls that run a leveldb flush on master): - Process ON_STOP appDidEnterBackground -> appBeginBackgroundTaskNonblock: unchanged from the parent, no else branch. - appWillExit: MainActivity finishing destroy, now also skipped when isChangingConfigurations (subset of the parent's calls). - Push / quick reply window, background only: appDidEnterBackground -> appBeginBackgroundTaskNonblock, same call master made on the same path; master's else setAppStateBackground (a second flush) is removed. - Foreground push / quick reply: no lifecycle call (master made none). - Quick reply rejected by the pre-checks: no window, no call (master opened one).
…ly whose uid can't be read A silent push gets no notifier, and Go only acks a push it can display, so in the foreground Go unboxed it for nothing; master skipped it there. The quick reply keeps running in the foreground. Reading the current uid can throw; the reply now reports failure instead of leaving the RemoteInput stuck sending. Flush audit: no change to any flushing call. A foreground silent push makes no lifecycle call (as on master); a background one is unchanged from the previous commit.
The notification carries the account it was shown for; Go posts as the current account, so a mismatch reports that the reply couldn't be sent.
chrisnojima
added this pull request to stack #29680
September 23, 2026 19:54
chrisnojima
removed this pull request from stack #29680
September 23, 2026 19:56
chrisnojima
added this pull request to stack #29681
September 23, 2026 19:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 4/7 on #29650.
Why
whileActivereturns early in the foreground, yet the notification says "Replied".What this changes
AppLifecycleReporterreplaces the previous PR's forwarder, behind a testableLifecycleBindseam.appWillExitruns only on a real finish, not on a configuration change.withBackgroundActive:finallycallsappDidEnterBackgroundand starts a background task if one is needed.goAsyncon a worker thread. It refuses when:Judgment calls
withBackgroundActivereturns Go to the background even when the work throws. That is one extra compaction on a rare error path, rather than Go staying in BACKGROUNDACTIVE indefinitely.setAppStateBackground.appDidEnterBackgroundalready does, so master's second flush is gone.Tests
WithBackgroundActiveTestcovers:SendQuickReplyTestcovers each refusal.AppLifecycleReporterTest,RunReceiverWorkTestandBackgroundSyncScheduleTestalso run.The guards were mutation-checked.