smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
491 stars 116 forks source link

Authentication dialog not shown on non-Samsung devices #32

Closed ghost closed 7 years ago

ghost commented 7 years ago

The plugin is working pretty well in all samsung devices where I have tested so far but I'm getting an error in all non samsung devices where I have tested.

[SamsungFingerprintImplementation] com.samsung.android.sdk.SsdkUnsupportedException: This is not Samsung device. [SamsungFingerprintImplementation] at com.samsung.android.sdk.pass.Spass.initialize(Unknown Source)

I have notice in your code that in the CreateFingerprint method inside the CrossFingerprint's class, you are asking for if it is compatible or not, and seem like the app is crashing there. Maybe in the constructor of SamsungFingerprintImplementation because inside that constructor it is when you are checking and setting the IsCompatible attribute.

smstuebe commented 7 years ago

Hi thanks for the feedback. I tested it on non samsung Devices (nexus 5x) as well. I'll digg into it :) what devices have you used for testing?

ghost commented 7 years ago

I have tested in three different devices:

Nexus 6P (Android 7.1.1) OnePlus 2 ( Android 6.0.1) LG V10 Model LG-H901 (Android 6.0)

In all those devices I'm getting the same error.

[Mono] Assembly Ref addref Plugin.Fingerprint.Abstractions[0xef153e40] -> System.Threading.Tasks[0xef1545c0]: 7

[Mono] Assembly Ref addref Plugin.Fingerprint[0xef153fc0] -> Plugin.Fingerprint.Android.Samsung[0xef153f00]: 2

_[SMSDK] Could not find ContextProvider

_[SMSDK] versionCode: -1

_[SM_SDK] Add com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURESURVEY permission

[SamsungFingerprintImplementation] com.samsung.android.sdk.SsdkUnsupportedException: This is not Samsung device.

[SamsungFingerprintImplementation] at com.samsung.android.sdk.pass.Spass.initialize(Unknown Source)

[Editor] setInputTypeforClipTray(): 0

_[Timeline] Timeline: Activityidle id: android.os.BinderProxy@13eb3e3 time:15379924

[] 203,686 ( 417) OnActivitySaveInstanceState:md5e0db24dc94d81030b4f45e9b537ed1c7.MainActivity

[Mono] [0xce0bf930] worker finishing

Thread finished: #3

I have notice the log also mention to add samsung permission, but in the AndroidManifest I have that permission added.

<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="com.samsung.android.providers.context.

permission.WRITE_USE_APP_FEATURE_SURVEY" />

Also I have checked runtime permission but really that is not needed. Any way, your plugin work fine in all the samsung devices where I have tested whit the current implementation I have, but it is no working in the non samsung devices where I have tested.

Best regards,

Yadrian

On Fri, Nov 18, 2016 at 1:40 PM, Sven-Michael Stübe < notifications@github.com> wrote:

Hi thanks for the feedback. I tested it on non samsung Devices (nexus 5x) as well. I'll digg into it :) what devices have you used for testing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#issuecomment-261622909, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNpqkplm4f4LSYH2hDsFfPCwclHWOks5q_f8wgaJpZM4K2i3D .

smstuebe commented 7 years ago

I think I know what the problem is. can't provide an update, today. Stay tuned.

ghost commented 7 years ago

Ok, great.

On Fri, Nov 18, 2016 at 4:38 PM Sven-Michael Stübe notifications@github.com wrote:

I think I know what the problem is. can't provide an update, today. Stay tuned.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#issuecomment-261660650, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNlfzc7-55Je2KObO_fDrs30KJuztks5q_ijQgaJpZM4K2i3D .

smstuebe commented 7 years ago

Hmmm,

I just created a new project and used the library from nuget. I could not reproduce your problem with my nexus 5x Android 7.1.1. Do you have some code or a small example project?

ghost commented 7 years ago

Ok, well. I have created a very basic project also using the library from NuGet. Here you can download the solution and test it. https://github.com/Yadrian/testing_fingerprint As you could see it is a very basic implementation following the steps you have described about how to use it. For me is working pretty well in Samsung devices but it does not work with non-Samsung devices. (check the logs I sent you before)

Use the link below to download the test solution: https://github.com/Yadrian/testing_fingerprint

