Java 类android.hardware.fingerprint.FingerprintManager.AuthenticationResult 实例源码

项目:boohee_v5.6    文件:FingerprintManagerCompatApi23.java   
private static android.hardware.fingerprint.FingerprintManager.AuthenticationCallback wrapCallback(final AuthenticationCallback callback) {
    return new android.hardware.fingerprint.FingerprintManager.AuthenticationCallback() {
        public void onAuthenticationError(int errMsgId, CharSequence errString) {
            callback.onAuthenticationError(errMsgId, errString);
        }

        public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
            callback.onAuthenticationHelp(helpMsgId, helpString);
        }

        public void onAuthenticationSucceeded(AuthenticationResult result) {
            callback.onAuthenticationSucceeded(new AuthenticationResultInternal(FingerprintManagerCompatApi23.unwrapCryptoObject(result.getCryptoObject())));
        }

        public void onAuthenticationFailed() {
            callback.onAuthenticationFailed();
        }
    };
}
项目:RxFingerprint    文件:AesEncryptionObservable.java   
@Override
protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintEncryptionResult> emitter, AuthenticationResult result) {
    try {
        Cipher cipher = result.getCryptoObject().getCipher();
        byte[] encryptedBytes = cipher.doFinal(toEncrypt.getBytes("UTF-8"));
        byte[] ivBytes = cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();

        String encryptedString = CryptoData.fromBytes(encodingProvider, encryptedBytes, ivBytes).toString();
        CryptoData.verifyCryptoDataString(encryptedString);

        emitter.onNext(new FingerprintEncryptionResult(FingerprintResult.AUTHENTICATED, null, encryptedString));
        emitter.onComplete();
    } catch (Exception e) {
        emitter.onError(cipherProvider.mapCipherFinalOperationException(e));
    }
}
项目:RxFingerprint    文件:FingerprintObservable.java   
private AuthenticationCallback createAuthenticationCallback(final ObservableEmitter<T> emitter) {
    return new AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errMsgId, CharSequence errString) {
            if (!emitter.isDisposed()) {
                emitter.onError(new FingerprintAuthenticationException(errString));
            }
        }

        @Override
        public void onAuthenticationFailed() {
            FingerprintObservable.this.onAuthenticationFailed(emitter);
        }

        @Override
        public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
            FingerprintObservable.this.onAuthenticationHelp(emitter, helpMsgId, helpString.toString());
        }

        @Override
        public void onAuthenticationSucceeded(AuthenticationResult result) {
            FingerprintObservable.this.onAuthenticationSucceeded(emitter, result);
        }
    };
}
项目:RxFingerprint    文件:FingerprintAuthenticationTest.java   
@Test
public void testAuthenticationSuccessful() throws Exception {
    when(fingerprintApiWrapper.isUnavailable()).thenReturn(false);
    when(fingerprintApiWrapper.getFingerprintManager()).thenReturn(fingerprintManager);

    AuthenticationResult result = mock(AuthenticationResult.class);
    TestObserver<FingerprintAuthenticationResult> testObserver = observable.test();

    ArgumentCaptor<FingerprintManager.AuthenticationCallback> callbackCaptor = ArgumentCaptor.forClass(FingerprintManager.AuthenticationCallback.class);
    verify(fingerprintManager).authenticate(any(CryptoObject.class), any(CancellationSignal.class), anyInt(), callbackCaptor.capture(), any(Handler.class));
    callbackCaptor.getValue().onAuthenticationSucceeded(result);

    testObserver.awaitTerminalEvent();
    testObserver.assertNoErrors();
    testObserver.assertComplete();
    testObserver.assertValueCount(1);

    FingerprintAuthenticationResult fingerprintAuthenticationResult = testObserver.values().get(0);
    assertTrue("Authentication should be successful", fingerprintAuthenticationResult.isSuccess());
    assertTrue("Result should be equal AUTHENTICATED", fingerprintAuthenticationResult.getResult().equals(FingerprintResult.AUTHENTICATED));
    assertTrue("Should contain no message", fingerprintAuthenticationResult.getMessage() == null);
}
项目:FMTech    文件:FingerprintUiHelper.java   
public final void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult paramAuthenticationResult)
{
  this.mIcon.setImageResource(2130837767);
  this.mStatusTextView.setTextColor(this.mStatusTextView.getResources().getColor(2131689543, null));
  updateAndAnnounceTextView(this.mStatusTextView.getResources().getString(2131362156));
  this.mStatusTextView.postDelayed(this.mSuccessRunnable, 300L);
}
项目:RxFingerprint    文件:AesDecryptionObservable.java   
@Override
protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintDecryptionResult> emitter, AuthenticationResult result) {
    try {
        CryptoData cryptoData = CryptoData.fromString(encodingProvider, encryptedString);
        Cipher cipher = result.getCryptoObject().getCipher();
        String decrypted = new String(cipher.doFinal(cryptoData.getMessage()));

        emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.AUTHENTICATED, null, decrypted));
        emitter.onComplete();
    } catch (Exception e) {
        emitter.onError(cipherProvider.mapCipherFinalOperationException(e));
    }

}
项目:RxFingerprint    文件:RsaDecryptionObservable.java   
@Override
protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintDecryptionResult> emitter, AuthenticationResult result) {
    try {
        Cipher cipher = result.getCryptoObject().getCipher();
        byte[] bytes = cipher.doFinal(encodingProvider.decode(encryptedString));
        String decrypted = new String(bytes, "UTF-8");

        emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.AUTHENTICATED, null, decrypted));
        emitter.onComplete();
    } catch (Exception e) {
        Logger.error("Unable to decrypt given value. RxFingerprint is only able to decrypt values previously encrypted by RxFingerprint with the same encryption mode.", e);
        emitter.onError(cipherProvider.mapCipherFinalOperationException(e));
    }

}
项目:RxFingerprint    文件:FingerprintAuthenticationTest.java   
@Test
public void testAuthenticationSuccessfulOnSecondTry() throws Exception {
    when(fingerprintApiWrapper.isUnavailable()).thenReturn(false);
    when(fingerprintApiWrapper.getFingerprintManager()).thenReturn(fingerprintManager);

    TestObserver<FingerprintAuthenticationResult> testObserver = observable.test();

    ArgumentCaptor<FingerprintManager.AuthenticationCallback> callbackCaptor = ArgumentCaptor.forClass(FingerprintManager.AuthenticationCallback.class);
    verify(fingerprintManager).authenticate(any(CryptoObject.class), any(CancellationSignal.class), anyInt(), callbackCaptor.capture(), any(Handler.class));
    callbackCaptor.getValue().onAuthenticationHelp(0, MESSAGE_HELP);

    testObserver.assertNotTerminated();
    testObserver.assertNoErrors();
    testObserver.assertNotComplete();
    testObserver.assertValueCount(1);

    FingerprintAuthenticationResult helpResult = testObserver.values().get(0);
    assertTrue("Authentication should not be successful", !helpResult.isSuccess());
    assertTrue("Result should be equal HELP", helpResult.getResult().equals(FingerprintResult.HELP));
    assertTrue("Should contain help message", helpResult.getMessage().equals(MESSAGE_HELP));

    callbackCaptor.getValue().onAuthenticationSucceeded(mock(AuthenticationResult.class));

    testObserver.awaitTerminalEvent();
    testObserver.assertNoErrors();
    testObserver.assertComplete();
    testObserver.assertValueCount(2);

    FingerprintAuthenticationResult successResult = testObserver.values().get(1);
    assertTrue("Authentication should be successful", successResult.isSuccess());
    assertTrue("Result should be equal AUTHENTICATED", successResult.getResult().equals(FingerprintResult.AUTHENTICATED));
    assertTrue("Should contain no message", successResult.getMessage() == null);
}
项目:GravityBox    文件:FingerprintLauncher.java   
@Override
public void onAuthenticationSucceeded(AuthenticationResult result) {
    startActivity(getFingerIdFromResult(result));
    restartListeningDelayed(1000);
}
项目:RxFingerprint    文件:FingerprintAuthenticationObservable.java   
@Override
protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintAuthenticationResult> emitter, AuthenticationResult result) {
    emitter.onNext(new FingerprintAuthenticationResult(FingerprintResult.AUTHENTICATED, null));
    emitter.onComplete();
}
项目:RxFingerprint    文件:FingerprintObservable.java   
/**
 * Action to execute when fingerprint authentication was successful.
 * Should return the needed result via the given {@link Emitter}.
 * <p/>
 * Should call {@link Emitter#onComplete()}.
 *
 * @param emitter current subscriber
 * @param result  result of the successful fingerprint authentication
 */
protected abstract void onAuthenticationSucceeded(ObservableEmitter<T> emitter, AuthenticationResult result);