* commit '6cd8d30d8341006a38c08e39eb5b9ef7b88d22ba': Added a message to the keyguard bouncer
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -159,6 +159,17 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
|
||||
mSecurityContainer.showPrimarySecurityScreen(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -110,6 +110,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();
|
||||
|
||||
@@ -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) {
|
||||
@@ -319,6 +318,17 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -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 */,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -508,6 +508,13 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
return mSecurityViewFlipper.getCallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
if (mCurrentSecuritySelection != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecuritySelection).showPromptReason(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
mSecurityViewFlipper.showUsabilityHint();
|
||||
|
||||
@@ -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
|
||||
@@ -65,6 +68,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.
|
||||
*
|
||||
|
||||
@@ -130,6 +130,14 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard
|
||||
return (ksv != null) ? ksv.getCallback() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.showPromptReason(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.android.internal.telephony.IccCardConstants;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardConstants;
|
||||
import com.android.keyguard.KeyguardDisplayManager;
|
||||
import com.android.keyguard.KeyguardSecurityView;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
@@ -526,6 +527,17 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
public boolean isScreenOn() {
|
||||
return mDeviceInteractive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBouncerPromptReason() {
|
||||
int currentUser = ActivityManager.getCurrentUser();
|
||||
if ((mUpdateMonitor.getUserTrustIsManaged(currentUser)
|
||||
|| mUpdateMonitor.isUnlockWithFingerPrintPossible(currentUser))
|
||||
&& !mTrustManager.hasUserAuthenticatedSinceBoot(currentUser)) {
|
||||
return KeyguardSecurityView.PROMPT_REASON_RESTART;
|
||||
}
|
||||
return KeyguardSecurityView.PROMPT_REASON_NONE;
|
||||
}
|
||||
};
|
||||
|
||||
public void userActivity() {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardHostView;
|
||||
import com.android.keyguard.KeyguardSecurityView;
|
||||
import com.android.keyguard.R;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
|
||||
@@ -46,6 +47,7 @@ public class KeyguardBouncer {
|
||||
private ViewGroup mRoot;
|
||||
private boolean mShowingSoon;
|
||||
private Choreographer mChoreographer = Choreographer.getInstance();
|
||||
private int mBouncerPromptReason;
|
||||
|
||||
public KeyguardBouncer(Context context, ViewMediatorCallback callback,
|
||||
LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
|
||||
@@ -68,6 +70,8 @@ public class KeyguardBouncer {
|
||||
return;
|
||||
}
|
||||
|
||||
mBouncerPromptReason = mCallback.getBouncerPromptReason();
|
||||
|
||||
// Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole
|
||||
// Keyguard. If we need to authenticate, show the bouncer.
|
||||
if (!mKeyguardView.dismiss()) {
|
||||
@@ -84,12 +88,24 @@ public class KeyguardBouncer {
|
||||
public void run() {
|
||||
mRoot.setVisibility(View.VISIBLE);
|
||||
mKeyguardView.onResume();
|
||||
showPromptReason(mBouncerPromptReason);
|
||||
mKeyguardView.startAppearAnimation();
|
||||
mShowingSoon = false;
|
||||
mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
mKeyguardView.showPromptReason(reason);
|
||||
}
|
||||
|
||||
private void cancelShowRunnable() {
|
||||
mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, mShowRunnable, null);
|
||||
mShowingSoon = false;
|
||||
|
||||
Reference in New Issue
Block a user