Commit bb7e3b08 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payment Request] Disconnect only from connected service.

Before this patch, if binding failed or the Android payment app
disconnected from Chrome midway through the payment process, Chrome
would unbind on its own side, which would result in an
IllegalArgumentException.

This patch adds a boolean mIsServiceConnected that tracks whether the
payment app's service is connected to Chrome. If this boolean is false,
then Chrome does not attempt to unbind from the payment app service.

After this patch, if the Android payment app disconnects from Chrome
midway through the payment process or the binding fails,
Chrome does not bother to unbind on its own side and thus avoids
the IllegalArgumentException.

Bug: 828852
Change-Id: I653b3bef07562f815d8e53d62c7aff97649bcac5
Reviewed-on: https://chromium-review.googlesource.com/995618
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548532}
parent 8cb1540c
......@@ -102,6 +102,7 @@ public class AndroidPaymentApp
@Nullable
private URI mCanDedupedApplicationId;
private boolean mIsReadyToPayQueried;
private boolean mIsServiceConnected;
/**
* Builds the point of interaction with a locally installed 3rd party native Android payment
......@@ -160,6 +161,7 @@ public class AndroidPaymentApp
mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mIsServiceConnected = true;
IsReadyToPayService isReadyToPayService =
IsReadyToPayService.Stub.asInterface(service);
if (isReadyToPayService == null) {
......@@ -170,7 +172,9 @@ public class AndroidPaymentApp
}
@Override
public void onServiceDisconnected(ComponentName name) {}
public void onServiceDisconnected(ComponentName name) {
mIsServiceConnected = false;
}
};
mIsReadyToPayIntent.putExtras(buildExtras(null /* id */, null /* merchantName */,
......@@ -194,7 +198,10 @@ public class AndroidPaymentApp
private void respondToGetInstrumentsQuery(final PaymentInstrument instrument) {
if (mServiceConnection != null) {
ContextUtils.getApplicationContext().unbindService(mServiceConnection);
if (mIsServiceConnected) {
ContextUtils.getApplicationContext().unbindService(mServiceConnection);
mIsServiceConnected = false;
}
mServiceConnection = null;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment