MCPcopy Create free account
hub / github.com/M66B/FairEmail / shouldAuthenticate

Method shouldAuthenticate

app/src/main/java/eu/faircode/email/Helper.java:3371–3394  ·  view source on GitHub ↗
(Context context, boolean pausing)

Source from the content-addressed store, hash-verified

3369 }
3370
3371 static boolean shouldAuthenticate(Context context, boolean pausing) {
3372 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
3373 boolean biometrics = prefs.getBoolean("biometrics", false);
3374 String pin = prefs.getString("pin", null);
3375
3376 if (biometrics || !TextUtils.isEmpty(pin)) {
3377 long now = new Date().getTime();
3378 long last_authentication = prefs.getLong("last_authentication", 0);
3379 long biometrics_timeout = prefs.getInt("biometrics_timeout", 2) * 60 * 1000L;
3380 boolean autolock_nav = prefs.getBoolean("autolock_nav", false);
3381 Log.i("Authentication valid until=" + new Date(last_authentication + biometrics_timeout));
3382
3383 if (last_authentication + biometrics_timeout < now)
3384 return true;
3385
3386 if (autolock_nav && pausing)
3387 last_authentication = now - biometrics_timeout + 5 * 1000L;
3388 else
3389 last_authentication = now;
3390 prefs.edit().putLong("last_authentication", last_authentication).apply();
3391 }
3392
3393 return false;
3394 }
3395
3396 static boolean shouldAutoLock(Context context) {
3397 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

Callers 3

checkAuthenticationMethod · 0.95
onCreateMethod · 0.95
onDismissMethod · 0.95

Calls 7

iMethod · 0.95
getBooleanMethod · 0.80
getLongMethod · 0.80
getStringMethod · 0.45
isEmptyMethod · 0.45
getIntMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected