mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 21:37:44 +00:00
Merge "Handle radio API in low version VTS for high version service" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1e757749fb
@@ -31,6 +31,8 @@ cc_test {
|
||||
"VtsHalRadioV1_0TargetTest.cpp",
|
||||
"vts_test_util.cpp"],
|
||||
static_libs: [
|
||||
"android.hardware.radio@1.2",
|
||||
"android.hardware.radio@1.1",
|
||||
"android.hardware.radio@1.0",
|
||||
],
|
||||
}
|
||||
@@ -44,6 +46,8 @@ cc_test {
|
||||
"VtsHalSapV1_0TargetTest.cpp",
|
||||
"vts_test_util.cpp"],
|
||||
static_libs: [
|
||||
"android.hardware.radio@1.2",
|
||||
"android.hardware.radio@1.1",
|
||||
"android.hardware.radio@1.0",
|
||||
],
|
||||
}
|
||||
@@ -55,6 +59,8 @@ cc_library_static {
|
||||
"vts_test_util.cpp"
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.radio@1.2",
|
||||
"android.hardware.radio@1.1",
|
||||
"android.hardware.radio@1.0",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -36,15 +36,19 @@ TEST_F(RadioHidlTest, getSignalStrength) {
|
||||
* Test IRadio.getVoiceRegistrationState() for the response returned.
|
||||
*/
|
||||
TEST_F(RadioHidlTest, getVoiceRegistrationState) {
|
||||
serial = GetRandomSerialNumber();
|
||||
// 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();
|
||||
|
||||
radio->getVoiceRegistrationState(serial);
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
|
||||
radio->getVoiceRegistrationState(serial);
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
|
||||
|
||||
if (cardStatus.cardState == CardState::ABSENT) {
|
||||
EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
|
||||
if (cardStatus.cardState == CardState::ABSENT) {
|
||||
EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ void RadioHidlTest::SetUp() {
|
||||
RadioHidlEnvironment::Instance()->getServiceName<IRadio>(
|
||||
hidl_string(RADIO_SERVICE_NAME)));
|
||||
}
|
||||
|
||||
versionIRadio = getIRadioVersion(radio);
|
||||
ASSERT_FALSE(unknown == versionIRadio);
|
||||
|
||||
ASSERT_NE(nullptr, radio.get());
|
||||
|
||||
radioRsp = new (std::nothrow) RadioResponse(*this);
|
||||
|
||||
@@ -33,6 +33,7 @@ using namespace ::android::hardware::radio::V1_0;
|
||||
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_version;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
@@ -536,6 +537,9 @@ class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
/* Serial number for radio request */
|
||||
int serial;
|
||||
|
||||
/* Version of radio service */
|
||||
hidl_version versionIRadio{0, 0};
|
||||
|
||||
/* Update Sim Card Status */
|
||||
void updateSimCardStatus();
|
||||
|
||||
|
||||
@@ -54,3 +54,21 @@ int GetRandomSerialNumber() {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef VTS_TEST_UTIL_H
|
||||
#define VTS_TEST_UTIL_H 1
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include <android/hardware/radio/1.0/IRadio.h>
|
||||
#include <android/hardware/radio/1.0/types.h>
|
||||
#include <android/hardware/radio/1.1/IRadio.h>
|
||||
#include <android/hardware/radio/1.2/IRadio.h>
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_version;
|
||||
using ::android::hardware::radio::V1_0::RadioError;
|
||||
using ::android::hardware::radio::V1_0::SapResultCode;
|
||||
using namespace std;
|
||||
@@ -32,6 +40,14 @@ enum CheckFlag {
|
||||
CHECK_SAP_ERROR = 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* Radio hidl version parameters.
|
||||
*/
|
||||
const hidl_version v1_0(1, 0);
|
||||
const hidl_version v1_1(1, 1);
|
||||
const hidl_version v1_2(1, 2);
|
||||
const hidl_version unknown(0, 0);
|
||||
|
||||
/*
|
||||
* Generate random serial number for radio test
|
||||
*/
|
||||
@@ -48,3 +64,10 @@ int GetRandomSerialNumber();
|
||||
* vendor/devices implementations.
|
||||
*/
|
||||
::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors);
|
||||
|
||||
/*
|
||||
* Get the radio service version.
|
||||
*/
|
||||
hidl_version getIRadioVersion(sp<::android::hardware::radio::V1_0::IRadio> radio);
|
||||
|
||||
#endif /*VTS_TEST_UTIL_H*/
|
||||
@@ -24,6 +24,7 @@ cc_test {
|
||||
"VtsHalRadioV1_1TargetTest.cpp"],
|
||||
static_libs: [
|
||||
"RadioVtsTestUtilBase",
|
||||
"android.hardware.radio@1.2",
|
||||
"android.hardware.radio@1.1",
|
||||
"android.hardware.radio@1.0",
|
||||
],
|
||||
|
||||
@@ -30,6 +30,10 @@ void RadioHidlTest_v1_1::SetUp() {
|
||||
->getServiceName<::android::hardware::radio::V1_1::IRadio>(
|
||||
hidl_string(RADIO_SERVICE_NAME)));
|
||||
}
|
||||
|
||||
versionIRadio = getIRadioVersion(radio_v1_1);
|
||||
ASSERT_FALSE(unknown == versionIRadio);
|
||||
|
||||
ASSERT_NE(nullptr, radio_v1_1.get());
|
||||
|
||||
radioRsp_v1_1 = new (std::nothrow) RadioResponse_v1_1(*this);
|
||||
|
||||
@@ -561,6 +561,9 @@ class RadioHidlTest_v1_1 : public ::testing::VtsHalHidlTargetTestBase {
|
||||
/* Serial number for radio request */
|
||||
int serial;
|
||||
|
||||
/* Version of radio service */
|
||||
hidl_version versionIRadio{0, 0};
|
||||
|
||||
/* Update Sim Card Status */
|
||||
void updateSimCardStatus();
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ void RadioHidlTest_v1_2::SetUp() {
|
||||
->getServiceName<::android::hardware::radio::V1_2::IRadio>(
|
||||
hidl_string(RADIO_SERVICE_NAME)));
|
||||
}
|
||||
|
||||
versionIRadio = getIRadioVersion(radio_v1_2);
|
||||
ASSERT_FALSE(unknown == versionIRadio);
|
||||
|
||||
ASSERT_NE(nullptr, radio_v1_2.get());
|
||||
|
||||
radioRsp_v1_2 = new (std::nothrow) RadioResponse_v1_2(*this);
|
||||
|
||||
@@ -616,6 +616,9 @@ class RadioHidlTest_v1_2 : public ::testing::VtsHalHidlTargetTestBase {
|
||||
/* Serial number for radio request */
|
||||
int serial;
|
||||
|
||||
/* Version of radio service */
|
||||
hidl_version versionIRadio{0, 0};
|
||||
|
||||
/* Update Sim Card Status */
|
||||
void updateSimCardStatus();
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ cc_test {
|
||||
static_libs: [
|
||||
"RadioVtsTestUtilBase",
|
||||
"android.hardware.radio.config@1.0",
|
||||
"android.hardware.radio@1.2",
|
||||
"android.hardware.radio@1.1",
|
||||
"android.hardware.radio@1.0",
|
||||
],
|
||||
header_libs: ["radio.util.header@1.0"],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user