On Sat, Nov 19, 2016 at 9:53 AM, Sven-Michael Stübe < notifications@github.com> wrote:

Hmmm,

I just created a new project and used the library from nuget. I could not reproduce your problem with my nexus 5x Android 7.1.1. Do you have some code or a small example project?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#issuecomment-261721710, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNscAD1RelH2GzF6YD5GwmGkj66iIks5q_xuIgaJpZM4K2i3D .

smstuebe commented 7 years ago

Weird. Can't reproduce it. Is your App really crashing? I see the same output you showed in the device log, but no crash. Are you using Xamarin Studio on Mac or Visual Studio on Windows? Have you updated it to the latest version?

ghost commented 7 years ago

Sorry. I explained wrong. The app is not crashing. Just the fingerprint dialog is never prompted. And you can see the logs I sent you before. In other words, it is not working the finger print authentication in non-Samsung devices, the fingerprint dialog is never launched but the app is not crashing. I'm using the latest version of Xamarin Studio 6.1.2. on MacBook Pro Running OS X El Capitan Version 10.11.6.

Then if you see the same logs I sent you, let me know if you can see the fingerprint dialog on non-Samsung devices? Because for me is not working, check the test solution I sent you before.

Best regards,

Yadrian

On Sat, Nov 19, 2016 at 12:53 PM, Sven-Michael Stübe < notifications@github.com> wrote:

Weird. Can't reproduce it. Is your App really crashing? I see the same output you showed in the device log, but no crash. Are you using Xamarin Studio on Mac or Visual Studio on Windows? Have you updated it to the latest version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#issuecomment-261732232, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNoYqKJpMlGpzuCnDIfqu1Pi91mbbks5q_0WYgaJpZM4K2i3D .

smstuebe commented 7 years ago

I used your example and it ran successful. Can you change the code to

public async Task FingerPrintAuthentication()
{
    var availability = await CrossFingerprint.Current.GetAvailabilityAsync();
}

and check what value availability has on each phone?

ghost commented 7 years ago

I caught an exception, attached you can see the log. Any way, that exception was thrown in my app, not in the basic example project I have created. After a couple of testing I have notice that example project is working pretty well in Samsung devices but also is working in non-Samsung devices. But the same code in my app is throwing an exception that you can see in the image attached here. I will remove the bug I have added to your library since the integration have worked in the test solution. Any suggestion about why your library is throwing a exception in my project will be welcome.

On Sat, Nov 19, 2016 at 1:10 PM, Sven-Michael Stübe < notifications@github.com> wrote:

I used your example and it ran successful. Can you change the code to

public async Task FingerPrintAuthentication() { var availability = await CrossFingerprint.Current.GetAvailabilityAsync(); }

and check what value availability has on each phone?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#issuecomment-261733204, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNp5E-ZHpXcEAg4_j3SRu6LG0LZ6Qks5q_0mmgaJpZM4K2i3D .

smstuebe commented 7 years ago

Where is the caught exception? Github doesn't attach the Mail attachments to the issue.

Hmm the only difference is: The sample is using the source code instead of the nuget. But your example ran fine on my phone, too. So I don't think that there is something wrong with the NuGet package.

ZachSand commented 7 years ago

I'm having the same issue (or one very similar).

I installed Xamarin-Fingerprint as well as the Plugin.CurrentActivity package from the Nuget Package Manager in Visual Studios (updated VS a few days ago) to my Xamarin Forms shared project (only targeting Droid and iOS). I then added the Android permissions for fingerprint and Samsung. I recreated your small sample onto my app's login page through XAML and the code behind. Everything builds and deploys successfully in debug mode but when I press the button to authenticate it is not working.

The app doesn't crash or anything, it just returns the status of NotAvailable and the errorMessage is empty/null.

Testing on a Nexus 7 emulator (AVD_for_Nexus_7_2012_by_Google) targetting Android 7.0 API 24 using Google APIs Intel Atom (x86). Minimum target SDK is 19.

