1 /* |
|
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handles RefreshRequired command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <msatrefreshobserver.h> |
|
22 #include "MSatSSimSubscriberId.h" |
|
23 #include "MSatSystemState.h" |
|
24 #include "MSatEventMonitorContainer.h" |
|
25 #include "MSatSUiClientHandler.h" |
|
26 #include "CRefreshRequiredHandler.h" |
|
27 #include "MSatApi.h" |
|
28 #include "MSatUtils.h" |
|
29 #include "MSatBIPUtils.h" |
|
30 #include "MSatUiSession.h" |
|
31 #include "SatSOpcodes.h" |
|
32 #include "MSatRefreshSubSession.h" |
|
33 #include "msatmultimodeapi.h" |
|
34 #include "SatLog.h" |
|
35 |
|
36 // CONSTANTS |
|
37 const TInt KAidMinSize( 12 ); |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CRefreshRequiredHandler::CRefreshRequiredHandler |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 //lint -e{1403, 1769} Can not be initialized, harmless. |
|
49 CRefreshRequiredHandler::CRefreshRequiredHandler() : |
|
50 CSatCommandHandler(), |
|
51 iRefreshRequiredData(), |
|
52 iRefreshRequiredPckg( iRefreshRequiredData ), |
|
53 iRefreshRequiredRsp(), |
|
54 iRefreshRequiredRspPckg( iRefreshRequiredRsp ), |
|
55 iQueryData(), |
|
56 iQueryPckg( iQueryData ), |
|
57 iQueryRsp(), |
|
58 iQueryRspPckg( iQueryRsp ), |
|
59 iRefreshQueryClientCount( 0 ), |
|
60 iAllowRefresh( ETrue ) |
|
61 { |
|
62 LOG( SIMPLE, "REFRESHREQ: \ |
|
63 CRefreshRequiredHandler::CRefreshRequiredHandler calling - exiting" ) |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CRefreshRequiredHandler::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CRefreshRequiredHandler::ConstructL() |
|
72 { |
|
73 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ConstructL calling" ) |
|
74 |
|
75 // Register events to be listen. |
|
76 iUtils->RegisterL( this, MSatUtils::ERefreshAllowed ); |
|
77 iUtils->RegisterL( this, MSatUtils::ERefreshNotAllowed ); |
|
78 |
|
79 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ConstructL exiting" ) |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CRefreshRequiredHandler::NewL |
|
84 // Two-phased constructor. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CRefreshRequiredHandler* CRefreshRequiredHandler::NewL( MSatUtils* aUtils ) |
|
88 { |
|
89 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::NewL calling" ) |
|
90 |
|
91 CRefreshRequiredHandler* self = new( ELeave ) CRefreshRequiredHandler; |
|
92 |
|
93 CleanupStack::PushL( self ); |
|
94 self->BaseConstructL( aUtils ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::NewL exiting" ) |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // Destructor |
|
104 CRefreshRequiredHandler::~CRefreshRequiredHandler() |
|
105 { |
|
106 LOG( SIMPLE, "REFRESHREQ: \ |
|
107 CRefreshRequiredHandler::~CRefreshRequiredHandler calling" ) |
|
108 |
|
109 Cancel(); |
|
110 |
|
111 LOG( SIMPLE, "REFRESHREQ: \ |
|
112 CRefreshRequiredHandler::~CRefreshRequiredHandler exiting" ) |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CRefreshRequiredHandler::Event |
|
117 // (other items were commented in a header). |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CRefreshRequiredHandler::Event( TInt aEvent ) |
|
121 { |
|
122 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::Event calling" ) |
|
123 |
|
124 switch ( aEvent ) |
|
125 { |
|
126 case MSatUtils::ERefreshAllowed: |
|
127 { |
|
128 LOG( NORMAL, "REFRESHREQ: Event: ERefreshAllowed" ) |
|
129 AllowRefresh( ETrue ); |
|
130 break; |
|
131 } |
|
132 |
|
133 case MSatUtils::ERefreshNotAllowed: |
|
134 { |
|
135 LOG( NORMAL, "REFRESHREQ: Event: ERefreshNotAllowed" ) |
|
136 AllowRefresh( EFalse ); |
|
137 break; |
|
138 } |
|
139 |
|
140 default: |
|
141 { |
|
142 LOG2( NORMAL, "REFRESHREQ: Event: %i", aEvent ) |
|
143 CSatCommandHandler::Event( aEvent ); |
|
144 break; |
|
145 } |
|
146 } |
|
147 |
|
148 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::Event exiting" ) |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CRefreshRequiredHandler::ClientResponse |
|
153 // (other items were commented in a header). |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CRefreshRequiredHandler::ClientResponse() |
|
157 { |
|
158 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ClientResponse calling" ) |
|
159 TBool commandAllowed( ETrue ); |
|
160 |
|
161 // Check ui client response for accepting refresh. |
|
162 if ( iQueryRsp.iAccepted ) |
|
163 { |
|
164 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ClientResponse \ |
|
165 accept refresh" ) |
|
166 // Check phone state again, whether refresh is still allowed, |
|
167 if ( BusyNotAllowed() ) |
|
168 { |
|
169 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ClientResponse \ |
|
170 BusyNotAllowed" ) |
|
171 // Refresh not allowed due phone is busy. |
|
172 iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 ); |
|
173 iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KMeBusyOnCall; |
|
174 commandAllowed = EFalse; |
|
175 } |
|
176 } |
|
177 // Client did not accept refresh. |
|
178 else |
|
179 { |
|
180 // Refresh is prevented by the user |
|
181 iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 ); |
|
182 iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KScreenBusy; |
|
183 commandAllowed = EFalse; |
|
184 |
|
185 if ( iQueryRsp.iSessionTerminatedByUser ) |
|
186 { |
|
187 LOG( SIMPLE, "REFRESHREQ: close the ui session" ) |
|
188 // Next SimSession end will close the ui session |
|
189 iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser ); |
|
190 } |
|
191 LOG( SIMPLE, "REFRESHREQ: User did not accept refresh" ) |
|
192 } |
|
193 |
|
194 if ( commandAllowed ) |
|
195 { |
|
196 LOG( SIMPLE, "REFRESHREQ: commandAllowed" ) |
|
197 // Refresh allowed. |
|
198 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
199 iRefreshRequiredRsp.iGeneralResult = RSat::KSuccess; |
|
200 |
|
201 if ( RSat::ESimReset == iRefreshRequiredData.iType ) |
|
202 { |
|
203 LOG( SIMPLE, "REFRESHREQ: ESimReset" ) |
|
204 iUtils->NotifyEvent( MSatUtils::ESimResetCalled ); |
|
205 } |
|
206 } |
|
207 else |
|
208 { |
|
209 // Notify clients already allowed Refresh about cancel. |
|
210 NotifyRefreshClientsCancel(); |
|
211 |
|
212 // Refresh not allowed. |
|
213 iRefreshRequiredRsp.iInfoType = RSat::KMeProblem; |
|
214 iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
215 } |
|
216 |
|
217 // Send the response |
|
218 iRefreshRequiredRsp.SetPCmdNumber( iRefreshRequiredData.PCmdNumber() ); |
|
219 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
220 |
|
221 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::ClientResponse exiting" ) |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CRefreshRequiredHandler::DoCancel |
|
226 // Cancels the sat request. |
|
227 // (other items were commented in a header). |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CRefreshRequiredHandler::DoCancel() |
|
231 { |
|
232 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoCancel calling" ) |
|
233 |
|
234 iUtils->USatAPI().NotifyRefreshRequiredCancel(); |
|
235 |
|
236 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoCancel exiting" ) |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CRefreshRequiredHandler::IssueUSATRequest |
|
241 // (other items were commented in a header). |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CRefreshRequiredHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
245 { |
|
246 LOG( SIMPLE, |
|
247 "REFRESHREQ: CRefreshRequiredHandler::IssueUSATRequest calling" ) |
|
248 |
|
249 // Clear the IPC package. |
|
250 new (&iRefreshRequiredData) RSat::TRefreshV2(); |
|
251 iQueryRsp.iAccepted = EFalse; // default |
|
252 |
|
253 iUtils->USatAPI().NotifyRefreshRequired( aStatus, iRefreshRequiredPckg ); |
|
254 |
|
255 LOG( SIMPLE, |
|
256 "REFRESHREQ: CRefreshRequiredHandler::IssueUSATRequest exiting" ) |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CRefreshRequiredHandler::CommandAllowed |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TBool CRefreshRequiredHandler::CommandAllowed() |
|
265 { |
|
266 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::CommandAllowed calling" ) |
|
267 TBool commandAllowed( ETrue ); |
|
268 |
|
269 #ifdef ENABLE_SAT_LOGGING |
|
270 |
|
271 // Log Refresh type. |
|
272 switch ( iRefreshRequiredData.iType ) |
|
273 { |
|
274 case RSat::ERefreshTypeNotSet: |
|
275 { |
|
276 LOG( NORMAL, |
|
277 "REFRESHREQ: Refresh type: ERefreshTypeNotSet" ) |
|
278 break; |
|
279 } |
|
280 |
|
281 case RSat::ESimInitFullFileChangeNotification: |
|
282 { |
|
283 LOG( NORMAL, |
|
284 "REFRESHREQ: Refresh type: ESimInitFullFileChangeNotificat." ) |
|
285 break; |
|
286 } |
|
287 |
|
288 case RSat::EFileChangeNotification: |
|
289 { |
|
290 LOG( NORMAL, |
|
291 "REFRESHREQ: Refresh type: EFileChangeNotification" ) |
|
292 break; |
|
293 } |
|
294 |
|
295 case RSat::ESimInitFileChangeNotification: |
|
296 { |
|
297 LOG( NORMAL, |
|
298 "REFRESHREQ: Refresh type: ESimInitFileChangeNotification" ) |
|
299 break; |
|
300 } |
|
301 |
|
302 case RSat::ESimInit: |
|
303 { |
|
304 LOG( NORMAL, |
|
305 "REFRESHREQ: Refresh type: ESimInit" ) |
|
306 break; |
|
307 } |
|
308 |
|
309 case RSat::ESimReset: |
|
310 { |
|
311 LOG( NORMAL, |
|
312 "REFRESHREQ: Refresh type: ESimReset" ) |
|
313 break; |
|
314 } |
|
315 |
|
316 case RSat::EUsimApplicationReset: |
|
317 { |
|
318 LOG( NORMAL, |
|
319 "REFRESHREQ: Refresh type: EUsimApplicationReset" ) |
|
320 break; |
|
321 } |
|
322 |
|
323 case RSat::E3GSessionReset: |
|
324 { |
|
325 LOG( NORMAL, |
|
326 "REFRESHREQ: Refresh type: E3GSessionReset" ) |
|
327 break; |
|
328 } |
|
329 |
|
330 default: |
|
331 { |
|
332 LOG2( NORMAL, |
|
333 "REFRESHREQ: Refresh type: unknown %d", |
|
334 iRefreshRequiredData.iType ) |
|
335 break; |
|
336 } |
|
337 } |
|
338 |
|
339 // Log the file list. |
|
340 TInt fileCount ( iRefreshRequiredData.iFileList.Length() ); |
|
341 LOG2( NORMAL, "REFRESHREQ: Refresh file count: %d", fileCount ) |
|
342 for ( TInt fileIndex = 0; fileIndex < fileCount; fileIndex++ ) |
|
343 { |
|
344 LOG2( NORMAL, "REFRESHREQ: Refresh file: %x", |
|
345 iRefreshRequiredData.iFileList[ fileIndex ] ) |
|
346 } |
|
347 |
|
348 #endif |
|
349 |
|
350 // Check EFimsi file refresh type. |
|
351 if ( !EFIMSIRefreshAllowed() ) |
|
352 { |
|
353 LOG( NORMAL, "REFRESHREQ: EFIMSIRefreshAllowed false" ) |
|
354 // Refresh not allowed |
|
355 iRefreshRequiredRsp.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
356 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
357 commandAllowed = EFalse; |
|
358 } |
|
359 // Check phone state. |
|
360 else if ( BusyNotAllowed() ) |
|
361 { |
|
362 LOG( NORMAL, "REFRESHREQ: BusyNotAllowed true" ) |
|
363 // Refresh not allowed |
|
364 iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
365 iRefreshRequiredRsp.iInfoType = RSat::KMeProblem; |
|
366 iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 ); |
|
367 iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KMeBusyOnCall; |
|
368 commandAllowed = EFalse; |
|
369 } |
|
370 //Check the AidState. |
|
371 else |
|
372 { |
|
373 const TAidState aidState = AidState(); |
|
374 LOG2( NORMAL, "REFRESHREQ: AID state: %i", aidState ) |
|
375 switch ( aidState ) |
|
376 { |
|
377 case EAidNotActive: |
|
378 { |
|
379 iRefreshRequiredRsp.iGeneralResult = |
|
380 RSat::KRefreshUSIMNotActive; |
|
381 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
382 commandAllowed = EFalse; |
|
383 break; |
|
384 } |
|
385 |
|
386 case EAidInvalid: |
|
387 { |
|
388 iRefreshRequiredRsp.iGeneralResult = |
|
389 RSat::KCmdDataNotUnderstood; |
|
390 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
391 commandAllowed = EFalse; |
|
392 break; |
|
393 } |
|
394 |
|
395 default: |
|
396 { |
|
397 LOG( NORMAL, "REFRESHREQ: Refresh allowed" ) |
|
398 break; |
|
399 } |
|
400 } |
|
401 } |
|
402 |
|
403 // When refresh is not allowed, send terminal response to sim. |
|
404 if ( !commandAllowed ) |
|
405 { |
|
406 LOG( NORMAL, "REFRESHREQ: Refresh not allowed" ) |
|
407 iRefreshRequiredRsp.SetPCmdNumber( iRefreshRequiredData.PCmdNumber() ); |
|
408 |
|
409 // Send the response |
|
410 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
411 } |
|
412 |
|
413 LOG2( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::CommandAllowed \ |
|
414 exiting, commandAllowed: %d", commandAllowed ) |
|
415 return commandAllowed; |
|
416 } |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // CRefreshRequiredHandler::NeedUiSession |
|
420 // (other items were commented in a header). |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 TBool CRefreshRequiredHandler::NeedUiSession() |
|
424 { |
|
425 LOG( NORMAL, "REFRESHREQ: CRefreshRequiredHandler::NeedUiSession calling" ) |
|
426 TBool needUiSession( EFalse ); |
|
427 |
|
428 if ( RSat::ESimReset == iRefreshRequiredData.iType |
|
429 && iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
430 { |
|
431 LOG( NORMAL, "REFRESHREQ: Need ui session" ) |
|
432 needUiSession = ETrue; |
|
433 } |
|
434 |
|
435 // Notify Cover UI if it's supported |
|
436 if ( needUiSession && iUtils->CoverUiSupported() ) |
|
437 { |
|
438 LOG( NORMAL, "REFRESHREQ: CoverUiSupported" ) |
|
439 TSatCommandData medEventData; |
|
440 medEventData.iPCmdNumber = RSat::ERefresh; |
|
441 |
|
442 //Doesn't have alpha id |
|
443 medEventData.iAlphaId.iStatus = RSat::EAlphaIdNotSet; |
|
444 medEventData.iDuration.iNumOfUnits = KSatSustainedDuration; |
|
445 medEventData.iDuration.iTimeUnit = RSat::ESeconds; |
|
446 medEventData.iIconID.iQualifier = RSat::ENoIconId; |
|
447 |
|
448 TSatCommandPckg tPckg( medEventData ); |
|
449 iUtils->RaiseSatEvent( tPckg ); |
|
450 } |
|
451 |
|
452 LOG2( NORMAL, "REFRESHREQ: CRefreshRequiredHandler::NeedUiSession exiting\ |
|
453 needUiSession: %d", needUiSession ) |
|
454 return needUiSession; |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CRefreshRequiredHandler::HandleCommand |
|
459 // (other items were commented in a header). |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 void CRefreshRequiredHandler::HandleCommand() |
|
463 { |
|
464 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::HandleCommand calling" ) |
|
465 |
|
466 // Ask permission from clients. |
|
467 if ( QueryRefreshClients() ) |
|
468 { |
|
469 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::HandleCommand \ |
|
470 refresh" ) |
|
471 DoRefresh(); |
|
472 } |
|
473 |
|
474 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::HandleCommand exiting" ) |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CRefreshRequiredHandler::UiLaunchFailed |
|
479 // (other items were commented in a header). |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CRefreshRequiredHandler::UiLaunchFailed() |
|
483 { |
|
484 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::UiLaunchFailed calling" ) |
|
485 |
|
486 iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
487 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
488 iRefreshRequiredRsp.SetPCmdNumber( iRefreshRequiredData.PCmdNumber() ); |
|
489 |
|
490 // Send the response |
|
491 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
492 |
|
493 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::UiLaunchFailed exiting" ) |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CRefreshRequiredHandler::EFIMSIRefreshAllowed |
|
498 // If an EFimsi file change occurs under certain conditions a refresh is not |
|
499 // allowed. |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 TBool CRefreshRequiredHandler::EFIMSIRefreshAllowed() const |
|
503 { |
|
504 LOG( SIMPLE, |
|
505 "REFRESHREQ: CRefreshRequiredHandler::EFIMSIRefreshAllowed calling" ) |
|
506 TBool refreshAllowed( ETrue ); |
|
507 |
|
508 // If changed file is EFimsi and the refresh type is any of the ones |
|
509 // specifed below, no refresh will take place as the behaviour of the UE |
|
510 // is unpredicatable. |
|
511 if ( RSat::EFileChangeNotification == iRefreshRequiredData.iType ) |
|
512 { |
|
513 LOG( SIMPLE, |
|
514 "REFRESHREQ: CRefreshRequiredHandler::EFIMSIRefreshAllowed \ |
|
515 EFileChangeNotification" ) |
|
516 const TChar efImsi( RSat::KImsiEf ); |
|
517 const TInt imsi( iRefreshRequiredData.iFileList.Locate( efImsi ) ); |
|
518 |
|
519 // Does the EFimsi file want to be updated. |
|
520 if ( KErrNotFound != imsi ) |
|
521 { |
|
522 LOG( SIMPLE, "REFRESHREQ: EFImsi file refresh not allowed" ) |
|
523 refreshAllowed = EFalse; |
|
524 } |
|
525 } |
|
526 |
|
527 LOG2( SIMPLE, |
|
528 "REFRESHREQ: CRefreshRequiredHandler::EFIMSIRefreshAllowed exiting,\ |
|
529 refreshAllowed: %d", refreshAllowed ) |
|
530 return refreshAllowed; |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CRefreshRequiredHandler::BusyNotAllowed |
|
535 // Check whether Refresh is allowed. |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 TBool CRefreshRequiredHandler::BusyNotAllowed() |
|
539 { |
|
540 LOG( SIMPLE, |
|
541 "REFRESHREQ: CRefreshRequiredHandler::BusyNotAllowed calling" ) |
|
542 TBool notAllowed( EFalse ); |
|
543 |
|
544 // Busy checked only for reset due only it may prevent call. |
|
545 if ( RSat::EFileChangeNotification != iRefreshRequiredData.iType ) |
|
546 { |
|
547 LOG( SIMPLE, |
|
548 "REFRESHREQ: CRefreshRequiredHandler::EFIMSIRefreshAllowed \ |
|
549 not EFileChangeNotification" ) |
|
550 // Refresh is not allowed when call is active or incoming. |
|
551 if ( iUtils->SystemState().IsCallActive() || |
|
552 iUtils->SystemState().IsCallIncoming() ) |
|
553 { |
|
554 notAllowed = ETrue; |
|
555 LOG( NORMAL, "REFRESHREQ: Refresh not allowed: phone is busy" ) |
|
556 } |
|
557 } |
|
558 |
|
559 LOG2( SIMPLE, |
|
560 "REFRESHREQ: CRefreshRequiredHandler::BusyNotAllowed exiting,\ |
|
561 notAllowed: %d", notAllowed ) |
|
562 return notAllowed; |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // CRefreshRequiredHandler::QueryRefreshClients |
|
567 // Notifies the observers that refresh query should start. |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 TBool CRefreshRequiredHandler::QueryRefreshClients() |
|
571 { |
|
572 LOG( SIMPLE, |
|
573 "REFRESHREQ: CRefreshRequiredHandler::QueryRefreshClients calling" ) |
|
574 TBool allowNow( ETrue ); |
|
575 TInt clientCount( iUtils->RefreshSubSessions().Count() ); |
|
576 |
|
577 // By default refresh is allowed after all clients have queried. |
|
578 iAllowRefresh = ETrue; |
|
579 |
|
580 // When there are clients, we must ask them first and refresh will be |
|
581 // started later, after all clients have allowed it. |
|
582 // When there are clients, we can just start refresh. |
|
583 if ( 0 != clientCount ) |
|
584 { |
|
585 LOG2( NORMAL, "REFRESHREQ: Client count: %d", clientCount ) |
|
586 allowNow = EFalse; |
|
587 iRefreshQueryClientCount = clientCount; |
|
588 for ( TInt i = 0; i < clientCount; i++ ) |
|
589 { |
|
590 iUtils->RefreshSubSessions()[i]->QueryClient( |
|
591 iRefreshRequiredData ); |
|
592 } |
|
593 } |
|
594 |
|
595 LOG2( SIMPLE, |
|
596 "REFRESHREQ: CRefreshRequiredHandler::QueryRefreshClients exiting,\ |
|
597 allowNow: %d", allowNow ) |
|
598 return allowNow; |
|
599 } |
|
600 |
|
601 // ----------------------------------------------------------------------------- |
|
602 // CRefreshRequiredHandler::AllowRefresh |
|
603 // Waits for all the responses of refresh query and |
|
604 // starts or declines the refresh. |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 void CRefreshRequiredHandler::AllowRefresh( TBool aAllow ) |
|
608 { |
|
609 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AllowRefresh calling" ) |
|
610 LOG2( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AllowRefresh \ |
|
611 iAllowRefresh: %d", iAllowRefresh ) |
|
612 LOG2( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AllowRefresh \ |
|
613 iRefreshQueryClientCount: %d", iRefreshQueryClientCount ) |
|
614 // if iAllowRefresh already false no need to set new value. |
|
615 if ( iAllowRefresh ) |
|
616 { |
|
617 iAllowRefresh = aAllow; |
|
618 } |
|
619 |
|
620 // Check whether all clients have replied. |
|
621 iRefreshQueryClientCount--; |
|
622 if ( iRefreshQueryClientCount <= 0 ) |
|
623 { |
|
624 if ( iAllowRefresh ) |
|
625 { |
|
626 DoRefresh(); |
|
627 } |
|
628 else |
|
629 { |
|
630 LOG( NORMAL, "REFRESHREQ: At least one client rejected refresh" ) |
|
631 // Notify clients already allowed Refresh about cancel. |
|
632 NotifyRefreshClientsCancel(); |
|
633 |
|
634 // Construct a proper refresh response data package |
|
635 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
636 iRefreshRequiredRsp.SetPCmdNumber( |
|
637 iRefreshRequiredData.PCmdNumber() ); |
|
638 iRefreshRequiredRsp.iGeneralResult = RSat::KPCmdNotAcceptedByUser; |
|
639 |
|
640 // Send the response |
|
641 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
642 } |
|
643 } |
|
644 |
|
645 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AllowRefresh exiting" ) |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CRefreshRequiredHandler::DoRefresh |
|
650 // Starts the refresh |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 void CRefreshRequiredHandler::DoRefresh() |
|
654 { |
|
655 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh calling" ) |
|
656 |
|
657 if ( RSat::ESimReset == iRefreshRequiredData.iType ) |
|
658 { |
|
659 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh \ |
|
660 ESimReset" ) |
|
661 // Register service request handler for RefreshRequired command, |
|
662 // If there is already service request for query, registering |
|
663 // updates command handler, so client responses comes to this |
|
664 // command handler. |
|
665 TRAPD( err, iUtils->RegisterServiceRequestL( |
|
666 ESatSProactiveQuery, |
|
667 ESatSProactiveQueryResponse, |
|
668 this ) ); |
|
669 |
|
670 if ( KErrNone != err ) |
|
671 { |
|
672 iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
673 iRefreshRequiredRsp.iInfoType = RSat::KMeProblem; |
|
674 iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 ); |
|
675 iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
676 iRefreshRequiredRsp.SetPCmdNumber( |
|
677 iRefreshRequiredData.PCmdNumber() ); |
|
678 |
|
679 // Notify clients already allowed Refresh about cancel. |
|
680 NotifyRefreshClientsCancel(); |
|
681 |
|
682 // Send the response |
|
683 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
684 LOG2( SIMPLE, |
|
685 "REFRESHREQ: CRefreshRequiredHandler::DoRefresh error", err ) |
|
686 } |
|
687 else |
|
688 { |
|
689 iUtils->NotifyEvent( MSatUtils::ERefreshExecuting ); |
|
690 |
|
691 // Ask the user permission to refresh. Reply will come |
|
692 // to ClientResponse method. |
|
693 if ( iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
694 { |
|
695 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh \ |
|
696 IsConfirmSatOperationsOn true" ) |
|
697 iQueryData.iCommand = ESatSRefreshQuery; |
|
698 iUtils->SatUiHandler().UiSession()->SendCommand( |
|
699 &iQueryPckg, |
|
700 &iQueryRspPckg, |
|
701 ESatSProactiveQuery ); |
|
702 } |
|
703 else |
|
704 { |
|
705 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh \ |
|
706 IsConfirmSatOperationsOn false" ) |
|
707 iQueryRsp.iAccepted = ETrue; |
|
708 ClientResponse(); |
|
709 } |
|
710 } |
|
711 } |
|
712 else |
|
713 { |
|
714 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh refresh" ) |
|
715 // Construct a proper refresh response data package. |
|
716 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
717 iRefreshRequiredRsp.SetPCmdNumber( iRefreshRequiredData.PCmdNumber() ); |
|
718 iRefreshRequiredRsp.iGeneralResult = RSat::KSuccess; |
|
719 |
|
720 // Send the response |
|
721 RefreshAllowed( iRefreshRequiredRspPckg ); |
|
722 } |
|
723 |
|
724 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::DoRefresh exiting" ) |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CRefreshHandler::NotifyRefreshClientsCancel |
|
729 // Notifies waiting clients about refrsh cancel. |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 void CRefreshRequiredHandler::NotifyRefreshClientsCancel() |
|
733 { |
|
734 LOG( SIMPLE, |
|
735 "REFRESHREQ: CRefreshHandler::NotifyRefreshClientsCancel calling" ) |
|
736 LOG2( SIMPLE, |
|
737 "REFRESHREQ: CRefreshHandler::NotifyRefreshClientsCancel \ |
|
738 RefreshSubSessions().Count: %d",iUtils->RefreshSubSessions().Count() ) |
|
739 for ( TInt i = 0; i < iUtils->RefreshSubSessions().Count() ; i++ ) |
|
740 { |
|
741 iUtils->RefreshSubSessions()[i]->NotifyClientCancel(); |
|
742 } |
|
743 |
|
744 LOG( SIMPLE, "REFRESHREQ: CRefreshHandler::NotifyRefreshClientsCancel exit" ) |
|
745 } |
|
746 |
|
747 // ----------------------------------------------------------------------------- |
|
748 // CRefreshRequiredHandler::RefreshAllowed |
|
749 // Sends the RefreshRequired specific response to the SIM and renews the sat |
|
750 // request. Notem, this replaces TerminalRsp() here. |
|
751 // (other items were commented in a header). |
|
752 // ----------------------------------------------------------------------------- |
|
753 // |
|
754 void CRefreshRequiredHandler::RefreshAllowed( const TDesC8& aRsp ) |
|
755 { |
|
756 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::RefreshAllowed calling" ) |
|
757 |
|
758 iUtils->USatAPI().RefreshAllowed( aRsp ); |
|
759 iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd ); |
|
760 Start(); |
|
761 |
|
762 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::RefreshAllowed exiting" ) |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CRefreshHandler::CheckIndicatedAid |
|
767 // Check the state of the indicated Aid. |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 CRefreshRequiredHandler::TAidState |
|
771 CRefreshRequiredHandler::AidState() const |
|
772 { |
|
773 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AidState calling" ) |
|
774 |
|
775 TAidState aidState( EAidNotActive ); |
|
776 if ( !iRefreshRequiredData.iAid.Length() ) |
|
777 { |
|
778 aidState = EAidNull; |
|
779 LOG( SIMPLE, "REFRESHREQ: Indicated AID Null" ) |
|
780 } |
|
781 else if ( !IsValidAid( iRefreshRequiredData.iAid ) ) |
|
782 { |
|
783 aidState = EAidInvalid; |
|
784 LOG( SIMPLE, "REFRESHREQ: Indicated AID Invalid" ) |
|
785 } |
|
786 else |
|
787 { |
|
788 RSat::TAid aid; |
|
789 MSatAsyncToSync* wrapper = iUtils->CreateAsyncToSyncHelper(); |
|
790 if ( wrapper ) |
|
791 { |
|
792 iUtils->MultiModeApi().GetCurrentActiveUSimApplication( |
|
793 wrapper->RequestStatus() , aid ); |
|
794 // wait until GetCurrentActiveUSimApplication return aid |
|
795 TInt err = wrapper->SetActiveAndWait(); |
|
796 LOG2( NORMAL, "REFRESHREQ: CRefreshHandler::TAidState err %d",err ) |
|
797 wrapper->Release(); |
|
798 |
|
799 if ( KErrNone == err ) |
|
800 { |
|
801 #ifdef ENABLE_SAT_LOGGING |
|
802 for ( TInt i=0; i < aid.Length(); i++ ) |
|
803 { |
|
804 LOG2( DETAILED, "REFRESHREQ: AID from TSY: %x", aid[i] ) |
|
805 } |
|
806 #endif |
|
807 if ( aid == iRefreshRequiredData.iAid ) |
|
808 { |
|
809 aidState = EAidActive; |
|
810 } |
|
811 } |
|
812 else if ( KErrNotSupported == err ) |
|
813 { |
|
814 aidState = EAidActive; |
|
815 } |
|
816 } |
|
817 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AidState exit" ) |
|
818 } |
|
819 return aidState; |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // Check whether the given AID is valid. |
|
824 // According to TS 110 220 |
|
825 // ----------------------------------------------------------------------------- |
|
826 TBool CRefreshRequiredHandler::IsValidAid( const RSat::TAid& aAid ) const |
|
827 { |
|
828 LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::\ |
|
829 IsValidAid calling-exiting" ) |
|
830 TInt result ( EFalse ); |
|
831 // Check the length of AID, it should be between 12 to 16 bytes |
|
832 // ETSI: A0,00,00,00,09; |
|
833 // 3GPP: A0,00,00,00,87 |
|
834 // the fifth byte is not sure in other situations. |
|
835 //compare the first to fourth byte |
|
836 if ( KAidMinSize <= aAid.Length() && RSat::KAidMaxSize >= aAid.Length() ) |
|
837 { |
|
838 if ( EAidA0 == aAid[0]&& EAid0 == aAid[1] && |
|
839 EAid0 == aAid[2]&& EAid0 == aAid[3] ) |
|
840 { |
|
841 result = ETrue; |
|
842 } |
|
843 } |
|
844 return result; |
|
845 } |
|
846 |
|
847 // End of File |
|