From 987144aa227aba76e1806ac6b5a1555f26b18045 Mon Sep 17 00:00:00 2001 From: ryanlwlin Date: Wed, 21 Apr 2021 21:20:57 +0800 Subject: [PATCH] Fix magnification bounds cut out with floating a11y button The window type Floating Accessibility Button is TYPE_NAVIGATION_BAR_PANEL which is unmagnifed, it leads to the cut out while drawing the magnification bounds. To fix it we did a compromise. We omit the window bounds of TYPE_NAVIGATION_BAR_PANEL windows while computing the magnification bounds. The cons is that magnification region is really changed. That means the interaction with such windows might have latency depending on if they are inside the magnification bounds. However, it is acceptable because users don't have complex interaction witch such windows and see them rarely. bug: 185401123 Test: manually test Change-Id: Ia0088a0140fb8d5516e703ebfa5e203f857636d9 --- .../server/wm/AccessibilityController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index e6d49e406803a..98b122706bfc9 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -22,6 +22,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CO import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; +import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static com.android.server.accessibility.AccessibilityTraceFileProto.ENTRY; import static com.android.server.accessibility.AccessibilityTraceFileProto.MAGIC_NUMBER; @@ -938,8 +939,7 @@ final class AccessibilityController { for (int i = visibleWindowCount - 1; i >= 0; i--) { WindowState windowState = visibleWindows.valueAt(i); final int windowType = windowState.mAttrs.type; - if ((windowType == TYPE_MAGNIFICATION_OVERLAY - || windowType == TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY) + if (isExcludedWindowType(windowType) || ((windowState.mAttrs.privateFlags & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0)) { continue; @@ -1040,6 +1040,17 @@ final class AccessibilityController { } } + private boolean isExcludedWindowType(int windowType) { + return windowType == TYPE_MAGNIFICATION_OVERLAY + // Omit the touch region to avoid the cut out of the magnification + // bounds because nav bar panel is unmagnifiable. + || windowType == TYPE_NAVIGATION_BAR_PANEL + // Omit the touch region of window magnification to avoid the cut out of the + // magnification and the magnified center of window magnification could be + // in the bounds + || windowType == TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY; + } + void onRotationChanged(SurfaceControl.Transaction t) { // If we are showing the magnification border, hide it immediately so // the user does not see strange artifacts during rotation. The screenshot