mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Update last authentication on user interaction
This commit is contained in:
parent
cab37caac9
commit
9d01825146
2 changed files with 17 additions and 2 deletions
|
@ -140,11 +140,26 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUserInteraction() {
|
||||||
|
Log.i("User interaction");
|
||||||
|
|
||||||
|
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this)) {
|
||||||
|
finish();
|
||||||
|
startActivity(new Intent(this, ActivityMain.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onUserLeaveHint() {
|
||||||
|
Log.i("User leaving");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
|
|
||||||
|
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
if (pm != null && !pm.isInteractive()) {
|
if (pm != null && !pm.isInteractive()) {
|
||||||
Log.i("Stop with screen off");
|
Log.i("Stop with screen off");
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
|
@ -697,11 +697,11 @@ public class Helper {
|
||||||
static boolean shouldAuthenticate(Context context) {
|
static boolean shouldAuthenticate(Context context) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||||
long biometrics_timeout = prefs.getInt("biometrics_timeout", 2) * 60 * 1000L;
|
|
||||||
|
|
||||||
if (biometrics) {
|
if (biometrics) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long last_authentication = prefs.getLong("last_authentication", 0);
|
long last_authentication = prefs.getLong("last_authentication", 0);
|
||||||
|
long biometrics_timeout = prefs.getInt("biometrics_timeout", 2) * 60 * 1000L;
|
||||||
Log.i("Authentication valid until=" + new Date(last_authentication + biometrics_timeout));
|
Log.i("Authentication valid until=" + new Date(last_authentication + biometrics_timeout));
|
||||||
|
|
||||||
if (last_authentication + biometrics_timeout < now)
|
if (last_authentication + biometrics_timeout < now)
|
||||||
|
|
Loading…
Reference in a new issue