Search in sources :

Example 61 with ChooseLockSettingsHelper

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

the class BuildNumberPreferenceController method handlePreferenceTreeClick.

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
    if (!TextUtils.equals(preference.getKey(), KEY_BUILD_NUMBER)) {
        return false;
    }
    if (Utils.isMonkeyRunning()) {
        return false;
    }
    // Don't enable developer options for secondary users.
    if (!mUm.isAdminUser()) {
        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    // Don't enable developer options until device has been provisioned
    if (!Utils.isDeviceProvisioned(mContext)) {
        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
        if (mDebuggingFeaturesDisallowedAdmin != null && !mDebuggingFeaturesDisallowedBySystem) {
            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mDebuggingFeaturesDisallowedAdmin);
        }
        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    if (mDevHitCountdown > 0) {
        mDevHitCountdown--;
        if (mDevHitCountdown == 0 && !mProcessingLastDevHit) {
            // Add 1 count back, then start password confirmation flow.
            mDevHitCountdown++;
            final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(mActivity, mFragment);
            mProcessingLastDevHit = helper.launchConfirmationActivity(REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF, mContext.getString(R.string.unlock_set_unlock_launch_picker_title));
            if (!mProcessingLastDevHit) {
                enableDevelopmentSettings();
            }
            mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF, Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, mProcessingLastDevHit ? 0 : 1));
        } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
            if (mDevHitToast != null) {
                mDevHitToast.cancel();
            }
            mDevHitToast = Toast.makeText(mContext, mContext.getResources().getQuantityString(R.plurals.show_dev_countdown, mDevHitCountdown, mDevHitCountdown), Toast.LENGTH_SHORT);
            mDevHitToast.show();
        }
        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF, Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, 0));
    } else if (mDevHitCountdown < 0) {
        if (mDevHitToast != null) {
            mDevHitToast.cancel();
        }
        mDevHitToast = Toast.makeText(mContext, R.string.show_dev_already, Toast.LENGTH_LONG);
        mDevHitToast.show();
        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF, Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, 1));
    }
    return true;
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper)

Example 62 with ChooseLockSettingsHelper

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

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 63 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BuildNumberPreferenceController method handlePreferenceTreeClick.

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
    if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
        return false;
    }
    if (Utils.isMonkeyRunning()) {
        return false;
    }
    // Don't enable developer options for secondary non-demo users.
    if (!(mUm.isAdminUser() || mUm.isDemoUser())) {
        mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    // Don't enable developer options until device has been provisioned
    if (!Utils.isDeviceProvisioned(mContext)) {
        mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
        if (mUm.isDemoUser()) {
            // Route to demo device owner to lift the debugging restriction.
            final ComponentName componentName = Utils.getDeviceOwnerComponent(mContext);
            if (componentName != null) {
                final Intent requestDebugFeatures = new Intent().setPackage(componentName.getPackageName()).setAction("com.android.settings.action.REQUEST_DEBUG_FEATURES");
                final ResolveInfo resolveInfo = mContext.getPackageManager().resolveActivity(requestDebugFeatures, 0);
                if (resolveInfo != null) {
                    mContext.startActivity(requestDebugFeatures);
                    return false;
                }
            }
        }
        if (mDebuggingFeaturesDisallowedAdmin != null && !mDebuggingFeaturesDisallowedBySystem) {
            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mDebuggingFeaturesDisallowedAdmin);
        }
        mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_SETTINGS_BUILD_NUMBER_PREF);
        return false;
    }
    if (mDevHitCountdown > 0) {
        mDevHitCountdown--;
        if (mDevHitCountdown == 0 && !mProcessingLastDevHit) {
            // Add 1 count back, then start password confirmation flow.
            mDevHitCountdown++;
            final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(mActivity, mFragment);
            mProcessingLastDevHit = helper.launchConfirmationActivity(REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF, mContext.getString(R.string.unlock_set_unlock_launch_picker_title));
            if (!mProcessingLastDevHit) {
                enableDevelopmentSettings();
            }
            mMetricsFeatureProvider.action(mMetricsFeatureProvider.getAttribution(mActivity), MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, mFragment.getMetricsCategory(), null, mProcessingLastDevHit ? 0 : 1);
        } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
            if (mDevHitToast != null) {
                mDevHitToast.cancel();
            }
            mDevHitToast = Toast.makeText(mContext, mContext.getResources().getQuantityString(R.plurals.show_dev_countdown_cm, mDevHitCountdown, mDevHitCountdown), Toast.LENGTH_SHORT);
            mDevHitToast.show();
        }
        mMetricsFeatureProvider.action(mMetricsFeatureProvider.getAttribution(mActivity), MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, mFragment.getMetricsCategory(), null, 0);
    } else if (mDevHitCountdown < 0) {
        if (mDevHitToast != null) {
            mDevHitToast.cancel();
        }
        mDevHitToast = Toast.makeText(mContext, R.string.show_dev_already_cm, Toast.LENGTH_LONG);
        mDevHitToast.show();
        mMetricsFeatureProvider.action(mMetricsFeatureProvider.getAttribution(mActivity), MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED, mFragment.getMetricsCategory(), null, 1);
    }
    return true;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 64 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FaceSettings method onResume.

@Override
public void onResume() {
    super.onResume();
    if (mToken == null && !mConfirmingPassword) {
        // Generate challenge in onResume instead of onCreate, since FaceSettings can be
        // created while Keyguard is showing, in which case the resetLockout revokeChallenge
        // will invalidate the too-early created challenge here.
        final long challenge = mFaceManager.generateChallenge();
        ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
        mConfirmingPassword = true;
        if (!helper.launchConfirmationActivity(CONFIRM_REQUEST, getString(R.string.security_settings_face_preference_title), null, null, challenge, mUserId, true)) {
            Log.e(TAG, "Password not set");
            finish();
        }
    } else {
        mAttentionController.setToken(mToken);
        mEnrollController.setToken(mToken);
    }
    final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId);
    mEnrollButton.setVisible(!hasEnrolled);
    mRemoveButton.setVisible(hasEnrolled);
    if (!mFaceFeatureProvider.isAttentionSupported(getContext())) {
        removePreference(FaceSettingsAttentionPreferenceController.KEY);
    }
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper)

Example 65 with ChooseLockSettingsHelper

use of com.android.settings.password.ChooseLockSettingsHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LockUnificationPreferenceController method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    if (Utils.startQuietModeDialogIfNecessary(mContext, mUm, mProfileUserId)) {
        return false;
    }
    final boolean useOneLock = (Boolean) value;
    if (useOneLock) {
        // Keep current device (personal) lock if the profile lock is empty or is not compliant
        // with the policy on personal side.
        mKeepDeviceLock = mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileUserId) < DevicePolicyManager.PASSWORD_QUALITY_SOMETHING || !mDpm.isProfileActivePasswordSufficientForParent(mProfileUserId);
        UnificationConfirmationDialog.newInstance(!mKeepDeviceLock).show(mHost);
    } else {
        final String title = mContext.getString(R.string.unlock_set_unlock_launch_picker_title);
        final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(mHost.getActivity(), mHost);
        if (!helper.launchConfirmationActivity(UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, /* returnCredentials */
        MY_USER_ID)) {
            ununifyLocks();
        }
    }
    return true;
}
Also used : ChooseLockSettingsHelper(com.android.settings.password.ChooseLockSettingsHelper)

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