|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include "TE_EtelIsvbase.h" |
|
21 |
|
22 _LIT(KEtelISVBufferConfigStr, "BufferMode"); |
|
23 |
|
24 CEtelIsvTestStep::CEtelIsvTestStep() |
|
25 {} |
|
26 |
|
27 CEtelIsvTestStep::~CEtelIsvTestStep() |
|
28 {} |
|
29 |
|
30 TVerdict CEtelIsvTestStep::doTestStepPreambleL() |
|
31 { |
|
32 __UHEAP_MARK; //mark for memory leaks!! |
|
33 |
|
34 iScheduler = new(ELeave) CActiveScheduler; |
|
35 CActiveScheduler::Install(iScheduler); |
|
36 |
|
37 // |
|
38 // Ensure the SIMTSY test number is zero'd before we start... |
|
39 // |
|
40 User::LeaveIfError(iTestNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
41 User::LeaveIfError(iTestNumberProperty.Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 0)); |
|
42 |
|
43 iTelephony = CTelephony::NewL(); |
|
44 |
|
45 // |
|
46 // Read the optional configuration info |
|
47 // |
|
48 if ( !GetBoolFromConfig(ConfigSection(),KEtelISVBufferConfigStr,iBufferMode) ) |
|
49 { |
|
50 // default test mode |
|
51 iBufferMode = EFalse; |
|
52 } |
|
53 |
|
54 if (iBufferMode) |
|
55 { |
|
56 INFO_PRINTF1(_L("Testing in \"buffer\" mode") ); |
|
57 } |
|
58 else |
|
59 { |
|
60 INFO_PRINTF1(_L("Testing in \"NON buffer\" mode") ); |
|
61 } |
|
62 |
|
63 return TestStepResult(); |
|
64 } |
|
65 |
|
66 TVerdict CEtelIsvTestStep::doTestStepPostambleL() |
|
67 { |
|
68 delete iTelephony; |
|
69 iTelephony = NULL; |
|
70 iTestNumberProperty.Close(); |
|
71 |
|
72 if (iMyAsyncOneShot) |
|
73 { |
|
74 delete iMyAsyncOneShot; |
|
75 iMyAsyncOneShot = NULL; |
|
76 } |
|
77 delete iScheduler; |
|
78 |
|
79 __UHEAP_MARKEND; |
|
80 |
|
81 return TestStepResult(); |
|
82 } |
|
83 |
|
84 void CEtelIsvTestStep::PrintIndicatorValues(TInt aIndicator, TInt aIndicatorCaps) |
|
85 { |
|
86 if(aIndicatorCaps&CTelephony::KIndChargerConnected) |
|
87 { |
|
88 if(aIndicator&CTelephony::KIndChargerConnected) |
|
89 { |
|
90 INFO_PRINTF1(_L("Battery charger connected")); |
|
91 } |
|
92 else |
|
93 { |
|
94 INFO_PRINTF1(_L("Battery charger not connected")); |
|
95 } |
|
96 } |
|
97 else |
|
98 { |
|
99 INFO_PRINTF1(_L("Battery charger indiction reporting unavailable")); |
|
100 } |
|
101 |
|
102 if(aIndicatorCaps&CTelephony::KIndNetworkAvailable) |
|
103 { |
|
104 if(aIndicator&CTelephony::KIndNetworkAvailable) |
|
105 { |
|
106 INFO_PRINTF1(_L("Network service available")); |
|
107 } |
|
108 else |
|
109 { |
|
110 INFO_PRINTF1(_L("Network service not available")); |
|
111 } |
|
112 } |
|
113 else |
|
114 { |
|
115 INFO_PRINTF1(_L("Network service indiction reporting unavailable")); |
|
116 } |
|
117 |
|
118 if(aIndicatorCaps&CTelephony::KIndCallInProgress) |
|
119 { |
|
120 if(aIndicator&CTelephony::KIndCallInProgress) |
|
121 { |
|
122 INFO_PRINTF1(_L("Call In progress")); |
|
123 } |
|
124 else |
|
125 { |
|
126 INFO_PRINTF1(_L("Call Not In progress")); |
|
127 } |
|
128 } |
|
129 else |
|
130 { |
|
131 INFO_PRINTF1(_L("Call In progress indiction reporting unavailable")); |
|
132 } |
|
133 } |
|
134 |
|
135 void CEtelIsvTestStep::PrintBatteryInfo(CTelephony::TBatteryInfoV1& aBatteryInfo) |
|
136 { |
|
137 TBuf<200> BatteryStatus; |
|
138 |
|
139 switch (aBatteryInfo.iStatus) |
|
140 { |
|
141 case CTelephony::EPowerStatusUnknown: |
|
142 BatteryStatus = _L("EPowerStatusUnknown"); |
|
143 break; |
|
144 case CTelephony::EPoweredByBattery: |
|
145 BatteryStatus = _L("EPoweredByBattery"); |
|
146 break; |
|
147 case CTelephony::EBatteryConnectedButExternallyPowered: |
|
148 BatteryStatus = _L("EBatteryConnectedButExternallyPowered"); |
|
149 break; |
|
150 case CTelephony::ENoBatteryConnected: |
|
151 BatteryStatus = _L("ENoBatteryConnected"); |
|
152 break; |
|
153 case CTelephony::EPowerFault: |
|
154 BatteryStatus = _L("EPowerFault"); |
|
155 break; |
|
156 default: |
|
157 BatteryStatus = _L("UNKNOWN"); |
|
158 break; |
|
159 } |
|
160 INFO_PRINTF2(_L("Battery status : %S"), &BatteryStatus); |
|
161 INFO_PRINTF2(_L("Battery level : %d"), aBatteryInfo.iChargeLevel); |
|
162 } |
|
163 |
|
164 void CEtelIsvTestStep::PrintLockInfo(CTelephony::TIccLock aLock, TInt aLockStatus, TInt aLockSetting) |
|
165 { |
|
166 TBuf<200> LockStatus; |
|
167 TBuf<200> LockSetting; |
|
168 TBuf<10> lock; |
|
169 |
|
170 if(aLock==CTelephony::ELockPin1) |
|
171 { |
|
172 lock = _L("Lock1"); |
|
173 } |
|
174 else |
|
175 { |
|
176 lock = _L("Lock2"); |
|
177 } |
|
178 |
|
179 switch (aLockStatus) |
|
180 { |
|
181 case CTelephony::EStatusLockUnknown: |
|
182 LockStatus = _L("EStatusLockUnknown"); |
|
183 break; |
|
184 case CTelephony::EStatusLocked: |
|
185 LockStatus = _L("EStatusLocked"); |
|
186 break; |
|
187 case CTelephony::EStatusUnlocked: |
|
188 LockStatus = _L("EStatusUnlocked"); |
|
189 break; |
|
190 case CTelephony::EStatusBlocked: |
|
191 LockStatus = _L("EStatusBlocked"); |
|
192 break; |
|
193 default: |
|
194 break; |
|
195 } |
|
196 |
|
197 switch (aLockSetting) |
|
198 { |
|
199 case CTelephony::ELockSetUnknown: |
|
200 LockSetting = _L("ELockSetUnknown"); |
|
201 break; |
|
202 case CTelephony::EStatusLocked: |
|
203 LockSetting = _L("ELockSetEnabled"); |
|
204 break; |
|
205 case CTelephony::EStatusUnlocked: |
|
206 LockSetting = _L("ELockSetDisabled"); |
|
207 break; |
|
208 default: |
|
209 break; |
|
210 } |
|
211 |
|
212 INFO_PRINTF3(_L("%S - Lock status : %S"), &lock, &LockStatus); |
|
213 INFO_PRINTF3(_L("%S - Lock setting : %S"), &lock, &LockSetting); |
|
214 } |
|
215 |
|
216 void CEtelIsvTestStep::PrintNetworkRegStatus(TInt aNetworkRegStatus) |
|
217 { |
|
218 TBuf<200> NetworkRegStatus; |
|
219 |
|
220 switch (aNetworkRegStatus) |
|
221 { |
|
222 case CTelephony::ERegistrationUnknown: |
|
223 NetworkRegStatus = _L("ERegistrationUnknown"); |
|
224 break; |
|
225 case CTelephony::ENotRegisteredNoService: |
|
226 NetworkRegStatus = _L("ENotRegisteredNoService"); |
|
227 break; |
|
228 case CTelephony::ENotRegisteredEmergencyOnly: |
|
229 NetworkRegStatus = _L("ENotRegisteredEmergencyOnly"); |
|
230 break; |
|
231 case CTelephony::ENotRegisteredSearching: |
|
232 NetworkRegStatus = _L("ENotRegisteredSearching"); |
|
233 break; |
|
234 case CTelephony::ERegisteredBusy: |
|
235 NetworkRegStatus = _L("ERegisteredBusy"); |
|
236 break; |
|
237 case CTelephony::ERegisteredOnHomeNetwork: |
|
238 NetworkRegStatus = _L("ERegisteredOnHomeNetwork"); |
|
239 break; |
|
240 case CTelephony::ERegistrationDenied: |
|
241 NetworkRegStatus = _L("ERegistrationDenied"); |
|
242 break; |
|
243 case CTelephony::ERegisteredRoaming: |
|
244 NetworkRegStatus = _L("ERegisteredRoaming"); |
|
245 break; |
|
246 default: |
|
247 break; |
|
248 } |
|
249 INFO_PRINTF2(_L("Network registration status : %S"), &NetworkRegStatus); |
|
250 |
|
251 } |
|
252 |
|
253 void CEtelIsvTestStep::PrintNetworkInfo(TInt aNetworkMode, TInt aNetworkAccess, TInt aNetworkStatus, TInt aNetworkBandInfo) |
|
254 { |
|
255 TBuf<200> NetworkMode; |
|
256 TBuf<200> NetworkAccess; |
|
257 TBuf<200> NetworkStatus; |
|
258 TBuf<200> NetworkBandInfo; |
|
259 |
|
260 switch (aNetworkMode) |
|
261 { |
|
262 case CTelephony::ENetworkModeUnknown: |
|
263 NetworkMode = _L("ENetworkModeUnknown"); |
|
264 break; |
|
265 case CTelephony::ENetworkModeUnregistered: |
|
266 NetworkMode = _L("ENetworkModeUnregistered"); |
|
267 break; |
|
268 case CTelephony::ENetworkModeGsm: |
|
269 NetworkMode = _L("ENetworkModeGsm"); |
|
270 break; |
|
271 case CTelephony::ENetworkModeAmps: |
|
272 NetworkMode = _L("ENetworkModeAmps"); |
|
273 break; |
|
274 case CTelephony::ENetworkModeCdma95: |
|
275 NetworkMode = _L("ENetworkModeCdma95"); |
|
276 break; |
|
277 case CTelephony::ENetworkModeCdma2000: |
|
278 NetworkMode = _L("ENetworkModeCdma2000"); |
|
279 break; |
|
280 case CTelephony::ENetworkModeWcdma: |
|
281 NetworkMode = _L("ENetworkModeWcdma"); |
|
282 break; |
|
283 case CTelephony::ENetworkModeTdcdma: |
|
284 NetworkMode = _L("ENetworkModeTdcdma"); |
|
285 break; |
|
286 default: |
|
287 break; |
|
288 } |
|
289 |
|
290 switch (aNetworkAccess) |
|
291 { |
|
292 case CTelephony::ENetworkAccessUnknown: |
|
293 NetworkAccess = _L("ENetworkAccessUnknown"); |
|
294 break; |
|
295 case CTelephony::ENetworkAccessGsm: |
|
296 NetworkAccess = _L("ENetworkAccessGsm"); |
|
297 break; |
|
298 case CTelephony::ENetworkAccessGsmCompact: |
|
299 NetworkAccess = _L("ENetworkAccessGsmCompact"); |
|
300 break; |
|
301 case CTelephony::ENetworkAccessUtran: |
|
302 NetworkAccess = _L("ENetworkAccessUtran"); |
|
303 break; |
|
304 default: |
|
305 break; |
|
306 } |
|
307 |
|
308 switch (aNetworkStatus) |
|
309 { |
|
310 case CTelephony::ENetworkStatusUnknown: |
|
311 NetworkStatus = _L("ENetworkStatusUnknown"); |
|
312 break; |
|
313 case CTelephony::ENetworkStatusAvailable: |
|
314 NetworkStatus = _L("ENetworkStatusAvailable"); |
|
315 break; |
|
316 case CTelephony::ENetworkStatusCurrent: |
|
317 NetworkStatus = _L("ENetworkStatusCurrent"); |
|
318 break; |
|
319 case CTelephony::ENetworkStatusForbidden: |
|
320 NetworkStatus = _L("ENetworkStatusForbidden"); |
|
321 break; |
|
322 default: |
|
323 break; |
|
324 } |
|
325 |
|
326 switch (aNetworkBandInfo) |
|
327 { |
|
328 case CTelephony::EBandUnknown: |
|
329 NetworkBandInfo = _L("EBandUnknown"); |
|
330 break; |
|
331 case CTelephony::E800BandA: |
|
332 NetworkBandInfo = _L("E800BandA"); |
|
333 break; |
|
334 case CTelephony::E800BandB: |
|
335 NetworkBandInfo = _L("E800BandB"); |
|
336 break; |
|
337 case CTelephony::E800BandC: |
|
338 NetworkBandInfo = _L("E800BandC"); |
|
339 break; |
|
340 case CTelephony::E1900BandA: |
|
341 NetworkBandInfo = _L("E1900BandA"); |
|
342 break; |
|
343 case CTelephony::E1900BandB: |
|
344 NetworkBandInfo = _L("E1900BandB"); |
|
345 break; |
|
346 case CTelephony::E1900BandC: |
|
347 NetworkBandInfo = _L("E1900BandC"); |
|
348 break; |
|
349 case CTelephony::E1900BandD: |
|
350 NetworkBandInfo = _L("E1900BandD"); |
|
351 break; |
|
352 case CTelephony::E1900BandE: |
|
353 NetworkBandInfo = _L("E1900BandE"); |
|
354 break; |
|
355 case CTelephony::E1900BandF: |
|
356 NetworkBandInfo = _L("E1900BandF"); |
|
357 break; |
|
358 default: |
|
359 break; |
|
360 } |
|
361 |
|
362 INFO_PRINTF2(_L("Network mode : %S"), &NetworkMode); |
|
363 INFO_PRINTF2(_L("Network access : %S"), &NetworkAccess); |
|
364 INFO_PRINTF2(_L("Network status : %S"), &NetworkStatus); |
|
365 INFO_PRINTF2(_L("Network band info : %S"), &NetworkBandInfo); |
|
366 } |
|
367 |
|
368 void CEtelIsvTestStep::SetTestNumber(TInt aTestNumber) |
|
369 { |
|
370 delete iTelephony; |
|
371 iTelephony=NULL; |
|
372 |
|
373 INFO_PRINTF1(_L("")); |
|
374 INFO_PRINTF2(_L("Changing the Test Number to %d"),aTestNumber); |
|
375 |
|
376 TRequestStatus status; |
|
377 iTestNumberProperty.Subscribe(status); |
|
378 TEST1(iTestNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,aTestNumber) == KErrNone, ETrue); |
|
379 User::WaitForRequest(status); |
|
380 TEST1(status.Int() == KErrNone, ETrue); |
|
381 TInt testNumberCheck; |
|
382 TEST1(iTestNumberProperty.Get(testNumberCheck) == KErrNone, ETrue); |
|
383 TEST1(aTestNumber == testNumberCheck, ETrue); |
|
384 |
|
385 TRAPD(ret, iTelephony = CTelephony::NewL()); |
|
386 TEST1(ret==KErrNone, ETrue); |
|
387 |
|
388 if (ret != KErrNone) |
|
389 { |
|
390 iTelephony=NULL; |
|
391 } |
|
392 } |
|
393 |
|
394 /** |
|
395 Uses a mechanism to tell sim.tsy that the timers it holds should have |
|
396 their countdown reduced. The timers are set up in sim.tsy as a |
|
397 consequence of the delays specified in the c:\config.txt. |
|
398 */ |
|
399 void CEtelIsvTestStep::SignalSimTsyToReduceTimersL() |
|
400 { |
|
401 RProperty reduceTimersProperty; |
|
402 User::LeaveIfError(reduceTimersProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime)); |
|
403 CleanupClosePushL(reduceTimersProperty); |
|
404 |
|
405 User::LeaveIfError(reduceTimersProperty.Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, |
|
406 KReduceSimTsyTimers)); |
|
407 |
|
408 CleanupStack::PopAndDestroy(&reduceTimersProperty); |
|
409 } |
|
410 |
|
411 CTestCanceller::CTestCanceller(CActive* aRetrieve) |
|
412 : CAsyncOneShot(EPriorityNormal),iRetrieve(aRetrieve) |
|
413 {} |
|
414 |
|
415 CTestCanceller::~CTestCanceller() |
|
416 {} |
|
417 |
|
418 void CTestCanceller::RunL() |
|
419 { |
|
420 iRetrieve->Cancel(); |
|
421 CActiveScheduler::Stop(); |
|
422 } |
|
423 |
|
424 CEtelIsvActBase::CEtelIsvActBase(CEtelIsvTestStep* aTestStep, CTelephony* aTelephony) |
|
425 : CActive(CActive::EPriorityStandard), iCanceller(NULL), iTelephony(aTelephony), iTestStep(aTestStep) |
|
426 {} |
|
427 |
|
428 void CEtelIsvActBase::CallMe(TInt& aCallCount) |
|
429 /** |
|
430 Notify property to get SIMTSY to initiate a call |
|
431 */ |
|
432 { |
|
433 aCallCount++; //increment count, implies a change of state which SIMTSY will react to. |
|
434 |
|
435 RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyIncomingVoiceCall, aCallCount); |
|
436 User::After(1000000L); |
|
437 |
|
438 return; |
|
439 } |
|
440 |
|
441 /** |
|
442 Public constructor. |
|
443 |
|
444 @return Pointer to created CMyAsyncOneShot object. |
|
445 */ |
|
446 CMyAsyncOneShot* CMyAsyncOneShot::NewL() |
|
447 { |
|
448 CMyAsyncOneShot* self = new (ELeave) CMyAsyncOneShot(); |
|
449 CleanupStack::PushL(self); |
|
450 self->ConstructL(); |
|
451 CleanupStack::Pop(self); |
|
452 return self; |
|
453 } |
|
454 |
|
455 /** |
|
456 Default constructor. |
|
457 */ |
|
458 CMyAsyncOneShot::CMyAsyncOneShot() |
|
459 : CAsyncOneShot(CActive::EPriorityStandard) |
|
460 { // NOP |
|
461 } |
|
462 |
|
463 /** |
|
464 Second phase constructor. |
|
465 */ |
|
466 void CMyAsyncOneShot::ConstructL() |
|
467 { |
|
468 User::LeaveIfError(iTimer.CreateLocal()); |
|
469 } |
|
470 |
|
471 /** |
|
472 Starts the timer. |
|
473 */ |
|
474 void CMyAsyncOneShot::StartOneShot() |
|
475 { |
|
476 iTimer.After(iStatus,10000); |
|
477 Call(); |
|
478 } |
|
479 /** |
|
480 Stops the active scheduler. Does nothing else. |
|
481 */ |
|
482 void CMyAsyncOneShot::RunL() |
|
483 { |
|
484 CActiveScheduler::Stop(); |
|
485 } |
|
486 |
|
487 /** |
|
488 Default destructor. |
|
489 */ |
|
490 CMyAsyncOneShot::~CMyAsyncOneShot() |
|
491 { |
|
492 Cancel(); |
|
493 iTimer.Close(); |
|
494 } |
|
495 |
|
496 /** |
|
497 Cancels the timer. |
|
498 */ |
|
499 void CMyAsyncOneShot::DoCancel() |
|
500 { |
|
501 iTimer.Cancel(); |
|
502 } |