authentication:passcodemanager: Cleaned up variable naming.

This commit is contained in:
ardevd 2018-05-02 14:19:36 +02:00
parent b8cde0fa86
commit 6fcfa840b7

View file

@ -38,28 +38,28 @@ import java.util.Set;
public class PassCodeManager {
private static final Set<Class> sExemptOfPasscodeActivites;
private static final Set<Class> exemptOfPasscodeActivities;
static {
sExemptOfPasscodeActivites = new HashSet<>();
sExemptOfPasscodeActivites.add(PassCodeActivity.class);
sExemptOfPasscodeActivites.add(FingerprintActivity.class);
exemptOfPasscodeActivities = new HashSet<>();
exemptOfPasscodeActivities.add(PassCodeActivity.class);
exemptOfPasscodeActivities.add(FingerprintActivity.class);
// other activities may be exempted, if needed
}
private static final int PASS_CODE_TIMEOUT = 1000;
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
private static PassCodeManager mPassCodeManagerInstance = null;
private static PassCodeManager passCodeManagerInstance = null;
private Long mTimestamp = 0l;
private int mVisibleActivitiesCounter = 0;
private Long timestamp = 0l;
private int visibleActivitiesCounter = 0;
public static PassCodeManager getPassCodeManager() {
if (mPassCodeManagerInstance == null) {
mPassCodeManagerInstance = new PassCodeManager();
if (passCodeManagerInstance == null) {
passCodeManagerInstance = new PassCodeManager();
}
return mPassCodeManagerInstance;
return passCodeManagerInstance;
}
protected PassCodeManager() {}
@ -73,7 +73,7 @@ public class PassCodeManager {
}
public void onActivityStarted(Activity activity) {
if (!sExemptOfPasscodeActivites.contains(activity.getClass()) && passCodeShouldBeRequested()) {
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested()) {
Intent i = new Intent(MainApp.getAppContext(), PassCodeActivity.class);
i.setAction(PassCodeActivity.ACTION_CHECK);
@ -81,7 +81,7 @@ public class PassCodeManager {
activity.startActivity(i);
}
if (!sExemptOfPasscodeActivites.contains(activity.getClass()) &&
if (!exemptOfPasscodeActivities.contains(activity.getClass()) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
fingerprintShouldBeRequested() && FingerprintActivity.isFingerprintReady(MainApp.getAppContext())) {
@ -91,12 +91,12 @@ public class PassCodeManager {
activity.startActivity(i);
}
mVisibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked
visibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked
}
public void onActivityStopped(Activity activity) {
if (mVisibleActivitiesCounter > 0) {
mVisibleActivitiesCounter--;
if (visibleActivitiesCounter > 0) {
visibleActivitiesCounter--;
}
setUnlockTimestamp();
PowerManager powerMgr = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
@ -106,11 +106,11 @@ public class PassCodeManager {
}
private void setUnlockTimestamp() {
mTimestamp = System.currentTimeMillis();
timestamp = System.currentTimeMillis();
}
private boolean passCodeShouldBeRequested() {
return (System.currentTimeMillis() - mTimestamp) > PASS_CODE_TIMEOUT && mVisibleActivitiesCounter <= 0 && passCodeIsEnabled();
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 && passCodeIsEnabled();
}
private boolean passCodeIsEnabled() {
@ -119,7 +119,7 @@ public class PassCodeManager {
}
private boolean fingerprintShouldBeRequested() {
return (System.currentTimeMillis() - mTimestamp) > PASS_CODE_TIMEOUT && mVisibleActivitiesCounter <= 0 && fingerprintIsEnabled();
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 && fingerprintIsEnabled();
}
private boolean fingerprintIsEnabled() {