1 /*
2 * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "tel_ril_test_util.h"
17
18 #include <fcntl.h>
19 #include <iostream>
20
21 #include "iservice_registry.h"
22 #include "radio_event.h"
23 #include "securec.h"
24 #include "system_ability_definition.h"
25
26 namespace OHOS {
27 namespace Telephony {
28 const std::string GTEST_STRING = "1234";
29 const std::string GTEST_STRING_PIN1 = "1234";
30 const std::string GTEST_STRING_PIN2 = "80785121";
31 const std::string GTEST_STRING_PUK1 = "19467362";
32 const std::string GTEST_STRING_PUK2 = "19467362";
33 const int32_t PW_LEN = 4;
34 const int32_t DECIMAL = 10;
35 const int32_t PHONE_NUM_LEN = 11;
36 const int32_t CID = 1;
37 const int32_t REASON = 2;
38 const int32_t P3 = 15;
39 const int32_t COMMAND = 192;
40 const int32_t FILEID = 20272;
41 const int32_t AUTHTYPE_1 = 0;
42 constexpr static const int32_t WAIT_TIME_SECOND = 20;
43 constexpr static const int32_t WAIT_TIME_SECOND_LONG = 30;
44 constexpr int32_t MAX_BUF_SIZE = 255;
45 constexpr int32_t WAIT_TELEPHONY_RETART_TIME = 60;
46 const int BANDWIDTH_HYSTERESIS_MS = 3000;
47 const int BANDWIDTH_HYSTERESIS_KBPS = 50;
48 const int MAX_DOWNLINK_LINK_BANDWIDTH[] = {100, // VoIP
49 500, // Web
50 1000, // SD
51 5000, // HD
52 10000, // file
53 20000, // 4K
54 50000, // LTE
55 100000,
56 200000, // 5G
57 500000, 1000000};
58 const int MAX_UPLINK_LINK_BANDWIDTH[] = {100, 500, 1000, 5000, 10000, 20000, 50000, 100000, 200000};
59 // send "test"
60 const std::string TEST_PDU = "A10305810180F6000004F4F29C0E";
61 // leave blank, smsc will be acquired automatically
62 const std::string TEST_SMSC_PDU = "";
63 // smsc addr
64 std::string g_smscAddr = "";
65 int32_t g_tosca = 0;
66 std::shared_ptr<Telephony::ITelRilManager> TelRilTest::telRilManager_ = nullptr;
67
SetUp()68 void TelRilTest::SetUp() {}
69
TearDown()70 void TelRilTest::TearDown() {}
71
SetUpTestCase()72 void TelRilTest::SetUpTestCase()
73 {
74 TELEPHONY_LOGI("----------TelRilTest gtest start ------------");
75 telRilManager_ = std::make_shared<TelRilManager>();
76 auto ret = telRilManager_->OnInit();
77 TELEPHONY_LOGI("----------TelRilTest setup finished ret: %{public}d ------------", ret);
78 }
79
ReStartTelephony()80 void TelRilTest::ReStartTelephony()
81 {
82 FILE *fp;
83 char buf[MAX_BUF_SIZE];
84 std::string cmd = "pidof telephony";
85 pid_t pid = -1;
86 if ((fp = popen(cmd.c_str(), "r")) != nullptr) {
87 if (fgets(buf, MAX_BUF_SIZE, fp) != nullptr) {
88 pid = atoi(buf);
89 }
90 }
91 if (fp == nullptr) {
92 TELEPHONY_LOGE("fp is null");
93 return;
94 }
95 kill(pid, SIGKILL);
96 pclose(fp);
97 sleep(WAIT_TELEPHONY_RETART_TIME);
98 }
99
TearDownTestCase()100 void TelRilTest::TearDownTestCase()
101 {
102 TELEPHONY_LOGI("----------TelRilTest gtest end ------------");
103 telRilManager_ = nullptr;
104 ReStartTelephony();
105 }
106
TelRilTest()107 TelRilTest::TelRilTest()
108 {
109 AddRequestToMap();
110 }
111
~TelRilTest()112 TelRilTest::~TelRilTest()
113 {
114 memberFuncMap_.clear();
115 }
116
GetProxy()117 sptr<ICoreService> TelRilTest::GetProxy()
118 {
119 TELEPHONY_LOGI("TelRilTest::GetProxy");
120 sptr<ISystemAbilityManager> systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
121 if (systemAbilityMgr == nullptr) {
122 TELEPHONY_LOGI("TelRilTest::GetProxy systemAbilityMgr is nullptr");
123 return nullptr;
124 }
125 sptr<IRemoteObject> remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CORE_SERVICE_SYS_ABILITY_ID);
126 if (remote) {
127 sptr<ICoreService> telephonyService = iface_cast<ICoreService>(remote);
128 return telephonyService;
129 } else {
130 TELEPHONY_LOGE("TelRilTest::GetProxy Get TELEPHONY_CORE_SERVICE_SYS_ABILITY_ID fail");
131 return nullptr;
132 }
133 }
134
ProcessTest(int32_t index,int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)135 bool TelRilTest::ProcessTest(int32_t index, int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
136 {
137 auto telephonyService = GetProxy();
138 if (telephonyService == nullptr) {
139 TELEPHONY_LOGE("TelRilTest::ProcessTest telephonyService is nullptr");
140 return true;
141 }
142 bool hasSimCard = false;
143 CoreServiceClient::GetInstance().HasSimCard(slotId, hasSimCard);
144 if (!hasSimCard) {
145 TELEPHONY_LOGE("TelRilTest::ProcessTest no sim card %{public}d", slotId);
146 return true;
147 }
148
149 for (auto itFunc : memberFuncMap_) {
150 int32_t val = static_cast<int32_t>(itFunc.first);
151 if (val == index) {
152 auto memberFunc = itFunc.second;
153 (this->*memberFunc)(slotId, handler);
154 return true;
155 }
156 }
157 return false;
158 }
159
AddRequestToMap()160 void TelRilTest::AddRequestToMap()
161 {
162 InitCall();
163 InitData();
164 InitSim();
165 InitSms();
166 InitNetwork();
167 InitModem();
168 }
169
InitCall()170 void TelRilTest::InitCall()
171 {
172 /* --------------------------------- CALL ----------------------------- */
173 memberFuncMap_[DiffInterfaceId::TEST_CURRENT_CALLS] = &TelRilTest::CallGetCurrentCallsStatusTest;
174 memberFuncMap_[DiffInterfaceId::TEST_CALL_DIAL] = &TelRilTest::CallDialTest;
175 memberFuncMap_[DiffInterfaceId::TEST_HANDUP_CONNECT] = &TelRilTest::CallHangupTest;
176 memberFuncMap_[DiffInterfaceId::TEST_ACCEPT_CALL] = &TelRilTest::CallAnswerTest;
177 memberFuncMap_[DiffInterfaceId::TEST_HOLD_CALL] = &TelRilTest::CallHoldTest;
178 memberFuncMap_[DiffInterfaceId::TEST_ACTIVE_CALL] = &TelRilTest::CallActiveTest;
179 memberFuncMap_[DiffInterfaceId::TEST_SWAP_CALL] = &TelRilTest::CallSwapTest;
180 memberFuncMap_[DiffInterfaceId::TEST_JOIN_CALL] = &TelRilTest::CallJoinTest;
181 memberFuncMap_[DiffInterfaceId::TEST_SPLIT_CALL] = &TelRilTest::CallSplitTest;
182 memberFuncMap_[DiffInterfaceId::TEST_REJECT_CALL] = &TelRilTest::RefusedCallTest;
183 memberFuncMap_[DiffInterfaceId::TEST_GET_CALL_WAIT] = &TelRilTest::GetCallWaitTest;
184 memberFuncMap_[DiffInterfaceId::TEST_SET_CALL_WAIT] = &TelRilTest::SetCallWaitTest;
185 memberFuncMap_[DiffInterfaceId::TEST_GET_CALL_FORWARD] = &TelRilTest::GetCallForwardTest;
186 memberFuncMap_[DiffInterfaceId::TEST_SET_CALL_FORWARD] = &TelRilTest::SetCallForwardTest;
187 memberFuncMap_[DiffInterfaceId::TEST_GET_CALL_DEAL_CLIP] = &TelRilTest::GetClipTest;
188 memberFuncMap_[DiffInterfaceId::TEST_SET_CALL_CLIP] = &TelRilTest::SetClipTest;
189 memberFuncMap_[DiffInterfaceId::TEST_GET_CALL_RESTRICTION] = &TelRilTest::GetCallRestrictionTest;
190 memberFuncMap_[DiffInterfaceId::TEST_SET_CALL_RESTRICTION] = &TelRilTest::SetCallRestrictionTest;
191 memberFuncMap_[DiffInterfaceId::TEST_SET_BARRING_PWD] = &TelRilTest::SetBarringPasswordTest;
192 memberFuncMap_[DiffInterfaceId::TEST_SEND_DTMF] = &TelRilTest::SendDtmfTest;
193 memberFuncMap_[DiffInterfaceId::TEST_START_DTMF] = &TelRilTest::StartDtmfTest;
194 memberFuncMap_[DiffInterfaceId::TEST_STOP_DTMF] = &TelRilTest::StopDtmfTest;
195 memberFuncMap_[DiffInterfaceId::TEST_SET_USSD] = &TelRilTest::SetUssdTest;
196 memberFuncMap_[DiffInterfaceId::TEST_GET_USSD] = &TelRilTest::GetUssdTest;
197 memberFuncMap_[DiffInterfaceId::TEST_SET_CMUT] = &TelRilTest::SetMuteTest;
198 memberFuncMap_[DiffInterfaceId::TEST_GET_CMUT] = &TelRilTest::GetMuteTest;
199 memberFuncMap_[DiffInterfaceId::TEST_GET_EMERGENCY_CALL_LIST] = &TelRilTest::GetEmergencyCallListTest;
200 memberFuncMap_[DiffInterfaceId::TEST_SET_VONR_STATUS] = &TelRilTest::SetVoNRSwitchTest;
201 }
202
InitData()203 void TelRilTest::InitData()
204 {
205 /* --------------------------------- DATA ----------------------------- */
206 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SET_INIT_APN_INFO] = &TelRilTest::DataSetInitApnInfoTest;
207 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SETUP_DATA_CALL] = &TelRilTest::DataSetupDataCallTest;
208 memberFuncMap_[DiffInterfaceId::TEST_RILCM_DEACTIVATE_DATA_CALL] = &TelRilTest::DataDisableDataCallTest;
209 memberFuncMap_[DiffInterfaceId::TEST_RILCM_GET_DATA_CALL_LIST] = &TelRilTest::GetDataCallListTest;
210 memberFuncMap_[DiffInterfaceId::TEST_RILCM_GET_LINK_BANDWIDTH_INFO] = &TelRilTest::GetLinkBandwidthInfoTest;
211 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SET_LINK_BANDWIDTH_REPORTING_RULE] =
212 &TelRilTest::OnRequestSetLinkBandwidthReportingRuleTest;
213 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SET_DATA_PERMITTED_TEST] = &TelRilTest::SetDataPermittedTest;
214 memberFuncMap_[DiffInterfaceId::TEST_RILCM_GET_LINK_CAPABILITY_TEST] = &TelRilTest::GetLinkCapabilityTest;
215 memberFuncMap_[DiffInterfaceId::TEST_RILCM_CLEAN_ALL_DATA_CONNECTIONS_TEST] = &TelRilTest::CleanAllConnectionsTest;
216 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SEND_URSP_DECODE_RESULT] = &TelRilTest::SendUrspDecodeResultTest;
217 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SEND_UE_POLICY_SECTION_IDENTIFIER] =
218 &TelRilTest::SendUePolicySectionIdentifierTest;
219 memberFuncMap_[DiffInterfaceId::TEST_RILCM_SEND_IMS_RSD_LIST] = &TelRilTest::SendImsRsdListTest;
220 memberFuncMap_[DiffInterfaceId::TEST_RILCM_GET_NETWORKSLICE_ALLOWEDNSSAI] =
221 &TelRilTest::GetNetworkSliceAllowedNssaiTest;
222 memberFuncMap_[DiffInterfaceId::TEST_RILCM_GET_NETWORKSLICE_EHPLMN] = &TelRilTest::GetNetworkSliceEhplmnTest;
223 }
224
InitSim()225 void TelRilTest::InitSim()
226 {
227 /*-----------------------------------SIM----------------------------------*/
228 memberFuncMap_[DiffInterfaceId::TEST_GET_SIM_CARD_STATUS] = &TelRilTest::SimGetSimStatusTest;
229 memberFuncMap_[DiffInterfaceId::TEST_SIM_IO] = &TelRilTest::SimIccIoTest;
230 memberFuncMap_[DiffInterfaceId::TEST_GET_IMSI] = &TelRilTest::SimGetImsiTest;
231 memberFuncMap_[DiffInterfaceId::TEST_GET_SIM_LOCK_STATUS] = &TelRilTest::GetSimLockStatusTest;
232 memberFuncMap_[DiffInterfaceId::TEST_SET_SIM_LOCK] = &TelRilTest::SetSimLockTest;
233 memberFuncMap_[DiffInterfaceId::TEST_UNSET_SIM_LOCK] = &TelRilTest::UnSetSimLockTest;
234 memberFuncMap_[DiffInterfaceId::TEST_GET_CHANGE_SIM_PASSWD] = &TelRilTest::ChangeSimPasswordTest;
235 memberFuncMap_[DiffInterfaceId::TEST_ENTER_SIM_PIN] = &TelRilTest::EnterSimPinTest;
236 memberFuncMap_[DiffInterfaceId::TEST_RADIO_RESTART] = &TelRilTest::RadioRestartTest;
237 memberFuncMap_[DiffInterfaceId::TEST_ENTER_ERROR_PIN] = &TelRilTest::EnterErrorPinTest;
238 memberFuncMap_[DiffInterfaceId::TEST_UNLOCK_SIM_PIN] = &TelRilTest::UnlockSimPinTest;
239 memberFuncMap_[DiffInterfaceId::TEST_SET_PIN2_LOCK] = &TelRilTest::SetPin2LockTest;
240 memberFuncMap_[DiffInterfaceId::TEST_ENTER_SIM_PIN2] = &TelRilTest::EnterSimPin2Test;
241 memberFuncMap_[DiffInterfaceId::TEST_ENTER_ERROR_PIN2] = &TelRilTest::EnterErrorPin2Test;
242 memberFuncMap_[DiffInterfaceId::TEST_UNLOCK_SIM_PIN2] = &TelRilTest::UnlockSimPin2Test;
243 memberFuncMap_[DiffInterfaceId::TEST_UNSET_PIN2_LOCK] = &TelRilTest::UnSetPin2LockTest;
244 memberFuncMap_[DiffInterfaceId::TEST_ENABLE_SIM_CARD] = &TelRilTest::EnableSimCardTest;
245 memberFuncMap_[DiffInterfaceId::TEST_STK_SEND_TERMINAL_RESPONSE] = &TelRilTest::SendTerminalResponseCmdTest;
246 memberFuncMap_[DiffInterfaceId::TEST_STK_SEND_ENVELOPE] = &TelRilTest::SendEnvelopeCmdTest;
247 memberFuncMap_[DiffInterfaceId::TEST_STK_SEND_CALL_SETUP_REQUEST_RESULT] =
248 &TelRilTest::SendCallSetupRequestResultTest;
249 memberFuncMap_[DiffInterfaceId::TEST_GET_RADIO_PROTOCOL] = &TelRilTest::GetRadioProtocolTest;
250 memberFuncMap_[DiffInterfaceId::TEST_SET_RADIO_PROTOCOL] = &TelRilTest::SetRadioProtocolTest;
251 }
252
InitSms()253 void TelRilTest::InitSms()
254 {
255 /* --------------------------------- SMS ----------------------------- */
256 memberFuncMap_[DiffInterfaceId::TEST_SEND_SMS] = &TelRilTest::SendRilCmSmsTest;
257 memberFuncMap_[DiffInterfaceId::TEST_STORAGE_SMS] = &TelRilTest::StorageRilCmSmsTest;
258 memberFuncMap_[DiffInterfaceId::TEST_DELETE_SMS] = &TelRilTest::DeleteRilCmSmsTest;
259 memberFuncMap_[DiffInterfaceId::TEST_UPDATE_SMS] = &TelRilTest::UpdateRilCmSmsTest;
260 memberFuncMap_[DiffInterfaceId::TEST_SET_SMS_CENTER_ADDRESS] = &TelRilTest::SetRilCmSmsCenterAddressTest;
261 memberFuncMap_[DiffInterfaceId::TEST_GET_SMS_CENTER_ADDRESS] = &TelRilTest::GetRilCmSmsCenterAddressTest;
262 memberFuncMap_[DiffInterfaceId::TEST_SET_CB_CONFIG] = &TelRilTest::SetRilCmCBConfigTest;
263 memberFuncMap_[DiffInterfaceId::TEST_SET_CDMA_CB_CONFIG] = &TelRilTest::SetRilCmCdmaCBConfigTest;
264 memberFuncMap_[DiffInterfaceId::TEST_GET_CB_CONFIG] = &TelRilTest::GetRilCmCBConfigTest;
265 memberFuncMap_[DiffInterfaceId::TEST_GET_CDMA_CB_CONFIG] = &TelRilTest::GetRilCmCdmaCBConfigTest;
266 memberFuncMap_[DiffInterfaceId::TEST_SEND_SMS_EXPECT_MORE] = &TelRilTest::SmsSendSmsExpectMoreTest;
267 memberFuncMap_[DiffInterfaceId::TEST_SEND_SMS_ACK] = &TelRilTest::SmsAcknowledgeTest;
268 memberFuncMap_[DiffInterfaceId::TEST_ADD_CDMA_SMS] = &TelRilTest::AddRilCmCdmaSmsTest;
269 memberFuncMap_[DiffInterfaceId::TEST_DEL_CDMA_SMS] = &TelRilTest::DelRilCmCdmaSmsTest;
270 memberFuncMap_[DiffInterfaceId::TEST_UPDATE_CDMA_SMS] = &TelRilTest::UpdateRilCmCdmaSmsTest;
271 }
272
InitNetwork()273 void TelRilTest::InitNetwork()
274 {
275 /* --------------------------------- NETWORK ----------------------------- */
276 memberFuncMap_[DiffInterfaceId::TEST_OPERATOR] = &TelRilTest::NetworkOperatorTest;
277 memberFuncMap_[DiffInterfaceId::TEST_GET_RILCM_VOICE_REGISTRATION_STATE] =
278 &TelRilTest::NetworkVoiceRegistrationStateTest;
279 memberFuncMap_[DiffInterfaceId::TEST_GET_RILCM_DATA_REGISTRATION_STATE] =
280 &TelRilTest::NetworkDataRegistrationStateTest;
281 memberFuncMap_[DiffInterfaceId::TEST_GET_NETWORKS_TO_USE] = &TelRilTest::GetNetworkSearchInformationTest;
282 memberFuncMap_[DiffInterfaceId::TEST_GET_SELECTION_MOD_FOR_NETWORKS] = &TelRilTest::GetNetworkSelectionModeTest;
283 memberFuncMap_[DiffInterfaceId::TEST_SET_MODE_AUTOMATIC_NETWORKS] = &TelRilTest::SetNetworkSelectionModeTest;
284 memberFuncMap_[DiffInterfaceId::TEST_GET_PREFERRED_NETWORK_TYPE] = &TelRilTest::GetPreferredNetworkParaTest;
285 memberFuncMap_[DiffInterfaceId::TEST_SET_PREFERRED_NETWORK_TYPE] = &TelRilTest::SetPreferredNetworkParaTest;
286 memberFuncMap_[DiffInterfaceId::TEST_GET_IMEI] = &TelRilTest::GetImeiTest;
287 memberFuncMap_[DiffInterfaceId::TEST_GET_IMEISV] = &TelRilTest::GetImeiSvTest;
288 memberFuncMap_[DiffInterfaceId::TEST_GET_MEID] = &TelRilTest::GetMeidTest;
289 memberFuncMap_[DiffInterfaceId::TEST_GET_VOICE_RADIO_INFO] = &TelRilTest::GetVoiceRadioTechnologyTest;
290 memberFuncMap_[DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG] = &TelRilTest::GetPhysicalChannelConfigTest;
291 memberFuncMap_[DiffInterfaceId::TEST_SET_LOCATE_UPDATES] = &TelRilTest::SetLocateUpdatesTest;
292 memberFuncMap_[DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER] = &TelRilTest::SetNotificationFilterTest;
293 memberFuncMap_[DiffInterfaceId::TEST_SET_DEVICE_STATE] = &TelRilTest::SetDeviceStateTest;
294 memberFuncMap_[DiffInterfaceId::TEST_GET_RRC_CONNECTION_STATE] = &TelRilTest::GetRrcConnectionStateTest;
295 memberFuncMap_[DiffInterfaceId::TEST_GET_NR_OPTION_MODE] = &TelRilTest::GetNrOptionModeTest;
296 memberFuncMap_[DiffInterfaceId::TEST_SET_NR_OPTION_MODE] = &TelRilTest::SetNrOptionModeTest;
297 memberFuncMap_[DiffInterfaceId::TEST_GET_NR_SSBID_INFO] = &TelRilTest::GetNrSsbIdTest;
298 memberFuncMap_[DiffInterfaceId::TEST_GET_NEIGHBORING_CELL_INFO_LIST_TYPE] =
299 &TelRilTest::GetNeighboringCellInfoListTest;
300 }
301
InitModem()302 void TelRilTest::InitModem()
303 {
304 /* --------------------------------- MODEM -------------------------- */
305 memberFuncMap_[DiffInterfaceId::TEST_GET_SIGNAL_STRENGTH] = &TelRilTest::NetworkGetRssiTest;
306 memberFuncMap_[DiffInterfaceId::TEST_SET_POWER_STATE] = &TelRilTest::SetRadioStateTest;
307 memberFuncMap_[DiffInterfaceId::TEST_GET_POWER_STATE] = &TelRilTest::GetRadioStateTest;
308 }
309
310 /**
311 * @brief Get current calls status
312 *
313 * @param handler
314 */
CallGetCurrentCallsStatusTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)315 void TelRilTest::CallGetCurrentCallsStatusTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
316 {
317 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_CURRENT_CALLS);
318 auto event = AppExecFwk::InnerEvent::Get(eventId);
319 if (event != nullptr && telRilManager_ != nullptr) {
320 event->SetOwner(handler);
321 TELEPHONY_LOGI("TelRilTest::CallGetCurrentCallsStatusTest -->");
322 telRilManager_->GetCallList(slotId, event);
323 TELEPHONY_LOGI("TelRilTest::CallGetCurrentCallsStatusTest --> finished");
324 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
325 ASSERT_TRUE(syncResult);
326 }
327 }
328
329 /************************************** SIM test func *******************************************/
330 /**
331 * @brief Get SIM card status
332 *
333 * @param handler
334 */
SimGetSimStatusTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)335 void TelRilTest::SimGetSimStatusTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
336 {
337 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_GET_STATUS);
338 auto event = AppExecFwk::InnerEvent::Get(eventId);
339 if (event != nullptr && telRilManager_ != nullptr) {
340 event->SetOwner(handler);
341 TELEPHONY_LOGI("TelRilTest::SimGetSimStatusTest -->");
342 telRilManager_->GetSimStatus(slotId, event);
343 TELEPHONY_LOGI("TelRilTest::SimGetSimStatusTest --> finished");
344 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
345 ASSERT_TRUE(syncResult);
346 }
347 }
348
349 /**
350 * @brief Get SIM card IO
351 *
352 * @param handler
353 */
SimIccIoTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)354 void TelRilTest::SimIccIoTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
355 {
356 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_IO);
357 auto event = AppExecFwk::InnerEvent::Get(eventId);
358 if (event != nullptr && telRilManager_ != nullptr) {
359 event->SetOwner(handler);
360 TELEPHONY_LOGI("TelRilTest::SimIccIoTest -->");
361 SimIoRequestInfo msg;
362 msg.command = COMMAND;
363 msg.fileId = FILEID;
364 msg.p1 = 0;
365 msg.p2 = 0;
366 msg.p3 = P3;
367 msg.data = "";
368 msg.path = "3F007F105F3A";
369 msg.pin2 = "";
370 telRilManager_->GetSimIO(slotId, msg, event);
371 TELEPHONY_LOGI("TelRilTest::SimIccIoTest --> finished");
372 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
373 ASSERT_TRUE(syncResult);
374 }
375 }
376
377 /**
378 * @brief Get International Mobile Subscriber Identity
379 *
380 * @param handler
381 */
SimGetImsiTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)382 void TelRilTest::SimGetImsiTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
383 {
384 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_GET_IMSI);
385 auto event = AppExecFwk::InnerEvent::Get(eventId);
386 if (event != nullptr && telRilManager_ != nullptr) {
387 event->SetOwner(handler);
388 TELEPHONY_LOGI("TelRilTest::SimGetImsiTest -->");
389 telRilManager_->GetImsi(slotId, event);
390 TELEPHONY_LOGI("TelRilTest::SimGetImsiTest --> finished");
391 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
392 ASSERT_TRUE(syncResult);
393 }
394 }
395
396 /**
397 * @brief Get SIM card lock status
398 *
399 * @param handler
400 */
GetSimLockStatusTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)401 void TelRilTest::GetSimLockStatusTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
402 {
403 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_GET_LOCK_STATUS);
404 auto event = AppExecFwk::InnerEvent::Get(eventId);
405 if (event != nullptr && telRilManager_ != nullptr) {
406 event->SetOwner(handler);
407 std::string fac = FAC_PIN_LOCK;
408 TELEPHONY_LOGI("TelRilTest::GetSimLockStatusTest -->");
409 telRilManager_->GetSimLockStatus(slotId, fac, event);
410 TELEPHONY_LOGI("TelRilTest::GetSimLockStatusTest --> finished");
411 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
412 ASSERT_TRUE(syncResult);
413 }
414 }
415
416 /**
417 * @brief Set SIM card lock status
418 *
419 * @param handler
420 */
SetSimLockTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)421 void TelRilTest::SetSimLockTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
422 {
423 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_SET_LOCK);
424 auto event = AppExecFwk::InnerEvent::Get(eventId);
425 if (event != nullptr && telRilManager_ != nullptr) {
426 event->SetOwner(handler);
427 SimLockParam simLockParam;
428 simLockParam.fac = FAC_PIN_LOCK;
429 simLockParam.mode = static_cast<int32_t>(LockState::LOCK_ON);
430 simLockParam.passwd = GTEST_STRING_PIN1;
431 TELEPHONY_LOGI("TelRilTest::SetSimLockTest -->");
432 telRilManager_->SetSimLock(slotId, simLockParam, event);
433 TELEPHONY_LOGI("TelRilTest::SetSimLockTest --> finished");
434 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
435 ASSERT_TRUE(syncResult);
436 }
437 }
438
439 /**
440 * @brief UnSet SIM card lock status
441 *
442 * @param handler
443 */
UnSetSimLockTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)444 void TelRilTest::UnSetSimLockTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
445 {
446 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_SET_LOCK);
447 auto event = AppExecFwk::InnerEvent::Get(eventId);
448 if (event != nullptr && telRilManager_ != nullptr) {
449 event->SetOwner(handler);
450 SimLockParam simLockParam;
451 simLockParam.fac = FAC_PIN_LOCK;
452 simLockParam.mode = static_cast<int32_t>(LockState::LOCK_OFF);
453 simLockParam.passwd = GTEST_STRING_PIN1;
454 TELEPHONY_LOGI("TelRilTest::UnSetSimLockTest -->");
455 telRilManager_->SetSimLock(slotId, simLockParam, event);
456 TELEPHONY_LOGI("TelRilTest::UnSetSimLockTest --> finished");
457 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
458 ASSERT_TRUE(syncResult);
459 }
460 }
461
462 /**
463 * @brief Change SIM card Password
464 *
465 * @param handler
466 */
ChangeSimPasswordTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)467 void TelRilTest::ChangeSimPasswordTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
468 {
469 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_CHANGE_PASSWD);
470 auto event = AppExecFwk::InnerEvent::Get(eventId);
471 if (event != nullptr && telRilManager_ != nullptr) {
472 event->SetOwner(handler);
473 SimPasswordParam simPassword;
474 simPassword.passwordLength = PW_LEN;
475 simPassword.fac = FAC_PIN_LOCK;
476 simPassword.oldPassword = GTEST_STRING_PIN1;
477 simPassword.newPassword = GTEST_STRING_PIN1;
478 TELEPHONY_LOGI("TelRilTest::ChangeSimPasswordTest -->");
479 telRilManager_->ChangeSimPassword(slotId, simPassword, event);
480 TELEPHONY_LOGI("TelRilTest::ChangeSimPasswordTest --> finished");
481 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
482 ASSERT_TRUE(syncResult);
483 }
484 }
485
486 /**
487 * @brief Restart Radio
488 *
489 * @param handler
490 */
RadioRestartTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)491 void TelRilTest::RadioRestartTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
492 {
493 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_STATUS);
494 auto event = AppExecFwk::InnerEvent::Get(eventId);
495 if (event != nullptr && telRilManager_ != nullptr) {
496 event->SetOwner(handler);
497 uint8_t funOffline = 4;
498 uint8_t rstOffline = 1;
499 telRilManager_->SetRadioState(slotId, funOffline, rstOffline, event);
500 TELEPHONY_LOGI("TelRilTest::RadioRestartTest1 -->");
501 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND_LONG);
502 ASSERT_TRUE(syncResult);
503
504 uint8_t funReboot = 6;
505 uint8_t rstReboot = 1;
506 telRilManager_->SetRadioState(slotId, funReboot, rstReboot, event);
507 TELEPHONY_LOGI("TelRilTest::RadioRestartTest2 -->");
508 bool syncResult2 = WaitGetResult(eventId, handler, WAIT_TIME_SECOND_LONG);
509 ASSERT_TRUE(syncResult2);
510 }
511 }
512
513 /**
514 * @brief Enter SIM card pin code
515 *
516 * @param handler
517 */
EnterSimPinTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)518 void TelRilTest::EnterSimPinTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
519 {
520 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_ENTER_PIN);
521 auto event = AppExecFwk::InnerEvent::Get(eventId);
522 if (event != nullptr && telRilManager_ != nullptr) {
523 event->SetOwner(handler);
524 std::string pin = GTEST_STRING_PIN1;
525 TELEPHONY_LOGI("TelRilTest::EnterSimPinTest -->");
526 telRilManager_->UnlockPin(slotId, pin, event);
527 TELEPHONY_LOGI("TelRilTest::EnterSimPinTest --> finished");
528 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
529 ASSERT_TRUE(syncResult);
530 }
531 }
532
533 /**
534 * @brief Enter error pin code
535 *
536 * @param handler
537 */
EnterErrorPinTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)538 void TelRilTest::EnterErrorPinTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
539 {
540 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_ENTER_PIN);
541 auto event = AppExecFwk::InnerEvent::Get(eventId);
542 if (event != nullptr && telRilManager_ != nullptr) {
543 event->SetOwner(handler);
544 std::string pin = "1111";
545 TELEPHONY_LOGI("TelRilTest::EnterErrorPinTest -->");
546 telRilManager_->UnlockPin(slotId, pin, event);
547 TELEPHONY_LOGI("TelRilTest::EnterErrorPinTest --> finished");
548 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
549 ASSERT_TRUE(syncResult);
550 }
551 }
552
553 /**
554 * @brief Unlock SIM card pin code
555 *
556 * @param handler
557 */
UnlockSimPinTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)558 void TelRilTest::UnlockSimPinTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
559 {
560 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_UNLOCK_PIN);
561 auto event = AppExecFwk::InnerEvent::Get(eventId);
562 if (event != nullptr && telRilManager_ != nullptr) {
563 event->SetOwner(handler);
564 std::string puk = GTEST_STRING_PUK1;
565 std::string pin = GTEST_STRING_PIN1;
566 TELEPHONY_LOGI("TelRilTest::UnlockSimPinTest -->");
567 telRilManager_->UnlockPuk(slotId, puk, pin, event);
568 TELEPHONY_LOGI("TelRilTest::UnlockSimPinTest --> finished");
569 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
570 ASSERT_TRUE(syncResult);
571 }
572 }
573
574 /**
575 * @brief Set SIM card PIN2 lock status
576 *
577 * @param handler
578 */
SetPin2LockTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)579 void TelRilTest::SetPin2LockTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
580 {
581 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_SET_LOCK);
582 auto event = AppExecFwk::InnerEvent::Get(eventId);
583 if (event != nullptr && telRilManager_ != nullptr) {
584 event->SetOwner(handler);
585 SimLockParam simLockParam;
586 simLockParam.fac = FDN_PIN2_LOCK;
587 simLockParam.mode = static_cast<int32_t>(LockState::LOCK_ON);
588 simLockParam.passwd = GTEST_STRING_PIN2;
589 TELEPHONY_LOGI("TelRilTest::SetPIN2LockTest -->");
590 telRilManager_->SetSimLock(slotId, simLockParam, event);
591 TELEPHONY_LOGI("TelRilTest::SetPin2LockTest --> finished");
592 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
593 ASSERT_TRUE(syncResult);
594 }
595 }
596
597 /**
598 * @brief Set SIM card PIN2 lock status
599 *
600 * @param handler
601 */
UnSetPin2LockTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)602 void TelRilTest::UnSetPin2LockTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
603 {
604 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_SET_LOCK);
605 auto event = AppExecFwk::InnerEvent::Get(eventId);
606 if (event != nullptr && telRilManager_ != nullptr) {
607 event->SetOwner(handler);
608 SimLockParam simLockParam;
609 simLockParam.fac = FDN_PIN2_LOCK;
610 simLockParam.mode = static_cast<int32_t>(LockState::LOCK_OFF);
611 simLockParam.passwd = GTEST_STRING_PIN2;
612 TELEPHONY_LOGI("TelRilTest::UnSetPin2LockTest -->");
613 telRilManager_->SetSimLock(slotId, simLockParam, event);
614 TELEPHONY_LOGI("TelRilTest::UnSetPin2LockTest --> finished");
615 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
616 ASSERT_TRUE(syncResult);
617 }
618 }
619
620 /**
621 * @brief Enter SIM card pin2 code
622 *
623 * @param handler
624 */
EnterSimPin2Test(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)625 void TelRilTest::EnterSimPin2Test(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
626 {
627 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_ENTER_PIN2);
628 auto event = AppExecFwk::InnerEvent::Get(eventId);
629 if (event != nullptr && telRilManager_ != nullptr) {
630 event->SetOwner(handler);
631 std::string pin2 = GTEST_STRING_PIN2;
632 TELEPHONY_LOGI("TelRilTest::EnterSimPin2Test -->");
633 telRilManager_->UnlockPin2(slotId, pin2, event);
634 TELEPHONY_LOGI("TelRilTest::EnterSimPin2Test --> finished");
635 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
636 ASSERT_TRUE(syncResult);
637 }
638 }
639
640 /**
641 * @brief Enter Error pin2 code
642 *
643 * @param handler
644 */
EnterErrorPin2Test(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)645 void TelRilTest::EnterErrorPin2Test(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
646 {
647 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_ENTER_PIN2);
648 auto event = AppExecFwk::InnerEvent::Get(eventId);
649 if (event != nullptr && telRilManager_ != nullptr) {
650 event->SetOwner(handler);
651 std::string pin2 = "2222";
652 TELEPHONY_LOGI("TelRilTest::EnterErrorPin2Test -->");
653 telRilManager_->UnlockPin2(slotId, pin2, event);
654 TELEPHONY_LOGI("TelRilTest::EnterErrorPin2Test --> finished");
655 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
656 ASSERT_TRUE(syncResult);
657 }
658 }
659
660 /**
661 * @brief Unlock SIM card pin2 code
662 *
663 * @param handler
664 */
UnlockSimPin2Test(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)665 void TelRilTest::UnlockSimPin2Test(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
666 {
667 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_UNLOCK_PIN2);
668 auto event = AppExecFwk::InnerEvent::Get(eventId);
669 if (event != nullptr && telRilManager_ != nullptr) {
670 event->SetOwner(handler);
671 std::string puk2 = GTEST_STRING_PUK2;
672 std::string pin2 = GTEST_STRING_PIN2;
673 TELEPHONY_LOGI("TelRilTest::UnlockSimPin2Test -->");
674 telRilManager_->UnlockPuk2(slotId, puk2, pin2, event);
675 TELEPHONY_LOGI("TelRilTest::UnlockSimPin2Test --> finished");
676 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
677 ASSERT_TRUE(syncResult);
678 }
679 }
680
681 /**
682 * @brief Enable SIM card
683 *
684 * @param handler
685 */
EnableSimCardTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)686 void TelRilTest::EnableSimCardTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
687 {
688 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SIM_CARD_ENABLED);
689 auto event = AppExecFwk::InnerEvent::Get(eventId);
690 if (event != nullptr && telRilManager_ != nullptr) {
691 event->SetOwner(handler);
692 int index = 0;
693 int enable = 0;
694 TELEPHONY_LOGI("TelRilTest::EnableSimCardTest -->");
695 telRilManager_->SetActiveSim(slotId, index, enable, event);
696 TELEPHONY_LOGI("TelRilTest::EnableSimCardTest --> finished");
697 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
698 ASSERT_TRUE(syncResult);
699 }
700 }
701
702 /**
703 * @brief Get radio protocol
704 *
705 * @param handler
706 */
GetRadioProtocolTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)707 void TelRilTest::GetRadioProtocolTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
708 {
709 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_RADIO_PROTOCOL);
710 auto event = AppExecFwk::InnerEvent::Get(eventId);
711 if (event == nullptr || telRilManager_ == nullptr) {
712 TELEPHONY_LOGE("TelRilTest::GetRadioProtocolTest telRilManager_ or event is nullptr");
713 return;
714 }
715 event->SetOwner(handler);
716 TELEPHONY_LOGI("TelRilTest::GetRadioProtocolTest -->");
717 telRilManager_->GetRadioProtocol(slotId, event);
718 TELEPHONY_LOGI("TelRilTest::GetRadioProtocolTest --> finished");
719 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
720 ASSERT_TRUE(syncResult);
721 }
722
723 /**
724 * @brief Set radio protocol
725 *
726 * @param handler
727 */
SetRadioProtocolTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)728 void TelRilTest::SetRadioProtocolTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
729 {
730 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_RADIO_PROTOCOL);
731 auto event = AppExecFwk::InnerEvent::Get(eventId);
732 if (event == nullptr || telRilManager_ == nullptr) {
733 TELEPHONY_LOGE("TelRilTest::SetRadioProtocolTest telRilManager_ or event is nullptr");
734 return;
735 }
736 event->SetOwner(handler);
737 TELEPHONY_LOGI("TelRilTest::SetRadioProtocolTest -->");
738 RadioProtocol protocol;
739 protocol.sessionId = 1;
740 protocol.phase = RadioProtocolPhase::RADIO_PROTOCOL_PHASE_CHECK;
741 protocol.technology = (int32_t)RadioProtocolTech::RADIO_PROTOCOL_TECH_LTE;
742 protocol.modemId = 0;
743 protocol.status = RadioProtocolStatus::RADIO_PROTOCOL_STATUS_NONE;
744 telRilManager_->SetRadioProtocol(slotId, protocol, event);
745 TELEPHONY_LOGI("TelRilTest::SetRadioProtocolTest --> finished");
746 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
747 ASSERT_TRUE(syncResult);
748 }
749
750 /**
751 * @brief Send terminal response command
752 *
753 * @param handler
754 */
SendTerminalResponseCmdTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)755 void TelRilTest::SendTerminalResponseCmdTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
756 {
757 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_STK_SEND_TERMINAL_RESPONSE);
758 auto event = AppExecFwk::InnerEvent::Get(eventId);
759 if (event != nullptr && telRilManager_ != nullptr) {
760 event->SetOwner(handler);
761 TELEPHONY_LOGI("TelRilTest::SendTerminalResponseCmdTest -->");
762 telRilManager_->SendTerminalResponseCmd(slotId, "", event);
763 TELEPHONY_LOGI("TelRilTest::SendTerminalResponseCmdTest --> finished");
764 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
765 ASSERT_TRUE(syncResult);
766 }
767 }
768
769 /**
770 * @brief Send envelope command
771 *
772 * @param handler
773 */
SendEnvelopeCmdTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)774 void TelRilTest::SendEnvelopeCmdTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
775 {
776 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_STK_SEND_ENVELOPE);
777 auto event = AppExecFwk::InnerEvent::Get(eventId);
778 if (event != nullptr && telRilManager_ != nullptr) {
779 event->SetOwner(handler);
780 TELEPHONY_LOGI("TelRilTest::SendEnvelopeCmdTest -->");
781 telRilManager_->SendEnvelopeCmd(slotId, "", event);
782 TELEPHONY_LOGI("TelRilTest::SendEnvelopeCmdTest --> finished");
783 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
784 ASSERT_TRUE(syncResult);
785 }
786 }
787
788 /**
789 * @brief Send Call Setup Request Result command
790 *
791 * @param handler
792 */
SendCallSetupRequestResultTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)793 void TelRilTest::SendCallSetupRequestResultTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
794 {
795 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_STK_SEND_CALL_SETUP_REQUEST_RESULT);
796 auto event = AppExecFwk::InnerEvent::Get(eventId);
797 if (event != nullptr && telRilManager_ != nullptr) {
798 event->SetOwner(handler);
799 TELEPHONY_LOGI("TelRilTest::SendCallSetupRequestResultTest -->");
800 telRilManager_->SendCallSetupRequestResult(slotId, true, event);
801 TELEPHONY_LOGI("TelRilTest::SendCallSetupRequestResultTest --> finished");
802 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
803 ASSERT_TRUE(syncResult);
804 }
805 }
806
807 /************************************** SIM test func *******************************************/
808 /**
809 * @brief Get Received Signal Strength Indication
810 *
811 * @param handler
812 */
NetworkGetRssiTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)813 void TelRilTest::NetworkGetRssiTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
814 {
815 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_SIGNAL_STRENGTH);
816 auto event = AppExecFwk::InnerEvent::Get(eventId);
817 if (event != nullptr && telRilManager_ != nullptr) {
818 event->SetOwner(handler);
819 TELEPHONY_LOGI("TelRilTest::NetworkGetRssiTest -->");
820 telRilManager_->GetSignalStrength(slotId, event);
821 TELEPHONY_LOGI("TelRilTest::NetworkGetRssiTest --> finished");
822 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
823 ASSERT_TRUE(syncResult);
824 }
825 }
826
827 /**
828 * @brief Call dial
829 *
830 * @param handler
831 */
CallDialTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)832 void TelRilTest::CallDialTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
833 {
834 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_DIAL);
835 auto event = AppExecFwk::InnerEvent::Get(eventId);
836 if (event == nullptr || telRilManager_ == nullptr) {
837 TELEPHONY_LOGI("TelRilTest::CallDialTest failed!!!!");
838 return;
839 }
840
841 std::string phoneNum = GetRandPhoneNum(PHONE_NUM_LEN);
842 int32_t clirMode; /* Calling Line Identification Restriction . From TS 27.007 V3.4.0 (2000-03) */
843 event->SetOwner(handler);
844 clirMode = 0; // use subscription default value
845 TELEPHONY_LOGI("TelRilTest::CallDialTest -->");
846 telRilManager_->Dial(slotId, phoneNum, clirMode, event);
847 TELEPHONY_LOGI("TelRilTest::CallDialTest --> finished");
848 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
849 ASSERT_TRUE(syncResult);
850 }
851
852 /**
853 * @brief Reject call
854 *
855 * @param handler
856 */
RefusedCallTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)857 void TelRilTest::RefusedCallTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
858 {
859 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_REJECT_CALL);
860 auto event = AppExecFwk::InnerEvent::Get(eventId);
861 if (event != nullptr && telRilManager_ != nullptr) {
862 event->SetOwner(handler);
863 TELEPHONY_LOGI("TelRilTest::RefusedCallTest -->");
864 telRilManager_->Reject(slotId, event);
865 TELEPHONY_LOGI("TelRilTest::RefusedCallTest --> finished");
866 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
867 ASSERT_TRUE(syncResult);
868 }
869 }
870
871 /**
872 * @brief Get call waiting
873 *
874 * @param handler
875 */
GetCallWaitTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)876 void TelRilTest::GetCallWaitTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
877 {
878 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CALL_WAIT);
879 auto event = AppExecFwk::InnerEvent::Get(eventId);
880 if (event != nullptr && telRilManager_ != nullptr) {
881 event->SetOwner(handler);
882 TELEPHONY_LOGI("TelRilTest::GetCallWaitTest -->");
883 telRilManager_->GetCallWaiting(slotId, event);
884 TELEPHONY_LOGI("TelRilTest::GetCallWaitTest --> finished");
885 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
886 ASSERT_TRUE(syncResult);
887 }
888 }
889
890 /**
891 * @brief Set call waiting
892 *
893 * @param handler
894 */
SetCallWaitTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)895 void TelRilTest::SetCallWaitTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
896 {
897 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CALL_WAIT);
898 auto event = AppExecFwk::InnerEvent::Get(eventId);
899 if (event == nullptr || telRilManager_ == nullptr) {
900 return;
901 }
902 event->SetOwner(handler);
903 int32_t operating = 0;
904 TELEPHONY_LOGI("TelRilTest::SetCallWaitTest -->");
905 telRilManager_->SetCallWaiting(slotId, operating, event);
906 TELEPHONY_LOGI("TelRilTest::SetCallWaitTest --> finished");
907 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
908 ASSERT_TRUE(syncResult);
909 }
910
911 /**
912 * @brief Call hangup
913 *
914 * @param handler
915 */
CallHangupTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)916 void TelRilTest::CallHangupTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
917 {
918 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_HANGUP_CONNECT);
919 auto event = AppExecFwk::InnerEvent::Get(eventId);
920 if (event != nullptr && telRilManager_ != nullptr) {
921 event->SetOwner(handler);
922 TELEPHONY_LOGI("TelRilTest::CallHangupTest -->");
923 telRilManager_->Hangup(slotId, static_cast<int>(event->GetInnerEventId()), event);
924 TELEPHONY_LOGI("TelRilTest::CallHangupTest --> finished");
925 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
926 ASSERT_TRUE(syncResult);
927 }
928 }
929
930 /**
931 * @brief Answer the call
932 *
933 * @param handler
934 */
CallAnswerTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)935 void TelRilTest::CallAnswerTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
936 {
937 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_ACCEPT_CALL);
938 auto event = AppExecFwk::InnerEvent::Get(eventId);
939 if (event != nullptr && telRilManager_ != nullptr) {
940 event->SetOwner(handler);
941 TELEPHONY_LOGI("TelRilTest::CallAnswerTest -->");
942 telRilManager_->Answer(slotId, event);
943 TELEPHONY_LOGI("TelRilTest::CallAnswerTest --> finished");
944 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
945 ASSERT_TRUE(syncResult);
946 }
947 }
948
949 /**
950 * @brief Call on hold
951 *
952 * @param handler
953 */
CallHoldTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)954 void TelRilTest::CallHoldTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
955 {
956 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_HOLD_CALL);
957 auto event = AppExecFwk::InnerEvent::Get(eventId);
958 if (event != nullptr && telRilManager_ != nullptr) {
959 event->SetOwner(handler);
960 TELEPHONY_LOGI("TelRilTest::CallHoldTest -->");
961 telRilManager_->HoldCall(slotId, event);
962 TELEPHONY_LOGI("TelRilTest::CallHoldTest --> finished");
963 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
964 ASSERT_TRUE(syncResult);
965 }
966 }
967
968 /**
969 * @brief Call activation
970 *
971 * @param handler
972 */
CallActiveTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)973 void TelRilTest::CallActiveTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
974 {
975 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_ACTIVE_CALL);
976 auto event = AppExecFwk::InnerEvent::Get(eventId);
977 if (event != nullptr && telRilManager_ != nullptr) {
978 event->SetOwner(handler);
979 TELEPHONY_LOGI("TelRilTest::CallActiveTest -->");
980 telRilManager_->UnHoldCall(slotId, event);
981 TELEPHONY_LOGI("TelRilTest::CallActiveTest --> finished");
982 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
983 ASSERT_TRUE(syncResult);
984 }
985 }
986
987 /**
988 * @brief Call switch
989 *
990 * @param handler
991 */
CallSwapTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)992 void TelRilTest::CallSwapTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
993 {
994 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SWAP_CALL);
995 auto event = AppExecFwk::InnerEvent::Get(eventId);
996 if (event != nullptr && telRilManager_ != nullptr) {
997 event->SetOwner(handler);
998 TELEPHONY_LOGI("TelRilTest::CallSwapTest -->");
999 telRilManager_->SwitchCall(slotId, event);
1000 TELEPHONY_LOGI("TelRilTest::CallSwapTest --> finished");
1001 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1002 ASSERT_TRUE(syncResult);
1003 }
1004 }
1005
1006 /**
1007 * @brief Get Voice Registration State
1008 *
1009 * @param handler
1010 */
NetworkVoiceRegistrationStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1011 void TelRilTest::NetworkVoiceRegistrationStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1012 {
1013 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_VOICE_REG_STATE);
1014 auto event = AppExecFwk::InnerEvent::Get(eventId);
1015 if (event != nullptr && telRilManager_ != nullptr) {
1016 event->SetOwner(handler);
1017 TELEPHONY_LOGI("TelRilTest::NetworkVoiceRegistrationStateTest -->");
1018 telRilManager_->GetCsRegStatus(slotId, event);
1019 TELEPHONY_LOGI("TelRilTest::NetworkVoiceRegistrationStateTest --> finished");
1020 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1021 ASSERT_TRUE(syncResult);
1022 }
1023 }
1024
1025 /**
1026 * @brief Get Data Registration State
1027 *
1028 * @param handler
1029 */
NetworkDataRegistrationStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1030 void TelRilTest::NetworkDataRegistrationStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1031 {
1032 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_DATA_REG_STATE);
1033 auto event = AppExecFwk::InnerEvent::Get(eventId);
1034 if (event != nullptr && telRilManager_ != nullptr) {
1035 event->SetOwner(handler);
1036 TELEPHONY_LOGI("TelRilTest::NetworkDataRegistrationStateTest -->");
1037 telRilManager_->GetPsRegStatus(slotId, event);
1038 TELEPHONY_LOGI("TelRilTest::NetworkDataRegistrationStateTest --> finished");
1039 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1040 ASSERT_TRUE(syncResult);
1041 }
1042 }
1043
1044 /**
1045 * @brief Get operator information
1046 *
1047 * @param handler
1048 */
NetworkOperatorTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1049 void TelRilTest::NetworkOperatorTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1050 {
1051 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_OPERATOR);
1052 auto event = AppExecFwk::InnerEvent::Get(eventId);
1053 if (event != nullptr && telRilManager_ != nullptr) {
1054 event->SetOwner(handler);
1055 TELEPHONY_LOGI("TelRilTest::NetworkOperatorTest -->");
1056 telRilManager_->GetOperatorInfo(slotId, event);
1057 TELEPHONY_LOGI("TelRilTest::NetworkOperatorTest --> finished");
1058 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1059 ASSERT_TRUE(syncResult);
1060 }
1061 }
1062
1063 /**
1064 * @brief Send SMS
1065 *
1066 * @param handler
1067 */
SendRilCmSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1068 void TelRilTest::SendRilCmSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1069 {
1070 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SEND_SMS);
1071 auto event = AppExecFwk::InnerEvent::Get(eventId);
1072 if (event != nullptr && telRilManager_ != nullptr) {
1073 event->SetOwner(handler);
1074 TELEPHONY_LOGI("TelRilTest::SendRilCmSmsTest -->");
1075 telRilManager_->SendGsmSms(slotId, TEST_SMSC_PDU, TEST_PDU, event);
1076 TELEPHONY_LOGI("TelRilTest::SendRilCmSmsTest --> finished");
1077 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1078 ASSERT_TRUE(syncResult);
1079 }
1080 }
1081
1082 /**
1083 * @brief Storage SMS
1084 *
1085 * @param handler
1086 */
StorageRilCmSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1087 void TelRilTest::StorageRilCmSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1088 {
1089 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_STORAGE_SMS);
1090 auto event = AppExecFwk::InnerEvent::Get(eventId);
1091 SimMessageParam simMessage;
1092 simMessage.status = 0;
1093 simMessage.gsmIndex = 0;
1094 simMessage.pdu = GTEST_STRING;
1095 simMessage.smscPdu = GTEST_STRING;
1096 if (event != nullptr && telRilManager_ != nullptr) {
1097 event->SetOwner(handler);
1098 TELEPHONY_LOGI("TelRilTest::StorageRilCmSmsTest -->");
1099 telRilManager_->AddSimMessage(slotId, simMessage, event);
1100 TELEPHONY_LOGI("TelRilTest::StorageRilCmSmsTest --> finished");
1101 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1102 ASSERT_TRUE(syncResult);
1103 }
1104 }
1105
1106 /**
1107 * @brief Delete SMS
1108 *
1109 * @param handler
1110 */
DeleteRilCmSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1111 void TelRilTest::DeleteRilCmSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1112 {
1113 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_DELETE_SMS);
1114 auto event = AppExecFwk::InnerEvent::Get(eventId);
1115 int32_t gsmIndex = 0;
1116 if (event != nullptr && telRilManager_ != nullptr) {
1117 event->SetOwner(handler);
1118 TELEPHONY_LOGI("TelRilTest::DeleteRilCmSmsTest -->");
1119 telRilManager_->DelSimMessage(slotId, gsmIndex, event);
1120 TELEPHONY_LOGI("TelRilTest::DeleteRilCmSmsTest --> finished");
1121 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1122 ASSERT_TRUE(syncResult);
1123 }
1124 }
1125
1126 /**
1127 * @brief Update SMS
1128 *
1129 * @param handler
1130 */
UpdateRilCmSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1131 void TelRilTest::UpdateRilCmSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1132 {
1133 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_UPDATE_SMS);
1134 auto event = AppExecFwk::InnerEvent::Get(eventId);
1135 if (event != nullptr && telRilManager_ != nullptr) {
1136 event->SetOwner(handler);
1137 SimMessageParam simMessage;
1138 simMessage.gsmIndex = 0;
1139 simMessage.status = 0;
1140 simMessage.pdu = GTEST_STRING;
1141 simMessage.smscPdu = GTEST_STRING;
1142 TELEPHONY_LOGI("TelRilTest::UpdateRilCmSmsTest -->");
1143 telRilManager_->UpdateSimMessage(slotId, simMessage, event);
1144 TELEPHONY_LOGI("TelRilTest::UpdateRilCmSmsTest --> finished");
1145 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1146 ASSERT_TRUE(syncResult);
1147 }
1148 }
1149
1150 /**
1151 * @brief Set SMS center address
1152 *
1153 * @param handler
1154 */
SetRilCmSmsCenterAddressTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1155 void TelRilTest::SetRilCmSmsCenterAddressTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1156 {
1157 int32_t eventIdGetSmsc = static_cast<int32_t>(RadioEvent::RADIO_GET_SMS_CENTER_ADDRESS);
1158 int32_t eventIdSetSmsc = static_cast<int32_t>(RadioEvent::RADIO_SET_SMS_CENTER_ADDRESS);
1159 auto eventGetSmsc = AppExecFwk::InnerEvent::Get(eventIdGetSmsc);
1160 auto eventSetSmsc = AppExecFwk::InnerEvent::Get(eventIdSetSmsc);
1161 if (eventGetSmsc != nullptr && eventSetSmsc != nullptr && telRilManager_ != nullptr) {
1162 // get smsc first
1163 eventGetSmsc->SetOwner(handler);
1164 TELEPHONY_LOGI("TelRilTest::GetRilCmSmsCenterAddressTest -->");
1165 telRilManager_->GetSmscAddr(slotId, eventGetSmsc);
1166 TELEPHONY_LOGI("TelRilTest::GetRilCmSmsCenterAddressTest --> finished");
1167 bool syncResult = WaitGetResult(eventIdGetSmsc, handler, WAIT_TIME_SECOND);
1168 ASSERT_TRUE(syncResult);
1169 // then set smsc
1170 eventSetSmsc->SetOwner(handler);
1171 TELEPHONY_LOGI("TelRilTest::SetRilCmSmsCenterAddressTest -->");
1172 telRilManager_->SetSmscAddr(slotId, g_tosca, g_smscAddr, eventSetSmsc);
1173 TELEPHONY_LOGI("TelRilTest::SetRilCmSmsCenterAddressTest --> finished");
1174 syncResult = WaitGetResult(eventIdSetSmsc, handler, WAIT_TIME_SECOND);
1175 ASSERT_TRUE(syncResult);
1176 }
1177 }
1178
1179 /**
1180 * @brief Get SMS center address
1181 *
1182 * @param handler
1183 */
GetRilCmSmsCenterAddressTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1184 void TelRilTest::GetRilCmSmsCenterAddressTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1185 {
1186 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_SMS_CENTER_ADDRESS);
1187 auto event = AppExecFwk::InnerEvent::Get(eventId);
1188 if (event != nullptr && telRilManager_ != nullptr) {
1189 event->SetOwner(handler);
1190 TELEPHONY_LOGI("TelRilTest::GetRilCmSmsCenterAddressTest -->");
1191 telRilManager_->GetSmscAddr(slotId, event);
1192 TELEPHONY_LOGI("TelRilTest::GetRilCmSmsCenterAddressTest --> finished");
1193 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1194 ASSERT_TRUE(syncResult);
1195 }
1196 }
1197
1198 /**
1199 * @brief Set SMS cell broadcast
1200 *
1201 * @param handler
1202 */
SetRilCmCBConfigTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1203 void TelRilTest::SetRilCmCBConfigTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1204 {
1205 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CELL_BROADCAST);
1206 auto event = AppExecFwk::InnerEvent::Get(eventId);
1207 if (event != nullptr && telRilManager_ != nullptr) {
1208 event->SetOwner(handler);
1209 CBConfigParam cbConfig;
1210 cbConfig.mode = 0;
1211 cbConfig.idList = "0,1,5,320-478,922";
1212 cbConfig.dcsList = "0-3,5";
1213 TELEPHONY_LOGI("TelRilTest::SetRilCmCBConfigTest -->");
1214 telRilManager_->SetCBConfig(slotId, cbConfig, event);
1215 TELEPHONY_LOGI("TelRilTest::SetRilCmCBConfigTest --> finished");
1216 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1217 ASSERT_TRUE(syncResult);
1218 }
1219 }
1220
1221 /**
1222 * @brief Set CDMA SMS cell broadcast
1223 *
1224 * @param handler
1225 */
SetRilCmCdmaCBConfigTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1226 void TelRilTest::SetRilCmCdmaCBConfigTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1227 {
1228 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CDMA_CELL_BROADCAST);
1229 auto event = AppExecFwk::InnerEvent::Get(eventId);
1230 CdmaCBConfigInfoList broadcastInfoList = {};
1231 if (event != nullptr && telRilManager_ != nullptr) {
1232 event->SetOwner(handler);
1233 TELEPHONY_LOGI("TelRilTest::SetRilCmCdmaCBConfigTest -->");
1234 telRilManager_->SetCdmaCBConfig(slotId, broadcastInfoList, event);
1235 TELEPHONY_LOGI("TelRilTest::SetRilCmCdmaCBConfigTest --> finished");
1236 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1237 ASSERT_TRUE(syncResult);
1238 }
1239 }
1240
1241 /**
1242 * @brief Get SMS cell broadcast
1243 *
1244 * @param handler
1245 */
GetRilCmCBConfigTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1246 void TelRilTest::GetRilCmCBConfigTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1247 {
1248 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CELL_BROADCAST);
1249 auto event = AppExecFwk::InnerEvent::Get(eventId);
1250 if (event != nullptr && telRilManager_ != nullptr) {
1251 event->SetOwner(handler);
1252 TELEPHONY_LOGI("TelRilTest::GetRilCmCBConfigTest -->");
1253 telRilManager_->GetCBConfig(slotId, event);
1254 TELEPHONY_LOGI("TelRilTest::GetRilCmCBConfigTest --> finished");
1255 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1256 ASSERT_TRUE(syncResult);
1257 }
1258 }
1259
1260 /**
1261 * @brief Get CDMA SMS cell broadcast
1262 *
1263 * @param handler
1264 */
GetRilCmCdmaCBConfigTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1265 void TelRilTest::GetRilCmCdmaCBConfigTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1266 {
1267 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CDMA_CELL_BROADCAST);
1268 auto event = AppExecFwk::InnerEvent::Get(eventId);
1269 if (event != nullptr && telRilManager_ != nullptr) {
1270 event->SetOwner(handler);
1271 TELEPHONY_LOGI("TelRilTest::GetRilCmCdmaCBConfigTest -->");
1272 telRilManager_->GetCdmaCBConfig(slotId, event);
1273 TELEPHONY_LOGI("TelRilTest::GetRilCmCdmaCBConfigTest --> finished");
1274 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1275 ASSERT_TRUE(syncResult);
1276 }
1277 }
1278
1279 /**
1280 * @brief Send multiple SMS
1281 *
1282 * @param handler
1283 */
SmsSendSmsExpectMoreTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1284 void TelRilTest::SmsSendSmsExpectMoreTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1285 {
1286 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SEND_SMS_EXPECT_MORE);
1287 auto event = AppExecFwk::InnerEvent::Get(eventId);
1288 if (event != nullptr && telRilManager_ != nullptr) {
1289 event->SetOwner(handler);
1290 TELEPHONY_LOGI("TelRilTest::SmsSendSmsExpectMoreTest -->");
1291 telRilManager_->SendSmsMoreMode(slotId, TEST_SMSC_PDU, TEST_PDU, event);
1292 TELEPHONY_LOGI("TelRilTest::SmsSendSmsExpectMoreTest --> finished");
1293 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1294 ASSERT_TRUE(syncResult);
1295 }
1296 }
1297
1298 /**
1299 * @brief Set radio state
1300 *
1301 * @param handler
1302 */
SetRadioStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1303 void TelRilTest::SetRadioStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1304 {
1305 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_STATUS);
1306 auto event = AppExecFwk::InnerEvent::Get(eventId);
1307 if (event != nullptr && telRilManager_ != nullptr) {
1308 event->SetOwner(handler);
1309 TELEPHONY_LOGI("TelRilTest::SetRadioStateTest -->");
1310 // set radio state off
1311 telRilManager_->SetRadioState(slotId, 0, 0, event);
1312 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1313 ASSERT_TRUE(syncResult);
1314 // set radio state on
1315 telRilManager_->SetRadioState(slotId, 1, 0, event);
1316 syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1317 ASSERT_TRUE(syncResult);
1318 TELEPHONY_LOGI("TelRilTest::SetRadioStateTest --> finished");
1319 }
1320 }
1321
1322 /**
1323 * @brief Get radio state
1324 *
1325 * @param handler
1326 */
GetRadioStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1327 void TelRilTest::GetRadioStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1328 {
1329 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_STATUS);
1330 auto event = AppExecFwk::InnerEvent::Get(eventId);
1331 if (event != nullptr && telRilManager_ != nullptr) {
1332 event->SetOwner(handler);
1333 TELEPHONY_LOGI("TelRilTest::GetRadioStateTest -->");
1334 telRilManager_->GetRadioState(slotId, event);
1335 TELEPHONY_LOGI("TelRilTest::GetRadioStateTest --> finished");
1336 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1337 ASSERT_TRUE(syncResult);
1338 }
1339 }
1340
1341 /**
1342 * @brief SMS Acknowledge
1343 *
1344 * @param handler
1345 */
SmsAcknowledgeTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1346 void TelRilTest::SmsAcknowledgeTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1347 {
1348 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SEND_SMS_ACK);
1349 auto event = AppExecFwk::InnerEvent::Get(eventId);
1350 if (event != nullptr && telRilManager_ != nullptr) {
1351 event->SetOwner(handler);
1352 TELEPHONY_LOGI("TelRilTest::SmsAcknowledgeTest -->");
1353 telRilManager_->SendSmsAck(slotId, true, REASON, event);
1354 TELEPHONY_LOGI("TelRilTest::SmsAcknowledgeTest --> finished");
1355 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1356 ASSERT_TRUE(syncResult);
1357 }
1358 }
1359
1360 /**
1361 * @brief Add CDMA SMS
1362 *
1363 * @param handler
1364 */
AddRilCmCdmaSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1365 void TelRilTest::AddRilCmCdmaSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1366 {
1367 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_ADD_CDMA_SMS);
1368 auto event = AppExecFwk::InnerEvent::Get(eventId);
1369 int32_t status = 0;
1370 std::string pdu = GTEST_STRING;
1371 if (event != nullptr && telRilManager_ != nullptr) {
1372 event->SetOwner(handler);
1373 TELEPHONY_LOGI("TelRilTest::AddRilCmCdmaSmsTest -->");
1374 telRilManager_->AddCdmaSimMessage(slotId, status, pdu, event);
1375 TELEPHONY_LOGI("TelRilTest::AddRilCmCdmaSmsTest --> finished");
1376 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1377 ASSERT_TRUE(syncResult);
1378 }
1379 }
1380
1381 /**
1382 * @brief Delete CDMA SMS
1383 *
1384 * @param handler
1385 */
DelRilCmCdmaSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1386 void TelRilTest::DelRilCmCdmaSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1387 {
1388 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_DEL_CDMA_SMS);
1389 auto event = AppExecFwk::InnerEvent::Get(eventId);
1390 int32_t gsmIndex = 0;
1391 if (event != nullptr && telRilManager_ != nullptr) {
1392 event->SetOwner(handler);
1393 TELEPHONY_LOGI("TelRilTest::DelRilCmCdmaSmsTest -->");
1394 telRilManager_->DelCdmaSimMessage(slotId, gsmIndex, event);
1395 TELEPHONY_LOGI("TelRilTest::DelRilCmCdmaSmsTest --> finished");
1396 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1397 ASSERT_TRUE(syncResult);
1398 }
1399 }
1400
1401 /**
1402 * @brief Update CDMA SMS
1403 *
1404 * @param handler
1405 */
UpdateRilCmCdmaSmsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1406 void TelRilTest::UpdateRilCmCdmaSmsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1407 {
1408 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_UPDATE_CDMA_SMS);
1409 auto event = AppExecFwk::InnerEvent::Get(eventId);
1410 if (event != nullptr && telRilManager_ != nullptr) {
1411 event->SetOwner(handler);
1412 CdmaSimMessageParam cdmaSimMsg;
1413 cdmaSimMsg.cdmaIndex = 0;
1414 cdmaSimMsg.status = 0;
1415 cdmaSimMsg.pdu = GTEST_STRING;
1416 TELEPHONY_LOGI("TelRilTest::UpdateRilCmCdmaSmsTest -->");
1417 telRilManager_->UpdateCdmaSimMessage(slotId, cdmaSimMsg, event);
1418 TELEPHONY_LOGI("TelRilTest::UpdateRilCmCdmaSmsTest --> finished");
1419 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1420 ASSERT_TRUE(syncResult);
1421 }
1422 }
1423
1424 /**
1425 * @brief Set apn initialization information
1426 *
1427 * @param handler
1428 */
DataSetInitApnInfoTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1429 void TelRilTest::DataSetInitApnInfoTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1430 {
1431 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SET_INIT_APN_INFO);
1432 auto event = AppExecFwk::InnerEvent::Get(eventId);
1433 if (event != nullptr && telRilManager_ != nullptr) {
1434 event->SetOwner(handler);
1435 TELEPHONY_LOGI("TelRilTest::DataSetInitApnInfoTest -->");
1436 DataProfile dataProfile;
1437 dataProfile.profileId = 0;
1438 dataProfile.apn = "cmnet";
1439 dataProfile.protocol = "IPV4V6";
1440 dataProfile.verType = AUTHTYPE_1;
1441 dataProfile.userName = "";
1442 dataProfile.password = "";
1443 dataProfile.roamingProtocol = "IPV4V6";
1444 telRilManager_->SetInitApnInfo(slotId, dataProfile, event);
1445 TELEPHONY_LOGI("TelRilTest::DataSetInitApnInfoTest --> finished");
1446 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1447 ASSERT_TRUE(syncResult);
1448 }
1449 }
1450
1451 /**
1452 * @brief Set data call
1453 *
1454 * @param handler
1455 */
DataSetupDataCallTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1456 void TelRilTest::DataSetupDataCallTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1457 {
1458 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SETUP_DATA_CALL);
1459 auto event = AppExecFwk::InnerEvent::Get(eventId);
1460 if (event != nullptr && telRilManager_ != nullptr) {
1461 event->SetOwner(handler);
1462 ActivateDataParam activateData;
1463 activateData.param = 0;
1464 activateData.radioTechnology = 0;
1465 activateData.isRoaming = false;
1466 activateData.allowRoaming = true;
1467 activateData.dataProfile.profileId = 0;
1468 activateData.dataProfile.apn = "cmnet";
1469 activateData.dataProfile.protocol = "IPV4V6";
1470 activateData.dataProfile.verType = AUTHTYPE_1;
1471 activateData.dataProfile.userName = "";
1472 activateData.dataProfile.password = "";
1473 activateData.dataProfile.roamingProtocol = "IPV4V6";
1474 TELEPHONY_LOGI("TelRilTest::DataSetupDataCallTest -->");
1475 telRilManager_->ActivatePdpContext(slotId, activateData, event);
1476 TELEPHONY_LOGI("TelRilTest::DataSetupDataCallTest --> finished");
1477 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1478 ASSERT_TRUE(syncResult);
1479 }
1480 }
1481
1482 /**
1483 * @brief Disable data call
1484 *
1485 * @param handler
1486 */
DataDisableDataCallTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1487 void TelRilTest::DataDisableDataCallTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1488 {
1489 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_DEACTIVATE_DATA_CALL);
1490 auto event = AppExecFwk::InnerEvent::Get(eventId);
1491 if (event != nullptr && telRilManager_ != nullptr) {
1492 event->SetOwner(handler);
1493 TELEPHONY_LOGI("TelRilTest::DataDisableDataCallTest -->");
1494 telRilManager_->DeactivatePdpContext(slotId, CID, REASON, event);
1495 TELEPHONY_LOGI("TelRilTest::DataDisableDataCallTest --> finished");
1496 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1497 ASSERT_TRUE(syncResult);
1498 }
1499 }
1500
1501 /**
1502 * @brief Get data call list
1503 *
1504 * @param handler
1505 */
GetDataCallListTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1506 void TelRilTest::GetDataCallListTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1507 {
1508 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_GET_DATA_CALL_LIST);
1509 auto event = AppExecFwk::InnerEvent::Get(eventId);
1510 if (event != nullptr && telRilManager_ != nullptr) {
1511 event->SetOwner(handler);
1512 TELEPHONY_LOGI("TelRilTest::GetDataCallListTest -->");
1513 sleep(WAIT_TIME_SECOND);
1514 telRilManager_->GetPdpContextList(slotId, event);
1515 TELEPHONY_LOGI("TelRilTest::GetDataCallListTest --> finished");
1516 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1517 ASSERT_TRUE(syncResult);
1518 }
1519 }
1520
SetDataPermittedTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1521 void TelRilTest::SetDataPermittedTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1522 {
1523 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SET_DATA_PERMITTED_TEST);
1524 auto event = AppExecFwk::InnerEvent::Get(eventId);
1525 if (event != nullptr && telRilManager_ != nullptr) {
1526 event->SetOwner(handler);
1527 TELEPHONY_LOGI("TelRilTest::SetDataPermittedTest -->");
1528 telRilManager_->SetDataPermitted(slotId, true, event);
1529 TELEPHONY_LOGI("TelRilTest::SetDataPermittedTest --> finished");
1530 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1531 ASSERT_TRUE(syncResult);
1532 }
1533 }
1534
1535 /**
1536 * @brief Get data link capability
1537 *
1538 * @param handler
1539 */
GetLinkCapabilityTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1540 void TelRilTest::GetLinkCapabilityTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1541 {
1542 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_GET_LINK_CAPABILITY_TEST);
1543 auto event = AppExecFwk::InnerEvent::Get(eventId);
1544 if (event != nullptr && telRilManager_ != nullptr) {
1545 event->SetOwner(handler);
1546 TELEPHONY_LOGI("TelRilTest::GetLinkCapabilityTest -->");
1547 sleep(WAIT_TIME_SECOND);
1548 telRilManager_->GetLinkCapability(slotId, event);
1549 TELEPHONY_LOGI("TelRilTest::GetLinkCapabilityTest --> finished");
1550 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1551 ASSERT_TRUE(syncResult);
1552 }
1553 }
1554
1555 /**
1556 * @brief Clean all data connections
1557 *
1558 * @param slotId Indicates the card slot index number
1559 * @param handler Indicates the event handler ptr
1560 */
CleanAllConnectionsTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1561 void TelRilTest::CleanAllConnectionsTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1562 {
1563 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_CLEAN_ALL_DATA_CONNECTIONS_TEST);
1564 auto event = AppExecFwk::InnerEvent::Get(eventId);
1565 if (event != nullptr && telRilManager_ != nullptr) {
1566 event->SetOwner(handler);
1567 TELEPHONY_LOGI("TelRilTest::CleanAllConnectionsTest -->");
1568 sleep(WAIT_TIME_SECOND);
1569 telRilManager_->CleanAllConnections(slotId, event);
1570 TELEPHONY_LOGI("TelRilTest::CleanAllConnectionsTest --> finished");
1571 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1572 ASSERT_TRUE(syncResult);
1573 }
1574 }
1575
1576 /**
1577 * @brief Send Ursp decode Result
1578 *
1579 * @param slotId Indicates the card slot index number
1580 * @param handler Indicates the event handler ptr
1581 */
SendUrspDecodeResultTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1582 void TelRilTest::SendUrspDecodeResultTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1583 {
1584 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SEND_URSP_DECODE_RESULT);
1585 auto event = AppExecFwk::InnerEvent::Get(eventId);
1586 if (event != nullptr && telRilManager_ != nullptr) {
1587 event->SetOwner(handler);
1588 TELEPHONY_LOGI("TelRilTest::SendUrspDecodeResultTest -->");
1589 std::vector<uint8_t> buffer = {0};
1590 telRilManager_->SendUrspDecodeResult(slotId, buffer, event);
1591 TELEPHONY_LOGI("SendUrspDecodeResultTest finished");
1592 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1593 ASSERT_TRUE(syncResult);
1594 }
1595 }
1596
1597 /**
1598 * @brief Send Ue Policy Section Identifier
1599 *
1600 * @param slotId Indicates the card slot index number
1601 * @param handler Indicates the event handler ptr
1602 */
SendUePolicySectionIdentifierTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1603 void TelRilTest::SendUePolicySectionIdentifierTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1604 {
1605 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SEND_UE_POLICY_SECTION_IDENTIFIER);
1606 auto event = AppExecFwk::InnerEvent::Get(eventId);
1607 if (event != nullptr && telRilManager_ != nullptr) {
1608 event->SetOwner(handler);
1609 TELEPHONY_LOGI("TelRilTest::SendUePolicySectionIdentifierTest -->");
1610 std::vector<uint8_t> buffer = {0};
1611 telRilManager_->SendUePolicySectionIdentifier(slotId, buffer, event);
1612 TELEPHONY_LOGI("SendUePolicySectionIdentifierTest finished");
1613 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1614 ASSERT_TRUE(syncResult);
1615 }
1616 }
1617
1618 /**
1619 * @brief Send Ims RsdList
1620 *
1621 * @param slotId Indicates the card slot index number
1622 * @param handler Indicates the event handler ptr
1623 */
SendImsRsdListTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1624 void TelRilTest::SendImsRsdListTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1625 {
1626 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SEND_IMS_RSD_LIST);
1627 auto event = AppExecFwk::InnerEvent::Get(eventId);
1628 if (event != nullptr && telRilManager_ != nullptr) {
1629 event->SetOwner(handler);
1630 TELEPHONY_LOGI("TelRilTest::SendImsRsdListTest -->");
1631 std::vector<uint8_t> buffer = {0};
1632 telRilManager_->SendImsRsdList(slotId, buffer, event);
1633 TELEPHONY_LOGI("SendImsRsdListTest finished");
1634 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1635 ASSERT_TRUE(syncResult);
1636 }
1637 }
1638
1639 /**
1640 * @brief Get NetworkSlice AllowedNssai
1641 *
1642 * @param slotId Indicates the card slot index number
1643 * @param handler Indicates the event handler ptr
1644 */
GetNetworkSliceAllowedNssaiTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1645 void TelRilTest::GetNetworkSliceAllowedNssaiTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1646 {
1647 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_GET_NETWORKSLICE_ALLOWEDNSSAI);
1648 auto event = AppExecFwk::InnerEvent::Get(eventId);
1649 if (event != nullptr && telRilManager_ != nullptr) {
1650 event->SetOwner(handler);
1651 TELEPHONY_LOGI("TelRilTest::GetNetworkSliceAllowedNssaiTest -->");
1652 std::vector<uint8_t> buffer = {0};
1653 telRilManager_->GetNetworkSliceAllowedNssai(slotId, buffer, event);
1654 TELEPHONY_LOGI("GetNetworkSliceAllowedNssaiTest finished");
1655 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1656 ASSERT_TRUE(syncResult);
1657 }
1658 }
1659
1660 /**
1661 * @brief Get NetworkSlice Ehplmn
1662 *
1663 * @param slotId Indicates the card slot index number
1664 * @param handler Indicates the event handler ptr
1665 */
GetNetworkSliceEhplmnTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1666 void TelRilTest::GetNetworkSliceEhplmnTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1667 {
1668 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_GET_NETWORKSLICE_EHPLMN);
1669 auto event = AppExecFwk::InnerEvent::Get(eventId);
1670 if (event != nullptr && telRilManager_ != nullptr) {
1671 event->SetOwner(handler);
1672 TELEPHONY_LOGI("TelRilTest::GetNetworkSliceEhplmnTest -->");
1673 telRilManager_->GetNetworkSliceEhplmn(slotId, event);
1674 TELEPHONY_LOGI("GetNetworkSliceEhplmnTest finished");
1675 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1676 ASSERT_TRUE(syncResult);
1677 }
1678 }
1679
1680 /**
1681 * @brief Search for carrier information
1682 *
1683 * @param handler
1684 */
GetNetworkSearchInformationTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1685 void TelRilTest::GetNetworkSearchInformationTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1686 {
1687 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_NETWORKS_TO_USE);
1688 auto event = AppExecFwk::InnerEvent::Get(eventId);
1689 if (event != nullptr && telRilManager_ != nullptr) {
1690 event->SetOwner(handler);
1691 TELEPHONY_LOGI("TelRilTest::GetNetworkSearchInformationTest -->");
1692 telRilManager_->GetNetworkSearchInformation(slotId, event);
1693 TELEPHONY_LOGI("TelRilTest::GetNetworkSearchInformationTest --> finished");
1694 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1695 ASSERT_TRUE(syncResult);
1696 }
1697 }
1698
1699 /**
1700 * @brief Get selection mode
1701 *
1702 * @param handler
1703 */
GetNetworkSelectionModeTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1704 void TelRilTest::GetNetworkSelectionModeTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1705 {
1706 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_SELECTION_MOD_FOR_NETWORKS);
1707 auto event = AppExecFwk::InnerEvent::Get(eventId);
1708 if (event != nullptr && telRilManager_ != nullptr) {
1709 event->SetOwner(handler);
1710 TELEPHONY_LOGI("TelRilTest::GetNetworkSelectionModeTest -->");
1711 telRilManager_->GetNetworkSelectionMode(slotId, event);
1712 TELEPHONY_LOGI("TelRilTest::GetNetworkSelectionModeTest --> finished");
1713 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1714 ASSERT_TRUE(syncResult);
1715 }
1716 }
1717
1718 /**
1719 * @brief Set selection mode
1720 *
1721 * @param handler
1722 */
SetNetworkSelectionModeTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1723 void TelRilTest::SetNetworkSelectionModeTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1724 {
1725 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_MODE_AUTOMATIC_NETWORKS);
1726 auto event = AppExecFwk::InnerEvent::Get(eventId);
1727 if (event != nullptr && telRilManager_ != nullptr) {
1728 event->SetOwner(handler);
1729 TELEPHONY_LOGI("TelRilTest::SetNetworkSelectionModeTest -->");
1730 telRilManager_->SetNetworkSelectionMode(slotId, 0, "46001", event);
1731 TELEPHONY_LOGI("TelRilTest::SetNetworkSelectionModeTest --> finished");
1732 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1733 ASSERT_TRUE(syncResult);
1734 }
1735 }
1736
1737 /**
1738 * @brief Set preferred network parameters
1739 *
1740 * @param handler
1741 */
SetPreferredNetworkParaTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1742 void TelRilTest::SetPreferredNetworkParaTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1743 {
1744 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_PREFERRED_NETWORK_TYPE);
1745 auto event = AppExecFwk::InnerEvent::Get(eventId);
1746 if (event != nullptr && telRilManager_ != nullptr) {
1747 event->SetOwner(handler);
1748 int32_t netType = 0;
1749 TELEPHONY_LOGI("TelRilTest::SetPreferredNetworkParaTest -->");
1750 telRilManager_->SetPreferredNetwork(slotId, netType, event);
1751 TELEPHONY_LOGI("TelRilTest::SetPreferredNetworkParaTest --> finished");
1752 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1753 ASSERT_TRUE(syncResult);
1754 }
1755 }
1756
1757 /**
1758 * @brief Get preferred network parameters
1759 *
1760 * @param handler
1761 */
GetPreferredNetworkParaTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1762 void TelRilTest::GetPreferredNetworkParaTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1763 {
1764 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_PREFERRED_NETWORK_TYPE);
1765 auto event = AppExecFwk::InnerEvent::Get(eventId);
1766 if (event != nullptr && telRilManager_ != nullptr) {
1767 event->SetOwner(handler);
1768 TELEPHONY_LOGI("TelRilTest::GetPreferredNetworkParaTest -->");
1769 telRilManager_->GetPreferredNetwork(slotId, event);
1770 TELEPHONY_LOGI("TelRilTest::GetPreferredNetworkParaTest --> finished");
1771 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1772 ASSERT_TRUE(syncResult);
1773 }
1774 }
1775
1776 /**
1777 * @brief Get IMEI
1778 *
1779 * @param handler
1780 */
GetImeiTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1781 void TelRilTest::GetImeiTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1782 {
1783 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_IMEI);
1784 auto event = AppExecFwk::InnerEvent::Get(eventId);
1785 if (event != nullptr && telRilManager_ != nullptr) {
1786 event->SetOwner(handler);
1787 TELEPHONY_LOGI("TelRilTest::GetImeiTest -->");
1788 telRilManager_->GetImei(slotId, event);
1789 TELEPHONY_LOGI("TelRilTest::GetImeiTest --> finished");
1790 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1791 ASSERT_TRUE(syncResult);
1792 }
1793 }
1794
1795 /**
1796 * @brief Get IMEISV
1797 *
1798 * @param handler
1799 */
GetImeiSvTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1800 void TelRilTest::GetImeiSvTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1801 {
1802 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_IMEISV);
1803 auto event = AppExecFwk::InnerEvent::Get(eventId);
1804 if (event != nullptr && telRilManager_ != nullptr) {
1805 event->SetOwner(handler);
1806 TELEPHONY_LOGI("TelRilTest::GetImeisVTest -->");
1807 telRilManager_->GetImeiSv(slotId, event);
1808 TELEPHONY_LOGI("TelRilTest::GetImeiSvTest --> finished");
1809 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1810 ASSERT_TRUE(syncResult);
1811 }
1812 }
1813
1814 /**
1815 * @brief Get MEID
1816 *
1817 * @param handler
1818 */
GetMeidTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1819 void TelRilTest::GetMeidTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1820 {
1821 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_MEID);
1822 auto event = AppExecFwk::InnerEvent::Get(eventId);
1823 if (event != nullptr && telRilManager_ != nullptr) {
1824 event->SetOwner(handler);
1825 TELEPHONY_LOGI("TelRilTest::GetMeidTest -->");
1826 telRilManager_->GetMeid(slotId, event);
1827 TELEPHONY_LOGI("TelRilTest::GetMeidTest --> finished");
1828 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1829 ASSERT_TRUE(syncResult);
1830 }
1831 }
1832
1833 /**
1834 * @brief Get voice radio technology
1835 *
1836 * @param handler
1837 */
GetVoiceRadioTechnologyTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1838 void TelRilTest::GetVoiceRadioTechnologyTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1839 {
1840 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_VOICE_RADIO_INFO);
1841 auto event = AppExecFwk::InnerEvent::Get(eventId);
1842 if (event != nullptr && telRilManager_ != nullptr) {
1843 event->SetOwner(handler);
1844 TELEPHONY_LOGI("TelRilTest::GetVoiceRadioTechnologyTest -->");
1845 telRilManager_->GetVoiceRadioTechnology(slotId, event);
1846 TELEPHONY_LOGI("TelRilTest::GetVoiceRadioTechnologyTest --> finished");
1847 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1848 ASSERT_TRUE(syncResult);
1849 }
1850 }
1851
1852 /**
1853 * @brief Get physical channel config
1854 *
1855 * @param handler
1856 */
GetPhysicalChannelConfigTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1857 void TelRilTest::GetPhysicalChannelConfigTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1858 {
1859 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG);
1860 auto event = AppExecFwk::InnerEvent::Get(eventId);
1861 if (event != nullptr && telRilManager_ != nullptr) {
1862 event->SetOwner(handler);
1863 TELEPHONY_LOGI("TelRilTest::GetPhysicalChannelConfigTest -->");
1864 telRilManager_->GetPhysicalChannelConfig(slotId, event);
1865 TELEPHONY_LOGI("TelRilTest::GetPhysicalChannelConfigTest --> finished");
1866 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1867 ASSERT_TRUE(syncResult);
1868 }
1869 }
1870
1871 /**
1872 * @brief Set location updates
1873 *
1874 * @param handler
1875 */
SetLocateUpdatesTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1876 void TelRilTest::SetLocateUpdatesTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1877 {
1878 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_LOCATE_UPDATES);
1879 auto event = AppExecFwk::InnerEvent::Get(eventId);
1880 if (event != nullptr && telRilManager_ != nullptr) {
1881 event->SetOwner(handler);
1882 TELEPHONY_LOGI("TelRilTest::SetLocateUpdatesTest -->");
1883 RegNotifyMode mode = REG_NOTIFY_STAT_LAC_CELLID;
1884 telRilManager_->SetLocateUpdates(slotId, mode, event);
1885 TELEPHONY_LOGI("TelRilTest::SetLocateUpdatesTest --> finished");
1886 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1887 ASSERT_TRUE(syncResult);
1888 }
1889 }
1890
1891 /**
1892 * @brief Set notification fiter
1893 *
1894 * @param handler
1895 */
SetNotificationFilterTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1896 void TelRilTest::SetNotificationFilterTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1897 {
1898 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER);
1899 auto event = AppExecFwk::InnerEvent::Get(eventId);
1900 if (event != nullptr && telRilManager_ != nullptr) {
1901 event->SetOwner(handler);
1902 int32_t filter = 1;
1903 TELEPHONY_LOGI("TelRilTest::SetNotificationFilterTest -->");
1904 telRilManager_->SetNotificationFilter(slotId, filter, event);
1905 TELEPHONY_LOGI("TelRilTest::SetNotificationFilterTest --> finished");
1906 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1907 ASSERT_TRUE(syncResult);
1908 }
1909 }
1910
1911 /**
1912 * @brief Set device state
1913 *
1914 * @param handler
1915 */
SetDeviceStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1916 void TelRilTest::SetDeviceStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1917 {
1918 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_DEVICE_STATE);
1919 auto event = AppExecFwk::InnerEvent::Get(eventId);
1920 if (event != nullptr && telRilManager_ != nullptr) {
1921 event->SetOwner(handler);
1922 int32_t deviceStateType = 0;
1923 bool deviceStateOn = true;
1924 TELEPHONY_LOGI("TelRilTest::SetDeviceStateTest -->");
1925 telRilManager_->SetDeviceState(slotId, deviceStateType, deviceStateOn, event);
1926 TELEPHONY_LOGI("TelRilTest::SetDeviceStateTest --> finished");
1927 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1928 ASSERT_TRUE(syncResult);
1929 }
1930 }
1931
1932 /**
1933 * @brief Get rrc conection state
1934 *
1935 * @param handler
1936 */
GetRrcConnectionStateTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1937 void TelRilTest::GetRrcConnectionStateTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1938 {
1939 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_RRC_CONNECTION_STATE);
1940 auto event = AppExecFwk::InnerEvent::Get(eventId);
1941 if (event != nullptr && telRilManager_ != nullptr) {
1942 event->SetOwner(handler);
1943 TELEPHONY_LOGI("TelRilTest::GetRrcConnectionStateTest -->");
1944 telRilManager_->GetRrcConnectionState(slotId, event);
1945 TELEPHONY_LOGI("TelRilTest::GetRrcConnectionStateTest --> finished");
1946 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1947 ASSERT_TRUE(syncResult);
1948 }
1949 }
1950
1951 /**
1952 * @brief Get nr mode
1953 *
1954 * @param handler
1955 */
GetNrOptionModeTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1956 void TelRilTest::GetNrOptionModeTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1957 {
1958 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_NR_OPTION_MODE);
1959 auto event = AppExecFwk::InnerEvent::Get(eventId);
1960 if (event != nullptr && telRilManager_ != nullptr) {
1961 event->SetOwner(handler);
1962 TELEPHONY_LOGI("TelRilTest::GetNrOptionModeTest -->");
1963 telRilManager_->GetNrOptionMode(slotId, event);
1964 TELEPHONY_LOGI("TelRilTest::GetNrOptionModeTest --> finished");
1965 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1966 ASSERT_TRUE(syncResult);
1967 }
1968 }
1969
1970 /**
1971 * @brief Get nr mode
1972 *
1973 * @param handler
1974 */
SetNrOptionModeTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1975 void TelRilTest::SetNrOptionModeTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1976 {
1977 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_NR_OPTION_MODE);
1978 auto event = AppExecFwk::InnerEvent::Get(eventId);
1979 if (event != nullptr && telRilManager_ != nullptr) {
1980 event->SetOwner(handler);
1981 TELEPHONY_LOGI("TelRilTest::SetNrOptionModeTest -->");
1982 int32_t mode = 1;
1983 telRilManager_->SetNrOptionMode(slotId, mode, event);
1984 TELEPHONY_LOGI("TelRilTest::SetNrOptionModeTest --> finished");
1985 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
1986 ASSERT_TRUE(syncResult);
1987 }
1988 }
1989
1990 /**
1991 * @brief Get NR ssb id Information
1992 *
1993 * @param handler
1994 */
GetNrSsbIdTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)1995 void TelRilTest::GetNrSsbIdTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
1996 {
1997 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_NR_SSBID_INFO);
1998 auto event = AppExecFwk::InnerEvent::Get(eventId);
1999 if (event != nullptr && telRilManager_ != nullptr) {
2000 event->SetOwner(handler);
2001 TELEPHONY_LOGI("TelRilTest::GetNrSsbIdTest -->");
2002 telRilManager_->GetNrSsbId(slotId, event);
2003 TELEPHONY_LOGI("TelRilTest::GetNrSsbIdTest --> finished");
2004 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2005 ASSERT_TRUE(syncResult);
2006 }
2007 }
2008
2009 /**
2010 * @brief Get Neighboring cellinfo list
2011 *
2012 * @param handler
2013 */
GetNeighboringCellInfoListTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2014 void TelRilTest::GetNeighboringCellInfoListTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2015 {
2016 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_GET_NEIGHBORING_CELL_INFO_LIST_TYPE);
2017 auto event = AppExecFwk::InnerEvent::Get(eventId);
2018 if (event != nullptr && telRilManager_ != nullptr) {
2019 event->SetOwner(handler);
2020 TELEPHONY_LOGI("TelRilTest::GetNeighboringCellInfoList -->");
2021 telRilManager_->GetNeighboringCellInfoList(slotId, event);
2022 TELEPHONY_LOGI("TelRilTest::GetNeighboringCellInfoList --> finished");
2023 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2024 ASSERT_TRUE(syncResult);
2025 }
2026 }
2027
2028 /**
2029 * @brief Call merge
2030 *
2031 * @param handler
2032 */
CallJoinTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2033 void TelRilTest::CallJoinTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2034 {
2035 /**
2036 * call type
2037 * 0: Voice call
2038 * 1: Video call: send one-way video
2039 * 2: Video call: two-way voice
2040 * 3: Video call: two-way video, two-way voice
2041 */
2042 int32_t callType = 0;
2043 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_JOIN_CALL);
2044 auto event = AppExecFwk::InnerEvent::Get(eventId);
2045 if (event != nullptr && telRilManager_ != nullptr) {
2046 event->SetOwner(handler);
2047 TELEPHONY_LOGI("TelRilTest::CallJoinTest -->");
2048 telRilManager_->CombineConference(slotId, callType, event);
2049 TELEPHONY_LOGI("TelRilTest::CallJoinTest --> finished");
2050 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2051 ASSERT_TRUE(syncResult);
2052 }
2053 }
2054
2055 /**
2056 * @brief Call separation
2057 *
2058 * @param handler
2059 */
CallSplitTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2060 void TelRilTest::CallSplitTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2061 {
2062 int32_t callIndex = 1;
2063 /**
2064 * call type
2065 * 0: Voice call
2066 * 1: Video call: send one-way video
2067 * 2: Video call: two-way voice
2068 * 3: Video call: two-way video, two-way voice
2069 */
2070 int32_t callType = 0;
2071 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SPLIT_CALL);
2072 auto event = AppExecFwk::InnerEvent::Get(eventId);
2073 if (event != nullptr && telRilManager_ != nullptr) {
2074 event->SetOwner(handler);
2075 TELEPHONY_LOGI("TelRilTest::CallSplitTest -->");
2076 telRilManager_->SeparateConference(slotId, callIndex, callType, event);
2077 TELEPHONY_LOGI("TelRilTest::CallSplitTest --> finished");
2078 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2079 ASSERT_TRUE(syncResult);
2080 }
2081 }
2082
2083 /**
2084 * @brief Get call forwarding
2085 *
2086 * @param handler
2087 */
GetCallForwardTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2088 void TelRilTest::GetCallForwardTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2089 {
2090 int32_t reason = 0;
2091 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CALL_FORWARD);
2092 auto event = AppExecFwk::InnerEvent::Get(eventId);
2093 if (event != nullptr && telRilManager_ != nullptr) {
2094 event->SetOwner(handler);
2095 TELEPHONY_LOGI("TelRilTest::GetCallForwardTest -->");
2096 telRilManager_->GetCallTransferInfo(slotId, reason, event);
2097 TELEPHONY_LOGI("TelRilTest::GetCallForwardTest --> finished");
2098 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2099 ASSERT_TRUE(syncResult);
2100 }
2101 }
2102
2103 /**
2104 * @brief Set call forwarding
2105 *
2106 * @param handler
2107 */
SetCallForwardTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2108 void TelRilTest::SetCallForwardTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2109 {
2110 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SPLIT_CALL);
2111 auto event = AppExecFwk::InnerEvent::Get(eventId);
2112 if (event != nullptr && telRilManager_ != nullptr) {
2113 event->SetOwner(handler);
2114 CallTransferParam callTransfer;
2115 callTransfer.mode = 0;
2116 callTransfer.reason = 0;
2117 callTransfer.classx = 0;
2118 callTransfer.number = GTEST_STRING;
2119 TELEPHONY_LOGI("TelRilTest::SetCallForwardTest -->");
2120 telRilManager_->SetCallTransferInfo(slotId, callTransfer, event);
2121 TELEPHONY_LOGI("TelRilTest::SetCallForwardTest --> finished");
2122 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2123 ASSERT_TRUE(syncResult);
2124 }
2125 }
2126
2127 /**
2128 * @brief Get Calling line Identification Presentation Supplementary Service
2129 *
2130 * @param handler
2131 */
GetClipTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2132 void TelRilTest::GetClipTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2133 {
2134 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CALL_CLIP);
2135 auto event = AppExecFwk::InnerEvent::Get(eventId);
2136 if (event != nullptr && telRilManager_ != nullptr) {
2137 event->SetOwner(handler);
2138 TELEPHONY_LOGI("TelRilTest::GetClipTest -->");
2139 telRilManager_->GetClip(slotId, event);
2140 TELEPHONY_LOGI("TelRilTest::GetClipTest --> finished");
2141 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2142 ASSERT_TRUE(syncResult);
2143 }
2144 }
2145
2146 /**
2147 * @brief Set Calling line Identification Presentation Supplementary Service
2148 *
2149 * @param handler
2150 */
SetClipTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2151 void TelRilTest::SetClipTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2152 {
2153 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CALL_CLIP);
2154 auto event = AppExecFwk::InnerEvent::Get(eventId);
2155 if (event != nullptr && telRilManager_ != nullptr) {
2156 int32_t action = 0;
2157 event->SetOwner(handler);
2158 TELEPHONY_LOGI("TelRilTest::SetClipTest -->");
2159 telRilManager_->SetClip(slotId, action, event);
2160 TELEPHONY_LOGI("TelRilTest::SetClipTest --> finished");
2161 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2162 ASSERT_TRUE(syncResult);
2163 }
2164 }
2165
2166 /**
2167 * @brief Get call barring
2168 *
2169 * @param handler
2170 */
GetCallRestrictionTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2171 void TelRilTest::GetCallRestrictionTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2172 {
2173 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CALL_RESTRICTION);
2174 auto event = AppExecFwk::InnerEvent::Get(eventId);
2175 if (event != nullptr && telRilManager_ != nullptr) {
2176 event->SetOwner(handler);
2177 TELEPHONY_LOGI("TelRilTest::GetCallRestrictionTest -->");
2178 telRilManager_->GetCallRestriction(slotId, "AI", event);
2179 TELEPHONY_LOGI("TelRilTest::GetCallRestrictionTest --> finished");
2180 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2181 ASSERT_TRUE(syncResult);
2182 }
2183 }
2184
2185 /**
2186 * @brief Set call barring
2187 *
2188 * @param handler
2189 */
SetCallRestrictionTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2190 void TelRilTest::SetCallRestrictionTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2191 {
2192 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CALL_RESTRICTION);
2193 auto event = AppExecFwk::InnerEvent::Get(eventId);
2194 if (event != nullptr && telRilManager_ != nullptr) {
2195 event->SetOwner(handler);
2196 CallRestrictionParam callRestriction;
2197 callRestriction.mode = 0;
2198 callRestriction.fac = GTEST_STRING;
2199 if (strcpy_s(callRestriction.password, strlen(GTEST_STRING.c_str()) + 1, GTEST_STRING.c_str()) != EOK) {
2200 TELEPHONY_LOGE("TelRilTest::SetCallRestrictionTest stop by strcpy_s fail.");
2201 return;
2202 }
2203 TELEPHONY_LOGI("TelRilTest::SetCallRestrictionTest -->");
2204 telRilManager_->SetCallRestriction(slotId, callRestriction, event);
2205 TELEPHONY_LOGI("TelRilTest::SetCallRestrictionTest --> finished");
2206 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2207 ASSERT_TRUE(syncResult);
2208 }
2209 }
2210
2211 /**
2212 * @brief Set call barring password
2213 *
2214 * @param handler
2215 */
SetBarringPasswordTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2216 void TelRilTest::SetBarringPasswordTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2217 {
2218 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CALL_RESTRICTION_PWD);
2219 auto event = AppExecFwk::InnerEvent::Get(eventId, slotId);
2220 if (event != nullptr && telRilManager_ != nullptr) {
2221 event->SetOwner(handler);
2222 std::string fac = GTEST_STRING;
2223 char oldPassword[MAX_BUF_SIZE + 1] = "oldPWD";
2224 char newPassword[MAX_BUF_SIZE + 1] = "newPWD";
2225 TELEPHONY_LOGI("TelRilTest::SetBarringPasswordTest -->");
2226 telRilManager_->SetBarringPassword(slotId, newPassword, oldPassword, fac, event);
2227 TELEPHONY_LOGI("TelRilTest::SetBarringPasswordTest --> finished");
2228 (void)memset_s(oldPassword, sizeof(oldPassword), 0, sizeof(oldPassword));
2229 (void)memset_s(newPassword, sizeof(newPassword), 0, sizeof(newPassword));
2230 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2231 ASSERT_TRUE(syncResult);
2232 }
2233 }
2234
2235 /**
2236 * @brief Send DTMF
2237 *
2238 * @param handler
2239 */
SendDtmfTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2240 void TelRilTest::SendDtmfTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2241 {
2242 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SEND_DTMF);
2243 auto event = AppExecFwk::InnerEvent::Get(eventId);
2244 if (event != nullptr && telRilManager_ != nullptr) {
2245 event->SetOwner(handler);
2246 TELEPHONY_LOGI("TelRilTest::SendDtmfTest -->");
2247 TELEPHONY_LOGI("TelRilTest::SendDtmfTest --> finished");
2248 }
2249 }
2250
2251 /**
2252 * @brief Start DTMF
2253 *
2254 * @param handler
2255 */
StartDtmfTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2256 void TelRilTest::StartDtmfTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2257 {
2258 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_START_DTMF);
2259 auto event = AppExecFwk::InnerEvent::Get(eventId);
2260 if (event != nullptr && telRilManager_ != nullptr) {
2261 event->SetOwner(handler);
2262 TELEPHONY_LOGI("TelRilTest::StartDtmfTest -->");
2263 TELEPHONY_LOGI("TelRilTest::StartDtmfTest --> finished");
2264 }
2265 }
2266
2267 /**
2268 * @brief Stop DTMF
2269 *
2270 * @param handler
2271 */
StopDtmfTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2272 void TelRilTest::StopDtmfTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2273 {
2274 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_STOP_DTMF);
2275 auto event = AppExecFwk::InnerEvent::Get(eventId);
2276 if (event != nullptr && telRilManager_ != nullptr) {
2277 event->SetOwner(handler);
2278 TELEPHONY_LOGI("TelRilTest::StopDtmfTest -->");
2279 TELEPHONY_LOGI("TelRilTest::StopDtmfTest --> finished");
2280 }
2281 }
2282
2283 /**
2284 * @brief Set USSD
2285 *
2286 * @param handler
2287 */
SetUssdTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2288 void TelRilTest::SetUssdTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2289 {
2290 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_USSD);
2291 auto event = AppExecFwk::InnerEvent::Get(eventId);
2292 if (event != nullptr && telRilManager_ != nullptr) {
2293 event->SetOwner(handler);
2294 TELEPHONY_LOGI("TelRilTest::SetUssdTest -->");
2295 telRilManager_->SetUssd(slotId, "12345678", event);
2296 TELEPHONY_LOGI("TelRilTest::SetUssdTest --> finished");
2297 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2298 ASSERT_TRUE(syncResult);
2299 }
2300 }
2301
2302 /**
2303 * @brief Get USSD
2304 *
2305 * @param handler
2306 */
GetUssdTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2307 void TelRilTest::GetUssdTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2308 {
2309 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_USSD);
2310 auto event = AppExecFwk::InnerEvent::Get(eventId);
2311 if (event != nullptr && telRilManager_ != nullptr) {
2312 event->SetOwner(handler);
2313 TELEPHONY_LOGI("TelRilTest::GetUssdTest -->");
2314 telRilManager_->GetUssd(slotId, event);
2315 TELEPHONY_LOGI("TelRilTest::GetUssdTest --> finished");
2316 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2317 ASSERT_TRUE(syncResult);
2318 }
2319 }
2320
2321 /**
2322 * @brief Set call mute
2323 *
2324 * @param handler
2325 */
SetMuteTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2326 void TelRilTest::SetMuteTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2327 {
2328 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_CMUT);
2329 auto event = AppExecFwk::InnerEvent::Get(eventId);
2330 if (event != nullptr && telRilManager_ != nullptr) {
2331 event->SetOwner(handler);
2332 TELEPHONY_LOGI("TelRilTest::SetMuteTest -->");
2333 telRilManager_->SetMute(slotId, 1, event);
2334 TELEPHONY_LOGI("TelRilTest::SetMuteTest --> finished");
2335 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2336 ASSERT_TRUE(syncResult);
2337 }
2338 }
2339
2340 /**
2341 * @brief Get call mute
2342 *
2343 * @param handler
2344 */
GetMuteTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2345 void TelRilTest::GetMuteTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2346 {
2347 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_CMUT);
2348 auto event = AppExecFwk::InnerEvent::Get(eventId);
2349 if (event != nullptr && telRilManager_ != nullptr) {
2350 event->SetOwner(handler);
2351 TELEPHONY_LOGI("TelRilTest::GetMuteTest -->");
2352 telRilManager_->GetMute(slotId, event);
2353 TELEPHONY_LOGI("TelRilTest::GetMuteTest --> finished");
2354 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2355 ASSERT_TRUE(syncResult);
2356 }
2357 }
2358
2359 /**
2360 * @brief Get emergency call list
2361 *
2362 * @param handler
2363 */
GetEmergencyCallListTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2364 void TelRilTest::GetEmergencyCallListTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2365 {
2366 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_GET_EMERGENCY_CALL_LIST);
2367 auto event = AppExecFwk::InnerEvent::Get(eventId);
2368 if (event != nullptr && telRilManager_ != nullptr) {
2369 event->SetOwner(handler);
2370 TELEPHONY_LOGI("TelRilTest::GetEmergencyCallListTest -->");
2371 telRilManager_->GetEmergencyCallList(slotId, event);
2372 TELEPHONY_LOGI("TelRilTest::GetEmergencyCallListTest --> finished");
2373 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND_LONG);
2374 ASSERT_TRUE(syncResult);
2375 }
2376 }
2377
2378 /**
2379 * @brief Set VoNR Switch
2380 *
2381 * @param handler
2382 */
SetVoNRSwitchTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2383 void TelRilTest::SetVoNRSwitchTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2384 {
2385 int32_t eventId = static_cast<int32_t>(RadioEvent::RADIO_SET_VONR_SWITCH_STATUS);
2386 auto event = AppExecFwk::InnerEvent::Get(eventId);
2387 if (event != nullptr && telRilManager_ != nullptr) {
2388 event->SetOwner(handler);
2389 TELEPHONY_LOGI("TelRilTest::SetVoNRSwitchTest -->");
2390 telRilManager_->SetVoNRSwitch(slotId, 1, event);
2391 TELEPHONY_LOGI("TelRilTest::SetVoNRSwitchTest --> finished");
2392 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2393 ASSERT_TRUE(syncResult);
2394 }
2395 }
2396
2397 /**
2398 * @brief Setting link bandwidth reporting rules
2399 *
2400 * @param handler
2401 */
OnRequestSetLinkBandwidthReportingRuleTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2402 void TelRilTest::OnRequestSetLinkBandwidthReportingRuleTest(int32_t slotId,
2403 std::shared_ptr<AppExecFwk::EventHandler> handler)
2404 {
2405 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_SET_LINK_BANDWIDTH_REPORTING_RULE);
2406 auto event = AppExecFwk::InnerEvent::Get(eventId);
2407 if (event != nullptr && telRilManager_ != nullptr) {
2408 event->SetOwner(handler);
2409 TELEPHONY_LOGI("TelRilTest::OnRequestSetLinkBandwidthReportingRuleTest -->");
2410 LinkBandwidthRule rule;
2411 rule.delayMs = BANDWIDTH_HYSTERESIS_MS;
2412 rule.rat = NETWORK_TYPE_LTE;
2413 rule.delayUplinkKbps = BANDWIDTH_HYSTERESIS_KBPS;
2414 rule.delayDownlinkKbps = BANDWIDTH_HYSTERESIS_KBPS;
2415 for (uint32_t i = 0; i < sizeof(MAX_UPLINK_LINK_BANDWIDTH) / sizeof(int); i++) {
2416 rule.maximumUplinkKbps.push_back(MAX_UPLINK_LINK_BANDWIDTH[i]);
2417 }
2418 for (uint32_t i = 0; i < sizeof(MAX_DOWNLINK_LINK_BANDWIDTH) / sizeof(int); i++) {
2419 rule.maximumDownlinkKbps.push_back(MAX_DOWNLINK_LINK_BANDWIDTH[i]);
2420 }
2421 telRilManager_->SetLinkBandwidthReportingRule(slotId, rule, event);
2422 TELEPHONY_LOGI("TelRilTest::OnRequestSetLinkBandwidthReportingRuleTest --> finished");
2423 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2424 ASSERT_TRUE(syncResult);
2425 }
2426 }
2427
2428 /**
2429 * @brief Get link bandwidth information
2430 *
2431 * @param handler
2432 */
GetLinkBandwidthInfoTest(int32_t slotId,std::shared_ptr<AppExecFwk::EventHandler> handler)2433 void TelRilTest::GetLinkBandwidthInfoTest(int32_t slotId, std::shared_ptr<AppExecFwk::EventHandler> handler)
2434 {
2435 int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_RILCM_GET_LINK_BANDWIDTH_INFO);
2436 auto event = AppExecFwk::InnerEvent::Get(eventId);
2437 if (event != nullptr && telRilManager_ != nullptr) {
2438 event->SetOwner(handler);
2439 int32_t cid = CID;
2440 TELEPHONY_LOGI("TelRilTest::GetLinkBandwidthInfoTest -->");
2441 telRilManager_->GetLinkBandwidthInfo(slotId, cid, event);
2442 TELEPHONY_LOGI("TelRilTest::GetLinkBandwidthInfoTest --> finished");
2443 bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
2444 ASSERT_TRUE(syncResult);
2445 }
2446 }
2447
2448 /**
2449 * @brief Waiting the result
2450 * @param eventId
2451 * @param handler
2452 * @param timeOut
2453 */
WaitGetResult(int32_t eventId,std::shared_ptr<AppExecFwk::EventHandler> handler,int32_t timeOut)2454 bool TelRilTest::WaitGetResult(int32_t eventId, std::shared_ptr<AppExecFwk::EventHandler> handler, int32_t timeOut)
2455 {
2456 TelRilTest::DemoHandler *demoHandler = static_cast<TelRilTest::DemoHandler *>(handler.get());
2457 if (demoHandler == nullptr) {
2458 return false;
2459 }
2460 demoHandler->WaitFor(timeOut);
2461 bool syncResult = demoHandler->GetBoolResult(eventId);
2462 return syncResult;
2463 }
2464
NotifyAll()2465 void TelRilTest::DemoHandler::NotifyAll()
2466 {
2467 std::unique_lock<std::mutex> callbackLock(callbackMutex_);
2468 cv_.notify_all();
2469 }
2470
WaitFor(int32_t timeoutSecond)2471 void TelRilTest::DemoHandler::WaitFor(int32_t timeoutSecond)
2472 {
2473 std::unique_lock<std::mutex> callbackLock(callbackMutex_);
2474 cv_.wait_for(callbackLock, std::chrono::seconds(timeoutSecond));
2475 }
2476
Clean()2477 void TelRilTest::DemoHandler::Clean()
2478 {
2479 eventId_ = 0;
2480 resultInfo_ = nullptr;
2481 }
2482
GetBoolResult(int32_t eventId)2483 bool TelRilTest::DemoHandler::GetBoolResult(int32_t eventId)
2484 {
2485 bool ret = false;
2486 if (eventId_ == 0) {
2487 TELEPHONY_LOGI(
2488 "Ril interface response timeout, not implemented."
2489 "eventId: %{public}d, current eventId: %{public}d",
2490 eventId, eventId_);
2491 ret = true;
2492 Clean();
2493 return ret;
2494 }
2495 if (eventId_ != eventId) {
2496 ret = false;
2497 TELEPHONY_LOGI("GetBoolResult eventId does not match. eventId: %{public}d, current eventId: %{public}d",
2498 eventId, eventId_);
2499 Clean();
2500 return ret;
2501 }
2502 if ((resultInfo_ != nullptr) &&
2503 ((resultInfo_->error == ErrType::NONE) || (resultInfo_->error == ErrType::ERR_GENERIC_FAILURE) ||
2504 (resultInfo_->error == ErrType::ERR_INVALID_RESPONSE) ||
2505 (resultInfo_->error == ErrType::ERR_INVALID_MODEM_PARAMETER))) {
2506 ret = true;
2507 }
2508 if (resultInfo_ == nullptr) {
2509 ret = true;
2510 TELEPHONY_LOGI("GetBoolResult eventId: %{public}d", eventId_);
2511 } else {
2512 TELEPHONY_LOGI("GetBoolResult eventId: %{public}d, error: %{public}d", eventId_, (int32_t)(resultInfo_->error));
2513 }
2514 Clean();
2515 return ret;
2516 }
2517
ProcessResponseInfo(const AppExecFwk::InnerEvent::Pointer & event)2518 void TelRilTest::DemoHandler::ProcessResponseInfo(const AppExecFwk::InnerEvent::Pointer &event)
2519 {
2520 if (event != nullptr) {
2521 eventId_ = event->GetInnerEventId();
2522 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> eventId:%{public}d", eventId_);
2523 // for some SIM interfaces, response data need to be get before RadioResponseInfo
2524 switch (eventId_) {
2525 case static_cast<int32_t>(RadioEvent::RADIO_SIM_GET_IMSI): {
2526 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> RADIO_SIM_GET_IMSI");
2527 std::shared_ptr<std::string> imsi = event->GetSharedObject<std::string>();
2528 if (imsi != nullptr) {
2529 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> imsi=%{public}s", imsi->c_str());
2530 } else {
2531 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> get resultInfo_");
2532 resultInfo_ = event->GetSharedObject<RadioResponseInfo>();
2533 }
2534 break;
2535 }
2536 case static_cast<int32_t>(RadioEvent::RADIO_GET_SMS_CENTER_ADDRESS): {
2537 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> RADIO_GET_SMS_CENTER_ADDRESS");
2538 std::shared_ptr<ServiceCenterAddress> addr = event->GetSharedObject<ServiceCenterAddress>();
2539 if (addr != nullptr) {
2540 g_smscAddr = addr->address;
2541 g_tosca = addr->tosca;
2542 TELEPHONY_LOGI(
2543 "TelRilTest::DemoHandler::ProcessResponseInfo --> g_smscAddr=%{public}s,"
2544 "g_tosca=%{public}d",
2545 g_smscAddr.c_str(), g_tosca);
2546 } else {
2547 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> get resultInfo_");
2548 resultInfo_ = event->GetSharedObject<RadioResponseInfo>();
2549 }
2550 break;
2551 }
2552 default: {
2553 TELEPHONY_LOGI("TelRilTest::DemoHandler::ProcessResponseInfo --> case default");
2554 resultInfo_ = event->GetSharedObject<RadioResponseInfo>();
2555 }
2556 }
2557 }
2558 NotifyAll();
2559 }
2560
2561 /**
2562 * @brief Process event
2563 *
2564 * @param event
2565 */
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)2566 void TelRilTest::DemoHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
2567 {
2568 ProcessResponseInfo(event);
2569 }
2570
GetRandNum()2571 uint32_t TelRilTest::GetRandNum()
2572 {
2573 int32_t r = 0;
2574 int fd = open("/dev/random", O_RDONLY);
2575 if (fd > 0) {
2576 read(fd, &r, sizeof(int32_t));
2577 }
2578 close(fd);
2579 return r;
2580 }
2581
2582 /**
2583 * @brief Get random phone number
2584 *
2585 * @param length
2586 */
GetRandPhoneNum(const int len)2587 std::string TelRilTest::GetRandPhoneNum(const int len)
2588 {
2589 char c;
2590 int32_t idx;
2591 uint32_t rtv = 0;
2592 std::string str;
2593
2594 for (idx = 0; idx < len; idx++) {
2595 rtv = GetRandNum() % DECIMAL;
2596 c = static_cast<char>(rtv + '0');
2597 str.push_back(c);
2598 }
2599
2600 return str;
2601 }
2602
GetHandler(void)2603 std::shared_ptr<TelRilTest::DemoHandler> TelRilTest::GetHandler(void)
2604 {
2605 std::shared_ptr<AppExecFwk::EventRunner> eventRunner;
2606 std::shared_ptr<TelRilTest::DemoHandler> demohandler;
2607 if (telRilManager_ == nullptr) {
2608 TELEPHONY_LOGE("ERROR : make_shared<ITelRilManager>(telRilManager) --> nullptr !!!");
2609 return NULL;
2610 }
2611 eventRunner = AppExecFwk::EventRunner::Create("DemoHandler");
2612 if (eventRunner == nullptr) {
2613 TELEPHONY_LOGE("ERROR : AppExecFwk::EventRunner::Create(\"DemoHandler\") --> nullptr !!!");
2614 return NULL;
2615 }
2616 demohandler = std::make_shared<TelRilTest::DemoHandler>(eventRunner);
2617 if (demohandler == nullptr) {
2618 TELEPHONY_LOGE("ERROR : make_shared<TelRilTest::DemoHandler>(runner) --> nullptr !!!");
2619 return NULL;
2620 }
2621 eventRunner->Run();
2622
2623 return demohandler;
2624 }
2625 } // namespace Telephony
2626 } // namespace OHOS
2627