|
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 // Name : strtsecuritychecktask.cpp |
|
15 // Part of : System Startup / Starter |
|
16 // Implementation of CStrtSecurityCheckTask class |
|
17 // Version : %version: ou1s60rt#7.1.1 % |
|
18 // This material, including documentation and any related computer |
|
19 // programs, is protected by copyright controlled by Nokia. All |
|
20 // rights are reserved. Copying, including reproducing, storing, |
|
21 // adapting or translating, any or all of this material requires the |
|
22 // prior written consent of Nokia. This material also contains |
|
23 // confidential information which may not be disclosed to others |
|
24 // without the prior written consent of Nokia. |
|
25 // Template version: 4.1 |
|
26 // Nokia Core OS * |
|
27 // File renamed from strtsecuritychecktask.cpp to cmdsimsecuritycheck.cpp as part of Core OS transfer. |
|
28 // |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 /** |
|
34 @file |
|
35 @internalComponent |
|
36 @released |
|
37 */ |
|
38 |
|
39 #include "ssmsecuritychecknotifier.h" |
|
40 #include "cmdsimsecuritycheck.h" |
|
41 #include "ssmrefcustomcmdcommon.h" |
|
42 #include "ssmdebug.h" |
|
43 |
|
44 #include <e32def.h> |
|
45 #include <ssm/startupdomainpskeys.h> |
|
46 #include <ssm/ssmstateawaresession.h> |
|
47 #include <ssm/ssmpatchableconstants.h> |
|
48 #include <centralrepository.h> |
|
49 #include <e32svr.h> |
|
50 #include <u32hal.h> |
|
51 |
|
52 //Ordinal postion of the security event observer NewL in the plugin dll |
|
53 const TInt KSecurityEventObserverNewLOridinal = 1; |
|
54 |
|
55 //Utility plugin name used for starting security note event observer |
|
56 _LIT(KSusUtilityPlugin, "ssmclayersup.dll"); |
|
57 |
|
58 /* |
|
59 * Function to check whether Invalid Sim feature is enabled or not |
|
60 */ |
|
61 TUint32 IsSsmInvalidSimOn() |
|
62 { |
|
63 TUint32 retVal = 0; |
|
64 |
|
65 #ifdef __WINS__ |
|
66 // KSsmInvalidSim is a ROM patchable constant, so need an emulator equivalent |
|
67 // if WINS then read value from epoc.ini, requires licencees to set property in epoc.ini. This value is 0xFFFFFFFF if feature is enabled. |
|
68 // Usage: In epoc.ini patchdata_KSsmInvalidSim 0xFFFFFFFF (Can be any non-zero value) |
|
69 TUint32 readValueOfInvalidSim = 0; |
|
70 if( UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalIntProperty, (TAny*)"patchdata_KSsmInvalidSim", &readValueOfInvalidSim) == KErrNone ) |
|
71 { |
|
72 retVal = readValueOfInvalidSim; |
|
73 } |
|
74 #else |
|
75 retVal = KSsmInvalidSim; |
|
76 |
|
77 #endif // __WINS__ |
|
78 return retVal; |
|
79 } |
|
80 |
|
81 CCustomCmdSimSecurityCheck* CCustomCmdSimSecurityCheck::NewL() |
|
82 { |
|
83 CCustomCmdSimSecurityCheck* self = new (ELeave) CCustomCmdSimSecurityCheck(); |
|
84 CleanupStack::PushL(self); |
|
85 self->ConstructL(); |
|
86 CleanupStack::Pop(self); |
|
87 return self; |
|
88 } |
|
89 |
|
90 void CCustomCmdSimSecurityCheck::ConstructL() |
|
91 { |
|
92 User::LeaveIfError(iSsmMiscAdaptation.Connect()); |
|
93 User::LeaveIfError(iSsmStateManager.Connect()); |
|
94 User::LeaveIfError(iSsmSusCli.Connect()); |
|
95 |
|
96 iStartupPSUid = CSsmUiSpecific::StartupPSUid(); |
|
97 __ASSERT_ALWAYS(0 != iStartupPSUid.iUid, PanicNow(KPanicCustomCmdSimSecurityCheck, EInvalidUid)); |
|
98 iSecurityStateInfoResult = new (ELeave) TPckg<TSecurityStateInfo>(iSecurityStateInfo); |
|
99 iSsmUiSpecific = CSsmUiSpecific::InstanceL(); |
|
100 |
|
101 iSimStatusPSObserver = CSsmSimStatusPSObserver::NewL(iStartupPSUid, iSsmUiSpecific->SimStatusPropertyKey()); |
|
102 //Add active object to active scheduler |
|
103 CActiveScheduler::Add(this); |
|
104 } |
|
105 |
|
106 CCustomCmdSimSecurityCheck::CCustomCmdSimSecurityCheck() |
|
107 : CActive( EPriorityStandard) |
|
108 { |
|
109 } |
|
110 |
|
111 CCustomCmdSimSecurityCheck::~CCustomCmdSimSecurityCheck() |
|
112 { |
|
113 ExecuteCancel(); |
|
114 iSsmMiscAdaptation.Close(); |
|
115 iSsmStateManager.Close(); |
|
116 iSsmSusCli.Close(); |
|
117 |
|
118 if(iSsmUiSpecific) |
|
119 { |
|
120 //Will be deleted after last dereference |
|
121 iSsmUiSpecific->Release(); |
|
122 } |
|
123 |
|
124 delete iSsmSecurityCheckNotifier; |
|
125 delete iSecurityNoteObserver; |
|
126 delete iSecurityStateInfoResult; |
|
127 delete iSimStatusPSObserver; |
|
128 } |
|
129 |
|
130 TInt CCustomCmdSimSecurityCheck::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/) |
|
131 { |
|
132 return KErrNone; |
|
133 } |
|
134 |
|
135 void CCustomCmdSimSecurityCheck::Close() |
|
136 { |
|
137 } |
|
138 |
|
139 void CCustomCmdSimSecurityCheck::Release() |
|
140 { |
|
141 delete this; |
|
142 } |
|
143 |
|
144 void CCustomCmdSimSecurityCheck::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus) |
|
145 { |
|
146 //Load the security event observer |
|
147 TSsmSupInfo observerPlugin(KSusUtilityPlugin, KSecurityEventObserverNewLOridinal); |
|
148 TInt retLoadSecEventObserver = iSsmSusCli.RequestLoadSup(observerPlugin); |
|
149 |
|
150 if(KErrNone != retLoadSecEventObserver) |
|
151 { |
|
152 DEBUGPRINT2A("Load security event observer SUP failed with error code : %d", retLoadSecEventObserver); |
|
153 } |
|
154 |
|
155 //Set the user request to pending |
|
156 aStatus = KRequestPending; |
|
157 iExecuteRequest = &aStatus; |
|
158 |
|
159 //Start the state change |
|
160 StartStateChange(StartupAdaptation::ESIMPresent); |
|
161 } |
|
162 |
|
163 /** |
|
164 @panic EInternalStateError if the active object is running or the state change is pending |
|
165 */ |
|
166 void CCustomCmdSimSecurityCheck::StartStateChange(const TSecurityState aState, const TStrtSecurityNoteType aNoteType) |
|
167 { |
|
168 __ASSERT_ALWAYS(!IsActive(), PanicNow(KPanicCustomCmdSimSecurityCheck, EInternalStateError)); |
|
169 __ASSERT_ALWAYS(!iStateChangePending, PanicNow(KPanicCustomCmdSimSecurityCheck, EInternalStateError)); |
|
170 |
|
171 iSubState = ESecuritySubStateNone; |
|
172 iStateChangePending = ETrue; |
|
173 iNoteType = aNoteType; |
|
174 iState = aState; |
|
175 |
|
176 //Request for security state change |
|
177 iSsmMiscAdaptation.SecurityStateChange(iState, *iSecurityStateInfoResult, iStatus); |
|
178 SetActive(); |
|
179 } |
|
180 |
|
181 void CCustomCmdSimSecurityCheck::RunL() |
|
182 { |
|
183 if(iSubState != ESecuritySubStateNone) |
|
184 { |
|
185 //Execute sim operations |
|
186 DoExtendedSimOperations(); |
|
187 return; |
|
188 } |
|
189 |
|
190 if (iStateChangePending) |
|
191 { |
|
192 //Start changing the state |
|
193 StateChangeL(iStatus.Int()); |
|
194 } |
|
195 else |
|
196 { |
|
197 if (iStatus == KErrNone) |
|
198 { |
|
199 //Do further security check |
|
200 DoSecurityCheck(); |
|
201 } |
|
202 else |
|
203 { |
|
204 //Complete client request with result code |
|
205 CompleteClientRequest(iStatus.Int()); |
|
206 } |
|
207 } |
|
208 } |
|
209 |
|
210 void CCustomCmdSimSecurityCheck::DoExtendedSimOperations() |
|
211 { |
|
212 if (KErrNone == iStatus.Int()) |
|
213 { |
|
214 switch (iSubState) |
|
215 { |
|
216 case ESecuritySubStateSimRemoved: |
|
217 DoSimRemoved(); |
|
218 break; |
|
219 case ESecuritySubStateSimNotSupported: |
|
220 DoSimNotSupported(); |
|
221 break; |
|
222 case ESecuritySubStateSimReadable: |
|
223 DoSimReadable(); |
|
224 break; |
|
225 case ESecuritySubStateSimUsable: |
|
226 DoSimUsable(); |
|
227 break; |
|
228 case ESecuritySubStateSimStatusPSObserver: |
|
229 DoObserveSimStatusPS(); |
|
230 break; |
|
231 default: |
|
232 __ASSERT_DEBUG(ESecuritySubStateNone == iSubState, PanicNow(KPanicCustomCmdSimSecurityCheck, EInvalidSecuritySubState)); |
|
233 break; |
|
234 } |
|
235 } |
|
236 else |
|
237 { |
|
238 //Complete client request with result code |
|
239 CompleteClientRequest(iStatus.Int()); |
|
240 } |
|
241 } |
|
242 |
|
243 void CCustomCmdSimSecurityCheck::StateChangeL(const TInt aResultCode) |
|
244 { |
|
245 __ASSERT_ALWAYS(iStateChangePending, PanicNow(KPanicCustomCmdSimSecurityCheck, EInternalStateError)); |
|
246 DEBUGPRINT2A("Sim security state change completed with error %d", aResultCode); |
|
247 |
|
248 iStateChangePending = EFalse; |
|
249 if (aResultCode == KErrNone) |
|
250 { |
|
251 //Proceed with state change in case previous state completed with out any error |
|
252 SecurityCheckL(); |
|
253 } |
|
254 else |
|
255 { |
|
256 //Complete client request with result code |
|
257 CompleteClientRequest(aResultCode); |
|
258 } |
|
259 } |
|
260 |
|
261 void CCustomCmdSimSecurityCheck::CompleteClientRequest(TInt aReason) |
|
262 { |
|
263 //Complete client request with reason code |
|
264 if (iExecuteRequest) |
|
265 { |
|
266 User::RequestComplete(iExecuteRequest, aReason); |
|
267 } |
|
268 } |
|
269 |
|
270 void CCustomCmdSimSecurityCheck::SecurityCheckL() |
|
271 { |
|
272 //Delete the security notifier |
|
273 delete iSsmSecurityCheckNotifier; |
|
274 iSsmSecurityCheckNotifier = NULL; |
|
275 |
|
276 TInt errorCode = KErrNone; |
|
277 //Handle the state transition |
|
278 switch (iState) |
|
279 { |
|
280 case StartupAdaptation::ESIMPresent: |
|
281 HandleSIMPresent(); |
|
282 break; |
|
283 case StartupAdaptation::ESIMReadable: |
|
284 SimReadable(); |
|
285 break; |
|
286 case StartupAdaptation::ESIMInvalid: |
|
287 HandleSIMInvalid(); |
|
288 break; |
|
289 case StartupAdaptation::ESIMRejected: |
|
290 HandleSIMRejected(); |
|
291 break; |
|
292 case StartupAdaptation::ESIMBlocked: |
|
293 HandleSIMBlocked(); |
|
294 break; |
|
295 case StartupAdaptation::EPINRequired: |
|
296 HandlePINRequired(); |
|
297 break; |
|
298 case StartupAdaptation::ESIMLessOfflineSupported: |
|
299 HandleSIMLessOfflineSupported(); |
|
300 break; |
|
301 case StartupAdaptation::ESIMCodesOK: |
|
302 StartStateChange( StartupAdaptation::ESIMLock ); |
|
303 break; |
|
304 case StartupAdaptation::ESecurityCheckOK: |
|
305 errorCode = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSimOk ); |
|
306 if(KErrNone != errorCode) |
|
307 { |
|
308 DEBUGPRINT2A("Failed to set value of property CSsmUiSpecific::StarterPSUid() because of error %d", errorCode); |
|
309 } |
|
310 CompleteClientRequest(KErrNone); |
|
311 break; |
|
312 case StartupAdaptation::ESecurityCheckFailed: |
|
313 errorCode = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSimNok); |
|
314 if(KErrNone != errorCode) |
|
315 { |
|
316 DEBUGPRINT2A("Failed to set value of property CSsmUiSpecific::StarterPSUid() because of error %d", errorCode); |
|
317 } |
|
318 CompleteClientRequest(KErrNone); |
|
319 break; |
|
320 case StartupAdaptation::ESIMLock: |
|
321 if (iSecurityStateInfo == StartupAdaptation::ESimLockRestrictionOn) |
|
322 { |
|
323 StartSecurityNoteObserverL(); |
|
324 iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn); |
|
325 iSsmSecurityCheckNotifier->ShowNoteL(iStatus); |
|
326 SetActive(); |
|
327 } |
|
328 else |
|
329 { |
|
330 DoSecurityCheck(); |
|
331 } |
|
332 break; |
|
333 case StartupAdaptation::EAskPIN: |
|
334 case StartupAdaptation::EAskPUK: |
|
335 StartSecurityNoteObserverL(); |
|
336 iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(iNoteType); |
|
337 iSsmSecurityCheckNotifier->ShowNoteL(iStatus); |
|
338 SetActive(); |
|
339 break; |
|
340 default: |
|
341 CompleteClientRequest(KErrNotSupported); |
|
342 break; |
|
343 }; |
|
344 } |
|
345 |
|
346 void CCustomCmdSimSecurityCheck::DoSecurityCheck() |
|
347 { |
|
348 //Handle pending state transition |
|
349 switch (iState) |
|
350 { |
|
351 case StartupAdaptation::ESIMLock: |
|
352 HandleSIMLock(); |
|
353 break; |
|
354 case StartupAdaptation::EAskPIN: |
|
355 HandlePINAsked(); |
|
356 break; |
|
357 case StartupAdaptation::EAskPUK: |
|
358 HandlePUKAsked(); |
|
359 break; |
|
360 default: |
|
361 CompleteClientRequest(KErrNotSupported); |
|
362 break; |
|
363 }; |
|
364 } |
|
365 |
|
366 void CCustomCmdSimSecurityCheck::HandleSIMPresent() |
|
367 { |
|
368 switch (iSecurityStateInfo) |
|
369 { |
|
370 case StartupAdaptation::EYes: |
|
371 //Start sim readable state transition |
|
372 StartStateChange(StartupAdaptation::ESIMReadable); |
|
373 break; |
|
374 case StartupAdaptation::ENo: |
|
375 if (IsSimSupported()) |
|
376 { |
|
377 SimRemoved(); |
|
378 } |
|
379 else |
|
380 { |
|
381 SimNotSupported(); |
|
382 } |
|
383 break; |
|
384 default: |
|
385 DEBUGPRINT2A("Illegal security result in ESIMPresent state: %d", iSecurityStateInfo); |
|
386 CompleteClientRequest(KErrGeneral); |
|
387 break; |
|
388 }; |
|
389 } |
|
390 |
|
391 void CCustomCmdSimSecurityCheck::DoSimRemoved() |
|
392 { |
|
393 //Start sim less offline support state transition |
|
394 StartStateChange(StartupAdaptation::ESIMLessOfflineSupported); |
|
395 } |
|
396 |
|
397 void CCustomCmdSimSecurityCheck::DoSimNotSupported() |
|
398 { |
|
399 //Start sim less offline support state transition |
|
400 StartStateChange(StartupAdaptation::ESIMLessOfflineSupported); |
|
401 } |
|
402 |
|
403 void CCustomCmdSimSecurityCheck::DoSimReadable() |
|
404 { |
|
405 if(IsSsmInvalidSimOn()) |
|
406 { |
|
407 //Start sim invalid state transition |
|
408 StartStateChange(StartupAdaptation::ESIMInvalid); |
|
409 } |
|
410 else |
|
411 { |
|
412 //Start sim rejected state transition |
|
413 StartStateChange(StartupAdaptation::ESIMRejected); |
|
414 } |
|
415 } |
|
416 |
|
417 void CCustomCmdSimSecurityCheck::DoSimUsable() |
|
418 { |
|
419 TInt simStatus = ESimStatusUninitialized; |
|
420 TInt errVal = (iSimStatusPSObserver->GetValue(simStatus)); |
|
421 |
|
422 if (KErrNone == errVal) |
|
423 { |
|
424 //Do not observe if SIM status has already changed to ESimUsable |
|
425 if(simStatus == ESimUsable) |
|
426 { |
|
427 //Start security check ok state transition |
|
428 StartStateChange(StartupAdaptation::ESecurityCheckOK); |
|
429 } |
|
430 else |
|
431 { |
|
432 //Wait till the SIM status changes to ESimUsable. |
|
433 //Start observing for the P&S key change |
|
434 iSimStatusPSObserver->StartObserving(iStatus); |
|
435 iSubState = ESecuritySubStateSimStatusPSObserver; |
|
436 SetActive(); |
|
437 } |
|
438 } |
|
439 else |
|
440 { |
|
441 DEBUGPRINT2A("Error when getting SIM status value: %d", errVal); |
|
442 CompleteClientRequest(errVal); |
|
443 } |
|
444 } |
|
445 |
|
446 void CCustomCmdSimSecurityCheck::DoObserveSimStatusPS() |
|
447 { |
|
448 //Start security check ok state transition |
|
449 StartStateChange(StartupAdaptation::ESecurityCheckOK); |
|
450 } |
|
451 |
|
452 void CCustomCmdSimSecurityCheck::SimRemoved() |
|
453 { |
|
454 TUint simStatusPropertyKey = iSsmUiSpecific->SimStatusPropertyKey(); |
|
455 TSsmSwp swp(simStatusPropertyKey, ESimNotPresent); |
|
456 iSsmStateManager.RequestSwpChange(swp, iStatus); |
|
457 iSubState = ESecuritySubStateSimRemoved; |
|
458 SetActive(); |
|
459 } |
|
460 |
|
461 void CCustomCmdSimSecurityCheck::SimNotSupported() |
|
462 { |
|
463 TUint simStatusPropertyKey = iSsmUiSpecific->SimStatusPropertyKey(); |
|
464 TSsmSwp swp(simStatusPropertyKey, ESimNotSupported); |
|
465 iSsmStateManager.RequestSwpChange(swp, iStatus); |
|
466 iSubState = ESecuritySubStateSimNotSupported; |
|
467 SetActive(); |
|
468 } |
|
469 |
|
470 void CCustomCmdSimSecurityCheck::SimReadable() |
|
471 { |
|
472 TUint simStatusPropertyKey = iSsmUiSpecific->SimStatusPropertyKey(); |
|
473 TSsmSwp swp(simStatusPropertyKey, ESimReadable); |
|
474 iSsmStateManager.RequestSwpChange(swp, iStatus); |
|
475 iSubState = ESecuritySubStateSimReadable; |
|
476 SetActive(); |
|
477 } |
|
478 |
|
479 void CCustomCmdSimSecurityCheck::SimUsable() |
|
480 { |
|
481 TUint simStatusPropertyKey = iSsmUiSpecific->SimStatusPropertyKey(); |
|
482 TSsmSwp swp(simStatusPropertyKey, ESimUsable); |
|
483 iSsmStateManager.RequestSwpChange(swp, iStatus); |
|
484 iSubState = ESecuritySubStateSimUsable; |
|
485 SetActive(); |
|
486 } |
|
487 |
|
488 void CCustomCmdSimSecurityCheck::HandleSIMInvalid() |
|
489 { |
|
490 switch (iSecurityStateInfo) |
|
491 { |
|
492 case StartupAdaptation::EYes: |
|
493 |
|
494 //Publish the Sim Security Status as ESimInvalid |
|
495 RProperty::Set(iStartupPSUid, KStartupSimSecurityStatus, ESimInvalid); |
|
496 |
|
497 //Set the security state as failed |
|
498 SetSecurityStatus(EStrtSecurityCheckFailed); |
|
499 |
|
500 //Start sim less offline support state transition |
|
501 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
502 break; |
|
503 case StartupAdaptation::ENo: |
|
504 //Start sim rejected state transition |
|
505 StartStateChange(StartupAdaptation::ESIMRejected); |
|
506 break; |
|
507 default: |
|
508 DEBUGPRINT2A("Illegal security result in ESIMInvalid state: %d", iSecurityStateInfo); |
|
509 //Complete user request with KErrGeneral |
|
510 CompleteClientRequest(KErrGeneral); |
|
511 break; |
|
512 }; |
|
513 } |
|
514 |
|
515 |
|
516 void CCustomCmdSimSecurityCheck::HandleSIMRejected() |
|
517 { |
|
518 switch (iSecurityStateInfo) |
|
519 { |
|
520 case StartupAdaptation::EYes: |
|
521 RProperty::Set(iStartupPSUid, KStartupSimSecurityStatus, ESimRejected ); |
|
522 |
|
523 //Set the security state as failed |
|
524 SetSecurityStatus(EStrtSecurityCheckFailed); |
|
525 |
|
526 //Start sim less offline support state transition |
|
527 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
528 break; |
|
529 case StartupAdaptation::ENo: |
|
530 //Start sim blocked state transition |
|
531 StartStateChange(StartupAdaptation::ESIMBlocked); |
|
532 break; |
|
533 default: |
|
534 DEBUGPRINT2A("Illegal security result in ESIMRejected state: %d", iSecurityStateInfo); |
|
535 |
|
536 //Complete user request with KErrGeneral |
|
537 CompleteClientRequest(KErrGeneral); |
|
538 break; |
|
539 }; |
|
540 } |
|
541 |
|
542 void CCustomCmdSimSecurityCheck::HandleSIMBlocked() |
|
543 { |
|
544 switch (iSecurityStateInfo) |
|
545 { |
|
546 case StartupAdaptation::EPUK1Required: |
|
547 //Start PUK required state transition |
|
548 StartStateChange(StartupAdaptation::EAskPUK, ESecCodePUK1); |
|
549 break; |
|
550 case StartupAdaptation::EUPUKRequired: |
|
551 //Start UPUK required state transition |
|
552 StartStateChange(StartupAdaptation::EAskPUK, ESecCodeUPUK); |
|
553 break; |
|
554 case StartupAdaptation::ENo: |
|
555 //Start PIN required state transition |
|
556 StartStateChange(StartupAdaptation::EPINRequired); |
|
557 break; |
|
558 default: |
|
559 DEBUGPRINT2A("Illegal security result in ESIMBlocked state: %d", iSecurityStateInfo); |
|
560 |
|
561 //Complete user request with KErrGeneral |
|
562 CompleteClientRequest(KErrGeneral); |
|
563 break; |
|
564 }; |
|
565 } |
|
566 |
|
567 void CCustomCmdSimSecurityCheck::HandlePINRequired() |
|
568 { |
|
569 switch (iSecurityStateInfo) |
|
570 { |
|
571 case StartupAdaptation::EPIN1Required: |
|
572 //Start PIN required state transition |
|
573 StartStateChange(StartupAdaptation::EAskPIN, ESecCodePIN1); |
|
574 break; |
|
575 case StartupAdaptation::EUPINRequired: |
|
576 //Start UPIN required state transition |
|
577 StartStateChange(StartupAdaptation::EAskPIN, ESecCodeUPIN); |
|
578 break; |
|
579 case StartupAdaptation::ENo: |
|
580 //Start SIM Codes OK state transition |
|
581 StartStateChange(StartupAdaptation::ESIMCodesOK); |
|
582 break; |
|
583 default: |
|
584 DEBUGPRINT2A( "Illegal security result in EPINRequired state: %d", iSecurityStateInfo ); |
|
585 |
|
586 //Complete user request with KErrGeneral |
|
587 CompleteClientRequest(KErrGeneral); |
|
588 break; |
|
589 }; |
|
590 } |
|
591 |
|
592 void CCustomCmdSimSecurityCheck::HandleSIMLessOfflineSupported() |
|
593 { |
|
594 if (IsSimSupported()) |
|
595 { |
|
596 if (iSsmUiSpecific->IsSimlessOfflineSupported()) |
|
597 { |
|
598 //SIMless offline is supported |
|
599 |
|
600 //Set the security state as Sim less offline |
|
601 SetSecurityStatus(EStrtSimlessOffline); |
|
602 StartStateChange(StartupAdaptation::ESIMLock); |
|
603 } |
|
604 else |
|
605 { |
|
606 //SIMless offline is not supported |
|
607 |
|
608 //Set the security state as failed |
|
609 SetSecurityStatus(EStrtSecurityCheckFailed); |
|
610 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
611 } |
|
612 } |
|
613 else |
|
614 { |
|
615 //SIM not supported |
|
616 SetSecurityStatus(EStrtSimlessOffline); |
|
617 StartStateChange(StartupAdaptation::ESIMLock); |
|
618 } |
|
619 } |
|
620 |
|
621 TBool CCustomCmdSimSecurityCheck::IsSimSupported() |
|
622 { |
|
623 return iSsmUiSpecific->IsSimSupported(); |
|
624 } |
|
625 |
|
626 void CCustomCmdSimSecurityCheck::HandleSIMLock() |
|
627 { |
|
628 switch(iSecurityStateInfo) |
|
629 { |
|
630 case StartupAdaptation::ESimLockRestricted: |
|
631 //Set the sim lock status property to "Sim lock active" |
|
632 RProperty::Set(iStartupPSUid, KStartupSimLockStatus, ESimLockActive ); |
|
633 |
|
634 //Set the sim security status property to "Sim unaccepted" |
|
635 RProperty::Set(iStartupPSUid, KStartupSimSecurityStatus, ESimUnaccepted ); |
|
636 |
|
637 //Set the security state as failed |
|
638 SetSecurityStatus(EStrtSecurityCheckFailed); |
|
639 |
|
640 //Start security check failed state transition |
|
641 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
642 break; |
|
643 case StartupAdaptation::ESimLockOk: |
|
644 //Set the sim lock status property to "Sim lock ok" |
|
645 RProperty::Set(iStartupPSUid, KStartupSimLockStatus, ESimLockOk ); |
|
646 SetSecurityCheckOK(); |
|
647 break; |
|
648 case StartupAdaptation::ESimLockRestrictionOn: |
|
649 //Set the sim lock status property to "Sim lock restriction on" |
|
650 RProperty::Set(iStartupPSUid, KStartupSimLockStatus, ESimLockRestrictionOn); |
|
651 SetSecurityCheckOK(); |
|
652 break; |
|
653 case StartupAdaptation::ESimLockRestrictionPending: |
|
654 //Set the sim lock status property to "Sim lock restriction pending" |
|
655 RProperty::Set(iStartupPSUid, KStartupSimLockStatus, ESimLockRestrictionPending); |
|
656 |
|
657 //Set the sim security status property to "Sim unaccepted" |
|
658 RProperty::Set(iStartupPSUid, KStartupSimSecurityStatus, ESimUnaccepted); |
|
659 |
|
660 //Set the security state as failed |
|
661 SetSecurityStatus( EStrtSecurityCheckFailed); |
|
662 |
|
663 //Start security check failed state transition |
|
664 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
665 break; |
|
666 default: |
|
667 DEBUGPRINT2A("Illegal security result in ESIMLock state: %d", iSecurityStateInfo); |
|
668 //Complete user request with KErrGeneral |
|
669 CompleteClientRequest(KErrGeneral); |
|
670 break; |
|
671 } |
|
672 |
|
673 } |
|
674 |
|
675 void CCustomCmdSimSecurityCheck::SetSecurityCheckOK() |
|
676 { |
|
677 if (SecurityStatus() != EStrtSimlessOffline) |
|
678 { |
|
679 //Set the security state as passed |
|
680 SetSecurityStatus( EStrtSecurityCheckPassed); |
|
681 SimUsable(); |
|
682 } |
|
683 else |
|
684 { |
|
685 //Start security check ok state transition |
|
686 StartStateChange(StartupAdaptation::ESecurityCheckOK); |
|
687 } |
|
688 } |
|
689 |
|
690 |
|
691 void CCustomCmdSimSecurityCheck::HandlePINAsked() |
|
692 { |
|
693 __ASSERT_DEBUG(NULL != iSsmSecurityCheckNotifier, PanicNow(KPanicCustomCmdSimSecurityCheck, ECmdNullPtr)); |
|
694 |
|
695 const TBool isCodeAccepted = iSsmSecurityCheckNotifier->IsCodeAccepted(); |
|
696 |
|
697 //Try again until PIN is either accepted or blocked. |
|
698 if (isCodeAccepted) |
|
699 { |
|
700 //Start SIM codes ok state transition |
|
701 StartStateChange(StartupAdaptation::ESIMCodesOK); |
|
702 } |
|
703 else |
|
704 { |
|
705 switch(iNoteType) |
|
706 { |
|
707 case ESecCodePIN1: |
|
708 //Start security code PUK1 state transition |
|
709 StartStateChange(StartupAdaptation::EAskPUK, ESecCodePUK1); |
|
710 break; |
|
711 case ESecCodeUPIN: |
|
712 //Start security code UPUK state transition |
|
713 StartStateChange(StartupAdaptation::EAskPUK, ESecCodeUPUK); |
|
714 break; |
|
715 default: |
|
716 DEBUGPRINT2A("Illegal code type in EAskPIN state: %d", iNoteType); |
|
717 //Complete user request with KErrGeneral |
|
718 CompleteClientRequest(KErrGeneral); |
|
719 break; |
|
720 } |
|
721 } |
|
722 } |
|
723 |
|
724 void CCustomCmdSimSecurityCheck::HandlePUKAsked() |
|
725 { |
|
726 __ASSERT_DEBUG(NULL != iSsmSecurityCheckNotifier, PanicNow(KPanicCustomCmdSimSecurityCheck, ECmdNullPtr)); |
|
727 |
|
728 //Is the entered code correct |
|
729 const TBool isCodeAccepted = iSsmSecurityCheckNotifier->IsCodeAccepted(); |
|
730 |
|
731 if (isCodeAccepted) |
|
732 { |
|
733 //Start SIM code ok state transition |
|
734 StartStateChange(StartupAdaptation::ESIMCodesOK); |
|
735 } |
|
736 else |
|
737 { |
|
738 //Set the Sim security status property to "Sim rejected" |
|
739 RProperty::Set(iStartupPSUid, KStartupSimSecurityStatus, ESimRejected); |
|
740 |
|
741 //Set the security state as failed |
|
742 SetSecurityStatus(EStrtSecurityCheckFailed); |
|
743 |
|
744 //Start security check failed state transition |
|
745 StartStateChange(StartupAdaptation::ESecurityCheckFailed); |
|
746 } |
|
747 } |
|
748 |
|
749 void CCustomCmdSimSecurityCheck::SetSecurityStatus(const TStrtSecurityStatus& aSecurityStatus) |
|
750 { |
|
751 iSsmUiSpecific->SetSecurityStatus(aSecurityStatus); |
|
752 } |
|
753 |
|
754 TStrtSecurityStatus CCustomCmdSimSecurityCheck::SecurityStatus() const |
|
755 { |
|
756 return iSsmUiSpecific->SecurityStatus(); |
|
757 } |
|
758 |
|
759 void CCustomCmdSimSecurityCheck::StartSecurityNoteObserverL() |
|
760 { |
|
761 if(!iSecurityNoteObserver) |
|
762 { |
|
763 iSecurityNoteObserver = CSecurityNoteObserver::NewL(); |
|
764 } |
|
765 } |
|
766 |
|
767 TInt CCustomCmdSimSecurityCheck::RunError(TInt aError) |
|
768 { |
|
769 //Do the final cleanup incase of error |
|
770 Cleanup(aError); |
|
771 return KErrNone; |
|
772 } |
|
773 |
|
774 void CCustomCmdSimSecurityCheck::DoCancel() |
|
775 { |
|
776 // Cancel all possible requests that could be outstanding on iStatus |
|
777 if(iSsmSecurityCheckNotifier) |
|
778 { |
|
779 iSsmSecurityCheckNotifier->Cancel(); |
|
780 } |
|
781 if(iSecurityNoteObserver) |
|
782 { |
|
783 iSecurityNoteObserver->Cancel(); |
|
784 } |
|
785 iSsmMiscAdaptation.Cancel(); |
|
786 iSsmStateManager.RequestSwpChangeCancel(); |
|
787 iSimStatusPSObserver->Cancel(); |
|
788 } |
|
789 |
|
790 void CCustomCmdSimSecurityCheck::ExecuteCancel() |
|
791 { |
|
792 //Call cancel method of CActive |
|
793 Cancel(); |
|
794 |
|
795 //Do the final cleanup before cancelling |
|
796 Cleanup(KErrCancel); |
|
797 } |
|
798 |
|
799 void CCustomCmdSimSecurityCheck::Cleanup(TInt aError) |
|
800 { |
|
801 if (iExecuteRequest) |
|
802 { |
|
803 //Complete the user request with the given error code |
|
804 User::RequestComplete(iExecuteRequest, aError); |
|
805 } |
|
806 } |
|
807 |
|
808 // CSsmSimStatusPSObserver |
|
809 // Active Object Class that observes for SIM status P&S key change |
|
810 CSsmSimStatusPSObserver* CSsmSimStatusPSObserver::NewL(TUid aCategory, TUint aKey) |
|
811 { |
|
812 CSsmSimStatusPSObserver* self = new (ELeave) CSsmSimStatusPSObserver(aCategory, aKey); |
|
813 CleanupStack::PushL(self); |
|
814 self->ConstructL(); |
|
815 CleanupStack::Pop(self); |
|
816 return self; |
|
817 } |
|
818 |
|
819 void CSsmSimStatusPSObserver::ConstructL() |
|
820 { |
|
821 User::LeaveIfError(iProperty.Attach(iCategory, iKey)); |
|
822 } |
|
823 |
|
824 CSsmSimStatusPSObserver::CSsmSimStatusPSObserver(TUid aCategory, TUint aKey) |
|
825 : CActive(EPriorityStandard), iCategory(aCategory), iKey(aKey) |
|
826 { |
|
827 CActiveScheduler::Add(this); |
|
828 } |
|
829 |
|
830 CSsmSimStatusPSObserver::~CSsmSimStatusPSObserver() |
|
831 { |
|
832 Cancel(); |
|
833 iProperty.Close(); |
|
834 } |
|
835 |
|
836 void CSsmSimStatusPSObserver::StartObserving(TRequestStatus& aStatus) |
|
837 { |
|
838 __ASSERT_DEBUG(!(IsActive()), PanicNow(KPanicCustomCmdSimSecurityCheck, EInternalStateError)); |
|
839 aStatus = KRequestPending; |
|
840 iClientStatus = &aStatus; |
|
841 iProperty.Subscribe(iStatus); |
|
842 SetActive(); |
|
843 } |
|
844 |
|
845 TInt CSsmSimStatusPSObserver::GetValue(TInt& aValue) |
|
846 { |
|
847 TInt errVal = (iProperty.Get(aValue)); |
|
848 return errVal; |
|
849 } |
|
850 |
|
851 void CSsmSimStatusPSObserver::DoCancel() |
|
852 { |
|
853 iProperty.Cancel(); |
|
854 Complete(KErrCancel); |
|
855 } |
|
856 |
|
857 void CSsmSimStatusPSObserver::RunL() |
|
858 { |
|
859 Complete(iStatus.Int()); |
|
860 } |
|
861 |
|
862 void CSsmSimStatusPSObserver::Complete(const TInt aErrorCode) |
|
863 { |
|
864 if (iClientStatus) |
|
865 { |
|
866 User::RequestComplete(iClientStatus, aErrorCode); |
|
867 iClientStatus = NULL; |
|
868 } |
|
869 } |