mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 14:32:49 +00:00
Fix all linter errors
Well almost all, just ignore missing translation errors
This commit is contained in:
parent
85bdecc573
commit
79279630ba
9 changed files with 45 additions and 22 deletions
|
@ -11,9 +11,19 @@ android {
|
||||||
versionName "1.0-beta1"
|
versionName "1.0-beta1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError true
|
||||||
|
disable "MissingTranslation"
|
||||||
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.all {
|
unitTests.all {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
ignoreFailures false
|
||||||
|
testLogging {
|
||||||
|
events "passed", "skipped", "failed", "standardOut", "standardError"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.beemdevelopment.aegis;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.test.ApplicationTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
|
||||||
*/
|
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
|
||||||
public ApplicationTest() {
|
|
||||||
super(Application.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,13 +5,16 @@ import android.content.Context;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
public class FingerprintHelper {
|
public class FingerprintHelper {
|
||||||
private FingerprintHelper() {
|
private FingerprintHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
public static FingerprintManager getManager(Context context) {
|
public static FingerprintManager getManager(Context context) {
|
||||||
if (isSupported() && PermissionHelper.granted(context, Manifest.permission.USE_FINGERPRINT)) {
|
if (PermissionHelper.granted(context, Manifest.permission.USE_FINGERPRINT)) {
|
||||||
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
|
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
|
||||||
if (manager != null && manager.isHardwareDetected() && manager.hasEnrolledFingerprints()) {
|
if (manager != null && manager.isHardwareDetected() && manager.hasEnrolledFingerprints()) {
|
||||||
return manager;
|
return manager;
|
||||||
|
@ -20,6 +23,11 @@ public class FingerprintHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
|
public static boolean isAvailable(Context context) {
|
||||||
|
return getManager(context) != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSupported() {
|
public static boolean isSupported() {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beemdevelopment.aegis.ui;
|
package com.beemdevelopment.aegis.ui;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
@ -44,6 +45,7 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
|
||||||
private FingerprintManager.CryptoObject _fingerCryptoObj;
|
private FingerprintManager.CryptoObject _fingerCryptoObj;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_auth);
|
setContentView(R.layout.activity_auth);
|
||||||
|
@ -71,9 +73,10 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
|
||||||
_slots = (SlotList) intent.getSerializableExtra("slots");
|
_slots = (SlotList) intent.getSerializableExtra("slots");
|
||||||
|
|
||||||
// only show the fingerprint controls if the api version is new enough, permission is granted, a scanner is found and a fingerprint slot is found
|
// only show the fingerprint controls if the api version is new enough, permission is granted, a scanner is found and a fingerprint slot is found
|
||||||
FingerprintManager manager = FingerprintHelper.getManager(this);
|
if (_slots.has(FingerprintSlot.class) && FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(this)) {
|
||||||
if (manager != null && _slots.has(FingerprintSlot.class)) {
|
|
||||||
boolean invalidated = false;
|
boolean invalidated = false;
|
||||||
|
FingerprintManager manager = FingerprintHelper.getManager(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// find a fingerprint slot with an id that matches an alias in the keystore
|
// find a fingerprint slot with an id that matches an alias in the keystore
|
||||||
for (FingerprintSlot slot : _slots.findAll(FingerprintSlot.class)) {
|
for (FingerprintSlot slot : _slots.findAll(FingerprintSlot.class)) {
|
||||||
|
@ -148,6 +151,7 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
@ -157,6 +161,7 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
@ -166,6 +171,7 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public void onAuthenticated() {
|
public void onAuthenticated() {
|
||||||
trySlots(FingerprintSlot.class, _fingerCryptoObj.getCipher());
|
trySlots(FingerprintSlot.class, _fingerCryptoObj.getCipher());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -35,6 +36,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ public class Dialogs {
|
||||||
showSecureDialog(dialog);
|
showSecureDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
public static void showFingerprintDialog(Activity activity, Dialogs.SlotListener listener) {
|
public static void showFingerprintDialog(Activity activity, Dialogs.SlotListener listener) {
|
||||||
View view = activity.getLayoutInflater().inflate(R.layout.dialog_fingerprint, null);
|
View view = activity.getLayoutInflater().inflate(R.layout.dialog_fingerprint, null);
|
||||||
TextView textFingerprint = view.findViewById(R.id.text_fingerprint);
|
TextView textFingerprint = view.findViewById(R.id.text_fingerprint);
|
||||||
|
|
|
@ -284,7 +284,9 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
SlotList slots = creds.getSlots();
|
SlotList slots = creds.getSlots();
|
||||||
|
|
||||||
if (!slots.has(FingerprintSlot.class)) {
|
if (!slots.has(FingerprintSlot.class)) {
|
||||||
Dialogs.showFingerprintDialog(getActivity(), new RegisterFingerprintListener());
|
if (FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(getContext())) {
|
||||||
|
Dialogs.showFingerprintDialog(getActivity(), new RegisterFingerprintListener());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove the fingerprint slot
|
// remove the fingerprint slot
|
||||||
FingerprintSlot slot = slots.find(FingerprintSlot.class);
|
FingerprintSlot slot = slots.find(FingerprintSlot.class);
|
||||||
|
@ -669,8 +671,9 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
boolean multiPassword = slots.findAll(PasswordSlot.class).size() > 1;
|
boolean multiPassword = slots.findAll(PasswordSlot.class).size() > 1;
|
||||||
boolean multiFinger = slots.findAll(FingerprintSlot.class).size() > 1;
|
boolean multiFinger = slots.findAll(FingerprintSlot.class).size() > 1;
|
||||||
boolean showSlots = BuildConfig.DEBUG || multiPassword || multiFinger;
|
boolean showSlots = BuildConfig.DEBUG || multiPassword || multiFinger;
|
||||||
|
boolean canUseFinger = FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(getContext());
|
||||||
_setPasswordPreference.setEnabled(!multiPassword);
|
_setPasswordPreference.setEnabled(!multiPassword);
|
||||||
_fingerprintPreference.setEnabled(FingerprintHelper.getManager(getContext()) != null && !multiFinger);
|
_fingerprintPreference.setEnabled(canUseFinger && !multiFinger);
|
||||||
_fingerprintPreference.setChecked(slots.has(FingerprintSlot.class), true);
|
_fingerprintPreference.setChecked(slots.has(FingerprintSlot.class), true);
|
||||||
_slotsPreference.setVisible(showSlots);
|
_slotsPreference.setVisible(showSlots);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,7 +43,9 @@ public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Li
|
||||||
bar.setDisplayHomeAsUpEnabled(true);
|
bar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
findViewById(R.id.button_add_fingerprint).setOnClickListener(view -> {
|
findViewById(R.id.button_add_fingerprint).setOnClickListener(view -> {
|
||||||
Dialogs.showFingerprintDialog(this ,this);
|
if (FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(this)) {
|
||||||
|
Dialogs.showFingerprintDialog(this ,this);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
findViewById(R.id.button_add_password).setOnClickListener(view -> {
|
findViewById(R.id.button_add_password).setOnClickListener(view -> {
|
||||||
|
@ -71,7 +73,7 @@ public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Li
|
||||||
// only show the fingerprint option if we can get an instance of the fingerprint manager
|
// only show the fingerprint option if we can get an instance of the fingerprint manager
|
||||||
// and if none of the slots in the collection has a matching alias in the keystore
|
// and if none of the slots in the collection has a matching alias in the keystore
|
||||||
int visibility = View.VISIBLE;
|
int visibility = View.VISIBLE;
|
||||||
if (FingerprintHelper.getManager(this) != null) {
|
if (FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(this)) {
|
||||||
try {
|
try {
|
||||||
KeyStoreHandle keyStore = new KeyStoreHandle();
|
KeyStoreHandle keyStore = new KeyStoreHandle();
|
||||||
for (FingerprintSlot slot : _creds.getSlots().findAll(FingerprintSlot.class)) {
|
for (FingerprintSlot slot : _creds.getSlots().findAll(FingerprintSlot.class)) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beemdevelopment.aegis.ui.slides;
|
package com.beemdevelopment.aegis.ui.slides;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
@ -70,6 +71,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
|
||||||
return EditTextHelper.getEditTextChars(_textPassword);
|
return EditTextHelper.getEditTextChars(_textPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public Cipher getFingerCipher() {
|
public Cipher getFingerCipher() {
|
||||||
return _fingerCryptoObj.getCipher();
|
return _fingerCryptoObj.getCipher();
|
||||||
}
|
}
|
||||||
|
@ -83,6 +85,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public void onSlideSelected() {
|
public void onSlideSelected() {
|
||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
_cryptType = intent.getIntExtra("cryptType", CustomAuthenticationSlide.CRYPT_TYPE_INVALID);
|
_cryptType = intent.getIntExtra("cryptType", CustomAuthenticationSlide.CRYPT_TYPE_INVALID);
|
||||||
|
@ -124,6 +127,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public void onSlideDeselected() {
|
public void onSlideDeselected() {
|
||||||
if (_fingerHelper != null) {
|
if (_fingerHelper != null) {
|
||||||
_fingerAuthenticated = false;
|
_fingerAuthenticated = false;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beemdevelopment.aegis.ui.slides;
|
package com.beemdevelopment.aegis.ui.slides;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -34,8 +35,7 @@ public class CustomAuthenticationSlide extends Fragment implements ISlidePolicy,
|
||||||
onCheckedChanged(_buttonGroup, _buttonGroup.getCheckedRadioButtonId());
|
onCheckedChanged(_buttonGroup, _buttonGroup.getCheckedRadioButtonId());
|
||||||
|
|
||||||
// only enable the fingerprint option if the api version is new enough, permission is granted and a scanner is found
|
// only enable the fingerprint option if the api version is new enough, permission is granted and a scanner is found
|
||||||
FingerprintManager manager = FingerprintHelper.getManager(getContext());
|
if (FingerprintHelper.isSupported() && FingerprintHelper.isAvailable(getContext())) {
|
||||||
if (manager != null) {
|
|
||||||
RadioButton button = view.findViewById(R.id.rb_fingerprint);
|
RadioButton button = view.findViewById(R.id.rb_fingerprint);
|
||||||
TextView text = view.findViewById(R.id.text_rb_fingerprint);
|
TextView text = view.findViewById(R.id.text_rb_fingerprint);
|
||||||
button.setEnabled(true);
|
button.setEnabled(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue