[Payment Request][Android] Attach UI right before blocking interactions

Before this patch, if PaymentRequest.show() was called in a CCT, then
user opened the CCT page in Chrome, and a skip-UI payment app was slow
to respond to the `canmakepayment` event, then the activity to which
Chrome attached the payment UI would be gone by the time the payment UI
needs to be shown, which would cause a crash. The skip-UI bit is
important, because in this flow Chrome blocks UI interactions only after
launching the payment app (after the response to `canmakepayment`
event).

This patch waits to attach the payment UI to the current Chrome activity
via buildUI(chromeActivity) until immediately before blocking UI
interactions via mUI.show() or mUI.dimBackground().

After this patch, Chrome does not crash when PaymentRequest.show() was
called in a CCT for skip-UI flow and the user opened the CCT page in
Chrome before the payment app responded to the `canmakepayment` event.

Bug: 817073
Change-Id: I5ce50d000c2f64a60c62955d9e3e8f080498238d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506494
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Danyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638617}
1 file changed