Deliver intents to active Custom Tabs via onNewIntent
Currently the intents to be handled in the foreground instance of CustomTabActivity are delivered via a static reference in BrowserSessionContentUtils, instead of delivering the intent via ordinary Android mechanisms. This means, in particular, that intent flags are lost in the process. This poses a problem for "Single activity" TWA apps, specifically for their ability to forward new incoming View intents to the running TWA. We'd like this forwarding to be possible, and to work "out of the box" with LauncherActivity. Currently it works as follows. LauncherActivity starts a TWA, and keeps running in background - this allows to customize it so that it would continue communicating with TWA via CustomTabConnection. If a new View intent comes in, it starts a new instance of LauncherActivity, which in turn creates ChromeLauncherActivity, so the stack is: LauncherActivity | CTA | LauncherActivity | ChromeLauncherActivity ChromeLauncherActivity calls CTA via a static method, and kills itself, which leaves the second LauncherActivity running. Setting SINGLE_TOP and CLEAR_TOP intent flags on the client won't help, because these flags won't reach CTA. In this CL I make ChromeLauncherActivity launch CTA with SINGLE_TOP and CLEAR_TOP if there is a foreground CTA with matching session. Otherwise, the intent handling is kept the way it was, with all the logic untouched. The fallback solution, in the case this one won't work out, is to just call finish() in LauncherActivity once it has launched a TWA. This would mean it won't be able to both do the intent routing and keep communicating via CustomTabConnection (and probably no client implementation would be able to), which isn't good, but might not be a blocker for MVP release. Companion CL: http://crrev.com/c/1349363 Bug: 907796 Change-Id: I8a2396b325baae2974d6b0dfb73c2ed2fb0519eb Reviewed-on: https://chromium-review.googlesource.com/c/1349653 Commit-Queue: Pavel Shmakov <pshmakov@chromium.org> Reviewed-by:Yusuf Ozuysal <yusufo@chromium.org> Reviewed-by:
Peter Conn <peconn@chromium.org> Cr-Commit-Position: refs/heads/master@{#611375}
Showing
Please register or sign in to comment