From a164db9e840ed9265403394a10bde3f778c7e6ac Mon Sep 17 00:00:00 2001 From: Malcolm Chen Date: Tue, 12 Nov 2019 19:03:12 -0800 Subject: [PATCH] Adding HAL API for disabling subscription Bug: 141018421 Test: vts on cuttlefish Change-Id: I90ded163ddc047916c205513ab77a886ebcc48f7 --- .../compatibility_matrix.current.xml | 2 +- current.txt | 7 +- radio/1.5/IRadio.hal | 41 +++++ radio/1.5/IRadioIndication.hal | 7 + radio/1.5/IRadioResponse.hal | 37 ++++ .../1.5/vts/functional/radio_hidl_hal_api.cpp | 170 ++++++++++++++++++ .../functional/radio_hidl_hal_utils_v1_5.h | 13 ++ radio/1.5/vts/functional/radio_indication.cpp | 5 + radio/1.5/vts/functional/radio_response.cpp | 24 ++- 9 files changed, 301 insertions(+), 5 deletions(-) diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index 99ffeaedfc..c6fd76ed7e 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -349,7 +349,7 @@ android.hardware.radio - 1.4 + 1.5 IRadio slot1 diff --git a/current.txt b/current.txt index 34621a585d..676beb0be2 100644 --- a/current.txt +++ b/current.txt @@ -612,10 +612,11 @@ a64467bae843569f0d465c5be7f0c7a5b987985b55a3ef4794dd5afc68538650 android.hardwar c9273429fcf98d797d3bb07fdba6f1be95bf960f9255cde169fd1ca4db85f856 android.hardware.wifi.supplicant@1.3::ISupplicantStaNetwork 9b0a3ab6f4f74b971ed094426d8a443e29b512ff03e1ab50c07156396cdb2483 android.hardware.wifi.supplicant@1.3::types 274fb1254a6d1a97824ec5c880eeefc0e410dc6d3a2a4c34052201169d2b7de0 android.hardware.radio@1.5::types -c8e81d912827a5d49b2ddcdc4eb4556c5d231a899a1dca879309e04210daa4a0 android.hardware.radio@1.5::IRadio -a62a93faf173b14a6175b683ebf61ffa568dc61f81e369d2dce7b1265e86cf2f android.hardware.radio@1.5::IRadioIndication -260ce05806d753d728f844d405e832179ed7d9b65986ec18fef3d21cf7285587 android.hardware.radio@1.5::IRadioResponse +4c666aaf3944ad91c2428b8456d0db4a2f81191f8c294f046a2f539e9fc7b6fd android.hardware.radio@1.5::IRadio +3afac66f21a33bc9c4b80481c7d5540038348651d9a7d8af64ea13610af138da android.hardware.radio@1.5::IRadioIndication +70e977f2ccefd2e503bedb3a66313639b53fbc7bde025538b07f41e2292b6624 android.hardware.radio@1.5::IRadioResponse 55f0a15642869ec98a55ea0a5ac049d3e1a6245ff7750deb6bcb7182057eee83 android.hardware.radio.config@1.3::types b27ab0cd40b0b078cdcd024bfe1061c4c4c065f3519eeb9347fa359a3268a5ae android.hardware.radio.config@1.3::IRadioConfig 742360c775313438b0f82256eac62fb5bbc76a6ae6f388573f3aa142fb2c1eea android.hardware.radio.config@1.3::IRadioConfigIndication 7683fed9d253956071f18b152e6be657719536f98d9b534433d5e411bcde5061 android.hardware.radio.config@1.3::IRadioConfigResponse + diff --git a/radio/1.5/IRadio.hal b/radio/1.5/IRadio.hal index 74ec56d4da..a3001fdfa2 100644 --- a/radio/1.5/IRadio.hal +++ b/radio/1.5/IRadio.hal @@ -55,4 +55,45 @@ interface IRadio extends @1.4::IRadio { */ oneway setSignalStrengthReportingCriteria_1_5(int32_t serial, SignalThresholdInfo signalThresholdInfo, AccessNetwork accessNetwork); + + /** + * Enable or disable UiccApplications on the SIM. If disabled: + * - Modem will not register on any network. + * - SIM must be PRESENT, and the IccId of the SIM must still be accessible. + * - The corresponding modem stack is still functional, e.g. able to make emergency calls or + * do network scan. + * By default if this API is not called, the uiccApplications must be enabled automatically. + * It must work for both single SIM and DSDS cases for UX consistency. + * The preference is per SIM, and must be remembered over power cycle, modem reboot, or SIM + * insertion / unplug. + * + * @param serial: Serial number of request. + * @param enable: true if to enable uiccApplications, false to disable. + + * Response callback is IRadioResponse.enableUiccApplicationsResponse() + */ + oneway enableUiccApplications(int32_t serial, bool enable); + + /** + * Whether uiccApplications are enabled, or disabled. + * + * By default uiccApplications must be enabled, unless enableUiccApplications() with enable + * being false is called. + * + * @param serial Serial number of request. + * + * Response callback is IRadioResponse.areUiccApplicationsEnabledResponse() + */ + oneway areUiccApplicationsEnabled(int32_t serial); + + /** + * Query whether disabling and enabling UiccApplications functionality is supported. If not, + * calling enableUiccApplications with a different value will return + * RadioError:REQUEST_NOT_SUPPORTED. + * + * @param serial Serial number of request. + * + * Response callback is IRadioResponse.canToggleUiccApplicationsEnablementResponse() + */ + oneway canToggleUiccApplicationsEnablement(int32_t serial); }; diff --git a/radio/1.5/IRadioIndication.hal b/radio/1.5/IRadioIndication.hal index d4884041c5..81452abb13 100644 --- a/radio/1.5/IRadioIndication.hal +++ b/radio/1.5/IRadioIndication.hal @@ -23,4 +23,11 @@ import @1.4::IRadioIndication; * Interface declaring unsolicited radio indications. */ interface IRadioIndication extends @1.4::IRadioIndication { + /** + * Report change of whether uiccApplications are enabled, or disabled. + * + * @param type Type of radio indication + * @param enabled whether uiccApplications are enabled, or disabled + */ + oneway uiccApplicationsEnablementChanged(RadioIndicationType type, bool enabled); }; diff --git a/radio/1.5/IRadioResponse.hal b/radio/1.5/IRadioResponse.hal index 91dc1e0d86..c136ba610a 100644 --- a/radio/1.5/IRadioResponse.hal +++ b/radio/1.5/IRadioResponse.hal @@ -32,4 +32,41 @@ interface IRadioResponse extends @1.4::IRadioResponse { * RadioError:RADIO_NOT_AVAILABLE */ oneway setSignalStrengthReportingCriteriaResponse_1_5(RadioResponseInfo info); + + /** + * @param info Response info struct containing response type, serial no. and error + * + * Valid errors returned: + * RadioError:NONE + * RadioError:SIM_ABSENT + * RadioError:RADIO_NOT_AVAILABLE + * RadioError:INTERNAL_ERR + * RadioError:BUSY + * RadioError:REQUEST_NOT_SUPPORTED + */ + oneway enableUiccApplicationsResponse(RadioResponseInfo info); + + /** + * @param info Response info struct containing response type, serial no. and error + * @param enabled whether Uicc applications are enabled. + * + * Valid errors returned: + * RadioError:NONE + * RadioError:SIM_ABSENT + * RadioError:RADIO_NOT_AVAILABLE + * RadioError:INTERNAL_ERR + * RadioError:REQUEST_NOT_SUPPORTED + */ + oneway areUiccApplicationsEnabledResponse(RadioResponseInfo info, bool enabled); + + /** + * @param info Response info struct containing response type, serial no. and error + * @param canToggle whether toggling UiccApplications functionality is supported. + * + * Valid errors returned: + * RadioError:NONE + * RadioError:RADIO_NOT_AVAILABLE + * RadioError:INTERNAL_ERR + */ + oneway canToggleUiccApplicationsEnablementResponse(RadioResponseInfo info, bool canToggle); }; diff --git a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp index d173411bca..72e8d5ebb3 100644 --- a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp @@ -276,3 +276,173 @@ TEST_F(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_NGRAN_SSSINR) toString(radioRsp_v1_5->rspInfo.error).c_str()); ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE})); } + +/* + * Test IRadio.enableUiccApplications() for the response returned. + */ +TEST_F(RadioHidlTest_v1_5, togglingUiccApplicationsNotSupported) { + serial = GetRandomSerialNumber(); + + radio_v1_5->canToggleUiccApplicationsEnablement(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // No error should happen. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + + // Supported case will be tested by other test cases. + if (radioRsp_v1_5->canToggleUiccApplicationsEnablement) return; + + // Enabling UiccApplications should still work as it should be enabled by default. + serial = GetRandomSerialNumber(); + radio_v1_5->enableUiccApplications(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + + // Disabling UiccApplications should return REQUEST_NOT_SUPPORTED error. + serial = GetRandomSerialNumber(); + radio_v1_5->enableUiccApplications(serial, false); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + EXPECT_EQ(RadioError::REQUEST_NOT_SUPPORTED, radioRsp_v1_5->rspInfo.error); + + // Query areUiccApplicationsEnabled should return true. + serial = GetRandomSerialNumber(); + radio_v1_5->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + ASSERT_TRUE(radioRsp_v1_5->areUiccApplicationsEnabled); +} + +/* + * Test IRadio.enableUiccApplications() for the response returned. + * For SIM ABSENT case. + */ +TEST_F(RadioHidlTest_v1_5, togglingUiccApplicationsSupportedSimAbsent) { + serial = GetRandomSerialNumber(); + + radio_v1_5->canToggleUiccApplicationsEnablement(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // No error should happen. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + // Not supported case will be tested by togglingUiccApplicationsNotSupported test case. + if (!radioRsp_v1_5->canToggleUiccApplicationsEnablement) return; + + // This test case only test SIM ABSENT case. + if (cardStatus.base.base.cardState != CardState::ABSENT) return; + + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_v1_5->enableUiccApplications(serial, false); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is absent, RadioError::SIM_ABSENT should be thrown. + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_v1_5->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is absent, RadioError::SIM_ABSENT should be thrown. + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error); +} + +/* + * Test IRadio.enableUiccApplications() for the response returned. + * For SIM PRESENT case. + */ +TEST_F(RadioHidlTest_v1_5, togglingUiccApplicationsSupportedSimPresent) { + serial = GetRandomSerialNumber(); + + radio_v1_5->canToggleUiccApplicationsEnablement(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // No error should happen. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + // Not supported case will be tested by disablingUiccApplicationsNotSupported test case. + if (!radioRsp_v1_5->canToggleUiccApplicationsEnablement) return; + + // This test case only test SIM ABSENT case. + if (cardStatus.base.base.cardState != CardState::PRESENT) return; + + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_v1_5->enableUiccApplications(serial, false); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_v1_5->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + ASSERT_FALSE(radioRsp_v1_5->areUiccApplicationsEnabled); + + // Enable Uicc applications. + serial = GetRandomSerialNumber(); + radio_v1_5->enableUiccApplications(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_v1_5->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + ASSERT_TRUE(radioRsp_v1_5->areUiccApplicationsEnabled); +} + +/* + * Test IRadio.areUiccApplicationsEnabled() for the response returned. + */ +TEST_F(RadioHidlTest_v1_5, areUiccApplicationsEnabled) { + serial = GetRandomSerialNumber(); + + radio_v1_5->canToggleUiccApplicationsEnablement(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + // No error should happen. + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + + // Not supported case will be tested by togglingUiccApplicationsNotSupported test case. + if (!radioRsp_v1_5->canToggleUiccApplicationsEnablement) return; + + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_v1_5->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + + // If SIM is absent, RadioError::SIM_ABSENT should be thrown. Otherwise there shouldn't be any + // error. + if (cardStatus.base.base.cardState == CardState::ABSENT) { + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error); + } else if (cardStatus.base.base.cardState == CardState::PRESENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error); + } +} diff --git a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h index 683fdfc5fb..c05359d631 100644 --- a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h +++ b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h @@ -80,6 +80,12 @@ class RadioResponse_v1_5 : public ::android::hardware::radio::V1_5::IRadioRespon ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority carrierRestrictionsResp; ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicyResp; + // Whether toggling uicc applications operation is supported. + bool canToggleUiccApplicationsEnablement; + + // Whether Uicc applications are enabled or not. + bool areUiccApplicationsEnabled; + RadioResponse_v1_5(RadioHidlTest_v1_5& parent_v1_5); virtual ~RadioResponse_v1_5() = default; @@ -524,6 +530,10 @@ class RadioResponse_v1_5 : public ::android::hardware::radio::V1_5::IRadioRespon /* 1.5 Api */ Return setSignalStrengthReportingCriteriaResponse_1_5(const RadioResponseInfo& info); + Return enableUiccApplicationsResponse(const RadioResponseInfo& info); + Return areUiccApplicationsEnabledResponse(const RadioResponseInfo& info, bool enabled); + Return canToggleUiccApplicationsEnablementResponse(const RadioResponseInfo& info, + bool canToggle); }; /* Callback class for radio indication */ @@ -535,6 +545,9 @@ class RadioIndication_v1_5 : public ::android::hardware::radio::V1_5::IRadioIndi RadioIndication_v1_5(RadioHidlTest_v1_5& parent_v1_5); virtual ~RadioIndication_v1_5() = default; + /* 1.5 Api */ + Return uiccApplicationsEnablementChanged(RadioIndicationType type, bool enabled); + /* 1.4 Api */ Return currentEmergencyNumberList( RadioIndicationType type, diff --git a/radio/1.5/vts/functional/radio_indication.cpp b/radio/1.5/vts/functional/radio_indication.cpp index b63b74571e..acffbbea3d 100644 --- a/radio/1.5/vts/functional/radio_indication.cpp +++ b/radio/1.5/vts/functional/radio_indication.cpp @@ -328,3 +328,8 @@ Return RadioIndication_v1_5::modemReset(RadioIndicationType /*type*/, const ::android::hardware::hidl_string& /*reason*/) { return Void(); } + +Return RadioIndication_v1_5::uiccApplicationsEnablementChanged(RadioIndicationType /*type*/, + bool /*enabled*/) { + return Void(); +} diff --git a/radio/1.5/vts/functional/radio_response.cpp b/radio/1.5/vts/functional/radio_response.cpp index 29a92506ab..78c03a9773 100644 --- a/radio/1.5/vts/functional/radio_response.cpp +++ b/radio/1.5/vts/functional/radio_response.cpp @@ -892,4 +892,26 @@ Return RadioResponse_v1_5::setSignalStrengthReportingCriteriaResponse_1_5( rspInfo = info; parent_v1_5.notify(info.serial); return Void(); -} \ No newline at end of file +} + +Return RadioResponse_v1_5::enableUiccApplicationsResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_v1_5.notify(info.serial); + return Void(); +} + +Return RadioResponse_v1_5::areUiccApplicationsEnabledResponse(const RadioResponseInfo& info, + bool enabled) { + rspInfo = info; + areUiccApplicationsEnabled = enabled; + parent_v1_5.notify(info.serial); + return Void(); +} + +Return RadioResponse_v1_5::canToggleUiccApplicationsEnablementResponse( + const RadioResponseInfo& info, bool canToggle) { + rspInfo = info; + canToggleUiccApplicationsEnablement = canToggle; + parent_v1_5.notify(info.serial); + return Void(); +}