Search in sources :

Example 56 with KeyguardManager

use of android.app.KeyguardManager in project android_frameworks_base by ResurrectionRemix.

the class ShutdownThread method isAdvancedRebootPossible.

private static boolean isAdvancedRebootPossible(final Context context) {
    KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    boolean keyguardLocked = km.inKeyguardRestrictedInputMode() && km.isKeyguardSecure();
    boolean advancedRebootEnabled = CMSettings.Secure.getInt(context.getContentResolver(), CMSettings.Secure.ADVANCED_REBOOT, 1) == 1;
    boolean isPrimaryUser = UserHandle.getCallingUserId() == UserHandle.USER_OWNER;
    return advancedRebootEnabled && !keyguardLocked && isPrimaryUser;
}
Also used : KeyguardManager(android.app.KeyguardManager)

Example 57 with KeyguardManager

use of android.app.KeyguardManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class Utils method unlockWorkProfileIfNecessary.

public static boolean unlockWorkProfileIfNecessary(Context context, int userId) {
    try {
        if (!ActivityManagerNative.getDefault().isUserRunning(userId, ActivityManager.FLAG_AND_LOCKED)) {
            return false;
        }
    } catch (RemoteException e) {
        return false;
    }
    if (!(new LockPatternUtils(context)).isSecure(userId)) {
        return false;
    }
    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 : LockPatternUtils(com.android.internal.widget.LockPatternUtils) Intent(android.content.Intent) RemoteException(android.os.RemoteException) KeyguardManager(android.app.KeyguardManager)

Example 58 with KeyguardManager

use of android.app.KeyguardManager in project android_frameworks_base by ResurrectionRemix.

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 59 with KeyguardManager

use of android.app.KeyguardManager in project android_frameworks_base by crdroidandroid.

the class LockSettingsService method showEncryptionNotificationForProfile.

private void showEncryptionNotificationForProfile(UserHandle user) {
    Resources r = mContext.getResources();
    CharSequence title = r.getText(com.android.internal.R.string.user_encrypted_title);
    CharSequence message = r.getText(com.android.internal.R.string.profile_encrypted_message);
    CharSequence detail = r.getText(com.android.internal.R.string.profile_encrypted_detail);
    final KeyguardManager km = (KeyguardManager) mContext.getSystemService(KEYGUARD_SERVICE);
    final Intent unlockIntent = km.createConfirmDeviceCredentialIntent(null, null, user.getIdentifier());
    if (unlockIntent == null) {
        return;
    }
    unlockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    PendingIntent intent = PendingIntent.getActivity(mContext, 0, unlockIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    showEncryptionNotification(user, title, message, detail, intent);
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Resources(android.content.res.Resources) PendingIntent(android.app.PendingIntent) KeyguardManager(android.app.KeyguardManager)

Example 60 with KeyguardManager

use of android.app.KeyguardManager in project android_frameworks_base by crdroidandroid.

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)

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