Authentication improvements/fixes

This commit is contained in:
M66B
2019-07-10 19:58:02 +02:00
parent 3bb6956bfe
commit e17f313956
2 changed files with 30 additions and 9 deletions

View File

@@ -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,