Fingerprint


Fingerprint는 3.0.0 버전 이상 부터 제공되며 해당 라이브러리를 추가하여 사용해야 된다.

Fingerprint 은 HSP 에서 확장 라이브러리로 제공하는 API 로 aar 라이브러리 파일과 build.gradle 파일을 수정하여 사용할 수 있다. 

라이브러리 추가 방법은 Android 개발 가이드의 내용을 참조하면 된다.

Fingerprint 은 지문이 올바른지 유/무 를 전달하는 기능을 가지고 있으며 Optional 한 기능이므로 사용자가 별도로 개발하여 사용해도 무방하다.


authenticate

authenticate 를 요청 하면 먼저 단말에 지문이 등록되어 있는지를 확인한 뒤 지문이 등록되어 있으면 센서에 인식중인 지문이 올바른지 그렇지 않은지를 반환 한다. 

Example

// 3.10.18 이상
DAPFingerprint.authenticate(activity, "지문인식을 해주세요", {
   // TODO
}) {
   // TODO
}

// 3.10.18 이하
DAPFingerprint.authenticate(activity, "지문인식을 해주세요") { result, value ->
    when (result) {
        OnResultListener.TRUE -> {
           // TODO
       }
       else -> {
           // TODO
       }
   }
}
// 3.10.18 이상
DAPFingerprint.authenticate(activity, "지문인식을 해주세요", result -> {
       // TODO
   }, e -> {
       // TODO
   });

// 3.10.18 이하
DAPFingerprint.authenticate(activity, "지문인식을 해주세요", (result, value) -> {
   switch (result) {
       case OnResultListener.TRUE:
           // TODO
           break;
       default:
           // TODO
           break;
   }
});

기본 Layout

API LEVEL 28 부터는 Android 제공하는 Biotmetric Prompt 를 이용하여 생체 인증을 검증하기 때문에 레이아웃을 커스텀 할 수 없다. 

지문 인식시 화면에 나타나는 다이얼로그는 hone_fingerprint_dialog.xml 으로 구성되어 있으며 App 단에서 해당 xml 을 새로 만들어 버튼과 이미지 등을 변경할 수 있다. 

hone_fingerprint_dialog.xml


<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">

   <ImageView
       android:id="@+id/fingerprint_icon"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:src="@drawable/hone_fingerprint_ic_fp_40px"
       android:layout_centerHorizontal="true"
       tools:ignore="ContentDescription"/>

   <ImageView
       android:id="@+id/result"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/fingerprint_icon"
       android:layout_toRightOf="@+id/fingerprint_icon"
       android:translationX="-20dp"
       android:translationY="-20dp"
       android:src="@drawable/hone_fingerprint_ic_fingerprint_success"
       android:visibility="gone"
       tools:ignore="ContentDescription,RtlHardcoded"/>

   <TextView
       android:layout_marginTop="20dp"
       android:id="@+id/retry_message"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/fingerprint_icon"
       android:layout_centerHorizontal="true"
       android:textSize="20sp"
       android:textStyle="bold"
       android:text="@string/hone_fingerprint_retry"
       android:visibility="gone"
       />

   <TextView
       android:layout_marginTop="20dp"
       android:layout_marginLeft="20dp"
       android:layout_marginRight="20dp"
       android:id="@+id/message"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/retry_message"
       android:gravity="center"
       android:layout_centerHorizontal="true"
       />

   <Button
       android:id="@+id/cancel_button"
       style="?android:attr/buttonBarButtonStyle"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_marginTop="20dp"
       android:layout_gravity="center"
       android:text="@android:string/cancel"
       android:layout_below="@+id/message" android:layout_alignParentLeft="true"
       android:layout_alignParentStart="true"/>
</RelativeLayout>