aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-15 15:32:18 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-15 15:32:18 +0000
commit72f46fb443eb7fb877a2aadd950ce204be1b0f19 (patch)
treec11157e608914b3b5f3f08aa55de1cd0f5d9508b
parent9dbf4e36f425f71e2f14b1096596201a07e98fa1 (diff)
parent0867bd1a0b27648b7b1fb5780511f03f708dff1d (diff)
downloadchre-72f46fb443eb7fb877a2aadd950ce204be1b0f19.tar.gz
Snap for 7915578 from 0867bd1a0b27648b7b1fb5780511f03f708dff1d to mainline-sdkext-releaseandroid-mainline-12.0.0_r81android-mainline-12.0.0_r109aml_sdk_311710000android12-mainline-sdkext-release
Change-Id: If0ed16790325ac5135279fe8fba8bdb868769127
-rw-r--r--apps/test/chqts/build/shared_make.mk8
-rw-r--r--apps/test/chqts/src/general_test/basic_wifi_test.cc39
-rw-r--r--apps/test/common/proto/chre_cross_validation_wifi.proto5
-rw-r--r--chpp/transport.c23
-rw-r--r--java/test/cross_validation/src/com/google/android/chre/test/crossvalidator/ChreCrossValidatorWifi.java22
5 files changed, 44 insertions, 53 deletions
diff --git a/apps/test/chqts/build/shared_make.mk b/apps/test/chqts/build/shared_make.mk
index 21611d77..661f05eb 100644
--- a/apps/test/chqts/build/shared_make.mk
+++ b/apps/test/chqts/build/shared_make.mk
@@ -11,11 +11,7 @@ $(error Must set Android build environment first)
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 @@ COMMON_CFLAGS += -DCHRE_NO_ENDIAN_H \
-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/chqts/src/general_test/basic_wifi_test.cc b/apps/test/chqts/src/general_test/basic_wifi_test.cc
index 6833952a..af648c9c 100644
--- a/apps/test/chqts/src/general_test/basic_wifi_test.cc
+++ b/apps/test/chqts/src/general_test/basic_wifi_test.cc
@@ -24,6 +24,7 @@
#include <shared/send_message.h>
#include <shared/time_util.h>
+#include "chre/util/nanoapp/log.h"
#include "chre/util/time.h"
#include "chre/util/unique_ptr.h"
@@ -31,6 +32,8 @@ using nanoapp_testing::sendFatalFailureToHost;
using nanoapp_testing::sendFatalFailureToHostUint8;
using nanoapp_testing::sendSuccessToHost;
+#define LOG_TAG "[BasicWifiTest]"
+
/*
* Test to check expected functionality of the CHRE WiFi APIs.
*
@@ -345,26 +348,24 @@ void BasicWifiTest::handleEvent(uint32_t /* senderInstanceId */,
}
const auto *result = static_cast<const chreWifiScanEvent *>(eventData);
- if (isActiveWifiScanType(result)) {
- // The first chreWifiScanResult is expected to come immediately,
- // but a long delay is possible if it's implemented incorrectly,
- // e.g. the async result comes right away (before the scan is actually
- // completed), then there's a long delay to the scan result.
- constexpr uint64_t maxDelayNs =
- 100 * chre::kOneMillisecondInNanoseconds;
- bool delayExceeded = (mStartTimestampNs != 0) &&
- (chreGetTime() - mStartTimestampNs > maxDelayNs);
- if (delayExceeded) {
- sendFatalFailureToHost(
- "Did not receive chreWifiScanResult within 100 milliseconds.");
- }
- // Do not reset mStartTimestampNs here, because it is used for the
- // subsequent RTT ranging timestamp validation.
- validateWifiScanEvent(result);
- } else {
- sendFatalFailureToHostUint8("Unexpected scan type %d",
- result->scanType);
+ if (!isActiveWifiScanType(result)) {
+ LOGW("Received unexpected scan type %" PRIu8, result->scanType);
+ }
+
+ // The first chreWifiScanResult is expected to come immediately,
+ // but a long delay is possible if it's implemented incorrectly,
+ // e.g. the async result comes right away (before the scan is actually
+ // completed), then there's a long delay to the scan result.
+ constexpr uint64_t maxDelayNs = 100 * chre::kOneMillisecondInNanoseconds;
+ bool delayExceeded = (mStartTimestampNs != 0) &&
+ (chreGetTime() - mStartTimestampNs > maxDelayNs);
+ if (delayExceeded) {
+ sendFatalFailureToHost(
+ "Did not receive chreWifiScanResult within 100 milliseconds.");
}
+ // Do not reset mStartTimestampNs here, because it is used for the
+ // subsequent RTT ranging timestamp validation.
+ validateWifiScanEvent(result);
break;
}
case CHRE_EVENT_WIFI_RANGING_RESULT: {
diff --git a/apps/test/common/proto/chre_cross_validation_wifi.proto b/apps/test/common/proto/chre_cross_validation_wifi.proto
index 7e6348d4..8a681d09 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 @@ enum MessageType {
// 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/chpp/transport.c b/chpp/transport.c
index 3f1c6cc7..f3f76517 100644
--- a/chpp/transport.c
+++ b/chpp/transport.c
@@ -520,6 +520,24 @@ static void chppSetResetComplete(struct ChppTransportState *context) {
* @param context Maintains status for each transport layer instance.
*/
static void chppProcessResetAck(struct ChppTransportState *context) {
+ if (context->resetState == CHPP_RESET_STATE_NONE) {
+ CHPP_LOGE("Unexpected reset-ack seq=%" PRIu8 " code=0x%" PRIx8,
+ context->rxHeader.seq, context->rxHeader.packetCode);
+ // In a reset race condition with both endpoints sending resets and
+ // reset-acks, the sent resets and reset-acks will both have a sequence
+ // number of 0.
+ // By ignoring the received reset-ack, the next expected sequence number
+ // will remain at 1 (following a reset with a sequence number of 0).
+ // Therefore, no further correction is necessary (beyond ignoring the
+ // received reset-ack), as the next packet (e.g. discovery) will have a
+ // sequence number of 1.
+
+ chppDatagramProcessDoneCb(context, context->rxDatagram.payload);
+ chppClearRxDatagram(context);
+
+ return;
+ }
+
chppSetResetComplete(context);
context->rxStatus.receivedPacketCode = context->rxHeader.packetCode;
context->rxStatus.expectedSeq = context->rxHeader.seq + 1;
@@ -634,8 +652,9 @@ static void chppProcessRxPayload(struct ChppTransportState *context) {
/**
* Resets the incoming datagram state, i.e. after the datagram has been
* processed.
- * Note that it is up to the app layer to inform the transport layer using
- * chppDatagramProcessDoneCb() once it is done with the buffer so it is freed.
+ * Note that this is independent from freeing the payload. It is up to the app
+ * layer to inform the transport layer using chppDatagramProcessDoneCb() once it
+ * is done with the buffer so it is freed.
*
* @param context Maintains status for each transport layer instance.
*/
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 a32c8cb5..a6cd0952 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 @@ public class ChreCrossValidatorWifi extends ChreCrossValidatorBase {
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 @@ public class ChreCrossValidatorWifi extends ChreCrossValidatorBase {
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 @@ public class ChreCrossValidatorWifi extends ChreCrossValidatorBase {
}
}
- 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;