@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { final String key = preference.getKey(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) { startFragment( this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment", SET_OR_CHANGE_LOCK_METHOD_REQUEST, null); } else if (KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING.equals(key)) { ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this); if (!helper.launchConfirmationActivity( CONFIRM_EXISTING_FOR_BIOMETRIC_IMPROVE_REQUEST, null, null)) { startBiometricWeakImprove(); // no password set, so no need to confirm } } else if (KEY_LOCK_ENABLED.equals(key)) { lockPatternUtils.setLockPatternEnabled(isToggled(preference)); } else if (KEY_VISIBLE_PATTERN.equals(key)) { lockPatternUtils.setVisiblePatternEnabled(isToggled(preference)); } else if (KEY_TACTILE_FEEDBACK_ENABLED.equals(key)) { lockPatternUtils.setTactileFeedbackEnabled(isToggled(preference)); } else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) { lockPatternUtils.setPowerButtonInstantlyLocks(isToggled(preference)); } else if (preference == mShowPassword) { Settings.System.putInt( getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, mShowPassword.isChecked() ? 1 : 0); } else if (preference == mToggleAppInstallation) { if (mToggleAppInstallation.isChecked()) { mToggleAppInstallation.setChecked(false); warnAppInstallation(); } else { setNonMarketAppsAllowed(false); } } else { // If we didn't handle it, let preferences handle it. return super.onPreferenceTreeClick(preferenceScreen, preference); } return true; }
public void onClick(View v) { if (Utils.isMonkeyRunning()) { return; } /* WARNING - nasty hack! Settings for the lock screen are not available to the crypto screen (CryptKeeper) at boot. We duplicate the ones that CryptKeeper needs to the crypto key/value store when they are modified (see LockPatternUtils). However, prior to encryption, the crypto key/value store is not persisted across reboots, thus modified settings are lost to CryptKeeper. In order to make sure CryptKeeper had the correct settings after first encrypting, we thus need to rewrite them, which ensures the crypto key/value store is up to date. On encryption, this store is then persisted, and the settings will be there on future reboots. */ // 1. The owner info. LockPatternUtils utils = new LockPatternUtils(getActivity()); utils.setVisiblePatternEnabled(utils.isVisiblePatternEnabled()); if (utils.isOwnerInfoEnabled()) { utils.setOwnerInfo(utils.getOwnerInfo(UserHandle.USER_OWNER), UserHandle.USER_OWNER); } Intent intent = new Intent(getActivity(), Blank.class); intent.putExtras(getArguments()); startActivity(intent); // 2. The system locale. try { IBinder service = ServiceManager.getService("mount"); IMountService mountService = IMountService.Stub.asInterface(service); mountService.setField("SystemLocale", Locale.getDefault().toLanguageTag()); } catch (Exception e) { Log.e(TAG, "Error storing locale for decryption UI", e); } }