libsurfaceflinger: fix screenshot permission check

Fix the logic for layers we check isSecure or isVisible for.  It was
regressed by my previous change to support
WINDOW_TYPE_DONT_SCREENSHOT.

Bug: 63311708
Bug: 62656774
Test: CTS
Change-Id: I7768cb590014cc610ec564847958bbd98742c277
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0f6c581..a57e8cf 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4392,7 +4392,7 @@
     bool secureLayerIsVisible = false;
     for (const auto& layer : mDrawingState.layersSortedByZ) {
         const Layer::State& state(layer->getDrawingState());
-        if (layer->belongsToDisplay(hw->getLayerStack(), false) ||
+        if (!layer->belongsToDisplay(hw->getLayerStack(), false) ||
                 (state.z < minLayerZ || state.z > maxLayerZ)) {
             continue;
         }