xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 505 forks source link

SecureStorage not always available. Documentation? #1789

Open Kukulkano opened 3 years ago

Kukulkano commented 3 years ago

Description

The SecureStorage is not available on devices like Xiaomi Mi 10T Lite and Huawei P30 with Android 10 and Samsung Galaxy S21 5G with Android 11. There are very likely more such devices. There, functions like SecureStorage.SetAsync() or Android.Provider.Settings.Secure.GetString() will fail.

I think that the functions should either contain an integrated fallback functionality or labeled explicitely as "not available on all devices". At least, developers who need to store data securely should be guided to a procedure or fallback to handle the failure here.

Alternatively, describe the reasons for failure more detailed. Maybe users can do something to activate this? I found no reliable source telling me why this is somethimes not available. Is it because of missing device-lock (code, pattern, fingerprint)? From my experience it has nothing to do with it.

Steps to Reproduce

Use these functions on one of the above mentioned devices.

Expected Behavior

Work on all devices.

Actual Behavior

Fails on some modern devices.

ghost commented 3 years ago

@Kukulkano I think the application I'm working on suffers from the same behavior, but I don't have a device to reproduce this. When you say the calls are failing, are these throwing an exception, or just silently doing nothing?

Kukulkano commented 3 years ago

these throwing an exception, or just silently doing nothing?

@YvesDelcoigne Here they throw exceptions. Sadly, it is not always easy to identify this from google stacktrance. I mostly got android.runtime.JavaProxyThrowable, but also others.

The problem is that, as a software developer, you don't know what to do then. If you have to develop a safe alternative for this exception, then there is no reason to use the Xamarin function at all.

This is why I filed this bug.

ghost commented 3 years ago

Indeed, not really usable if it's unreliable.

Saccomani commented 1 year ago

I am having a strange behavior using secure storage, in samsung devices, after this update: https://doc.samsungmobile.com/SM-G780F/ZTO/doc.html, some secure storages has been deleted.