summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fabian Kozynski <kozynski@google.com> 2022-04-26 13:06:08 -0400
committer Fabian Kozynski <kozynski@google.com> 2022-04-26 13:06:08 -0400
commitb5f774ccfbca19b43890023400a622e06b04850a (patch)
treef85029241c38ad0826a4c0b3f81de78c1de87713
parente02f9e390dcc6dae7766a7452f5a74cc16149d03 (diff)
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
-rw-r--r--packages/SystemUI/res/values/strings.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt28
3 files changed, 31 insertions, 2 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index f92d6238e863..454d2f866e74 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -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>
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt
index fe4cb7182168..d4e164208167 100644
--- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt
@@ -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)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
index c714fa0e5b27..1d687b141d1e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
@@ -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()
+ }
} \ No newline at end of file