Merge "Display grant trust messages on the lock screen"

This commit is contained in:
Beverly Tai
2022-02-08 21:22:52 +00:00
committed by Android (Google) Code Review
2 changed files with 58 additions and 1 deletions

View File

@@ -143,6 +143,7 @@ public class KeyguardIndicationController {
private String mRestingIndication;
private String mAlignmentIndication;
private CharSequence mTrustGrantedIndication;
private CharSequence mTransientIndication;
private CharSequence mBiometricMessage;
protected ColorStateList mInitialTextColorState;
@@ -609,7 +610,9 @@ public class KeyguardIndicationController {
*/
@VisibleForTesting
String getTrustGrantedIndication() {
return mContext.getString(R.string.keyguard_indication_trust_unlocked);
return TextUtils.isEmpty(mTrustGrantedIndication)
? mContext.getString(R.string.keyguard_indication_trust_unlocked)
: mTrustGrantedIndication.toString();
}
/**
@@ -909,6 +912,7 @@ public class KeyguardIndicationController {
pw.println(" mTextView.getText(): " + (
mTopIndicationView == null ? null : mTopIndicationView.getText()));
pw.println(" computePowerIndication(): " + computePowerIndication());
pw.println(" trustGrantedIndication: " + getTrustGrantedIndication());
mRotateTextViewController.dump(fd, pw, args);
}
@@ -1054,6 +1058,22 @@ public class KeyguardIndicationController {
|| msgId == FaceManager.FACE_ERROR_CANCELED);
}
@Override
public void onTrustChanged(int userId) {
if (KeyguardUpdateMonitor.getCurrentUser() != userId) {
return;
}
updateTrust(userId, getTrustGrantedIndication(), getTrustManagedIndication());
}
@Override
public void showTrustGrantedMessage(CharSequence message) {
mTrustGrantedIndication = message;
updateTrust(KeyguardUpdateMonitor.getCurrentUser(), getTrustGrantedIndication(),
getTrustManagedIndication());
}
@Override
public void onTrustAgentErrorMessage(CharSequence message) {
showBiometricMessage(message);

View File

@@ -774,6 +774,43 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_LOGOUT);
}
@Test
public void onTrustGrantedMessageDoesNotShowUntilTrustGranted() {
createController();
// GIVEN a trust granted message but trust isn't granted
final String trustGrantedMsg = "testing trust granted message";
mController.getKeyguardCallback().showTrustGrantedMessage(trustGrantedMsg);
verifyHideIndication(INDICATION_TYPE_TRUST);
// WHEN trust is granted
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true);
mController.setVisible(true);
// THEN verify the trust granted message shows
verifyIndicationMessage(
INDICATION_TYPE_TRUST,
trustGrantedMsg);
}
@Test
public void onTrustGrantedMessageDoesShowsOnTrustGranted() {
createController();
// GIVEN trust is granted
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true);
// WHEN the showTrustGranted message is called
final String trustGrantedMsg = "testing trust granted message";
mController.getKeyguardCallback().showTrustGrantedMessage(trustGrantedMsg);
// THEN verify the trust granted message shows
verifyIndicationMessage(
INDICATION_TYPE_TRUST,
trustGrantedMsg);
}
private void sendUpdateDisclosureBroadcast() {
mBroadcastReceiver.onReceive(mContext, new Intent());
}