diff options
Diffstat (limited to 'packages/Keyguard/src/com/android/keyguard')
12 files changed, 114 insertions, 10 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java index aa99a7b..0c6837f 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java @@ -216,6 +216,19 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout return mCallback; } + @Override + public void showPromptReason(int reason) { + if (reason != PROMPT_REASON_NONE) { + int promtReasonStringRes = getPromtReasonStringRes(reason); + if (promtReasonStringRes != 0) { + mSecurityMessageDisplay.setMessage(promtReasonStringRes, + true /* important */); + } + } + } + + protected abstract int getPromtReasonStringRes(int reason); + // Cause a VIRTUAL_KEY vibration public void doHapticKeyClick() { if (mEnableHaptics) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index cd4b24a..ff4e815 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -160,6 +160,17 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback { } /** + * Show a string explaining why the security view needs to be solved. + * + * @param reason a flag indicating which string should be shown, see + * {@link KeyguardSecurityView#PROMPT_REASON_NONE} + * and {@link KeyguardSecurityView#PROMPT_REASON_RESTART} + */ + public void showPromptReason(int reason) { + mSecurityContainer.showPromptReason(reason); + } + + /** * Dismisses the keyguard by going to the next screen or making it gone. * * @return True if the keyguard is done. diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java index c9ad728..2db87b3 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java @@ -111,6 +111,16 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView } @Override + protected int getPromtReasonStringRes(int reason) { + switch (reason) { + case PROMPT_REASON_RESTART: + return R.string.kg_prompt_reason_restart_password; + default: + return 0; + } + } + + @Override public void onPause() { super.onPause(); mImm.hideSoftInputFromWindow(getWindowToken(), 0); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java index 1bd0bb4..59a8ad5 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java @@ -85,10 +85,9 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } }; private Rect mTempRect = new Rect(); - private SecurityMessageDisplay mSecurityMessageDisplay; + private KeyguardMessageArea mSecurityMessageDisplay; private View mEcaView; private ViewGroup mContainer; - private KeyguardMessageArea mHelpMessage; private int mDisappearYTranslation; enum FooterMode { @@ -141,10 +140,10 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit // vibrate mode will be the same for the life of this screen mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled()); - mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this); + mSecurityMessageDisplay = + (KeyguardMessageArea) KeyguardMessageArea.findSecurityMessageDisplay(this); mEcaView = findViewById(R.id.keyguard_selector_fade_container); mContainer = (ViewGroup) findViewById(R.id.container); - mHelpMessage = (KeyguardMessageArea) findViewById(R.id.keyguard_message_area); EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button); if (button != null) { @@ -320,6 +319,17 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } @Override + public void showPromptReason(int reason) { + switch (reason) { + case PROMPT_REASON_RESTART: + mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern, + true /* important */); + break; + default: + } + } + + @Override public void startAppearAnimation() { enableClipping(false); setAlpha(1f); @@ -337,8 +347,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } }, this); - if (!TextUtils.isEmpty(mHelpMessage.getText())) { - mAppearAnimationUtils.createAnimation(mHelpMessage, 0, + if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) { + mAppearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0, AppearAnimationUtils.DEFAULT_APPEAR_DURATION, mAppearAnimationUtils.getStartTranslation(), true /* appearing */, @@ -366,8 +376,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } } }, KeyguardPatternView.this); - if (!TextUtils.isEmpty(mHelpMessage.getText())) { - mDisappearAnimationUtils.createAnimation(mHelpMessage, 0, + if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) { + mDisappearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0, 200, - mDisappearAnimationUtils.getStartTranslation() * 3, false /* appearing */, diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java index 23834a3..07947b1 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java @@ -93,6 +93,16 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView return super.onKeyDown(keyCode, event); } + @Override + protected int getPromtReasonStringRes(int reason) { + switch (reason) { + case PROMPT_REASON_RESTART: + return R.string.kg_prompt_reason_restart_pin; + default: + return 0; + } + } + private void performClick(View view) { view.performClick(); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java index d17b25a..f529ac0 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -509,6 +509,13 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe } @Override + public void showPromptReason(int reason) { + if (mCurrentSecuritySelection != SecurityMode.None) { + getSecurityView(mCurrentSecuritySelection).showPromptReason(reason); + } + } + + @Override public void showUsabilityHint() { mSecurityViewFlipper.showUsabilityHint(); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityView.java index 5b50236..5658a74 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityView.java @@ -21,6 +21,9 @@ public interface KeyguardSecurityView { static public final int SCREEN_ON = 1; static public final int VIEW_REVEALED = 2; + int PROMPT_REASON_NONE = 0; + int PROMPT_REASON_RESTART = 1; + /** * Interface back to keyguard to tell it when security * @param callback @@ -66,6 +69,14 @@ public interface KeyguardSecurityView { KeyguardSecurityCallback getCallback(); /** + * Show a string explaining why the security view needs to be solved. + * + * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} + * and {@link #PROMPT_REASON_RESTART} + */ + void showPromptReason(int reason); + + /** * Instruct the view to show usability hints, if any. * */ diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java index 54467f3..a0ff21b 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java @@ -131,6 +131,14 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard } @Override + public void showPromptReason(int reason) { + KeyguardSecurityView ksv = getSecurityView(); + if (ksv != null) { + ksv.showPromptReason(reason); + } + } + + @Override public void showUsabilityHint() { KeyguardSecurityView ksv = getSecurityView(); if (ksv != null) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java index f4acff8..aeac912 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java @@ -95,6 +95,12 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { } } + @Override + protected int getPromtReasonStringRes(int reason) { + // No message on SIM Pin + return 0; + } + private String getPinPasswordErrorMessage(int attemptsRemaining) { String displayMessage; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java index b85d966..af88239 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java @@ -140,6 +140,12 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { } } + @Override + protected int getPromtReasonStringRes(int reason) { + // No message on SIM Puk + return 0; + } + private String getPukPasswordErrorMessage(int attemptsRemaining) { String displayMessage; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 273f166..022338d 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -804,8 +804,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private void startListeningForFingerprint() { if (DEBUG) Log.v(TAG, "startListeningForFingerprint()"); int userId = ActivityManager.getCurrentUser(); - if (mFpm != null && mFpm.isHardwareDetected() && !isFingerprintDisabled(userId) - && mFpm.getEnrolledFingerprints(userId).size() > 0) { + if (isUnlockWithFingerPrintPossible(userId)) { if (mFingerprintCancelSignal != null) { mFingerprintCancelSignal.cancel(); } @@ -815,6 +814,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } } + public boolean isUnlockWithFingerPrintPossible(int userId) { + return mFpm != null && mFpm.isHardwareDetected() && !isFingerprintDisabled(userId) + && mFpm.getEnrolledFingerprints(userId).size() > 0; + } + private void stopListeningForFingerprint() { if (DEBUG) Log.v(TAG, "stopListeningForFingerprint()"); if (isFingerprintDetectionRunning()) { diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java index f5c809a..ff463c6 100644 --- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java @@ -81,4 +81,12 @@ public interface ViewMediatorCallback { * @return true if the screen is on */ boolean isScreenOn(); + + /** + * @return one of the reasons why the bouncer needs to be shown right now and the user can't use + * his normal unlock method like fingerprint or trust agents. See + * {@link KeyguardSecurityView#PROMPT_REASON_NONE} + * and {@link KeyguardSecurityView#PROMPT_REASON_RESTART}. + */ + int getBouncerPromptReason(); } |