Detect consecutive missing Qsocket responses

Bug: 111220438
Test: sanity check CHRE works, then locally lower kDefaultSeeRespTimeout
      to verify a crash can be triggerd with missing responses.
Change-Id: Iffc7dda297ab52bd35824ba2597c06acdf9fc8c9
diff --git a/platform/slpi/include/chre/platform/slpi/see/see_helper.h b/platform/slpi/include/chre/platform/slpi/see/see_helper.h
index 693014b..a8bc173 100644
--- a/platform/slpi/include/chre/platform/slpi/see/see_helper.h
+++ b/platform/slpi/include/chre/platform/slpi/see/see_helper.h
@@ -79,6 +79,9 @@
 //! Default timeout for sendReq indication
 constexpr Nanoseconds kDefaultSeeIndTimeout = Seconds(2);
 
+//! Allowed number of consecutive missing responses.
+constexpr uint32_t kSeeNumMissingResp = 5;
+
 //! Length of the char array to store sensor string attributes.
 constexpr size_t kSeeAttrStrValLen = 64;
 
@@ -353,6 +356,9 @@
   //! A transaction ID that increments for each request.
   uint32_t mCurrentTxnId = 0;
 
+  //! The number of consecutive missing responses.
+  uint32_t mNumMissingResp = 0;
+
   //! The SUID for the remote_proc sensor.
   Optional<sns_std_suid> mRemoteProcSuid;
 
diff --git a/platform/slpi/see/see_helper.cc b/platform/slpi/see/see_helper.cc
index 47fe6eb..d2c8334 100644
--- a/platform/slpi/see/see_helper.cc
+++ b/platform/slpi/see/see_helper.cc
@@ -1648,11 +1648,19 @@
         if (!waitSuccess) {
           LOGE("SEE resp timed out after %" PRIu64 " ms",
                Milliseconds(timeoutResp).getMilliseconds());
-        } else if (mRespError != SNS_STD_ERROR_NO_ERROR) {
-          LOGE("SEE txn ID %" PRIu32 " failed with error %d",
-               mCurrentTxnId, mRespError);
+
+          if (++mNumMissingResp >= kSeeNumMissingResp) {
+            FATAL_ERROR("%" PRIu32 " consecutive missing responses",
+                        mNumMissingResp);
+          }
         } else {
-          success = true;
+          mNumMissingResp = 0;
+          if (mRespError != SNS_STD_ERROR_NO_ERROR) {
+            LOGE("SEE txn ID %" PRIu32 " failed with error %d",
+                 mCurrentTxnId, mRespError);
+          } else {
+            success = true;
+          }
         }
       }
       mWaitingOnResp = false;