@@ -8939,14 +8939,8 @@ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
89398939
89408940 final boolean isPassword = hasPasswordTransformationMethod ();
89418941 if (!isPassword ) {
8942- CharSequence text = getText ();
8942+ CharSequence text = getTextForAccessibility ();
89438943 if (TextUtils .isEmpty (text )) {
8944- text = getHint ();
8945- }
8946- if (TextUtils .isEmpty (text )) {
8947- text = getContentDescription ();
8948- }
8949- if (!TextUtils .isEmpty (text )) {
89508944 event .getText ().add (text );
89518945 }
89528946 }
@@ -8972,7 +8966,7 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
89728966
89738967 final boolean isPassword = hasPasswordTransformationMethod ();
89748968 if (!isPassword ) {
8975- info .setText (getText ());
8969+ info .setText (getTextForAccessibility ());
89768970 }
89778971 info .setPassword (isPassword );
89788972 }
@@ -8988,6 +8982,20 @@ public void sendAccessibilityEvent(int eventType) {
89888982 super .sendAccessibilityEvent (eventType );
89898983 }
89908984
8985+ /**
8986+ * Gets the text reported for accessibility purposes. It is the
8987+ * text if not empty or the hint.
8988+ *
8989+ * @return The accessibility text.
8990+ */
8991+ private CharSequence getTextForAccessibility () {
8992+ CharSequence text = getText ();
8993+ if (TextUtils .isEmpty (text )) {
8994+ text = getHint ();
8995+ }
8996+ return text ;
8997+ }
8998+
89918999 void sendAccessibilityEventTypeViewTextChanged (CharSequence beforeText ,
89929000 int fromIndex , int removedCount , int addedCount ) {
89939001 AccessibilityEvent event =
0 commit comments