Merge "Keyguard: Clean up security message display"
This commit is contained in:
@@ -200,7 +200,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
}
|
||||
}
|
||||
if (timeoutMs == 0) {
|
||||
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
|
||||
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId());
|
||||
}
|
||||
}
|
||||
resetPasswordText(true /* animate */, !matched /* announce deletion if no match */);
|
||||
@@ -220,13 +220,13 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int secondsRemaining = (int) (millisUntilFinished / 1000);
|
||||
mSecurityMessageDisplay.setMessage(
|
||||
R.string.kg_too_many_failed_attempts_countdown, true, secondsRemaining);
|
||||
mSecurityMessageDisplay.formatMessage(
|
||||
R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
mSecurityMessageDisplay.setMessage("", false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
resetState();
|
||||
}
|
||||
}.start();
|
||||
@@ -236,7 +236,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
if (mCallback != null) {
|
||||
mCallback.userActivity();
|
||||
}
|
||||
mSecurityMessageDisplay.setMessage("", false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,8 +273,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
if (reason != PROMPT_REASON_NONE) {
|
||||
int promtReasonStringRes = getPromtReasonStringRes(reason);
|
||||
if (promtReasonStringRes != 0) {
|
||||
mSecurityMessageDisplay.setMessage(promtReasonStringRes,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(promtReasonStringRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +281,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
@Override
|
||||
public void showMessage(String message, int color) {
|
||||
mSecurityMessageDisplay.setNextMessageColor(color);
|
||||
mSecurityMessageDisplay.setMessage(message, true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(message);
|
||||
}
|
||||
|
||||
protected abstract int getPromtReasonStringRes(int reason);
|
||||
|
||||
@@ -41,14 +41,10 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
|
||||
private static final long ANNOUNCEMENT_DELAY = 250;
|
||||
private static final int DEFAULT_COLOR = -1;
|
||||
|
||||
private static final int SECURITY_MESSAGE_DURATION = 5000;
|
||||
|
||||
private final KeyguardUpdateMonitor mUpdateMonitor;
|
||||
private final Handler mHandler;
|
||||
private final int mDefaultColor;
|
||||
|
||||
// Timeout before we reset the message to show charging/owner info
|
||||
long mTimeout = SECURITY_MESSAGE_DURATION;
|
||||
CharSequence mMessage;
|
||||
private int mNextMessageColor = DEFAULT_COLOR;
|
||||
|
||||
@@ -91,8 +87,8 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessage(CharSequence msg, boolean important) {
|
||||
if (!TextUtils.isEmpty(msg) && important) {
|
||||
public void setMessage(CharSequence msg) {
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
securityMessageChanged(msg);
|
||||
} else {
|
||||
clearMessage();
|
||||
@@ -100,28 +96,21 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessage(int resId, boolean important) {
|
||||
if (resId != 0 && important) {
|
||||
CharSequence message = getContext().getResources().getText(resId);
|
||||
securityMessageChanged(message);
|
||||
} else {
|
||||
clearMessage();
|
||||
public void setMessage(int resId) {
|
||||
CharSequence message = null;
|
||||
if (resId != 0) {
|
||||
message = getContext().getResources().getText(resId);
|
||||
}
|
||||
setMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessage(int resId, boolean important, Object... formatArgs) {
|
||||
if (resId != 0 && important) {
|
||||
String message = getContext().getString(resId, formatArgs);
|
||||
securityMessageChanged(message);
|
||||
} else {
|
||||
clearMessage();
|
||||
public void formatMessage(int resId, Object... formatArgs) {
|
||||
CharSequence message = null;
|
||||
if (resId != 0) {
|
||||
message = getContext().getString(resId, formatArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout(int timeoutMs) {
|
||||
mTimeout = timeoutMs;
|
||||
setMessage(message);
|
||||
}
|
||||
|
||||
public static SecurityMessageDisplay findSecurityMessageDisplay(View v) {
|
||||
@@ -142,10 +131,6 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
|
||||
private void securityMessageChanged(CharSequence message) {
|
||||
mMessage = message;
|
||||
update();
|
||||
mHandler.removeCallbacks(mClearMessageRunnable);
|
||||
if (mTimeout > 0) {
|
||||
mHandler.postDelayed(mClearMessageRunnable, mTimeout);
|
||||
}
|
||||
mHandler.removeCallbacksAndMessages(ANNOUNCE_TOKEN);
|
||||
mHandler.postAtTime(new AnnounceRunnable(this, getText()), ANNOUNCE_TOKEN,
|
||||
(SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY));
|
||||
|
||||
@@ -67,7 +67,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
@Override
|
||||
protected void resetState() {
|
||||
super.resetState();
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_pin_instructions, false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,7 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
|
||||
@Override
|
||||
protected void resetState() {
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_password_instructions, false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
final boolean wasDisabled = mPasswordEntry.isEnabled();
|
||||
setPasswordEntryEnabled(true);
|
||||
setPasswordEntryInputEnabled(true);
|
||||
|
||||
@@ -200,7 +200,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
}
|
||||
|
||||
private void displayDefaultSecurityMessage() {
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions, false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,7 +219,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
@Override
|
||||
public void onPatternStart() {
|
||||
mLockPatternView.removeCallbacks(mCancelPatternRunnable);
|
||||
mSecurityMessageDisplay.setMessage("", false);
|
||||
mSecurityMessageDisplay.setMessage("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,7 +314,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
}
|
||||
}
|
||||
if (timeoutMs == 0) {
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern);
|
||||
mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
@@ -331,8 +331,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
final int secondsRemaining = (int) (millisUntilFinished / 1000);
|
||||
mSecurityMessageDisplay.setMessage(
|
||||
R.string.kg_too_many_failed_attempts_countdown, true, secondsRemaining);
|
||||
mSecurityMessageDisplay.formatMessage(
|
||||
R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,26 +375,21 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
public void showPromptReason(int reason) {
|
||||
switch (reason) {
|
||||
case PROMPT_REASON_RESTART:
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern);
|
||||
break;
|
||||
case PROMPT_REASON_TIMEOUT:
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
break;
|
||||
case PROMPT_REASON_DEVICE_ADMIN:
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_device_admin,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_device_admin);
|
||||
break;
|
||||
case PROMPT_REASON_USER_REQUEST:
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_user_request,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_user_request);
|
||||
break;
|
||||
case PROMPT_REASON_NONE:
|
||||
break;
|
||||
default:
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern,
|
||||
true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -402,7 +397,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
@Override
|
||||
public void showMessage(String message, int color) {
|
||||
mSecurityMessageDisplay.setNextMessageColor(color);
|
||||
mSecurityMessageDisplay.setMessage(message, true /* important */);
|
||||
mSecurityMessageDisplay.setMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,7 +92,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
|
||||
color = info.getIconTint();
|
||||
}
|
||||
}
|
||||
mSecurityMessageDisplay.setMessage(msg, true);
|
||||
mSecurityMessageDisplay.setMessage(msg);
|
||||
mSimImageView.setImageTintList(ColorStateList.valueOf(color));
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,6 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
mSecurityMessageDisplay.setTimeout(0); // don't show ownerinfo/charging status by default
|
||||
if (mEcaView instanceof EmergencyCarrierArea) {
|
||||
((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
|
||||
}
|
||||
@@ -252,7 +251,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
|
||||
|
||||
if (entry.length() < 4) {
|
||||
// otherwise, display a message to the user, and don't submit.
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_invalid_sim_pin_hint, true);
|
||||
mSecurityMessageDisplay.setMessage(R.string.kg_invalid_sim_pin_hint);
|
||||
resetPasswordText(true /* animate */, true /* announce */);
|
||||
mCallback.userActivity();
|
||||
return;
|
||||
@@ -284,13 +283,13 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
|
||||
} else {
|
||||
// show message
|
||||
mSecurityMessageDisplay.setMessage(
|
||||
getPinPasswordErrorMessage(attemptsRemaining), true);
|
||||
getPinPasswordErrorMessage(attemptsRemaining));
|
||||
}
|
||||
} else {
|
||||
// "PIN operation failed!" - no idea what this was and no way to
|
||||
// find out. :/
|
||||
mSecurityMessageDisplay.setMessage(getContext().getString(
|
||||
R.string.kg_password_pin_failed), true);
|
||||
R.string.kg_password_pin_failed));
|
||||
}
|
||||
if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
|
||||
+ " CheckSimPin.onSimCheckResponse: " + result
|
||||
|
||||
@@ -108,7 +108,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
}
|
||||
resetPasswordText(true /* animate */, true /* announce */);
|
||||
if (msg != 0) {
|
||||
mSecurityMessageDisplay.setMessage(msg, true);
|
||||
mSecurityMessageDisplay.setMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
color = info.getIconTint();
|
||||
}
|
||||
}
|
||||
mSecurityMessageDisplay.setMessage(msg, true);
|
||||
mSecurityMessageDisplay.setMessage(msg);
|
||||
mSimImageView.setImageTintList(ColorStateList.valueOf(color));
|
||||
}
|
||||
mPasswordEntry.requestFocus();
|
||||
@@ -184,7 +184,6 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
mSecurityMessageDisplay.setTimeout(0); // don't show ownerinfo/charging status by default
|
||||
if (mEcaView instanceof EmergencyCarrierArea) {
|
||||
((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
|
||||
}
|
||||
@@ -341,11 +340,11 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
} else {
|
||||
// show message
|
||||
mSecurityMessageDisplay.setMessage(
|
||||
getPukPasswordErrorMessage(attemptsRemaining), true);
|
||||
getPukPasswordErrorMessage(attemptsRemaining));
|
||||
}
|
||||
} else {
|
||||
mSecurityMessageDisplay.setMessage(getContext().getString(
|
||||
R.string.kg_password_puk_failed), true);
|
||||
R.string.kg_password_puk_failed));
|
||||
}
|
||||
if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
|
||||
+ " UpdateSim.onSimCheckResponse: "
|
||||
|
||||
@@ -20,11 +20,9 @@ public interface SecurityMessageDisplay {
|
||||
|
||||
void setNextMessageColor(int color);
|
||||
|
||||
void setMessage(CharSequence msg, boolean important);
|
||||
void setMessage(CharSequence msg);
|
||||
|
||||
void setMessage(int resId, boolean important);
|
||||
void setMessage(int resId);
|
||||
|
||||
void setMessage(int resId, boolean important, Object... formatArgs);
|
||||
|
||||
void setTimeout(int timeout_ms);
|
||||
void formatMessage(int resId, Object... formatArgs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user