Search in sources :

Example 21 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project android_packages_apps_Settings by DirtyUnicorns.

the class SecuritySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Activity activity = getActivity();
    mSubscriptionManager = SubscriptionManager.from(activity);
    mLockPatternUtils = new LockPatternUtils(activity);
    mManagedPasswordProvider = ManagedLockPasswordProvider.get(activity, MY_USER_ID);
    mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    mUm = UserManager.get(activity);
    mChooseLockSettingsHelper = new ChooseLockSettingsHelper(activity);
    mDashboardFeatureProvider = FeatureFactory.getFactory(activity).getDashboardFeatureProvider(activity);
    mSecurityFeatureProvider = FeatureFactory.getFactory(activity).getSecurityFeatureProvider();
    mTrustAgentManager = mSecurityFeatureProvider.getTrustAgentManager();
    if (savedInstanceState != null && savedInstanceState.containsKey(TRUST_AGENT_CLICK_INTENT)) {
        mTrustAgentClickIntent = savedInstanceState.getParcelable(TRUST_AGENT_CLICK_INTENT);
    }
    mManageDeviceAdminPreferenceController = new ManageDeviceAdminPreferenceController(activity);
    mEnterprisePrivacyPreferenceController = new EnterprisePrivacyPreferenceController(activity, null);
    mLockScreenNotificationPreferenceController = new LockScreenNotificationPreferenceController(activity);
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) ManageDeviceAdminPreferenceController(com.android.settings.enterprise.ManageDeviceAdminPreferenceController) EnterprisePrivacyPreferenceController(com.android.settings.enterprise.EnterprisePrivacyPreferenceController) LockPatternUtils(com.android.internal.widget.LockPatternUtils) Activity(android.app.Activity) LockScreenNotificationPreferenceController(com.android.settings.notification.LockScreenNotificationPreferenceController)

Example 22 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project android_packages_apps_Settings by DirtyUnicorns.

the class SecuritySettings method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    boolean result = true;
    final String key = preference.getKey();
    final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
    if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
        if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm, mProfileChallengeUserId)) {
            return false;
        }
        lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
    } else if (KEY_UNIFICATION.equals(key)) {
        if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm, mProfileChallengeUserId)) {
            return false;
        }
        if ((Boolean) value) {
            final boolean compliantForDevice = (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId) >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING && mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(mProfileChallengeUserId));
            UnificationConfirmationDialog dialog = UnificationConfirmationDialog.newIntance(compliantForDevice);
            dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
        } else {
            final String title = getActivity().getString(R.string.unlock_set_unlock_launch_picker_title);
            final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
            if (!helper.launchConfirmationActivity(UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, MY_USER_ID)) {
                ununifyLocks();
            }
        }
    } else if (KEY_SHOW_PASSWORD.equals(key)) {
        Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, ((Boolean) value) ? 1 : 0);
        lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID);
    }
    return result;
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) LockPatternUtils(com.android.internal.widget.LockPatternUtils)

Example 23 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project android_packages_apps_Settings by DirtyUnicorns.

the class SecuritySettings method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    final String key = preference.getKey();
    if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
        // able to complete the operation due to the lack of (old) encryption key.
        if (mProfileChallengeUserId != UserHandle.USER_NULL && !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && StorageManager.isFileEncryptedNativeOnly()) {
            if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm, mProfileChallengeUserId)) {
                return false;
            }
        }
        startFragment(this, ChooseLockGenericFragment.class.getName(), R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
    } else if (KEY_UNLOCK_SET_OR_CHANGE_PROFILE.equals(key)) {
        if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm, mProfileChallengeUserId)) {
            return false;
        }
        Bundle extras = new Bundle();
        extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
        startFragment(this, ChooseLockGenericFragment.class.getName(), R.string.lock_settings_picker_title_profile, SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
    } else if (KEY_TRUST_AGENT.equals(key)) {
        ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this);
        mTrustAgentClickIntent = preference.getIntent();
        boolean confirmationLaunched = helper.launchConfirmationActivity(CHANGE_TRUST_AGENT_SETTINGS, preference.getTitle());
        if (!confirmationLaunched && mTrustAgentClickIntent != null) {
            // If this returns false, it means no password confirmation is required.
            startActivity(mTrustAgentClickIntent);
            mTrustAgentClickIntent = null;
        }
    } else {
        // If we didn't handle it, let preferences handle it.
        return super.onPreferenceTreeClick(preference);
    }
    return true;
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ChooseLockGenericFragment(com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment)

Example 24 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project android_packages_apps_Settings by DirtyUnicorns.

the class CryptKeeperSettings method runKeyguardConfirmation.

/**
 * Keyguard validation is run using the standard {@link ConfirmLockPattern}
 * component as a subactivity
 * @param request the request code to be returned once confirmation finishes
 * @return true if confirmation launched
 */
private boolean runKeyguardConfirmation(int request) {
    Resources res = getActivity().getResources();
    ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
    if (helper.utils().getKeyguardStoredPasswordQuality(UserHandle.myUserId()) == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
        showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "");
        return true;
    }
    return helper.launchConfirmationActivity(request, res.getText(R.string.crypt_keeper_encrypt_title), true);
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) Resources(android.content.res.Resources)

Example 25 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project platform_packages_apps_Settings by BlissRoms.

the class AddAccountSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mAddAccountCalled = savedInstanceState.getBoolean(KEY_ADD_CALLED);
        if (Log.isLoggable(TAG, Log.VERBOSE))
            Log.v(TAG, "restored");
    }
    final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
    mUserHandle = Utils.getSecureTargetUser(getActivityToken(), um, null, /* arguments */
    getIntent().getExtras());
    if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, mUserHandle)) {
        // We aren't allowed to add an account.
        Toast.makeText(this, R.string.user_cannot_add_accounts_message, Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    if (mAddAccountCalled) {
        // We already called add account - maybe the callback was lost.
        finish();
        return;
    }
    if (Utils.startQuietModeDialogIfNecessary(this, um, mUserHandle.getIdentifier())) {
        finish();
        return;
    }
    if (um.isUserUnlocked(mUserHandle)) {
        requestChooseAccount();
    } else {
        // If the user is locked by fbe: we couldn't start the authenticator. So we must ask the
        // user to unlock it first.
        ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
        if (!helper.launchConfirmationActivity(UNLOCK_WORK_PROFILE_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), false, mUserHandle.getIdentifier())) {
            requestChooseAccount();
        }
    }
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) UserManager(android.os.UserManager)

Aggregations

ChooseLockSettingsHelper (com.android.settings.password.ChooseLockSettingsHelper)68 Resources (android.content.res.Resources)13 LockPatternUtils (com.android.internal.widget.LockPatternUtils)11 UserManager (android.os.UserManager)8 Bundle (android.os.Bundle)6 PersistableBundle (android.os.PersistableBundle)6 ChooseLockGenericFragment (com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment)6 Activity (android.app.Activity)5 EnterprisePrivacyPreferenceController (com.android.settings.enterprise.EnterprisePrivacyPreferenceController)5 ManageDeviceAdminPreferenceController (com.android.settings.enterprise.ManageDeviceAdminPreferenceController)5 LockScreenNotificationPreferenceController (com.android.settings.notification.LockScreenNotificationPreferenceController)5 LineageLockPatternUtils (org.lineageos.internal.util.LineageLockPatternUtils)5 Intent (android.content.Intent)3 UserInfo (android.content.pm.UserInfo)2 ComponentName (android.content.ComponentName)1 ResolveInfo (android.content.pm.ResolveInfo)1 StorageManager (android.os.storage.StorageManager)1 Random (java.util.Random)1