Merge "[DO NOT MERGE] Do not dismiss keyguard after SIM PUK unlock" into qt-dev

This commit is contained in:
TreeHugger Robot
2022-09-15 16:39:42 +00:00
committed by Android (Google) Code Review
9 changed files with 73 additions and 18 deletions

View File

@@ -30,6 +30,7 @@ import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.internal.util.LatencyTracker; import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternChecker; import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -96,6 +97,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
protected abstract int getPasswordTextViewId(); protected abstract int getPasswordTextViewId();
protected abstract void resetState(); protected abstract void resetState();
protected abstract SecurityMode getSecurityMode();
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
@@ -203,7 +205,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
mCallback.reportUnlockAttempt(userId, true, 0); mCallback.reportUnlockAttempt(userId, true, 0);
if (dismissKeyguard) { if (dismissKeyguard) {
mDismissing = true; mDismissing = true;
mCallback.dismiss(true, userId); mCallback.dismiss(true, userId, getSecurityMode());
} }
} else { } else {
if (isValidPassword) { if (isValidPassword) {

View File

@@ -83,7 +83,7 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
// the user proved presence via some other way to the trust agent. // the user proved presence via some other way to the trust agent.
Log.i(TAG, "TrustAgent dismissed Keyguard."); Log.i(TAG, "TrustAgent dismissed Keyguard.");
} }
dismiss(false /* authenticated */, userId); dismiss(false /* authenticated */, userId, SecurityMode.Invalid);
} else { } else {
mViewMediatorCallback.playTrustedSound(); mViewMediatorCallback.playTrustedSound();
} }
@@ -187,12 +187,13 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
* @return True if the keyguard is done. * @return True if the keyguard is done.
*/ */
public boolean dismiss(int targetUserId) { public boolean dismiss(int targetUserId) {
return dismiss(false, targetUserId); return dismiss(false, targetUserId, getCurrentSecurityMode());
} }
public boolean handleBackKey() { public boolean handleBackKey() {
if (mSecurityContainer.getCurrentSecuritySelection() != SecurityMode.None) { if (mSecurityContainer.getCurrentSecuritySelection() != SecurityMode.None) {
mSecurityContainer.dismiss(false, KeyguardUpdateMonitor.getCurrentUser()); mSecurityContainer.dismiss(false, KeyguardUpdateMonitor.getCurrentUser(),
getCurrentSecurityMode());
return true; return true;
} }
return false; return false;
@@ -203,8 +204,10 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
} }
@Override @Override
public boolean dismiss(boolean authenticated, int targetUserId) { public boolean dismiss(boolean authenticated, int targetUserId,
return mSecurityContainer.showNextSecurityScreenOrFinish(authenticated, targetUserId); SecurityMode expectedSecurityMode) {
return mSecurityContainer.showNextSecurityScreenOrFinish(authenticated, targetUserId,
expectedSecurityMode);
} }
/** /**

View File

@@ -22,6 +22,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.settingslib.animation.AppearAnimationUtils; import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils; import com.android.settingslib.animation.DisappearAnimationUtils;
@@ -181,4 +182,9 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
public boolean hasOverlappingRendering() { public boolean hasOverlappingRendering() {
return false; return false;
} }
@Override
public SecurityMode getSecurityMode() {
return SecurityMode.PIN;
}
} }

View File

@@ -37,6 +37,7 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
import com.android.internal.widget.TextViewInputDisabler; import com.android.internal.widget.TextViewInputDisabler;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import java.util.List; import java.util.List;
/** /**
@@ -393,4 +394,9 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
} }
return bytes; return bytes;
} }
@Override
public SecurityMode getSecurityMode() {
return SecurityMode.Password;
}
} }

View File

@@ -39,6 +39,7 @@ import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternChecker; import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView; import com.android.internal.widget.LockPatternView;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.settingslib.animation.AppearAnimationCreator; import com.android.settingslib.animation.AppearAnimationCreator;
import com.android.settingslib.animation.AppearAnimationUtils; import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils; import com.android.settingslib.animation.DisappearAnimationUtils;
@@ -345,7 +346,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mCallback.reportUnlockAttempt(userId, true, 0); mCallback.reportUnlockAttempt(userId, true, 0);
if (dismissKeyguard) { if (dismissKeyguard) {
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mCallback.dismiss(true, userId); mCallback.dismiss(true, userId, SecurityMode.Pattern);
} }
} else { } else {
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);

View File

@@ -15,14 +15,17 @@
*/ */
package com.android.keyguard; package com.android.keyguard;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
public interface KeyguardSecurityCallback { public interface KeyguardSecurityCallback {
/** /**
* Dismiss the given security screen. * Dismiss the given security screen.
* @param securityVerified true if the user correctly entered credentials for the given screen. * @param securityVerified true if the user correctly entered credentials for the given screen.
* @param targetUserId a user that needs to be the foreground user at the dismissal completion. * @param targetUserId a user that needs to be the foreground user at the dismissal completion.
* @param expectedSecurityMode The security mode that is invoking this dismiss.
*/ */
void dismiss(boolean securityVerified, int targetUserId); void dismiss(boolean securityVerified, int targetUserId, SecurityMode expectedSecurityMode);
/** /**
* Manually report user activity to keep the device awake. * Manually report user activity to keep the device awake.

View File

@@ -99,7 +99,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
// Used to notify the container when something interesting happens. // Used to notify the container when something interesting happens.
public interface SecurityCallback { public interface SecurityCallback {
public boolean dismiss(boolean authenticated, int targetUserId); public boolean dismiss(boolean authenticated, int targetUserId,
SecurityMode expectedSecurityMode);
public void userActivity(); public void userActivity();
public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput); public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput);
@@ -473,10 +474,20 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
* @param authenticated true if the user entered the correct authentication * @param authenticated true if the user entered the correct authentication
* @param targetUserId a user that needs to be the foreground user at the finish (if called) * @param targetUserId a user that needs to be the foreground user at the finish (if called)
* completion. * completion.
* @param expectedSecurityMode SecurityMode that is invoking this request. SecurityMode.Invalid
* indicates that no check should be done
* @return true if keyguard is done * @return true if keyguard is done
*/ */
boolean showNextSecurityScreenOrFinish(boolean authenticated, int targetUserId) { boolean showNextSecurityScreenOrFinish(boolean authenticated, int targetUserId,
SecurityMode expectedSecurityMode) {
if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")"); if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
if (expectedSecurityMode != SecurityMode.Invalid
&& expectedSecurityMode != getCurrentSecurityMode()) {
Log.w(TAG, "Attempted to invoke showNextSecurityScreenOrFinish with securityMode "
+ expectedSecurityMode + ", but current mode is " + getCurrentSecurityMode());
return false;
}
boolean finish = false; boolean finish = false;
boolean strongAuth = false; boolean strongAuth = false;
int eventSubtype = -1; int eventSubtype = -1;
@@ -591,8 +602,13 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
} }
} }
public void dismiss(boolean authenticated, int targetId) { /**
mSecurityCallback.dismiss(authenticated, targetId); * Potentially dismiss the current security screen, after validating that all device
* security has been unlocked. Otherwise show the next screen.
*/
public void dismiss(boolean authenticated, int targetId,
SecurityMode expectedSecurityMode) {
mSecurityCallback.dismiss(authenticated, targetId, expectedSecurityMode);
} }
public boolean isVerifyUnlockOnly() { public boolean isVerifyUnlockOnly() {
@@ -633,7 +649,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
@Override @Override
public boolean isVerifyUnlockOnly() { return false; } public boolean isVerifyUnlockOnly() { return false; }
@Override @Override
public void dismiss(boolean securityVerified, int targetUserId) { } public void dismiss(boolean securityVerified, int targetUserId,
SecurityMode expectedSecurityMode) { }
@Override @Override
public void reset() {} public void reset() {}
}; };
@@ -683,8 +700,9 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
return mCurrentSecuritySelection; return mCurrentSecuritySelection;
} }
public void dismiss(boolean authenticated, int targetUserId) { public void dismiss(boolean authenticated, int targetUserId,
mCallback.dismiss(authenticated, targetUserId); SecurityMode expectedSecurityMode) {
mCallback.dismiss(authenticated, targetUserId, expectedSecurityMode);
} }
public boolean needsInput() { public boolean needsInput() {

View File

@@ -41,6 +41,8 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
/** /**
* Displays a PIN pad for unlocking. * Displays a PIN pad for unlocking.
@@ -342,7 +344,8 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
mRemainingAttempts = -1; mRemainingAttempts = -1;
mShowDefaultMessage = true; mShowDefaultMessage = true;
if (mCallback != null) { if (mCallback != null) {
mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser(),
SecurityMode.SimPin);
} }
} else { } else {
mShowDefaultMessage = false; mShowDefaultMessage = false;
@@ -390,5 +393,10 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
return getContext().getString( return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_sim_pin_unlock); com.android.internal.R.string.keyguard_accessibility_sim_pin_unlock);
} }
@Override
public SecurityMode getSecurityMode() {
return SecurityMode.SimPin;
}
} }

View File

@@ -40,6 +40,7 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
/** /**
@@ -78,7 +79,8 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
// mCallback can be null if onSimStateChanged callback is called when keyguard // mCallback can be null if onSimStateChanged callback is called when keyguard
// isn't active. // isn't active.
if (mCallback != null) { if (mCallback != null) {
mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser(),
SecurityMode.SimPuk);
} }
break; break;
} }
@@ -413,7 +415,8 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
mRemainingAttempts = -1; mRemainingAttempts = -1;
mShowDefaultMessage = true; mShowDefaultMessage = true;
if (mCallback != null) { if (mCallback != null) {
mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser(),
SecurityMode.SimPuk);
} }
} else { } else {
mShowDefaultMessage = false; mShowDefaultMessage = false;
@@ -468,6 +471,11 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
return getContext().getString( return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_sim_puk_unlock); com.android.internal.R.string.keyguard_accessibility_sim_puk_unlock);
} }
@Override
public SecurityMode getSecurityMode() {
return SecurityMode.SimPuk;
}
} }