| 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); |