Bound timeout in default SeeHelper SUID lookup

Instead of waiting up to 10 seconds for each sensor lookup when the
default timeout behavior is requested, once a single lookup has failed,
drop to performing 0 retries to significantly shorten the maximum CHRE
startup delay when sensors are not present.

Also, shorten the default retry delay from 500ms to 250ms, but increase
the retry count accordingly to keep the overall maximum timeout the
same (10 seconds), to reduce the time spent sleeping after a sensor has
arrived.

Bug: 79844069
Test: change 2 sensor type strings in initialization list to invalid,
confirm retry time of first is long (10s) and second fails immediately
Change-Id: Ib37af9bf262e6d683b9db2659b88aeebc037f5b9
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 179691b..6854e8c 100644
--- a/platform/slpi/include/chre/platform/slpi/see/see_helper.h
+++ b/platform/slpi/include/chre/platform/slpi/see/see_helper.h
@@ -138,8 +138,20 @@
    * @return true if at least minNumSuids were successfully found
    */
   bool findSuidSync(const char *dataType, DynamicVector<sns_std_suid> *suids,
-                    uint8_t minNumSuids = 1, uint32_t maxRetries = 20,
-                    Milliseconds retryDelay = Milliseconds(500));
+                    uint8_t minNumSuids, uint32_t maxRetries,
+                    Milliseconds retryDelay);
+
+  /**
+   * Version of findSuidSync providing default timeout/retry behavior.
+   *
+   * @see findSuidSync
+   */
+  bool findSuidSync(const char *dataType, DynamicVector<sns_std_suid> *suids,
+                    uint8_t minNumSuids = 1) {
+    uint32_t maxRetries = (mHaveTimedOutOnSuidLookup) ? 0 : 40;
+    return findSuidSync(dataType, suids, minNumSuids, maxRetries,
+                        Milliseconds(250) /* retryDelay */);
+  }
 
   /**
    * A synchronous call to obtain the attributes of the specified SUID.
@@ -276,6 +288,9 @@
   //! true if we are waiting on a response of a Qsocket request.
   bool mWaitingOnResp = false;
 
+  //! true if we've timed out in findSuidSync at least once
+  bool mHaveTimedOutOnSuidLookup = false;
+
   //! The Qsocket response error of the request we just made.
   sns_std_error mRespError;
 
diff --git a/platform/slpi/see/see_helper.cc b/platform/slpi/see/see_helper.cc
index 5b2d217..5484c49 100644
--- a/platform/slpi/see/see_helper.cc
+++ b/platform/slpi/see/see_helper.cc
@@ -1439,6 +1439,9 @@
       } while (suids->size() < minNumSuids && trialCount < maxRetries);
 
       success = (suids->size() >= minNumSuids);
+      if (!success) {
+        mHaveTimedOutOnSuidLookup = true;
+      }
       if (trialCount > 1) {
         LOGD("Waited %" PRIu32 " ms for %s (found: %d)",
              static_cast<uint32_t>(trialCount * retryDelay.getMilliseconds()),