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