[SurfaceFlinger] Make sure switch the protected state of buffers.

Previously we avoid switching the protected state of buffers if the protected
state is not changed or we fail to switch RenderEngine. However, if we just
switch away from protected state and immediately have screenshot capturing
happen, we end up not switching buffers to unprotected in next round because
we switch RenderEngine to unprotected state. This patch makes sure we always
switch the protected state correctly.

BUG: b/130435822, b/130442144
Test: Verified with Youtube
Test: libcompositionengine_test
Change-Id: I30da95d8172b349cc7897a008fd27ecbc24fb960
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h
index 3c79084..0f57315 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h
@@ -45,6 +45,7 @@
     bool isValid() const override;
     void initialize() override;
     const ui::Size& getSize() const override;
+    bool isProtected() const override { return mProtected; }
 
     const sp<Fence>& getClientTargetAcquireFence() const override;
     void setBufferDataspace(ui::Dataspace) override;
@@ -78,6 +79,7 @@
     sp<GraphicBuffer> mGraphicBuffer;
     const sp<DisplaySurface> mDisplaySurface;
     ui::Size mSize;
+    bool mProtected{false};
     std::uint32_t mPageFlipCount{0};
 };