Merge "Fix type conversion from aidl::AccessNetworks to hidl::RadioAccessNetworks"

This commit is contained in:
Gary Jian 2022-03-18 03:51:42 +00:00 committed by Gerrit Code Review
commit b9fbe11dfe
3 changed files with 44 additions and 3 deletions

View file

@ -228,7 +228,7 @@ ScopedAStatus RadioNetwork::setNetworkSelectionModeAutomatic(int32_t serial) {
ScopedAStatus RadioNetwork::setNetworkSelectionModeManual( //
int32_t serial, const std::string& opNumeric, AccessNetwork ran) {
LOG_CALL << serial;
mHal1_5->setNetworkSelectionModeManual_1_5(serial, opNumeric, V1_5::RadioAccessNetworks(ran));
mHal1_5->setNetworkSelectionModeManual_1_5(serial, opNumeric, toRadioAccessNetworks(ran));
return ok();
}

View file

@ -98,17 +98,56 @@ static V1_5::RadioAccessSpecifier::Bands toHidl(const aidl::RadioAccessSpecifier
return hidl;
}
AccessNetwork fromRadioAccessNetwork(V1_5::RadioAccessNetworks ran) {
switch (ran) {
case V1_5::RadioAccessNetworks::UNKNOWN:
return AccessNetwork::UNKNOWN;
case V1_5::RadioAccessNetworks::GERAN:
return AccessNetwork::GERAN;
case V1_5::RadioAccessNetworks::UTRAN:
return AccessNetwork::UTRAN;
case V1_5::RadioAccessNetworks::EUTRAN:
return AccessNetwork::EUTRAN;
case V1_5::RadioAccessNetworks::CDMA2000:
return AccessNetwork::CDMA2000;
case V1_5::RadioAccessNetworks::NGRAN:
return AccessNetwork::NGRAN;
default:
return AccessNetwork::UNKNOWN;
}
}
aidl::RadioAccessSpecifier toAidl(const V1_5::RadioAccessSpecifier& spec) {
return {
.accessNetwork = AccessNetwork(spec.radioAccessNetwork),
.accessNetwork = fromRadioAccessNetwork(spec.radioAccessNetwork),
.bands = toAidl(spec.bands),
.channels = spec.channels,
};
}
V1_5::RadioAccessNetworks toRadioAccessNetworks(AccessNetwork val) {
switch (val) {
case AccessNetwork::UNKNOWN:
return V1_5::RadioAccessNetworks::UNKNOWN;
case AccessNetwork::GERAN:
return V1_5::RadioAccessNetworks::GERAN;
case AccessNetwork::UTRAN:
return V1_5::RadioAccessNetworks::UTRAN;
case AccessNetwork::EUTRAN:
return V1_5::RadioAccessNetworks::EUTRAN;
case AccessNetwork::CDMA2000:
return V1_5::RadioAccessNetworks::CDMA2000;
case AccessNetwork::NGRAN:
return V1_5::RadioAccessNetworks::NGRAN;
case AccessNetwork::IWLAN:
default:
return V1_5::RadioAccessNetworks::UNKNOWN;
}
}
V1_5::RadioAccessSpecifier toHidl(const aidl::RadioAccessSpecifier& spec) {
return {
.radioAccessNetwork = V1_5::RadioAccessNetworks{spec.accessNetwork},
.radioAccessNetwork = toRadioAccessNetworks(spec.accessNetwork),
.bands = toHidl(spec.bands),
.channels = spec.channels,
};

View file

@ -49,6 +49,8 @@ toHidl(const ::aidl::android::hardware::radio::network::SignalThresholdInfo& inf
::aidl::android::hardware::radio::network::RadioAccessSpecifier //
toAidl(const V1_5::RadioAccessSpecifier& spec);
V1_5::RadioAccessNetworks //
toRadioAccessNetworks(::aidl::android::hardware::radio::AccessNetwork val);
V1_5::RadioAccessSpecifier //
toHidl(const ::aidl::android::hardware::radio::network::RadioAccessSpecifier& spec);