|
1 // Copyright (c) 2008-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 #include "tcustcmd_step_simsecuritypincheck.h" |
|
17 #include <ssm/ssmuiproviderdll.h> |
|
18 #include <ssm/startupdomainpskeys.h> |
|
19 #include <w32std.h> |
|
20 #include <s32file.h> |
|
21 |
|
22 const TInt KNumOfTestCases = 8; |
|
23 |
|
24 static TInt CustomCmdTestSecurityCheckCallBackL(TAny* aCustomCmdTestSecurityPinCheck) |
|
25 { |
|
26 CCustomCmdTestSecurityPinCheck* test = reinterpret_cast<CCustomCmdTestSecurityPinCheck*>(aCustomCmdTestSecurityPinCheck); |
|
27 CleanupStack::PushL(test); |
|
28 test->CallBackForEnterPin(); |
|
29 CleanupStack::Pop(); |
|
30 return KErrNone; |
|
31 } |
|
32 |
|
33 /* |
|
34 Call back function to enter a PIN |
|
35 */ |
|
36 void CCustomCmdTestSecurityPinCheck::CallBackForEnterPin() |
|
37 { |
|
38 iAsyncStopScheduler->CallBack(); |
|
39 |
|
40 RWsSession wsSession; |
|
41 wsSession.Connect(); |
|
42 |
|
43 TRawEvent eventDown; |
|
44 TRawEvent eventUp; |
|
45 |
|
46 if(iValidPin) |
|
47 { |
|
48 eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); |
|
49 UserSvr::AddEvent(eventDown); |
|
50 eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); |
|
51 UserSvr::AddEvent(eventUp); |
|
52 User::After(100000); |
|
53 } |
|
54 |
|
55 eventDown.Set(TRawEvent::EKeyDown, EStdKeyEnter); |
|
56 UserSvr::AddEvent(eventDown); |
|
57 eventUp.Set(TRawEvent::EKeyUp, EStdKeyEnter); |
|
58 UserSvr::AddEvent(eventUp); |
|
59 User::After(100000); |
|
60 |
|
61 wsSession.Flush(); |
|
62 wsSession.Close(); |
|
63 } |
|
64 |
|
65 void CCustomCmdTestSecurityPinCheck::StopScheduler() |
|
66 { |
|
67 //Stop the active scheduler |
|
68 RDebug::Printf("CCustomCmdTestSecurityPinCheck::StopScheduler()"); |
|
69 iActiveSchedulerWait->AsyncStop(); |
|
70 } |
|
71 |
|
72 CCustomCmdTestSecurityPinCheck::~CCustomCmdTestSecurityPinCheck() |
|
73 { |
|
74 delete iAsyncStopScheduler; |
|
75 delete iActiveSchedulerWait; |
|
76 delete iActiveScheduler; |
|
77 delete iStopSimulatekey; |
|
78 } |
|
79 |
|
80 CCustomCmdTestSecurityPinCheck::CCustomCmdTestSecurityPinCheck():iSwp(TSsmSwp(KTestSwp, 0)) |
|
81 { |
|
82 SetTestStepName(KTCCustomCmdTestSecurityPinCheck); |
|
83 } |
|
84 |
|
85 TVerdict CCustomCmdTestSecurityPinCheck::doTestStepPreambleL() |
|
86 { |
|
87 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
88 CActiveScheduler::Install (iActiveScheduler); |
|
89 |
|
90 iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait; |
|
91 |
|
92 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
|
93 |
|
94 //Start the test exe which defines startup related property keys |
|
95 RProcess processHandle; |
|
96 CleanupClosePushL(processHandle); |
|
97 processHandle.Create(KExeToDefineStartUpPS, KNullDesC); |
|
98 processHandle.Resume(); |
|
99 |
|
100 // wait for the newly created process to rendezvous |
|
101 TRequestStatus status; |
|
102 processHandle.Rendezvous(status); |
|
103 User::WaitForRequest(status); |
|
104 |
|
105 TInt retVal = status.Int(); |
|
106 TEST(KErrNone == retVal); |
|
107 // leave if the process has not started properly |
|
108 User::LeaveIfError(retVal); |
|
109 CleanupStack::PopAndDestroy(); |
|
110 |
|
111 RProcess processHandle1; |
|
112 TInt err1 = processHandle1.Create(KExeToDefineStartUpStatePS, KNullDesC); |
|
113 INFO_PRINTF2(_L("KExeToDefineStartUpStatePS ret is %d"), err1); |
|
114 processHandle1.Resume(); |
|
115 processHandle1.Close(); |
|
116 |
|
117 //there are 8 different scenarios to test the custom command. Check the test spec for the scenarios. |
|
118 //CMiscAdaptationRef::SecurityStateChange() has been changed to simulate the scenarios. |
|
119 //CMiscAdaptationRef::SecurityStateChange() uses KTestCmdSecurityCheckTestFile to get the scenario number |
|
120 //connect to file server |
|
121 User::LeaveIfError(iFs.Connect()); |
|
122 TInt err = iFs.MkDirAll(KDirNameOfTestCasesNumFile); |
|
123 if (KErrAlreadyExists != err && KErrNone != err) |
|
124 { |
|
125 User::Leave(err); |
|
126 } |
|
127 err = iFile.Replace(iFs, KTestCmdSecurityCheckTestFile, EFileWrite | EFileStream); |
|
128 iFile.Close(); |
|
129 |
|
130 //For stopping the key simulation when execution behaviour is deferredwaitforsignal and fireandforget |
|
131 iStopSimulatekey = CStopSimulatekey::NewL(this); |
|
132 |
|
133 //Connect to SsmStateManager |
|
134 const TInt connect = iClient.Connect(); |
|
135 TEST(KErrNone == connect); |
|
136 |
|
137 //RProperty property; |
|
138 iProperty.Define(KCustomcmdServerSID, iSwp.Key(), RProperty::EInt); |
|
139 |
|
140 // Register mapping between keys and swp policy DLL (done once per ssmserver) |
|
141 INFO_PRINTF1(_L("Registering swp...")); |
|
142 iClient.RegisterSwpMapping(KTestSwp, KTestSwpPolicyCustomCmd); |
|
143 |
|
144 RegisterSimSecurityStatus(); |
|
145 return TestStepResult(); |
|
146 } |
|
147 |
|
148 void CCustomCmdTestSecurityPinCheck::RegisterSimSecurityStatus() |
|
149 { |
|
150 INFO_PRINTF1(_L("RegisterSimSecurityStatus")); |
|
151 |
|
152 _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
153 //Define the property for sim status for swp. |
|
154 TInt ret = RProperty::Define(RProcess().SecureId(), CSsmUiSpecific::SimStatusPropertyKey(), RProperty::EInt,KAllowAllPolicy, KAllowAllPolicy); |
|
155 TEST(KErrNone == ret || KErrAlreadyExists == ret); |
|
156 |
|
157 |
|
158 const TUint KStartupSimSecurityStatusKey = {CSsmUiSpecific::SimStatusPropertyKey()}; |
|
159 |
|
160 //register the swp mapping for Sim security status with its swp policy |
|
161 ret = iClient.RegisterSwpMapping(KStartupSimSecurityStatusKey, KTestSimStatusSwpPolicy); |
|
162 TEST(KErrNone == ret || KErrAlreadyExists == ret); |
|
163 } |
|
164 |
|
165 TVerdict CCustomCmdTestSecurityPinCheck::doTestStepL() |
|
166 { |
|
167 INFO_PRINTF1(_L("doTestStepL")); |
|
168 TInt err = 0; |
|
169 __UHEAP_MARK; |
|
170 |
|
171 iCancelRequest = EFalse; |
|
172 TRAP(err,TestHandleSecCustCmdWithExeBehaviourFireAndForgetL()); |
|
173 TEST(KErrNone == err); |
|
174 TRAP(err,TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL()); |
|
175 TEST(KErrNone == err); |
|
176 TRAP(err,TestHandleSecCustCmdWithExeBehaviourWaitForSignalL()); |
|
177 TEST(KErrNone == err); |
|
178 |
|
179 iCancelRequest = ETrue; |
|
180 TRAP(err,TestHandleSecCustCmdWithExeBehaviourWaitForSignalCancelL()); |
|
181 TEST(KErrNone == err); |
|
182 TRAP(err,TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalCancelL()); |
|
183 TEST(KErrNone == err); |
|
184 |
|
185 TRAP(err,TestOOMDevSecCustCmdwithExeBehaviourDWFL()); |
|
186 TEST(KErrNone == err); |
|
187 |
|
188 return TestStepResult(); |
|
189 } |
|
190 |
|
191 /** |
|
192 Old Test CaseID APPFWK-CUSTCMD-0019 |
|
193 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
194 */ |
|
195 |
|
196 void CCustomCmdTestSecurityPinCheck::TestHandleSecCustCmdWithExeBehaviourWaitForSignalL() |
|
197 { |
|
198 TInt testNum; |
|
199 iExecutionBehaviour = ESsmWaitForSignal; |
|
200 iValidPin = ETrue; |
|
201 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourWaitForSignal")); |
|
202 for(testNum = 1; testNum <= KNumOfTestCases; testNum++) |
|
203 { |
|
204 INFO_PRINTF2(_L("EPINCHECK%d started"),testNum); |
|
205 WritePinCheckTestCaseNumToFileL(testNum); |
|
206 iStopSimulatekey->Start(); |
|
207 CreateAndExecuteCustCmd(); |
|
208 StartSimulateKey(); |
|
209 TEST(KErrNone == iStatus.Int()); |
|
210 INFO_PRINTF3(_L("Security PIN check completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
211 } |
|
212 INFO_PRINTF1(_L("Test security custom command for a invalid PIN ")); |
|
213 iValidPin = EFalse; |
|
214 for(testNum = 1; testNum < KNumOfTestCases; testNum++) |
|
215 { |
|
216 INFO_PRINTF2(_L("EPINCHECK%d started"),testNum); |
|
217 WritePinCheckTestCaseNumToFileL(testNum); |
|
218 iStopSimulatekey->Start(); |
|
219 CreateAndExecuteCustCmd(); |
|
220 StartSimulateKey(); |
|
221 TEST(KErrNone == iStatus.Int()); |
|
222 INFO_PRINTF3(_L("Security PIN check completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
223 } |
|
224 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourWaitForSignal completed")); |
|
225 } |
|
226 |
|
227 /** |
|
228 Old Test CaseID APPFWK-CUSTCMD-0027 |
|
229 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
230 */ |
|
231 |
|
232 void CCustomCmdTestSecurityPinCheck::TestHandleSecCustCmdWithExeBehaviourWaitForSignalCancelL() |
|
233 { |
|
234 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourWaitForSignalCancelL")); |
|
235 TInt testNum = 1; |
|
236 iValidPin = ETrue; |
|
237 WritePinCheckTestCaseNumToFileL(testNum); |
|
238 iExecutionBehaviour = ESsmWaitForSignal; |
|
239 iStopSimulatekey->Start(); |
|
240 CreateAndExecuteCancelCustCmd(); |
|
241 StartSimulateKey(); |
|
242 TEST(KErrCancel == iCancelReqStatus.Int()); |
|
243 RDebug::Print(_L("TestHandleSecCustCmdWithExeBehaviourWaitForSignalCancelL completed with %d, expected %d"),iCancelReqStatus.Int(),KErrCancel); |
|
244 INFO_PRINTF3(_L("TestHandleSecCustCmdWithExeBehaviourWaitForSignalCancelL completed with %d, expected %d"),iCancelReqStatus.Int(),KErrCancel); |
|
245 } |
|
246 |
|
247 /** |
|
248 Old Test CaseID APPFWK-CUSTCMD-0019 |
|
249 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
250 */ |
|
251 |
|
252 void CCustomCmdTestSecurityPinCheck::TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL() |
|
253 { |
|
254 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL")); |
|
255 TInt testNum = 1; |
|
256 iValidPin = ETrue; |
|
257 WritePinCheckTestCaseNumToFileL(testNum); |
|
258 iExecutionBehaviour = ESsmDeferredWaitForSignal; |
|
259 iStopSimulatekey->Start(); |
|
260 CreateAndExecuteCustCmd(); |
|
261 StartSimulateKey(); |
|
262 TEST(KErrNone == iStatus.Int()); |
|
263 RDebug::Print(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
264 INFO_PRINTF3(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
265 } |
|
266 |
|
267 /** |
|
268 Old Test CaseID APPFWK-CUSTCMD-0027 |
|
269 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
270 */ |
|
271 |
|
272 void CCustomCmdTestSecurityPinCheck::TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalCancelL() |
|
273 { |
|
274 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalCancelL")); |
|
275 TInt testNum = 1; |
|
276 iValidPin = ETrue; |
|
277 WritePinCheckTestCaseNumToFileL(testNum); |
|
278 iExecutionBehaviour = ESsmDeferredWaitForSignal; |
|
279 iStopSimulatekey->Start(); |
|
280 CreateAndExecuteCancelCustCmd(); |
|
281 StartSimulateKey(); |
|
282 TEST(KErrCancel == iCancelReqStatus.Int()); |
|
283 RDebug::Print(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalCancelL completed with %d, expected %d"),iCancelReqStatus.Int(),KErrCancel); |
|
284 INFO_PRINTF3(_L("TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalCancelL completed with %d, expected %d"),iCancelReqStatus.Int(),KErrCancel); |
|
285 } |
|
286 |
|
287 /** |
|
288 Old Test CaseID APPFWK-CUSTCMD-0019 |
|
289 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
290 */ |
|
291 |
|
292 void CCustomCmdTestSecurityPinCheck::TestHandleSecCustCmdWithExeBehaviourFireAndForgetL() |
|
293 { |
|
294 INFO_PRINTF1(_L("TestHandleSecCustCmdWithExeBehaviourFireAndForgetL")); |
|
295 TInt testNum = 1; |
|
296 iValidPin = ETrue; |
|
297 WritePinCheckTestCaseNumToFileL(testNum); |
|
298 iExecutionBehaviour = ESsmFireAndForget; |
|
299 iStopSimulatekey->Start(); |
|
300 CreateAndExecuteCustCmd(); |
|
301 StartSimulateKey(); |
|
302 TEST(KErrNone == iStatus.Int()); |
|
303 RDebug::Print(_L("TestHandleSecCustCmdWithExeBehaviourFireAndForgetL completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
304 INFO_PRINTF3(_L("TestHandleSecCustCmdWithExeBehaviourFireAndForgetL completed with %d, expected %d"),iStatus.Int(),KErrNone); |
|
305 } |
|
306 |
|
307 /** |
|
308 Old Test CaseID APPFWK-CUSTCMD-0025 |
|
309 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0019 |
|
310 */ |
|
311 |
|
312 void CCustomCmdTestSecurityPinCheck::TestOOMDevSecCustCmdwithExeBehaviourDWFL() |
|
313 { |
|
314 INFO_PRINTF1(_L("*** Starting TestOOMDevSecCustCmdwithExeBehaviourDWF")); |
|
315 TInt failRate = 1; |
|
316 for (;;failRate++) |
|
317 { |
|
318 __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); |
|
319 __UHEAP_MARK; |
|
320 |
|
321 TRAPD(ret, TestHandleSecCustCmdWithExeBehaviourDeferredWaitForSignalL()); |
|
322 |
|
323 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
324 __UHEAP_MARKEND; |
|
325 |
|
326 if (ret==KErrNone) |
|
327 { |
|
328 break; |
|
329 } |
|
330 } |
|
331 __UHEAP_RESET; |
|
332 INFO_PRINTF2(_L(" Executed securitypincheck custom command %d number of times."),failRate); |
|
333 } |
|
334 |
|
335 void CCustomCmdTestSecurityPinCheck::CancelSwpRequest() |
|
336 { |
|
337 iStopSimulatekey->Start(); |
|
338 if(iCancelRequest) |
|
339 { |
|
340 iClient.RequestSwpChangeCancel(); |
|
341 } |
|
342 RDebug::Printf("Cancel Swp Request"); |
|
343 |
|
344 } |
|
345 |
|
346 void CCustomCmdTestSecurityPinCheck::CreateAndExecuteCustCmd() |
|
347 { |
|
348 //set the SIM status property as ESimStatusUninitialized |
|
349 TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimStatusUninitialized); |
|
350 TEST(KErrNone == result); |
|
351 |
|
352 TInt swpValue = 0; |
|
353 switch(iExecutionBehaviour) |
|
354 { |
|
355 case ESsmWaitForSignal: |
|
356 swpValue = ERPropertyValForSecCustCmdWaitForSignal; |
|
357 break; |
|
358 case ESsmDeferredWaitForSignal: |
|
359 swpValue = ERPropertyValForSecCustCmdDeferrdWaitForSignal; |
|
360 break; |
|
361 case ESsmFireAndForget: |
|
362 swpValue = ERPropertyValForSecCustCmdFireAndForget; |
|
363 break; |
|
364 default: |
|
365 break; |
|
366 } |
|
367 // Create swps |
|
368 INFO_PRINTF1(_L("Creating swp...")); |
|
369 //set this property to create appropriate command by ssm.swp.policy.test.customcmd.dll |
|
370 iSwp.Set(KTestSwp, swpValue); |
|
371 |
|
372 TEST(KErrNone == iProperty.Set(KCustomcmdServerSID, iSwp.Key(), iSwp.Value())); |
|
373 |
|
374 //Ensure the environment is clean |
|
375 TInt value = 0; |
|
376 TEST(KErrNone == iProperty.Get(KCustomcmdServerSID, iSwp.Key(), value)); |
|
377 TESTE(swpValue == value, value); |
|
378 |
|
379 //Let client request swp changes |
|
380 INFO_PRINTF1(_L("Request several swp changes ")); |
|
381 iSwp.Set(KTestSwp, -99); |
|
382 |
|
383 iClient.RequestSwpChange(iSwp, iStatus); |
|
384 |
|
385 TEST(iStatus == KRequestPending); |
|
386 User::WaitForRequest(iStatus); |
|
387 User::After(500000); // Wait for 0.5sec to allow transitions to fully complete |
|
388 TEST(iStatus.Int() == KErrNone); |
|
389 } |
|
390 |
|
391 void CCustomCmdTestSecurityPinCheck::CreateAndExecuteCancelCustCmd() |
|
392 { |
|
393 TInt swpValue = 0; |
|
394 switch(iExecutionBehaviour) |
|
395 { |
|
396 case ESsmWaitForSignal: |
|
397 swpValue = ERPropertyValForSecCustCmdWaitForSignal; |
|
398 break; |
|
399 case ESsmDeferredWaitForSignal: |
|
400 swpValue = ERPropertyValForSecCustCmdDeferrdWaitForSignal; |
|
401 break; |
|
402 case ESsmFireAndForget: |
|
403 swpValue = ERPropertyValForSecCustCmdFireAndForget; |
|
404 break; |
|
405 default: |
|
406 break; |
|
407 } |
|
408 // Create swps |
|
409 INFO_PRINTF1(_L("Creating swp...")); |
|
410 //set this property to create appropriate command by ssm.swp.policy.test.customcmd.dll |
|
411 iSwp.Set(KTestSwp, swpValue); |
|
412 |
|
413 TEST(KErrNone == iProperty.Set(KCustomcmdServerSID, iSwp.Key(), iSwp.Value())); |
|
414 |
|
415 //Ensure the environment is clean |
|
416 TInt value = 0; |
|
417 TEST(KErrNone == iProperty.Get(KCustomcmdServerSID, iSwp.Key(), value)); |
|
418 TESTE(swpValue == value, value); |
|
419 |
|
420 //Let client request swp changes |
|
421 INFO_PRINTF1(_L("Request several swp changes ")); |
|
422 iSwp.Set(KTestSwp, -99); |
|
423 |
|
424 //Transition engine will no cancel any request that is currently in execution. It will delete only quad request. |
|
425 TRequestStatus status; |
|
426 iClient.RequestSwpChange(iSwp, iStatus); |
|
427 iClient.RequestSwpChange(iSwp, iCancelReqStatus); |
|
428 TEST(iStatus == KRequestPending); |
|
429 //User::After(5000); // Wait for 0.005sec to allow transitions to start |
|
430 User::WaitForRequest(iStatus); |
|
431 TEST(iStatus.Int() == KErrNone); |
|
432 iClient.RequestSwpChangeCancel(); |
|
433 RDebug::Print(_L("CreateAndExecuteCancelCustCmdL completes with %d err"),iStatus.Int()); |
|
434 |
|
435 } |
|
436 /** |
|
437 write the pin check test case number to a file so that misc ref plugin can read the |
|
438 it and check corresponding PIN Check security plug-in functionality in different SIM status |
|
439 */ |
|
440 void CCustomCmdTestSecurityPinCheck::WritePinCheckTestCaseNumToFileL(TInt aTestNum) |
|
441 { |
|
442 INFO_PRINTF1(_L("WritePinCheckTestCaseNumToFileL")); |
|
443 //RFile file; |
|
444 const TInt err = iFile.Open(iFs, KTestCmdSecurityCheckTestFile, EFileWrite | EFileStream); |
|
445 User::LeaveIfError(err); |
|
446 |
|
447 RFileWriteStream stream(iFile); |
|
448 CleanupClosePushL(stream); |
|
449 |
|
450 stream.WriteInt32L(aTestNum); |
|
451 stream.CommitL(); |
|
452 CleanupStack::PopAndDestroy(&stream); |
|
453 } |
|
454 |
|
455 TVerdict CCustomCmdTestSecurityPinCheck::doTestStepPostambleL() |
|
456 { |
|
457 TEST(KErrNone == iProperty.Delete(KCustomcmdServerSID, iSwp.Key())); |
|
458 iProperty.Close(); |
|
459 iClient.Close(); |
|
460 //delete the file |
|
461 iFs.Delete(KTestCmdSecurityCheckTestFile); |
|
462 iFs.Close(); |
|
463 __UHEAP_MARKEND; |
|
464 return TestStepResult(); |
|
465 } |
|
466 |
|
467 void CCustomCmdTestSecurityPinCheck::StartSimulateKey() |
|
468 { |
|
469 //Callback function for simulating the key |
|
470 TCallBack stop(CustomCmdTestSecurityCheckCallBackL, this); |
|
471 if(!iAsyncStopScheduler->IsActive()) |
|
472 { |
|
473 iAsyncStopScheduler->Set(stop); |
|
474 } |
|
475 iAsyncStopScheduler->CallBack(); |
|
476 iActiveSchedulerWait->Start(); |
|
477 } |
|
478 |
|
479 TSsmExecutionBehaviour CCustomCmdTestSecurityPinCheck::GetExecutionBehaviour() |
|
480 { |
|
481 return iExecutionBehaviour; |
|
482 } |
|
483 // |
|
484 /** |
|
485 CStopSimulatekey class is used for stoping the scheduler and for canceling the swp request. |
|
486 */ |
|
487 CStopSimulatekey::~CStopSimulatekey() |
|
488 { |
|
489 iProperty.Close(); |
|
490 Cancel(); |
|
491 } |
|
492 |
|
493 CStopSimulatekey::CStopSimulatekey() : CActive(CActive::EPriorityHigh) //Standard) |
|
494 { |
|
495 CActiveScheduler::Add(this); |
|
496 } |
|
497 |
|
498 CStopSimulatekey* CStopSimulatekey::NewL(CCustomCmdTestSecurityPinCheck* aCustomCmdTestSecurityPinCheck) |
|
499 { |
|
500 CStopSimulatekey* self = new (ELeave) CStopSimulatekey(); |
|
501 CleanupStack::PushL(self); |
|
502 self->Construct(aCustomCmdTestSecurityPinCheck); |
|
503 CleanupStack::Pop(); |
|
504 return self; |
|
505 } |
|
506 |
|
507 void CStopSimulatekey::Construct(CCustomCmdTestSecurityPinCheck* aCustomCmdTestSecurityPinCheck) |
|
508 { |
|
509 // Define a property for stopping active scheduler |
|
510 TInt r = RProperty::Define(KCustomcmdServerPropertyKey, RProperty::EInt,ECapability_None, ECapability_None); |
|
511 iCustomCmdTestSecurityPinCheck = aCustomCmdTestSecurityPinCheck; |
|
512 } |
|
513 |
|
514 void CStopSimulatekey::Start() |
|
515 { |
|
516 iProperty.Attach(KCustomcmdServerSID,KCustomcmdServerPropertyKey); |
|
517 iProperty.Subscribe(iStatus); |
|
518 SetActive(); |
|
519 } |
|
520 |
|
521 void CStopSimulatekey::RunL() |
|
522 { |
|
523 TInt value; |
|
524 TInt err = RProperty::Get(RProcess().SecureId(),KCustomcmdServerPropertyKey,value); |
|
525 |
|
526 if( value == ERPropertyValForSecCustCmdCancelRequest) |
|
527 { |
|
528 RDebug::Printf("CStopSimulatekey::RunL() CustCmdCancelRequest)"); |
|
529 iCustomCmdTestSecurityPinCheck->CancelSwpRequest(); |
|
530 } |
|
531 else if( value == ERPropertyValForStopSchedulerCmdDeferredWaitForSignal && iCustomCmdTestSecurityPinCheck->GetExecutionBehaviour() == ESsmDeferredWaitForSignal) |
|
532 { |
|
533 RDebug::Printf("CStopSimulatekey::RunL() ExecutionBehaviour = ESsmDeferredWaitForSignal"); |
|
534 iCustomCmdTestSecurityPinCheck->StopScheduler(); |
|
535 } |
|
536 else if( value == ERPropertyValForStopSchedulerCmdWaitForSignal && iCustomCmdTestSecurityPinCheck->GetExecutionBehaviour() == ESsmWaitForSignal) |
|
537 { |
|
538 RDebug::Printf("iCustomCmdTestSecurityPinCheck->StopScheduler()if( CStopSimulatekey::RunL() ExecutionBehaviour = ESsmWaitForSignal"); |
|
539 iCustomCmdTestSecurityPinCheck->StopScheduler(); |
|
540 } |
|
541 else if( value == ERPropertyValForStopSchedulerCmdFireAndForget && iCustomCmdTestSecurityPinCheck->GetExecutionBehaviour() == ESsmFireAndForget ) |
|
542 { |
|
543 RDebug::Printf("CStopSimulatekey::RunL() ExecutionBehaviour = FireAndForget"); |
|
544 User::After(5000000); // Wait 5sec to allow transitions to fully complete |
|
545 User::After(5000000); // Wait 5sec to allow transitions to fully complete |
|
546 iCustomCmdTestSecurityPinCheck->StopScheduler(); |
|
547 } |
|
548 else |
|
549 { |
|
550 Start(); |
|
551 } |
|
552 } |
|
553 |
|
554 void CStopSimulatekey::DoCancel() |
|
555 { |
|
556 iProperty.Cancel(); |
|
557 } |
|
558 |
|
559 |