Search in sources :

Example 61 with KeyguardManager

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;
    }
}
Also used : Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager)

Example 62 with KeyguardManager

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);
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ColorStateList(android.content.res.ColorStateList) FingerprintManager(android.hardware.fingerprint.FingerprintManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) KeyguardManager(android.app.KeyguardManager) CancellationSignal(android.os.CancellationSignal)

Example 63 with KeyguardManager

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();
}
Also used : Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager)

Example 64 with KeyguardManager

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;
}
Also used : IIntentSender(android.content.IIntentSender) Intent(android.content.Intent) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender) KeyguardManager(android.app.KeyguardManager)

Example 65 with KeyguardManager

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();
}
Also used : Context(android.content.Context) PowerManager(android.os.PowerManager) KeyguardManager(android.app.KeyguardManager)

Aggregations

KeyguardManager (android.app.KeyguardManager)94 Intent (android.content.Intent)44 PendingIntent (android.app.PendingIntent)18 PowerManager (android.os.PowerManager)17 Context (android.content.Context)12 SuppressLint (android.annotation.SuppressLint)10 IIntentSender (android.content.IIntentSender)10 IntentSender (android.content.IntentSender)10 FingerprintManager (android.hardware.fingerprint.FingerprintManager)7 Resources (android.content.res.Resources)5 TelephonyManager (android.telephony.TelephonyManager)5 TargetApi (android.annotation.TargetApi)4 ConnectivityManager (android.net.ConnectivityManager)4 RemoteException (android.os.RemoteException)4 Activity (android.app.Activity)3 NotificationManager (android.app.NotificationManager)3 Bitmap (android.graphics.Bitmap)3 NetworkInfo (android.net.NetworkInfo)3 DialogFragment (android.app.DialogFragment)2 Notification (android.app.Notification)2