Inherit touch occlusion mode from parent w/ input info

SAW windows can use SurfaceView which creates surfaces that don't have
associated windows, so they get the default BLOCK_UNTRUSTED occlusion
mode. This end up blocking touches as part of go/untrusted-touches even
if they are opacity compliant.

To fix this, traverse parent pointers in case the surface doesn't have
input info associated until we find one parent that has and inherit the
occlusion mode from them, if no such parent is found nothing changes.

Bug: 175369159
Test: Create SAW window w/ a SurfaceView, FLAG_NOT_TOUCHABLE and
      alpha = 0.5, verify touches are not blocked
Test: atest android.server.wm.WindowUntrustedTouchTest
Change-Id: Id3b1a557ccb86a282f51ad5ed8a0ee17ffeceb5e
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a7c8704..be52fbf 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2353,6 +2353,16 @@
     info.touchableRegion = inputTransform.transform(info.touchableRegion);
 }
 
+void Layer::fillTouchOcclusionMode(InputWindowInfo& info) {
+    sp<Layer> p = this;
+    while (p != nullptr && !p->hasInputInfo()) {
+        p = p->mDrawingParent.promote();
+    }
+    if (p != nullptr) {
+        info.touchOcclusionMode = p->mDrawingState.inputInfo.touchOcclusionMode;
+    }
+}
+
 InputWindowInfo Layer::fillInputInfo(const sp<DisplayDevice>& display) {
     if (!hasInputInfo()) {
         mDrawingState.inputInfo.name = getName();
@@ -2390,6 +2400,7 @@
     // anything.
     info.visible = hasInputInfo() ? canReceiveInput() : isVisible();
     info.alpha = getAlpha();
+    fillTouchOcclusionMode(info);
 
     auto cropLayer = mDrawingState.touchableRegionCrop.promote();
     if (info.replaceTouchableRegionWithCrop) {