Add mechanism for a task's windows to be trusted overlays (SF)

- Add a layer state to indicate that this layer and its children
  in the hierarchy are trusted. This can only be set by callers
  holding ACCESS_SURFACE_FLINGER, and will be used for the PIP
  task layer to indicate that activities in PIP are trusted (as
  they are controlled only by the user and SystemUI)

Bug: 191529039
Test: TBD

Change-Id: Id92ccb087bd0d8dbaeeef3ba50b67fe015e53db8
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 6ea070ea..96da8ef 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1656,6 +1656,19 @@
     return *this;
 }
 
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
+        const sp<SurfaceControl>& sc, bool isTrustedOverlay) {
+    layer_state_t* s = getLayerState(sc);
+    if (!s) {
+        mStatus = BAD_INDEX;
+        return *this;
+    }
+
+    s->what |= layer_state_t::eTrustedOverlayChanged;
+    s->isTrustedOverlay = isTrustedOverlay;
+    return *this;
+}
+
 SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setApplyToken(
         const sp<IBinder>& applyToken) {
     mApplyToken = applyToken;