Skip to content

Commit

Permalink
Revert "Fix failing unit tests (#352)"
Browse files Browse the repository at this point in the history
This reverts commit d66cafc.
  • Loading branch information
oblador committed Jun 9, 2020
1 parent d235100 commit c251116
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.biometric.BiometricManager;

import static android.content.Context.FINGERPRINT_SERVICE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS;

Expand All @@ -26,45 +23,13 @@ public static boolean isBiometricAuthAvailable(@NonNull final Context context) {
}

public static boolean isFingerprintAuthAvailable(@NonNull final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return false;
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
// -----------------------------------------------------------------------------------------------
// WARNING: hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) cannot be reliably used on API23.
// -----------------------------------------------------------------------------------------------
return isFingerprintHardwareDetected_Api23_Workaround(context);
} else {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
}
}

/**
* On API23, hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) will return false on *some* devices,
* even though the fingerprint HW is present and usable.
*
* This Google Issue Tracker ticket https://issuetracker.google.com/issues/124066957 reported that this check was
* problematic and they had to remove it in the support lib:
*
* | mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) which can return false,
* | even if scanner exists and fingerprint is configured, and FingerprintManager can be used for authentication. ...
* | We need to update FingerprintManagerCompat which also checks PackageManager.
* | The flag exists on API23, but OEMs were not setting it properly. I believe we started enforcing this after 23.
*
* @deprecated TODO Remove this method once API23 support is phased out.
*/
@RequiresApi(Build.VERSION_CODES.M)
@Deprecated
private static boolean isFingerprintHardwareDetected_Api23_Workaround(@NonNull final Context context) {
final FingerprintManager manager = (FingerprintManager) context.getSystemService(FINGERPRINT_SERVICE);
return (manager != null) && manager.isHardwareDetected();
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
}

@TargetApi(Build.VERSION_CODES.Q)
public static boolean isFaceAuthAvailable(@NonNull final Context context) {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE);
}

@TargetApi(Build.VERSION_CODES.Q)
public static boolean isIrisAuthAvailable(@NonNull final Context context) {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IRIS);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public class KeychainModuleTest {
public class KeychainModuleTests {
public static final byte[] BYTES_USERNAME = "username".getBytes();
public static final byte[] BYTES_PASSWORD = "password".getBytes();
/**
Expand Down

0 comments on commit c251116

Please sign in to comment.