libsurfaceflinger: fix screenshot permission check am: fc0b911090 am: 88f99396fd
am: f0e9eaf841

Change-Id: I5652f12bebd0a5f284d5c1d92d954dd4f3f586a1
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9dfdaa1..0d93467 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4455,7 +4455,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;
         }