Snap for 7901677 from dd75ea3df64fc9d965ccb447259488245585d999 to sc-platform-release

Change-Id: I2ce4a37a6fe1d8cd56d15760fa3f3c83a7df8bf1
diff --git a/apps/test/chqts/build/shared_make.mk b/apps/test/chqts/build/shared_make.mk
index 21611d7..661f05e 100644
--- a/apps/test/chqts/build/shared_make.mk
+++ b/apps/test/chqts/build/shared_make.mk
@@ -11,11 +11,7 @@
 endif
 
 NANOAPP_DIR_NAME ?= $(NANOAPP_NAME)
-
-# This path is actually relative to one level deeper as this file
-# gets included from Makefile of each test subdirectory
-NANOAPP_SRC_PATH = ../../src
-CHRE_ROOT_PATH = ../../../..
+NANOAPP_SRC_PATH = $(CHRE_PREFIX)/apps/test/chqts/src
 
 SHARED_LIB_FILES = abort.cc \
   chunk_allocator.cc \
@@ -38,7 +34,7 @@
   -D__BIG_ENDIAN=2
 
 COMMON_CFLAGS += -I$(NANOAPP_SRC_PATH)
-COMMON_CFLAGS += -I$(CHRE_ROOT_PATH)/util/include
+COMMON_CFLAGS += -I$(CHRE_PREFIX)/util/include
 
 OPT_LEVEL=2
 
diff --git a/apps/test/common/proto/chre_cross_validation_wifi.proto b/apps/test/common/proto/chre_cross_validation_wifi.proto
index 7e6348d..8a681d0 100644
--- a/apps/test/common/proto/chre_cross_validation_wifi.proto
+++ b/apps/test/common/proto/chre_cross_validation_wifi.proto
@@ -26,11 +26,6 @@
   // C2H: Nanoapp informing host about the wifi capabilities it has.
   // The payload must be a WifiCapabilities message.
   WIFI_CAPABILITIES = 4;
-
-  // H2C: Host telling nanoapp whether or not to allow a certain threshold of
-  // the CHRE scan results size to be less than the AP scan results size.
-  // The payload must be a UseScanResultsSizeThreshold message.
-  USE_SCAN_RESULTS_SIZE_THRESHOLD = 5;
 }
 
 enum Step {
diff --git a/core/include/chre/core/wifi_request_manager.h b/core/include/chre/core/wifi_request_manager.h
index 5f43d94..d97f5f1 100644
--- a/core/include/chre/core/wifi_request_manager.h
+++ b/core/include/chre/core/wifi_request_manager.h
@@ -241,6 +241,9 @@
   //! Helps ensure we don't get stuck if platform isn't behaving as expected
   Nanoseconds mRangingResponseTimeout;
 
+  //! System time when the last WiFi scan event was received.
+  Milliseconds mLastScanEventTime;
+
   /**
    * @return true if the scan monitor is enabled by any nanoapps.
    */
diff --git a/core/wifi_request_manager.cc b/core/wifi_request_manager.cc
index e7080f4..aaeae3c 100644
--- a/core/wifi_request_manager.cc
+++ b/core/wifi_request_manager.cc
@@ -282,6 +282,9 @@
                     log.timestamp.toRawNanoseconds(), log.instanceId,
                     log.scanType, log.maxScanAgeMs.getMilliseconds());
   }
+
+  debugDump.print(" Last scan event @ %" PRIu64 " ms",
+                  mLastScanEventTime.getMilliseconds());
 }
 
 bool WifiRequestManager::scanMonitorIsEnabled() const {
@@ -435,6 +438,7 @@
 }
 
 void WifiRequestManager::postScanEventFatal(chreWifiScanEvent *event) {
+  mLastScanEventTime = Milliseconds(SystemTime::getMonotonicTime());
   EventLoopManagerSingleton::get()->getEventLoop().postEventOrDie(
       CHRE_EVENT_WIFI_SCAN_RESULT, event, freeWifiScanEventCallback);
 }
diff --git a/java/test/cross_validation/src/com/google/android/chre/test/crossvalidator/ChreCrossValidatorWifi.java b/java/test/cross_validation/src/com/google/android/chre/test/crossvalidator/ChreCrossValidatorWifi.java
index a32c8cb..a6cd095 100644
--- a/java/test/cross_validation/src/com/google/android/chre/test/crossvalidator/ChreCrossValidatorWifi.java
+++ b/java/test/cross_validation/src/com/google/android/chre/test/crossvalidator/ChreCrossValidatorWifi.java
@@ -78,21 +78,14 @@
     private AtomicReference<String> mWifiScanResultsCompareFinalErrorMessage =
             new AtomicReference<String>(null);
 
-    private boolean mUseScanResultsSizeThreshold;
-
-    /**
-     * @param useScanResultsSizeThreshold true if the test should allow CHRE to have a certain
-     *                                    threhsold less scan results than AP.
-     */
     public ChreCrossValidatorWifi(
             ContextHubManager contextHubManager, ContextHubInfo contextHubInfo,
-            NanoAppBinary nanoAppBinary, boolean useScanResultsSizeThreshold) {
+            NanoAppBinary nanoAppBinary) {
         super(contextHubManager, contextHubInfo, nanoAppBinary);
         Assert.assertTrue("Nanoapp given to cross validator is not the designated chre cross"
                 + " validation nanoapp.",
                 nanoAppBinary.getNanoAppId() == NANO_APP_ID);
         Context context = InstrumentationRegistry.getInstrumentation().getContext();
-        mUseScanResultsSizeThreshold = useScanResultsSizeThreshold;
         mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mWifiScanReceiver = new BroadcastReceiver() {
             @Override
@@ -120,9 +113,6 @@
         mCollectingData.set(true);
         sendStepStartMessage(Step.SETUP);
 
-        // TODO(b/158770664): Address the issue that requires this workaround in the test on older
-        // devices.
-        sendMessageUseScanResultsThresholdMessage(mUseScanResultsSizeThreshold);
         waitForMessageFromNanoapp();
         mCollectingData.set(false);
 
@@ -215,16 +205,6 @@
         }
     }
 
-    private void sendMessageUseScanResultsThresholdMessage(boolean useThreshold) {
-        int messageType = ChreCrossValidationWifi.MessageType.USE_SCAN_RESULTS_SIZE_THRESHOLD_VALUE;
-        ChreCrossValidationWifi.UseScanResultsSizeThreshold messageProto =
-                ChreCrossValidationWifi.UseScanResultsSizeThreshold
-                .newBuilder().setUseThreshold(useThreshold).build();
-        NanoAppMessage message = NanoAppMessage.createMessageToNanoApp(
-                mNappBinary.getNanoAppId(), messageType, messageProto.toByteArray());
-        sendMessageToNanoApp(message);
-    }
-
     private NanoAppMessage makeWifiScanResultMessage(ScanResult result, int totalNumResults,
                                                      int resultIndex) {
         int messageType = ChreCrossValidationWifi.MessageType.SCAN_RESULT_VALUE;