本文整理匯總了Java中android.hardware.fingerprint.FingerprintManager類的典型用法代碼示例。如果您正苦於以下問題:Java FingerprintManager類的具體用法?Java FingerprintManager怎麽用?Java FingerprintManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FingerprintManager類屬於android.hardware.fingerprint包,在下文中一共展示了FingerprintManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkFingerPrintAvailability
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
/**
* Check if the finger print hardware is available.
*
* @param context instance of the caller.
* @return true if finger print authentication is supported.
*/
@SuppressWarnings("MissingPermission")
private boolean checkFingerPrintAvailability(@NonNull Context context) {
// Check if we're running on Android 6.0 (M) or higher
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//Fingerprint API only available on from Android 6.0 (M)
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
return false;
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
return false;
}
return true;
} else {
return false;
}
}
示例2: isAvailable
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public static boolean isAvailable(Context context){
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if(fingerprintManager!=null){
return (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints());
}
return false;
}
示例3: startFingerprintAuth
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
private void startFingerprintAuth() throws GeneralSecurityException, IOException {
Signature signature = Signature.getInstance("SHA256withECDSA");
PrivateKey privateKey = fidoKeystore.getKeyPair(Preferences.getSettingsParam("username")).getPrivate();
signature.initSign(privateKey);
FingerprintAuthenticationDialogFragment fragment
= new FingerprintAuthenticationDialogFragment();
FingerprintManager.CryptoObject cryptoObj = new FingerprintManager.CryptoObject(signature);
fragment.setCryptoObject(cryptoObj);
fragment.setStage(
FingerprintAuthenticationDialogFragment.Stage.FINGERPRINT);
Log.d(TAG, "Showing fragment: " + fragment);
fragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
示例4: isHardwarePresent
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public boolean isHardwarePresent() {
final FingerprintManager fingerprintManager = fingerprintManager();
if (fingerprintManager == null) return false;
// Normally, a security exception is only thrown if you don't have the USE_FINGERPRINT
// permission in your manifest. However, some OEMs have pushed updates to M for phones
// that don't have sensors at all, and for some reason decided not to implement the
// USE_FINGERPRINT permission. So on those devices, a SecurityException is raised no matter
// what. This has been confirmed on a number of devices, including the LG LS770, LS991,
// and the HTC One M8.
//
// On Robolectric, FingerprintManager.isHardwareDetected raises an NPE.
try {
return fingerprintManager.isHardwareDetected();
} catch (SecurityException | NullPointerException e) {
logger.logException(e, "MarshmallowReprintModule: isHardwareDetected failed unexpectedly");
return false;
}
}
示例5: onAuthenticationSucceeded
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
/**
* Called by {@link FingerprintManager} if the authentication succeeded.
*/
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
mIcon.setImageResource(R.drawable.ic_fingerprint_success);
mErrorTextView.setTextColor(
mErrorTextView.getResources().getColor(R.color.success_color, null));
mErrorTextView.setText(
mErrorTextView.getResources().getString(R.string.pin_code_fingerprint_success));
mIcon.postDelayed(new Runnable() {
@Override
public void run() {
mCallback.onAuthenticated();
}
}, SUCCESS_DELAY_MILLIS);
}
示例6: startAuth
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public void startAuth(FingerprintManager manager,
FingerprintManager.CryptoObject cryptoObject) {
cancellationSignal = new CancellationSignal();
if (ActivityCompat.checkSelfPermission(context,
Manifest.permission.USE_FINGERPRINT) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
示例7: checkSensorState
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public static SensorState checkSensorState(Context context) {
if (checkFingerprintCompatibility(context)) {
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if (!keyguardManager.isKeyguardSecure()) {
return SensorState.NOT_BLOCKED;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || !((FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
return SensorState.NO_FINGERPRINTS;
}
return SensorState.READY;
} else {
return SensorState.NOT_SUPPORTED;
}
}
示例8: onAuthenticationSucceeded
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthenticationSucceeded(
FingerprintManager.AuthenticationResult result) {
String pwd = WCFPXSharedPreferencesUtil.getPwd(mContext);
//TODO 這裏邏輯有待修改
if (pwd != null && pwd.length() > 0) {
if (mEditText != null) {
mEditText.setText(pwd);
}
else {
showToast("Error: mEditText null");
}
} else {
showToast("Sorry, but you have not set the password in WeChatFingerprintPay yet");
}
}
示例9: initFingerPrint
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
private void initFingerPrint(Context context) {
KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
Toast.makeText(context, "Your device doesn't support fingerprint authentication", Toast.LENGTH_LONG).show();
} else if (context.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(context, "Please enable the fingerprint permission", Toast.LENGTH_LONG).show();
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
Toast.makeText(
context,
"No fingerprint configured. Please register at least one fingerprint in your device's Settings",
Toast.LENGTH_LONG).show();
} else if (!keyguardManager.isKeyguardSecure()) {
Toast.makeText(
context,
"Please enable lock screen security in your device's Settings",
Toast.LENGTH_LONG).show();
} else {
fHandler = new FingerprintHandler(context);
}
}
示例10: onAuthenticationSucceeded
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
fingerprintResult = result;
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
int ic_fingerprint_success_id = mContext.getResources()
.getIdentifier("ic_fingerprint_success", "drawable", FingerprintAuth.packageName);
mIcon.setImageResource(ic_fingerprint_success_id);
int success_color_id = mContext.getResources()
.getIdentifier("success_color", "color", FingerprintAuth.packageName);
mErrorTextView.setTextColor(
mErrorTextView.getResources().getColor(success_color_id, null));
int fingerprint_success_id = mContext.getResources()
.getIdentifier("fingerprint_success", "string", FingerprintAuth.packageName);
mErrorTextView.setText(
mErrorTextView.getResources().getString(fingerprint_success_id));
mIcon.postDelayed(new Runnable() {
@Override
public void run() {
mCallback.onAuthenticated(fingerprintResult);
}
}, SUCCESS_DELAY_MILLIS);
}
示例11: onAuthentication
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthentication(int helpOrErrorCode, CharSequence infoString, FingerprintManager.AuthenticationResult authenticationResult, int authCode) {
switch (authCode) {
case ResponseCode.AUTH_ERROR:
// Show appropriate message
break;
case ResponseCode.AUTH_FAILED:
// Show appropriate message
showToast("Authentication Failed");
break;
case ResponseCode.AUTH_HELP:
// Show appropriate message
break;
case ResponseCode.AUTH_SUCCESS:
// Do whatever you want
showToast("Authentication Success");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
fingerprintResultsHandler.restartListening(fingerPrintHelper.getFingerprintManager(), fingerPrintHelper.getCryptoObject());
}
break;
}
}
示例12: isSensorAvailable
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@ReactMethod
public void isSensorAvailable(final Promise promise) {
response = Arguments.createMap();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(mReactContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
sendResponse("failed", "You haven't allow this app to use your fingerprint sensor", promise);
return;
}
if (mReactContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) ||
((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).isHardwareDetected()) {
if (((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
sendResponse("ok", null, promise);
} else {
sendResponse("failed", "You have fingerprint sensor, but you should set it enabled in your settings to use with this app", promise);
}
} else {
sendResponse("failed", "You don\'t have appropriate hardware", promise);
}
} else {
sendResponse("failed", "You don\'t have appropriate hardware", promise);
}
}
示例13: setupFingerprintStuff
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
public void setupFingerprintStuff() {
fingerprintManager = (FingerprintManager) this.getSystemService(Context.FINGERPRINT_SERVICE);
fingerprintHelper = new FingerprintHelper(this);
try {
generateKey();
if (cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(cipher);
fingerprintHelper.startAuth(fingerprintManager, cryptoObject);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例14: startAuth
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public void startAuth(FingerprintManager manager,
FingerprintManager.CryptoObject cryptoObject) {
cancellationSignal = new CancellationSignal();
if (ActivityCompat.checkSelfPermission(appContext,
Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(appContext,
appContext.getString(R.string.fingerprint_error_no_permission),
Toast.LENGTH_LONG).show();
return;
}
manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
示例15: inicializarSeguranca
import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
private void inicializarSeguranca() {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
getString(R.string.fingerprint_error_no_permission),
Toast.LENGTH_LONG).show();
return;
}
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
keystoreManager = new AndroidKeystoreManager(KEY_NAME);
keystoreManager.generateKey();
if (keystoreManager.cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(keystoreManager.getCipher());
}
}