summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2014-12-19 19:58:13 +0100
committerJorim Jaggi <jjaggi@google.com>2015-01-07 15:01:00 +0100
commitcd3b5b52ac227c4f69879102a31a22d0258002e6 (patch)
tree18099f3aa2eb1242dc362f37a89ddf20d2ef4d8a /packages/Keyguard
parent8a8941aa1be01fbfca8c4540298cc5de12b6538b (diff)
downloadframeworks_base-cd3b5b52ac227c4f69879102a31a22d0258002e6.zip
frameworks_base-cd3b5b52ac227c4f69879102a31a22d0258002e6.tar.gz
frameworks_base-cd3b5b52ac227c4f69879102a31a22d0258002e6.tar.bz2
Remove dead code #5: Remove KeyguardAccountView
Change-Id: I04431625e922e9554ce55b852bd8ee571049339b
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/res/layout/keyguard_account_view.xml88
-rw-r--r--packages/Keyguard/res/values/strings.xml14
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java341
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java16
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java11
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java5
6 files changed, 2 insertions, 473 deletions
diff --git a/packages/Keyguard/res/layout/keyguard_account_view.xml b/packages/Keyguard/res/layout/keyguard_account_view.xml
deleted file mode 100644
index bde2ec6..0000000
--- a/packages/Keyguard/res/layout/keyguard_account_view.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-**
-** Copyright 2012, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License")
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<com.android.keyguard.KeyguardAccountView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/res-auto"
- android:id="@+id/keyguard_account_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- androidprv:layout_maxWidth="@dimen/keyguard_security_width"
- androidprv:layout_maxHeight="@dimen/keyguard_security_height"
- android:orientation="vertical">
-
- <include layout="@layout/keyguard_message_area"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1">
-
- <EditText
- android:id="@+id/login"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dip"
- android:layout_marginStart="7dip"
- android:layout_marginEnd="7dip"
- android:layout_alignParentTop="true"
- android:hint="@string/kg_login_username_hint"
- android:inputType="textEmailAddress"
- />
-
- <EditText
- android:id="@+id/password"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/login"
- android:layout_toLeftOf="@+id/ok"
- android:layout_marginTop="15dip"
- android:layout_marginStart="7dip"
- android:layout_marginEnd="7dip"
- android:inputType="textPassword"
- android:hint="@string/kg_login_password_hint"
- android:nextFocusRight="@+id/ok"
- android:nextFocusDown="@+id/ok"
- />
-
- <!-- ok below password, aligned to right of screen -->
- <Button
- android:id="@+id/ok"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="7dip"
- android:layout_alignParentEnd="true"
- android:layout_below="@id/login"
- android:text="@string/kg_login_submit_button"
- />
-
- </RelativeLayout>
-
- <!-- no room for ECA on this screen right now
- <include layout="@layout/keyguard_eca"
- android:id="@+id/keyguard_selector_fade_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="bottom|center_horizontal"
- android:gravity="center_horizontal" />
- -->
-
-</com.android.keyguard.KeyguardAccountView>
diff --git a/packages/Keyguard/res/values/strings.xml b/packages/Keyguard/res/values/strings.xml
index ba693f6..25fd10e 100644
--- a/packages/Keyguard/res/values/strings.xml
+++ b/packages/Keyguard/res/values/strings.xml
@@ -172,20 +172,6 @@
<string name="kg_invalid_confirm_pin_hint" product="default">PIN codes does not match</string>
<!-- Message shown when the user exceeds the maximum number of pattern attempts -->
<string name="kg_login_too_many_attempts">Too many pattern attempts</string>
- <!-- Instructions show in account unlock screen allowing user to enter their email password -->
- <string name="kg_login_instructions">To unlock, sign in with your Google account.</string>
- <!-- Hint shown in TextView in account unlock screen of keyguard -->
- <string name="kg_login_username_hint">Username (email)</string>
- <!-- Hint shown in TextView in account unlock screen of keyguard -->
- <string name="kg_login_password_hint">Password</string>
- <!-- Label shown on sign in button on account unlock screen of keyguard -->
- <string name="kg_login_submit_button">Sign in</string>
- <!-- Message shown when the user enters an invalid username/password combination in account unlock screen of keyguard -->
- <string name="kg_login_invalid_input">Invalid username or password.</string>
- <!-- Hint text shown when user has too many failed password attempts in account unlock screen of keyguard -->
- <string name="kg_login_account_recovery_hint">Forgot your username or password\?\nVisit <b>google.com/accounts/recovery</b>.</string>
- <!-- Message shown while device checks username/password in account unlock screen of keyguard -->
- <string name="kg_login_checking_password">Checking account\u2026</string>
<!-- Message shown in dialog when max number of attempts are reached for PIN screen of keyguard -->
<string name="kg_too_many_failed_pin_attempts_dialog_message">
You have incorrectly typed your PIN <xliff:g id="number">%d</xliff:g> times.
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java
deleted file mode 100644
index 5cb3b9b..0000000
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.keyguard;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.text.Editable;
-import android.text.InputFilter;
-import android.text.LoginFilter;
-import android.text.TextWatcher;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-
-import com.android.internal.widget.LockPatternUtils;
-
-import java.io.IOException;
-
-/**
- * When the user forgets their password a bunch of times, we fall back on their
- * account's login/password to unlock the phone (and reset their lock pattern).
- */
-public class KeyguardAccountView extends LinearLayout implements KeyguardSecurityView,
- View.OnClickListener, TextWatcher {
- private static final String LOCK_PATTERN_PACKAGE = "com.android.settings";
- private static final String LOCK_PATTERN_CLASS = LOCK_PATTERN_PACKAGE + ".ChooseLockGeneric";
-
- private KeyguardSecurityCallback mCallback;
- private LockPatternUtils mLockPatternUtils;
- private EditText mLogin;
- private EditText mPassword;
- private Button mOk;
- public boolean mEnableFallback;
- private SecurityMessageDisplay mSecurityMessageDisplay;
-
- /**
- * Shown while making asynchronous check of password.
- */
- private ProgressDialog mCheckingDialog;
-
- public KeyguardAccountView(Context context) {
- this(context, null, 0);
- }
-
- public KeyguardAccountView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public KeyguardAccountView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mLockPatternUtils = new LockPatternUtils(getContext());
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mLogin = (EditText) findViewById(R.id.login);
- mLogin.setFilters(new InputFilter[] { new LoginFilter.UsernameFilterGeneric() } );
- mLogin.addTextChangedListener(this);
-
- mPassword = (EditText) findViewById(R.id.password);
- mPassword.addTextChangedListener(this);
-
- mOk = (Button) findViewById(R.id.ok);
- mOk.setOnClickListener(this);
-
- mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
- reset();
- }
-
- public void setKeyguardCallback(KeyguardSecurityCallback callback) {
- mCallback = callback;
- }
-
- public void setLockPatternUtils(LockPatternUtils utils) {
- mLockPatternUtils = utils;
- }
-
- public KeyguardSecurityCallback getCallback() {
- return mCallback;
- }
-
-
- public void afterTextChanged(Editable s) {
- }
-
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- if (mCallback != null) {
- mCallback.userActivity();
- }
- }
-
- @Override
- protected boolean onRequestFocusInDescendants(int direction,
- Rect previouslyFocusedRect) {
- // send focus to the login field
- return mLogin.requestFocus(direction, previouslyFocusedRect);
- }
-
- public boolean needsInput() {
- return true;
- }
-
- public void reset() {
- // start fresh
- mLogin.setText("");
- mPassword.setText("");
- mLogin.requestFocus();
- boolean permLocked = mLockPatternUtils.isPermanentlyLocked();
- mSecurityMessageDisplay.setMessage(permLocked ? R.string.kg_login_too_many_attempts :
- R.string.kg_login_instructions, permLocked ? true : false);
- }
-
- /** {@inheritDoc} */
- public void cleanUp() {
- if (mCheckingDialog != null) {
- mCheckingDialog.hide();
- }
- mCallback = null;
- mLockPatternUtils = null;
- }
-
- public void onClick(View v) {
- mCallback.userActivity();
- if (v == mOk) {
- asyncCheckPassword();
- }
- }
-
- private void postOnCheckPasswordResult(final boolean success) {
- // ensure this runs on UI thread
- mLogin.post(new Runnable() {
- public void run() {
- if (success) {
- // clear out forgotten password
- mLockPatternUtils.setPermanentlyLocked(false);
- mLockPatternUtils.setLockPatternEnabled(false);
- mLockPatternUtils.saveLockPattern(null);
-
- // launch the 'choose lock pattern' activity so
- // the user can pick a new one if they want to
- Intent intent = new Intent();
- intent.setClassName(LOCK_PATTERN_PACKAGE, LOCK_PATTERN_CLASS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivityAsUser(intent,
- new UserHandle(mLockPatternUtils.getCurrentUser()));
- mCallback.reportUnlockAttempt(true);
-
- // dismiss keyguard
- mCallback.dismiss(true);
- } else {
- mSecurityMessageDisplay.setMessage(R.string.kg_login_invalid_input, true);
- mPassword.setText("");
- mCallback.reportUnlockAttempt(false);
- }
- }
- });
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_DOWN
- && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
- if (mLockPatternUtils.isPermanentlyLocked()) {
- mCallback.dismiss(false);
- } else {
- // TODO: mCallback.forgotPattern(false);
- }
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
- /**
- * Given the string the user entered in the 'username' field, find
- * the stored account that they probably intended. Prefer, in order:
- *
- * - an exact match for what was typed, or
- * - a case-insensitive match for what was typed, or
- * - if they didn't include a domain, an exact match of the username, or
- * - if they didn't include a domain, a case-insensitive
- * match of the username.
- *
- * If there is a tie for the best match, choose neither --
- * the user needs to be more specific.
- *
- * @return an account name from the database, or null if we can't
- * find a single best match.
- */
- private Account findIntendedAccount(String username) {
- Account[] accounts = AccountManager.get(mContext).getAccountsByTypeAsUser("com.google",
- new UserHandle(mLockPatternUtils.getCurrentUser()));
-
- // Try to figure out which account they meant if they
- // typed only the username (and not the domain), or got
- // the case wrong.
-
- Account bestAccount = null;
- int bestScore = 0;
- for (Account a: accounts) {
- int score = 0;
- if (username.equals(a.name)) {
- score = 4;
- } else if (username.equalsIgnoreCase(a.name)) {
- score = 3;
- } else if (username.indexOf('@') < 0) {
- int i = a.name.indexOf('@');
- if (i >= 0) {
- String aUsername = a.name.substring(0, i);
- if (username.equals(aUsername)) {
- score = 2;
- } else if (username.equalsIgnoreCase(aUsername)) {
- score = 1;
- }
- }
- }
- if (score > bestScore) {
- bestAccount = a;
- bestScore = score;
- } else if (score == bestScore) {
- bestAccount = null;
- }
- }
- return bestAccount;
- }
-
- private void asyncCheckPassword() {
- mCallback.userActivity();
- final String login = mLogin.getText().toString();
- final String password = mPassword.getText().toString();
- Account account = findIntendedAccount(login);
- if (account == null) {
- postOnCheckPasswordResult(false);
- return;
- }
- getProgressDialog().show();
- Bundle options = new Bundle();
- options.putString(AccountManager.KEY_PASSWORD, password);
- AccountManager.get(mContext).confirmCredentialsAsUser(account, options, null /* activity */,
- new AccountManagerCallback<Bundle>() {
- public void run(AccountManagerFuture<Bundle> future) {
- try {
- mCallback.userActivity();
- final Bundle result = future.getResult();
- final boolean verified = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
- postOnCheckPasswordResult(verified);
- } catch (OperationCanceledException e) {
- postOnCheckPasswordResult(false);
- } catch (IOException e) {
- postOnCheckPasswordResult(false);
- } catch (AuthenticatorException e) {
- postOnCheckPasswordResult(false);
- } finally {
- mLogin.post(new Runnable() {
- public void run() {
- getProgressDialog().hide();
- }
- });
- }
- }
- }, null /* handler */, new UserHandle(mLockPatternUtils.getCurrentUser()));
- }
-
- private Dialog getProgressDialog() {
- if (mCheckingDialog == null) {
- mCheckingDialog = new ProgressDialog(mContext);
- mCheckingDialog.setMessage(
- mContext.getString(R.string.kg_login_checking_password));
- mCheckingDialog.setIndeterminate(true);
- mCheckingDialog.setCancelable(false);
- mCheckingDialog.getWindow().setType(
- WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
- }
- return mCheckingDialog;
- }
-
- @Override
- public void onPause() {
-
- }
-
- @Override
- public void onResume(int reason) {
- reset();
- }
-
- @Override
- public void showUsabilityHint() {
- }
-
- @Override
- public void showBouncer(int duration) {
- }
-
- @Override
- public void hideBouncer(int duration) {
- }
-
- @Override
- public void startAppearAnimation() {
- // TODO.
- }
-
- @Override
- public boolean startDisappearAnimation(Runnable finishRunnable) {
- return false;
- }
-}
-
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
index 50377c3..50a6adf 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -41,7 +41,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
private static final int USER_TYPE_SECONDARY_USER = 3;
private KeyguardSecurityModel mSecurityModel;
- private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView
private LockPatternUtils mLockPatternUtils;
private KeyguardSecurityViewFlipper mSecurityViewFlipper;
@@ -198,7 +197,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
messageId = R.string.kg_too_many_failed_password_attempts_dialog_message;
break;
// These don't have timeout dialogs.
- case Account:
case Invalid:
case None:
case SimPin:
@@ -305,17 +303,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
} else {
showTimeout =
(failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
- if (usingPattern && mEnableFallback) {
- if (failedAttempts == failedAttemptWarning) {
- showAlmostAtAccountLoginDialog();
- showTimeout = false; // don't show both dialogs
- } else if (failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) {
- mLockPatternUtils.setPermanentlyLocked(true);
- showSecurityScreen(SecurityMode.Account);
- // don't show timeout dialog because we show account unlock screen next
- showTimeout = false;
- }
- }
}
monitor.reportFailedUnlockAttempt();
mLockPatternUtils.reportFailedPasswordAttempt();
@@ -377,7 +364,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
case Pattern:
case Password:
case PIN:
- case Account:
finish = true;
break;
@@ -522,7 +508,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
case Pattern: return R.id.keyguard_pattern_view;
case PIN: return R.id.keyguard_pin_view;
case Password: return R.id.keyguard_password_view;
- case Account: return R.id.keyguard_account_view;
case SimPin: return R.id.keyguard_sim_pin_view;
case SimPuk: return R.id.keyguard_sim_puk_view;
}
@@ -534,7 +519,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
case Pattern: return R.layout.keyguard_pattern_view;
case PIN: return R.layout.keyguard_pin_view;
case Password: return R.layout.keyguard_password_view;
- case Account: return R.layout.keyguard_account_view;
case SimPin: return R.layout.keyguard_sim_pin_view;
case SimPuk: return R.layout.keyguard_sim_puk_view;
default:
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
index adf8dd2..11f7c63 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
@@ -38,7 +38,6 @@ public class KeyguardSecurityModel {
Pattern, // Unlock by drawing a pattern.
Password, // Unlock by entering an alphanumeric password
PIN, // Strictly numeric password
- Account, // Unlock by entering an account's login and password.
SimPin, // Unlock by entering a sim pin.
SimPuk // Unlock by entering a sim puk
}
@@ -82,10 +81,8 @@ public class KeyguardSecurityModel {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED:
- if (mLockPatternUtils.isLockPatternEnabled()) {
- mode = mLockPatternUtils.isPermanentlyLocked() ?
- SecurityMode.Account : SecurityMode.Pattern;
- }
+ mode = mLockPatternUtils.isLockPatternEnabled() ?
+ SecurityMode.Pattern : SecurityMode.None;
break;
default:
@@ -114,10 +111,6 @@ public class KeyguardSecurityModel {
* @return backup method or current security mode
*/
SecurityMode getBackupSecurityMode(SecurityMode mode) {
- switch(mode) {
- case Pattern:
- return SecurityMode.Account;
- }
return mode; // no backup, return current security mode
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
index 91a14c8..b303dca 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
@@ -132,11 +132,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
}
public boolean handleBackKey() {
- if (mSecurityContainer.getCurrentSecuritySelection() == SecurityMode.Account) {
- // go back to primary screen
- mSecurityContainer.showPrimarySecurityScreen(false /*turningOff*/);
- return true;
- }
if (mSecurityContainer.getCurrentSecuritySelection() != SecurityMode.None) {
mSecurityContainer.dismiss(false);
return true;