Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8669889 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Display grant trust messages on the lock screen"

parents 4a441d64 d95d2e73
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -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);
+37 −0
Original line number Diff line number Diff line
@@ -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());
    }