Merge "Revert "Fix sockfd leakage in SensorService. Remove sockfd from Looper  when the connection is removed from mActiveConnections."" into lmp-dev
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index ce14f99..2b5e744 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -653,8 +653,8 @@
     KeyEntry* entry = mKeyRepeatState.lastKeyEntry;
 
     // Reuse the repeated key entry if it is otherwise unreferenced.
-    uint32_t policyFlags = (entry->policyFlags & POLICY_FLAG_RAW_MASK)
-            | POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_TRUSTED;
+    uint32_t policyFlags = entry->policyFlags &
+            (POLICY_FLAG_RAW_MASK | POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_TRUSTED);
     if (entry->refCount == 1) {
         entry->recycle();
         entry->eventTime = currentTime;
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index e712523..f0fe58a 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -284,7 +284,7 @@
     /*
      * Returns if a frame is queued.
      */
-    bool hasQueuedFrame() const { return mQueuedFrames > 0; }
+    bool hasQueuedFrame() const { return mQueuedFrames > 0 || mSidebandStreamChanged; }
 
     // -----------------------------------------------------------------------