fython / BiometricPromptCompat

A Thrid-party BiometricPrompt compat library.
Apache License 2.0
263 stars 23 forks source link

Accept fingerprint even after cancel the dialog #8

Open nikz-dev opened 6 years ago

nikz-dev commented 6 years ago

After click on USE PASSWORD Biometric dialog disappears and show you requested password Toast but accept fingerprint at the same time. Bug reproduce steps : - 1- click on USE PASSWORD 2- Biometric Dialog disappears 3- Now touch fingerprint senser Its accept fingerprint and show Success Toast. Tested on Nexus 6P, Android version 8.1.0

nikz-dev commented 6 years ago
BiometricPromptApi23Impl(
            @NonNull Context context,
            @NonNull CharSequence title,
            @Nullable CharSequence subtitle,
            @Nullable CharSequence description,
            @Nullable CharSequence negativeButtonText,
            @Nullable DialogInterface.OnClickListener negativeButtonListener
    ) {
        this.context = context;
        this.mainHandler = new Handler(context.getMainLooper());
        this.animateHandler = new AnimateHandler(context.getMainLooper());
        this.fingerprintManager = context.getSystemService(FingerprintManager.class);
        this.negativeButtonListener = negativeButtonListener;

        dialog = new BiometricPromptCompatDialog(context);

        dialog.setTitle(title);
        if (subtitle == null) {
            dialog.getSubtitle().setVisibility(View.GONE);
        } else {
            dialog.getSubtitle().setText(subtitle);
        }
        if (description == null) {
            dialog.getDescription().setVisibility(View.GONE);
        } else {
            dialog.getDescription().setText(description);
        }
        if (negativeButtonText == null) {
            dialog.getNegativeButton().setVisibility(View.INVISIBLE);
        } else {
            dialog.getNegativeButton().setText(negativeButtonText);
            if (negativeButtonListener == null) {
                throw new IllegalArgumentException("Negative button listener should not be null.");
            }
            dialog.getNegativeButton().setOnClickListener(v -> {
                shouldNotifyClose = false;
                dialog.dismiss();

                negativeButtonListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);

                //I think by adding this code we can resolve this issue.
                if (cancellationSignal != null && !cancellationSignal.isCanceled()) {
                    cancellationSignal.cancel();
                }
            });
        }
    }