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); } }
@Override public void onResume() { super.onResume(); // Make sure we reload the preference hierarchy since some of these settings // depend on others... createPreferenceHierarchy(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); if (mVisiblePattern != null) { mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled()); } if (mTactileFeedback != null) { mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled()); } if (mPowerButtonInstantlyLocks != null) { mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks()); } mShowPassword.setChecked( Settings.System.getInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, 1) != 0); KeyStore.State state = KeyStore.getInstance().state(); mResetCredentials.setEnabled(state != KeyStore.State.UNINITIALIZED); // Location Settings updateLocationToggles(); if (mSettingsObserver == null) { mSettingsObserver = new Observer() { public void update(Observable o, Object arg) { updateLocationToggles(); } }; mContentQueryMap.addObserver(mSettingsObserver); } }
/** * @param context The context. * @param configuration * @param lockPatternUtils Used to lookup lock pattern settings. * @param updateMonitor Used to lookup state affecting keyguard. * @param callback Used to notify the manager when we're done, etc. * @param totalFailedAttempts The current number of failed attempts. * @param enableFallback True if a backup unlock option is available when the user has forgotten * their pattern (e.g they have a google account so we can show them the account based backup * option). */ PatternUnlockScreen( Context context, Configuration configuration, LockPatternUtils lockPatternUtils, KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback, int totalFailedAttempts) { super(context); mLockPatternUtils = lockPatternUtils; mUpdateMonitor = updateMonitor; mCallback = callback; mTotalFailedPatternAttempts = totalFailedAttempts; mFailedPatternAttemptsSinceLastTimeout = totalFailedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT; if (DEBUG) Log.d( TAG, "UnlockScreen() ctor: totalFailedAttempts=" + totalFailedAttempts + ", mFailedPat...=" + mFailedPatternAttemptsSinceLastTimeout); mCreationOrientation = configuration.orientation; LayoutInflater inflater = LayoutInflater.from(context); if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) { Log.d(TAG, "portrait mode"); inflater.inflate(R.layout.keyguard_screen_unlock_portrait, this, true); } else { Log.d(TAG, "landscape mode"); inflater.inflate(R.layout.keyguard_screen_unlock_landscape, this, true); } LockScreen.setBackground(context, (ViewGroup) findViewById(R.id.root)); mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor, mLockPatternUtils, mCallback, true); mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); mForgotPatternButton = (Button) findViewById(R.id.forgotPatternButton); mForgotPatternButton.setText(R.string.lockscreen_forgot_pattern_button_text); mForgotPatternButton.setOnClickListener(mForgotPatternClick); // make it so unhandled touch events within the unlock screen go to the // lock pattern view. setDefaultTouchRecepient(mLockPatternView); mLockPatternView.setSaveEnabled(false); mLockPatternView.setFocusable(false); mLockPatternView.setOnPatternListener(new UnlockPatternListener()); // stealth mode will be the same for the life of this screen mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled()); // vibrate mode will be the same for the life of this screen mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled()); // assume normal footer mode for now updateFooter(FooterMode.Normal); setFocusableInTouchMode(true); }