smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
490 stars 115 forks source link

Fingerprint automatically cancels #176

Open bohdanhrybach opened 4 years ago

bohdanhrybach commented 4 years ago

Steps to reproduce

  1. Request AuthenticateAsync()

  2. Provide 5 times wrong fingerprint

  3. Wait 30 seconds

  4. Request AuthenticateAsync() once more

Expected behavior

Dialog is being shown and stayed till user provide fingerprint or cancel dialog.

Actual behavior

Dialog is being shown for short amount of time and then is closed automatically.

Crashlog

AuthenticationHandler.OnAuthenticationError() return code "5" and message "Fingerprint operation cancelled". I found that it can be because the sensor is occupied by a previous operation (https://stackoverflow.com/a/46277750).

It works fine when I cancel dialog:

await using (cancellationToken.Register(() => dialog.CancelAuthentication()))
{
                    dialog.Authenticate(info);

                    var result = await handler.GetTask();

                    if (!result.Authenticated)
                    {
                        // NOTE: release fingerprint
                        dialog.CancelAuthentication();
                    }

                    return result;
}

Configuration

Version of the Plugin: 2.1.1

Platform: Android 8.0.0

Device: Samsung S7 Edge

smsissuechecker commented 4 years ago

Hi @bohdanhrybach,

I'm the friendly issue checker. Thanks for using the issue template :star2: I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

bohdanhrybach commented 4 years ago

@smstuebe Maybe you can add me to contributors and I will create related PR?

Pelinalpp commented 4 years ago

I have same issue. Any update?

bohdanhrybach commented 4 years ago

@Pelinalpp as I understand, no update :(

Pelinalpp commented 4 years ago

@bohdanhrybach you said "It works fine when I cancel dialog". I cancel CancellationTokenSource but it doesn't work. Do I understand wrong?

bohdanhrybach commented 4 years ago

@Pelinalpp I assume that you just pass CancellationToken to AuthenticateAsync(token) and cancel it after get result, don't you? Sth like:

1) var tokenSource = new CancellationTokenSource();
2) var res = await AuthenticateAsync(tokenSource.Token);
3) tokenSource.Cancel();

But it will not work, changes is needed inside plugin. Because after we get result cancellation token disposes: https://github.com/smstuebe/xamarin-fingerprint/blob/0fc44bc84cf7a33d46f78fb34703c36d2e29a8ad/src/Plugin.Fingerprint/Platforms/Android/FingerprintImplementation.cs#L128 So cancelling CancellationTokenSource will not help.

Pelinalpp commented 4 years ago

Yes I did this thank you.

Could you update for this issue please? @smstuebe

DenisLaky commented 3 years ago

@smstuebe The problem still exists. Could you please provide any updates about it?