com.github.ajalt.reprint.core.AuthenticationFailureReason Java Examples

The following examples show how to use com.github.ajalt.reprint.core.AuthenticationFailureReason. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SendConfirmDialogFragment.java    From natrium-android-wallet with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showFingerprintError(AuthenticationFailureReason reason, CharSequence message, View view) {
    if (isAdded()) {
        final HashMap<String, String> customData = new HashMap<>();
        customData.put("description", reason.name());
        TextView textView = view.findViewById(R.id.fingerprint_textview);
        textView.setText(message.toString());
        if (getContext() != null) {
            textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error));
        }
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fingerprint_error, 0, 0, 0);
    }
}
 
Example #2
Source File: SettingsFragment.java    From natrium-android-wallet with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showFingerprintError(AuthenticationFailureReason reason, CharSequence message, View view) {
    if (isAdded()) {
        final HashMap<String, String> customData = new HashMap<>();
        customData.put("description", reason.name());
        TextView textView = view.findViewById(R.id.fingerprint_textview);
        textView.setText(message.toString());
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error));
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fingerprint_error, 0, 0, 0);
    }
}
 
Example #3
Source File: ChangeRepDialogFragment.java    From natrium-android-wallet with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showFingerprintError(AuthenticationFailureReason reason, CharSequence message, View view) {
    if (isAdded()) {
        final HashMap<String, String> customData = new HashMap<>();
        customData.put("description", reason.name());
        TextView textView = view.findViewById(R.id.fingerprint_textview);
        textView.setText(message.toString());
        if (getContext() != null) {
            textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error));
        }
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fingerprint_error, 0, 0, 0);
    }
}
 
Example #4
Source File: SendFragment.java    From nano-wallet-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showFingerprintError(AuthenticationFailureReason reason, CharSequence message, View view) {
    if (isAdded()) {
        final HashMap<String, String> customData = new HashMap<>();
        customData.put("description", reason.name());
        analyticsService.track(AnalyticsEvents.SEND_AUTH_ERROR, customData);
        TextView textView = view.findViewById(R.id.fingerprint_textview);
        textView.setText(message.toString());
        if (getContext() != null) {
            textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error));
        }
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fingerprint_error, 0, 0, 0);
    }
}
 
Example #5
Source File: SettingsDialogFragment.java    From nano-wallet-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showFingerprintError(AuthenticationFailureReason reason, CharSequence message, View view) {
    if (isAdded()) {
        final HashMap<String, String> customData = new HashMap<>();
        customData.put("description", reason.name());
        analyticsService.track(AnalyticsEvents.SEED_COPY_FAILED, customData);
        TextView textView = view.findViewById(R.id.fingerprint_textview);
        textView.setText(message.toString());
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error));
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fingerprint_error, 0, 0, 0);
    }
}
 
Example #6
Source File: MainActivity.java    From reprint with Apache License 2.0 5 votes vote down vote up
private void showError(AuthenticationFailureReason failureReason, boolean fatal,
                       CharSequence errorMessage, int errorCode) {
    result.setText(errorMessage);

    if (fatal) {
        fab.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_fingerprint_white_24dp));
        running = false;
    }
}
 
Example #7
Source File: RxReprint2Test.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Test
public void nonFatalFailure() throws Exception {
    ts.requestMore(1);
    module.listener.onFailure(AuthenticationFailureReason.AUTHENTICATION_FAILED, false, "", module.TAG, 0);
    List<AuthenticationResult> events = ts.values();
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).status, NONFATAL_FAILURE);
    ts.assertNotTerminated();
}
 
Example #8
Source File: RxReprint2Test.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Test
public void fatalFailure() throws Exception {
    ts.requestMore(1);
    module.listener.onFailure(AuthenticationFailureReason.AUTHENTICATION_FAILED, true, "", module.TAG, 0);
    List<AuthenticationResult> events = ts.values();
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).status, FATAL_FAILURE);
    ts.assertComplete();
}
 
Example #9
Source File: RxReprintTest.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Test
public void nonFatalFailure() throws Exception {
    ts.requestMore(1);
    module.listener.onFailure(AuthenticationFailureReason.AUTHENTICATION_FAILED, false, "", module.TAG, 0);
    final List<AuthenticationResult> events = ts.getOnNextEvents();
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).status, NONFATAL_FAILURE);
    ts.assertNoTerminalEvent();
}
 
