SF: replicate mSidebandStream in LayerBE

Add a copy of mSidebandStream in LayerBE.  This is
one of the few data items that is replicated in
both FE and BE.

Test: build
Change-Id: Ief98645a4fa178e2606c0c337b3f260a1766597a
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index a33ef2c..f37f0ab 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -115,7 +115,7 @@
 
 bool BufferLayer::isVisible() const {
     return !(isHiddenByPolicy()) && getAlpha() > 0.0f &&
-            (mActiveBuffer != NULL || mSidebandStream != NULL);
+            (mActiveBuffer != NULL || getBE().mSidebandStream != NULL);
 }
 
 bool BufferLayer::isFixedSize() const {
@@ -385,7 +385,9 @@
     if (android_atomic_acquire_cas(true, false, &mSidebandStreamChanged) == 0) {
         // mSidebandStreamChanged was true
         mSidebandStream = mSurfaceFlingerConsumer->getSidebandStream();
-        if (mSidebandStream != NULL) {
+        // replicated in LayerBE until FE/BE is ready to be synchronized
+        getBE().mSidebandStream = mSidebandStream;
+        if (getBE().mSidebandStream != NULL) {
             setTransactionFlags(eTransactionNeeded);
             mFlinger->setTransactionFlags(eTraversalNeeded);
         }
@@ -606,13 +608,13 @@
     }
 
     // Sideband layers
-    if (mSidebandStream.get()) {
+    if (getBE().mSidebandStream.get()) {
         setCompositionType(hwcId, HWC2::Composition::Sideband);
         ALOGV("[%s] Requesting Sideband composition", mName.string());
-        error = hwcLayer->setSidebandStream(mSidebandStream->handle());
+        error = hwcLayer->setSidebandStream(getBE().mSidebandStream->handle());
         if (error != HWC2::Error::None) {
             ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(),
-                  mSidebandStream->handle(), to_string(error).c_str(),
+                  getBE().mSidebandStream->handle(), to_string(error).c_str(),
                   static_cast<int32_t>(error));
         }
         return;
@@ -651,7 +653,7 @@
 bool BufferLayer::isOpaque(const Layer::State& s) const {
     // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the
     // layer's opaque flag.
-    if ((mSidebandStream == nullptr) && (mActiveBuffer == nullptr)) {
+    if ((getBE().mSidebandStream == nullptr) && (mActiveBuffer == nullptr)) {
         return false;
     }
 
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index e29132d..f4eace8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1002,7 +1002,7 @@
     const bool resizePending = ((c.requested.w != c.active.w) || (c.requested.h != c.active.h)) &&
             (mActiveBuffer != nullptr);
     if (!isFixedSize()) {
-        if (resizePending && mSidebandStream == NULL) {
+        if (resizePending && getBE().mSidebandStream == NULL) {
             flags |= eDontUpdateGeometryState;
         }
     }
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 5dfc963..b5638e0 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -73,6 +73,8 @@
 public:
     LayerBE();
 
+    sp<NativeHandle> mSidebandStream;
+
     // The mesh used to draw the layer in GLES composition mode
     Mesh mMesh;