xref: /aosp_15_r20/hardware/interfaces/radio/aidl/vts/radio_voice_test.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 /*
2  * Copyright (C) 2021 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 <aidl/android/hardware/radio/config/IRadioConfig.h>
18 #include <aidl/android/hardware/radio/voice/EmergencyServiceCategory.h>
19 #include <android/binder_manager.h>
20 
21 #include "radio_voice_utils.h"
22 
23 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
24 
SetUp()25 void RadioVoiceTest::SetUp() {
26     RadioServiceTest::SetUp();
27     std::string serviceName = GetParam();
28 
29     if (!isServiceValidForDeviceConfiguration(serviceName)) {
30         ALOGI("Skipped the test due to device configuration.");
31         GTEST_SKIP();
32     }
33 
34     radio_voice = IRadioVoice::fromBinder(
35             ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
36     ASSERT_NE(nullptr, radio_voice.get());
37 
38     radioRsp_voice = ndk::SharedRefBase::make<RadioVoiceResponse>(*this);
39     ASSERT_NE(nullptr, radioRsp_voice.get());
40 
41     radioInd_voice = ndk::SharedRefBase::make<RadioVoiceIndication>(*this);
42     ASSERT_NE(nullptr, radioInd_voice.get());
43 
44     radio_voice->setResponseFunctions(radioRsp_voice, radioInd_voice);
45 
46     // Assert IRadioSim exists and SIM is present before testing
47     radio_sim = sim::IRadioSim::fromBinder(ndk::SpAIBinder(
48             AServiceManager_waitForService("android.hardware.radio.sim.IRadioSim/slot1")));
49     ASSERT_NE(nullptr, radio_sim.get());
50     updateSimCardStatus();
51     EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState);
52 
53     // Assert IRadioConfig exists before testing
54     radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder(
55             AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default")));
56     ASSERT_NE(nullptr, radio_config.get());
57 
58     if (isDsDsEnabled() || isTsTsEnabled()) {
59         radio_network = IRadioNetwork::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService(
60                 "android.hardware.radio.network.IRadioNetwork/slot1")));
61         ASSERT_NE(nullptr, radio_network.get());
62         radioRsp_network = ndk::SharedRefBase::make<RadioNetworkResponse>(*this);
63         radioInd_network = ndk::SharedRefBase::make<RadioNetworkIndication>(*this);
64         radio_network->setResponseFunctions(radioRsp_network, radioInd_network);
65     }
66 }
67 
clearPotentialEstablishedCalls()68 ndk::ScopedAStatus RadioVoiceTest::clearPotentialEstablishedCalls() {
69     // Get the current call Id to hangup the established emergency call.
70     serial = GetRandomSerialNumber();
71     radio_voice->getCurrentCalls(serial);
72     EXPECT_EQ(std::cv_status::no_timeout, wait());
73 
74     // Hang up to disconnect the established call channels.
75     for (const Call& call : radioRsp_voice->currentCalls) {
76         serial = GetRandomSerialNumber();
77         radio_voice->hangup(serial, call.index);
78         ALOGI("Hang up to disconnect the established call channel: %d", call.index);
79         EXPECT_EQ(std::cv_status::no_timeout, wait());
80         // Give some time for modem to disconnect the established call channel.
81         sleep(MODEM_EMERGENCY_CALL_DISCONNECT_TIME);
82     }
83 
84     // Verify there are no more current calls.
85     serial = GetRandomSerialNumber();
86     radio_voice->getCurrentCalls(serial);
87     EXPECT_EQ(std::cv_status::no_timeout, wait());
88     EXPECT_EQ(0, radioRsp_voice->currentCalls.size());
89     return ndk::ScopedAStatus::ok();
90 }
91 
92 /*
93  * Test IRadioVoice.emergencyDial() for the response returned.
94  */
TEST_P(RadioVoiceTest,emergencyDial)95 TEST_P(RadioVoiceTest, emergencyDial) {
96     if (telephony_flags::enforce_telephony_feature_mapping()) {
97         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
98             GTEST_SKIP() << "Skipping emergencyDial "
99                             "due to undefined FEATURE_TELEPHONY_CALLING";
100         }
101     } else {
102         if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
103             ALOGI("Skipping emergencyDial because voice call is not supported in device");
104             return;
105         } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
106                    !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
107             ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
108             return;
109         } else {
110             ALOGI("Running emergencyDial because voice call is supported in device");
111         }
112     }
113 
114     serial = GetRandomSerialNumber();
115 
116     Dial dialInfo;
117     dialInfo.address = std::string("911");
118     int32_t categories = static_cast<int32_t>(EmergencyServiceCategory::UNSPECIFIED);
119     std::vector<std::string> urns = {""};
120     EmergencyCallRouting routing = EmergencyCallRouting::UNKNOWN;
121 
122     ndk::ScopedAStatus res =
123             radio_voice->emergencyDial(serial, dialInfo, categories, urns, routing, true, true);
124     ASSERT_OK(res);
125     EXPECT_EQ(std::cv_status::no_timeout, wait());
126     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
127     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
128 
129     ALOGI("emergencyDial, rspInfo.error = %s\n", toString(radioRsp_voice->rspInfo.error).c_str());
130 
131     RadioError rspEmergencyDial = radioRsp_voice->rspInfo.error;
132     // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
133     // or Emergency_Only.
134     if (isDsDsEnabled() || isTsTsEnabled()) {
135         serial = GetRandomSerialNumber();
136         radio_network->getVoiceRegistrationState(serial);
137         EXPECT_EQ(std::cv_status::no_timeout, wait());
138         if (isVoiceEmergencyOnly(radioRsp_network->voiceRegResp.regState) ||
139             isVoiceInService(radioRsp_network->voiceRegResp.regState)) {
140             EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
141         }
142     } else {
143         EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
144     }
145 
146     // Give some time for modem to establish the emergency call channel.
147     sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
148 
149     // Disconnect all the potential established calls to prevent them affecting other tests.
150     clearPotentialEstablishedCalls();
151 }
152 
153 /*
154  * Test IRadioVoice.emergencyDial() with specified service and its response returned.
155  */
TEST_P(RadioVoiceTest,emergencyDial_withServices)156 TEST_P(RadioVoiceTest, emergencyDial_withServices) {
157     if (telephony_flags::enforce_telephony_feature_mapping()) {
158         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
159             GTEST_SKIP() << "Skipping emergencyDial_withServices "
160                             "due to undefined FEATURE_TELEPHONY_CALLING";
161         }
162     } else {
163         if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
164             ALOGI("Skipping emergencyDial because voice call is not supported in device");
165             return;
166         } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
167                    !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
168             ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
169             return;
170         } else {
171             ALOGI("Running emergencyDial because voice call is supported in device");
172         }
173     }
174 
175     serial = GetRandomSerialNumber();
176 
177     Dial dialInfo;
178     dialInfo.address = std::string("911");
179     int32_t categories = static_cast<int32_t>(EmergencyServiceCategory::AMBULANCE);
180     std::vector<std::string> urns = {"urn:service:sos.ambulance"};
181     EmergencyCallRouting routing = EmergencyCallRouting::UNKNOWN;
182 
183     ndk::ScopedAStatus res =
184             radio_voice->emergencyDial(serial, dialInfo, categories, urns, routing, true, true);
185     ASSERT_OK(res);
186     EXPECT_EQ(std::cv_status::no_timeout, wait());
187     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
188     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
189 
190     ALOGI("emergencyDial_withServices, rspInfo.error = %s\n",
191           toString(radioRsp_voice->rspInfo.error).c_str());
192     RadioError rspEmergencyDial = radioRsp_voice->rspInfo.error;
193 
194     // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
195     // or Emergency_Only.
196     if (isDsDsEnabled() || isTsTsEnabled()) {
197         serial = GetRandomSerialNumber();
198         radio_network->getVoiceRegistrationState(serial);
199         EXPECT_EQ(std::cv_status::no_timeout, wait());
200         if (isVoiceEmergencyOnly(radioRsp_network->voiceRegResp.regState) ||
201             isVoiceInService(radioRsp_network->voiceRegResp.regState)) {
202             EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
203         }
204     } else {
205         EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
206     }
207     // Give some time for modem to establish the emergency call channel.
208     sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
209 
210     // Disconnect all the potential established calls to prevent them affecting other tests.
211     clearPotentialEstablishedCalls();
212 }
213 
214 /*
215  * Test IRadioVoice.emergencyDial() with known emergency call routing and its response returned.
216  */
TEST_P(RadioVoiceTest,emergencyDial_withEmergencyRouting)217 TEST_P(RadioVoiceTest, emergencyDial_withEmergencyRouting) {
218     if (telephony_flags::enforce_telephony_feature_mapping()) {
219         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
220             GTEST_SKIP() << "Skipping emergencyDial_withEmergencyRouting "
221                             "due to undefined FEATURE_TELEPHONY_CALLING";
222         }
223     } else {
224         if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
225             ALOGI("Skipping emergencyDial because voice call is not supported in device");
226             return;
227         } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
228                    !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
229             ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
230             return;
231         } else {
232             ALOGI("Running emergencyDial because voice call is supported in device");
233         }
234     }
235 
236     serial = GetRandomSerialNumber();
237 
238     Dial dialInfo;
239     dialInfo.address = std::string("911");
240     int32_t categories = static_cast<int32_t>(EmergencyServiceCategory::UNSPECIFIED);
241     std::vector<std::string> urns = {""};
242     EmergencyCallRouting routing = EmergencyCallRouting::EMERGENCY;
243 
244     ndk::ScopedAStatus res =
245             radio_voice->emergencyDial(serial, dialInfo, categories, urns, routing, true, true);
246     ASSERT_OK(res);
247     EXPECT_EQ(std::cv_status::no_timeout, wait());
248     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
249     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
250 
251     ALOGI("emergencyDial_withEmergencyRouting, rspInfo.error = %s\n",
252           toString(radioRsp_voice->rspInfo.error).c_str());
253     RadioError rspEmergencyDial = radioRsp_voice->rspInfo.error;
254 
255     // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
256     // or Emergency_Only.
257     if (isDsDsEnabled() || isTsTsEnabled()) {
258         serial = GetRandomSerialNumber();
259         radio_network->getVoiceRegistrationState(serial);
260         EXPECT_EQ(std::cv_status::no_timeout, wait());
261         if (isVoiceEmergencyOnly(radioRsp_network->voiceRegResp.regState) ||
262             isVoiceInService(radioRsp_network->voiceRegResp.regState)) {
263             EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
264         }
265     } else {
266         EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
267     }
268 
269     // Give some time for modem to establish the emergency call channel.
270     sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
271 
272     // Disconnect all the potential established calls to prevent them affecting other tests.
273     clearPotentialEstablishedCalls();
274 }
275 
276 /*
277  * Test IRadioVoice.getCurrentCalls() for the response returned.
278  */
TEST_P(RadioVoiceTest,getCurrentCalls)279 TEST_P(RadioVoiceTest, getCurrentCalls) {
280     if (telephony_flags::enforce_telephony_feature_mapping()) {
281         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
282             GTEST_SKIP() << "Skipping getCurrentCalls "
283                             "due to undefined FEATURE_TELEPHONY_CALLING";
284         }
285     }
286 
287     serial = GetRandomSerialNumber();
288     radio_voice->getCurrentCalls(serial);
289     EXPECT_EQ(std::cv_status::no_timeout, wait());
290     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
291     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
292     EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error);
293 }
294 
295 /*
296  * Test IRadioVoice.getClir() for the response returned.
297  */
TEST_P(RadioVoiceTest,getClir)298 TEST_P(RadioVoiceTest, getClir) {
299     if (telephony_flags::enforce_telephony_feature_mapping()) {
300         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
301             GTEST_SKIP() << "Skipping getClir "
302                             "due to undefined FEATURE_TELEPHONY_CALLING";
303         }
304     }
305 
306     serial = GetRandomSerialNumber();
307 
308     radio_voice->getClir(serial);
309 
310     EXPECT_EQ(std::cv_status::no_timeout, wait());
311     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
312     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
313 
314     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
315         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::MODEM_ERR},
316                                      CHECK_GENERAL_ERROR));
317     }
318 }
319 
320 /*
321  * Test IRadioVoice.setClir() for the response returned.
322  */
TEST_P(RadioVoiceTest,setClir)323 TEST_P(RadioVoiceTest, setClir) {
324     if (telephony_flags::enforce_telephony_feature_mapping()) {
325         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
326             GTEST_SKIP() << "Skipping setClir "
327                             "due to undefined FEATURE_TELEPHONY_CALLING";
328         }
329     }
330 
331     serial = GetRandomSerialNumber();
332     int32_t status = 1;
333 
334     radio_voice->setClir(serial, status);
335 
336     EXPECT_EQ(std::cv_status::no_timeout, wait());
337     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
338     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
339 
340     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
341         EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error);
342     }
343 }
344 
345 /*
346  * Test IRadioVoice.getClip() for the response returned.
347  */
TEST_P(RadioVoiceTest,getClip)348 TEST_P(RadioVoiceTest, getClip) {
349     if (telephony_flags::enforce_telephony_feature_mapping()) {
350         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
351             GTEST_SKIP() << "Skipping getClip "
352                             "due to undefined FEATURE_TELEPHONY_CALLING";
353         }
354     }
355 
356     serial = GetRandomSerialNumber();
357 
358     radio_voice->getClip(serial);
359 
360     EXPECT_EQ(std::cv_status::no_timeout, wait());
361     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
362     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
363 
364     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
365         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::MODEM_ERR},
366                                      CHECK_GENERAL_ERROR));
367     }
368 }
369 
370 /*
371  * Test IRadioVoice.getTtyMode() for the response returned.
372  */
TEST_P(RadioVoiceTest,getTtyMode)373 TEST_P(RadioVoiceTest, getTtyMode) {
374     if (telephony_flags::enforce_telephony_feature_mapping()) {
375         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
376             GTEST_SKIP() << "Skipping getTtyMode "
377                             "due to undefined FEATURE_TELEPHONY_CALLING";
378         }
379     }
380 
381     serial = GetRandomSerialNumber();
382 
383     radio_voice->getTtyMode(serial);
384     EXPECT_EQ(std::cv_status::no_timeout, wait());
385     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
386     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
387 
388     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
389         EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error);
390     }
391 }
392 
393 /*
394  * Test IRadioVoice.setTtyMode() for the response returned.
395  */
TEST_P(RadioVoiceTest,setTtyMode)396 TEST_P(RadioVoiceTest, setTtyMode) {
397     if (telephony_flags::enforce_telephony_feature_mapping()) {
398         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
399             GTEST_SKIP() << "Skipping setTtyMode "
400                             "due to undefined FEATURE_TELEPHONY_CALLING";
401         }
402     }
403 
404     serial = GetRandomSerialNumber();
405 
406     radio_voice->setTtyMode(serial, TtyMode::OFF);
407     EXPECT_EQ(std::cv_status::no_timeout, wait());
408     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
409     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
410 
411     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
412         EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error);
413     }
414 }
415 
416 /*
417  * Test IRadioVoice.setPreferredVoicePrivacy() for the response returned.
418  */
TEST_P(RadioVoiceTest,setPreferredVoicePrivacy)419 TEST_P(RadioVoiceTest, setPreferredVoicePrivacy) {
420     if (telephony_flags::enforce_telephony_feature_mapping()) {
421         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
422             GTEST_SKIP() << "Skipping setPreferredVoicePrivacy "
423                             "due to undefined FEATURE_TELEPHONY_CALLING";
424         }
425     }
426 
427     serial = GetRandomSerialNumber();
428 
429     radio_voice->setPreferredVoicePrivacy(serial, true);
430     EXPECT_EQ(std::cv_status::no_timeout, wait());
431     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
432     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
433 
434     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
435         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
436                                      {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
437     }
438 }
439 
440 /*
441  * Test IRadioVoice.getPreferredVoicePrivacy() for the response returned.
442  */
TEST_P(RadioVoiceTest,getPreferredVoicePrivacy)443 TEST_P(RadioVoiceTest, getPreferredVoicePrivacy) {
444     if (telephony_flags::enforce_telephony_feature_mapping()) {
445         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
446             GTEST_SKIP() << "Skipping getPreferredVoicePrivacy "
447                             "due to undefined FEATURE_TELEPHONY_CALLING";
448         }
449     }
450 
451     serial = GetRandomSerialNumber();
452 
453     radio_voice->getPreferredVoicePrivacy(serial);
454     EXPECT_EQ(std::cv_status::no_timeout, wait());
455     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
456     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
457 
458     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
459         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
460                                      {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
461     }
462 }
463 
464 /*
465  * Test IRadioVoice.exitEmergencyCallbackMode() for the response returned.
466  */
TEST_P(RadioVoiceTest,exitEmergencyCallbackMode)467 TEST_P(RadioVoiceTest, exitEmergencyCallbackMode) {
468     if (telephony_flags::enforce_telephony_feature_mapping()) {
469         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
470             GTEST_SKIP() << "Skipping exitEmergencyCallbackMode "
471                             "due to undefined FEATURE_TELEPHONY_CALLING";
472         }
473     }
474 
475     serial = GetRandomSerialNumber();
476 
477     radio_voice->exitEmergencyCallbackMode(serial);
478     EXPECT_EQ(std::cv_status::no_timeout, wait());
479     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
480     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
481 
482     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
483         ASSERT_TRUE(CheckAnyOfErrors(
484                 radioRsp_voice->rspInfo.error,
485                 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT}));
486     }
487 }
488 
489 /*
490  * Test IRadioVoice.handleStkCallSetupRequestFromSim() for the response returned.
491  */
TEST_P(RadioVoiceTest,handleStkCallSetupRequestFromSim)492 TEST_P(RadioVoiceTest, handleStkCallSetupRequestFromSim) {
493     if (telephony_flags::enforce_telephony_feature_mapping()) {
494         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
495             GTEST_SKIP() << "Skipping handleStkCallSetupRequestFromSim "
496                             "due to undefined FEATURE_TELEPHONY_CALLING";
497         }
498     }
499 
500     serial = GetRandomSerialNumber();
501     bool accept = false;
502 
503     radio_voice->handleStkCallSetupRequestFromSim(serial, accept);
504 
505     EXPECT_EQ(std::cv_status::no_timeout, wait());
506     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
507     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
508 
509     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
510         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
511                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
512                                       RadioError::MODEM_ERR, RadioError::SIM_ABSENT},
513                                      CHECK_GENERAL_ERROR));
514     }
515 }
516 
517 /*
518  * Test IRadioVoice.dial() for the response returned.
519  */
TEST_P(RadioVoiceTest,dial)520 TEST_P(RadioVoiceTest, dial) {
521     if (telephony_flags::enforce_telephony_feature_mapping()) {
522         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
523             GTEST_SKIP() << "Skipping dial "
524                             "due to undefined FEATURE_TELEPHONY_CALLING";
525         }
526     }
527 
528     serial = GetRandomSerialNumber();
529 
530     Dial dialInfo;
531     memset(&dialInfo, 0, sizeof(dialInfo));
532     dialInfo.address = std::string("123456789");
533 
534     radio_voice->dial(serial, dialInfo);
535     EXPECT_EQ(std::cv_status::no_timeout, wait());
536     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
537     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
538 
539     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
540         ASSERT_TRUE(CheckAnyOfErrors(
541                 radioRsp_voice->rspInfo.error,
542                 {RadioError::CANCELLED, RadioError::DEVICE_IN_USE, RadioError::FDN_CHECK_FAILURE,
543                  RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
544                  RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE, RadioError::MODEM_ERR,
545                  RadioError::NO_NETWORK_FOUND, RadioError::NO_SUBSCRIPTION,
546                  RadioError::OPERATION_NOT_ALLOWED},
547                 CHECK_GENERAL_ERROR));
548     }
549 }
550 
551 /*
552  * Test IRadioVoice.hangup() for the response returned.
553  */
TEST_P(RadioVoiceTest,hangup)554 TEST_P(RadioVoiceTest, hangup) {
555     if (telephony_flags::enforce_telephony_feature_mapping()) {
556         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
557             GTEST_SKIP() << "Skipping hangup "
558                             "due to undefined FEATURE_TELEPHONY_CALLING";
559         }
560     }
561 
562     serial = GetRandomSerialNumber();
563 
564     radio_voice->hangup(serial, 1);
565     EXPECT_EQ(std::cv_status::no_timeout, wait());
566     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
567     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
568 
569     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
570         ASSERT_TRUE(CheckAnyOfErrors(
571                 radioRsp_voice->rspInfo.error,
572                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
573                 CHECK_GENERAL_ERROR));
574     }
575 }
576 
577 /*
578  * Test IRadioVoice.hangupWaitingOrBackground() for the response returned.
579  */
TEST_P(RadioVoiceTest,hangupWaitingOrBackground)580 TEST_P(RadioVoiceTest, hangupWaitingOrBackground) {
581     if (telephony_flags::enforce_telephony_feature_mapping()) {
582         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
583             GTEST_SKIP() << "Skipping hangupWaitingOrBackground "
584                             "due to undefined FEATURE_TELEPHONY_CALLING";
585         }
586     }
587 
588     serial = GetRandomSerialNumber();
589 
590     radio_voice->hangupWaitingOrBackground(serial);
591     EXPECT_EQ(std::cv_status::no_timeout, wait());
592     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
593     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
594 
595     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
596         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
597                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
598                                      CHECK_GENERAL_ERROR));
599     }
600 }
601 
602 /*
603  * Test IRadioVoice.hangupForegroundResumeBackground() for the response returned.
604  */
TEST_P(RadioVoiceTest,hangupForegroundResumeBackground)605 TEST_P(RadioVoiceTest, hangupForegroundResumeBackground) {
606     if (telephony_flags::enforce_telephony_feature_mapping()) {
607         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
608             GTEST_SKIP() << "Skipping hangupForegroundResumeBackground "
609                             "due to undefined FEATURE_TELEPHONY_CALLING";
610         }
611     }
612 
613     serial = GetRandomSerialNumber();
614 
615     radio_voice->hangupForegroundResumeBackground(serial);
616     EXPECT_EQ(std::cv_status::no_timeout, wait());
617     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
618     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
619 
620     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
621         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
622                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
623                                      CHECK_GENERAL_ERROR));
624     }
625 }
626 
627 /*
628  * Test IRadioVoice.switchWaitingOrHoldingAndActive() for the response returned.
629  */
TEST_P(RadioVoiceTest,switchWaitingOrHoldingAndActive)630 TEST_P(RadioVoiceTest, switchWaitingOrHoldingAndActive) {
631     if (telephony_flags::enforce_telephony_feature_mapping()) {
632         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
633             GTEST_SKIP() << "Skipping switchWaitingOrHoldingAndActive "
634                             "due to undefined FEATURE_TELEPHONY_CALLING";
635         }
636     }
637 
638     serial = GetRandomSerialNumber();
639 
640     radio_voice->switchWaitingOrHoldingAndActive(serial);
641     EXPECT_EQ(std::cv_status::no_timeout, wait());
642     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
643     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
644 
645     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
646         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
647                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
648                                      CHECK_GENERAL_ERROR));
649     }
650 }
651 
652 /*
653  * Test IRadioVoice.conference() for the response returned.
654  */
TEST_P(RadioVoiceTest,conference)655 TEST_P(RadioVoiceTest, conference) {
656     if (telephony_flags::enforce_telephony_feature_mapping()) {
657         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
658             GTEST_SKIP() << "Skipping conference "
659                             "due to undefined FEATURE_TELEPHONY_CALLING";
660         }
661     }
662 
663     serial = GetRandomSerialNumber();
664 
665     radio_voice->conference(serial);
666     EXPECT_EQ(std::cv_status::no_timeout, wait());
667     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
668     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
669 
670     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
671         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
672                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
673                                      CHECK_GENERAL_ERROR));
674     }
675 }
676 
677 /*
678  * Test IRadioVoice.rejectCall() for the response returned.
679  */
TEST_P(RadioVoiceTest,rejectCall)680 TEST_P(RadioVoiceTest, rejectCall) {
681     if (telephony_flags::enforce_telephony_feature_mapping()) {
682         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
683             GTEST_SKIP() << "Skipping rejectCall "
684                             "due to undefined FEATURE_TELEPHONY_CALLING";
685         }
686     }
687 
688     serial = GetRandomSerialNumber();
689 
690     radio_voice->rejectCall(serial);
691     EXPECT_EQ(std::cv_status::no_timeout, wait());
692     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
693     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
694 
695     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
696         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
697                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
698                                      CHECK_GENERAL_ERROR));
699     }
700 }
701 
702 /*
703  * Test IRadioVoice.getLastCallFailCause() for the response returned.
704  */
TEST_P(RadioVoiceTest,getLastCallFailCause)705 TEST_P(RadioVoiceTest, getLastCallFailCause) {
706     if (telephony_flags::enforce_telephony_feature_mapping()) {
707         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
708             GTEST_SKIP() << "Skipping getLastCallFailCause "
709                             "due to undefined FEATURE_TELEPHONY_CALLING";
710         }
711     }
712 
713     serial = GetRandomSerialNumber();
714 
715     radio_voice->getLastCallFailCause(serial);
716     EXPECT_EQ(std::cv_status::no_timeout, wait());
717     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
718     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
719 
720     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
721         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::NONE},
722                                      CHECK_GENERAL_ERROR));
723     }
724 }
725 
726 /*
727  * Test IRadioVoice.getCallForwardStatus() for the response returned.
728  */
TEST_P(RadioVoiceTest,getCallForwardStatus)729 TEST_P(RadioVoiceTest, getCallForwardStatus) {
730     if (telephony_flags::enforce_telephony_feature_mapping()) {
731         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
732             GTEST_SKIP() << "Skipping getCallForwardStatus "
733                             "due to undefined FEATURE_TELEPHONY_CALLING";
734         }
735     }
736 
737     serial = GetRandomSerialNumber();
738     CallForwardInfo callInfo;
739     memset(&callInfo, 0, sizeof(callInfo));
740     callInfo.number = std::string();
741 
742     radio_voice->getCallForwardStatus(serial, callInfo);
743     EXPECT_EQ(std::cv_status::no_timeout, wait());
744     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
745     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
746 
747     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
748         ASSERT_TRUE(CheckAnyOfErrors(
749                 radioRsp_voice->rspInfo.error,
750                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
751                 CHECK_GENERAL_ERROR));
752     }
753 }
754 
755 /*
756  * Test IRadioVoice.setCallForward() for the response returned.
757  */
TEST_P(RadioVoiceTest,setCallForward)758 TEST_P(RadioVoiceTest, setCallForward) {
759     if (telephony_flags::enforce_telephony_feature_mapping()) {
760         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
761             GTEST_SKIP() << "Skipping setCallForward "
762                             "due to undefined FEATURE_TELEPHONY_CALLING";
763         }
764     }
765 
766     serial = GetRandomSerialNumber();
767     CallForwardInfo callInfo;
768     memset(&callInfo, 0, sizeof(callInfo));
769     callInfo.number = std::string();
770 
771     radio_voice->setCallForward(serial, callInfo);
772     EXPECT_EQ(std::cv_status::no_timeout, wait());
773     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
774     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
775 
776     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
777         ASSERT_TRUE(CheckAnyOfErrors(
778                 radioRsp_voice->rspInfo.error,
779                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
780                 CHECK_GENERAL_ERROR));
781     }
782 }
783 
784 /*
785  * Test IRadioVoice.getCallWaiting() for the response returned.
786  */
TEST_P(RadioVoiceTest,getCallWaiting)787 TEST_P(RadioVoiceTest, getCallWaiting) {
788     if (telephony_flags::enforce_telephony_feature_mapping()) {
789         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
790             GTEST_SKIP() << "Skipping getCallWaiting "
791                             "due to undefined FEATURE_TELEPHONY_CALLING";
792         }
793     }
794 
795     serial = GetRandomSerialNumber();
796 
797     radio_voice->getCallWaiting(serial, 1);
798     EXPECT_EQ(std::cv_status::no_timeout, wait());
799     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
800     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
801 
802     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
803         ASSERT_TRUE(CheckAnyOfErrors(
804                 radioRsp_voice->rspInfo.error,
805                 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
806                 CHECK_GENERAL_ERROR));
807     }
808 }
809 
810 /*
811  * Test IRadioVoice.setCallWaiting() for the response returned.
812  */
TEST_P(RadioVoiceTest,setCallWaiting)813 TEST_P(RadioVoiceTest, setCallWaiting) {
814     if (telephony_flags::enforce_telephony_feature_mapping()) {
815         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
816             GTEST_SKIP() << "Skipping setCallWaiting "
817                             "due to undefined FEATURE_TELEPHONY_CALLING";
818         }
819     }
820 
821     serial = GetRandomSerialNumber();
822 
823     radio_voice->setCallWaiting(serial, true, 1);
824     EXPECT_EQ(std::cv_status::no_timeout, wait());
825     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
826     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
827 
828     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
829         ASSERT_TRUE(CheckAnyOfErrors(
830                 radioRsp_voice->rspInfo.error,
831                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
832                 CHECK_GENERAL_ERROR));
833     }
834 }
835 
836 /*
837  * Test IRadioVoice.acceptCall() for the response returned.
838  */
TEST_P(RadioVoiceTest,acceptCall)839 TEST_P(RadioVoiceTest, acceptCall) {
840     if (telephony_flags::enforce_telephony_feature_mapping()) {
841         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
842             GTEST_SKIP() << "Skipping acceptCall "
843                             "due to undefined FEATURE_TELEPHONY_CALLING";
844         }
845     }
846 
847     serial = GetRandomSerialNumber();
848 
849     radio_voice->acceptCall(serial);
850     EXPECT_EQ(std::cv_status::no_timeout, wait());
851     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
852     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
853 
854     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
855         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
856                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
857                                      CHECK_GENERAL_ERROR));
858     }
859 }
860 
861 /*
862  * Test IRadioVoice.separateConnection() for the response returned.
863  */
TEST_P(RadioVoiceTest,separateConnection)864 TEST_P(RadioVoiceTest, separateConnection) {
865     if (telephony_flags::enforce_telephony_feature_mapping()) {
866         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
867             GTEST_SKIP() << "Skipping separateConnection "
868                             "due to undefined FEATURE_TELEPHONY_CALLING";
869         }
870     }
871 
872     serial = GetRandomSerialNumber();
873 
874     radio_voice->separateConnection(serial, 1);
875     EXPECT_EQ(std::cv_status::no_timeout, wait());
876     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
877     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
878 
879     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
880         ASSERT_TRUE(CheckAnyOfErrors(
881                 radioRsp_voice->rspInfo.error,
882                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
883                 CHECK_GENERAL_ERROR));
884     }
885 }
886 
887 /*
888  * Test IRadioVoice.explicitCallTransfer() for the response returned.
889  */
TEST_P(RadioVoiceTest,explicitCallTransfer)890 TEST_P(RadioVoiceTest, explicitCallTransfer) {
891     if (telephony_flags::enforce_telephony_feature_mapping()) {
892         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
893             GTEST_SKIP() << "Skipping explicitCallTransfer "
894                             "due to undefined FEATURE_TELEPHONY_CALLING";
895         }
896     }
897 
898     serial = GetRandomSerialNumber();
899 
900     radio_voice->explicitCallTransfer(serial);
901     EXPECT_EQ(std::cv_status::no_timeout, wait());
902     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
903     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
904 
905     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
906         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
907                                      {RadioError::INVALID_STATE, RadioError::MODEM_ERR},
908                                      CHECK_GENERAL_ERROR));
909     }
910 }
911 
912 /*
913  * Test IRadioVoice.sendCdmaFeatureCode() for the response returned.
914  */
TEST_P(RadioVoiceTest,sendCdmaFeatureCode)915 TEST_P(RadioVoiceTest, sendCdmaFeatureCode) {
916     if (telephony_flags::enforce_telephony_feature_mapping()) {
917         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
918             GTEST_SKIP() << "Skipping sendCdmaFeatureCode "
919                             "due to undefined FEATURE_TELEPHONY_CDMA";
920         }
921     }
922 
923     serial = GetRandomSerialNumber();
924 
925     radio_voice->sendCdmaFeatureCode(serial, std::string());
926     EXPECT_EQ(std::cv_status::no_timeout, wait());
927     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
928     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
929 
930     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
931         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
932                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
933                                       RadioError::INVALID_CALL_ID, RadioError::INVALID_MODEM_STATE,
934                                       RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED},
935                                      CHECK_GENERAL_ERROR));
936     }
937 }
938 
939 /*
940  * Test IRadioVoice.sendDtmf() for the response returned.
941  */
TEST_P(RadioVoiceTest,sendDtmf)942 TEST_P(RadioVoiceTest, sendDtmf) {
943     if (telephony_flags::enforce_telephony_feature_mapping()) {
944         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
945             GTEST_SKIP() << "Skipping sendDtmf "
946                             "due to undefined FEATURE_TELEPHONY_CALLING";
947         }
948     }
949 
950     serial = GetRandomSerialNumber();
951 
952     radio_voice->sendDtmf(serial, "1");
953     EXPECT_EQ(std::cv_status::no_timeout, wait());
954     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
955     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
956 
957     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
958         ASSERT_TRUE(CheckAnyOfErrors(
959                 radioRsp_voice->rspInfo.error,
960                 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
961                  RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
962                 CHECK_GENERAL_ERROR));
963     }
964 }
965 
966 /*
967  * Test IRadioVoice.startDtmf() for the response returned.
968  */
TEST_P(RadioVoiceTest,startDtmf)969 TEST_P(RadioVoiceTest, startDtmf) {
970     if (telephony_flags::enforce_telephony_feature_mapping()) {
971         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
972             GTEST_SKIP() << "Skipping startDtmf "
973                             "due to undefined FEATURE_TELEPHONY_CALLING";
974         }
975     }
976 
977     serial = GetRandomSerialNumber();
978 
979     radio_voice->startDtmf(serial, "1");
980     EXPECT_EQ(std::cv_status::no_timeout, wait());
981     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
982     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
983 
984     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
985         ASSERT_TRUE(CheckAnyOfErrors(
986                 radioRsp_voice->rspInfo.error,
987                 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID,
988                  RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
989                 CHECK_GENERAL_ERROR));
990     }
991 }
992 
993 /*
994  * Test IRadioVoice.stopDtmf() for the response returned.
995  */
TEST_P(RadioVoiceTest,stopDtmf)996 TEST_P(RadioVoiceTest, stopDtmf) {
997     if (telephony_flags::enforce_telephony_feature_mapping()) {
998         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
999             GTEST_SKIP() << "Skipping stopDtmf "
1000                             "due to undefined FEATURE_TELEPHONY_CALLING";
1001         }
1002     }
1003 
1004     serial = GetRandomSerialNumber();
1005 
1006     radio_voice->stopDtmf(serial);
1007     EXPECT_EQ(std::cv_status::no_timeout, wait());
1008     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1009     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1010 
1011     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1012         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
1013                                      {RadioError::NONE, RadioError::INVALID_CALL_ID,
1014                                       RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR},
1015                                      CHECK_GENERAL_ERROR));
1016     }
1017 }
1018 
1019 /*
1020  * Test IRadioVoice.setMute() for the response returned.
1021  */
TEST_P(RadioVoiceTest,setMute)1022 TEST_P(RadioVoiceTest, setMute) {
1023     if (telephony_flags::enforce_telephony_feature_mapping()) {
1024         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1025             GTEST_SKIP() << "Skipping setMute "
1026                             "due to undefined FEATURE_TELEPHONY_CALLING";
1027         }
1028     }
1029 
1030     serial = GetRandomSerialNumber();
1031 
1032     radio_voice->setMute(serial, true);
1033     EXPECT_EQ(std::cv_status::no_timeout, wait());
1034     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1035     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1036 
1037     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1038         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
1039                                      {RadioError::NONE, RadioError::INVALID_ARGUMENTS},
1040                                      CHECK_GENERAL_ERROR));
1041     }
1042 }
1043 
1044 /*
1045  * Test IRadioVoice.getMute() for the response returned.
1046  */
TEST_P(RadioVoiceTest,getMute)1047 TEST_P(RadioVoiceTest, getMute) {
1048     if (telephony_flags::enforce_telephony_feature_mapping()) {
1049         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1050             GTEST_SKIP() << "Skipping getMute "
1051                             "due to undefined FEATURE_TELEPHONY_CALLING";
1052         }
1053     }
1054 
1055     serial = GetRandomSerialNumber();
1056 
1057     radio_voice->getMute(serial);
1058     EXPECT_EQ(std::cv_status::no_timeout, wait());
1059     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1060     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1061 
1062     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1063         EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error);
1064     }
1065 }
1066 
1067 /*
1068  * Test IRadioVoice.sendBurstDtmf() for the response returned.
1069  */
TEST_P(RadioVoiceTest,sendBurstDtmf)1070 TEST_P(RadioVoiceTest, sendBurstDtmf) {
1071     if (telephony_flags::enforce_telephony_feature_mapping()) {
1072         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1073             GTEST_SKIP() << "Skipping sendBurstDtmf "
1074                             "due to undefined FEATURE_TELEPHONY_CALLING";
1075         }
1076     }
1077 
1078     serial = GetRandomSerialNumber();
1079 
1080     radio_voice->sendBurstDtmf(serial, "1", 0, 0);
1081     EXPECT_EQ(std::cv_status::no_timeout, wait());
1082     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1083     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1084 
1085     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1086         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
1087                                      {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE,
1088                                       RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED},
1089                                      CHECK_GENERAL_ERROR));
1090     }
1091 }
1092 
1093 /*
1094  * Test IRadioVoice.sendUssd() for the response returned.
1095  */
TEST_P(RadioVoiceTest,sendUssd)1096 TEST_P(RadioVoiceTest, sendUssd) {
1097     if (telephony_flags::enforce_telephony_feature_mapping()) {
1098         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1099             GTEST_SKIP() << "Skipping sendUssd "
1100                             "due to undefined FEATURE_TELEPHONY_CALLING";
1101         }
1102     }
1103 
1104     serial = GetRandomSerialNumber();
1105     radio_voice->sendUssd(serial, std::string("test"));
1106     EXPECT_EQ(std::cv_status::no_timeout, wait());
1107     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1108     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1109 
1110     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1111         ASSERT_TRUE(CheckAnyOfErrors(
1112                 radioRsp_voice->rspInfo.error,
1113                 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
1114                 CHECK_GENERAL_ERROR));
1115     }
1116 }
1117 
1118 /*
1119  * Test IRadioVoice.cancelPendingUssd() for the response returned.
1120  */
TEST_P(RadioVoiceTest,cancelPendingUssd)1121 TEST_P(RadioVoiceTest, cancelPendingUssd) {
1122     if (telephony_flags::enforce_telephony_feature_mapping()) {
1123         if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1124             GTEST_SKIP() << "Skipping cancelPendingUssd "
1125                             "due to undefined FEATURE_TELEPHONY_CALLING";
1126         }
1127     }
1128 
1129     serial = GetRandomSerialNumber();
1130 
1131     radio_voice->cancelPendingUssd(serial);
1132     EXPECT_EQ(std::cv_status::no_timeout, wait());
1133     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1134     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1135 
1136     if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1137         ASSERT_TRUE(CheckAnyOfErrors(
1138                 radioRsp_voice->rspInfo.error,
1139                 {RadioError::NONE, RadioError::INVALID_STATE, RadioError::MODEM_ERR},
1140                 CHECK_GENERAL_ERROR));
1141     }
1142 }
1143 
1144 /*
1145  * Test IRadioVoice.isVoNrEnabled() for the response returned.
1146  */
TEST_P(RadioVoiceTest,isVoNrEnabled)1147 TEST_P(RadioVoiceTest, isVoNrEnabled) {
1148     if (telephony_flags::enforce_telephony_feature_mapping()) {
1149         if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
1150             GTEST_SKIP() << "Skipping isVoNrEnabled "
1151                             "due to undefined FEATURE_TELEPHONY_IMS";
1152         }
1153     }
1154 
1155     serial = GetRandomSerialNumber();
1156 
1157     radio_voice->isVoNrEnabled(serial);
1158     EXPECT_EQ(std::cv_status::no_timeout, wait());
1159     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1160     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1161 
1162     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
1163                                  {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
1164 }
1165 
1166 /*
1167  * Test IRadioVoice.setVoNrEnabled() for the response returned.
1168  */
TEST_P(RadioVoiceTest,setVoNrEnabled)1169 TEST_P(RadioVoiceTest, setVoNrEnabled) {
1170     if (telephony_flags::enforce_telephony_feature_mapping()) {
1171         if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
1172             GTEST_SKIP() << "Skipping setVoNrEnabled "
1173                             "due to undefined FEATURE_TELEPHONY_IMS";
1174         }
1175     }
1176 
1177     serial = GetRandomSerialNumber();
1178 
1179     radio_voice->setVoNrEnabled(serial, true);
1180     EXPECT_EQ(std::cv_status::no_timeout, wait());
1181     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
1182     EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
1183 
1184     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
1185                                  {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
1186 }
1187