2016-08-29 3 views
2

Android Android 6.0 이상에서 기본 Android Fingerprint API를 사용하여 사용자를 인증하는 앱을 작성하고 있습니다. 하나 개의 시나리오에서Android 지문 api - SCREEN_ON 의도 후 FingerprintManager.AuthenticationCallback이 호출되지 않습니다.

- 장치는 GCM 알림을 수신하고 화면이 꺼져 있지만 전화가 잠겨 있지 않은 경우 - 응용 프로그램은 다음과 같은 플래그 activity 실행하여 장치를 "깨어"

WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED 

을 그런 다음 사용자가 손가락으로 인증하도록 요청하는 대화 상자가 표시됩니다. - (FingerprintManager.AuthenticationCallback에서) 어떤 콜백 함수 -이 경우 여기

라고하는 코드입니다 :

fingerprintManager.authenticate(null, cancellationSignal, 0, new FingerprintManager.AuthenticationCallback() { 
      @Override 
      public void onAuthenticationError(int errorCode, CharSequence errString) { 
       super.onAuthenticationError(errorCode, errString); 
       logger.info("Authentication error " + errorCode + " " + errString); 
       ... 
      } 

      @Override 
      public void onAuthenticationHelp(int helpCode, CharSequence helpString) { 
       super.onAuthenticationHelp(helpCode, helpString); 
       logger.info("Authentication help message thrown " + helpCode + " " + helpString); 
       ... 
      } 

      @Override 
      public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { 
       super.onAuthenticationSucceeded(result); 
       logger.info("Authentication succeeded"); 
       ... 
      } 

      /* 
      * Called when authentication failed but the user can try again 
      * When called four times - on the next fail onAuthenticationError(FINGERPRINT_ERROR_LOCKOUT) 
      * will be called 
      */ 
      @Override 
      public void onAuthenticationFailed() { 
       super.onAuthenticationFailed(); 
       logger.info("Authentication failed"); 
       ... 
      } 
     }, null); 

화면이 켜져있을 때 동일한 코드가 실행이 꺼져 있지만 전원이 때와는 켜져 때 활동에 의해 - 콜백은 호출되지 않습니다.

아이디어가 있으십니까? 미리 감사드립니다.

답변

2

나는 동일한 문제가 나타났습니다과 adb logcat에서 나는 다음 라인을 본 적이 :

W/FingerprintManager : 인증이 이미

을 취소 내가 소스에 깊이 검색 한을 내가 FingerprintManager에 다음과 같은 기능을 발견했습니다 및 코드 :

if (cancel != null) { 
    if (cancel.isCanceled()) { 
     Log.w(TAG, "authentication already canceled"); 
     return; 
    } else { 
     cancel.setOnCancelListener(new OnAuthenticationCancelListener(crypto)); 
    } 
} 

이 의미 당신은 당신의 012를 입력하는 것을 이미 과 함께기능이 취소되었습니다.cancellationSignal. 그냥 당신의 authenticate() 전에 다음 을 추가

if(cancellationSignal.isCanceled()){ 
    cancellationSignal = new CancellationSignal(); 
} 

이 방법 당신은 항상 통과 할 비 취소 cancellationSignal을하고 흐름이 올 것입니다.