From b5d358480af466aaebd9c4af498d361471404cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Kozynski?= Date: Tue, 25 Apr 2023 14:13:41 -0400 Subject: [PATCH] Put all text content in the node's text Instead of just putting the state, put all the text content from the tile. That way, the relevant services will find it. "on"/"off" is not necessary anymore for ui tests because we use `isChecked`. Test: manual with Talkback and Select To Speak Test: android.platform.test.scenario.sysui.quicksettings Bug: 261994726 Change-Id: Iea47ab940ea3e0163ba196109851ea21260af017 --- .../android/systemui/qs/tileimpl/QSTileViewImpl.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 4a3199850e0f6..b80668379e49c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -385,6 +385,11 @@ open class QSTileViewImpl @JvmOverloads constructor( super.onInitializeAccessibilityNodeInfo(info) // Clear selected state so it is not announce by talkback. info.isSelected = false + info.text = if (TextUtils.isEmpty(secondaryLabel.text)) { + "${label.text}" + } else { + "${label.text}, ${secondaryLabel.text}" + } if (lastDisabledByPolicy) { info.addAction( AccessibilityNodeInfo.AccessibilityAction( @@ -402,12 +407,6 @@ open class QSTileViewImpl @JvmOverloads constructor( accessibilityClass } if (Switch::class.java.name == accessibilityClass) { - val label = resources.getString( - if (tileState) R.string.switch_bar_on else R.string.switch_bar_off) - // Set the text here for tests in - // android.platform.test.scenario.sysui.quicksettings. Can be removed when - // UiObject2 has a new getStateDescription() API and tests are updated. - info.text = label info.isChecked = tileState info.isCheckable = true if (isLongClickable) {