......
D/Mono    ( 5712): Assembly Ref addref Plugin.Fingerprint[0xa28363e0] -> Plugin.Fingerprint.Android.Samsung[0xa28359c0]: 2
11-23 14:45:15.282 D/SM_SDK  ( 5712): Could not find ContextProvider
11-23 14:45:15.282 D/SM_SDK  ( 5712): versionCode: -1
11-23 14:45:15.282 D/SM_SDK  ( 5712): Add com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY permission
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):*
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712): com.samsung.android.sdk.SsdkUnsupportedException: This is not Samsung device.
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at com.samsung.android.sdk.pass.Spass.initialize(Unknown Source)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.n_onClick(Native Method)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.onClick(ButtonRenderer_ButtonClickListener.java:30)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.view.View.performClick(View.java:5610)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.view.View$PerformClick.run(View.java:22260)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.os.Handler.handleCallback(Handler.java:751)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.os.Handler.dispatchMessage(Handler.java:95)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.os.Looper.loop(Looper.java:154)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at android.app.ActivityThread.main(ActivityThread.java:6077)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at java.lang.reflect.Method.invoke(Native Method)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
11-23 14:45:15.318 W/SamsungFingerprintImplementation( 5712):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
.....

In a debugging effort I removed the Samsung permission from the Android manifest and rebuilt/redeployed and there was zero change in behavior -- I got the same error response.

Unfortunately I won't be able to share the repo for our application with you as it is private and out of my control but I can answer any questions you might have. Let me know if you need any additional details.

smstuebe commented 7 years ago

Ok one try: Can you please check the type of CrossFingerprint.Current? Is it SamsungFingerprintImplementation or StandardFingerprintImplementation ?

And the same question for you: What does CrossFingerprint.Current.GetAvailabilityAsync() return?

ZachSand commented 7 years ago

Here's the details from my debugging when the authentication button is pressed.

CrossFingerprint.Current = {Plugin.Fingerprint.Standard.StandardFingerprintImplementation}

CrossFingerprint.Current.GetAvailabilityAsync() = 
System.Threading.Tasks.Task.<Plugin.Fingerprint.Abstractions.FingerprintAvailability> 
  {
    Id = 1, Status = RanToCompletion, Method = {null}, AsyncState = null, Exception = null,
    CancellationPending = false
  }
smstuebe commented 7 years ago
  1. thx
  2. This is just the task not the result :P ofc I meant var availability = await CrossFingerprint.Current.GetAvailabilityAsync() ^^ What's the value of availability?

Have you enrolled the fingerprint on your Emulator? As far as I know: The Nexus 7 doesn't have a fingerprint sensor. Can you try a Nexus 5X ???

ZachSand commented 7 years ago

I copied the type and the values of the type's data members in my previous comment between the brackets. Were you expecting something different?

When I run the emulator and go to Settings->Security there's an option for opening the lock screen with "Fingerprint". Also in the extended controls of the emulator there is a "Fingerprint" section. I assumed this meant it was Fingerprint enabled.

I changed the verbosity of my error output and I just noticed that I'm getting the following before the previously mentioned error output:

...
Assembly Ref addref be[0xa7b05160] -> Plugin.Fingerprint.Abstractions[0xa7b05100]: 3
11-23 16:25:59.189 D/Mono    ( 2854): Assembly Loader probing location: '/storage/emulated/0/Android/data/io.com.app/files/.__override__/System.Threading.Tasks.dll'.
11-23 16:25:59.190 D/Mono    ( 2854): AOT module '/storage/emulated/0/Android/data/io.com.app/files/.__override__/System.Threading.Tasks.dll.so' not found: dlopen failed: library "/data/app/io.com.app-1/lib/x86/libaot-System.Threading.Tasks.dll.so" not found
11-23 16:25:59.190 D/Mono    ( 2854): AOT module '/Users/builder/data/lanes/3511/77cb8568/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/System.Threading.Tasks.dll.so' not found: dlopen failed: library "/data/app/io.com.app-1/lib/x86/libaot-System.Threading.Tasks.dll.so" not found
11-23 16:25:59.190 D/Mono    ( 2854): Assembly Ref addref Plugin.Fingerprint.Abstractions[0xa7b05100] -> System.Threading.Tasks[0xa7b05d60]: 3

Maybe the issue stems from it not being able to find the System.Threading.Tasks dll? It's strange that it can't find it thought because I have System.Threading.Tasks under my References for both my Droid and iOS project.

I can try to run it on a different emulator but it might be a while before I can around to doing that.

smstuebe commented 7 years ago

Were you expecting something different?

