From 62fd3447114d013082bae1bfaf7dd99a0d080ecf Mon Sep 17 00:00:00 2001 From: Jack Nudelman Date: Thu, 24 Sep 2020 14:23:35 -0700 Subject: [PATCH] HAL changes for ThermalMitigation API. go/telephony-thermal-mitigation Bug: 158872959 Test: make, vts Change-Id: I914993a6e80305732564e0507ca6a74b1c296439 --- radio/1.6/IRadio.hal | 25 +++++++ radio/1.6/IRadioResponse.hal | 11 ++++ radio/1.6/types.hal | 22 +++++++ .../1.6/vts/functional/radio_hidl_hal_api.cpp | 66 +++++++++++++++++++ .../functional/radio_hidl_hal_utils_v1_6.h | 3 + radio/1.6/vts/functional/radio_response.cpp | 7 ++ 6 files changed, 134 insertions(+) diff --git a/radio/1.6/IRadio.hal b/radio/1.6/IRadio.hal index a093dee18a..91709fabe7 100644 --- a/radio/1.6/IRadio.hal +++ b/radio/1.6/IRadio.hal @@ -320,4 +320,29 @@ interface IRadio extends @1.5::IRadio { */ oneway setAllowedNetworkTypeBitmap( uint32_t serial, bitfield networkTypeBitmap); + + /** + * Control data throttling at modem. + * - DataThrottlingAction:NO_DATA_THROTTLING should clear any existing + * data throttling within the requested completion window. + * - DataThrottlingAction:THROTTLE_SECONDARY_CARRIER: Remove any existing + * throttling on anchor carrier and achieve maximum data throttling on + * secondary carrier within the requested completion window. + * - DataThrottlingAction:THROTTLE_ANCHOR_CARRIER: disable secondary + * carrier and achieve maximum data throttling on anchor carrier by + * requested completion window. + * - DataThrottlingAction:HOLD: Immediately hold on to current level of + * throttling. + * + * @param serial Serial number of request. + * @param dataThrottlingAction DataThrottlingAction as defined in types.hal + * @param completionWindowSecs window, in seconds, in which the requested + * throttling action has to be achieved. This must be 0 when + * dataThrottlingAction is DataThrottlingAction:HOLD. + * + * Response function is IRadioResponse.setDataThrottlingResponse() + */ + oneway setDataThrottling(int32_t serial, + DataThrottlingAction dataThrottlingAction, + int32_t completionWindowSecs); }; diff --git a/radio/1.6/IRadioResponse.hal b/radio/1.6/IRadioResponse.hal index 0379e00329..acae5c7e22 100644 --- a/radio/1.6/IRadioResponse.hal +++ b/radio/1.6/IRadioResponse.hal @@ -306,4 +306,15 @@ interface IRadioResponse extends @1.5::IRadioResponse { * RadioError:NO_RESOURCES */ oneway setAllowedNetworkTypeBitmapResponse(RadioResponseInfo info); + + /** + * @param info Response info struct containing response type, serial no. and error + * + * Valid errors returned: + * RadioError:NONE + * RadioError:RADIO_NOT_AVAILABLE + * RadioError:MODEM_ERR + * RadioError:INVALID_ARGUMENTS + */ + oneway setDataThrottlingResponse(RadioResponseInfo info); }; diff --git a/radio/1.6/types.hal b/radio/1.6/types.hal index 4f32b3c66f..2cba9157f2 100644 --- a/radio/1.6/types.hal +++ b/radio/1.6/types.hal @@ -394,3 +394,25 @@ struct LinkCapacityEstimate { */ uint32_t secondaryUplinkCapacityKbps; }; + +enum DataThrottlingAction : int32_t { + /* Clear all existing data throttling. */ + NO_DATA_THROTTLING = 0, + + /** + * Enact secondary carrier data throttling and remove any existing data + * throttling on anchor carrier. + */ + THROTTLE_SECONDARY_CARRIER = 1, + + /** + * Enact anchor carrier data throttling and disable data on secondary + * carrier if currently enabled. + */ + THROTTLE_ANCHOR_CARRIER = 2, + + /** + * Immediately hold on to current level of throttling. + */ + HOLD = 3 +}; diff --git a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp index 6547611b50..ac84417ff8 100644 --- a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp @@ -295,3 +295,69 @@ TEST_P(RadioHidlTest_v1_6, isNrDualConnectivityEnabled) { ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR, ::android::hardware::radio::V1_6::RadioError::NONE})); } + +/* + * Test IRadio.setDataThrottling() for the response returned. + */ +TEST_P(RadioHidlTest_v1_6, setDataThrottling) { + serial = GetRandomSerialNumber(); + + Return res = radio_v1_6->setDataThrottling( + serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60); + ASSERT_OK(res); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error, + {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE, + ::android::hardware::radio::V1_6::RadioError::MODEM_ERR, + ::android::hardware::radio::V1_6::RadioError::NONE, + ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS})); + + serial = GetRandomSerialNumber(); + + res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER, 60); + ASSERT_OK(res); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error, + {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE, + ::android::hardware::radio::V1_6::RadioError::MODEM_ERR, + ::android::hardware::radio::V1_6::RadioError::NONE, + ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS})); + + serial = GetRandomSerialNumber(); + + res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::HOLD, 60); + ASSERT_OK(res); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error, + {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE, + ::android::hardware::radio::V1_6::RadioError::MODEM_ERR, + ::android::hardware::radio::V1_6::RadioError::NONE, + ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS})); + + serial = GetRandomSerialNumber(); + + res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60); + ASSERT_OK(res); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error, + {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE, + ::android::hardware::radio::V1_6::RadioError::MODEM_ERR, + ::android::hardware::radio::V1_6::RadioError::NONE, + ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS})); +} \ No newline at end of file diff --git a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h index 6189be6add..31bb1d7114 100644 --- a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h +++ b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h @@ -792,6 +792,9 @@ class RadioResponse_v1_6 : public ::android::hardware::radio::V1_6::IRadioRespon Return setAllowedNetworkTypeBitmapResponse( const ::android::hardware::radio::V1_6::RadioResponseInfo& info); + + Return setDataThrottlingResponse( + const ::android::hardware::radio::V1_6::RadioResponseInfo& info); }; /* Callback class for radio indication */ diff --git a/radio/1.6/vts/functional/radio_response.cpp b/radio/1.6/vts/functional/radio_response.cpp index 18cda6aae4..09a2baced4 100644 --- a/radio/1.6/vts/functional/radio_response.cpp +++ b/radio/1.6/vts/functional/radio_response.cpp @@ -1156,3 +1156,10 @@ Return RadioResponse_v1_6::setAllowedNetworkTypeBitmapResponse( parent_v1_6.notify(info.serial); return Void(); } + +Return RadioResponse_v1_6::setDataThrottlingResponse( + const ::android::hardware::radio::V1_6::RadioResponseInfo& info) { + rspInfo = info; + parent_v1_6.notify(info.serial); + return Void(); +}