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 <startupdomainpskeys.h> |
|
22 #include <hwrmpowerstatesdkpskeys.h> |
|
23 #include <sysutil.h> |
|
24 #include <fotaengine.h> |
|
25 #include "fotaserverPrivateCRKeys.h" |
|
26 #include "fmsserver.h" |
|
27 #include "fmsinterruptaob.h" |
|
28 #include "fmsclientserver.h" |
|
29 #include "FotaIPCTypes.h" |
|
30 |
|
31 #if defined (__WINS__) |
|
32 #include <cmpluginlanbasedef.h> |
|
33 #endif |
|
34 // ---------------------------------------------------------------------------------------- |
|
35 // static method StaticCheckNwRequestL() called to check n/w availability |
|
36 // ---------------------------------------------------------------------------------------- |
|
37 static TInt StaticCheckNwRequestL(TAny* aPtr) |
|
38 { |
|
39 CFMSInterruptAob* ptr = (CFMSInterruptAob*) aPtr; |
|
40 FLOG(_L("StaticCheckNwRequestL:-Begin")); |
|
41 TRAPD(err, ptr->NetworkRegistryCheckL() ); |
|
42 FLOG(_L("StaticCheckNwRequestL:-end")); |
|
43 return err; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CFMSInterruptAob::CFMSInterruptAob() |
|
48 // ----------------------------------------------------------------------------- |
|
49 CFMSInterruptAob::CFMSInterruptAob() |
|
50 :CActive(EPriorityStandard) |
|
51 { |
|
52 //CActiveScheduler::Add(this); |
|
53 iConnStatus = KErrNone; |
|
54 iWlanAvailable = EFalse; |
|
55 iGPRSAvail = EFalse; |
|
56 iWcdma = EFalse; |
|
57 iUpdInterruptType = ENoInterrupt; |
|
58 iChargeToMonitor = 0; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CFMSInterruptAob::ConstructL() |
|
63 // ----------------------------------------------------------------------------- |
|
64 void CFMSInterruptAob::ConstructL() |
|
65 { |
|
66 CActiveScheduler::Add(this); |
|
67 User::LeaveIfError(iConnMon.ConnectL()); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CFMSInterruptAob::Start() |
|
72 // ----------------------------------------------------------------------------- |
|
73 void CFMSInterruptAob::StartL(TFmsIpcCommands aType) |
|
74 { |
|
75 FLOG(_L("CFMSInterruptAob::Start- begin")); |
|
76 iInterruptType = aType; |
|
77 if(iInterruptType == EDLUserInterrupt && iServer->ChargerTobeMonitered()) |
|
78 { |
|
79 FLOG(_L("CFMSInterruptAob::Start--EUserInterrupt")); |
|
80 if(!IsActive()) |
|
81 { |
|
82 //RProperty pw; |
|
83 iProperty.Attach(KPSUidHWRMPowerState,KHWRMChargingStatus); |
|
84 iStatus=KRequestPending; |
|
85 iProperty.Subscribe(iStatus); |
|
86 SetActive(); |
|
87 } |
|
88 } |
|
89 else if(iInterruptType == EDLNetworkInterrupt && iServer->NetworkTobeMonitered()) |
|
90 { |
|
91 FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt")); |
|
92 if(!IsActive()) |
|
93 { |
|
94 iStatus=KRequestPending; |
|
95 TBool phonenotoffline = CheckGlobalRFStateL(); |
|
96 if ( ( iBearer == EBearerIdGPRS || iBearer == EBearerIdWCDMA ) |
|
97 && phonenotoffline ) |
|
98 { |
|
99 FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt iBearer is %d"),iBearer); |
|
100 NotifyL(); |
|
101 return; |
|
102 } |
|
103 else if ( iBearer == EBearerIdWLAN ) |
|
104 { |
|
105 //feature supported check |
|
106 iWlanAvailable = EFalse; |
|
107 iConnMon.GetBoolAttribute( EBearerIdWLAN, |
|
108 0, |
|
109 KBearerAvailability, |
|
110 iWlanAvailable, |
|
111 iStatus ); |
|
112 SetActive(); |
|
113 } |
|
114 else |
|
115 { |
|
116 FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt--other then GPRS/ WLan bearer ")); |
|
117 //Stop the server |
|
118 //Dont delete the file if interrupt is network + offline( to differentiate from hard reboot |
|
119 iServer->DeleteFile(EFalse); |
|
120 StopServer(); |
|
121 } |
|
122 } |
|
123 } |
|
124 else if(iInterruptType == EDLMemoryInterrupt && iServer->MemoryTobeMonitered()) |
|
125 { |
|
126 FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt on drive %d"),(TInt)iDrive ); |
|
127 if(!IsActive()) |
|
128 { |
|
129 User::LeaveIfError(iFs.Connect()); |
|
130 TBool critical = EFalse; |
|
131 TInt err = KErrNone; |
|
132 err=IsPkgSizeMoreThanWL(critical); |
|
133 if(critical) |
|
134 { |
|
135 FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--critical pkg dont fit on drive %d"),(TInt)iDrive ); |
|
136 iStatus=KRequestPending; |
|
137 iFs.NotifyDiskSpace( iSize, iDrive, iStatus ); |
|
138 FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt-setting as active") ); |
|
139 SetActive(); |
|
140 } |
|
141 else |
|
142 { |
|
143 if(err == KErrNone) |
|
144 { |
|
145 FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--critical pkg fits on drive %d"),(TInt)iDrive ); |
|
146 LaunchFotaEngineL(); |
|
147 } |
|
148 else |
|
149 { |
|
150 FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--System error %d on memory drive %d"), err,(TInt)iDrive ); |
|
151 } |
|
152 //Stop the server |
|
153 StopServer(); |
|
154 } |
|
155 } |
|
156 } |
|
157 else //case where variation fails or by chance if a bad interrupt reason |
|
158 { |
|
159 StopServer(); |
|
160 } |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CFMSInterruptAob::RunL() |
|
165 // ----------------------------------------------------------------------------- |
|
166 void CFMSInterruptAob::RunL() |
|
167 { |
|
168 FLOG(_L("CFMSInterruptAob::RunL()- begin")); |
|
169 TInt value = 0; |
|
170 if( EUpdMonitorPhoneCallEnd == iUpdInterruptType) |
|
171 { |
|
172 FLOG(_L("RunL EPhoneCallActiveAsync--call status %d"),iCallStatus); |
|
173 if(iStatus == KErrNone && RCall::EStatusIdle == iCallStatus ) |
|
174 { |
|
175 //call fota scheduler & Stop the server |
|
176 LaunchFotaUpdate(); |
|
177 StopServer(); |
|
178 } |
|
179 else //call in progress, subscribe again |
|
180 { |
|
181 FLOG(_L("call in progress, subscribing again")); |
|
182 iLine.NotifyStatusChange(iStatus, iCallStatus); |
|
183 SetActive(); |
|
184 } |
|
185 } |
|
186 else if( iUpdInterruptType == EUpdMonitorbattery) |
|
187 { |
|
188 FLOG(_L("CFMSInterruptAob::RunL()- handling battery monitor")); |
|
189 iProperty.Attach(KPSUidHWRMPowerState,KHWRMBatteryLevel); |
|
190 TInt err=iProperty.Get(KPSUidHWRMPowerState,KHWRMBatteryLevel,value); |
|
191 if(err != KErrNone) |
|
192 { |
|
193 FLOG(_L("CFMSInterruptAob::RunL()- error in getiing the battery level")); |
|
194 StopServer(); |
|
195 } |
|
196 if(value >= iChargeToMonitor) |
|
197 { iProperty.Cancel(); |
|
198 iProperty.Close(); |
|
199 TRAPD(err, LaunchFotaScheduleUpdate()); |
|
200 if(err) |
|
201 { |
|
202 FLOG(_L("CFMSInterruptAob::RunL()- error in launch fota schedule")); |
|
203 } |
|
204 iUpdInterruptType = ENoInterrupt; |
|
205 StopServer(); |
|
206 |
|
207 } |
|
208 |
|
209 else |
|
210 { |
|
211 FLOG(_L("CFMSInterruptAob::RunL()--status charger not connected")); |
|
212 if(!IsActive()) |
|
213 { |
|
214 iStatus=KRequestPending; |
|
215 iProperty.Subscribe(iStatus); |
|
216 FLOG(_L("CFMSInterruptAob::RunL()--waiting for charger Connectivity")); |
|
217 SetActive(); |
|
218 } |
|
219 } |
|
220 } |
|
221 else if( iInterruptType == EDLUserInterrupt) |
|
222 { |
|
223 TInt value; |
|
224 //RProperty pw; |
|
225 iProperty.Attach(KPSUidHWRMPowerState,KHWRMChargingStatus); |
|
226 iProperty.Get(KPSUidHWRMPowerState,KHWRMChargingStatus,value); |
|
227 // charger connected or already charging going on |
|
228 if( value == EChargingStatusCharging /*|| value == EChargingStatusChargingComplete || |
|
229 value == EChargingStatusAlmostComplete || value == EChargingStatusChargingContinued */) |
|
230 { |
|
231 FLOG(_L("CFMSInterruptAob::RunL()--status charging")); |
|
232 HandleChargingInterruptL(); |
|
233 |
|
234 } |
|
235 else |
|
236 { |
|
237 FLOG(_L("CFMSInterruptAob::RunL()--status charger not connected")); |
|
238 if(!IsActive()) |
|
239 { |
|
240 iStatus=KRequestPending; |
|
241 iProperty.Subscribe(iStatus); |
|
242 FLOG(_L("CFMSInterruptAob::RunL()--waiting for charger Connectivity")); |
|
243 SetActive(); |
|
244 } |
|
245 } |
|
246 } |
|
247 else if( iInterruptType == EDLNetworkInterrupt ) |
|
248 { |
|
249 FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt" )); |
|
250 /*if( iBearer == EBearerIdGPRS || iBearer == EBearerIdWCDMA ) |
|
251 { |
|
252 FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt:GPRS/WCDMA" )); |
|
253 }*/ |
|
254 if ( iBearer == EBearerIdWLAN ) |
|
255 { |
|
256 TBuf<10> num; |
|
257 FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt due to bearer id WLAN, iStatus %d"),iStatus.Int()); |
|
258 /*if(iWlanAvailable) |
|
259 FLOG(_L("iWlanAvailable :TRUE")); |
|
260 else |
|
261 FLOG(_L("iWlanAvailable :FALSE")); */ |
|
262 if( iWlanAvailable && iStatus == KErrNone ) |
|
263 { |
|
264 FLOG(_L("CFMSInterruptAob::RunL()--status WLAN networks found")); |
|
265 LaunchFotaEngineL(); |
|
266 StopServer(); |
|
267 } |
|
268 else if( iStatus == KErrNotSupported )//feture not supported |
|
269 { |
|
270 FLOG(_L("CFMSInterruptAob::RunL()--status WLAN feature not supported")); |
|
271 StopServer(); |
|
272 } |
|
273 else |
|
274 { |
|
275 FLOG(_L("CFMSInterruptAob::RunL()--status WLAN networks not found")); |
|
276 if(!IsActive()) |
|
277 { |
|
278 iWlanAvailable = EFalse; |
|
279 iStatus=KRequestPending; |
|
280 iConnMon.GetBoolAttribute( EBearerIdWLAN, |
|
281 0, |
|
282 KBearerAvailability, |
|
283 iWlanAvailable, |
|
284 iStatus ); |
|
285 FLOG(_L("CFMSInterruptAob::RunL()--search for wlan availability")); |
|
286 SetActive(); |
|
287 } |
|
288 } |
|
289 } |
|
290 } |
|
291 else if( iInterruptType == EDLMemoryInterrupt ) |
|
292 { |
|
293 FLOG(_L("CFMSInterruptAob::RunL()--EMemoryInterrupt,iStatus %d"),iStatus.Int()); |
|
294 if( iStatus == KErrNone || iStatus == KErrCancel ) |
|
295 { |
|
296 TBool critical = EFalse; |
|
297 IsPkgSizeMoreThanWL(critical); |
|
298 //if download size doesn't lead to memory less than critical level |
|
299 if( !critical ) |
|
300 { |
|
301 FLOG(_L("CFMSInterruptAob::RunL()--Ok download not greater than critical level")); |
|
302 //Check network status at this moment |
|
303 |
|
304 HandleAboveCriticallevelL(); |
|
305 |
|
306 |
|
307 } |
|
308 else |
|
309 { |
|
310 FLOG(_L("CFMSInterruptAob::RunL()--Ok download greater than critical level")); |
|
311 // space monitor for this |
|
312 if(!IsActive()) |
|
313 { |
|
314 iStatus=KRequestPending; |
|
315 iFs.NotifyDiskSpace( iSize, iDrive, iStatus ); |
|
316 SetActive(); |
|
317 } |
|
318 } |
|
319 } |
|
320 else // for size request more than disk space |
|
321 { |
|
322 FLOG(_L("CFMSInterruptAob::RunL()--bad request size greater than the disk limit")); |
|
323 StopServer(); |
|
324 } |
|
325 } |
|
326 else //general |
|
327 { |
|
328 //Already ahandled in session class |
|
329 } |
|
330 FLOG(_L("CFMSInterruptAob::RunL()- End")); |
|
331 } |
|
332 |
|
333 // ---------------------------------------------------------------------------------------- |
|
334 // CFMSInterruptAob::DoCancel() |
|
335 // ---------------------------------------------------------------------------------------- |
|
336 void CFMSInterruptAob::DoCancel() |
|
337 { |
|
338 FLOG(_L("CFMSInterruptAob::::DoCancel()")); |
|
339 if( iStatus == KRequestPending ) |
|
340 { |
|
341 FLOG(_L("CFMSInterruptAob::::DoCancel()--request pending")); |
|
342 TRequestStatus* status = &iStatus; |
|
343 User::RequestComplete( status, KErrCancel ); |
|
344 } |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------------------- |
|
348 // CFMSInterruptAob::MemoryToMonitorL() |
|
349 // ---------------------------------------------------------------------------------------- |
|
350 void CFMSInterruptAob::MemoryToMonitorL(TInt aSize, TDriveNumber aDrive) |
|
351 { |
|
352 FLOG(_L("CFMSInterruptAob::::MemoryToMonitorL()--Begin")); |
|
353 if( aSize < 0 || (aDrive < EDriveA && aDrive > EDriveZ) ) |
|
354 { |
|
355 FLOG(_L("CFMSInterruptAob::::MemoryToMonitorL()--Leving with KErrArgumnet")); |
|
356 User::Leave(KErrArgument); |
|
357 } |
|
358 iDrive = aDrive; |
|
359 iSize = aSize; |
|
360 CheckMemSizeL(); |
|
361 } |
|
362 |
|
363 // ---------------------------------------------------------------------------------------- |
|
364 // CFMSInterruptAob::NetworkTypeL() |
|
365 // ---------------------------------------------------------------------------------------- |
|
366 void CFMSInterruptAob::NetworkTypeL(TInt aBearer) |
|
367 { |
|
368 if( aBearer == EBearerIdGPRS || aBearer == EBearerIdWLAN |
|
369 || aBearer == EBearerIdWCDMA |
|
370 #if defined (__WINS__) |
|
371 || aBearer == EBearerIdLAN) |
|
372 #else |
|
373 ) |
|
374 #endif |
|
375 { |
|
376 iBearer = aBearer; |
|
377 } |
|
378 else |
|
379 { |
|
380 FLOG(_L("CFMSInterruptAob::::NetworkTypeL()--leaving with KErrArgument")); |
|
381 User::Leave(KErrArgument); |
|
382 } |
|
383 } |
|
384 |
|
385 // ---------------------------------------------------------------------------------------- |
|
386 // CFMSInterruptAob::IsPkgSizeMoreThanWL() |
|
387 // ---------------------------------------------------------------------------------------- |
|
388 TInt CFMSInterruptAob::IsPkgSizeMoreThanWL(TBool& aCritical) |
|
389 { |
|
390 FLOG(_L("CFMSInterruptAob::::IsPkgSizeMoreThanWL()--Begin")); |
|
391 TInt err = KErrNone; |
|
392 //Already checked the drive is proper or not |
|
393 //here the check happened for warning level |
|
394 TRAP(err,aCritical = SysUtil::DiskSpaceBelowCriticalLevelL ( &iFs, iSize, iDrive )); |
|
395 FLOG(_L("CFMSInterruptAob::::IsPkgSizeMoreThanWL() end %d"),err); |
|
396 return err; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------------------- |
|
400 // CFMSInterruptAob::CheckNetworkL() |
|
401 // ---------------------------------------------------------------------------------------- |
|
402 TBool CFMSInterruptAob::CheckNetworkL() |
|
403 { |
|
404 FLOG(_L("CFMSInterruptAob::CheckNetworkL--begin")); |
|
405 TRequestStatus status=KRequestPending; |
|
406 iConnStatus = KErrNone; |
|
407 TBool phonenotoffline = CheckGlobalRFStateL(); |
|
408 if ( phonenotoffline && iBearer == EBearerIdGPRS ) |
|
409 { |
|
410 TRequestStatus gsmstatus = KRequestPending; |
|
411 iConnStatus = KErrNotFound; |
|
412 FLOG(_L("CFMSInterruptAob::CheckNetworkL--check GSM registry")); |
|
413 iConnMon.GetIntAttribute( EBearerIdGSM, 0,KNetworkRegistration, iConnStatus, gsmstatus ); |
|
414 User::WaitForRequest(gsmstatus); |
|
415 FLOG(_L("iConnStatus is %d gsmstatus is %d"),iConnStatus,gsmstatus.Int()); |
|
416 if( iConnStatus == ENetworkRegistrationHomeNetwork || |
|
417 iConnStatus == ENetworkRegistrationRoaming ) |
|
418 { |
|
419 FLOG(_L("CFMSInterruptAob::CheckNetworkL--GSM available")); |
|
420 FLOG(_L("CFMSInterruptAob::CheckNetworkL--checking GPRS")); |
|
421 iConnMon.GetBoolAttribute( EBearerIdGPRS, 0,KPacketDataAvailability, |
|
422 iGPRSAvail, status ); |
|
423 User::WaitForRequest(status); |
|
424 if( iGPRSAvail && status.Int()==KErrNone ) |
|
425 { |
|
426 FLOG(_L("CFMSInterruptAob::CheckNetworkL--GPRS available")); |
|
427 return ETrue; |
|
428 } |
|
429 } |
|
430 } |
|
431 else if ( phonenotoffline && iBearer == EBearerIdWCDMA ) |
|
432 { |
|
433 TRequestStatus gsmstatus = KRequestPending; |
|
434 iConnStatus = KErrNotFound; |
|
435 FLOG(_L("CFMSInterruptAob::CheckNetworkL--check WCDMA sim registry")); |
|
436 iConnMon.GetIntAttribute( EBearerIdWCDMA, 0,KNetworkRegistration, iConnStatus, gsmstatus ); |
|
437 User::WaitForRequest(gsmstatus); |
|
438 FLOG(_L("iConnStatus is %d WCDMA gsmstatus is %d"),iConnStatus,gsmstatus.Int()); |
|
439 if( iConnStatus == ENetworkRegistrationHomeNetwork || |
|
440 iConnStatus == ENetworkRegistrationRoaming ) |
|
441 { |
|
442 FLOG(_L("CFMSInterruptAob::CheckNetworkL--WCDMA GSM available")); |
|
443 FLOG(_L("CFMSInterruptAob::CheckNetworkL--checking WCDMA GPRS")); |
|
444 iConnMon.GetBoolAttribute( EBearerIdWCDMA, 0,KPacketDataAvailability, |
|
445 iGPRSAvail, status ); |
|
446 User::WaitForRequest(status); |
|
447 if( iGPRSAvail && status.Int()==KErrNone ) |
|
448 { |
|
449 FLOG(_L("CFMSInterruptAob::CheckNetworkL--WCDMA GPRS available")); |
|
450 return ETrue; |
|
451 } |
|
452 } |
|
453 } |
|
454 else if ( iBearer == EBearerIdWLAN ) |
|
455 { |
|
456 FLOG(_L("CFMSInterruptAob::CheckNetworkL--checking WLAN")); |
|
457 iWlanAvailable = EFalse; |
|
458 iConnMon.GetBoolAttribute( EBearerIdWLAN, |
|
459 0, |
|
460 KBearerAvailability, |
|
461 iWlanAvailable, |
|
462 status ); |
|
463 User::WaitForRequest(status);//Synchronous call |
|
464 if( iWlanAvailable && status == KErrNone ) |
|
465 { |
|
466 FLOG(_L("CFMSInterruptAob::CheckNetworkL--wlan available")); |
|
467 return ETrue; |
|
468 } |
|
469 } |
|
470 else //phone is offline |
|
471 { |
|
472 FLOG(_L("CFMSInterruptAob::CheckNetworkL--phone is offline or invalid bearer")); |
|
473 } |
|
474 FLOG(_L("CFMSInterruptAob::CheckNetworkL--end")); |
|
475 return EFalse; |
|
476 } |
|
477 |
|
478 // ---------------------------------------------------------------------------------------- |
|
479 // CFMSInterruptAob::CheckGlobalRFStateL() |
|
480 // ---------------------------------------------------------------------------------------- |
|
481 TBool CFMSInterruptAob::CheckGlobalRFStateL() |
|
482 { |
|
483 TInt val = KErrNone; |
|
484 TInt err = KErrNone; |
|
485 TInt status = EFalse; |
|
486 err = RProperty::Get(KPSUidStartup, KPSGlobalSystemState, val); |
|
487 if ( err == KErrNone && val == ESwStateNormalRfOn ) |
|
488 { |
|
489 //Phone is not offline. Check for Network Registration status |
|
490 FLOG(_L("Phone is online. Check for Network Registration status")); |
|
491 status = ETrue; |
|
492 } |
|
493 else |
|
494 { |
|
495 //Phone is offline. No Network activities allowed. |
|
496 FLOG(_L("Phone is offline. No Network activities allowed.")); |
|
497 status = EFalse; |
|
498 } |
|
499 FLOG(_L("CFotaNetworkRegStatus::CheckGlobalRFState, status = %d <<"),status); |
|
500 return status; |
|
501 } |
|
502 |
|
503 // ---------------------------------------------------------------------------------------- |
|
504 // CFMSInterruptAob::StopServer() |
|
505 // ---------------------------------------------------------------------------------------- |
|
506 void CFMSInterruptAob::StopServer() |
|
507 { |
|
508 FLOG(_L("CFMSInterruptAob::StopServer begin")); |
|
509 iServer->iSessionCount = 0; |
|
510 CActiveScheduler::Stop();//---for stopping the server |
|
511 FLOG(_L("CFMSInterruptAob::StopServer:server stopped")); |
|
512 } |
|
513 |
|
514 // ---------------------------------------------------------------------------------------- |
|
515 // CFMSInterruptAob::LaunchFotaEngineL() |
|
516 // ---------------------------------------------------------------------------------------- |
|
517 void CFMSInterruptAob::LaunchFotaEngineL() |
|
518 { |
|
519 FLOG(_L("CFMSInterruptAob::LaunchFotaEngineL call to iFotaEngine.OpenL() ")); |
|
520 TInt err = KErrNone; |
|
521 iServer->DeleteScheduledRemindersL(); |
|
522 TRAP(err,iFotaEngine.OpenL()); |
|
523 FLOG(_L("iFotaEngine.OpenL() launched withe error as %d"),err); |
|
524 if(err == KErrNone) |
|
525 { |
|
526 RFotaEngineSession::TState state = iFotaEngine.GetState(-1); |
|
527 if (state == RFotaEngineSession::EDownloadProgressing) |
|
528 { |
|
529 FLOG(_L("Trying resume download...")); |
|
530 err = iFotaEngine.TryResumeDownload(); |
|
531 } |
|
532 else if (state == RFotaEngineSession::EStartingUpdate) |
|
533 { |
|
534 FLOG(_L("Trying resume update...")); |
|
535 err = iFotaEngine.Update(-1,(TSmlProfileId)1, _L8(""), _L8("")); |
|
536 } |
|
537 |
|
538 FLOG(_L("Fota engine returned : %d"), err); |
|
539 iFotaEngine.Close(); |
|
540 FLOG(_L("CFMSInterruptAob::LaunchFotaEngineL END - fotaengine closed ")); |
|
541 } |
|
542 } |
|
543 |
|
544 // ---------------------------------------------------------------------------------------- |
|
545 // CFMSInterruptAob::CheckMemSizeL() |
|
546 // ---------------------------------------------------------------------------------------- |
|
547 void CFMSInterruptAob::CheckMemSizeL(/*TInt& aMemoryNeeded*/) |
|
548 { |
|
549 FLOG(_L("CFMSInterruptAob::CheckMemSizeL-begin")); |
|
550 iSize = iSize + KDRIVECWARNINGTHRESHOLD; //irrespective of Drive |
|
551 FLOG(_L(" neededspace = sizeNeededFromFS + KDRIVECWARNINGTHRESHOLD: %d"), iSize); |
|
552 FLOG(_L("CFMSInterruptAob::CheckMemSizeL-end")); |
|
553 } |
|
554 |
|
555 // ---------------------------------------------------------------------------------------- |
|
556 // CFMSInterruptAob::~CFMSInterruptAob() |
|
557 // ---------------------------------------------------------------------------------------- |
|
558 CFMSInterruptAob::~CFMSInterruptAob() |
|
559 { |
|
560 FLOG(_L("CFMSInterruptAob::~CFMSInterruptAob()")); |
|
561 if(iPeriodicNwCheck) |
|
562 { |
|
563 FLOG(_L("CFMSInterruptAob::~CFMSInterruptAob()--deleting iPeriodicNwCheck")); |
|
564 delete iPeriodicNwCheck; |
|
565 iPeriodicNwCheck = NULL; |
|
566 } |
|
567 StopNotify(); |
|
568 Cancel(); |
|
569 iConnMon.Close(); |
|
570 if(iProperty.Handle()) |
|
571 { |
|
572 iProperty.Close(); |
|
573 FLOG(_L("CFMSInterruptAob::~CFMSInterruptAob()--iProperty closed")); |
|
574 } |
|
575 |
|
576 if(iInterruptType == EDLMemoryInterrupt) |
|
577 { |
|
578 iFs.NotifyDiskSpaceCancel(); |
|
579 } |
|
580 iFs.Close(); |
|
581 if(iLine.SubSessionHandle()) |
|
582 { |
|
583 iLine.Close(); |
|
584 } |
|
585 if(iPhone.SubSessionHandle()) |
|
586 { |
|
587 iPhone.Close(); |
|
588 } |
|
589 if(iTelServer.Handle()) |
|
590 { |
|
591 iTelServer.Close(); |
|
592 } |
|
593 FLOG(_L("CFMSInterruptAob::~CFMSInterruptAob()--End")); |
|
594 } |
|
595 |
|
596 |
|
597 // --------------------------------------------------------------------------- |
|
598 // CFMSInterruptAob::RunError |
|
599 // --------------------------------------------------------------------------- |
|
600 // |
|
601 TInt CFMSInterruptAob::RunError( TInt aError ) |
|
602 { |
|
603 FLOG( _L("CAOConnectionImpl::RunError: aError: %d"), aError ); |
|
604 return aError; |
|
605 } |
|
606 |
|
607 |
|
608 // |
|
609 // ----------------------------------------------------------------------------- |
|
610 // CFMSInterruptAob::NotifyL() |
|
611 // Registers with connection monitor for notification |
|
612 // ----------------------------------------------------------------------------- |
|
613 // |
|
614 void CFMSInterruptAob::NotifyL() |
|
615 { |
|
616 FLOG(_L("CFMSInterruptAob::NotifyL Begin ")); |
|
617 iConnMon.NotifyEventL( *this ); |
|
618 FLOG(_L("CFMSInterruptAob::NotifyL, after registering ")); |
|
619 // Threholds |
|
620 TInt err = iConnMon.SetUintAttribute( iBearer, |
|
621 0, |
|
622 KBearerAvailabilityThreshold, |
|
623 1 ); |
|
624 FLOG(_L("CFMSInterruptAob::NotifyL : END ")); |
|
625 |
|
626 } |
|
627 |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CFMSInterruptAob::StopNotify() |
|
631 // Cancels notification with connection monitor |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CFMSInterruptAob::StopNotify() |
|
635 { |
|
636 FLOG(_L("CFMSInterruptAob::StopNotify Begin ")); |
|
637 iConnMon.CancelNotifications(); |
|
638 FLOG(_L("CFMSInterruptAob::StopNotify end ")); |
|
639 } |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // CNsmlNetworkStatusEngine::EventL() |
|
643 // Method involed by connection monitor with current event. |
|
644 // This method handles the events |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 void CFMSInterruptAob::EventL( const CConnMonEventBase& aConnMonEvent ) |
|
648 { |
|
649 FLOG(_L("CFMSInterruptAob::EventL, BEGIN")); |
|
650 FLOG(_L("CFMSInterruptAob::EventL event is == %d"), aConnMonEvent.EventType() ); |
|
651 switch ( aConnMonEvent.EventType() ) |
|
652 { |
|
653 case EConnMonNetworkStatusChange: |
|
654 { |
|
655 CConnMonBearerAvailabilityChange* eventBearerAvailabilityChange; |
|
656 eventBearerAvailabilityChange = ( CConnMonBearerAvailabilityChange* ) &aConnMonEvent; |
|
657 |
|
658 if ( eventBearerAvailabilityChange->ConnectionId() == iBearer ) |
|
659 { |
|
660 if ( eventBearerAvailabilityChange->Availability() ) |
|
661 { |
|
662 // Available |
|
663 if(CheckNetworkL()) |
|
664 { |
|
665 FLOG(_L("CFMSInterruptAob::EventL()--status GPRS up")); |
|
666 LaunchFotaEngineL(); |
|
667 StopServer(); |
|
668 } |
|
669 else |
|
670 { |
|
671 FLOG(_L("CFMSInterruptAob::EventL()--status GPRS not up-- but connmon triggererd")); |
|
672 NotifyL(); |
|
673 } |
|
674 } |
|
675 else |
|
676 { |
|
677 //check the phone status |
|
678 // Not available |
|
679 FLOG(_L("CFMSInterruptAob::EventL()--search for GPRS connection not up")); |
|
680 NotifyL(); |
|
681 } |
|
682 } |
|
683 break; |
|
684 } |
|
685 case EConnMonPacketDataAvailable: |
|
686 { |
|
687 CConnMonPacketDataAvailable* eventAvailable; |
|
688 eventAvailable = ( CConnMonPacketDataAvailable* ) &aConnMonEvent; |
|
689 |
|
690 if ( eventAvailable->ConnectionId() == iBearer ) |
|
691 { |
|
692 // Available |
|
693 if(CheckNetworkL()) |
|
694 { |
|
695 FLOG(_L("CFMSInterruptAob::EventL()--status GPRS up")); |
|
696 LaunchFotaEngineL(); |
|
697 StopServer(); |
|
698 } |
|
699 else |
|
700 { |
|
701 FLOG(_L("CFMSInterruptAob::EventL()--status GPRS not up-- but connmon triggererd")); |
|
702 NotifyL(); |
|
703 } |
|
704 } |
|
705 else |
|
706 { |
|
707 //check the phone status |
|
708 // Not available |
|
709 FLOG(_L("CFMSInterruptAob::EventL()--search for GPRS connection not up")); |
|
710 NotifyL(); |
|
711 } |
|
712 break; |
|
713 } |
|
714 default: |
|
715 break; |
|
716 } |
|
717 } |
|
718 |
|
719 //------------------------------------------------------------ |
|
720 // CFMSInterruptAob::SetWcdma |
|
721 //------------------------------------------------------------ |
|
722 void CFMSInterruptAob::SetWcdma() |
|
723 { |
|
724 iWcdma = ETrue; |
|
725 } |
|
726 |
|
727 //------------------------------------------------------------ |
|
728 // CFMSInterruptAob::CheckNetworkRegistryL |
|
729 //------------------------------------------------------------ |
|
730 void CFMSInterruptAob::StartNetworkRegistryCheckL() |
|
731 { |
|
732 FLOG(_L("CFMSInterruptAob::CheckNetworkRegistryL- begin")); |
|
733 iPeriodicNwCheck = CPeriodic::NewL (EPriorityNormal) ; |
|
734 FLOG(_L("CFMSInterruptAob::CheckNetworkRegistryL:-iPeriodicNwCheck created)")); |
|
735 iPeriodicNwCheck->Start( |
|
736 TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*20) |
|
737 , TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*25) |
|
738 , TCallBack(StaticCheckNwRequestL,this) ) ; |
|
739 FLOG(_L("CFMSInterruptAob::CheckNetworkRegistryL- End")); |
|
740 } |
|
741 |
|
742 //------------------------------------------------------------ |
|
743 // CFMSInterruptAob::StopNetworkRegistryCheckL |
|
744 //------------------------------------------------------------ |
|
745 void CFMSInterruptAob::NetworkRegistryCheckL() |
|
746 { |
|
747 FLOG(_L("CFMSInterruptAob::StopNetworkRegistryCheckL- begin")); |
|
748 if(CheckNetworkL()) |
|
749 { |
|
750 FLOG(_L("CFMSInterruptAob::StopNetworkRegistryCheckL-n/w found")); |
|
751 if(iPeriodicNwCheck) |
|
752 { |
|
753 delete iPeriodicNwCheck; |
|
754 iPeriodicNwCheck = NULL; |
|
755 FLOG(_L("CFMSInterruptAob::iPeriodicNwCheck-deleted")); |
|
756 } |
|
757 LaunchFotaEngineL(); |
|
758 StopServer(); |
|
759 } |
|
760 FLOG(_L("CFMSInterruptAob::StopNetworkRegistryCheckL- End")); |
|
761 } |
|
762 |
|
763 //---------------------------------------------------------------------------- |
|
764 // CFMSInterruptAob::StartBatteryMonitoringL |
|
765 // Starts the monitoring of Battery |
|
766 //---------------------------------------------------------------------------- |
|
767 void CFMSInterruptAob::StartBatteryMonitoringL(TFmsIpcCommands aType, TUint aLevel) |
|
768 { |
|
769 FLOG(_L("CFMSInterruptAob::StartBatteryMonitoringL- begin")); |
|
770 |
|
771 __ASSERT_ALWAYS(aLevel > EBatteryLevelLevel0 && aLevel <=EBatteryLevelLevel7, User::Leave(KErrArgument)); |
|
772 |
|
773 iUpdInterruptType = aType; |
|
774 if(iUpdInterruptType == EUpdMonitorbattery) |
|
775 { |
|
776 FLOG(_L("CFMSInterruptAob::Start- EMonitorbattery")); |
|
777 TInt value =0; |
|
778 iChargeToMonitor = aLevel; |
|
779 iProperty.Attach(KPSUidHWRMPowerState,KHWRMBatteryLevel); |
|
780 TInt err=iProperty.Get(KPSUidHWRMPowerState,KHWRMBatteryLevel,value); |
|
781 if(err != KErrNone) |
|
782 { |
|
783 FLOG(_L("CFMSInterruptAob::StartBatteryMonitoringL- error in getiing the battery level")); |
|
784 StopServer(); |
|
785 } |
|
786 if(value >= iChargeToMonitor) |
|
787 { |
|
788 iProperty.Cancel(); |
|
789 iProperty.Close(); |
|
790 TRAPD(err1, LaunchFotaScheduleUpdate()); |
|
791 if (err1) |
|
792 { |
|
793 FLOG(_L("CFMSInterruptAob::error in LaunchFotaScheduleUpdateL()")); |
|
794 } |
|
795 |
|
796 StopServer(); |
|
797 } |
|
798 else |
|
799 { |
|
800 if(!IsActive()) |
|
801 { |
|
802 //RProperty pw; |
|
803 FLOG(_L("CFMSInterruptAob::Start- attaching for battery")); |
|
804 |
|
805 iProperty.Attach(KPSUidHWRMPowerState,KHWRMBatteryLevel); |
|
806 iStatus=KRequestPending; |
|
807 iProperty.Subscribe(iStatus); |
|
808 SetActive(); |
|
809 } |
|
810 } |
|
811 } |
|
812 FLOG(_L("CFMSInterruptAob::StartBatteryMonitoringL- end")); |
|
813 } |
|
814 //---------------------------------------------------------------------------- |
|
815 // CFMSInterruptAob::LaunchFotaScheduleUpdate |
|
816 // Launches the FOTA schedule dialog |
|
817 //---------------------------------------------------------------------------- |
|
818 |
|
819 void CFMSInterruptAob::LaunchFotaScheduleUpdate() |
|
820 { |
|
821 TRAP_IGNORE(iServer->DeleteScheduledRemindersL()); |
|
822 |
|
823 RFotaEngineSession fotaengine; |
|
824 TRAPD(error,fotaengine.OpenL()); |
|
825 if(error == KErrNone) |
|
826 { |
|
827 |
|
828 |
|
829 FLOG(_L("CFMSInterruptAob::LaunchFotaScheduleUpdate()- going for update again")); |
|
830 TFotaScheduledUpdate sched(-1,-1); //trigger the Fota remainder dialog here.. |
|
831 TPckg<TFotaScheduledUpdate> p(sched); |
|
832 TRAPD(err, fotaengine.ScheduledUpdateL(sched)); |
|
833 if(err) |
|
834 { |
|
835 FLOG( _L( "[LaunchFotaScheduleUpdate()] FirmwareUpdate scheduling failed " ) ); |
|
836 } |
|
837 FLOG(_L("CFMSInterruptAob::LaunchFotaScheduleUpdate()- closing fota engine")); |
|
838 iUpdInterruptType = ENoInterrupt; |
|
839 fotaengine.Close(); |
|
840 } |
|
841 else |
|
842 { |
|
843 FLOG(_L("CFMSInterruptAob::LaunchFotaScheduleUpdate()- error in opening the fota engine")); |
|
844 |
|
845 } |
|
846 } |
|
847 |
|
848 //---------------------------------------------------------------------------- |
|
849 // CFMSInterruptAob::CheckNetworkStatusL |
|
850 // Checks the network status |
|
851 //---------------------------------------------------------------------------- |
|
852 void CFMSInterruptAob::CheckNetworkStatusL() |
|
853 { |
|
854 if(CheckNetworkL()) |
|
855 { |
|
856 FLOG(_L("CFMSInterruptAob::RunL()--charging & network found")); |
|
857 LaunchFotaEngineL(); |
|
858 StopServer(); |
|
859 } |
|
860 else |
|
861 { |
|
862 FLOG(_L("CFMSInterruptAob::RunL()--charging but no network found & started monitoring")); |
|
863 //StartNetWorkMonitoring |
|
864 iServer->WriteToFile(EDLNetworkInterrupt, iBearer, EDriveC, 0, iWcdma); |
|
865 StartL(EDLNetworkInterrupt); |
|
866 } |
|
867 } |
|
868 |
|
869 |
|
870 //---------------------------------------------------------------------------- |
|
871 // CFMSInterruptAob::HandleChargingInterruptL |
|
872 // Handle the cherging interrupt |
|
873 //---------------------------------------------------------------------------- |
|
874 void CFMSInterruptAob::HandleChargingInterruptL() |
|
875 { |
|
876 iProperty.Cancel(); |
|
877 iProperty.Close(); |
|
878 //check variation |
|
879 if(iServer->NetworkTobeMonitered()) |
|
880 { |
|
881 //Check network status at this moment |
|
882 CheckNetworkStatusL(); |
|
883 |
|
884 } |
|
885 else |
|
886 { |
|
887 FLOG(_L("CFMSInterruptAob::RunL()--charging & network found")); |
|
888 LaunchFotaEngineL(); |
|
889 StopServer(); |
|
890 } |
|
891 } |
|
892 |
|
893 //---------------------------------------------------------------------------- |
|
894 // CFMSInterruptAob::HandleAboveCriticallevelL |
|
895 // Handle the meory above critical level |
|
896 //---------------------------------------------------------------------------- |
|
897 void CFMSInterruptAob::HandleAboveCriticallevelL() |
|
898 { |
|
899 if(iServer->NetworkTobeMonitered()) |
|
900 { |
|
901 if(CheckNetworkL()) |
|
902 { |
|
903 FLOG(_L("CFMSInterruptAob::RunL()--memory avail & network found")); |
|
904 //Notify fota server |
|
905 LaunchFotaEngineL(); |
|
906 StopServer(); |
|
907 } |
|
908 else |
|
909 { |
|
910 FLOG(_L("CFMSInterruptAob::RunL()--memory avail but no network found")); |
|
911 //StartNetWorkMonitoring |
|
912 iServer->WriteToFile(EDLNetworkInterrupt, iBearer, iDrive, 0, iWcdma); |
|
913 StartL(EDLNetworkInterrupt); |
|
914 } |
|
915 } |
|
916 else |
|
917 { |
|
918 FLOG(_L("CFMSInterruptAob::RunL()--memory avail & no network monitor ")); |
|
919 //Notify fota server |
|
920 LaunchFotaEngineL(); |
|
921 StopServer(); |
|
922 } |
|
923 } |
|
924 //---------------------------------------------------------------------------- |
|
925 // CFMSInterruptAob::LaunchFotaUpdate |
|
926 // Launches the FOTA update dialog |
|
927 //---------------------------------------------------------------------------- |
|
928 |
|
929 void CFMSInterruptAob::LaunchFotaUpdate() |
|
930 { |
|
931 RFotaEngineSession fotaengine; |
|
932 TRAPD(error,fotaengine.OpenL()); |
|
933 if(error == KErrNone) |
|
934 { |
|
935 FLOG(_L("CFMSInterruptAob::LaunchFotaUpdate()- going for update")); |
|
936 TInt err=fotaengine.Update( -1, -1, KNullDesC8, KNullDesC8 ); |
|
937 if(err) |
|
938 { |
|
939 FLOG( _L( "LaunchFotaUpdate() failed " ) ); |
|
940 } |
|
941 FLOG(_L("CFMSInterruptAob::LaunchFotaUpdate()- closing fota engine")); |
|
942 iUpdInterruptType = ENoInterrupt; |
|
943 fotaengine.Close(); |
|
944 } |
|
945 else |
|
946 { |
|
947 FLOG(_L("CFMSInterruptAob::LaunchFotaUpdate()- error in opening the fota engine")); |
|
948 } |
|
949 } |
|
950 |
|
951 |
|
952 |
|
953 //---------------------------------------------------------------------------- |
|
954 // CFMSInterruptAob::StartCallEndMonitoringL |
|
955 // starts monitoring for call end |
|
956 //---------------------------------------------------------------------------- |
|
957 void CFMSInterruptAob::StartCallEndMonitoringL(TFmsIpcCommands aType) |
|
958 { |
|
959 if(!IsActive()) |
|
960 { |
|
961 FLOG(_L("Starting Call End Monitoring:Begin")); |
|
962 iUpdInterruptType = aType; |
|
963 User::LeaveIfError(iTelServer.Connect()); |
|
964 _LIT(KTsyName, "phonetsy.tsy");//TSY module names wouldn't change |
|
965 RTelServer::TPhoneInfo info; |
|
966 RPhone::TLineInfo lineInfo; |
|
967 User::LeaveIfError(iTelServer.LoadPhoneModule(KTsyName)); |
|
968 // Get the details for the first (and only) phone. |
|
969 User::LeaveIfError(iTelServer.GetPhoneInfo(0, info)); |
|
970 // Open the phone. |
|
971 User::LeaveIfError(iPhone.Open(iTelServer, info.iName)); |
|
972 iPhone.Initialise(); |
|
973 TInt numberLines = 0; |
|
974 User::LeaveIfError(iPhone.EnumerateLines(numberLines)); |
|
975 TBool foundLine = EFalse; |
|
976 for (TInt a = 0; a < numberLines; a++) |
|
977 { |
|
978 User::LeaveIfError(iPhone.GetLineInfo(a, lineInfo)); |
|
979 if (lineInfo.iLineCapsFlags & RLine::KCapsVoice) |
|
980 { |
|
981 foundLine = ETrue; |
|
982 break; |
|
983 } |
|
984 } |
|
985 if (!foundLine) |
|
986 { |
|
987 User::Leave(KErrNotFound); |
|
988 } |
|
989 User::LeaveIfError(iLine.Open(iPhone, lineInfo.iName)); |
|
990 iCallStatus = RCall::EStatusIdle; |
|
991 iLine.NotifyStatusChange(iStatus, iCallStatus); |
|
992 SetActive(); |
|
993 } |
|
994 FLOG(_L("Starting Call End Monitoring: end")); |
|
995 } |
|
996 //End of File |
|