private void InitializeFP() { fp = new FingerprintHandler(); fp.SuccessfullyAddedToDBEvent += Fp_SuccessfullyAddedToDBEvent; fp.FailedToAddToDBEvent += Fp_FailedToAddToDBEvent; }
public ScanWindow() { InitializeComponent(); fp = new FingerprintHandler(); fp.SuccessfullyScannedFP += Fp_SuccessfullyScannedFP; fp.GetTemplate += Fp_GetTemplate; fp.DeviceNotConnected += Fp_DeviceNotConnected; }
protected override void OnResume() { base.OnResume(); bool fingerprint = !string.IsNullOrEmpty(Utils.GetDefaults("fingerprint")) && Convert.ToBoolean(Utils.GetDefaults("fingerprint")); if (!fingerprint && !string.IsNullOrEmpty(Utils.GetDefaults("UserPin"))) { StartActivity(typeof(PinActivity)); return; } FingerprintManagerCompat checkHardware = FingerprintManagerCompat.From(this); var keyguardManager1 = (KeyguardManager)GetSystemService(KeyguardService); if (!fingerprint || !checkHardware.IsHardwareDetected || !keyguardManager1.IsKeyguardSecure) { return; } SetContentView(Resource.Layout.activity_finger); var animationView = FindViewById <LottieAnimationView>(Resource.Id.animation_view); var filter = new SimpleColorFilter(ContextCompat.GetColor(this, Resource.Color.colorAccent)); animationView.AddValueCallback(new KeyPath("**"), LottieProperty.ColorFilter, new LottieValueCallback(filter)); //Using the Android Support Library v4 var keyguardManager = (KeyguardManager)GetSystemService(KeyguardService); var fingerprintManager = (FingerprintManager)GetSystemService(FingerprintService); var btn = FindViewById <Button>(Resource.Id.btn_pin); btn.Click += (sender, e) => { StartActivity(typeof(PinActivity)); }; if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.UseFingerprint) != (int)Permission.Granted) { return; } if (!fingerprintManager.IsHardwareDetected) { Toast.MakeText(this, "Nu exista permisiuni pentru autentificare utilizand amprenta", ToastLength.Long).Show(); LoadLoginUi(); } else { if (!fingerprintManager.HasEnrolledFingerprints) { Toast.MakeText(this, "Nu ati inregistrat nici o amprenta in setari", ToastLength.Long).Show(); LoadLoginUi(); } else { if (!keyguardManager.IsKeyguardSecure) { Toast.MakeText(this, "Telefonul trebuie sa fie securizat utilizand senzorul de amprente", ToastLength.Long).Show(); LoadLoginUi(); } else { GenKey(); } if (!CipherInit()) { return; } var helper = new FingerprintHandler(this); helper.StartAuthentication(fingerprintManager, new FingerprintManager.CryptoObject(_cipher)); helper.FingerprintAuth += delegate(object sender, FingerprintHandler.FingerprintAuthEventArgs args) { if (args.Status) { StartActivity(typeof(MainActivity)); Finish(); } else { var filterError = new SimpleColorFilter( ContextCompat.GetColor(this, Resource.Color.accent)); animationView.AddValueCallback(new KeyPath("**"), LottieProperty.ColorFilter, new LottieValueCallback(filterError)); var vibrator = (Vibrator)GetSystemService(VibratorService); vibrator?.Vibrate(VibrationEffect.CreateOneShot(100, VibrationEffect.DefaultAmplitude)); if (args.ErrorsCount != 5) { return; } Toast.MakeText(this, "5 incercari gresite de verificare a amprentelor!", ToastLength.Long).Show(); } }; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.FingerPrintAuth); String nombreArchivo = "app-bco_security.sqlite"; String rutaCarpeta = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); String ruta = System.IO.Path.Combine(rutaCarpeta, nombreArchivo); var key = new Contenido() { Password = KEY_NAME }; DatabaseHelper.Insertar(ref key, ruta); KeyguardManager keyguardManager = (KeyguardManager)GetSystemService(KeyguardService); FingerprintManager fingerprintManager = (FingerprintManager)GetSystemService(FingerprintService); if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.UseFingerprint) != (int)Android.Content.PM.Permission.Granted) { return; } if (!fingerprintManager.IsHardwareDetected) { Toast.MakeText(ApplicationContext, "Lector de huella no habilitado en tu dispositivo", ToastLength.Long).Show(); } else { if (!fingerprintManager.HasEnrolledFingerprints) { Toast.MakeText(ApplicationContext, "Debes enrolar tu huella del dispositivo", ToastLength.Long).Show(); } else { if (!keyguardManager.IsKeyguardSecure) { Toast.MakeText(ApplicationContext, "No tienes habilitada la configuracion del scaner dactilar", ToastLength.Long).Show(); } else { GenKey(); } if (CipherInit()) { FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler helper = new FingerprintHandler(this); helper.StartAuthentication(fingerprintManager, cryptoObject); } } } lblTituloAsociaHuella = FindViewById <TextView>(Resource.Id.lblTituloAsociaHuella); lblTextoIndicacionAsociacion1 = FindViewById <TextView>(Resource.Id.lblTextoIndicacionAsociacion1); lblTextoIndicacionAsociacion2 = FindViewById <TextView>(Resource.Id.lblTextoIndicacionAsociacion2); lblTextoIndicacionAsociacion3 = FindViewById <TextView>(Resource.Id.lblTextoIndicacionAsociacion3); lblTextoIndicacionAsociacion4 = FindViewById <TextView>(Resource.Id.lblTextoIndicacionAsociacion4); lblTextoIndicacionAsociacion5 = FindViewById <TextView>(Resource.Id.lblTextoIndicacionAsociacion5); btnOmitirEnrolado = FindViewById <ImageView>(Resource.Id.btnOmitirEnrolado); btnOmitirEnrolado.Click += BtnOmitirEnrolado_Click; var fontRegular = Typeface.CreateFromAsset(Assets, rutaFuenteTitiliumRegular); var fontSemiBold = Typeface.CreateFromAsset(Assets, rutaFuenteTitiliumSemiBold); lblTituloAsociaHuella.Typeface = fontSemiBold; lblTextoIndicacionAsociacion1.Typeface = fontRegular; lblTextoIndicacionAsociacion2.Typeface = fontSemiBold; lblTextoIndicacionAsociacion3.Typeface = fontRegular; lblTextoIndicacionAsociacion4.Typeface = fontRegular; lblTextoIndicacionAsociacion5.Typeface = fontRegular; }