Search in sources :

Example 71 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ResurrectionRemix.

the class RetailDemoModeService method onSwitchUser.

@Override
public void onSwitchUser(int userId) {
    if (!mDeviceInDemoMode) {
        return;
    }
    if (DEBUG) {
        Slog.d(TAG, "onSwitchUser: " + userId);
    }
    final UserInfo ui = getUserManager().getUserInfo(userId);
    if (!ui.isDemo()) {
        Slog.wtf(TAG, "Should not allow switch to non-demo user in demo mode");
        return;
    }
    if (!mIsCarrierDemoMode && !mWakeLock.isHeld()) {
        mWakeLock.acquire();
    }
    mCurrentUserId = userId;
    mAmi.updatePersistentConfigurationForUser(getSystemUsersConfiguration(), userId);
    turnOffAllFlashLights();
    muteVolumeStreams();
    if (!mWifiManager.isWifiEnabled()) {
        mWifiManager.setWifiEnabled(true);
    }
    // Disable lock screen for demo users.
    LockPatternUtils lockPatternUtils = new LockPatternUtils(getContext());
    lockPatternUtils.setLockScreenDisabled(true, userId);
    if (!mIsCarrierDemoMode) {
        // Show reset notification (except in carrier demo mode).
        mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId));
        synchronized (mActivityLock) {
            mUserUntouched = true;
        }
        MetricsLogger.count(getContext(), DEMO_SESSION_COUNT, 1);
        mHandler.removeMessages(MSG_INACTIVITY_TIME_OUT);
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                mPreloadAppsInstaller.installApps(userId);
            }
        });
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils) UserInfo(android.content.pm.UserInfo)

Example 72 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils 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 73 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetNewPasswordController method create.

public static SetNewPasswordController create(Context context, Ui ui, Intent intent, IBinder activityToken) {
    // Trying to figure out which user is setting new password. If it is
    // ACTION_SET_NEW_PARENT_PROFILE_PASSWORD or the calling user is not allowed to set
    // separate profile challenge, it is the current user to set new password. Otherwise,
    // it is the user who starts this activity setting new password.
    int userId = ActivityManager.getCurrentUser();
    if (ACTION_SET_NEW_PASSWORD.equals(intent.getAction())) {
        final int callingUserId = Utils.getSecureTargetUser(activityToken, UserManager.get(context), null, intent.getExtras()).getIdentifier();
        final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
        if (lockPatternUtils.isSeparateProfileChallengeAllowed(callingUserId)) {
            userId = callingUserId;
        }
    }
    // Create a wrapper of FingerprintManager for testing, see IFingerPrintManager for details.
    final FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
    final IFingerprintManager fingerprintManagerWrapper = fingerprintManager == null ? null : new FingerprintManagerWrapper(fingerprintManager);
    return new SetNewPasswordController(userId, context.getPackageManager(), fingerprintManagerWrapper, (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE), ui);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) LockPatternUtils(com.android.internal.widget.LockPatternUtils)

Example 74 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ResurrectionRemix.

the class DatabaseHelper method upgradeLockPatternLocation.

