本文整理汇总了Java中android.app.KeyguardManager.isKeyguardSecure方法的典型用法代码示例。如果您正苦于以下问题:Java KeyguardManager.isKeyguardSecure方法的具体用法?Java KeyguardManager.isKeyguardSecure怎么用?Java KeyguardManager.isKeyguardSecure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.KeyguardManager
的用法示例。
在下文中一共展示了KeyguardManager.isKeyguardSecure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requireAuthentication
import android.app.KeyguardManager; //导入方法依赖的package包/类
/**
* Require the user to authenticate using the configured LockScreen before accessing the credentials.
* This feature is disabled by default and will only work if the device is running on Android version 21 or up and if the user
* has configured a secure LockScreen (PIN, Pattern, Password or Fingerprint).
* <p>
* The activity passed as first argument here must override the {@link Activity#onActivityResult(int, int, Intent)} method and
* call {@link SecureCredentialsManager#checkAuthenticationResult(int, int)} with the received parameters.
*
* @param activity a valid activity context. Will be used in the authentication request to launch a LockScreen intent.
* @param requestCode the request code to use in the authentication request. Must be a value between 1 and 255.
* @param title the text to use as title in the authentication screen. Passing null will result in using the OS's default value.
* @param description the text to use as description in the authentication screen. On some Android versions it might not be shown. Passing null will result in using the OS's default value.
* @return whether this device supports requiring authentication or not. This result can be ignored safely.
*/
public boolean requireAuthentication(@NonNull Activity activity, @IntRange(from = 1, to = 255) int requestCode, @Nullable String title, @Nullable String description) {
if (requestCode < 1 || requestCode > 255) {
throw new IllegalArgumentException("Request code must a value between 1 and 255.");
}
KeyguardManager kManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
this.authIntent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? kManager.createConfirmDeviceCredentialIntent(title, description) : null;
this.authenticateBeforeDecrypt = ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && kManager.isDeviceSecure())
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && kManager.isKeyguardSecure()))
&& authIntent != null;
if (authenticateBeforeDecrypt) {
this.activity = activity;
this.authenticationRequestCode = requestCode;
}
return authenticateBeforeDecrypt;
}
示例2: checkSensorState
import android.app.KeyguardManager; //导入方法依赖的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;
}
}
示例3: initFingerPrint
import android.app.KeyguardManager; //导入方法依赖的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);
}
}
示例4: onCreate
import android.app.KeyguardManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
Button purchaseButton = (Button) findViewById(R.id.purchase_button);
if (!mKeyguardManager.isKeyguardSecure()) {
// Show a message that the user hasn't set up a lock screen.
Toast.makeText(this,
"Secure lock screen hasn't set up.\n"
+ "Go to 'Settings -> Security -> Screenlock' to set up a lock screen",
Toast.LENGTH_LONG).show();
purchaseButton.setEnabled(false);
return;
}
createKey();
findViewById(R.id.purchase_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Test to encrypt something. It might fail if the timeout expired (30s).
tryEncrypt();
}
});
}
示例5: showAuthScreen
import android.app.KeyguardManager; //导入方法依赖的package包/类
void showAuthScreen() {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(
Context.KEYGUARD_SERVICE);
if (!keyguardManager.isKeyguardSecure()) {
basicConfigFragment.unlockAppIDandSecret();
return;
}
Intent intent = keyguardManager
.createConfirmDeviceCredentialIntent(getString(R.string.unlock_auth_title),
getString(R.string.unlock_auth_explain));
if (intent != null) {
startActivityForResult(intent, 1);
}
}
示例6: isFingerAvailable
import android.app.KeyguardManager; //导入方法依赖的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;
}
示例7: isStandardKeyguardState
import android.app.KeyguardManager; //导入方法依赖的package包/类
public boolean isStandardKeyguardState() {
boolean isStandardKeyguqrd = false;
KeyguardManager keyManager =(KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
if (null != keyManager) {
isStandardKeyguqrd = keyManager.isKeyguardSecure();
}
return isStandardKeyguqrd;
}
示例8: isLockScreenDisabled
import android.app.KeyguardManager; //导入方法依赖的package包/类
private boolean isLockScreenDisabled() {
KeyguardManager km = (KeyguardManager) this.reactContext.getSystemService(Context.KEYGUARD_SERVICE);
if (km.isKeyguardSecure())
return true;
else
return false;
}
示例9: authenticateUser
import android.app.KeyguardManager; //导入方法依赖的package包/类
@ReactMethod
public void authenticateUser(String userName, String passWord, Callback errorCallback,
Callback successCallback) {
activityContext = getCurrentActivity();
this.successCallback = successCallback;
this.errorCallback = errorCallback;
String errorMessage = null;
//Check if device is not Rooted
if (RootUtil.isDeviceRooted()) {
fingerprintManager = FingerprintManagerCompat.from(AppContext);
keyguardManager = (KeyguardManager) AppContext.getSystemService(Context.KEYGUARD_SERVICE);
//keyguardManager = AppContext.getSystemService(KeyguardManager.class);
// fingerprintManager = AppContext.getSystemService(FingerprintManager.class);
jsonObject = new JSONObject();
try {
jsonObject.put(AppConstants.USER_NAME, userName);
jsonObject.put(AppConstants.PASS_WORD, passWord);
} catch (JSONException e) {
e.printStackTrace();
}
// Check whether the device has a Fingerprint sensor.
if (!fingerprintManager.isHardwareDetected()) {
errorMessage = "Your Device does not have a Fingerprint Sensor";
errorCallback.invoke(errorMessage);
} else {
// Checks whether fingerprint permission is set on manifest
if (ActivityCompat.checkSelfPermission(AppContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
errorMessage = "Fingerprint authentication permission not enabled";
errorCallback.invoke(errorMessage);
} else {
// Check whether at least one fingerprint is registered
if (!fingerprintManager.hasEnrolledFingerprints()) {
errorMessage = "Go to 'Settings -> Security -> Fingerprint' and register at least one fingerprint";
errorCallback.invoke(errorMessage);
} else {
// Checks whether lock screen security is enabled or not
if (!keyguardManager.isKeyguardSecure()) {
errorMessage = "Secure lock screen hasn't set up.\n"
+ "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint";
errorCallback.invoke(errorMessage);
} else {
//Generate key
generateKey();
//initialize cipher and pass it to FingerPrint scanner
if (cipherInit()) {
//Create dialog
FingerprintAuthenticationDialogFragment fragment
= new FingerprintAuthenticationDialogFragment(BiometricModule.this);
//Assign crypto Object
fragment.setCryptoObject(new FingerprintManagerCompat.CryptoObject(defaultCipher));
//Start Authentication
fragment.show(activityContext.getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
}
}
}
}
} else {
errorMessage = "Fingerprint authentication feature does not work on rooted devices";
errorCallback.invoke(errorMessage);
//clear stored credentials
flushFileSystem();
}
}
开发者ID:hiteshsahu,项目名称:FingerPrint-Authentication-With-React-Native-Android,代码行数:79,代码来源:BiometricModule.java
示例10: onCreate
import android.app.KeyguardManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mKeyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mFingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
// Checking fingerprint permission.
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.USE_FINGERPRINT) !=
PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
"Fingerprint authentication permission not enabled",
Toast.LENGTH_LONG).show();
return;
}
// Checking Device support fingerprint or not.
if (mFingerprintManager.isHardwareDetected()) {
// Not setting lock screen with imprint.
if (!mKeyguardManager.isKeyguardSecure()) {
Toast.makeText(this,
"Lock screen security not enabled in Settings",
Toast.LENGTH_LONG).show();
return;
}
// Not registered at least one fingerprint in Settings.
if (!mFingerprintManager.hasEnrolledFingerprints()) {
Toast.makeText(this,
"Register at least one fingerprint in Settings",
Toast.LENGTH_LONG).show();
return;
}
generateKey();
if (initCipher()) {
mCryptoObject = new FingerprintManager.CryptoObject(cipher);
mFingerprintHelper = new FingerprintHelper(this);
}
}
}
示例11: onCreate
import android.app.KeyguardManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_login);
setTitle("Fingerprint Authentication");
auth_status = (SwirlView) findViewById(R.id.fp_stat);
auth_status.setState(SwirlView.State.ON,true);
// If you’ve set your app’s minSdkVersion to anything lower than 23, then you’ll need to verify that the device is running Marshmallow
// or higher before executing any fingerprint-related code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//Get an instance of KeyguardManager and FingerprintManager//
keyguardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager =
(FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
//Check whether the device has a fingerprint sensor//
if (!fingerprintManager.isHardwareDetected()) {
// If a fingerprint sensor isn’t available, then inform the user that they’ll be unable to use your app’s fingerprint functionality//
MDToast.makeText(this,"Your device doesn't support fingerprint authentication",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check whether the user has granted your app the USE_FINGERPRINT permission//
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
// If your app doesn't have this permission, then display the following text//
MDToast.makeText(this,"Please enable the fingerprint permission",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check that the user has registered at least one fingerprint//
if (!fingerprintManager.hasEnrolledFingerprints()) {
// If the user hasn’t configured any fingerprints, then display the following message//
MDToast.makeText(this,"No fingerprint configured. Please register at least one fingerprint in your device's Settings",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check that the lockscreen is secured//
if (!keyguardManager.isKeyguardSecure()) {
// If the user hasn’t secured their lockscreen with a PIN password or pattern, then display the following text//
MDToast.makeText(this,"Please enable lockscreen security in your device's Settings",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
} else {
try {
generateKey();
} catch (FingerprintException e) {
e.printStackTrace();
}
if (initCipher()) {
//If the cipher is initialized successfully, then create a CryptoObject instance//
cryptoObject = new FingerprintManager.CryptoObject(cipher);
// Here, I’m referencing the FingerprintHandler class that we’ll create in the next section. This class will be responsible
// for starting the authentication process (via the startAuth method) and processing the authentication process events//
FingerprintHandler helper = new FingerprintHandler(this,this);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
}
}
示例12: checkAndEnableFingerPrintService
import android.app.KeyguardManager; //导入方法依赖的package包/类
/**
* @return Returns result code, an integer which can be any one of the following,<br/><br/>
* <b>FINGERPRINT_SENSOR_NOT_FOUND - 100<br/><br/></b>
* <b>PERMISSION_NOT_GRANTED_TO_ACCESS_FINGERPRINT_SENSOR - 200<br/><br/></b>
* <b>NO_FINGER_PRINTS_ENROLLED_IN_THE_DEVICE - 300<br/><br/></b>
* <b>OS_DOES_NOT_SUPPORT_FINGERPRINT_API - 400<br/><br/></b>
* <b>FAILED_INITIALISING_FINGERPRINT_SERVICE - 500<br/><br/></b>
* <b>FINGERPRINT_INITIALISATION_SUCCESS- 600<br/><br/></b>
* <b>KEY_GUARD_DISABLED - 700<br/><br/></b>
*/
public int checkAndEnableFingerPrintService() {
KeyguardManager keyguardManager = (KeyguardManager) mContext.getSystemService(KEYGUARD_SERVICE);
fingerprintManager = (FingerprintManager) mContext.getSystemService(FINGERPRINT_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!fingerprintManager.isHardwareDetected()) {
// Check if fingerprint sensor is available
return ResponseCode.FINGER_PRINT_SENSOR_UNAVAILABLE;
} else {
// Check if permission is granted to access fingerprint sensor
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return ResponseCode.ENABLE_FINGER_PRINT_SENSOR_ACCESS;
} else {
// Check if device is keyguard protected
if (!keyguardManager.isKeyguardSecure()) {
return ResponseCode.DEVICE_NOT_KEY_GUARD_SECURED;
} else {
// Check if any fingerprints are enrolled
if (!fingerprintManager.hasEnrolledFingerprints()) {
return ResponseCode.NO_FINGER_PRINTS_ARE_ENROLLED;
} else {
if (generateKey()) {
if (cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(cipher);
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_SUCCESS;
} else {
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_FAILED;
}
} else {
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_FAILED;
}
}
}
}
}
} else {
return ResponseCode.OS_NOT_SUPPORTED;
}
}
示例13: onCreate
import android.app.KeyguardManager; //导入方法依赖的package包/类
@Override
@TargetApi(23)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fingerprint);
activity = this;
// Initializing both Android Keyguard Manager and Fingerprint Manager
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
textView = (TextView) findViewById(R.id.errorText);
// Check whether the device has a Fingerprint sensor.
if(!fingerprintManager.isHardwareDetected()){
/**
* An error message will be displayed if the device does not contain the fingerprint hardware.
* However if you plan to implement a default authentication method,
* you can redirect the user to a default authentication activity from here.
* Example:
* Intent intent = new Intent(this, DefaultAuthenticationActivity.class);
* startActivity(intent);
*/
textView.setText("Your Device does not have a Fingerprint Sensor");
}else {
// Checks whether fingerprint permission is set on manifest
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
textView.setText("Fingerprint authentication permission not enabled");
}else{
// Check whether at least one fingerprint is registered
if (!fingerprintManager.hasEnrolledFingerprints()) {
textView.setText("Register at least one fingerprint in Settings");
}else{
// Checks whether lock screen security is enabled or not
if (!keyguardManager.isKeyguardSecure()) {
textView.setText("Lock screen security not enabled in Settings");
}else{
generateKey();
if (cipherInit()) {
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
FingerprintHandler helper = new FingerprintHandler(this, shortcutInfo);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
}
}
}
}
示例14: onCreate
import android.app.KeyguardManager; //导入方法依赖的package包/类
@Override
@TargetApi(23)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fingerprint);
activity = this;
// Initializing both Android Keyguard Manager and Fingerprint Manager
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
textView = (TextView) findViewById(R.id.errorText);
// Check whether the device has a Fingerprint sensor.
if(!fingerprintManager.isHardwareDetected()){
/**
* An error message will be displayed if the device does not contain the fingerprint hardware.
* However if you plan to implement a default authentication method,
* you can redirect the user to a default authentication activity from here.
* Example:
* Intent intent = new Intent(this, DefaultAuthenticationActivity.class);
* startActivity(intent);
*/
textView.setText("Your Device does not have a Fingerprint Sensor");
}else {
// Checks whether fingerprint permission is set on manifest
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
textView.setText("Fingerprint authentication permission not enabled");
}else{
// Check whether at least one fingerprint is registered
if (!fingerprintManager.hasEnrolledFingerprints()) {
textView.setText("Register at least one fingerprint in Settings");
}else{
// Checks whether lock screen security is enabled or not
if (!keyguardManager.isKeyguardSecure()) {
textView.setText("Lock screen security not enabled in Settings");
}else{
generateKey();
if (cipherInit()) {
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
FingerprintHandlerSettings helper = new FingerprintHandlerSettings(this);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
}
}
}
}
示例15: isPassOrPinSet
import android.app.KeyguardManager; //导入方法依赖的package包/类
private static boolean isPassOrPinSet(Context context) {
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager.isKeyguardSecure();
}