Example #10
Source File: RxReprintTest.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Test
public void fatalFailure() throws Exception {
    ts.requestMore(1);
    module.listener.onFailure(AuthenticationFailureReason.AUTHENTICATION_FAILED, true, "", module.TAG, 0);
    final List<AuthenticationResult> events = ts.getOnNextEvents();
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).status, FATAL_FAILURE);
    ts.assertCompleted();
}
 
Example #11
Source File: MarshmallowReprintModule.java    From reprint with Apache License 2.0 5 votes vote down vote up
void authenticate(final CancellationSignal cancellationSignal,
                          final AuthenticationListener listener,
                          final Reprint.RestartPredicate restartPredicate,
                          final int restartCount) throws SecurityException {
    final FingerprintManager fingerprintManager = fingerprintManager();

    if (fingerprintManager == null) {
        listener.onFailure(AuthenticationFailureReason.UNKNOWN, true,
                context.getString(R.string.fingerprint_error_hw_not_available), TAG, FINGERPRINT_ERROR_CANCELED);
        return;
    }

    final FingerprintManager.AuthenticationCallback callback =
            new AuthCallback(restartCount, restartPredicate, cancellationSignal, listener);

    // Why getCancellationSignalObject returns an Object is unexplained
    final android.os.CancellationSignal signalObject = cancellationSignal == null ? null :
            (android.os.CancellationSignal) cancellationSignal.getCancellationSignalObject();

    // Occasionally, an NPE will bubble up out of FingerprintManager.authenticate
    try {
        fingerprintManager.authenticate(null, signalObject, 0, callback, null);
    } catch (NullPointerException e) {
        logger.logException(e, "MarshmallowReprintModule: authenticate failed unexpectedly");
        listener.onFailure(AuthenticationFailureReason.UNKNOWN, true,
                context.getString(R.string.fingerprint_error_unable_to_process), TAG, FINGERPRINT_ERROR_CANCELED);
    }
}
 
Example #12
Source File: MarshmallowReprintModule.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
    if (listener == null) return;
    AuthenticationFailureReason failureReason = AuthenticationFailureReason.UNKNOWN;
    switch (errMsgId) {
        case FINGERPRINT_ERROR_HW_UNAVAILABLE:
            failureReason = AuthenticationFailureReason.HARDWARE_UNAVAILABLE;
            break;
        case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
        case FINGERPRINT_ERROR_NO_SPACE:
            failureReason = AuthenticationFailureReason.SENSOR_FAILED;
            break;
        case FINGERPRINT_ERROR_TIMEOUT:
            failureReason = AuthenticationFailureReason.TIMEOUT;
            break;
        case FINGERPRINT_ERROR_LOCKOUT:
            failureReason = AuthenticationFailureReason.LOCKED_OUT;
            break;
        case FINGERPRINT_ERROR_CANCELED:
            // Don't send a cancelled message.
            return;
    }

    if (errMsgId == FINGERPRINT_ERROR_TIMEOUT && restartPredicate.invoke(failureReason, restartCount)) {
        authenticate(cancellationSignal, listener, restartPredicate, restartCount);
    } else {
        listener.onFailure(failureReason, true, errString, TAG, errMsgId);
        listener = null;
    }
}
 
Example #13
Source File: MarshmallowReprintModule.java    From reprint with Apache License 2.0 5 votes vote down vote up
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
    if (listener == null) return;
    if (!restartPredicate.invoke(AuthenticationFailureReason.SENSOR_FAILED, restartCount++)) {
        cancellationSignal.cancel();
    }
    listener.onFailure(AuthenticationFailureReason.SENSOR_FAILED, false, helpString, TAG, helpMsgId);
}
 
Example #14
Source File: MarshmallowReprintModule.java    From reprint with Apache License 2.0 4 votes vote down vote up
@Override
public void onAuthenticationFailed() {
    if (listener == null) return;
    listener.onFailure(AuthenticationFailureReason.AUTHENTICATION_FAILED, false,
            context.getString(R.string.fingerprint_not_recognized), TAG, FINGERPRINT_AUTHENTICATION_FAILED);
}