|
|
|
@ -129,6 +129,7 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
|
|
|
|
|
// only show the biometric prompt if the api version is new enough, permission is granted, a scanner is found and a biometric slot is found
|
|
|
|
|
_slots = _vaultFile.getHeader().getSlots();
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
if (_slots.has(BiometricSlot.class) && BiometricsHelper.isAvailable(this)) {
|
|
|
|
|
boolean invalidated = false;
|
|
|
|
|
|
|
|
|
@ -163,6 +164,7 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
biometricsButton.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_decryptButton.setOnClickListener(v -> {
|
|
|
|
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
@ -177,12 +179,13 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
_decryptButton.setEnabled(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
biometricsButton.setOnClickListener(v -> {
|
|
|
|
|
if (_prefs.isPasswordReminderNeeded()) {
|
|
|
|
|
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this, R.style.ThemeOverlay_Aegis_AlertDialog_Warning)
|
|
|
|
|
.setTitle(getString(R.string.password_reminder_dialog_title))
|
|
|
|
|
.setMessage(getString(R.string.password_reminder_dialog_message))
|
|
|
|
|
.setCancelable(false)
|
|
|
|
|
.setCancelable(false))
|
|
|
|
|
.setIconAttribute(android.R.attr.alertDialogIcon)
|
|
|
|
|
.setPositiveButton(android.R.string.ok, (dialog1, which) -> {
|
|
|
|
|
showBiometricPrompt();
|
|
|
|
@ -193,6 +196,7 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
|
|
|
@ -216,29 +220,35 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
focusPasswordField();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
if (_bioKey != null && _bioPrompt == null && !_inhibitBioPrompt && !remindPassword) {
|
|
|
|
|
_bioPrompt = showBiometricPrompt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_inhibitBioPrompt = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPause() {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
if (!isChangingConfigurations() && _bioPrompt != null) {
|
|
|
|
|
_bioPrompt.cancelAuthentication();
|
|
|
|
|
_bioPrompt = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.onPause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttachedToWindow() {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
if (_bioKey != null && _prefs.isPasswordReminderNeeded()) {
|
|
|
|
|
showPasswordReminder();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void focusPasswordField() {
|
|
|
|
|
_textPassword.requestFocus();
|
|
|
|
@ -268,7 +278,8 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BiometricPrompt showBiometricPrompt() {
|
|
|
|
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
imm.hideSoftInputFromWindow(_textPassword.getWindowToken(), 0);
|
|
|
|
|
|
|
|
|
|
Cipher cipher;
|
|
|
|
@ -291,6 +302,8 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
prompt.authenticate(info, cryptoObj);
|
|
|
|
|
return prompt;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void finish(MasterKey key, boolean isSlotRepaired) {
|
|
|
|
|
VaultFileCredentials creds = new VaultFileCredentials(key, _slots);
|
|
|
|
@ -366,6 +379,7 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
private class BiometricPromptListener extends BiometricPrompt.AuthenticationCallback {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
super.onAuthenticationError(errorCode, errString);
|
|
|
|
|
_bioPrompt = null;
|
|
|
|
|
|
|
|
|
@ -374,9 +388,11 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
Toast.makeText(AuthActivity.this, errString, Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
super.onAuthenticationSucceeded(result);
|
|
|
|
|
_bioPrompt = null;
|
|
|
|
|
|
|
|
|
@ -393,10 +409,13 @@ public class AuthActivity extends AegisActivity {
|
|
|
|
|
|
|
|
|
|
finish(key, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAuthenticationFailed() {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
|
super.onAuthenticationFailed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|