Configurable biometric grace time

pull/214/head
M66B 5 months ago
parent ab0c6481a2
commit 05725ade65

@ -81,10 +81,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swDisableTracking;
private Button btnPin;
private Button btnBiometrics;
private Spinner spBiometricsTimeout;
private SwitchCompat swAutoLock;
private SwitchCompat swAutoLockNav;
private TextView tvAutoLockNavHint;
private Spinner spBiometricsTimeout;
private SwitchCompat swClientId;
private TextView tvClientId;
private ImageButton ibClientId;
@ -156,10 +155,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisableTracking = view.findViewById(R.id.swDisableTracking);
btnPin = view.findViewById(R.id.btnPin);
btnBiometrics = view.findViewById(R.id.btnBiometrics);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swAutoLock = view.findViewById(R.id.swAutoLock);
swAutoLockNav = view.findViewById(R.id.swAutoLockNav);
tvAutoLockNavHint = view.findViewById(R.id.tvAutoLockNavHint);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swClientId = view.findViewById(R.id.swClientId);
tvClientId = view.findViewById(R.id.tvClientId);
ibClientId = view.findViewById(R.id.ibClientId);
@ -394,19 +392,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.biometricsTimeoutValues);
prefs.edit().putInt("biometrics_timeout", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("biometrics_timeout").apply();
}
});
swAutoLock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -421,7 +406,18 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
tvAutoLockNavHint.setText(getString(R.string.title_advanced_display_autolock_nav_hint, Helper.AUTH_AUTOLOCK_GRACE));
spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.biometricsTimeoutValues);
prefs.edit().putInt("biometrics_timeout", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("biometrics_timeout").apply();
}
});
swClientId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -711,6 +707,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
: R.string.title_setup_biometrics_enable);
btnBiometrics.setEnabled(Helper.canAuthenticate(getContext()));
swAutoLock.setChecked(prefs.getBoolean("autolock", true));
swAutoLockNav.setChecked(prefs.getBoolean("autolock_nav", false));
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
for (int pos = 0; pos < biometricTimeoutValues.length; pos++)
@ -719,9 +718,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
break;
}
swAutoLock.setChecked(prefs.getBoolean("autolock", true));
swAutoLockNav.setChecked(prefs.getBoolean("autolock_nav", false));
swClientId.setChecked(prefs.getBoolean("client_id", true));
swHideTimeZone.setChecked(prefs.getBoolean("hide_timezone", false));
swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));

@ -196,7 +196,6 @@ public class Helper {
static final int BUFFER_SIZE = 8192; // Same as in Files class
static final long MIN_REQUIRED_SPACE = 100 * 1000L * 1000L;
static final long AUTH_AUTOCANCEL_TIMEOUT = 60 * 1000L; // milliseconds
static final int AUTH_AUTOLOCK_GRACE = 15; // seconds
static final int PIN_FAILURE_DELAY = 3; // seconds
static final long PIN_FAILURE_DELAY_MAX = 20 * 60 * 1000L; // milliseconds
static final float BNV_LUMINANCE_THRESHOLD = 0.7f;
@ -3095,7 +3094,7 @@ public class Helper {
return true;
if (autolock_nav && pausing)
last_authentication = now - biometrics_timeout + AUTH_AUTOLOCK_GRACE * 1000L;
last_authentication = now - biometrics_timeout + biometrics_timeout;
else
last_authentication = now;
prefs.edit().putLong("last_authentication", last_authentication).apply();

@ -357,30 +357,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnPin" />
<TextView
android:id="@+id/tvBiometricsTimeout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_biometrics_timeout"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPinHint" />
<Spinner
android:id="@+id/spBiometricsTimeout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoLock"
android:layout_width="0dp"
@ -391,7 +367,7 @@
android:text="@string/title_advanced_autolock"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spBiometricsTimeout"
app:layout_constraintTop_toBottomOf="@+id/tvPinHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
@ -408,18 +384,28 @@
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvAutoLockNavHint"
android:id="@+id/tvBiometricsTimeout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_display_autolock_nav_hint"
android:text="@string/title_advanced_biometrics_timeout"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoLockNav" />
<Spinner
android:id="@+id/spBiometricsTimeout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

@ -1076,7 +1076,6 @@
<string name="title_advanced_display_harmful_hint">Disabling this option might be harmful to your privacy</string>
<string name="title_advanced_display_hidden_hint">This can result in odd looking and double texts</string>
<string name="title_advanced_display_pin_hint">A PIN takes precedence over biometrics authentication</string>
<string name="title_advanced_display_autolock_nav_hint">There will be a grace time of %1$d seconds</string>
<string name="title_advanced_user_agent_hint">Some servers do not accept a generic user agent string</string>
<string name="title_advanced_safe_browsing_hint">The Google server knows which addresses are being looked up</string>

Loading…
Cancel
Save