Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fingerprint API for Android

Fingerprint API for Android

E28404a128b6014e6f499d2a967c72a0?s=128

Takuji Nishibayashi

November 30, 2015
Tweet

Transcript

  1. Fingerprint API for Android @takuji31

  2. About me • Takuji Nishibayashi • @takuji31 • Fenrir Inc.

    • NNID: takuji31 • Udemae: S / Rank: 41 • Loves Android / Kotlin
  3. New features in Marshmallow (Android 6)

  4. Now on Tap

  5. New Permission Model

  6. see. http://bit.ly/1LI09MJ

  7. Fingerprint API

  8. Authentication with Fingerprint

  9. Available in Nexus 5X/6P (Nexus Imprint)

  10. how to use

  11. Use these APIs in conjunction with the Android Keystore system.

    — Android 6.0 APIs
  12. Needs keyguard lock

  13. PIN

  14. Password

  15. Pattern

  16. Add USE_FINGERPRINT permission

  17. Add USE_FINGERPRINT permission <uses-permission android:name="android.permission.USE_FINGERPRINT" />

  18. Check keyguard is enabled

  19. Check keyguard is enabled public class MainActivity extends Activity {

    KeyguardManager mKeyguardManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!mKeyguardManager.isKeyguardSecure()) { // keyguard disabled Toast.makeText(this, "Secure lock screen hasn't set up.\n" + "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint", Toast.LENGTH_LONG).show(); return; } } }
  20. Check fingerprint registered

  21. Check fingerprint registered public class MainActivity extends Activity { @Inject

    FingerprintManager mFingerprintManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!mFingerprintManager.hasEnrolledFingerprints()) { // no fingerprints registered Toast.makeText(this, "Go to 'Settings -> Security -> Fingerprint' and register at least one fingerprint", Toast.LENGTH_LONG).show(); return; } } }
  22. Create encryption key

  23. Start Authentication

  24. Start Authentication mCancellationSignal = new CancellationSignal(); mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0, this,

    null); @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { // authentication error } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { // needs help? } @Override public void onAuthenticationFailed() { // failed } @Override public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { // succeeded }
  25. but

  26. These codes has no UI

  27. Create UI yourself !

  28. Darkness..?

  29. No!

  30. Use sample code dialog fragment

  31. Two samples available • Fingerprint Dialog • Asymmetric Fingerprint Dialog

  32. None
  33. !

  34. URL • Android 6.0 APIs • http://developer.android.com/intl/ja/about/versions/marshmallow/ android-6.0.html#fingerprint-authentication • Android

    Keystore System • http://developer.android.com/intl/ja/training/articles/keystore.html • FingerprintDialog sample • http://developer.android.com/intl/ja/samples/FingerprintDialog/ index.html • Google Store • https://store.google.com/category/phones • Buy now !
  35. Happy secure life!