Fix empty touchable region of pip window

AccessibilityController uses the region to compute the window list
for AccessibilityManagerService to evaluate window changed events.
If the region is empty, the window will be ignored.

Bug: 120429758
Test: atest AccessibilityWindowQueryTest

Change-Id: Ic2d7f3a8249478358308b093ca8db9d3b8948046
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index d2dfa76..f1a48d2 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2168,11 +2168,13 @@
                 mTmpRect.inset(-delta, -delta);
             }
             region.set(mTmpRect);
-            region.translate(-mWindowFrames.mFrame.left, -mWindowFrames.mFrame.top);
+            cropRegionToStackBoundsIfNeeded(region);
         } else {
             // Not modal or full screen modal
-            getTouchableRegion(region, true /* forSurface */);
+            getTouchableRegion(region);
         }
+        // Translate to surface based coordinates.
+        region.translate(-mWindowFrames.mFrame.left, -mWindowFrames.mFrame.top);
 
         return flags;
     }
@@ -2809,16 +2811,6 @@
 
     /** Get the touchable region in global coordinates. */
     void getTouchableRegion(Region outRegion) {
-        getTouchableRegion(outRegion, false /* forSurface */);
-    }
-
-    /** If {@param forSuface} is {@code true}, the region will be translated to surface based. */
-    private void getTouchableRegion(Region outRegion, boolean forSurface) {
-        if (inPinnedWindowingMode() && !isFocused()) {
-            outRegion.setEmpty();
-            return;
-        }
-
         final Rect frame = mWindowFrames.mFrame;
         switch (mTouchableInsets) {
             default:
@@ -2833,18 +2825,11 @@
                 break;
             case TOUCHABLE_INSETS_REGION: {
                 outRegion.set(mGivenTouchableRegion);
+                outRegion.translate(frame.left, frame.top);
                 break;
             }
         }
         cropRegionToStackBoundsIfNeeded(outRegion);
-
-        if (forSurface) {
-            if (mTouchableInsets != TOUCHABLE_INSETS_REGION) {
-                outRegion.translate(-frame.left, -frame.top);
-            }
-            outRegion.getBounds(mTmpRect);
-            applyInsets(outRegion, mTmpRect, mAttrs.surfaceInsets);
-        }
     }
 
     private void cropRegionToStackBoundsIfNeeded(Region region) {