Pro Yearly is on sale from $80 to $50! »

Biometric Prompt

Biometric Prompt

E519edb7ffc107220b60ba98ea66ef9e?s=128

Hiroshi Hashimoto

June 13, 2018
Tweet

Transcript

  1. Biometric Prompt 〜Google I/O 2018 わいわい報告会 in 福岡~ Hiroshi Hashimoto

    @hi6484 株式会社メルペイ
  2. 自己紹介 Hiroshi Hashimoto @hi6484 株式会社メルペイ Android Developer

  3. Biometric Prompt

  4. Biometric Prompt Andorid P(API:28)から Fingerprint Managerが非推奨となり Biometric Promptへ

  5. FingerPrint Manager

  6. Fingerprint Manager <uses-permission android:name="android.permission.USE_FINGERPRINT" />

  7. Fingerprint Manager val fingerprintManager = getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager //Fingerprintが搭載端末且つ登録済み if

    (manager.isHardwareDetected and fingerprintManager.hasEnrolledFingerprints()) { //認証処理 }
  8. Fingerprint Manager fingerprintManager.authenticate( cryptoObject, cancellationSignal, flags, authenticationCallback, Handler())

  9. Fingerprint Manager object : FingerprintManager.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int,

    errString: CharSequence?) { super.onAuthenticationError(errorCode, errString) } override fun onAuthenticationSucceeded(result: FingerprintManager.AuthenticationResult?) { super.onAuthenticationSucceeded(result) } override fun onAuthenticationFailed() { super.onAuthenticationFailed() } override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence?) { super.onAuthenticationHelp(helpCode, helpString) } }
  10. Fingerprint Manager ・実装は簡単 ・Fingerprintのみ! ・認証するためのダイアログは各アプリで。

  11. Biometric Prompt

  12. Biometric Prompt <uses-permission android:name="android.permission.USE_BIOMETRIC"/>

  13. Biometric Prompt <uses-permission android:name="android.permission.USE_BIOMETRIC"/> <uses-permission android:name="android.permission.USE_FINGERPRINT"/> Fingerprint Manager

  14. Biometric Prompt if (packageManager.hasSystemFeature( PackageManager.FEATURE_FINGERPRINT)) { //認証処理 }

  15. Biometric Prompt if (packageManager.hasSystemFeature( PackageManager.FEATURE_FINGERPRINT)) { //認証処理 } val manager

    = getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager //Fingerprintが搭載端末且つ登録済み if (manager.isHardwareDetected and fingerprintManager.hasEnrolledFingerprints()) { //認証処理 } Fingerprint Manager
  16. Biometric Prompt biometricPrompt = BiometricPrompt.Builder(this) .setTitle("タイトル") .setSubtitle("サブ タイトル") .setDescription("指紋認証をお願いします") .setNegativeButton("キャンセル",

    mainExecutor, DialogInterface.OnClickListener {dialogInterface, i -> }) .build()
  17. Biometric Prompt biometricPrompt.authenticate( cryptoObject, cancellationSignal, mainExecutor, authenticationCallback) biometricPrompt.authenticate( cancellationSignal, mainExecutor,

    authenticationCallback)
  18. Biometric Prompt biometricPrompt.authenticate( cancellationSignal, mainExecutor, authenticationCallback) fingerprintManager.authenticate( cryptoObject, cancellationSignal, flags,

    authenticationCallback, Handler()) Fingerprint Manager
  19. Biometric Prompt object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int,

    errString: CharSequence) { super.onAuthenticationError(errorCode, errString) } override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) { super.onAuthenticationHelp(helpCode, helpString) } override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { super.onAuthenticationSucceeded(result) } override fun onAuthenticationFailed() { super.onAuthenticationFailed()
  20. Biometric Prompt object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int,

    errString: CharSequence) { } override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) { } override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { } override fun onAuthenticationFailed() { object : FingerprintManager.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) { } override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence?) { } override fun onAuthenticationSucceeded(result: FingerprintManager.AuthenticationResult?) { } override fun onAuthenticationFailed() { } } Fingerprint Manager
  21. Biometric Prompt ・実装は簡単 ・Fingerprint以外もできるはず! ・認証するためのダイアログは共通になる!!!

  22. Demo

  23. Biometric Prompt けど、 APIレベルは 28以上!!

  24. Biometric Prompt ・P以上はBiometricPromptを使う (使った方が楽) ・M以上N以下はFingerprintManager ・M以上N以下は頑張ってDialogを実装する

  25. Biometric Prompt あとは、 Fingerprint以外の認証方法ができるのを 待つのみ

  26. ご静聴ありがとうございました。