OSDN Git Service

Expose a11y overlay window titles to a11y services
authorPhil Weaver <pweaver@google.com>
Wed, 25 Apr 2018 00:09:26 +0000 (17:09 -0700)
committerPhil Weaver <pweaver@google.com>
Thu, 26 Apr 2018 00:25:25 +0000 (17:25 -0700)
Bug: 78463085
Test: Adding CTS test: atest AccessibilityOverlayTest
Change-Id: I9b8ec7368b6684018a43c8bca07fd1eac5969a4e

services/core/java/com/android/server/wm/WindowState.java

index 6c2821d..2616d1d 100644 (file)
@@ -3865,9 +3865,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
         windowInfo.title = mAttrs.accessibilityTitle;
         // Panel windows have no public way to set the a11y title directly. Use the
         // regular title as a fallback.
-        if (TextUtils.isEmpty(windowInfo.title)
-                && (mAttrs.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW)
-                && (mAttrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW)) {
+        final boolean isPanelWindow = (mAttrs.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW)
+                && (mAttrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW);
+        // Accessibility overlays should have titles that work for accessibility, and can't set
+        // the a11y title themselves.
+        final boolean isAccessibilityOverlay =
+                windowInfo.type == WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
+        if (TextUtils.isEmpty(windowInfo.title) && (isPanelWindow || isAccessibilityOverlay)) {
             windowInfo.title = mAttrs.getTitle();
         }
         windowInfo.accessibilityIdOfAnchor = mAttrs.accessibilityIdOfAnchor;