Yes of course. var availability = await CrossFingerprint.Current.GetAvailabilityAsync() returns a FingerprintAvailability so please try to think one second before answering ;) It's late in Germany and I'm spending my sleep time... Come on it was obvious that I meant this and on the Task.

ZachSand commented 7 years ago

Apologies for the misunderstanding, I'm not familiar with any of this. I appreciate your help.

availability = Plugin.Fingerprint.Abstractions.FingerprintAvailability.NoFingerprint

smstuebe commented 7 years ago

Ok :) NoFingerprint means: Fingerprint has not been set up.

https://github.com/smstuebe/xamarin-fingerprint/blob/master/src/Plugin.Fingerprint.Abstractions/FingerprintAvailability.cs#L29

I think you have to enroll a Fingerprint: https://developer.xamarin.com/guides/android/platform_features/fingerprint-authentication/enrolling-fingerprint/

On Windows you might need telnet: https://github.com/smstuebe/xamarin-fingerprint/blob/master/README.md#android-1

good night.

ZachSand commented 7 years ago

It works now that I'm using a different emulator with the fingerprint setup. I didn't have to use telnet, the emulator had the option to mock a fingerprint.

smstuebe commented 7 years ago

@ZachSand Can you please say which emulator you used? I might write a trouble shoot doc, because you were not the first one with this problem.

smstuebe commented 7 years ago

@Yadrian any updates on your issues?

ghost commented 7 years ago

For me still is not working in the app I'm working on. As I told before, I added a try-catch and I'm getting the following error: {System.TypeLoadException: Could not resolve type with token 01000020 at System.Runtime.CompilerSer…} System.TypeLoadException

Use this link to see more details: https://drive.google.com/open?id=0B4m8QC55wCSfRS1yR0NFcWJaUEk

Maybe it is a compatibility problem with another libraries I'm using in my project but at this time I'm not able to know what is causing the problem.

About the example solution I have created and shared with you on Github, that example it is working properly. But the real project I'm working on with the same implementation is throwing the exception I sent you here. But unfortunately I can not share the code of that app. Any way, take a look to the link I put above and let me know what you think about it.

Best regards,

Yadrian

On Fri, Nov 25, 2016 at 6:56 AM, Sven-Michael Stübe < notifications@github.com> wrote:

Assigned #32 https://github.com/smstuebe/xamarin-fingerprint/issues/32 to @Yadrian https://github.com/Yadrian.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#event-872049610, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNk2XERQOov307cn0njnKnUvoRO6fks5rBtsVgaJpZM4K2i3D .

ghost commented 7 years ago

I forgot to mention that I can not tell you what is the value of availability's var since the exception is thrown just in that call.

On Fri, Nov 25, 2016 at 9:29 AM, Yadrian Serrano García <yadriansg@gmail.com

wrote:

For me still is not working in the app I'm working on. As I told before, I added a try-catch and I'm getting the following error: {System.TypeLoadException: Could not resolve type with token 01000020 at System.Runtime.CompilerSer…} System.TypeLoadException

Use this link to see more details: https://drive.google.com/open?id=0B4m8QC55wCSfRS1yR0NFcWJaUEk

Maybe it is a compatibility problem with another libraries I'm using in my project but at this time I'm not able to know what is causing the problem.

About the example solution I have created and shared with you on Github, that example it is working properly. But the real project I'm working on with the same implementation is throwing the exception I sent you here. But unfortunately I can not share the code of that app. Any way, take a look to the link I put above and let me know what you think about it.

Best regards,

Yadrian

On Fri, Nov 25, 2016 at 6:56 AM, Sven-Michael Stübe < notifications@github.com> wrote:

Assigned #32 https://github.com/smstuebe/xamarin-fingerprint/issues/32 to @Yadrian https://github.com/Yadrian.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smstuebe/xamarin-fingerprint/issues/32#event-872049610, or mute the thread https://github.com/notifications/unsubscribe-auth/AGvBNk2XERQOov307cn0njnKnUvoRO6fks5rBtsVgaJpZM4K2i3D .

ghost commented 7 years ago

Finally I solved the issue. The library was working fine, the problem was happening just because I was compiling the project targeting Android 5.1 and should be Android 6.0 since Googled added fingerprint support in Android 6.0 . This was my mistake. Apologize everyone for any inconvenience.