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

Commit cabe101c authored by sqian's avatar sqian
Browse files

Handle radio API in low version VTS for high version service

There are some request/response pair that could be replaced in
higher-version hal. Radio service need to handle
these request/response pair specific to version number. For example,
e.g. getVoiceRegistrationStateResponse_1_2 replaces
getVoiceRegistrationStateResponse for getVoiceRegistrationState
in 1.2 radio service. We need to add util and update version number
of IRadio service to check the version for testing the correct
behavior.

Bug: 109839239
Test: run vts
Change-Id: I291690e77ea0e6e37fe75219e550f79fa44fb840
parent b6093dcc
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,8 @@ cc_test {
           "VtsHalRadioV1_0TargetTest.cpp",
           "VtsHalRadioV1_0TargetTest.cpp",
           "vts_test_util.cpp"],
           "vts_test_util.cpp"],
    static_libs: [
    static_libs: [
        "android.hardware.radio@1.2",
        "android.hardware.radio@1.1",
        "android.hardware.radio@1.0",
        "android.hardware.radio@1.0",
    ],
    ],
}
}
@@ -44,6 +46,8 @@ cc_test {
           "VtsHalSapV1_0TargetTest.cpp",
           "VtsHalSapV1_0TargetTest.cpp",
           "vts_test_util.cpp"],
           "vts_test_util.cpp"],
    static_libs: [
    static_libs: [
        "android.hardware.radio@1.2",
        "android.hardware.radio@1.1",
        "android.hardware.radio@1.0",
        "android.hardware.radio@1.0",
    ],
    ],
}
}
@@ -55,6 +59,8 @@ cc_library_static {
        "vts_test_util.cpp"
        "vts_test_util.cpp"
    ],
    ],
    shared_libs: [
    shared_libs: [
        "android.hardware.radio@1.2",
        "android.hardware.radio@1.1",
        "android.hardware.radio@1.0",
        "android.hardware.radio@1.0",
    ],
    ],
}
}
+13 −9
Original line number Original line Diff line number Diff line
@@ -36,6 +36,9 @@ TEST_F(RadioHidlTest, getSignalStrength) {
 * Test IRadio.getVoiceRegistrationState() for the response returned.
 * Test IRadio.getVoiceRegistrationState() for the response returned.
 */
 */
TEST_F(RadioHidlTest, getVoiceRegistrationState) {
TEST_F(RadioHidlTest, getVoiceRegistrationState) {
    // The IRadio/IRadioResponse pair of this function is upgraded in 1.2.
    // For radio version < 1.2, skip to test this function.
    if (versionIRadio < v1_2) {
        serial = GetRandomSerialNumber();
        serial = GetRandomSerialNumber();


        radio->getVoiceRegistrationState(serial);
        radio->getVoiceRegistrationState(serial);
@@ -47,6 +50,7 @@ TEST_F(RadioHidlTest, getVoiceRegistrationState) {
            EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
            EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
        }
        }
    }
    }
}


/*
/*
 * Test IRadio.getOperator() for the response returned.
 * Test IRadio.getOperator() for the response returned.
+4 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,10 @@ void RadioHidlTest::SetUp() {
            RadioHidlEnvironment::Instance()->getServiceName<IRadio>(
            RadioHidlEnvironment::Instance()->getServiceName<IRadio>(
                hidl_string(RADIO_SERVICE_NAME)));
                hidl_string(RADIO_SERVICE_NAME)));
    }
    }

    versionIRadio = getIRadioVersion(radio);
    ASSERT_FALSE(unknown == versionIRadio);

    ASSERT_NE(nullptr, radio.get());
    ASSERT_NE(nullptr, radio.get());


    radioRsp = new (std::nothrow) RadioResponse(*this);
    radioRsp = new (std::nothrow) RadioResponse(*this);
+4 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ using namespace ::android::hardware::radio::V1_0;


using ::android::hardware::hidl_string;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_version;
using ::android::hardware::Return;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::Void;
using ::android::sp;
using ::android::sp;
@@ -536,6 +537,9 @@ class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    /* Serial number for radio request */
    /* Serial number for radio request */
    int serial;
    int serial;


    /* Version of radio service */
    hidl_version versionIRadio{0, 0};

    /* Update Sim Card Status */
    /* Update Sim Card Status */
    void updateSimCardStatus();
    void updateSimCardStatus();


+18 −0
Original line number Original line Diff line number Diff line
@@ -54,3 +54,21 @@ int GetRandomSerialNumber() {
    }
    }
    return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned";
    return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned";
}
}

hidl_version getIRadioVersion(sp<::android::hardware::radio::V1_0::IRadio> radio) {
    if (::android::hardware::radio::V1_2::IRadio::castFrom(radio).withDefault(nullptr) != nullptr) {
        ALOGI("Radio service version: 1.2");
        return v1_2;
    } else if (::android::hardware::radio::V1_1::IRadio::castFrom(radio).withDefault(nullptr) !=
               nullptr) {
        ALOGI("Radio service version: 1.1");
        return v1_1;
    } else if (::android::hardware::radio::V1_0::IRadio::castFrom(radio).withDefault(nullptr) !=
               nullptr) {
        ALOGI("Radio service version: 1.0");
        return v1_0;
    } else {
        ALOGI("Radio service version: unknown");
        return unknown;
    }
}
 No newline at end of file
Loading