Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove legacy fingerprint #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applock/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 34
}
lintOptions {
Expand Down
2 changes: 2 additions & 0 deletions applock/src/main/java/com/bitcoin/applock/AppLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class AppLock {
public static final int ERROR_CODE_FINGERPRINTS_EMPTY = 3;
public static final int ERROR_CODE_FINGERPRINTS_NOT_LOCALLY_ENROLLED = 4;
public static final int ERROR_CODE_SDK_VERSION_MINIMUM = 5;
public static final int ERROR_CODE_SCREEN_LOCK_DISABLED = 6;

public Activity fragmentActivity;

public Dialog activeDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class BiometricsLockService extends LockService {
@Override
public boolean isEnrollmentEligible(Context context) {
KeyguardManager keyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return Build.VERSION.SDK_INT > 23 && keyguard.isDeviceSecure() && isBiometricCompatible(context);
return keyguard.isDeviceSecure() && isBiometricCompatible(context);
}

private boolean isBiometricCompatible(Context context) {
boolean isBiometricCompatible(Context context) {
BiometricManager biometricManager = BiometricManager.from(context);
switch (biometricManager.canAuthenticate(
BiometricManager.Authenticators.BIOMETRIC_WEAK |
Expand All @@ -38,6 +38,9 @@ private boolean isBiometricCompatible(Context context) {
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
case BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED:
case BiometricManager.BIOMETRIC_STATUS_UNKNOWN:
break;
}
return false;
Expand All @@ -61,9 +64,6 @@ public void authenticate(Context context, AuthenticationDelegate delegate) {

protected void authenticate(Context context, boolean localEnrollmentRequired, AuthenticationDelegate delegate) {

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
return;

showBiometricPrompt(context, delegate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.provider.Settings;
import android.view.View;
import android.widget.TextView;

Expand Down Expand Up @@ -43,7 +44,6 @@ public AppLockViewController(Activity activity, View parent) {
this.descriptionView = new WeakReference(parent.findViewById(R.id.pin__description));
this.actionSettings = new WeakReference<View>(parent.findViewById(R.id.pin__action_settings));
this.actionFallback = new WeakReference<View>(parent.findViewById(R.id.pin__action_fallback));

this.biometricsImageView = new WeakReference(parent.findViewById(R.id.pin__biometric_image));

this.pinInputView = new WeakReference(parent.findViewById(R.id.pin__input_view));
Expand Down Expand Up @@ -171,11 +171,12 @@ protected int getDescriptionResIdForError(int errorCode) {
*/
public Intent getSettingsIntent(int errorCode) {
switch (errorCode) {
case AppLock.ERROR_CODE_SCREEN_LOCK_DISABLED:
case AppLock.ERROR_CODE_FINGERPRINTS_PERMISSION_REQUIRED:
// TODO: App settings?
case AppLock.ERROR_CODE_FINGERPRINTS_EMPTY:
case AppLock.ERROR_CODE_FINGERPRINTS_MISSING_HARDWARE:
return new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS);
return new Intent(Settings.ACTION_SECURITY_SETTINGS);
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.bitcoin.applock.views;

import static androidx.core.content.ContextCompat.startActivity;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.view.View;

import androidx.biometric.BiometricPrompt;
Expand Down Expand Up @@ -57,16 +60,7 @@ public void setupRootFlow() {
return;
}


FingerprintLockService fingerprintService = AppLock.getInstance(activity)
.getLockService(FingerprintLockService.class);

if (!fingerprintService.isEnrollmentEligible(activity)) {
setupPINCreation();

return;
}

// setupPINCreation();
setupCreationChooser();
}

Expand All @@ -75,19 +69,23 @@ protected void setupCreationChooser() {

hide(fingerprintAuthImageView);
hide(pinInputView);
hide(actionSettings);
hide(actionFallback);
hide(biometricsImageView);
hide(chooserParent);

show(chooserParent);

setDescription(R.string.applock__description_chooser);
setDescription(R.string.applock__enable_screen_lock);

View parent = this.parent.get();
final View parent = this.parent.get();

if (parent == null)
return;

parent.findViewById(R.id.pin__action_settings).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
handleActionSettingsClicked(AppLock.ERROR_CODE_SCREEN_LOCK_DISABLED);
}
});

parent.findViewById(R.id.pin__create_option_pin)
.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Expand All @@ -104,7 +102,7 @@ public void onClick(View view) {
}

protected void setupBiometricCreation() {
this.displayVariant = DisplayVariant.PIN_CREATION;
this.displayVariant = DisplayVariant.BIOMETRICS_AUTHENTICATION;

hide(fingerprintAuthImageView);
hide(chooserParent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.view.View;

import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -41,20 +43,14 @@ public void setupRootFlow() {
BiometricsLockService biometricsLockService = AppLock.getInstance(parent.getContext())
.getLockService(BiometricsLockService.class);

if (biometricsLockService.isEnrolled(parent.getContext())) {
if (biometricsLockService.isEnrolled(parent.getContext()) || biometricsLockService.isEnrollmentEligible(parent.getContext())) {
setupBiometricUnlock();
return;
}


FingerprintLockService fingerprintService = AppLock.getInstance(parent.getContext())
.getLockService(FingerprintLockService.class);

if (biometricsLockService.isEnrollmentEligible(parent.getContext())){
setupBiometricUnlock();
return;
}

if (fingerprintService.isEnrolled(parent.getContext())) {
setupFingerprintUnlock();
} else {
Expand Down Expand Up @@ -97,7 +93,6 @@ protected void attemptPINUnlock(String input) {
AppLock.getInstance(activity)
.attemptPINUnlock(input, this);
}

protected void setupBiometricUnlock() {
this.displayVariant = DisplayVariant.BIOMETRIC_AUTHENTICATION;
setDescription(R.string.applock__description_biometric);
Expand All @@ -122,20 +117,28 @@ protected void setupFingerprintUnlock() {
View actionFallback = this.actionFallback.get();

hide(pinInputView);
hide(actionSettings);
hide(biometricsImageView);
show(fingerprintAuthImageView);
show(actionSettings);
hide(this.actionFallback);
show(biometricsImageView);
hide(fingerprintAuthImageView);


parent.get().findViewById(R.id.pin__action_settings).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
handleActionSettingsClicked(AppLock.ERROR_CODE_SCREEN_LOCK_DISABLED);
}
});

actionFallback.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setupPINUnlock();
}
});


setDescription(R.string.applock__description_unlock_fingerprint);

setDescription(R.string.applock__fingerprint_depreciated);
if (autoAuthorizationEnabled)
attemptFingerprintAuthentication();
attemptBiometricAuthentication();
}

protected void attemptFingerprintAuthentication() {
Expand Down Expand Up @@ -218,25 +221,6 @@ public void onActivityPaused() {
setDescription(R.string.applock__description_create_fingerprint_paused);
}

@Override
public void onActivityResumed() {
Activity activity = this.activity.get();

if (activity == null || displayVariant != DisplayVariant.FINGERPRINT_AUTHENTICATION)
return;

if (ContextCompat.checkSelfPermission(activity, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
setDescription(R.string.applock__fingerprint_error_permission_multiple);
updateActionSettings(AppLock.ERROR_CODE_FINGERPRINTS_PERMISSION_REQUIRED);
return;
}

setDescription(R.string.applock__description_unlock_fingerprint);
hide(actionSettings);

attemptFingerprintAuthentication();
}

@Override
protected void handleActionSettingsClicked(int errorCode) {
Activity activity = this.activity.get();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added applock/src/main/res/font/sf_pro_text_medium.otf
Binary file not shown.
Binary file added applock/src/main/res/font/sf_pro_text_regular.otf
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion applock/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>

<dimen name="applock__action_settings">14dip</dimen>
<dimen name="applock__action_settings">16dip</dimen>
<dimen name="applock__action_settings_margin_top">24dip</dimen>
<dimen name="applock__action_settings_padding">12dip</dimen>
<dimen name="applock__activity_padding">24dip</dimen>
Expand Down
2 changes: 2 additions & 0 deletions applock/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<string name="applock__unlock_error_retry_limit_exceeded">You failed too many times. You may try again in %1$s.
</string>

<string name="applock__enable_screen_lock">To secure your wallet, please enable Screen Lock on your device</string>
<string name="applock__fingerprint_depreciated">Legacy Fingerprint authentication is no longer supported, please enable Screen Lock to continue</string>

<item name="applock__empty_item_min_size_percent" format="float" translatable="false" type="string">
0.2
Expand Down
2 changes: 2 additions & 0 deletions applock/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">@dimen/applock__action_settings_margin_top</item>
<item name="android:gravity">center</item>
<item name="fontFamily">@font/sf_pro_display_regular</item>
<item name="android:padding">@dimen/applock__action_settings_padding</item>
<item name="android:text">@string/applock__action_settings</item>
<item name="android:textColor">@color/applock__action_settings</item>
Expand All @@ -72,6 +73,7 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center</item>
<item name="fontFamily">@font/sf_pro_display_regular</item>
<item name="android:text">These is some kind of instructions you should follow.</item>
<item name="android:textColor">@color/applock__description_text</item>
<item name="android:textSize">@dimen/applock__description_text</item>
Expand Down