VTS workaround for RadioSimTest#setAllowedCarriers
This change fixes setAllowedCarriers test enough for VTS to pass on CF:
- update libradiocompat to support new fields allowedCarrierInfoList
and excludedCarrierInfoList
- update radio VTS to use the same MCC and MNC as the one used by CF HAL
(this was never properly tested, needs to be fixed later)
- update radio VTS to not test fields unsupported by CF HAL
(this needs to be re-enabled later)
This test was broken by change I940fd4ecdc70cb4e31802cefc1ae1d02436ffe90
but never catched due to VTS being disabled for CF on TreeHugger.
Bug: 365568518
Test: atest VtsHalRadioTargetTest
Change-Id: Iea8e771eb6d7982220a0f2b6522467397d87f2ce
diff --git a/radio/aidl/compat/libradiocompat/sim/structs.cpp b/radio/aidl/compat/libradiocompat/sim/structs.cpp
index 00db2b8..27aca60 100644
--- a/radio/aidl/compat/libradiocompat/sim/structs.cpp
+++ b/radio/aidl/compat/libradiocompat/sim/structs.cpp
@@ -70,26 +70,60 @@
};
}
-aidl::CarrierRestrictions toAidl(const V1_0::CarrierRestrictions& cr) {
+static aidl::CarrierInfo toCarrierInfo(const aidl::Carrier& carrier) {
return {
- .allowedCarriers = toAidl(cr.allowedCarriers),
- .excludedCarriers = toAidl(cr.excludedCarriers),
+ .mcc = carrier.mcc,
+ .mnc = carrier.mnc,
+ };
+}
+
+static std::vector<aidl::CarrierInfo> toCarrierInfos(const std::vector<aidl::Carrier>& carriers) {
+ std::vector<aidl::CarrierInfo> infos(carriers.size());
+ for (size_t i = 0; i < carriers.size(); i++) {
+ infos[i] = toCarrierInfo(carriers[i]);
+ }
+ return infos;
+}
+
+V1_0::Carrier toHidl(const aidl::CarrierInfo& carrierInfo) {
+ return {
+ .mcc = carrierInfo.mcc,
+ .mnc = carrierInfo.mnc,
+ };
+}
+
+aidl::CarrierRestrictions toAidl(const V1_0::CarrierRestrictions& cr) {
+ auto allowedCarriers = toAidl(cr.allowedCarriers);
+ auto excludedCarriers = toAidl(cr.excludedCarriers);
+ return {
+ .allowedCarriers = allowedCarriers,
+ .excludedCarriers = excludedCarriers,
.allowedCarriersPrioritized = true,
+ .allowedCarrierInfoList = toCarrierInfos(allowedCarriers),
+ .excludedCarrierInfoList = toCarrierInfos(excludedCarriers),
};
}
aidl::CarrierRestrictions toAidl(const V1_4::CarrierRestrictionsWithPriority& cr) {
+ auto allowedCarriers = toAidl(cr.allowedCarriers);
+ auto excludedCarriers = toAidl(cr.excludedCarriers);
return {
- .allowedCarriers = toAidl(cr.allowedCarriers),
- .excludedCarriers = toAidl(cr.excludedCarriers),
+ .allowedCarriers = allowedCarriers,
+ .excludedCarriers = excludedCarriers,
.allowedCarriersPrioritized = cr.allowedCarriersPrioritized,
+ .allowedCarrierInfoList = toCarrierInfos(allowedCarriers),
+ .excludedCarrierInfoList = toCarrierInfos(excludedCarriers),
};
}
V1_4::CarrierRestrictionsWithPriority toHidl(const aidl::CarrierRestrictions& cr) {
return {
- .allowedCarriers = toHidl(cr.allowedCarriers),
- .excludedCarriers = toHidl(cr.excludedCarriers),
+ .allowedCarriers = (cr.allowedCarriers.size() > cr.allowedCarrierInfoList.size())
+ ? toHidl(cr.allowedCarriers)
+ : toHidl(cr.allowedCarrierInfoList),
+ .excludedCarriers = (cr.excludedCarriers.size() > cr.excludedCarrierInfoList.size())
+ ? toHidl(cr.excludedCarriers)
+ : toHidl(cr.excludedCarrierInfoList),
.allowedCarriersPrioritized = cr.allowedCarriersPrioritized,
};
}
diff --git a/radio/aidl/compat/libradiocompat/sim/structs.h b/radio/aidl/compat/libradiocompat/sim/structs.h
index 54099b7..7774bee 100644
--- a/radio/aidl/compat/libradiocompat/sim/structs.h
+++ b/radio/aidl/compat/libradiocompat/sim/structs.h
@@ -37,6 +37,7 @@
::aidl::android::hardware::radio::sim::Carrier toAidl(const V1_0::Carrier& carrier);
V1_0::Carrier toHidl(const ::aidl::android::hardware::radio::sim::Carrier& carrier);
+V1_0::Carrier toHidl(const ::aidl::android::hardware::radio::sim::CarrierInfo& carrierInfo);
::aidl::android::hardware::radio::sim::CarrierRestrictions //
toAidl(const V1_0::CarrierRestrictions& cr);