diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-23 01:09:42 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-23 01:09:42 +0000 |
commit | 05468f7577db53e836dcb6fa7308cdadc211e94a (patch) | |
tree | b0b6e9597e956c34d273ebe39f5662fc1697d41e | |
parent | 52b3e1784add1d3c744f706411fe1cbdfe61e1f9 (diff) | |
parent | 7cb4cff2411c92efa1c41f498901865461c1a8ce (diff) | |
download | chre-android-security-12.0.0_r40.tar.gz |
Snap for 7574892 from 7cb4cff2411c92efa1c41f498901865461c1a8ce to sc-releaseandroid-vts-12.0_r9android-vts-12.0_r8android-vts-12.0_r7android-vts-12.0_r6android-vts-12.0_r5android-vts-12.0_r4android-vts-12.0_r3android-vts-12.0_r2android-vts-12.0_r12android-vts-12.0_r11android-vts-12.0_r10android-vts-12.0_r1android-security-12.0.0_r60android-security-12.0.0_r59android-security-12.0.0_r58android-security-12.0.0_r57android-security-12.0.0_r56android-security-12.0.0_r55android-security-12.0.0_r54android-security-12.0.0_r53android-security-12.0.0_r52android-security-12.0.0_r51android-security-12.0.0_r50android-security-12.0.0_r49android-security-12.0.0_r48android-security-12.0.0_r47android-security-12.0.0_r46android-security-12.0.0_r45android-security-12.0.0_r44android-security-12.0.0_r43android-security-12.0.0_r42android-security-12.0.0_r41android-security-12.0.0_r40android-security-12.0.0_r39android-security-12.0.0_r38android-security-12.0.0_r37android-security-12.0.0_r36android-security-12.0.0_r35android-security-12.0.0_r34android-platform-12.0.0_r1android-cts-12.0_r9android-cts-12.0_r8android-cts-12.0_r7android-cts-12.0_r6android-cts-12.0_r5android-cts-12.0_r4android-cts-12.0_r3android-cts-12.0_r2android-cts-12.0_r12android-cts-12.0_r11android-cts-12.0_r10android-cts-12.0_r1android-12.0.0_r9android-12.0.0_r8android-12.0.0_r34android-12.0.0_r33android-12.0.0_r31android-12.0.0_r30android-12.0.0_r3android-12.0.0_r25android-12.0.0_r2android-12.0.0_r11android-12.0.0_r10android-12.0.0_r1android12-tests-releaseandroid12-security-releaseandroid12-s5-releaseandroid12-s4-releaseandroid12-s3-releaseandroid12-s2-releaseandroid12-s1-releaseandroid12-release
Change-Id: I723e4c01fe6a0e8d35a5144f012cc8b18af30d05
-rw-r--r-- | apps/test/chqts/src/general_test/basic_wifi_test.cc | 39 | ||||
-rw-r--r-- | chpp/transport.c | 23 |
2 files changed, 41 insertions, 21 deletions
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/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. */ |