Fix "Abnormal while playing netflix in PIP mode"

protected buffer usage of output buffer of framebuffer is determined by
if any input layer contains protected buffer.

If all the protected layers are handled by HWC,then GPU will process
normal layers only. It means, GPU got normal buffer as input but need
output to protected buffer.It would be memory violation for ARM as it
required at least one normal buffer as input for such case

Cherry-picked from AOSP. Conflicts in the test file are uninteresting;
both branches simply added new tests.
- services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp

Put the behavior change behind a flag.

Bug: 307674749
Test: atest
    libcompositionengine_test:OutputUpdateProtectedContentStateTest

Change-Id: I11d7c73c8eee4a46383516e8eb672827b26314e6
diff --git a/services/surfaceflinger/surfaceflinger_flags.aconfig b/services/surfaceflinger/surfaceflinger_flags.aconfig
index f5ec1ee..c8f4218 100644
--- a/services/surfaceflinger/surfaceflinger_flags.aconfig
+++ b/services/surfaceflinger/surfaceflinger_flags.aconfig
@@ -189,6 +189,13 @@
   namespace: "core_graphics"
   description: "This flag is guarding the behaviour where SurfaceFlinger is trying to opportunistically present a frame when the configuration change from late to early"
   bug: "273702768"
+}
+
+flag {
+  name: "protected_if_client"
+  namespace: "core_graphics"
+  description: "Only set the RenderSurface to protected if protected layers are in client composition."
+  bug: "307674749"
   is_fixed_read_only: true
   metadata {
     purpose: PURPOSE_BUGFIX