Commit 327d86ac authored by Suzy Li's avatar Suzy Li Committed by Commit Bot

Call isUVPAA supported by GmsCore Fido2 Api

isUVPAA is currently implemented in AuthenticatorImpl.java by using
fingerprintManager. GmsCore SDK v26 now provides its own
implementation of isUVPAA as part of the FIDO2 APIs, so Clank should
call that API instead.

This is the third of three CLs for isUVPAA implementation that calls
isUVPAA from FIDO2 Apis if using GmsCore SDK v26. If not, calls
FingerprintManager.

The first CL is here:
https://chromium-review.googlesource.com/c/chromium/src/+/1671707
The second CL is here:
https://chrome-internal-review.googlesource.com/c/clank/internal/apps/+/1409937/1

Bug: 976480
Change-Id: I02a802234ec1dbf4417d125c0b6cc7b3601c1b45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677548Reviewed-by: default avatarKim Paulhamus <kpaulhamus@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Suzy Li <suzyli@google.com>
Cr-Commit-Position: refs/heads/master@{#672621}
parent 4419618e
......@@ -32,6 +32,7 @@ public class AuthenticatorImpl implements Authenticator, HandlerResponseCallback
private static final String GMSCORE_PACKAGE_NAME = "com.google.android.gms";
private static final int GMSCORE_MIN_VERSION = 12800000;
private static final int GMSCORE_MIN_VERSION_ISUVPAA = 16200000;
/** Ensures only one request is processed at a time. */
private boolean mIsOperationPending;
......@@ -100,11 +101,6 @@ public class AuthenticatorImpl implements Authenticator, HandlerResponseCallback
// ChromeActivity could be null.
if (context == null) {
callback.call(false);
}
if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME) < GMSCORE_MIN_VERSION
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
callback.call(false);
return;
}
......@@ -113,9 +109,21 @@ public class AuthenticatorImpl implements Authenticator, HandlerResponseCallback
return;
}
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
callback.call(fingerprintManager != null && fingerprintManager.hasEnrolledFingerprints());
if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME)
>= GMSCORE_MIN_VERSION_ISUVPAA) {
mIsUserVerifyingPlatformAuthenticatorAvailableCallback = callback;
Fido2ApiHandler.getInstance().isUserVerifyingPlatformAuthenticatorAvailable(
mRenderFrameHost, this);
} else if (PackageUtils.getPackageVersion(context, GMSCORE_PACKAGE_NAME)
>= GMSCORE_MIN_VERSION
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
callback.call(
fingerprintManager != null && fingerprintManager.hasEnrolledFingerprints());
} else {
callback.call(false);
}
}
@Override
......@@ -145,12 +153,12 @@ public class AuthenticatorImpl implements Authenticator, HandlerResponseCallback
public void onIsUserVerifyingPlatformAuthenticatorAvailableResponse(boolean isUVPAA) {
assert mIsUserVerifyingPlatformAuthenticatorAvailableCallback != null;
mIsUserVerifyingPlatformAuthenticatorAvailableCallback.call(isUVPAA);
close();
mIsUserVerifyingPlatformAuthenticatorAvailableCallback = null;
}
@Override
public void onError(Integer status) {
assert((mMakeCredentialCallback != null && mGetAssertionCallback == null)
assert ((mMakeCredentialCallback != null && mGetAssertionCallback == null)
|| (mMakeCredentialCallback == null && mGetAssertionCallback != null));
if (mMakeCredentialCallback != null) {
mMakeCredentialCallback.call(status, null);
......
......@@ -61,6 +61,12 @@ public class AuthenticatorTest {
RenderFrameHost frameHost, HandlerResponseCallback callback) {
callback.onError(AuthenticatorStatus.NOT_IMPLEMENTED);
}
@Override
protected void isUserVerifyingPlatformAuthenticatorAvailable(
RenderFrameHost frameHost, HandlerResponseCallback callback) {
callback.onIsUserVerifyingPlatformAuthenticatorAvailableResponse(false);
}
}
/** Waits until the JavaScript code supplies a result. */
......@@ -149,6 +155,7 @@ public class AuthenticatorTest {
@Feature({"WebAuth"})
public void testIsUserVerifyingPlatformAuthenticatorAvailable() throws Exception {
mActivityTestRule.loadUrl(mUrl);
Fido2ApiHandler.overrideInstanceForTesting(mMockHandler);
mActivityTestRule.runJavaScriptCodeInCurrentTab(
"doIsUserVerifyingPlatformAuthenticatorAvailable()");
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());
......
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