The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 16 | package com.android.keyguard; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 17 | |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 18 | import android.accounts.Account; |
| 19 | import android.accounts.AccountManager; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 20 | import android.accounts.AccountManagerCallback; |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 21 | import android.accounts.AccountManagerFuture; |
| 22 | import android.accounts.AuthenticatorException; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 23 | import android.accounts.OperationCanceledException; |
| 24 | import android.app.Dialog; |
| 25 | import android.app.ProgressDialog; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 26 | import android.content.Context; |
| 27 | import android.content.Intent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 28 | import android.graphics.Rect; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 29 | import android.os.Bundle; |
Amith Yamasani | 2c7bc26 | 2012-11-05 16:46:02 -0800 | [diff] [blame] | 30 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 31 | import android.text.Editable; |
| 32 | import android.text.InputFilter; |
| 33 | import android.text.LoginFilter; |
| 34 | import android.text.TextWatcher; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 35 | import android.util.AttributeSet; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 36 | import android.view.KeyEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 37 | import android.view.View; |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 38 | import android.view.WindowManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 39 | import android.widget.Button; |
| 40 | import android.widget.EditText; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 41 | import android.widget.LinearLayout; |
| 42 | |
| 43 | import com.android.internal.widget.LockPatternUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 44 | |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 45 | import java.io.IOException; |
| 46 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 47 | /** |
| 48 | * When the user forgets their password a bunch of times, we fall back on their |
| 49 | * account's login/password to unlock the phone (and reset their lock pattern). |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 50 | */ |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 51 | public class KeyguardAccountView extends LinearLayout implements KeyguardSecurityView, |
Jim Miller | 6b05d58 | 2011-07-18 13:09:59 -0700 | [diff] [blame] | 52 | View.OnClickListener, TextWatcher { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 53 | private static final int AWAKE_POKE_MILLIS = 30000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 54 | private static final String LOCK_PATTERN_PACKAGE = "com.android.settings"; |
Brian Colonna | aae641b | 2011-09-23 14:37:11 -0400 | [diff] [blame] | 55 | private static final String LOCK_PATTERN_CLASS = LOCK_PATTERN_PACKAGE + ".ChooseLockGeneric"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 56 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 57 | private KeyguardSecurityCallback mCallback; |
Jim Miller | 8b886fa | 2011-01-13 17:56:35 -0800 | [diff] [blame] | 58 | private LockPatternUtils mLockPatternUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 59 | private EditText mLogin; |
| 60 | private EditText mPassword; |
| 61 | private Button mOk; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 62 | public boolean mEnableFallback; |
Jim Miller | 0ff7f01 | 2012-10-11 20:40:01 -0700 | [diff] [blame] | 63 | private SecurityMessageDisplay mSecurityMessageDisplay; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 66 | * Shown while making asynchronous check of password. |
| 67 | */ |
| 68 | private ProgressDialog mCheckingDialog; |
| 69 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 70 | public KeyguardAccountView(Context context) { |
| 71 | this(context, null, 0); |
| 72 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 73 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 74 | public KeyguardAccountView(Context context, AttributeSet attrs) { |
| 75 | this(context, attrs, 0); |
| 76 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 77 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 78 | public KeyguardAccountView(Context context, AttributeSet attrs, int defStyle) { |
| 79 | super(context, attrs, defStyle); |
| 80 | mLockPatternUtils = new LockPatternUtils(getContext()); |
| 81 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 82 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 83 | @Override |
| 84 | protected void onFinishInflate() { |
| 85 | super.onFinishInflate(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 86 | |
| 87 | mLogin = (EditText) findViewById(R.id.login); |
| 88 | mLogin.setFilters(new InputFilter[] { new LoginFilter.UsernameFilterGeneric() } ); |
| 89 | mLogin.addTextChangedListener(this); |
| 90 | |
| 91 | mPassword = (EditText) findViewById(R.id.password); |
| 92 | mPassword.addTextChangedListener(this); |
| 93 | |
| 94 | mOk = (Button) findViewById(R.id.ok); |
| 95 | mOk.setOnClickListener(this); |
Jim Miller | 0b72824 | 2012-10-28 19:42:30 -0700 | [diff] [blame] | 96 | |
| 97 | mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 98 | reset(); |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 99 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 100 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 101 | public void setKeyguardCallback(KeyguardSecurityCallback callback) { |
| 102 | mCallback = callback; |
| 103 | } |
| 104 | |
| 105 | public void setLockPatternUtils(LockPatternUtils utils) { |
| 106 | mLockPatternUtils = utils; |
| 107 | } |
| 108 | |
| 109 | public KeyguardSecurityCallback getCallback() { |
| 110 | return mCallback; |
| 111 | } |
| 112 | |
| 113 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 114 | public void afterTextChanged(Editable s) { |
| 115 | } |
| 116 | |
| 117 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| 118 | } |
| 119 | |
| 120 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 121 | if (mCallback != null) { |
| 122 | mCallback.userActivity(AWAKE_POKE_MILLIS); |
| 123 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | @Override |
| 127 | protected boolean onRequestFocusInDescendants(int direction, |
| 128 | Rect previouslyFocusedRect) { |
| 129 | // send focus to the login field |
| 130 | return mLogin.requestFocus(direction, previouslyFocusedRect); |
| 131 | } |
| 132 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 133 | public boolean needsInput() { |
| 134 | return true; |
| 135 | } |
| 136 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 137 | public void reset() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 138 | // start fresh |
| 139 | mLogin.setText(""); |
| 140 | mPassword.setText(""); |
| 141 | mLogin.requestFocus(); |
Adam Cohen | 0a4f900 | 2012-10-12 19:57:16 -0700 | [diff] [blame] | 142 | boolean permLocked = mLockPatternUtils.isPermanentlyLocked(); |
| 143 | mSecurityMessageDisplay.setMessage(permLocked ? R.string.kg_login_too_many_attempts : |
| 144 | R.string.kg_login_instructions, permLocked ? true : false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /** {@inheritDoc} */ |
| 148 | public void cleanUp() { |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 149 | if (mCheckingDialog != null) { |
| 150 | mCheckingDialog.hide(); |
| 151 | } |
Jim Miller | 8b886fa | 2011-01-13 17:56:35 -0800 | [diff] [blame] | 152 | mCallback = null; |
| 153 | mLockPatternUtils = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 154 | } |
| 155 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 156 | public void onClick(View v) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 157 | mCallback.userActivity(0); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 158 | if (v == mOk) { |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 159 | asyncCheckPassword(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 160 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 161 | } |
| 162 | |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 163 | private void postOnCheckPasswordResult(final boolean success) { |
| 164 | // ensure this runs on UI thread |
| 165 | mLogin.post(new Runnable() { |
| 166 | public void run() { |
| 167 | if (success) { |
| 168 | // clear out forgotten password |
| 169 | mLockPatternUtils.setPermanentlyLocked(false); |
| 170 | mLockPatternUtils.setLockPatternEnabled(false); |
| 171 | mLockPatternUtils.saveLockPattern(null); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 172 | |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 173 | // launch the 'choose lock pattern' activity so |
| 174 | // the user can pick a new one if they want to |
| 175 | Intent intent = new Intent(); |
| 176 | intent.setClassName(LOCK_PATTERN_PACKAGE, LOCK_PATTERN_CLASS); |
| 177 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Amith Yamasani | 2c7bc26 | 2012-11-05 16:46:02 -0800 | [diff] [blame] | 178 | mContext.startActivityAsUser(intent, |
| 179 | new UserHandle(mLockPatternUtils.getCurrentUser())); |
Jim Miller | 7751ff6 | 2014-01-14 18:57:03 -0800 | [diff] [blame] | 180 | mCallback.reportUnlockAttempt(true); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 181 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 182 | // dismiss keyguard |
| 183 | mCallback.dismiss(true); |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 184 | } else { |
Adam Cohen | 0a4f900 | 2012-10-12 19:57:16 -0700 | [diff] [blame] | 185 | mSecurityMessageDisplay.setMessage(R.string.kg_login_invalid_input, true); |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 186 | mPassword.setText(""); |
Jim Miller | 7751ff6 | 2014-01-14 18:57:03 -0800 | [diff] [blame] | 187 | mCallback.reportUnlockAttempt(false); |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | }); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 191 | } |
| 192 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 193 | @Override |
| 194 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 195 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 196 | && event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 197 | if (mLockPatternUtils.isPermanentlyLocked()) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 198 | mCallback.dismiss(false); |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 199 | } else { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 200 | // TODO: mCallback.forgotPattern(false); |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 201 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 202 | return true; |
| 203 | } |
| 204 | return super.dispatchKeyEvent(event); |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Given the string the user entered in the 'username' field, find |
| 209 | * the stored account that they probably intended. Prefer, in order: |
| 210 | * |
| 211 | * - an exact match for what was typed, or |
| 212 | * - a case-insensitive match for what was typed, or |
| 213 | * - if they didn't include a domain, an exact match of the username, or |
| 214 | * - if they didn't include a domain, a case-insensitive |
| 215 | * match of the username. |
| 216 | * |
| 217 | * If there is a tie for the best match, choose neither -- |
| 218 | * the user needs to be more specific. |
| 219 | * |
| 220 | * @return an account name from the database, or null if we can't |
| 221 | * find a single best match. |
| 222 | */ |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 223 | private Account findIntendedAccount(String username) { |
Amith Yamasani | 2c7bc26 | 2012-11-05 16:46:02 -0800 | [diff] [blame] | 224 | Account[] accounts = AccountManager.get(mContext).getAccountsByTypeAsUser("com.google", |
| 225 | new UserHandle(mLockPatternUtils.getCurrentUser())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 226 | |
| 227 | // Try to figure out which account they meant if they |
| 228 | // typed only the username (and not the domain), or got |
| 229 | // the case wrong. |
| 230 | |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 231 | Account bestAccount = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 232 | int bestScore = 0; |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 233 | for (Account a: accounts) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 234 | int score = 0; |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 235 | if (username.equals(a.name)) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 236 | score = 4; |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 237 | } else if (username.equalsIgnoreCase(a.name)) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 238 | score = 3; |
| 239 | } else if (username.indexOf('@') < 0) { |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 240 | int i = a.name.indexOf('@'); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 241 | if (i >= 0) { |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 242 | String aUsername = a.name.substring(0, i); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 243 | if (username.equals(aUsername)) { |
| 244 | score = 2; |
| 245 | } else if (username.equalsIgnoreCase(aUsername)) { |
| 246 | score = 1; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | if (score > bestScore) { |
| 251 | bestAccount = a; |
| 252 | bestScore = score; |
| 253 | } else if (score == bestScore) { |
| 254 | bestAccount = null; |
| 255 | } |
| 256 | } |
| 257 | return bestAccount; |
| 258 | } |
| 259 | |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 260 | private void asyncCheckPassword() { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 261 | mCallback.userActivity(AWAKE_POKE_MILLIS); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 262 | final String login = mLogin.getText().toString(); |
| 263 | final String password = mPassword.getText().toString(); |
Fred Quintana | 4e8f62f | 2009-03-24 22:48:13 -0700 | [diff] [blame] | 264 | Account account = findIntendedAccount(login); |
| 265 | if (account == null) { |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 266 | postOnCheckPasswordResult(false); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 267 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 268 | } |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 269 | getProgressDialog().show(); |
Fred Quintana | 261259b | 2009-10-02 17:19:24 -0700 | [diff] [blame] | 270 | Bundle options = new Bundle(); |
| 271 | options.putString(AccountManager.KEY_PASSWORD, password); |
Amith Yamasani | 2c7bc26 | 2012-11-05 16:46:02 -0800 | [diff] [blame] | 272 | AccountManager.get(mContext).confirmCredentialsAsUser(account, options, null /* activity */, |
Fred Quintana | 261259b | 2009-10-02 17:19:24 -0700 | [diff] [blame] | 273 | new AccountManagerCallback<Bundle>() { |
| 274 | public void run(AccountManagerFuture<Bundle> future) { |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 275 | try { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 276 | mCallback.userActivity(AWAKE_POKE_MILLIS); |
Fred Quintana | 261259b | 2009-10-02 17:19:24 -0700 | [diff] [blame] | 277 | final Bundle result = future.getResult(); |
| 278 | final boolean verified = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT); |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 279 | postOnCheckPasswordResult(verified); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 280 | } catch (OperationCanceledException e) { |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 281 | postOnCheckPasswordResult(false); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 282 | } catch (IOException e) { |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 283 | postOnCheckPasswordResult(false); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 284 | } catch (AuthenticatorException e) { |
Jim Miller | 1d587e3 | 2010-05-06 16:31:34 -0700 | [diff] [blame] | 285 | postOnCheckPasswordResult(false); |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 286 | } finally { |
| 287 | mLogin.post(new Runnable() { |
| 288 | public void run() { |
| 289 | getProgressDialog().hide(); |
| 290 | } |
| 291 | }); |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 292 | } |
Fred Quintana | 1c01c8bc | 2009-08-15 21:46:24 -0700 | [diff] [blame] | 293 | } |
Amith Yamasani | 2c7bc26 | 2012-11-05 16:46:02 -0800 | [diff] [blame] | 294 | }, null /* handler */, new UserHandle(mLockPatternUtils.getCurrentUser())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 295 | } |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 296 | |
| 297 | private Dialog getProgressDialog() { |
| 298 | if (mCheckingDialog == null) { |
| 299 | mCheckingDialog = new ProgressDialog(mContext); |
| 300 | mCheckingDialog.setMessage( |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 301 | mContext.getString(R.string.kg_login_checking_password)); |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 302 | mCheckingDialog.setIndeterminate(true); |
| 303 | mCheckingDialog.setCancelable(false); |
| 304 | mCheckingDialog.getWindow().setType( |
| 305 | WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); |
Karl Rosaen | 84999d6 | 2009-08-24 17:18:02 -0700 | [diff] [blame] | 306 | } |
| 307 | return mCheckingDialog; |
| 308 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 309 | |
| 310 | @Override |
| 311 | public void onPause() { |
| 312 | |
| 313 | } |
| 314 | |
| 315 | @Override |
Chris Wren | a042ac9 | 2012-11-07 11:37:06 -0500 | [diff] [blame] | 316 | public void onResume(int reason) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 317 | reset(); |
| 318 | } |
| 319 | |
Jim Miller | 0ff7f01 | 2012-10-11 20:40:01 -0700 | [diff] [blame] | 320 | @Override |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 321 | public void showUsabilityHint() { |
| 322 | } |
Chris Wren | c0ae9e6 | 2012-11-05 13:16:31 -0500 | [diff] [blame] | 323 | |
| 324 | @Override |
| 325 | public void showBouncer(int duration) { |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public void hideBouncer(int duration) { |
| 330 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 331 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 332 | |