use of android.app.KeyguardManager in project android_packages_apps_Settings by LineageOS.
the class Utils method confirmWorkProfileCredentials.
private static boolean confirmWorkProfileCredentials(Context context, int userId) {
final KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
final Intent unlockIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
if (unlockIntent != null) {
context.startActivity(unlockIntent);
return true;
} else {
return false;
}
}
use of android.app.KeyguardManager in project android by nextcloud.
the class FingerprintHandler method startFingerprint.
private void startFingerprint() {
TextView fingerprintTextView = (TextView) findViewById(R.id.scanfingerprinttext);
FingerprintManager fingerprintManager = (FingerprintManager) MainApp.getAppContext().getSystemService(Context.FINGERPRINT_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return;
}
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
if (keyguardManager.isKeyguardSecure()) {
generateKey();
if (cipherInit()) {
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
FingerprintHandler.Callback callback = new FingerprintHandler.Callback() {
@Override
public void onAuthenticated() {
fingerprintResult(true);
}
@Override
public void onFailed(String error) {
Toast.makeText(MainApp.getAppContext(), error, Toast.LENGTH_LONG).show();
ImageView imageView = (ImageView) findViewById(R.id.fingerprinticon);
int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[] { -android.R.attr.state_activated } };
int[] colors = new int[] { Color.parseColor("#FF0000"), Color.RED };
ColorStateList csl = new ColorStateList(states, colors);
Drawable drawable = DrawableCompat.wrap(imageView.getDrawable());
DrawableCompat.setTintList(drawable, csl);
imageView.setImageDrawable(drawable);
}
};
FingerprintHandler helper = new FingerprintHandler(fingerprintTextView, callback);
cancellationSignal = new CancellationSignal();
if (ActivityCompat.checkSelfPermission(MainApp.getAppContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return;
}
fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, helper, null);
}
}
}
use of android.app.KeyguardManager in project platform_frameworks_base by android.
the class ImfBaseTestCase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
final String packageName = getInstrumentation().getTargetContext().getPackageName();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
mTargetActivity = launchActivityWithIntent(packageName, mTargetActivityClass, intent);
// expect ime to auto pop up if device has no hard keyboard
int keyboardType = mTargetActivity.getResources().getConfiguration().keyboard;
mExpectAutoPop = (keyboardType == Configuration.KEYBOARD_NOKEYS || keyboardType == Configuration.KEYBOARD_UNDEFINED);
mImm = InputMethodManager.getInstance();
KeyguardManager keyguardManager = (KeyguardManager) getInstrumentation().getContext().getSystemService(Context.KEYGUARD_SERVICE);
keyguardManager.newKeyguardLock("imftest").disableKeyguard();
}
use of android.app.KeyguardManager in project android_frameworks_base by crdroidandroid.
the class ActivityStartInterceptor method interceptWithConfirmCredentialsIfNeeded.
/**
* Creates an intent to intercept the current activity start with Confirm Credentials if needed.
*
* @return The intercepting intent if needed.
*/
private Intent interceptWithConfirmCredentialsIfNeeded(Intent intent, String resolvedType, ActivityInfo aInfo, String callingPackage, int userId) {
if (!mService.mUserController.shouldConfirmCredentials(userId)) {
return null;
}
// Allow direct boot aware activity to be displayed before the user is unlocked.
if (aInfo.directBootAware && mService.mUserController.isUserRunningLocked(userId, ActivityManager.FLAG_AND_LOCKED)) {
return null;
}
final IIntentSender target = mService.getIntentSenderLocked(INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, null, 0, new Intent[] { intent }, new String[] { resolvedType }, FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT | FLAG_IMMUTABLE, null);
final KeyguardManager km = (KeyguardManager) mService.mContext.getSystemService(KEYGUARD_SERVICE);
final Intent newIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
if (newIntent == null) {
return null;
}
newIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_TASK_ON_HOME);
newIntent.putExtra(EXTRA_PACKAGE_NAME, aInfo.packageName);
newIntent.putExtra(EXTRA_INTENT, new IntentSender(target));
return newIntent;
}
use of android.app.KeyguardManager in project sbt-android by scala-android.
the class U2020TestRunner method onStart.
@Override
public void onStart() {
// Inform the app we are an instrumentation test before the object graph is initialized.
DebugU2020Module.instrumentationTest = true;
Context app = getTargetContext().getApplicationContext();
String name = U2020TestRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
KeyguardManager keyguard = (KeyguardManager) app.getSystemService(KEYGUARD_SERVICE);
keyguard.newKeyguardLock(name).disableKeyguard();
// Wake up the screen.
PowerManager power = (PowerManager) app.getSystemService(POWER_SERVICE);
wakeLock = power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, name);
wakeLock.acquire();
super.onStart();
}
Aggregations