1 /* |
|
2 * Copyright (c) 2009 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: Implementation of fotaserver component |
|
15 * This is part of fotaapplication. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <systemwarninglevels.hrh> |
|
20 #include <e32property.h> |
|
21 #include <bldvariant.hrh> |
|
22 #include <startupdomainpskeys.h> |
|
23 #include <hwrmpowerstatesdkpskeys.h> |
|
24 #include <f32file.h> |
|
25 #include <sysutil.h> |
|
26 #include <centralrepository.h> |
|
27 #include <ctsydomainpskeys.h> |
|
28 #include "fotaserverPrivateCRKeys.h" |
|
29 #include "fmsserver.h" |
|
30 #include "fmsinterruptaob.h" |
|
31 #include "fmsclientserver.h" |
|
32 #include "fmsserversession.h" |
|
33 |
|
34 |
|
35 // ---------------------------------------------------------------------------------------- |
|
36 // Server startup code |
|
37 // ---------------------------------------------------------------------------------------- |
|
38 static void RunServerL() |
|
39 { |
|
40 // naming the server thread after the server helps to debug panics |
|
41 User::LeaveIfError(User::RenameThread(KFMSServerName)); |
|
42 |
|
43 // create and install the active scheduler |
|
44 CActiveScheduler* s=new(ELeave) CActiveScheduler; |
|
45 CleanupStack::PushL(s); |
|
46 CActiveScheduler::Install(s); |
|
47 |
|
48 // create the server (leave it on the cleanup stack) |
|
49 CFMSServer::NewLC(); |
|
50 |
|
51 // Initialisation complete, now signal the client |
|
52 RProcess::Rendezvous(KErrNone); |
|
53 |
|
54 // Ready to run |
|
55 CActiveScheduler::Start(); |
|
56 |
|
57 // Cleanup the server and scheduler |
|
58 CleanupStack::PopAndDestroy(2); |
|
59 } |
|
60 |
|
61 |
|
62 // ---------------------------------------------------------------------------------------- |
|
63 // static method LogNwRequestL() called to submit async n/w request |
|
64 // ---------------------------------------------------------------------------------------- |
|
65 static TInt LogNwRequestL(TAny* aPtr) |
|
66 { |
|
67 CFMSServer* ptr = (CFMSServer*) aPtr; |
|
68 FLOG(_L("static LogNwRequestL:-Begin")); |
|
69 TRAPD(err, ptr->StartMonitoringL(ENetworkInterrupt)); |
|
70 FLOG(_L("LogNwRequestL started monitoring")); |
|
71 ptr->StopAsyncRequest(); |
|
72 FLOG(_L("static LogNwRequestL:-end")); |
|
73 return err; |
|
74 } |
|
75 |
|
76 |
|
77 // ---------------------------------------------------------------------------------------- |
|
78 // static method LogCallEndMonitorRequestL() called to submit async call end monitor request |
|
79 // ---------------------------------------------------------------------------------------- |
|
80 static TInt LogCallEndMonitorRequestL(TAny* aPtr) |
|
81 { |
|
82 CFMSServer* ptr = (CFMSServer*) aPtr; |
|
83 FLOG(_L("static LogCallEndMonitorRequestL:-Begin")); |
|
84 TRAPD(err, ptr->StartUpdateInterruptMonitoringL(EMonitorPhoneCallEnd)); |
|
85 FLOG(_L("LogCallEndMonitorRequestL started monitoring")); |
|
86 ptr->StopAsyncRequest(); |
|
87 FLOG(_L("static LogCallEndMonitorRequestL:-end")); |
|
88 return err; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------------------- |
|
92 // Server process entry-point |
|
93 // ---------------------------------------------------------------------------------------- |
|
94 TInt E32Main() |
|
95 { |
|
96 __UHEAP_MARK; |
|
97 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
98 TInt r=KErrNoMemory; |
|
99 if (cleanup) |
|
100 { |
|
101 TRAP(r,RunServerL()); |
|
102 delete cleanup; |
|
103 } |
|
104 __UHEAP_MARKEND; |
|
105 return r; |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------------------- |
|
109 // CFMSServer::NewLC |
|
110 // ---------------------------------------------------------------------------------------- |
|
111 CServer2* CFMSServer::NewLC() |
|
112 { |
|
113 CFMSServer* self=new(ELeave) CFMSServer; |
|
114 CleanupStack::PushL(self); |
|
115 self->ConstructL(); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------------------- |
|
120 // CFMSServer::ConstructL |
|
121 // ---------------------------------------------------------------------------------------- |
|
122 void CFMSServer::ConstructL() |
|
123 { |
|
124 FLOG(_L("CFMSServer::ConstructL- begin")); |
|
125 StartL(KFMSServerName); |
|
126 User::LeaveIfError( iFs.Connect() ); |
|
127 TInt err; |
|
128 err = iFs.CreatePrivatePath(EDriveC); |
|
129 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
130 { User::Leave (err); } |
|
131 User::LeaveIfError( iFs.SetSessionToPrivate( EDriveC ) ); |
|
132 err = iFile.Create(iFs,KFotaInterruptFileName,EFileWrite); |
|
133 if(err == KErrNone)//means file created now and opened |
|
134 { |
|
135 FLOG(_L("CFMSServer::ConstructL- file closed")); |
|
136 iFile.Close(); |
|
137 } |
|
138 else if( err != KErrAlreadyExists ) |
|
139 { |
|
140 FLOG(_L("CFMSServer::ConstructL- leaving with err as %d"),err); |
|
141 User::Leave(err); |
|
142 } |
|
143 FindVariation(); |
|
144 iFMSInterruptAob.ConstructL(); |
|
145 iFMSInterruptAob.iServer = this; |
|
146 FLOG(_L("CFMSServer::ConstructL- end")); |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------------------- |
|
150 // CFMSServer::CFMSServer() |
|
151 // ---------------------------------------------------------------------------------------- |
|
152 CFMSServer::CFMSServer() :CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/ |
|
153 { |
|
154 iSessionCount = 0; |
|
155 //iNetworkMon = ETrue; //Incase of cenrep key has problem |
|
156 iNetworkMon = EFalse; |
|
157 iChargerMon = EFalse; |
|
158 iPhoneRestartMon = EFalse; |
|
159 iMemoryMon = EFalse; |
|
160 iDeleteFile = ETrue; |
|
161 iLogAsyncRequest = NULL; |
|
162 iProfileId = EFalse; |
|
163 iPkgId = EFalse; |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------------------- |
|
167 // CFMSServer::MemoryToMonitorL() |
|
168 // ---------------------------------------------------------------------------------------- |
|
169 void CFMSServer::MemoryToMonitorL(TInt aSize, TDriveNumber aDrive) |
|
170 { |
|
171 if( iSessionCount == 0 )// no pending request |
|
172 { |
|
173 iFMSInterruptAob.MemoryToMonitorL(aSize,aDrive); |
|
174 } |
|
175 } |
|
176 // ---------------------------------------------------------------------------------------- |
|
177 // CFMSServer::NetworkTypeL() |
|
178 // ---------------------------------------------------------------------------------------- |
|
179 void CFMSServer::NetworkTypeL(TInt aBearer) |
|
180 { |
|
181 if( iSessionCount == 0 )// no pending request |
|
182 { |
|
183 iFMSInterruptAob.NetworkTypeL(aBearer); |
|
184 } |
|
185 } |
|
186 |
|
187 //------------------------------------------------------------ |
|
188 // Call from session class in fotastartup case |
|
189 // CFMSServer::CheckNetworkL |
|
190 //------------------------------------------------------------ |
|
191 void CFMSServer::CheckNetworkL(TInt& aBearerId, TInt& aDrive, TInt& aSize, |
|
192 TBool& aWcdma) |
|
193 { |
|
194 if(iNetworkMon)//n/w monitoring supports |
|
195 { |
|
196 FLOG(_L("CFMSServer::CheckNetworkL- n/w monitor supported")); |
|
197 if(iFMSInterruptAob.CheckNetworkL()) //not n/w interrupt + WLAN or GPRS |
|
198 { |
|
199 FLOG(_L("CFMSServer::CheckNetworkL- n/w mon supported & launch fota")); |
|
200 iFMSInterruptAob.LaunchFotaEngineL(); |
|
201 DropSession(); // to close the session & server |
|
202 return; |
|
203 } |
|
204 else //if network not up, monitor for that |
|
205 { |
|
206 //from session itself we set the bearer type |
|
207 FLOG(_L("CFMSServer::CheckNetworkL- n/w not up beaerer 3G %d"),aWcdma); |
|
208 WriteToFile(ENetworkInterrupt,aBearerId, |
|
209 (TDriveNumber)aDrive, aSize, aWcdma ); |
|
210 StartMonitoringL(ENetworkInterrupt); |
|
211 } |
|
212 } |
|
213 else //user interrupt or general interrupt dont check n/w call fota |
|
214 { |
|
215 FLOG(_L("CFMSServer::CheckNetworkL- n/w monitor not supported & launch fota")); |
|
216 iFMSInterruptAob.LaunchFotaEngineL(); |
|
217 FLOG(_L("CFMSServer::CheckNetworkL- stop server")); |
|
218 DropSession(); |
|
219 } |
|
220 } |
|
221 |
|
222 //------------------------------------------------------------ |
|
223 // Call from session class in hard reboot only |
|
224 // CFMSServer::TriggerFotaL |
|
225 //------------------------------------------------------------ |
|
226 void CFMSServer::TriggerFotaL() |
|
227 { |
|
228 FLOG(_L("CFMSServer::TriggerFotaL- begin")); |
|
229 if(iNetworkMon)//n/w monitoring supports |
|
230 { |
|
231 FLOG(_L("CFMSServer::TriggerFotaL- n/w monitor supported")); |
|
232 if(iFMSInterruptAob.CheckNetworkL()) |
|
233 { |
|
234 FLOG(_L("CFMSServer::TriggerFotaL- n/w mon supported & launch fota")); |
|
235 iFMSInterruptAob.LaunchFotaEngineL(); |
|
236 } |
|
237 else if(iFMSInterruptAob.CheckGlobalRFStateL()) |
|
238 { |
|
239 FLOG(_L("CFMSServer::TriggerFotaL- n/w check started")); |
|
240 iFMSInterruptAob.StartNetworkRegistryCheckL(); |
|
241 return; //dont call drop session as it closes server |
|
242 } |
|
243 else |
|
244 { |
|
245 FLOG(_L("CFMSServer::TriggerFotaL- phone is offline")); |
|
246 } |
|
247 } |
|
248 else //user interrupt or general interrupt dont check n/w call fota |
|
249 { |
|
250 FLOG(_L("CFMSServer::TriggerFotaL- n/w monitor not supported & launch fota")); |
|
251 iFMSInterruptAob.LaunchFotaEngineL(); |
|
252 FLOG(_L("CFMSServer::TriggerFotaL- stop server")); |
|
253 } |
|
254 DropSession(); // to close the session & server in any case |
|
255 FLOG(_L("CFMSServer::TriggerFotaL- End")); |
|
256 } |
|
257 |
|
258 //------------------------------------------------------------ |
|
259 // Called only in n/w interrupt+ WLAN case from session class |
|
260 // CFMSServer::CheckWlanL |
|
261 //------------------------------------------------------------ |
|
262 TBool CFMSServer::CheckWlanL() |
|
263 { |
|
264 return iFMSInterruptAob.CheckNetworkL(); |
|
265 } |
|
266 |
|
267 //------------------------------------------------------------ |
|
268 // CFMSServer::SetWcdma |
|
269 //------------------------------------------------------------ |
|
270 void CFMSServer::SetWcdma() |
|
271 { |
|
272 iFMSInterruptAob.SetWcdma(); |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------------------------------------------- |
|
276 // CFMSServer::LockSession() |
|
277 // ---------------------------------------------------------------------------------------- |
|
278 void CFMSServer::LockSession() |
|
279 { |
|
280 iSessionCount++; |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------------------- |
|
284 // CFMSServer::WriteToFile() |
|
285 // ---------------------------------------------------------------------------------------- |
|
286 void CFMSServer::WriteToFile(TInt aReason, TInt aBearer,TDriveNumber aDrive, |
|
287 TInt aSize, TBool aWcdmaBearer ) |
|
288 { |
|
289 if(iSessionCount == 0) |
|
290 { |
|
291 FLOG(_L("CFMSServer::WriteToFile- begin")); |
|
292 TInt err=iFile.Open(iFs,KFotaInterruptFileName,EFileWrite); |
|
293 if(err == KErrNone) |
|
294 { |
|
295 FLOG(_L("CFMSServer::WriteToFile--passed")); |
|
296 TBuf8<30> data;//size 30 or 32--as args is 16 bytes |
|
297 TBuf8<30> temp; |
|
298 temp.Num(aReason); |
|
299 data.Append(temp); |
|
300 data.Append(','); |
|
301 temp.Num(aBearer);// or use iFMSinterruptAob's iBearer |
|
302 data.Append(temp); |
|
303 data.Append(','); |
|
304 temp.Num((TInt)aDrive); |
|
305 data.Append(temp); |
|
306 data.Append(','); |
|
307 temp.Num(aSize); |
|
308 data.Append(temp); |
|
309 data.Append(','); |
|
310 temp.Num(aWcdmaBearer); |
|
311 data.Append(temp); |
|
312 iFile.Write(data); |
|
313 iFile.Close(); |
|
314 } |
|
315 else |
|
316 FLOG(_L("CFMSServer::WriteToFile- Failed")); |
|
317 } |
|
318 else |
|
319 FLOG(_L("CFMSServer::WriteToFile- not done as another request is there")); |
|
320 } |
|
321 |
|
322 // ---------------------------------------------------------------------------------------- |
|
323 // CFMSServer::ReadFromFile() |
|
324 // ---------------------------------------------------------------------------------------- |
|
325 TBool CFMSServer::ReadFromFile(TInt& aReason, TInt& aBearer, TInt& aDrive, TInt& aSize |
|
326 , TInt& aWcdmaBearer ) |
|
327 { |
|
328 TInt err = iFile.Open(iFs,KFotaInterruptFileName,EFileRead); |
|
329 FLOG(_L("CFMSServer::ReadFromFile() error as %d"),err); |
|
330 if(err == KErrNone) |
|
331 { |
|
332 TInt size = KErrNone; |
|
333 err = iFile.Size(size); |
|
334 if(size == 0) //file empty |
|
335 { |
|
336 FLOG(_L("CFMSServer::ReadFromFile() file size is empty")); |
|
337 iFile.Close(); |
|
338 return EFalse; |
|
339 } |
|
340 TBuf8<30> data; |
|
341 iFile.Read(data); |
|
342 iFile.Close(); |
|
343 TBuf8<30> data1; |
|
344 if(data.Length()>0) |
|
345 { |
|
346 TInt len =0 ; |
|
347 if((len=data.LocateF(',')) > 0) |
|
348 { |
|
349 TLex8 value( data.Left(len)); |
|
350 value.Val(aReason); |
|
351 FLOG(_L("CFMSServer::ReadFromFile() retrieving reason as %d"),aReason); |
|
352 data1.Insert(0,data.Right(data.Length()-(len+1))); |
|
353 data.Zero(); |
|
354 // len=data1.LocateF(','); |
|
355 if( data1.Length() > 0 && (len=data1.LocateF(',')) > 0) |
|
356 { |
|
357 value=data1.Left(len); |
|
358 value.Val(aBearer); |
|
359 FLOG(_L("CFMSServer::ReadFromFile() retrieving aBearer as %d"),aBearer); |
|
360 data.Insert(0,data1.Right(data1.Length()-(len+1))); |
|
361 data1.Zero(); |
|
362 // len=data.LocateF(','); |
|
363 if(data.Length() > 0 && ( len=data.LocateF(','))> 0) |
|
364 { |
|
365 value=data.Left(len); |
|
366 value.Val(aDrive); |
|
367 FLOG(_L("CFMSServer::ReadFromFile() retrieving aDrive as %d"),aDrive); |
|
368 data1.Insert(0,data.Right(data.Length()-(len+1))); |
|
369 data.Zero(); |
|
370 if(data1.Length() > 0 && ( len=data1.LocateF(','))> 0 ) |
|
371 { |
|
372 value=data1.Left(len); |
|
373 value.Val(aSize); |
|
374 FLOG(_L("CFMSServer::ReadFromFile() retrieving aSize as %d"),aSize); |
|
375 data.Insert(0,data1.Right(data1.Length()-len-1)); |
|
376 data1.Zero(); |
|
377 if(data.Length() > 0 ) |
|
378 { |
|
379 value=data; |
|
380 value.Val(aWcdmaBearer); |
|
381 FLOG(_L("CFMSServer::ReadFromFile() retrieving aWcdmaBearer as %d"),aWcdmaBearer); |
|
382 } |
|
383 } |
|
384 } |
|
385 } |
|
386 } |
|
387 } |
|
388 } |
|
389 else |
|
390 { |
|
391 return EFalse; |
|
392 } |
|
393 return ETrue; |
|
394 } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CFMSServer::DropSession() |
|
398 // ----------------------------------------------------------------------------- |
|
399 |
|
400 void CFMSServer::DropSession() |
|
401 { |
|
402 // A session is being destroyed |
|
403 iSessionCount = 0; |
|
404 //Kill the server |
|
405 CActiveScheduler::Stop(); |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------------------------------------------- |
|
409 // CFMSServer::FindVariation() |
|
410 // ---------------------------------------------------------------------------------------- |
|
411 void CFMSServer::FindVariation() |
|
412 { |
|
413 FLOG(_L("CFMSServer::FindVariation()")); |
|
414 CRepository* centrep = NULL; |
|
415 TInt variation = 1; |
|
416 TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) ); |
|
417 if ( centrep ) |
|
418 { |
|
419 FLOG(_L("CFMSServer::FindVariation()::Inside cenrep if")); |
|
420 TInt err = centrep->Get( KFotaMonitoryServiceEnabled, variation ); |
|
421 if( err == KErrNone) |
|
422 { |
|
423 FLOG(_L("CFMSServer::FindVariation()::cenrep key found with %d"),variation); |
|
424 } |
|
425 delete centrep; |
|
426 } |
|
427 if ( err == KErrNone ) |
|
428 { |
|
429 TBuf<10> var; //32-bit has max of 10 chars in Decimal |
|
430 var.Num(variation,EBinary); |
|
431 TInt size = var.Length(), maxlen = 4; |
|
432 if( size < maxlen) |
|
433 { |
|
434 TBuf<4> temp; |
|
435 temp.AppendFill('0',maxlen-size); |
|
436 temp.Append(var); |
|
437 var.Zero(); |
|
438 var.Append(temp); |
|
439 } |
|
440 var.AppendFill('0',6); |
|
441 if( var[0] == '1' )//memory |
|
442 { |
|
443 FLOG(_L("CFMSServer::FindVariation():: memory monitor supported")); |
|
444 iMemoryMon = ETrue; |
|
445 } |
|
446 if( var[1] == '1' ) //startup |
|
447 { |
|
448 FLOG(_L("CFMSServer::FindVariation()::Phone restart monitor supported")); |
|
449 iPhoneRestartMon = ETrue; |
|
450 } |
|
451 if( var[2] == '1' )//user or charger |
|
452 { |
|
453 FLOG(_L("CFMSServer::FindVariation()::charger monitor supported")); |
|
454 iChargerMon = ETrue; |
|
455 } |
|
456 if( var[3] == '1' )//newtwork |
|
457 { |
|
458 FLOG(_L("CFMSServer::FindVariation()::network monitor supported")); |
|
459 iNetworkMon = ETrue; |
|
460 } |
|
461 } |
|
462 } |
|
463 |
|
464 // ---------------------------------------------------------------------------------------- |
|
465 // CFMSServer::ChargerTobeMonitered() |
|
466 // ---------------------------------------------------------------------------------------- |
|
467 TBool CFMSServer::ChargerTobeMonitered() |
|
468 { |
|
469 FLOG(_L("CFMSServer::ChargerTobeMonitered()::charger monitor check")); |
|
470 return iChargerMon; |
|
471 } |
|
472 |
|
473 // ---------------------------------------------------------------------------------------- |
|
474 // CFMSServer::NetworkTobeMonitered() |
|
475 // ---------------------------------------------------------------------------------------- |
|
476 TBool CFMSServer::NetworkTobeMonitered() |
|
477 { |
|
478 FLOG(_L("CFMSServer::NetworkTobeMonitered()::network monitor check")); |
|
479 return iNetworkMon; |
|
480 } |
|
481 |
|
482 // ---------------------------------------------------------------------------------------- |
|
483 // CFMSServer::MoniterAfterPhoneRestart() |
|
484 // ---------------------------------------------------------------------------------------- |
|
485 TBool CFMSServer::MoniterAfterPhoneRestart() |
|
486 { |
|
487 FLOG(_L("CFMSServer::MoniterAfterPhoneRestart()::phonerestart monitor check")); |
|
488 return iPhoneRestartMon; |
|
489 } |
|
490 |
|
491 // ---------------------------------------------------------------------------------------- |
|
492 // CFMSServer::MemoryTobeMonitered() |
|
493 // ---------------------------------------------------------------------------------------- |
|
494 TBool CFMSServer::MemoryTobeMonitered() |
|
495 { |
|
496 FLOG(_L("CFMSServer::MemoryTobeMonitered()::memory monitor check")); |
|
497 return iMemoryMon; |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CFMSServer::StartMonitoring() |
|
502 // ----------------------------------------------------------------------------- |
|
503 void CFMSServer::StartMonitoringL(TOmaDLInterruptReason aType) |
|
504 { |
|
505 // A new session is being created |
|
506 FLOG(_L("CFMSServer::StartMonitoringL>>")); |
|
507 if( iSessionCount == 0 ) |
|
508 { |
|
509 ++iSessionCount; |
|
510 iFMSInterruptAob.StartL(aType); |
|
511 } |
|
512 FLOG(_L("CFMSServer::StartMonitoringL<<")); |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CFMSServer::DeleteFile() |
|
517 // ----------------------------------------------------------------------------- |
|
518 void CFMSServer::DeleteFile(TBool aValue) |
|
519 { |
|
520 iDeleteFile = aValue; |
|
521 } |
|
522 // ---------------------------------------------------------------------------------------- |
|
523 // CFMSServer::~CFMSServer() |
|
524 // ---------------------------------------------------------------------------------------- |
|
525 CFMSServer::~CFMSServer() |
|
526 { |
|
527 FLOG(_L("CFMSServer::~CFMSServer())")); |
|
528 //iFMSInterruptAob.Cancel(); |
|
529 if(iDeleteFile) |
|
530 { |
|
531 TInt err = iFs.Delete(KFotaInterruptFileName); |
|
532 FLOG(_L("CFMSServer::~CFMSServer() File Deleted with error as %d"),err); |
|
533 } |
|
534 if(iLogAsyncRequest) |
|
535 { |
|
536 FLOG(_L("CFMSServer::~CFMSServer():-iLogAsyncRequest cancel)")); |
|
537 iLogAsyncRequest->Cancel(); |
|
538 delete iLogAsyncRequest; |
|
539 iLogAsyncRequest = NULL; |
|
540 } |
|
541 iFs.Close(); |
|
542 } |
|
543 |
|
544 // ---------------------------------------------------------------------------------------- |
|
545 // CFMSServer::NewSessionL() |
|
546 // ---------------------------------------------------------------------------------------- |
|
547 CSession2* CFMSServer::NewSessionL(const TVersion&,const RMessage2&) const |
|
548 { |
|
549 return new (ELeave) CFMSSession(); |
|
550 } |
|
551 |
|
552 // ---------------------------------------------------------------------------------------- |
|
553 // CFMSServer::RequestPending() |
|
554 // Any request pending |
|
555 // ---------------------------------------------------------------------------------------- |
|
556 TBool CFMSServer::RequestPending() |
|
557 { |
|
558 if( iSessionCount > 0 ) |
|
559 { |
|
560 return ETrue; |
|
561 } |
|
562 return EFalse; |
|
563 } |
|
564 |
|
565 // ---------------------------------------------------------------------------- |
|
566 // CFMSServer::AsyncSessionRequestL() |
|
567 // Asynchronous request logging |
|
568 // ---------------------------------------------------------------------------- |
|
569 void CFMSServer::AsyncSessionRequestL() |
|
570 { |
|
571 if(iLogAsyncRequest) |
|
572 { |
|
573 FLOG(_L("CFMSServer::AsyncSessionRequestL():-iLogAsyncRequest cancel)")); |
|
574 iLogAsyncRequest->Cancel(); |
|
575 delete iLogAsyncRequest; |
|
576 iLogAsyncRequest = NULL; |
|
577 } |
|
578 iLogAsyncRequest = CPeriodic::NewL (EPriorityNormal) ; |
|
579 FLOG(_L("CFMSServer::AsyncSessionRequestL():-iLogAsyncRequest created)")); |
|
580 iLogAsyncRequest->Start( |
|
581 TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*4) |
|
582 , TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*4) |
|
583 , TCallBack(LogNwRequestL,this) ) ; |
|
584 FLOG(_L("CFMSServer::AsyncSessionRequestL():-Request logged)")); |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CFMSServer::AsyncSessionRequestL() |
|
589 // Asynchronous request logging |
|
590 // ----------------------------------------------------------------------------- |
|
591 void CFMSServer::StopAsyncRequest() |
|
592 { |
|
593 FLOG(_L("CFMSServer::StopAsyncRequest():-Begin)")); |
|
594 if(iLogAsyncRequest) |
|
595 { |
|
596 FLOG(_L("CFMSServer::StopAsyncRequest():-cancelling the request)")); |
|
597 iLogAsyncRequest->Cancel(); |
|
598 delete iLogAsyncRequest; |
|
599 iLogAsyncRequest = NULL; |
|
600 } |
|
601 FLOG(_L("CFMSServer::StopAsyncRequest():-End)")); |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // CFMSServer::StartBatteryMonitoringL() |
|
606 // Monitors for the battery |
|
607 // ----------------------------------------------------------------------------- |
|
608 void CFMSServer::StartBatteryMonitoringL(TOmaUpdInterruptReason aType, TUint aLevel) |
|
609 { |
|
610 // A new session is being created |
|
611 FLOG(_L("CFMSServer::StartMonitoringL, level = %d>>"), aLevel); |
|
612 if( iSessionCount == 0 ) |
|
613 { |
|
614 ++iSessionCount; |
|
615 iFMSInterruptAob.StartBatteryMonitoringL(aType, aLevel); |
|
616 } |
|
617 FLOG(_L("CFMSServer::StartMonitoringL<<")); |
|
618 } |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CFMSServer::StartUpdateInterruptMonitoringL() |
|
621 // Monitors for the update interrupt type |
|
622 // ----------------------------------------------------------------------------- |
|
623 void CFMSServer::StartUpdateInterruptMonitoringL(TOmaUpdInterruptReason aType) |
|
624 { |
|
625 // A new session is being created |
|
626 FLOG(_L("CFMSServer::StartUpdateInterruptMonitoringL>>")); |
|
627 if(EMonitorPhoneCallEnd == aType) |
|
628 { |
|
629 iFMSInterruptAob.StartCallEndMonitoringL(aType); |
|
630 } |
|
631 else |
|
632 { |
|
633 FLOG(_L("reason unknown")); |
|
634 } |
|
635 FLOG(_L("CFMSServer::StartUpdateInterruptMonitoringL<<")); |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CFMSServer::CheckPhoneCallActiveL() |
|
640 // checks any phone call is there or not at this moment |
|
641 // ----------------------------------------------------------------------------- |
|
642 void CFMSServer::CheckPhoneCallActiveL(TInt& aStatus) |
|
643 { |
|
644 FLOG(_L("CFMSServer::CheckPhoneCallActiveL>>")); |
|
645 TInt callstatus(KErrNotFound); |
|
646 RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callstatus); |
|
647 //check ctsydomainpskeys.h for different combinations, below OR condition holds good |
|
648 if(EPSCTsyCallStateUninitialized == callstatus || |
|
649 EPSCTsyCallStateNone == callstatus ) // call not active |
|
650 { |
|
651 aStatus = EFalse; |
|
652 } |
|
653 else // call active |
|
654 { |
|
655 aStatus = ETrue; |
|
656 } |
|
657 FLOG(_L("CFMSServer::CheckPhoneCallActiveL status is %d<<"),aStatus); |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CFMSServer::MonitorPhoneCallEndL() |
|
662 // Monitors for active phone call end |
|
663 // ----------------------------------------------------------------------------- |
|
664 TBool CFMSServer::MonitorPhoneCallEndL(TInt aPkgId, TInt aProfileId) |
|
665 { |
|
666 TInt CallState = KErrNotFound; |
|
667 iPkgId=aPkgId; |
|
668 iProfileId = aProfileId; |
|
669 FLOG(_L(" iPkgId:%d,iProfileId:%d<<"),iPkgId,iProfileId); |
|
670 CheckPhoneCallActiveL(CallState); |
|
671 if(CallState) |
|
672 { |
|
673 //go for call end montioring |
|
674 LogAsyncCallMonitorL(); |
|
675 return EFalse; |
|
676 } |
|
677 else //trigger fota to show install query |
|
678 { |
|
679 iFMSInterruptAob.LaunchFotaUpdate(iPkgId,iProfileId); |
|
680 return ETrue; |
|
681 } |
|
682 } |
|
683 |
|
684 // ----------------------------------------------------------------------------- |
|
685 // CFMSServer::LogAsyncCallMonitorL() |
|
686 // Async request to monitor active phone call end |
|
687 // ----------------------------------------------------------------------------- |
|
688 void CFMSServer::LogAsyncCallMonitorL() |
|
689 { |
|
690 if(iLogAsyncRequest) |
|
691 { |
|
692 FLOG(_L("CFMSServer::LogAsyncCallMonitorL():- cancel)")); |
|
693 iLogAsyncRequest->Cancel(); |
|
694 delete iLogAsyncRequest; |
|
695 iLogAsyncRequest = NULL; |
|
696 } |
|
697 iLogAsyncRequest = CPeriodic::NewL (EPriorityNormal) ; |
|
698 FLOG(_L("CFMSServer::LogAsyncCallMonitorL(): created)")); |
|
699 iLogAsyncRequest->Start( |
|
700 TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*1) |
|
701 , TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*4) |
|
702 , TCallBack(LogCallEndMonitorRequestL,this) ) ; |
|
703 FLOG(_L("CFMSServer::LogAsyncCallMonitorL():-Request logged)")); |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CFMSServer::PkgId()) |
|
708 // returns the PkgId of the FOTA update |
|
709 // ----------------------------------------------------------------------------- |
|
710 TInt& CFMSServer::PkgId() |
|
711 { |
|
712 return iPkgId; |
|
713 } |
|
714 |
|
715 // ----------------------------------------------------------------------------- |
|
716 // CFMSServer::ProfileId() |
|
717 // returns the ProfileId of the FOTA |
|
718 // ----------------------------------------------------------------------------- |
|
719 TInt& CFMSServer::ProfileId() |
|
720 { |
|
721 return iProfileId; |
|
722 } |
|
723 //End of file |
|