private void upgradeLockPatternLocation(SQLiteDatabase db) {
    Cursor c = db.query(TABLE_SYSTEM, new String[] { "_id", "value" }, "name='lock_pattern'", null, null, null, null);
    if (c.getCount() > 0) {
        c.moveToFirst();
        String lockPattern = c.getString(1);
        if (!TextUtils.isEmpty(lockPattern)) {
            // Convert lock pattern
            try {
                LockPatternUtils lpu = new LockPatternUtils(mContext);
                List<LockPatternView.Cell> cellPattern = LockPatternUtils.stringToPattern(lockPattern, lpu.getLockPatternSize(mUserHandle));
                lpu.saveLockPattern(cellPattern, null, UserHandle.USER_SYSTEM);
            } catch (IllegalArgumentException e) {
            // Don't want corrupted lock pattern to hang the reboot process
            }
        }
        c.close();
        db.delete(TABLE_SYSTEM, "name='lock_pattern'", null);
    } else {
        c.close();
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils) Cursor(android.database.Cursor)

Example 75 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method checkIfKeyguardFeaturesDisabled.

/**
     * Checks if keyguard features are disabled by policy.
     *
     * @param keyguardFeatures Could be any of keyguard features that can be
     * disabled by {@link android.app.admin.DevicePolicyManager#setKeyguardDisabledFeatures}.
     * @return EnforcedAdmin Object containing the enforced admin component and admin user details,
     * or {@code null} If the notification features are not disabled. If the restriction is set by
     * multiple admins, then the admin component will be set to {@code null} and userId to
     * {@link UserHandle#USER_NULL}.
     */
public static EnforcedAdmin checkIfKeyguardFeaturesDisabled(Context context, int keyguardFeatures, int userId) {
    final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm == null) {
        return null;
    }
    final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
    LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
    EnforcedAdmin enforcedAdmin = null;
    if (um.getUserInfo(userId).isManagedProfile()) {
        final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userId);
        if (admins == null) {
            return null;
        }
        for (ComponentName admin : admins) {
            if ((dpm.getKeyguardDisabledFeatures(admin, userId) & keyguardFeatures) != 0) {
                if (enforcedAdmin == null) {
                    enforcedAdmin = new EnforcedAdmin(admin, userId);
                } else {
                    return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
                }
            }
        }
    } else {
        // user that do not use a separate work challenge.
        for (UserInfo userInfo : um.getProfiles(userId)) {
            final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id);
            if (admins == null) {
                continue;
            }
            final boolean isSeparateProfileChallengeEnabled = lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id);
            for (ComponentName admin : admins) {
                if (!isSeparateProfileChallengeEnabled) {
                    if ((dpm.getKeyguardDisabledFeatures(admin, userInfo.id) & keyguardFeatures) != 0) {
                        if (enforcedAdmin == null) {
                            enforcedAdmin = new EnforcedAdmin(admin, userInfo.id);
                        } else {
                            return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
                        }
                        // has set policy on the parent admin.
                        continue;
                    }
                }
                if (userInfo.isManagedProfile()) {
                    // If userInfo.id is a managed profile, we also need to look at
                    // the policies set on the parent.
                    DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo);
                    if ((parentDpm.getKeyguardDisabledFeatures(admin, userInfo.id) & keyguardFeatures) != 0) {
                        if (enforcedAdmin == null) {
                            enforcedAdmin = new EnforcedAdmin(admin, userInfo.id);
                        } else {
                            return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
                        }
                    }
                }
            }
        }
    }
    return enforcedAdmin;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) UserManager(android.os.UserManager) LockPatternUtils(com.android.internal.widget.LockPatternUtils) ComponentName(android.content.ComponentName) UserInfo(android.content.pm.UserInfo)

Aggregations

LockPatternUtils (com.android.internal.widget.LockPatternUtils)96 ComponentName (android.content.ComponentName)24 UserInfo (android.content.pm.UserInfo)24 DevicePolicyManager (android.app.admin.DevicePolicyManager)19 UserManager (android.os.UserManager)16 IOException (java.io.IOException)11 IntentFilter (android.content.IntentFilter)10 Intent (android.content.Intent)9 View (android.view.View)9 Cursor (android.database.Cursor)6 RemoteException (android.os.RemoteException)6 ArrayList (java.util.ArrayList)6 ContentResolver (android.content.ContentResolver)5 Configuration (android.content.res.Configuration)5 Rect (android.graphics.Rect)5 SoundPool (android.media.SoundPool)5 IBinder (android.os.IBinder)5 IVrManager (android.service.vr.IVrManager)5 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)5 KeyguardDisplayManager (com.android.keyguard.KeyguardDisplayManager)5