Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a86912c7 authored by Nathan Harold's avatar Nathan Harold Committed by android-build-merger
Browse files

RadioV1_1 VTS Tests: startKeepalive, stopKeepalive

am: 64aae865

Change-Id: Ie49223b634fd0260c89b0cb44e762f719311f474
parents a732c00f 64aae865
Loading
Loading
Loading
Loading
+114 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include <radio_hidl_hal_utils_v1_1.h>
#include <vector>

/*
 * Test IRadio.setSimCardPower() for the response returned.
@@ -130,3 +131,115 @@ TEST_F(RadioHidlTest_v1_1, setCarrierInfoForImsiEncryption) {
                    radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startKeepalive() for the response returned.
 */
TEST_F(RadioHidlTest_v1_1, startKeepalive) {
    std::vector<KeepaliveRequest> requests = {
        {
            // Invalid IPv4 source address
            KeepaliveType::NATT_IPV4,
            {192, 168, 0 /*, 100*/},
            1234,
            {8, 8, 4, 4},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid IPv4 destination address
            KeepaliveType::NATT_IPV4,
            {192, 168, 0, 100},
            1234,
            {8, 8, 4, 4, 1, 2, 3, 4},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid Keepalive Type
            static_cast<KeepaliveType>(-1),
            {192, 168, 0, 100},
            1234,
            {8, 8, 4, 4},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid IPv6 source address
            KeepaliveType::NATT_IPV6,
            {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED,
             0xBE, 0xEF, 0xBD},
            1234,
            {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x88, 0x44},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid IPv6 destination address
            KeepaliveType::NATT_IPV6,
            {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED,
             0xBE, 0xEF},
            1234,
            {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x88,
             /*0x44*/},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid Context ID (cid), this should survive the initial
            // range checking and fail in the modem data layer
            KeepaliveType::NATT_IPV4,
            {192, 168, 0, 100},
            1234,
            {8, 8, 4, 4},
            4500,
            20000,
            0xBAD,
        },
        {
            // Invalid Context ID (cid), this should survive the initial
            // range checking and fail in the modem data layer
            KeepaliveType::NATT_IPV6,
            {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED,
             0xBE, 0xEF},
            1234,
            {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x88, 0x44},
            4500,
            20000,
            0xBAD,
        }};

    for (auto req = requests.begin(); req != requests.end(); req++) {
        int serial = GetRandomSerialNumber();
        radio_v1_1->startKeepalive(serial, *req);
        EXPECT_EQ(std::cv_status::no_timeout, wait());
        EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type);
        EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial);

        ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.stopKeepalive() for the response returned.
 */
TEST_F(RadioHidlTest_v1_1, stopKeepalive) {
    int serial = GetRandomSerialNumber();

    radio_v1_1->stopKeepalive(serial, 0xBAD);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial);

    ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
}
+2 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ class RadioResponse_v1_1 : public ::android::hardware::radio::V1_1::IRadioRespon
    hidl_string imsi;
    IccIoResult iccIoResult;
    int channelId;
    KeepaliveStatus keepaliveStatus;

    // Sms
    SendSmsResult sendSmsResult;
+9 −4
Original line number Diff line number Diff line
@@ -683,11 +683,16 @@ Return<void> RadioResponse_v1_1::stopNetworkScanResponse(const RadioResponseInfo
    return Void();
}

Return<void> RadioResponse_v1_1::startKeepaliveResponse(const RadioResponseInfo& /*info*/,
                                                        const KeepaliveStatus& /*status*/) {
Return<void> RadioResponse_v1_1::startKeepaliveResponse(const RadioResponseInfo& info,
                                                        const KeepaliveStatus& status) {
    rspInfo = info;
    keepaliveStatus = status;
    parent_v1_1.notify();
    return Void();
}

Return<void> RadioResponse_v1_1::stopKeepaliveResponse(const RadioResponseInfo& /*info*/) {
Return<void> RadioResponse_v1_1::stopKeepaliveResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_v1_1.notify();
    return Void();
}