本文整理匯總了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();
}
};
}
示例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();
}
};
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
示例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);
}
}