Fix empty region if the scale is smaller than 1

It may be used by Layer of SurfaceFlinger to calculate
touchable region. It should be able to scale a window
to a smaller size.

Bug: 111440400
Test: manual - An input-associated surface with a scaling
      matrix that has dsdx, dsdy < 1. Use "dumpsys input"
      to observe its touchable region.

Change-Id: I495bd16acec77f913fd39dcac90404eddc71cabb
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index bea4f91..0e258c8 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -3518,7 +3518,7 @@
                     dump += StringPrintf(INDENT3 "%zu: name='%s', displayId=%d, "
                             "paused=%s, hasFocus=%s, hasWallpaper=%s, "
                             "visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
-                            "frame=[%d,%d][%d,%d], globalScale=%f, windowScale=%f,%f"
+                            "frame=[%d,%d][%d,%d], globalScale=%f, windowScale=(%f,%f), "
                             "touchableRegion=",
                             i, windowInfo->name.c_str(), windowInfo->displayId,
                             toString(windowInfo->paused),
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 81456df..58fd866 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2069,10 +2069,13 @@
     info.frameBottom = screenBounds.bottom - info.surfaceInset;
 
     ui::Transform t = getTransform();
-    info.windowXScale *= 1.0f / t.sx();
-    info.windowYScale *= 1.0f / t.sy();
-
-    info.touchableRegion.scaleSelf(t.sx(), t.sy());
+    const float xScale = t.sx();
+    const float yScale = t.sy();
+    if (xScale != 1.0f || yScale != 1.0f) {
+        info.windowXScale *= 1.0f / xScale;
+        info.windowYScale *= 1.0f / yScale;
+        info.touchableRegion.scaleSelf(xScale, yScale);
+    }
 
     info.touchableRegion = info.touchableRegion.translate(
             screenBounds.left,