• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <radio_hidl_hal_utils_v1_0.h>
18 
19 using namespace ::android::hardware::radio::V1_0;
20 
21 /*
22  * Test IRadio.getClir() for the response returned.
23  */
TEST_F(RadioHidlTest,getClir)24 TEST_F(RadioHidlTest, getClir) {
25     serial = GetRandomSerialNumber();
26 
27     radio->getClir(serial);
28 
29     EXPECT_EQ(std::cv_status::no_timeout, wait());
30     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
31     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
32 
33     if (cardStatus.cardState == CardState::ABSENT) {
34         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::MODEM_ERR},
35                                      CHECK_GENERAL_ERROR));
36     }
37 }
38 
39 /*
40  * Test IRadio.setClir() for the response returned.
41  */
TEST_F(RadioHidlTest,setClir)42 TEST_F(RadioHidlTest, setClir) {
43     serial = GetRandomSerialNumber();
44     int32_t status = 1;
45 
46     radio->setClir(serial, status);
47 
48     EXPECT_EQ(std::cv_status::no_timeout, wait());
49     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
50     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
51 
52     if (cardStatus.cardState == CardState::ABSENT) {
53         EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
54     }
55 }
56 
57 /*
58  * Test IRadio.getFacilityLockForApp() for the response returned.
59  */
TEST_F(RadioHidlTest,getFacilityLockForApp)60 TEST_F(RadioHidlTest, getFacilityLockForApp) {
61     serial = GetRandomSerialNumber();
62     std::string facility = "";
63     std::string password = "";
64     int32_t serviceClass = 1;
65     std::string appId = "";
66 
67     radio->getFacilityLockForApp(serial, facility, password, serviceClass, appId);
68 
69     EXPECT_EQ(std::cv_status::no_timeout, wait());
70     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
71     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
72 
73     if (cardStatus.cardState == CardState::ABSENT) {
74         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
75                                      {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
76                                      CHECK_GENERAL_ERROR));
77     }
78 }
79 
80 /*
81  * Test IRadio.setFacilityLockForApp() for the response returned.
82  */
TEST_F(RadioHidlTest,setFacilityLockForApp)83 TEST_F(RadioHidlTest, setFacilityLockForApp) {
84     serial = GetRandomSerialNumber();
85     std::string facility = "";
86     bool lockState = false;
87     std::string password = "";
88     int32_t serviceClass = 1;
89     std::string appId = "";
90 
91     radio->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId);
92 
93     EXPECT_EQ(std::cv_status::no_timeout, wait());
94     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
95     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
96 
97     if (cardStatus.cardState == CardState::ABSENT) {
98         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
99                                      {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
100                                      CHECK_GENERAL_ERROR));
101     }
102 }
103 
104 /*
105  * Test IRadio.setBarringPassword() for the response returned.
106  */
TEST_F(RadioHidlTest,setBarringPassword)107 TEST_F(RadioHidlTest, setBarringPassword) {
108     serial = GetRandomSerialNumber();
109     std::string facility = "";
110     std::string oldPassword = "";
111     std::string newPassword = "";
112 
113     radio->setBarringPassword(serial, facility, oldPassword, newPassword);
114 
115     EXPECT_EQ(std::cv_status::no_timeout, wait());
116     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
117     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
118 
119     if (cardStatus.cardState == CardState::ABSENT) {
120         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
121                                      {RadioError::NONE, RadioError::FDN_CHECK_FAILURE,
122                                       RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
123                                      CHECK_GENERAL_ERROR));
124     }
125 }
126 
127 /*
128  * Test IRadio.getClip() for the response returned.
129  */
TEST_F(RadioHidlTest,getClip)130 TEST_F(RadioHidlTest, getClip) {
131     serial = GetRandomSerialNumber();
132 
133     radio->getClip(serial);
134 
135     EXPECT_EQ(std::cv_status::no_timeout, wait());
136     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
137     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
138 
139     if (cardStatus.cardState == CardState::ABSENT) {
140         ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::MODEM_ERR},
141                                      CHECK_GENERAL_ERROR));
142     }
143 }
144 
145 /*
146  * Test IRadio.setSuppServiceNotifications() for the response returned.
147  */
TEST_F(RadioHidlTest,setSuppServiceNotifications)148 TEST_F(RadioHidlTest, setSuppServiceNotifications) {
149     serial = GetRandomSerialNumber();
150     bool enable = false;
151 
152     radio->setSuppServiceNotifications(serial, enable);
153 
154     EXPECT_EQ(std::cv_status::no_timeout, wait());
155     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
156     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
157 
158     if (cardStatus.cardState == CardState::ABSENT) {
159         ASSERT_TRUE(
160             CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE, RadioError::SIM_ABSENT}));
161     }
162 }
163 
164 /*
165  * Test IRadio.requestIsimAuthentication() for the response returned.
166  */
TEST_F(RadioHidlTest,requestIsimAuthentication)167 TEST_F(RadioHidlTest, requestIsimAuthentication) {
168     serial = GetRandomSerialNumber();
169     std::string challenge = "";
170 
171     radio->requestIsimAuthentication(serial, challenge);
172 
173     EXPECT_EQ(std::cv_status::no_timeout, wait());
174     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
175     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
176 
177     if (cardStatus.cardState == CardState::ABSENT) {
178         ASSERT_TRUE(CheckAnyOfErrors(
179             radioRsp->rspInfo.error,
180             {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE,
181              RadioError::NO_MEMORY, RadioError::SYSTEM_ERR, RadioError::REQUEST_NOT_SUPPORTED,
182              RadioError::CANCELLED}));
183     }
184 }
185 
186 /*
187  * Test IRadio.getImsRegistrationState() for the response returned.
188  */
TEST_F(RadioHidlTest,getImsRegistrationState)189 TEST_F(RadioHidlTest, getImsRegistrationState) {
190     serial = GetRandomSerialNumber();
191 
192     radio->getImsRegistrationState(serial);
193 
194     EXPECT_EQ(std::cv_status::no_timeout, wait());
195     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
196     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
197 
198     if (cardStatus.cardState == CardState::ABSENT) {
199         ASSERT_TRUE(CheckAnyOfErrors(
200             radioRsp->rspInfo.error,
201             {RadioError::NONE, RadioError::MODEM_ERR, RadioError::INVALID_MODEM_STATE},
202             CHECK_GENERAL_ERROR));
203     }
204 }
205