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

Commit 3b0704fd authored by Julia Reynolds's avatar Julia Reynolds Committed by Android Build Coastguard Worker
Browse files

Remove notification content from icon a11y

The content can be read when the full cards are visible

Test: StatusBarIconViewTest
Test: enable talkback, highlight icons
Flag: EXEMPT bug fix
Bug: 338024220
(cherry picked from commit e55a350c)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:9d00ab315dd7d661e71b5fcc51152ced2b2ae28a)
Merged-In: I3d3b7329c187808a28663aab16838a93a288b051
Change-Id: I3d3b7329c187808a28663aab16838a93a288b051
parent 106d3165
Loading
Loading
Loading
Loading
+1 −23
Original line number Diff line number Diff line
@@ -34,31 +34,9 @@ class NotificationContentDescriptionTest : SysuiTestCase() {
    private val TICKER = "this is a ticker"

    @Test
    fun notificationWithAllDifferentFields_descriptionIsTitle() {
    fun notificationWithAllDifferentFields_descriptionIsAppName() {
        val n = createNotification(TITLE, TEXT, TICKER)
        val description = contentDescForNotification(context, n)
        assertThat(description).isEqualTo(createDescriptionText(n, TITLE))
    }

    @Test
    fun notificationWithAllDifferentFields_titleMatchesAppName_descriptionIsText() {
        val n = createNotification(getTestAppName(), TEXT, TICKER)
        val description = contentDescForNotification(context, n)
        assertThat(description).isEqualTo(createDescriptionText(n, TEXT))
    }

    @Test
    fun notificationWithAllDifferentFields_titleMatchesAppNameNoText_descriptionIsTicker() {
        val n = createNotification(getTestAppName(), null, TICKER)
        val description = contentDescForNotification(context, n)
        assertThat(description).isEqualTo(createDescriptionText(n, TICKER))
    }

    @Test
    fun notificationWithAllDifferentFields_titleMatchesAppNameNoTextNoTicker_descriptionEmpty() {
        val appName = getTestAppName()
        val n = createNotification(appName, null, null)
        val description = contentDescForNotification(context, n)
        assertThat(description).isEqualTo(createDescriptionText(n, ""))
    }

+1 −10
Original line number Diff line number Diff line
@@ -28,14 +28,5 @@ import com.android.systemui.res.R
@MainThread
fun contentDescForNotification(c: Context, n: Notification): CharSequence {
    val appName = n.loadHeaderAppName(c) ?: ""
    val title = n.extras?.getCharSequence(Notification.EXTRA_TITLE)
    val text = n.extras?.getCharSequence(Notification.EXTRA_TEXT)
    val ticker = n.tickerText

    // Some apps just put the app name into the title
    val titleOrText = if (TextUtils.equals(title, appName)) text else title
    val desc =
        if (!TextUtils.isEmpty(titleOrText)) titleOrText
        else if (!TextUtils.isEmpty(ticker)) ticker else ""
    return c.getString(R.string.accessibility_desc_notification_icon, appName, desc)
    return c.getString(R.string.accessibility_desc_notification_icon, appName, "")
}