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

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

For a11y, assertively announce primary biometric messages

Fixes: 322889148
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor NEXTFOOD
Test: atest KeyguardIndicationControlerTest
Test: manually enable talkback, enroll fingerprint,
then intentionally fail fingerprint on the lockscreen (with
other rotating messages). Observe that talk back announces
the fingerprint failures and erorrs.

Change-Id: I227901b87cc91d5be5414f87fd97e744fe67329b
parent 5876053b
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import android.view.View;
public class KeyguardIndication {
    @Nullable
    private final CharSequence mMessage;
    @Nullable
    private final boolean mForceAccessibilityLiveRegionAssertive;
    @NonNull
    private final ColorStateList mTextColor;
    @Nullable
@@ -49,13 +51,15 @@ public class KeyguardIndication {
            Drawable icon,
            View.OnClickListener onClickListener,
            Drawable background,
            Long minVisibilityMillis) {
            Long minVisibilityMillis,
            Boolean foceAssertive) {
        mMessage = message;
        mTextColor = textColor;
        mIcon = icon;
        mOnClickListener = onClickListener;
        mBackground = background;
        mMinVisibilityMillis = minVisibilityMillis;
        mForceAccessibilityLiveRegionAssertive = foceAssertive;
    }

    /**
@@ -101,6 +105,15 @@ public class KeyguardIndication {
        return mMinVisibilityMillis;
    }


    /**
     * Whether to force the accessibility live region to be assertive.
     */
    public boolean getForceAssertiveAccessibilityLiveRegion() {
        return mForceAccessibilityLiveRegionAssertive;
    }


    @Override
    public String toString() {
        String str = "KeyguardIndication{";
@@ -109,6 +122,7 @@ public class KeyguardIndication {
        if (mOnClickListener != null) str += " mOnClickListener=" + mOnClickListener;
        if (mBackground != null) str += " mBackground=" + mBackground;
        if (mMinVisibilityMillis != null) str += " mMinVisibilityMillis=" + mMinVisibilityMillis;
        if (mForceAccessibilityLiveRegionAssertive) str += "mForceAccessibilityLiveRegionAssertive";
        str += "}";
        return str;
    }
@@ -123,6 +137,7 @@ public class KeyguardIndication {
        private ColorStateList mTextColor;
        private Drawable mBackground;
        private Long mMinVisibilityMillis;
        private boolean mForceAccessibilityLiveRegionAssertive;

        public Builder() { }

@@ -177,6 +192,14 @@ public class KeyguardIndication {
            return this;
        }

        /**
         * Optional. Can force the accessibility live region to be assertive for this message.
         */
        public Builder setForceAccessibilityLiveRegionAssertive() {
            this.mForceAccessibilityLiveRegionAssertive = true;
            return this;
        }

        /**
         * Build the KeyguardIndication.
         */
@@ -190,7 +213,7 @@ public class KeyguardIndication {

            return new KeyguardIndication(
                    mMessage, mTextColor, mIcon, mOnClickListener, mBackground,
                    mMinVisibilityMillis);
                    mMinVisibilityMillis, mForceAccessibilityLiveRegionAssertive);
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -633,6 +633,7 @@ public class KeyguardIndicationController {
                    INDICATION_TYPE_BIOMETRIC_MESSAGE,
                    new KeyguardIndication.Builder()
                            .setMessage(mBiometricMessage)
                            .setForceAccessibilityLiveRegionAssertive()
                            .setMinVisibilityMillis(IMPORTANT_MSG_MIN_DURATION)
                            .setTextColor(mInitialTextColorState)
                            .build(),
+9 −0
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ public class KeyguardIndicationTextView extends TextView {
    }

    private void setNextIndication() {
        boolean forceAssertiveAccessibilityLiveRegion = false;
        if (mKeyguardIndicationInfo != null) {
            // First, update the style.
            // If a background is set on the text, we don't want shadow on the text
@@ -239,8 +240,16 @@ public class KeyguardIndicationTextView extends TextView {
                }
            }
            setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
            forceAssertiveAccessibilityLiveRegion =
                mKeyguardIndicationInfo.getForceAssertiveAccessibilityLiveRegion();
        }
        if (!forceAssertiveAccessibilityLiveRegion) {
            setAccessibilityLiveRegion(ACCESSIBILITY_LIVE_REGION_NONE);
        }
        setText(mMessage);
        if (forceAssertiveAccessibilityLiveRegion) {
            setAccessibilityLiveRegion(ACCESSIBILITY_LIVE_REGION_ASSERTIVE);
        }
        if (mAlwaysAnnounceText) {
            announceForAccessibility(mMessage);
        }