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

Commit d95d2e73 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Display grant trust messages on the lock screen

Before, nothing was registered for the trust
granted message callback and we were always showing
the default trust granted message.

Test: locally/manually add FLAG_DISPLAY_GRANT_TRUST_MESSAGE
to all messages in TrustAgentWrapper. Observe messages
are shown on the lock screen.
Test: atest KeyguardIndicationControlerTest
Fixes: 213911325

Change-Id: I239b71dcd14d7edde7d99a54cfbee43a211badc2
parent d7c5ca76
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());
    }