7

지문 제스처를 사용하여 Pixel 장치에서 접근성을 테스트합니다. FingerprintGestureController를 사용하여 제스처 콜백을 얻으 려하지만 설정 -> 내게 필요한 옵션에서이 응용 프로그램의 접근 기능을 ON으로 설정 한 후에도 어떤 제스처도 반환하지 않습니다. isGestureDetectionAvailable()은 항상 false를 반환합니다. 누군가 제발 도와 줄 수 있어요. 여기 Android O - 지문 제스처 콜백이 작동하지 않습니다.

코드이다

my_gesture_service.xml

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" 
android:accessibilityFeedbackType="feedbackGeneric" 
android:accessibilityFlags="flagDefault" 
android:canRequestFingerprintGestures="true" /> 

의 AndroidManifest.xml

<uses-feature android:name="android.hardware.fingerprint"/> 
    <uses-permission android:name="android.permission.USE_FINGERPRINT" /> 
    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"/> 
<service 
      android:name="android.gestures.MyService" 
      android:label="@string/app_name" 
      android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> 
      <intent-filter> 
       <action android:name="android.accessibilityservice.AccessibilityService" /> 
      </intent-filter> 
      <meta-data 
       android:name="android.accessibilityservice" 
       android:resource="@xml/my_gesture_service" /> 
     </service> 

MyService.java

public class MyService extends AccessibilityService { 

    private static final String TAG = MyService.class.getSimpleName(); 

    @Override 
    public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { 
     Log.d(TAG, "onAccessibilityEvent"); 
    } 

    @Override 
    public void onInterrupt() { 
     Log.d(TAG, "onInterrupt"); 
    } 

    @Override 
    protected boolean onGesture(int gestureId) { 
     Log.d(TAG, "onGesture " + gestureId); 
     return super.onGesture(gestureId); 
    } 

    @Override 
    protected boolean onKeyEvent(KeyEvent event) { 
     Log.d(TAG, "onKeyEvent " + event.getKeyCode()); 
     return super.onKeyEvent(event); 
    } 

    @Override 
    public void onDestroy() { 
     Toast.makeText(getApplicationContext(), "onDestroy" , Toast.LENGTH_SHORT).show(); 
     super.onDestroy(); 
    } 



    @Override 
    protected void onServiceConnected() { 
     super.onServiceConnected(); 
     Log.d(TAG, "onServiceConnected"); 

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 

      FingerprintGestureController gestureController = getFingerprintGestureController(); 

      Toast.makeText(getApplicationContext(), "Is available: " + gestureController.isGestureDetectionAvailable(), Toast.LENGTH_LONG).show(); 
      Log.e(TAG, "Is available: " + gestureController.isGestureDetectionAvailable()); 

      FingerprintGestureController.FingerprintGestureCallback callback = new 
        FingerprintGestureController.FingerprintGestureCallback() { 
         @Override 
         public void onGestureDetectionAvailabilityChanged(boolean available) { 
          super.onGestureDetectionAvailabilityChanged(available); 
          Toast.makeText(getApplicationContext(), "Gesture available change to: " + available, Toast.LENGTH_SHORT).show(); 
          Log.d(TAG, "onGestureDetectionAvailabilityChanged " + available); 
         } 

         @Override 
         public void onGestureDetected(int gesture) { 
          super.onGestureDetected(gesture); 
          Toast.makeText(getApplicationContext(), "Gesture: " + gesture, Toast.LENGTH_SHORT).show(); 
          Log.d(TAG, "onGestureDetected " + gesture); 
         } 
        }; 

      gestureController.registerFingerprintGestureCallback(callback, new Handler()); 
     } 
    } 

    @Override 
    public boolean onUnbind(Intent intent) { 
     Log.d(TAG, "onUnbind "); 
     return super.onUnbind(intent); 
    } 


} 

답변

9

답을 찾았습니다. xml에서도이 플래그 하나가 필요했습니다.