本文整理匯總了Java中android.hardware.fingerprint.FingerprintManager.isHardwareDetected方法的典型用法代碼示例。如果您正苦於以下問題:Java FingerprintManager.isHardwareDetected方法的具體用法?Java FingerprintManager.isHardwareDetected怎麽用?Java FingerprintManager.isHardwareDetected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.fingerprint.FingerprintManager
的用法示例。
在下文中一共展示了FingerprintManager.isHardwareDetected方法的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: 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;
}
}
示例3: 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;
}
示例4: 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);
}
}
示例5: initFingerprintManager
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private void initFingerprintManager() throws Throwable {
mFpManager = (FingerprintManager) mContext.getSystemService(Context.FINGERPRINT_SERVICE);
if (!mFpManager.isHardwareDetected())
throw new IllegalStateException("Fingerprint hardware not present");
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
KeyGenerator keyGenerator = KeyGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
keyStore.load(null);
keyGenerator.init(new KeyGenParameterSpec.Builder(
KEY_NAME, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
keyGenerator.generateKey();
Cipher cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/" +
KeyProperties.BLOCK_MODE_CBC + "/" +
KeyProperties.ENCRYPTION_PADDING_PKCS7);
SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null);
cipher.init(Cipher.ENCRYPT_MODE, key);
mFpHandler = new FingerprintHandler(cipher);
if (DEBUG) log("Fingeprint manager initialized");
}
示例6: scanFingerprint
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private boolean scanFingerprint() throws CertificateException, NoSuchAlgorithmException,
IOException, UnrecoverableKeyException, KeyStoreException, InvalidKeyException,
InvalidAlgorithmParameterException, NoSuchPaddingException {
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
//noinspection ResourceType
if (fingerprintManager.isHardwareDetected()) {
Cipher cipher = getCipherInstance();
IvParameterSpec ivSpec = new IvParameterSpec(mIvData);
SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null);
cipher.init(Cipher.DECRYPT_MODE, key, ivSpec);
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
//noinspection ResourceType
fingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0x0, mAuthenticationCallback, mHandler);
return true;
} else {
return false;
}
}
示例7: initLayoutForFingerprint
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* Init {@link FingerprintManager} of the {@link Build.VERSION#SDK_INT} is > to Marshmallow
* and {@link FingerprintManager#isHardwareDetected()}.
*/
private void initLayoutForFingerprint() {
mFingerprintImageView = (ImageView) this.findViewById(R.id.pin_code_fingerprint_imageview);
mFingerprintTextView = (TextView) this.findViewById(R.id.pin_code_fingerprint_textview);
if (mType == AppLock.UNLOCK_PIN && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mFingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
mFingerprintUiHelper = new FingerprintUiHelper.FingerprintUiHelperBuilder(mFingerprintManager).build(mFingerprintImageView, mFingerprintTextView, this);
try {
if (mFingerprintManager.isHardwareDetected() && mFingerprintUiHelper.isFingerprintAuthAvailable()
&& mLockManager.getAppLock().isFingerprintAuthEnabled()) {
mFingerprintImageView.setVisibility(View.VISIBLE);
mFingerprintTextView.setVisibility(View.VISIBLE);
mFingerprintUiHelper.startListening();
} else {
mFingerprintImageView.setVisibility(View.GONE);
mFingerprintTextView.setVisibility(View.GONE);
}
} catch (SecurityException e) {
Log.e(TAG, e.toString());
mFingerprintImageView.setVisibility(View.GONE);
mFingerprintTextView.setVisibility(View.GONE);
}
} else {
mFingerprintImageView.setVisibility(View.GONE);
mFingerprintTextView.setVisibility(View.GONE);
}
}
示例8: checkFingerprintCompatibility
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean checkFingerprintCompatibility(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (manager != null) {
return manager.isHardwareDetected();
}
}
/*if (manager.isHardwareDetected()) {
//code here
}
return FingerprintManagerCompat.from(context).isHardwareDetected();*/
return false;
}
示例9: isSupportedHardware
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* Check if the device have supported hardware fir the finger print scanner.
*
* @param context instance of the caller.
* @return true if device have the hardware.
*/
@SuppressWarnings("MissingPermission")
@RequiresApi(api = Build.VERSION_CODES.M)
@RequiresPermission(allOf = {Manifest.permission.USE_FINGERPRINT})
public static boolean isSupportedHardware(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
return fingerprintManager.isHardwareDetected();
}
示例10: isFingerPrintEnrolled
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* Check if the device has any fingerprint registered?
* <p>
* If no fingerprint registered, use {@link #openSecuritySettings(Context)} to open security settings.
*
* @param context instance
* @return true if any fingerprint is register.
*/
@SuppressWarnings({"MissingPermission", "WeakerAccess"})
public static boolean isFingerPrintEnrolled(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);
return !(!fingerprintManager.isHardwareDetected() || !fingerprintManager.hasEnrolledFingerprints());
} else {
return false;
}
}
示例11: hasDeviceFingerprintSupport
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean hasDeviceFingerprintSupport(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return false;
}
return fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints();
} else {
return false;
}
}
示例12: supportsFingerprint
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean supportsFingerprint(Context ctx) {
try {
FingerprintManager fpm = (FingerprintManager) ctx.getSystemService(Context.FINGERPRINT_SERVICE);
return (fpm != null && fpm.isHardwareDetected());
} catch (Throwable t) {
log("Error checkin for fingerprint support: " + t.getMessage());
return false;
}
}
示例13: checkFingerprintHardwareAndPermission
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@TargetApi(23)
public static boolean checkFingerprintHardwareAndPermission(Context context, FingerprintManager fingerprintManager){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED) {
if(fingerprintManager != null) {
if (fingerprintManager.isHardwareDetected()) {
return true;
}
}else{
return false;
}
}
}
return false;
}
示例14: isFingerAvailable
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* 判斷指紋是否可用, 1:有指紋模塊, 2:錄入了指紋
*/
public static boolean isFingerAvailable(Context context) {
if (Build.VERSION.SDK_INT < 23) {
return false;
}
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
KeyguardManager mKeyManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
//權限檢查
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
//判斷硬件是否支持指紋識別
if (!manager.isHardwareDetected()) {
return false;
}
//判斷 是否開啟鎖屏密碼
if (!mKeyManager.isKeyguardSecure()) {
return false;
}
//判斷是否有指紋錄入
if (!manager.hasEnrolledFingerprints()) {
return false;
}
return true;
}
示例15: isFingerprintReady
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean isFingerprintReady(Context context) {
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 (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
if (!fingerprintManager.isHardwareDetected()) {
return false;
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
return false;
} else {
return true;
}
} else {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.USE_FINGERPRINT)) {
System.out.println("asd");
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.USE_FINGERPRINT}, 0);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
}
return false;
}