* 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;
|
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
|
// Cause a VIRTUAL_KEY vibration
|
||||||
public void doHapticKeyClick() {
|
public void doHapticKeyClick() {
|
||||||
if (mEnableHaptics) {
|
if (mEnableHaptics) {
|
||||||
|
|||||||
@@ -159,6 +159,17 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
|
|||||||
mSecurityContainer.showPrimarySecurityScreen(false);
|
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.
|
* 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
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|||||||
@@ -85,10 +85,9 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Rect mTempRect = new Rect();
|
private Rect mTempRect = new Rect();
|
||||||
private SecurityMessageDisplay mSecurityMessageDisplay;
|
private KeyguardMessageArea mSecurityMessageDisplay;
|
||||||
private View mEcaView;
|
private View mEcaView;
|
||||||
private ViewGroup mContainer;
|
private ViewGroup mContainer;
|
||||||
private KeyguardMessageArea mHelpMessage;
|
|
||||||
private int mDisappearYTranslation;
|
private int mDisappearYTranslation;
|
||||||
|
|
||||||
enum FooterMode {
|
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
|
// vibrate mode will be the same for the life of this screen
|
||||||
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
|
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
|
||||||
|
|
||||||
mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
|
mSecurityMessageDisplay =
|
||||||
|
(KeyguardMessageArea) KeyguardMessageArea.findSecurityMessageDisplay(this);
|
||||||
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
||||||
mContainer = (ViewGroup) findViewById(R.id.container);
|
mContainer = (ViewGroup) findViewById(R.id.container);
|
||||||
mHelpMessage = (KeyguardMessageArea) findViewById(R.id.keyguard_message_area);
|
|
||||||
|
|
||||||
EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
|
EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
@@ -319,6 +318,17 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
return mCallback;
|
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
|
@Override
|
||||||
public void startAppearAnimation() {
|
public void startAppearAnimation() {
|
||||||
enableClipping(false);
|
enableClipping(false);
|
||||||
@@ -337,8 +347,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
if (!TextUtils.isEmpty(mHelpMessage.getText())) {
|
if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) {
|
||||||
mAppearAnimationUtils.createAnimation(mHelpMessage, 0,
|
mAppearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0,
|
||||||
AppearAnimationUtils.DEFAULT_APPEAR_DURATION,
|
AppearAnimationUtils.DEFAULT_APPEAR_DURATION,
|
||||||
mAppearAnimationUtils.getStartTranslation(),
|
mAppearAnimationUtils.getStartTranslation(),
|
||||||
true /* appearing */,
|
true /* appearing */,
|
||||||
@@ -366,8 +376,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, KeyguardPatternView.this);
|
}, KeyguardPatternView.this);
|
||||||
if (!TextUtils.isEmpty(mHelpMessage.getText())) {
|
if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) {
|
||||||
mDisappearAnimationUtils.createAnimation(mHelpMessage, 0,
|
mDisappearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0,
|
||||||
200,
|
200,
|
||||||
- mDisappearAnimationUtils.getStartTranslation() * 3,
|
- mDisappearAnimationUtils.getStartTranslation() * 3,
|
||||||
false /* appearing */,
|
false /* appearing */,
|
||||||
|
|||||||
@@ -93,6 +93,16 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
|
|||||||
return super.onKeyDown(keyCode, event);
|
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) {
|
private void performClick(View view) {
|
||||||
view.performClick();
|
view.performClick();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,6 +508,13 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
|||||||
return mSecurityViewFlipper.getCallback();
|
return mSecurityViewFlipper.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showPromptReason(int reason) {
|
||||||
|
if (mCurrentSecuritySelection != SecurityMode.None) {
|
||||||
|
getSecurityView(mCurrentSecuritySelection).showPromptReason(reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showUsabilityHint() {
|
public void showUsabilityHint() {
|
||||||
mSecurityViewFlipper.showUsabilityHint();
|
mSecurityViewFlipper.showUsabilityHint();
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public interface KeyguardSecurityView {
|
|||||||
static public final int SCREEN_ON = 1;
|
static public final int SCREEN_ON = 1;
|
||||||
static public final int VIEW_REVEALED = 2;
|
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
|
* Interface back to keyguard to tell it when security
|
||||||
* @param callback
|
* @param callback
|
||||||
@@ -65,6 +68,14 @@ public interface KeyguardSecurityView {
|
|||||||
*/
|
*/
|
||||||
KeyguardSecurityCallback getCallback();
|
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.
|
* 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;
|
return (ksv != null) ? ksv.getCallback() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showPromptReason(int reason) {
|
||||||
|
KeyguardSecurityView ksv = getSecurityView();
|
||||||
|
if (ksv != null) {
|
||||||
|
ksv.showPromptReason(reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showUsabilityHint() {
|
public void showUsabilityHint() {
|
||||||
KeyguardSecurityView ksv = getSecurityView();
|
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) {
|
private String getPinPasswordErrorMessage(int attemptsRemaining) {
|
||||||
String displayMessage;
|
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) {
|
private String getPukPasswordErrorMessage(int attemptsRemaining) {
|
||||||
String displayMessage;
|
String displayMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -804,8 +804,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
private void startListeningForFingerprint() {
|
private void startListeningForFingerprint() {
|
||||||
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
|
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
|
||||||
int userId = ActivityManager.getCurrentUser();
|
int userId = ActivityManager.getCurrentUser();
|
||||||
if (mFpm != null && mFpm.isHardwareDetected() && !isFingerprintDisabled(userId)
|
if (isUnlockWithFingerPrintPossible(userId)) {
|
||||||
&& mFpm.getEnrolledFingerprints(userId).size() > 0) {
|
|
||||||
if (mFingerprintCancelSignal != null) {
|
if (mFingerprintCancelSignal != null) {
|
||||||
mFingerprintCancelSignal.cancel();
|
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() {
|
private void stopListeningForFingerprint() {
|
||||||
if (DEBUG) Log.v(TAG, "stopListeningForFingerprint()");
|
if (DEBUG) Log.v(TAG, "stopListeningForFingerprint()");
|
||||||
if (isFingerprintDetectionRunning()) {
|
if (isFingerprintDetectionRunning()) {
|
||||||
|
|||||||
@@ -81,4 +81,12 @@ public interface ViewMediatorCallback {
|
|||||||
* @return true if the screen is on
|
* @return true if the screen is on
|
||||||
*/
|
*/
|
||||||
boolean isScreenOn();
|
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.internal.widget.LockPatternUtils;
|
||||||
import com.android.keyguard.KeyguardConstants;
|
import com.android.keyguard.KeyguardConstants;
|
||||||
import com.android.keyguard.KeyguardDisplayManager;
|
import com.android.keyguard.KeyguardDisplayManager;
|
||||||
|
import com.android.keyguard.KeyguardSecurityView;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
import com.android.keyguard.ViewMediatorCallback;
|
import com.android.keyguard.ViewMediatorCallback;
|
||||||
@@ -526,6 +527,17 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
public boolean isScreenOn() {
|
public boolean isScreenOn() {
|
||||||
return mDeviceInteractive;
|
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() {
|
public void userActivity() {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.view.accessibility.AccessibilityEvent;
|
|||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.keyguard.KeyguardHostView;
|
import com.android.keyguard.KeyguardHostView;
|
||||||
|
import com.android.keyguard.KeyguardSecurityView;
|
||||||
import com.android.keyguard.R;
|
import com.android.keyguard.R;
|
||||||
import com.android.keyguard.ViewMediatorCallback;
|
import com.android.keyguard.ViewMediatorCallback;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ public class KeyguardBouncer {
|
|||||||
private ViewGroup mRoot;
|
private ViewGroup mRoot;
|
||||||
private boolean mShowingSoon;
|
private boolean mShowingSoon;
|
||||||
private Choreographer mChoreographer = Choreographer.getInstance();
|
private Choreographer mChoreographer = Choreographer.getInstance();
|
||||||
|
private int mBouncerPromptReason;
|
||||||
|
|
||||||
public KeyguardBouncer(Context context, ViewMediatorCallback callback,
|
public KeyguardBouncer(Context context, ViewMediatorCallback callback,
|
||||||
LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
|
LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
|
||||||
@@ -68,6 +70,8 @@ public class KeyguardBouncer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mBouncerPromptReason = mCallback.getBouncerPromptReason();
|
||||||
|
|
||||||
// Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole
|
// 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.
|
// Keyguard. If we need to authenticate, show the bouncer.
|
||||||
if (!mKeyguardView.dismiss()) {
|
if (!mKeyguardView.dismiss()) {
|
||||||
@@ -84,12 +88,24 @@ public class KeyguardBouncer {
|
|||||||
public void run() {
|
public void run() {
|
||||||
mRoot.setVisibility(View.VISIBLE);
|
mRoot.setVisibility(View.VISIBLE);
|
||||||
mKeyguardView.onResume();
|
mKeyguardView.onResume();
|
||||||
|
showPromptReason(mBouncerPromptReason);
|
||||||
mKeyguardView.startAppearAnimation();
|
mKeyguardView.startAppearAnimation();
|
||||||
mShowingSoon = false;
|
mShowingSoon = false;
|
||||||
mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
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() {
|
private void cancelShowRunnable() {
|
||||||
mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, mShowRunnable, null);
|
mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, mShowRunnable, null);
|
||||||
mShowingSoon = false;
|
mShowingSoon = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user