Set title for privacy dialog

a11y services will try to guess the title of a window if it's empty,
usually assigning the title of the first element. As we don't want that,
we explicitly give it a title. This is not visible in UI, and only
available when using a11y descriptions.

Test: manual
Test: atest PrivacyDialogTest
Fixes: 208954254
Change-Id: Ic2042028bed58e369456442e6f6de0965163bee2
This commit is contained in:
Fabian Kozynski
2022-04-26 13:06:08 -04:00
parent e02f9e390d
commit b5f774ccfb
3 changed files with 31 additions and 2 deletions

View File

@@ -1994,7 +1994,8 @@
app for debugging. Will not be seen by users. [CHAR LIMIT=20] -->
<string name="heap_dump_tile_name">Dump SysUI Heap</string>
<!-- Content description for ongoing privacy chip. Use with a single app [CHAR LIMIT=NONE]-->
<!-- Title for the privacy indicators dialog, only appears as part of a11y descriptions [CHAR LIMIT=NONE] -->
<string name="ongoing_privacy_dialog_a11y_title">In use</string>
<!-- Content description for ongoing privacy chip. Use with multiple apps [CHAR LIMIT=NONE]-->
<string name="ongoing_privacy_chip_content_multiple_apps">Applications are using your <xliff:g id="types_list" example="camera, location">%s</xliff:g>.</string>

View File

@@ -67,7 +67,7 @@ class PrivacyDialog(
attributes.receiveInsetsIgnoringZOrder = true
setGravity(Gravity.TOP or Gravity.CENTER_HORIZONTAL)
}
setTitle(R.string.ongoing_privacy_dialog_a11y_title)
setContentView(R.layout.privacy_dialog)
rootView = requireViewById<ViewGroup>(R.id.root)

View File

@@ -35,6 +35,7 @@ import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
import android.content.Intent
import android.text.TextUtils
@SmallTest
@RunWith(AndroidTestingRunner::class)
@@ -373,4 +374,31 @@ class PrivacyDialogTest : SysuiTestCase() {
)
)
}
@Test
fun testDialogHasTitle() {
// Dialog must have a non-empty title for a11y purposes.
val list = listOf(
PrivacyDialog.PrivacyElement(
PrivacyType.TYPE_MICROPHONE,
TEST_PACKAGE_NAME,
TEST_USER_ID,
"App",
null,
null,
null,
0L,
false,
false,
false,
TEST_PERM_GROUP,
null
)
)
dialog = PrivacyDialog(context, list, starter)
dialog.show()
assertThat(TextUtils.isEmpty(dialog.window?.attributes?.title)).isFalse()
}
}