當前位置: 首頁>>代碼示例>>Java>>正文


Java FingerprintManager.AuthenticationCallback方法代碼示例

本文整理匯總了Java中android.hardware.fingerprint.FingerprintManager.AuthenticationCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java FingerprintManager.AuthenticationCallback方法的具體用法?Java FingerprintManager.AuthenticationCallback怎麽用?Java FingerprintManager.AuthenticationCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.fingerprint.FingerprintManager的用法示例。


在下文中一共展示了FingerprintManager.AuthenticationCallback方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: wrapCallback

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private static FingerprintManager.AuthenticationCallback wrapCallback(final AuthenticationCallback callback) {
    return new FingerprintManager.AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errMsgId, CharSequence errString) {
            callback.onAuthenticationError(errMsgId, errString);
        }

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

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

        @Override
        public void onAuthenticationFailed() {
            callback.onAuthenticationFailed();
        }
    };
}
 
開發者ID:uccmawei,項目名稱:FingerprintIdentify,代碼行數:24,代碼來源:FingerprintManagerCompatApi23.java

示例2: wrapCallback

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private static FingerprintManager.AuthenticationCallback wrapCallback(
        final AuthenticationCallback callback) {
    return new FingerprintManager.AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errMsgId, CharSequence errString) {
            callback.onAuthenticationError(errMsgId, errString);
        }

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

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

        @Override
        public void onAuthenticationFailed() {
            callback.onAuthenticationFailed();
        }
    };
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:26,代碼來源:FingerprintManagerCompatApi23.java

示例3: testAuthenticationSuccessful

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Mauin,項目名稱:RxFingerprint,代碼行數:23,代碼來源:FingerprintAuthenticationTest.java

示例4: testAuthenticationError

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Test
public void testAuthenticationError() 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().onAuthenticationError(0, ERROR_MESSAGE);

    testObserver.awaitTerminalEvent();
    testObserver.assertError(FingerprintAuthenticationException.class);
    testObserver.assertValueCount(0);

    assertTrue("Should contain 1 error", testObserver.errorCount() == 1);

    Throwable throwable = testObserver.errors().get(0);
    assertTrue("Message should equal ERROR_MESSAGE", throwable.getMessage().equals(ERROR_MESSAGE));
}
 
開發者ID:Mauin,項目名稱:RxFingerprint,代碼行數:21,代碼來源:FingerprintAuthenticationTest.java

示例5: testAuthenticationFailed

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Test
public void testAuthenticationFailed() 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().onAuthenticationFailed();

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

    FingerprintAuthenticationResult fingerprintAuthenticationResult = testObserver.values().get(0);
    assertTrue("Authentication should not be successful", !fingerprintAuthenticationResult.isSuccess());
    assertTrue("Result should be equal FAILED", fingerprintAuthenticationResult.getResult().equals(FingerprintResult.FAILED));
    assertTrue("Should contain no message", fingerprintAuthenticationResult.getMessage() == null);
}
 
開發者ID:Mauin,項目名稱:RxFingerprint,代碼行數:22,代碼來源:FingerprintAuthenticationTest.java

示例6: testAuthenticationHelp

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Test
public void testAuthenticationHelp() 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 fingerprintAuthenticationResult = testObserver.values().get(0);
    assertTrue("Authentication should not be successful", !fingerprintAuthenticationResult.isSuccess());
    assertTrue("Result should be equal HELP", fingerprintAuthenticationResult.getResult().equals(FingerprintResult.HELP));
    assertTrue("Should contain help message", fingerprintAuthenticationResult.getMessage().equals(MESSAGE_HELP));
}
 
開發者ID:Mauin,項目名稱:RxFingerprint,代碼行數:22,代碼來源:FingerprintAuthenticationTest.java

示例7: observeFingerprintActions

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private void observeFingerprintActions(){
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
        return;
    }

    FingerprintManager manager = (FingerprintManager) getApplicationContext().getSystemService(Context.FINGERPRINT_SERVICE);

    this.fingerprintCancellationSignal = new CancellationSignal();

    final FingerprintManager.AuthenticationCallback callback = (FingerprintManager.AuthenticationCallback) fingerprintCallback;
    manager.authenticate(null, fingerprintCancellationSignal, 0, callback, null);
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:13,代碼來源:EnterPinPresenter.java

示例8: initManager

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
private void initManager() {
    mCancellationSignal = new CancellationSignal();
    manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
    mKeyManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    mSelfCancelled = new FingerprintManager.AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errorCode, CharSequence errString) {
            //多次指紋密碼驗證錯誤後,進入此方法;並且,不能短時間內調用指紋驗證
            publishSubject.onError(new FPerException(FINGERPRINTERS_FAILED_ERROR));
            mCancellationSignal.cancel();
        }

        @Override
        public void onAuthenticationHelp(int helpCode, CharSequence helpString) {

        }

        @Override
        public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
            publishSubject.onNext(true);

        }

        @Override
        public void onAuthenticationFailed() {
            publishSubject.onNext(false);
        }
    };
}
 
開發者ID:paradoxie,項目名稱:DizzyPassword,代碼行數:31,代碼來源:RxFingerPrinter.java

示例9: initManager

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
private void initManager() {
    mCancellationSignal = new CancellationSignal();
    manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
    mKeyManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    mSelfCancelled = new FingerprintManager.AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errorCode, CharSequence errString) {
            //多次指紋密碼驗證錯誤後,進入此方法;並且,不能短時間內調用指紋驗證
            publishSubject.onError(new FPerException(FINGERPRINTERS_FAILED_ERROR));
            mCancellationSignal.cancel();
        }

        @Override
        public void onAuthenticationHelp(int helpCode, CharSequence helpString) {

        }

        @Override
        public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
            publishSubject.onNext(true);
        }

        @Override
        public void onAuthenticationFailed() {
            publishSubject.onNext(false);
        }
    };
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:30,代碼來源:RxFingerPrinter.java

示例10: testAuthenticationSuccessfulOnSecondTry

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Mauin,項目名稱:RxFingerprint,代碼行數:34,代碼來源:FingerprintAuthenticationTest.java

示例11: authenticate

import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
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_unable_to_process), 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);
    }
}
 
開發者ID:ajalt,項目名稱:reprint,代碼行數:29,代碼來源:MarshmallowReprintModule.java


注:本文中的android.hardware.fingerprint.FingerprintManager.AuthenticationCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。