mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-28 08:32:16 +01:00
Authentication improvements/fixes
This commit is contained in:
@@ -658,18 +658,23 @@ public class Helper {
|
||||
static boolean shouldAuthenticate(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
if (!biometrics)
|
||||
return false;
|
||||
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
int screen_timeout = Settings.System.getInt(resolver, Settings.System.SCREEN_OFF_TIMEOUT, -1);
|
||||
Log.i("Screen timeout=" + screen_timeout);
|
||||
if (biometrics) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
int screen_timeout = Settings.System.getInt(resolver, Settings.System.SCREEN_OFF_TIMEOUT, -1);
|
||||
Log.i("Screen timeout=" + screen_timeout);
|
||||
|
||||
long now = new Date().getTime();
|
||||
long last_authentication = prefs.getLong("last_authentication", 0);
|
||||
prefs.edit().putLong("last_authentication", now).apply();
|
||||
long now = new Date().getTime();
|
||||
long last_authentication = prefs.getLong("last_authentication", 0);
|
||||
Log.i("Authentication valid until=" + new Date(last_authentication + screen_timeout));
|
||||
|
||||
return (last_authentication + screen_timeout < now);
|
||||
if (last_authentication + screen_timeout < now)
|
||||
return true;
|
||||
|
||||
prefs.edit().putLong("last_authentication", now).apply();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void authenticate(final FragmentActivity activity,
|
||||
|
||||
Reference in New Issue
Block a user