1 /* |
|
2 * Copyright (c) 2005-2006 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: starts update sequence |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <StringLoader.h> |
|
22 #include <fotaserver.rsg> |
|
23 #include <centralrepository.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknBidiTextUtils.h> |
|
26 #include <biditext.h> |
|
27 #include <gdi.h> |
|
28 #include <fotaengine.h> |
|
29 #include <apgtask.h> |
|
30 #include <SyncMLNotifierParams.h> |
|
31 #include <aknradiobuttonsettingpage.h> |
|
32 #include <akntitle.h> |
|
33 #include <schtime.h> |
|
34 #include <csch_cli.h> |
|
35 |
|
36 #include "fotaupdate.h" |
|
37 #include "fmsclient.h" |
|
38 #include "FotaReminderDlg.h" |
|
39 #include "FotasrvSession.h" |
|
40 #include "fotaserverPrivateCRKeys.h" |
|
41 #include "fotaserverPrivatePSKeys.h" |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 // ============== LOCAL FUNCTIONS ============================================ |
|
48 |
|
49 |
|
50 |
|
51 TInt WriteUpdateBitmapL( const TDesC& aText, const TDesC& aFile) |
|
52 { |
|
53 FLOG(_L("WriteUpdateBitmapL writing %S to %S w/ txtdir"),&aText,&aFile); |
|
54 |
|
55 TSize screensize = CCoeEnv::Static()->ScreenDevice()->SizeInPixels(); |
|
56 TInt width = screensize.iWidth - KBmpMargin*2; |
|
57 TInt height = screensize.iHeight; |
|
58 |
|
59 CArrayFixSeg<TPtrC>* lines = new CArrayFixSeg<TPtrC>(5); |
|
60 CleanupStack::PushL(lines); |
|
61 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap; |
|
62 CleanupStack::PushL( bitmap ); |
|
63 bitmap->Create( TSize(width,height), EColor64K ); |
|
64 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( bitmap ); |
|
65 CleanupStack::PushL( device ); |
|
66 const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont); |
|
67 CFbsBitGc* context; |
|
68 User::LeaveIfError( device->CreateContext( context ) ); |
|
69 CleanupStack::PushL( context ); |
|
70 TInt ascent = font->AscentInPixels(); |
|
71 TInt descent = font->DescentInPixels(); |
|
72 context->UseFont ( font ); |
|
73 context->Clear(); // bg color |
|
74 |
|
75 // Visually ordered text |
|
76 HBufC* wrappedstring = AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( |
|
77 aText, width,*font, *lines); |
|
78 CleanupStack::PushL ( wrappedstring ); |
|
79 TBool dirfound (ETrue); |
|
80 // direction of text, affects alignemnt |
|
81 TBidiText::TDirectionality direction = TBidiText::TextDirectionality( |
|
82 *wrappedstring, &dirfound ); |
|
83 |
|
84 // Print visual text to bitmap |
|
85 for ( TInt i=0; i<lines->Count(); ++i ) |
|
86 { |
|
87 TPtrC l = (*lines)[i]; |
|
88 TInt top = (ascent+descent)*(i); |
|
89 TInt bot = (ascent+descent)*(i+1); |
|
90 TRect rect (0, top ,width, bot ); |
|
91 CGraphicsContext::TTextAlign alignment = |
|
92 direction==TBidiText::ELeftToRight ? CGraphicsContext::ELeft |
|
93 : CGraphicsContext::ERight; |
|
94 context->DrawText(l, rect, ascent, alignment); |
|
95 } |
|
96 height = (ascent+descent)*lines->Count() + descent; |
|
97 bitmap->Resize( TSize(width,height)); |
|
98 bitmap->Save( aFile ); |
|
99 context->DiscardFont(); |
|
100 CleanupStack::PopAndDestroy( wrappedstring ); |
|
101 CleanupStack::PopAndDestroy( context ); |
|
102 CleanupStack::PopAndDestroy( device ); |
|
103 CleanupStack::PopAndDestroy( bitmap ); |
|
104 CleanupStack::PopAndDestroy( lines ); |
|
105 return 1; |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // PackageFileName Creates pgk filename ,like 5.swupd |
|
111 // --------------------------------------------------------------------------- |
|
112 void PackageFileName( TInt aPkgid, TDes8& aFileName ) |
|
113 { |
|
114 aFileName.AppendNum(aPkgid); |
|
115 aFileName.Append( KSwupdFileExt8 ); |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // PackageFilePath Creates pk file path, like c:\\private\\102072C4\\5.swupd |
|
121 // --------------------------------------------------------------------------- |
|
122 void PackageFilePath( TInt aPkgid, TDes8& aPath ) |
|
123 { |
|
124 TBuf8<20> fn; |
|
125 PackageFileName ( aPkgid,fn); |
|
126 aPath.Append(KSwupdPath8); |
|
127 aPath.Append(fn); |
|
128 } |
|
129 |
|
130 // ============================= MEMBER FUNCTIONS ============================ |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CFotaUpdate::CFotaUpdate() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 CFotaUpdate::CFotaUpdate() : CActive(EPriorityNormal) |
|
138 ,iScheduledUpdate(NULL),iHandleUpdateAcceptLater(EFalse) |
|
139 { |
|
140 CActiveScheduler::Add( this ); |
|
141 iNotifParams.iNoteType = ESyncMLFwUpdUnknown; |
|
142 iNotifParams.iIntParam = 0; |
|
143 iChargeToMonitor = 0; |
|
144 iFinalizeLater = EFalse; |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CFotaUpdate::~CFotaUpdate() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 CFotaUpdate::~CFotaUpdate() |
|
153 { |
|
154 if(iScheduledUpdate) |
|
155 { |
|
156 delete iScheduledUpdate; |
|
157 iScheduledUpdate = NULL; |
|
158 } |
|
159 iIntervalType.Close(); |
|
160 iInterval.Close(); |
|
161 } |
|
162 |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CFotaUpdate::NewL |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 CFotaUpdate* CFotaUpdate::NewL (CFotaServer* aServer) |
|
169 { |
|
170 CFotaUpdate* ao = new (ELeave) CFotaUpdate(); |
|
171 ao->iFotaServer = aServer; |
|
172 return ao; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CFotaUpdate::CheckUpdateResults |
|
177 // Checks if there is update result file available (meaning that update just |
|
178 // took place) |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 TBool CFotaUpdate::CheckUpdateResults( RFs& aRfs ) |
|
182 { |
|
183 RFile f; |
|
184 TInt err; |
|
185 err = f.Open ( aRfs, KUpdateResultFile, EFileShareAny ); |
|
186 f.Close(); |
|
187 if ( err!=KErrNone ) |
|
188 { |
|
189 return EFalse; |
|
190 } |
|
191 FLOG(_L(" CFotaUpdate::CheckUpdateResults update result file Found! ")); |
|
192 return ETrue; |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CFotaUpdate::ExecuteUpdateResultFileL |
|
198 // Read result code from update result file and update state accordingly. |
|
199 // Show notifier "Update succesful". Do some cleanup. |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CFotaUpdate::ExecuteUpdateResultFileL( RFs& aRfs ) |
|
203 { |
|
204 FLOG(_L("CFotaUpdate::ExecuteUpdateResultFileL >>")); |
|
205 iFs = &aRfs; |
|
206 TInt err; |
|
207 RFileReadStream rstr; |
|
208 TInt result; |
|
209 TInt msglen; |
|
210 HBufC8* message=NULL; |
|
211 HBufC16* message16=NULL; |
|
212 TBool deleteData ( EFalse ); |
|
213 |
|
214 // Open update result file |
|
215 FLOG(_L("opening rstr 1/2 ")); |
|
216 err = rstr.Open(*iFs,KUpdateResultFile ,EFileRead|EFileStream); |
|
217 FLOG(_L("opened rstr 2/2 ")); |
|
218 if(err) FLOG(_L(" update result file open err %d"), err); |
|
219 User::LeaveIfError (err ); |
|
220 FLOG(_L(" 0.1")); |
|
221 CleanupClosePushL( rstr ); |
|
222 FLOG(_L(" 0.2")); |
|
223 |
|
224 // Read resultcode |
|
225 result = rstr.ReadUint32L(); FLOG(_L(" 0.3")); |
|
226 msglen = rstr.ReadUint32L(); FLOG(_L(" 0.4 result: %d \ |
|
227 msglen:%d "), result, msglen); |
|
228 if(msglen != 0) |
|
229 { |
|
230 FLOG(_L(" 0.5 reading msg")); |
|
231 message = HBufC8::NewLC(msglen+1); |
|
232 TPtr8 ptrdesc = message->Des(); |
|
233 TRAPD ( err2, rstr.ReadL(ptrdesc) ); |
|
234 if ( err2 != KErrNone && err2 != KErrEof) |
|
235 { |
|
236 FLOG(_L(" file read err %d"),err2); User::Leave( err2 ); |
|
237 } |
|
238 |
|
239 message16 = HBufC16::NewLC (message->Des().Length()); |
|
240 message16->Des().Copy( *message ); |
|
241 FLOG(_L(" 1 update result: %d"), result) ; |
|
242 FLOG(_L(" 2 dbg msg: %S"),message16); |
|
243 CleanupStack::PopAndDestroy( message16 ); |
|
244 CleanupStack::PopAndDestroy( message ); |
|
245 } |
|
246 |
|
247 FLOG(_L(" 0.6 ")); |
|
248 CleanupStack::PopAndDestroy( &rstr ); |
|
249 |
|
250 // Map resultcode to FUMO result code |
|
251 RFotaEngineSession::TState fstate |
|
252 = RFotaEngineSession::EUpdateFailed; |
|
253 RFotaEngineSession::TResult fresult |
|
254 = RFotaEngineSession::EResUpdateFailed; |
|
255 |
|
256 TDriveNumber drive; |
|
257 TBool toencrypt = iFotaServer->NeedToEncryptL(drive); |
|
258 |
|
259 FLOG(_L(" 3")); |
|
260 switch ( result ) |
|
261 { |
|
262 case UPD_OK: |
|
263 { |
|
264 fstate = RFotaEngineSession::EUpdateSuccessfulNoData; |
|
265 fresult = RFotaEngineSession::EResSuccessful; |
|
266 deleteData = ETrue; |
|
267 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNone, toencrypt ); |
|
268 } |
|
269 break; |
|
270 case UPD_INSTALL_REQUEST_IS_INVALID: |
|
271 { |
|
272 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
273 fresult = RFotaEngineSession::EResUpdateFailed; |
|
274 deleteData = ETrue; |
|
275 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotFound, toencrypt ); |
|
276 } |
|
277 break; |
|
278 case UPD_UPDATE_PACKAGE_IS_ABSENT: |
|
279 { |
|
280 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
281 fresult = RFotaEngineSession::EResUpdateFailed; |
|
282 } |
|
283 break; |
|
284 case UPD_UPDATE_PACKAGE_IS_CORRUPTED: |
|
285 { |
|
286 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
287 fresult = RFotaEngineSession::EResCorruptedFWUPD; |
|
288 deleteData = ETrue; |
|
289 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotSupported, toencrypt ); |
|
290 } |
|
291 break; |
|
292 case UPD_UPDATE_PACKAGE_CONTENTS_IS_INVALID: |
|
293 { |
|
294 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
295 fresult = RFotaEngineSession::EResCorruptedFWUPD; |
|
296 deleteData = ETrue; |
|
297 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotSupported, toencrypt ); |
|
298 } |
|
299 break; |
|
300 case UPD_UPDATE_PACKAGE_IS_NOT_COMPATIBLE_WITH_CURRENT_MOBILE_DEVICE: |
|
301 { |
|
302 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
303 fresult = RFotaEngineSession::EResPackageMismatch; |
|
304 deleteData = ETrue; |
|
305 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotSupported, toencrypt ); |
|
306 } |
|
307 break; |
|
308 case UPD_FATAL_ERROR: |
|
309 { |
|
310 fstate = RFotaEngineSession::EUpdateFailedNoData; |
|
311 fresult = RFotaEngineSession::EResUpdateFailed; |
|
312 deleteData = ETrue; |
|
313 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotFound, toencrypt ); |
|
314 } |
|
315 break; |
|
316 |
|
317 default: |
|
318 { |
|
319 FLOG(_L(" 3.1 invalid result: %d"), result); |
|
320 LaunchNotifierL ( ESyncMLFwUpdResultNote, KErrNotFound, toencrypt ); |
|
321 } |
|
322 break; |
|
323 } |
|
324 |
|
325 // Find the state 60 (update progressing) -> 100 (etc) |
|
326 RArray<TInt> states; |
|
327 TPackageState state; |
|
328 CleanupClosePushL (states); |
|
329 iFotaServer->iDatabase->OpenDBL(); |
|
330 iFotaServer->iDatabase->GetAllL(states); |
|
331 |
|
332 FLOG(_L(" 4.1 found %d states "),states.Count() ); |
|
333 for(TInt i=0;i<states.Count(); ++i ) |
|
334 { |
|
335 TPackageState tmp; |
|
336 tmp = iFotaServer->iDatabase->GetStateL( states[i] ); |
|
337 FLOG(_L(" 5 got state ")); |
|
338 if ( tmp.iState == RFotaEngineSession::EUpdateProgressing ) |
|
339 { |
|
340 state = tmp; |
|
341 state.iState = fstate; |
|
342 state.iResult = fresult; |
|
343 FLOG(_L(" 6 Updating state id %d to %d ,result %d ") |
|
344 ,state.iPkgId, state.iState,state.iResult ); |
|
345 iFotaServer->iDatabase->SetStateL(state,KNullDesC8 |
|
346 ,EFDBState|EFDBResult ) ; |
|
347 } |
|
348 } |
|
349 iFotaServer->iDatabase->CloseAndCommitDB(); |
|
350 CleanupStack::PopAndDestroy(&states); |
|
351 |
|
352 |
|
353 // Delete request file |
|
354 err = BaflUtils::DeleteFile ( *iFs, KUpdateRequestFile ); |
|
355 if ( err != KErrNone && err != KErrNotFound ) |
|
356 { |
|
357 FLOG(_L(" 6.1 req file deleted, err %d"), err); |
|
358 User::Leave(err); |
|
359 } |
|
360 |
|
361 // Write timestamp (shown to user in device management ui) |
|
362 if( fresult == RFotaEngineSession::EResSuccessful ) |
|
363 { |
|
364 RFileWriteStream wstr; |
|
365 TTime time; |
|
366 User::LeaveIfError( wstr.Replace( *iFs, KUpdateTimeStampFileName |
|
367 ,EFileWrite ) ); |
|
368 CleanupClosePushL ( wstr ); |
|
369 time.HomeTime(); |
|
370 TInt year = time.DateTime().Year(); |
|
371 TInt month = time.DateTime().Month(); |
|
372 TInt day = time.DateTime().Day(); |
|
373 TInt hour = time.DateTime().Hour(); |
|
374 TInt minute = time.DateTime().Minute(); |
|
375 wstr.WriteInt32L(year) ; |
|
376 wstr.WriteInt32L(month) ; |
|
377 wstr.WriteInt32L(day) ; |
|
378 wstr.WriteInt32L(hour) ; |
|
379 wstr.WriteInt32L(minute) ; |
|
380 CleanupStack::PopAndDestroy (1); // wstr |
|
381 } |
|
382 // Delete package content |
|
383 if ( deleteData && state.iPkgId > KErrNotFound ) |
|
384 { |
|
385 iFotaServer->StoragePluginL()->DeleteUpdatePackageL( state.iPkgId ) ; |
|
386 } |
|
387 |
|
388 |
|
389 // Report state back to syncml server |
|
390 if ( state.iPkgId >= 0 ) |
|
391 { |
|
392 FLOG(_L(" 6.1 creating device mgmt session for profile %d") |
|
393 ,state.iProfileId); |
|
394 iFotaServer->CreateDeviceManagementSessionL( state ); |
|
395 } |
|
396 else |
|
397 { |
|
398 FLOG(_L(" No state found in 'update progress' mode! cannot report\ |
|
399 status to DM server ")); |
|
400 } |
|
401 |
|
402 FLOG(_L("CFotaUpdate::ExecuteUpdateResultFileL <<")); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CFotaUpdate::DeleteUpdateResultsL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CFotaUpdate::DeleteUpdateResultFileL( RFs& aRfs ) |
|
410 { |
|
411 FLOG(_L("CFotaUpdate::DeleteUpdateResultsL ")); |
|
412 // Delete result file |
|
413 BaflUtils::DeleteFile( aRfs, KUpdateResultFile ); |
|
414 BaflUtils::DeleteFile( aRfs, KUpdateRequestFile ); |
|
415 BaflUtils::DeleteFile( aRfs, KUpdateBitmap ); |
|
416 BaflUtils::DeleteFile( aRfs, KRestartingBitmap ); |
|
417 } |
|
418 |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // CFotaUpdate::RunL |
|
422 // Handles user selection (button press: accept/ cancel update) |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 void CFotaUpdate::RunL() |
|
426 { |
|
427 FLOG(_L( "[FotaServer] CFotaUpdate::RunL() >> %d" ),iStatus.Int() ); |
|
428 TBool handled( EFalse ); |
|
429 User::LeaveIfError(iNotifier.CancelNotifier(KSyncMLFwUpdNotifierUid)); |
|
430 iNotifier.Close(); |
|
431 |
|
432 if (iStatus.Int() == KErrNotFound ) |
|
433 { |
|
434 FLOG(_L("Exiting....")); |
|
435 TApaTaskList taskList(iFotaServer->GetEikEnv()->WsSession()); |
|
436 TApaTask task=taskList.FindApp(TUid::Uid(KOmaDMAppUid)); |
|
437 if(task.Exists()) |
|
438 { |
|
439 task.EndTask(); |
|
440 } |
|
441 return; |
|
442 |
|
443 } |
|
444 // Handle update start query |
|
445 if ( iNotifParams.iNoteType == ESyncMLFwUpdStartQuery ) |
|
446 { |
|
447 FLOG(_L(" update start query")); |
|
448 // User pressed accept |
|
449 if ( iStatus.Int() == KErrNone ) |
|
450 { |
|
451 handled = ETrue; |
|
452 HandleUpdateAcceptStartL(); |
|
453 } |
|
454 // User pressed later |
|
455 else if ( iStatus.Int() == KErrCancel ) |
|
456 { |
|
457 |
|
458 FLOG(_L("USER PRESSED LATER")); |
|
459 handled = ETrue; |
|
460 HandleUpdateAcceptLaterL(); |
|
461 } |
|
462 } |
|
463 if ( iNotifParams.iNoteType == ESyncMLFwUpdStartQueryEnc ) |
|
464 { |
|
465 FLOG(_L(" update start query")); |
|
466 |
|
467 if ( iStatus.Int() == KErrNone ) |
|
468 { |
|
469 FLOG(_L(" user accepted query to decrypt memory")); |
|
470 handled = ETrue; |
|
471 TRAPD(err, iFotaServer->DoStartDecryptionL()); |
|
472 |
|
473 if (err == KErrNotReady) |
|
474 { |
|
475 HandleUpdateErrorL(err); |
|
476 } |
|
477 } |
|
478 else if (iStatus.Int() == KErrCancel ) |
|
479 { |
|
480 FLOG(_L("User pressed cancel. Don't decrypt. Stop.")); |
|
481 handled = ETrue; |
|
482 LaunchNotifierL( ESyncMLFwUpdNoReminder , KErrNone ); |
|
483 } |
|
484 |
|
485 } |
|
486 // Handle battery error |
|
487 if ( iNotifParams.iNoteType == ESyncMLFwUpdErrorNote ) |
|
488 { |
|
489 |
|
490 if (iNotifParams.iIntParam == KErrBadPower || iNotifParams.iIntParam == KErrBadUsbPower) |
|
491 { |
|
492 FLOG(_L(" battery note")); |
|
493 if ( iStatus.Int() == KErrNone ) |
|
494 { |
|
495 handled = ETrue; |
|
496 |
|
497 // Still check batt. (user might have connected charger) |
|
498 |
|
499 HandleErrorBasedonChargingTypeL(); |
|
500 |
|
501 } |
|
502 else if (iNotifParams.iIntParam == KErrDeviceMemoryBusy) |
|
503 { |
|
504 FLOG(_L("Do nothing. Stop the update.")); |
|
505 iFotaServer->FinalizeUpdateL(); |
|
506 } |
|
507 else if (iNotifParams.iIntParam == KErrBadPowerForEnc) |
|
508 { |
|
509 if (iFinalizeLater) |
|
510 { |
|
511 FLOG(_L("Finalizing update now...")); |
|
512 iFinalizeLater = EFalse; |
|
513 iFotaServer->FinalizeUpdateL(); |
|
514 } |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 // Handle update complete notification |
|
520 if ( iNotifParams.iNoteType == ESyncMLFwUpdResultNote ) |
|
521 { |
|
522 handled = ETrue; |
|
523 DeleteUpdateResultFileL( iFotaServer->iFs ); |
|
524 if (!iNotifParams.iEncryptReq) |
|
525 { |
|
526 FLOG(_L("Going to finalize update...")); |
|
527 iFotaServer->FinalizeUpdateL(); |
|
528 } |
|
529 |
|
530 } |
|
531 if ( iNotifParams.iNoteType == ESyncMLFwUpdNoReminder ) |
|
532 { |
|
533 FLOG(_L(" No Reminder selected")); |
|
534 if ( iStatus.Int() == KErrNone ) |
|
535 { |
|
536 handled = ETrue; |
|
537 |
|
538 FindScheduleL( ETrue ); |
|
539 iUpdateState.iState = RFotaEngineSession::EStartingUpdate; |
|
540 iFotaServer->iDatabase->OpenDBL(); |
|
541 iFotaServer->iDatabase->SetStateL(iUpdateState ,KNullDesC8,EFDBState); |
|
542 iFotaServer->iDatabase->CloseAndCommitDB(); |
|
543 |
|
544 // Report state back to syncml server |
|
545 if ( iUpdateState.iPkgId >= 0 && iUpdateState.iSendAlert ) |
|
546 { |
|
547 FLOG(_L(" creating device mgmt session for profile %d") |
|
548 ,iUpdateState.iProfileId); |
|
549 iFotaServer->CreateDeviceManagementSessionL( iUpdateState ); |
|
550 } |
|
551 iFotaServer->FinalizeUpdateL(); |
|
552 } |
|
553 } |
|
554 if ( iNotifParams.iNoteType == ESyncMLFwUpdResultNote && iNotifParams.iEncryptReq) |
|
555 { |
|
556 if (iStatus.Int() == KErrNone) |
|
557 { |
|
558 FLOG(_L("User wanted to start encryption...")); |
|
559 iFotaServer->DoStartEncryptionL(); |
|
560 } |
|
561 else |
|
562 { |
|
563 FLOG(_L("User do not want to start encryption.")); |
|
564 } |
|
565 if (!iFinalizeLater) |
|
566 iFotaServer->FinalizeUpdateL(); |
|
567 } |
|
568 if ( !handled ) |
|
569 { |
|
570 FLOG(_L("CANNOT INTERPRET NOTIFIER RESULT CODE: %d"), iStatus.Int() ); |
|
571 } |
|
572 |
|
573 FLOG(_L( "[FotaServer] CFotaUpdate::RunL() <<" ) ); |
|
574 } |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // CFotaUpdate::HandleUpdateAcceptStartL() |
|
582 // Handles user selection of NOW |
|
583 // --------------------------------------------------------------------------- |
|
584 // |
|
585 void CFotaUpdate::HandleUpdateAcceptStartL(TBool aSkipBatteryChk) |
|
586 { |
|
587 FLOG(_L("USER PRESSED ACCEPT")); |
|
588 |
|
589 TBool enoughPower (EFalse); |
|
590 TInt usbchargingsupport =0; |
|
591 if (aSkipBatteryChk) |
|
592 { |
|
593 enoughPower = ETrue; |
|
594 } |
|
595 else |
|
596 { |
|
597 CRepository* centrep = NULL; |
|
598 //centrep = CRepository::NewLC( TUid::Uid(KFotaServerUid)); |
|
599 TRAPD(err, centrep = CRepository::NewL( TUid::Uid(KFotaServerUid))); |
|
600 if(err) |
|
601 { |
|
602 FLOG(_L("reading from cenrep failed")); |
|
603 } |
|
604 |
|
605 if(centrep) |
|
606 {centrep->Get( KFotaUSBChargerEnabled , usbchargingsupport ); |
|
607 if(usbchargingsupport != 0 && usbchargingsupport != 1) |
|
608 usbchargingsupport =0; |
|
609 delete centrep; |
|
610 } |
|
611 centrep = NULL; |
|
612 enoughPower = CheckBatteryL(usbchargingsupport); |
|
613 #if defined(__WINS__) |
|
614 enoughPower = ETrue; |
|
615 #endif |
|
616 } |
|
617 // Failure due to low battery |
|
618 if ( !enoughPower ) |
|
619 { |
|
620 FLOG(_L("Launching low battery notifier")); |
|
621 if(!usbchargingsupport) |
|
622 LaunchNotifierL( ESyncMLFwUpdErrorNote, KErrBadPower ); |
|
623 else |
|
624 LaunchNotifierL( ESyncMLFwUpdErrorNote , KErrBadUsbPower ); |
|
625 } |
|
626 else |
|
627 { |
|
628 UpdateL(); |
|
629 } |
|
630 } |
|
631 |
|
632 |
|
633 void CFotaUpdate::HandleUpdateErrorL(TInt aError, TInt aValue) |
|
634 { |
|
635 FLOG(_L("CFotaUpdate::HandleUpdateErrorL, error = %d, value = %d >>"), aError, aValue); |
|
636 |
|
637 switch (aError) |
|
638 { |
|
639 case KErrNotReady: //Called from within StartUpdate |
|
640 { |
|
641 LaunchNotifierL(ESyncMLFwUpdErrorNote,KErrDeviceMemoryBusy); |
|
642 } |
|
643 break; |
|
644 case KErrBadPower: //Called from fotaserver when battery power is not enough |
|
645 { |
|
646 iChargeToMonitor = aValue; |
|
647 CRepository* centrep = NULL; |
|
648 TRAPD(err, centrep = CRepository::NewL( TUid::Uid(KFotaServerUid))); |
|
649 if(err) |
|
650 { |
|
651 FLOG(_L("reading from cenrep failed")); |
|
652 } |
|
653 TInt usbchargingsupport =0; |
|
654 if(centrep) |
|
655 {centrep->Get( KFotaUSBChargerEnabled , usbchargingsupport ); |
|
656 if(usbchargingsupport != 0 && usbchargingsupport != 1) |
|
657 usbchargingsupport =0; |
|
658 delete centrep; |
|
659 } |
|
660 centrep = NULL; |
|
661 FLOG(_L("Launching low battery notifier, usbsupport = %d, state = %d"), usbchargingsupport, iUpdateState.iState); |
|
662 if(!usbchargingsupport ) |
|
663 { |
|
664 FLOG(_L("Here 1")); |
|
665 if (iUpdateState.iState == RFotaEngineSession::EStartingUpdate) |
|
666 { |
|
667 FLOG(_L("Here 2")); |
|
668 LaunchNotifierL( ESyncMLFwUpdErrorNote, KErrBadPower ); |
|
669 } |
|
670 } |
|
671 else |
|
672 { |
|
673 LaunchNotifierL( ESyncMLFwUpdErrorNote , KErrBadUsbPower ); |
|
674 } |
|
675 |
|
676 } |
|
677 break; |
|
678 default: |
|
679 { |
|
680 //Do nothing |
|
681 } |
|
682 } |
|
683 |
|
684 |
|
685 FLOG(_L("CFotaUpdate::HandleUpdateErrorL <<")); |
|
686 } |
|
687 |
|
688 void CFotaUpdate::HandleEncryptionErrorL(TInt aError) |
|
689 { |
|
690 FLOG(_L("CFotaUpdate::HandleEncryptionErrorL, error = %d >>"), aError); |
|
691 |
|
692 if (aError == KErrBadPower) |
|
693 { |
|
694 iFinalizeLater = ETrue; |
|
695 LaunchNotifierL(ESyncMLFwUpdErrorNote, KErrBadPowerForEnc); |
|
696 } |
|
697 else |
|
698 { |
|
699 FLOG(_L("Unknown error. Ignored")); |
|
700 } |
|
701 |
|
702 FLOG(_L("CFotaUpdate::HandleEncryptionErrorL <<")); |
|
703 } |
|
704 |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // CFotaUpdate::HandleUpdateAcceptLaterL |
|
708 // Handles user selection of Later |
|
709 // --------------------------------------------------------------------------- |
|
710 void CFotaUpdate::HandleUpdateAcceptLaterL() |
|
711 { |
|
712 TInt fotaUpdateAppName (EFotaUpdateDM); |
|
713 TInt err = RProperty::Get( KPSUidNSmlDMSyncApp, KNSmlCurrentFotaUpdateAppName, fotaUpdateAppName ); |
|
714 FLOG(_L("Setting iHandleUpdateAcceptLater to True")); |
|
715 |
|
716 if (!err && ((fotaUpdateAppName == EFotaUpdateNSC) || (fotaUpdateAppName == EFotaUpdateNSCBg ))) |
|
717 { |
|
718 iFotaServer->FinalizeUpdateL(); //make sure it is not called 2 times |
|
719 } |
|
720 else |
|
721 { |
|
722 iHandleUpdateAcceptLater = ETrue; |
|
723 ShowReminderDialogL(); |
|
724 } |
|
725 } |
|
726 |
|
727 |
|
728 // --------------------------------------------------------------------------- |
|
729 // CFotaUpdate::HandleErrorBasedonChargingTypeL |
|
730 // Handles the error based on charger type supported by the device |
|
731 // --------------------------------------------------------------------------- |
|
732 |
|
733 void CFotaUpdate::HandleErrorBasedonChargingTypeL() |
|
734 { |
|
735 FLOG(_L("CFotaUpdate::HandleErrorBasedonChargingTypeL >>")); |
|
736 |
|
737 if (iUpdateState.iState == RFotaEngineSession::EStartingUpdate) |
|
738 { |
|
739 if (iNotifParams.iIntParam == KErrBadUsbPower) |
|
740 { |
|
741 FLOG(_L("handling usb charger error ")); |
|
742 SetUpdateFailedStatesL(); |
|
743 FLOG(_L("calling for monitoring the battery")); |
|
744 iFotaServer->MonitorBattery(iChargeToMonitor); |
|
745 iFotaServer->FinalizeUpdateL(); |
|
746 } |
|
747 else |
|
748 { |
|
749 TInt usbcharger = KErrNone; |
|
750 TBool enoughPower = CheckBatteryL(usbcharger); |
|
751 |
|
752 #if defined(__WINS__) |
|
753 //It will not come here, just used for testing. |
|
754 enoughPower = ETrue; |
|
755 #endif |
|
756 |
|
757 if (enoughPower) |
|
758 { |
|
759 //User has connected the charger |
|
760 FLOG(_L("User has connected the charger")); |
|
761 UpdateL(); |
|
762 } |
|
763 else |
|
764 { |
|
765 FLOG(_L("User hasn't connected the charger")); |
|
766 //User hasn't connected the charger, hence notify user to update later. |
|
767 SetUpdateFailedStatesL(); |
|
768 //Call reminder here |
|
769 if(!iHandleUpdateAcceptLater) |
|
770 { |
|
771 FLOG(_L("calling HandleUpdateAcceptLaterL")); |
|
772 HandleUpdateAcceptLaterL(); |
|
773 } |
|
774 iHandleUpdateAcceptLater = EFalse; |
|
775 } |
|
776 } |
|
777 } |
|
778 else //must be during encryption after update |
|
779 { |
|
780 if (iNotifParams.iIntParam == KErrBadUsbPower) |
|
781 { |
|
782 iFotaServer->MonitorBattery(iChargeToMonitor); |
|
783 } |
|
784 else |
|
785 { |
|
786 //nothing to do for dynamo charging |
|
787 } |
|
788 iFotaServer->FinalizeUpdateL(); |
|
789 } |
|
790 FLOG(_L("CFotaUpdate::HandleErrorBasedonChargingTypeL <<")); |
|
791 } |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // CFotaUpdate::SetUpdateFailedStatesL |
|
795 // Set the state to update failed |
|
796 // --------------------------------------------------------------------------- |
|
797 |
|
798 void CFotaUpdate::SetUpdateFailedStatesL() |
|
799 { |
|
800 FLOG(_L("CFotaUpdate::SetUpdateFailedStatesL >>")); |
|
801 |
|
802 iUpdateState.iState = RFotaEngineSession::EStartingUpdate; |
|
803 iUpdateState.iResult= RFotaEngineSession::EResUpdateFailed; |
|
804 iFotaServer->iDatabase->OpenDBL(); |
|
805 iFotaServer->iDatabase->SetStateL( iUpdateState ,KNullDesC8 |
|
806 ,EFDBState|EFDBResult ); |
|
807 iFotaServer->iDatabase->CloseAndCommitDB(); |
|
808 |
|
809 FLOG(_L("CFotaUpdate::SetUpdateFailedStatesL <<")); |
|
810 |
|
811 } |
|
812 |
|
813 |
|
814 // --------------------------------------------------------------------------- |
|
815 // CFotaUpdate::DoCancel() |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 void CFotaUpdate::DoCancel() |
|
819 { |
|
820 FLOG(_L("CFotaUpdate::DoCancel() >>")); |
|
821 iNotifier.CancelNotifier(KSyncMLFwUpdNotifierUid); |
|
822 iNotifier.Close(); |
|
823 FLOG(_L("CFotaUpdate::DoCancel() <<")); |
|
824 } |
|
825 |
|
826 // --------------------------------------------------------------------------- |
|
827 // CFotaUpdate::RunError(TInt aError) |
|
828 // --------------------------------------------------------------------------- |
|
829 // |
|
830 TInt CFotaUpdate::RunError(TInt aError) |
|
831 { |
|
832 FLOG(_L("CFotaUpdate::RunError >> err %d"),aError); |
|
833 FLOG(_L("CFotaUpdate::RunError << err %d"),aError); |
|
834 return KErrNone; |
|
835 } |
|
836 |
|
837 // --------------------------------------------------------------------------- |
|
838 // CSyncMLNTestAppAO::LaunchNotifierL |
|
839 // Shows one of the following queries: "update now?", "update success", |
|
840 // "update fail", "too low battery" |
|
841 // --------------------------------------------------------------------------- |
|
842 void CFotaUpdate::LaunchNotifierL( const TSyncMLFwUpdNoteTypes aNotetype |
|
843 ,const TInt aIntParam, const TBool aEnc ) |
|
844 { |
|
845 FLOG(_L("CFotaUpdate::LaunchNotifierL() >> prof.Id: %d") |
|
846 ,iUpdateState.iProfileId); |
|
847 if (!IsActive()) |
|
848 { |
|
849 TSyncMLFwUpdNotifParams params; |
|
850 params.iNoteType = aNotetype; |
|
851 params.iIntParam = aIntParam; |
|
852 params.iEncryptReq = aEnc; |
|
853 TSyncMLFwUpdNotifParamsPckg pckg(params); |
|
854 iNotifParams.iNoteType = params.iNoteType; |
|
855 iNotifParams.iIntParam = params.iIntParam; |
|
856 iNotifParams.iEncryptReq = params.iEncryptReq; |
|
857 iDummyResponsePckg = TSyncMLFwUpdNotifRetValPckg(); |
|
858 User::LeaveIfError( iNotifier.Connect() ); |
|
859 iNotifier.StartNotifierAndGetResponse( iStatus,KSyncMLFwUpdNotifierUid |
|
860 , pckg, iDummyResponsePckg ); |
|
861 SetActive(); |
|
862 } |
|
863 FLOG(_L("CFotaUpdate::LaunchNotifierL() <<")); |
|
864 } |
|
865 |
|
866 |
|
867 // --------------------------------------------------------------------------- |
|
868 // CFotaUpdate::UpdateL |
|
869 // Updates the fw: Creates input files for update agent and boots device to |
|
870 // update mode. |
|
871 // --------------------------------------------------------------------------- |
|
872 void CFotaUpdate::UpdateL() |
|
873 { |
|
874 FLOG(_L("CFotaUpdate::UpdateL() >>")); |
|
875 // Set state ........................................ |
|
876 iUpdateState.iState = RFotaEngineSession::EUpdateProgressing; |
|
877 iFotaServer->iDatabase->OpenDBL(); |
|
878 iFotaServer->iDatabase->SetStateL( iUpdateState ,KNullDesC8, EFDBState ); |
|
879 iFotaServer->iDatabase->CloseAndCommitDB(); |
|
880 |
|
881 // Write update request for update agent.............. |
|
882 FLOG(_L("CFotaUpdate::UpdateL 1 writing update.req ")); |
|
883 TBuf8<150> dp2filepath; |
|
884 HBufC16* dp2; |
|
885 RFileWriteStream wstr; |
|
886 CleanupClosePushL ( wstr ); |
|
887 FLOG(_L("CFotaUpdate::UpdateL 2 getting pkg location")); |
|
888 iFotaServer->StoragePluginL()->GetUpdatePackageLocationL( |
|
889 iUpdateState.iPkgId, dp2filepath ); |
|
890 FLOG(_L("CFotaUpdate::UpdateL 3 craeting update.req") ); |
|
891 User::LeaveIfError( wstr.Replace( iFotaServer->iFs |
|
892 ,KUpdateRequestFile, EFileWrite ) ); |
|
893 wstr.WriteInt16L( 1 ); // version number is 1 |
|
894 wstr.WriteInt32L( 1 ); // count of cmds is 1 |
|
895 wstr.WriteInt16L( 0 ); // requestid is 0 |
|
896 |
|
897 dp2 = HBufC16::NewLC ( dp2filepath.Length( ) ); |
|
898 dp2->Des().Copy( dp2filepath ); |
|
899 wstr.WriteInt32L( dp2->Des().Length() + 1 ); // length of filename + null |
|
900 wstr.WriteL( dp2->Des() ); |
|
901 wstr.WriteInt16L( 0 ); // null character |
|
902 CleanupStack::PopAndDestroy( dp2 ); |
|
903 CleanupStack::PopAndDestroy( &wstr ); // wstr |
|
904 |
|
905 FLOG(_L("CFotaUpdate::UpdateL 4 craeting update.bmp") ); |
|
906 |
|
907 // Write update graphic for update agent ............... |
|
908 HBufC* updatetxt; |
|
909 HBufC* restarttxt; |
|
910 updatetxt = StringLoader::LoadLC( R_APPS_FOTA_UPDATING ); |
|
911 restarttxt = StringLoader::LoadLC( R_APPS_FOTA_RESTARTING ); |
|
912 WriteUpdateBitmapL( updatetxt->Des(), KUpdateBitmap ); |
|
913 WriteUpdateBitmapL( restarttxt->Des(), KRestartingBitmap ); |
|
914 CleanupStack::PopAndDestroy( restarttxt ); |
|
915 CleanupStack::PopAndDestroy( updatetxt ); |
|
916 TRAPD(error,FindScheduleL( ETrue)); //deleting the schedule (fix for failed update) |
|
917 if(error) |
|
918 { |
|
919 FLOG(_L("CFotaUpdate::UpdateL error in deleting previous schedule") ); |
|
920 |
|
921 } |
|
922 // Simulate update agent by writing result file. |
|
923 CRepository* centrep( NULL); |
|
924 TInt err = KErrNone; |
|
925 TRAP(err, centrep = CRepository::NewL( KCRUidFotaServer ) ); |
|
926 TInt simulate(KErrNotFound); |
|
927 if ( centrep ) |
|
928 { |
|
929 err = centrep->Get( KSimulateUpdateAgent, simulate ); |
|
930 } |
|
931 delete centrep; |
|
932 if ( simulate>0 ) |
|
933 { |
|
934 FLOG(_L("CFotaUpdate::UpdateL 5 - writing update.resp")); |
|
935 RFileWriteStream respstr; |
|
936 CleanupClosePushL ( respstr ); |
|
937 User::LeaveIfError( respstr.Replace( iFotaServer->iFs, KUpdateResultFile |
|
938 , EFileWrite ) ); |
|
939 |
|
940 respstr.WriteUint32L(UPD_OK); |
|
941 respstr.WriteUint32L(15); |
|
942 respstr.WriteL(_L("UPDATE DONE!")); |
|
943 CleanupStack::PopAndDestroy( &respstr ); |
|
944 } |
|
945 |
|
946 CRepository* centrep2 = NULL; |
|
947 TRAP( err, centrep2 = CRepository::NewL( KCRUidFotaServer ) ) |
|
948 if (err==KErrNone ) |
|
949 { |
|
950 centrep2->Set( KFotaUpdateState, EFotaPendingGenAlert ); |
|
951 } |
|
952 delete centrep2; |
|
953 |
|
954 // Boot to update mode |
|
955 LaunchNotifierL( ESyncMLFwUpdRebootNote, KErrNone); |
|
956 |
|
957 FLOG(_L(" waiting 2 sec to keep 'restarting' visible")); |
|
958 User::After(TTimeIntervalMicroSeconds32(2000000)); |
|
959 |
|
960 RStarterSession starter; |
|
961 FLOG(_L(" starter->Connect")); |
|
962 User::LeaveIfError(starter.Connect()); |
|
963 starter.Reset(RStarterSession::EFirmwareUpdate); |
|
964 starter.Close(); |
|
965 FLOG(_L("CFotaUpdate::UpdateL() <<")); |
|
966 } |
|
967 |
|
968 |
|
969 // --------------------------------------------------------------------------- |
|
970 // CFotaUpdate::CheckBatteryL() |
|
971 // Cheks if there's enough battery power to update |
|
972 // --------------------------------------------------------------------------- |
|
973 // |
|
974 TBool CFotaUpdate::CheckBatteryL(TBool aUSBChargingsupported) |
|
975 { |
|
976 TInt chargingstatus( EChargingStatusError ); |
|
977 TInt batterylevel( 1 ); |
|
978 TBool enoughPower( EFalse ); |
|
979 // Read battery |
|
980 FLOG(_L(" 0.9 checking batt level")); |
|
981 RProperty pw; |
|
982 User::LeaveIfError(pw.Attach(KPSUidHWRMPowerState,KHWRMBatteryLevel)); |
|
983 User::LeaveIfError(pw.Get( batterylevel )); |
|
984 pw.Close(); |
|
985 if(aUSBChargingsupported) |
|
986 { |
|
987 if ( batterylevel >= EBatteryLevelLevel2 ) |
|
988 enoughPower = ETrue; |
|
989 |
|
990 //return enoughPower; |
|
991 } |
|
992 else |
|
993 { |
|
994 User::LeaveIfError(pw.Attach(KPSUidHWRMPowerState,KHWRMChargingStatus)); |
|
995 User::LeaveIfError(pw.Get( chargingstatus )); |
|
996 pw.Close(); |
|
997 |
|
998 // Too low battery, power insufficient |
|
999 if ( batterylevel >= EBatteryLevelLevel2 ) |
|
1000 { |
|
1001 enoughPower = ETrue; |
|
1002 } |
|
1003 // But charger is connected, power sufficient |
|
1004 if ( chargingstatus != EChargingStatusError |
|
1005 && chargingstatus != EChargingStatusNotConnected ) |
|
1006 { |
|
1007 enoughPower = ETrue; |
|
1008 } |
|
1009 } |
|
1010 |
|
1011 if (!enoughPower) |
|
1012 iChargeToMonitor = EBatteryLevelLevel2; |
|
1013 FLOG(_L(" 1.0 batt level: %d (0..7), chargingstatus %d") |
|
1014 ,batterylevel,chargingstatus); |
|
1015 FLOG(_L("CFotaUpdate::checkBattery %d"), enoughPower?1:0 ); |
|
1016 return enoughPower; |
|
1017 } |
|
1018 |
|
1019 |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // CFotaUpdate::StartUpdateL |
|
1022 // Starts fw updating (shows a notifier to user). |
|
1023 // --------------------------------------------------------------------------- |
|
1024 // |
|
1025 void CFotaUpdate::StartUpdateL( const TDownloadIPCParams &aParams ) |
|
1026 { |
|
1027 FLOG(_L("CFotaUpdate::StartUpdateL(TDownloadIPCParams aParams) >> \ |
|
1028 pkig:%d"), aParams.iPkgId ); |
|
1029 TSmlProfileId profile(KErrNotFound); |
|
1030 |
|
1031 // Get update state from db |
|
1032 iFotaServer->iDatabase->OpenDBL( ); |
|
1033 iUpdateState = iFotaServer->iDatabase->GetStateL( aParams.iPkgId ); |
|
1034 iFotaServer->iDatabase->CloseAndCommitDB( ); |
|
1035 |
|
1036 FLOG(_L(" 0 ")); |
|
1037 if ( iUpdateState.iPkgId == KErrNotFound ) |
|
1038 { |
|
1039 FLOG(_L(" STATE NOT FOUND pkgid %d"), aParams.iPkgId); |
|
1040 User::Leave(KErrNotFound); |
|
1041 } |
|
1042 |
|
1043 // Resolve profile id |
|
1044 RSyncMLSession sml; |
|
1045 TInt tmp1; |
|
1046 TSmlServerAlertedAction tmp2; |
|
1047 TBool tmp3; |
|
1048 TInt tmp4; |
|
1049 CleanupClosePushL( sml ); |
|
1050 sml.OpenL(); |
|
1051 // Use stored profile |
|
1052 if ( aParams.iProfileId == KErrNotFound ) |
|
1053 { |
|
1054 iFotaServer->GetProfileDataL( &sml,iUpdateState.iProfileId |
|
1055 ,tmp1,tmp2,tmp3,tmp4); |
|
1056 profile = iUpdateState.iProfileId; |
|
1057 } |
|
1058 // Use passed profile. If error, then try to use stored profile |
|
1059 else |
|
1060 { |
|
1061 TRAPD(err, iFotaServer->GetProfileDataL( &sml,aParams.iProfileId |
|
1062 ,tmp1,tmp2, tmp3, tmp4 ) ); |
|
1063 if ( err != KErrNone ) |
|
1064 { |
|
1065 iFotaServer->GetProfileDataL( &sml,iUpdateState.iProfileId |
|
1066 ,tmp1,tmp2,tmp3,tmp4); |
|
1067 profile = iUpdateState.iProfileId; |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 profile = aParams.iProfileId; |
|
1072 } |
|
1073 } |
|
1074 CleanupStack::PopAndDestroy( &sml ); |
|
1075 |
|
1076 // Must update package state with fresh params (it could be empty) |
|
1077 TUint fields = EFDBState | EFDBPkgName|EFDBVersion; |
|
1078 if ( profile != iUpdateState.iProfileId ) |
|
1079 { |
|
1080 fields |= EFDBProfileId; |
|
1081 } |
|
1082 |
|
1083 iUpdateState.iProfileId = profile; |
|
1084 iUpdateState.iPkgName = aParams.iPkgName; |
|
1085 iUpdateState.iPkgVersion = aParams.iPkgVersion; |
|
1086 iUpdateState.iState = RFotaEngineSession::EStartingUpdate; |
|
1087 iUpdateState.iResult = KErrNotFound; |
|
1088 iUpdateState.iSendAlert = EFalse; // HJHA-6MJCFE . This operation will |
|
1089 // not reach any final state. |
|
1090 iFotaServer->iDatabase->OpenDBL( ); |
|
1091 iFotaServer->iDatabase->SetStateL( iUpdateState, KNullDesC8, fields ); |
|
1092 iFotaServer->iDatabase->CloseAndCommitDB( ); |
|
1093 |
|
1094 CRepository* centrep2 = NULL; |
|
1095 TRAPD( err, centrep2 = CRepository::NewL( KCRUidFotaServer ) ) |
|
1096 if (err==KErrNone ) |
|
1097 { TInt val; |
|
1098 // |
|
1099 centrep2->Get( KFotaUpdateState, val ); |
|
1100 |
|
1101 if(val == EFotaUpdateInterrupted) |
|
1102 centrep2->Set( KFotaUpdateState, EFotaDefault ); |
|
1103 } |
|
1104 delete centrep2; |
|
1105 |
|
1106 FLOG(_L("CFotaUpdate::StartUpdateL 2")); |
|
1107 //new code |
|
1108 TInt client = iFotaServer->GetInstallUpdateClientL(); |
|
1109 if( CheckUpdateVariations() && |
|
1110 client!= CFotaSrvSession::EOMADMAppUi && |
|
1111 client != CFotaSrvSession::EFMSServer ) |
|
1112 { |
|
1113 TInt callactive(EFalse); |
|
1114 RFMSClient fmsclient; |
|
1115 TRAPD(err,fmsclient.OpenL()); |
|
1116 if(err == KErrNone) |
|
1117 { |
|
1118 CleanupClosePushL(fmsclient); |
|
1119 FLOG(_L("CFotaUpdate::startupdate FMS for active call >>")); |
|
1120 TInt err1 = fmsclient.IsPhoneCallActive(callactive); |
|
1121 FLOG(_L("IsPhoneCallActive returns %d >>"),err1); |
|
1122 } |
|
1123 if(callactive) |
|
1124 { |
|
1125 FLOG(_L(" active phone call found")); |
|
1126 |
|
1127 FLOG(_L("putting call end Ao start pkgid=%d, profileid=%d"),iUpdateState.iPkgId,iUpdateState.iProfileId); |
|
1128 TInt err1 = fmsclient.MonitorActivePhoneCallEnd(iUpdateState.iPkgId,iUpdateState.iProfileId); |
|
1129 FLOG(_L("MonitorActivePhoneCallEnd returns %d >>"),err1); |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 FLOG(_L("CFotaUpdate::StartUpdateL 2")); |
|
1134 |
|
1135 TDriveNumber drive; |
|
1136 |
|
1137 TBool ret (EFalse); |
|
1138 TRAPD(err2, ret = iFotaServer->NeedToDecryptL(iUpdateState.iPkgId, drive)); |
|
1139 if ( err2 == KErrNone ) |
|
1140 { |
|
1141 if (!ret) |
|
1142 { |
|
1143 //Drive is not encrypted |
|
1144 LaunchNotifierL( ESyncMLFwUpdStartQuery, iUpdateState.iProfileId ); |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 //Drive is encrypted. |
|
1149 LaunchNotifierL( ESyncMLFwUpdStartQueryEnc, iUpdateState.iProfileId ); |
|
1150 } |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 HandleUpdateErrorL(err2); |
|
1155 } |
|
1156 |
|
1157 } |
|
1158 if(err == KErrNone) //fms opening error |
|
1159 { |
|
1160 CleanupStack::PopAndDestroy(&fmsclient); |
|
1161 } |
|
1162 } |
|
1163 else |
|
1164 { |
|
1165 FLOG(_L("CFotaUpdate::StartUpdateL 2 DM UI Install update")); |
|
1166 //LaunchNotifierL( ESyncMLFwUpdStartQuery, iUpdateState.iProfileId ); |
|
1167 |
|
1168 TDriveNumber drive; |
|
1169 |
|
1170 TBool ret (EFalse); |
|
1171 TRAP(err, ret = iFotaServer->NeedToDecryptL(iUpdateState.iPkgId, drive)); |
|
1172 if ( err == KErrNone ) |
|
1173 { |
|
1174 if (!ret) |
|
1175 { |
|
1176 //Drive is not encrypted |
|
1177 LaunchNotifierL( ESyncMLFwUpdStartQuery, iUpdateState.iProfileId ); |
|
1178 } |
|
1179 else |
|
1180 { |
|
1181 //Drive is encrypted. |
|
1182 LaunchNotifierL( ESyncMLFwUpdStartQueryEnc, iUpdateState.iProfileId ); |
|
1183 } |
|
1184 } |
|
1185 else |
|
1186 { |
|
1187 HandleUpdateErrorL(err); |
|
1188 } |
|
1189 |
|
1190 } |
|
1191 |
|
1192 //new code |
|
1193 |
|
1194 |
|
1195 FLOG(_L("CFotaUpdate::StartUpdateL(TDownloadIPCParams aParams) << \ |
|
1196 pkig:%d"),aParams.iPkgId); |
|
1197 } |
|
1198 |
|
1199 |
|
1200 |
|
1201 // --------------------------------------------------------------------------- |
|
1202 // CFotaUpdate::CreateRadionButtonArrayLC |
|
1203 // Creates the array of radio buttons to display |
|
1204 // on radio button setting page |
|
1205 // --------------------------------------------------------------------------- |
|
1206 // |
|
1207 |
|
1208 CDesCArray* CFotaUpdate::CreateRadionButtonArrayLC( const TScheduleEntryInfo2 aScEntry, |
|
1209 TInt& aSelectionIndex) |
|
1210 { |
|
1211 // selection defaults to 0 |
|
1212 FLOG(_L("CFotaUpdate::CreateRadionButtonArrayLC >>")); |
|
1213 aSelectionIndex = 0; |
|
1214 CDesCArray* array = new (ELeave) CDesC16ArrayFlat(4); |
|
1215 CleanupStack::PushL(array); |
|
1216 for (TInt i=0;i<iInterval.Count();i++) |
|
1217 |
|
1218 { |
|
1219 switch (iIntervalType[i]) |
|
1220 { |
|
1221 case EHourly : |
|
1222 { |
|
1223 |
|
1224 HBufC* string1 ; |
|
1225 if(iInterval[i] == 1) |
|
1226 string1 = StringLoader::LoadLC(R_FOTA_RADIO_DIALOG_1HOUR_REMAINDER); |
|
1227 else |
|
1228 string1 = StringLoader::LoadLC(R_QTN_FOTA_REMINDER_HOURS , iInterval[i] ); |
|
1229 |
|
1230 array->AppendL( string1->Des() ); |
|
1231 CleanupStack::PopAndDestroy( string1 ); |
|
1232 if(aScEntry.Interval() == iInterval[i] && aScEntry.IntervalType()== EHourly ) |
|
1233 aSelectionIndex = i; |
|
1234 } |
|
1235 break; |
|
1236 |
|
1237 case EDaily: |
|
1238 { |
|
1239 |
|
1240 HBufC* string1; //= StringLoader::LoadLC(R_QTN_FOTA_REMINDER_DAYS , iInterval[i] ); |
|
1241 if(iInterval[i] == 1) |
|
1242 string1 = StringLoader::LoadLC(R_FOTA_RADIO_DIALOG_1DAY_REMAINDER); |
|
1243 else |
|
1244 string1 = StringLoader::LoadLC(R_QTN_FOTA_REMINDER_DAYS , iInterval[i] ); |
|
1245 |
|
1246 array->AppendL( string1->Des() ); |
|
1247 CleanupStack::PopAndDestroy( string1 ); |
|
1248 if(aScEntry.Interval() == iInterval[i] && aScEntry.IntervalType()== EDaily ) |
|
1249 aSelectionIndex = i; |
|
1250 } |
|
1251 break; |
|
1252 case EMonthly: |
|
1253 { |
|
1254 |
|
1255 HBufC* string1 ;//== StringLoader::LoadLC(R_QTN_FOTA_REMINDER_MINUTES , iInterval[i] ); |
|
1256 if(iInterval[i] == 1) |
|
1257 string1 = StringLoader::LoadLC(R_QTN_FOTA_REMINDER_1_MINUTE); |
|
1258 else |
|
1259 string1 = StringLoader::LoadLC(R_QTN_FOTA_REMINDER_MINUTES , iInterval[i] ); |
|
1260 |
|
1261 array->AppendL( string1->Des() ); |
|
1262 CleanupStack::PopAndDestroy( string1 ); |
|
1263 if(aScEntry.Interval() == iInterval[i] && aScEntry.IntervalType()== EMonthly) |
|
1264 aSelectionIndex = i; |
|
1265 } |
|
1266 break; |
|
1267 |
|
1268 /*case EYearly: |
|
1269 { |
|
1270 tempChar.Num(iInterval[i]); |
|
1271 HBufC* string1 = StringLoader::LoadLC(R_FOTA_RADIO_DIALOG_YEAR_REMAINDER , iInterval[i] ); |
|
1272 array->AppendL( string1->Des() ); |
|
1273 CleanupStack::PopAndDestroy( string1 ); |
|
1274 if(aScEntry.Interval() == iInterval[i] ) |
|
1275 aSelectionIndex = i; |
|
1276 } |
|
1277 break;*/ |
|
1278 } |
|
1279 } |
|
1280 |
|
1281 if(iIntervalType[iIntervalType.Count()-1] == ENoReminderOn ) |
|
1282 { |
|
1283 HBufC* string1 = StringLoader::LoadLC( R_FOTA_RADIO_DIALOG_NO_REMAINDER); |
|
1284 array->AppendL( string1->Des() ); |
|
1285 CleanupStack::PopAndDestroy( string1 ); |
|
1286 } |
|
1287 FLOG(_L("CFotaUpdate::CreateRadionButtonArrayLC <<")); |
|
1288 return array; |
|
1289 } |
|
1290 // --------------------------------------------------------------------------- |
|
1291 // CFotaUpdate::ParseScheduleString() |
|
1292 // Parse the schedule string from cenrep |
|
1293 // --------------------------------------------------------------------------- |
|
1294 // |
|
1295 // |
|
1296 void CFotaUpdate::ParseScheduleStringL() |
|
1297 { |
|
1298 FLOG(_L("CFotaUpdate::ParseScheduleString() >>")); |
|
1299 |
|
1300 GetSchedulesInfoL(); |
|
1301 |
|
1302 |
|
1303 |
|
1304 iInterval.Reset(); |
|
1305 iIntervalType.Reset(); |
|
1306 TBuf<5> aTime; |
|
1307 TBuf<9> aSched,tempChar; |
|
1308 aTime.Zero(); |
|
1309 aSched.Zero(); |
|
1310 |
|
1311 |
|
1312 //TText*sep = (TText *)ksep.Ptr(); |
|
1313 TBufC<1>ksep(Ksep); |
|
1314 TText *t = (TText *)ksep.Ptr(); //just for Initialization |
|
1315 for(TInt i = 0; i<iscInfo.Length();i++) |
|
1316 { |
|
1317 |
|
1318 TChar ch = iscInfo[i]; |
|
1319 if ( ch.IsDigit()) //separates digits from the string |
|
1320 { aTime.Append(ch); |
|
1321 |
|
1322 } |
|
1323 else |
|
1324 { |
|
1325 aSched.Append(ch); |
|
1326 *t = ch; |
|
1327 if (*t == 'h' || *t =='H') //hour |
|
1328 { iIntervalType.Append(EHourly) ; |
|
1329 TInt val =1 ; |
|
1330 TLex lex(aTime); |
|
1331 TInt err = lex.Val(val); |
|
1332 if (err) |
|
1333 { |
|
1334 iInterval.Append(1); |
|
1335 } |
|
1336 else |
|
1337 { |
|
1338 iInterval.Append(val); |
|
1339 } |
|
1340 |
|
1341 } |
|
1342 else if (*t == 'd'|| *t =='D') //daily |
|
1343 {iIntervalType.Append(EDaily); |
|
1344 TInt val =1 ; |
|
1345 TLex lex(aTime); |
|
1346 TInt err = lex.Val(val); |
|
1347 if (err) |
|
1348 { |
|
1349 iInterval.Append(1); |
|
1350 } |
|
1351 else |
|
1352 { |
|
1353 iInterval.Append(val); |
|
1354 } |
|
1355 |
|
1356 } |
|
1357 else if (*t == 'm'|| *t =='M') //minute |
|
1358 {iIntervalType.Append( EMonthly); |
|
1359 TInt val =1 ; |
|
1360 TLex lex(aTime); |
|
1361 TInt err = lex.Val(val); |
|
1362 if (err) |
|
1363 { |
|
1364 |
|
1365 iInterval.Append(1); |
|
1366 } |
|
1367 else |
|
1368 { |
|
1369 iInterval.Append(val); |
|
1370 } |
|
1371 |
|
1372 } |
|
1373 /* else if (*t == 'y') //year |
|
1374 {iIntervalType.Append( EYearly); |
|
1375 TInt val =1 ; |
|
1376 TLex lex(aTime); |
|
1377 TInt err = lex.Val(val); |
|
1378 if (err) |
|
1379 { |
|
1380 |
|
1381 iInterval.Append(1); |
|
1382 } |
|
1383 else |
|
1384 { |
|
1385 iInterval.Append(val); |
|
1386 } |
|
1387 |
|
1388 }*/ |
|
1389 else if (*t == ':') //colon |
|
1390 { |
|
1391 aTime.Zero(); |
|
1392 aSched.Zero(); |
|
1393 } |
|
1394 } |
|
1395 } |
|
1396 TBool checkSchInfo =EFalse; |
|
1397 |
|
1398 if(iInterval.Count() == iIntervalType.Count() ) |
|
1399 { |
|
1400 for (TInt j =0 ;j< iInterval.Count();j++ ) |
|
1401 { //setting to default 1h:4h:1d:3d |
|
1402 if(iInterval[j] < 0 || iIntervalType[j] > 3 ) |
|
1403 { |
|
1404 iInterval.Reset(); iIntervalType.Reset(); |
|
1405 iInterval.Append(1); iIntervalType.Append(EHourly); |
|
1406 iInterval.Append(4); iIntervalType.Append(EHourly); |
|
1407 iInterval.Append(1); iIntervalType.Append(EDaily); |
|
1408 iInterval.Append(3); iIntervalType.Append(EDaily); |
|
1409 checkSchInfo =ETrue; |
|
1410 break; |
|
1411 } |
|
1412 } |
|
1413 } |
|
1414 else |
|
1415 { |
|
1416 iInterval.Reset(); iIntervalType.Reset(); |
|
1417 iInterval.Append(1); iIntervalType.Append(EHourly); |
|
1418 iInterval.Append(4); iIntervalType.Append(EHourly); //setting to default 1h:4h:1d:3d |
|
1419 iInterval.Append(1); iIntervalType.Append(EDaily); |
|
1420 iInterval.Append(3); iIntervalType.Append(EDaily); |
|
1421 checkSchInfo =ETrue; |
|
1422 } |
|
1423 |
|
1424 TPtrC16 lastFive = iscInfo.Right(5); |
|
1425 _LIT( KNoRem , "NROFF"); |
|
1426 TPtrC noRem( KNoRem ); //check for No Remainder |
|
1427 if (lastFive != noRem || checkSchInfo) |
|
1428 { |
|
1429 iIntervalType.Append(ENoReminderOn); |
|
1430 } |
|
1431 else |
|
1432 { |
|
1433 iIntervalType.Append(ENoReminderOff); |
|
1434 |
|
1435 } |
|
1436 FLOG(_L("CFotaUpdate::ParseScheduleString() <<")); |
|
1437 |
|
1438 } |
|
1439 |
|
1440 |
|
1441 // --------------------------------------------------------------------------- |
|
1442 // CFotaUpdate::GetSchedulesInfoL |
|
1443 // Get the schedule info from the cenrep |
|
1444 // --------------------------------------------------------------------------- |
|
1445 // |
|
1446 // |
|
1447 void CFotaUpdate::GetSchedulesInfoL() |
|
1448 { |
|
1449 |
|
1450 CRepository* centrep = NULL; |
|
1451 //TBuf<255> scInfo; |
|
1452 centrep = CRepository::NewLC( TUid::Uid(KFotaServerUid)); |
|
1453 if ( centrep ) |
|
1454 {TBuf<255> temp; |
|
1455 if (centrep->Get( KFotaOptionsForReminderDuration , temp )==KErrNone && temp.Length() ) |
|
1456 { FLOG(_L("CFotaUpdate::ParseScheduleString taking from cenrep <<")); |
|
1457 temp.Trim(); //read from cenrep |
|
1458 iscInfo.Copy(temp); |
|
1459 } |
|
1460 else |
|
1461 { //else set to default |
|
1462 iscInfo.Copy(KDefaultSched); |
|
1463 |
|
1464 } |
|
1465 CleanupStack::PopAndDestroy(centrep); |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 iscInfo.Copy(KDefaultSched); //else set to default |
|
1470 } |
|
1471 |
|
1472 } |
|
1473 |
|
1474 // --------------------------------------------------------------------------- |
|
1475 // CFotaUpdate::ShowReminderDialogL |
|
1476 // Prepare and display Reminder Dialog using RFotaReminderDlg |
|
1477 // on radio button setting page |
|
1478 // --------------------------------------------------------------------------- |
|
1479 // |
|
1480 void CFotaUpdate::ShowReminderDialogL() |
|
1481 { |
|
1482 // Push default content to navigation pane and change title |
|
1483 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
1484 CAknNavigationControlContainer* naviPane = NULL; |
|
1485 HBufC* originalTitle; |
|
1486 CAknTitlePane* titlePane = NULL; |
|
1487 originalTitle = HBufC::NewLC( 50 ); //KNsmlMaxTitleSize |
|
1488 |
|
1489 if ( statusPane && statusPane->PaneCapabilities( |
|
1490 TUid::Uid(EEikStatusPaneUidTitle) ).IsPresent() ) |
|
1491 { |
|
1492 naviPane = ( CAknNavigationControlContainer* ) |
|
1493 statusPane->ControlL( TUid::Uid(EEikStatusPaneUidNavi) ); |
|
1494 naviPane->PushDefaultL(); |
|
1495 titlePane = static_cast<CAknTitlePane*> |
|
1496 ( statusPane->ControlL( TUid::Uid( |
|
1497 EEikStatusPaneUidTitle) ) ); |
|
1498 if ( titlePane->Text() ) |
|
1499 { |
|
1500 originalTitle->Des().Copy( *titlePane->Text() ); |
|
1501 HBufC* titleText = StringLoader::LoadLC( |
|
1502 R_QTN_DM_TITLE_SETTINGS_DIALOG ); |
|
1503 titlePane->SetTextL( *titleText ); |
|
1504 CleanupStack::PopAndDestroy( titleText ); |
|
1505 titleText = NULL; |
|
1506 } |
|
1507 } |
|
1508 |
|
1509 TApaTaskList taskList(iFotaServer->GetEikEnv()->WsSession()); |
|
1510 TApaTask task=taskList.FindApp(TUid::Uid(KFotaServerUid)); |
|
1511 |
|
1512 if(task.Exists()) |
|
1513 task.BringToForeground(); |
|
1514 |
|
1515 // Construct radio btn list and launch radio button dlg |
|
1516 TScheduleEntryInfo2 en=FindScheduleL( EFalse ); |
|
1517 TInt radioSelectionIndex( KErrNotFound ); |
|
1518 TRAPD(error,ParseScheduleStringL()); |
|
1519 if (error) |
|
1520 { |
|
1521 iInterval.Reset(); iIntervalType.Reset(); |
|
1522 iInterval.Append(1); iIntervalType.Append(EHourly); |
|
1523 iInterval.Append(4); iIntervalType.Append(EHourly); |
|
1524 iInterval.Append(1); iIntervalType.Append(EDaily); |
|
1525 iInterval.Append(3); iIntervalType.Append(EDaily); |
|
1526 iIntervalType.Append(ENoReminderOn); |
|
1527 } |
|
1528 if(iInterval.Count() > 4) |
|
1529 { |
|
1530 for(TInt i= 4;i <iInterval.Count();i++) |
|
1531 iInterval.Remove(i); |
|
1532 } |
|
1533 CDesCArray* itemArray = CreateRadionButtonArrayLC( en,radioSelectionIndex ); |
|
1534 |
|
1535 TInt aEvent(KErrNone); |
|
1536 CFotaReminderDlg* aFotaReminderDlg = CFotaReminderDlg::NewL(radioSelectionIndex,itemArray,aEvent ); |
|
1537 FLOG(_L("after creating fota reminder dialog")); |
|
1538 CleanupStack::PushL(aFotaReminderDlg); |
|
1539 TInt presentPriotiry = CEikonEnv::Static()->RootWin().OrdinalPriority(); |
|
1540 TInt presentPosition = CEikonEnv::Static()->RootWin().OrdinalPosition(); |
|
1541 CEikonEnv::Static()->RootWin().SetOrdinalPosition(presentPosition, ECoeWinPriorityMedium); //setting the priority to medium for activation on top of global notes |
|
1542 |
|
1543 TInt ret = aFotaReminderDlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1544 CleanupStack::Pop(aFotaReminderDlg); |
|
1545 CleanupStack::PopAndDestroy( itemArray ); |
|
1546 |
|
1547 CEikonEnv::Static()->RootWin().SetOrdinalPosition(presentPosition, presentPriotiry); //resetting to previous priority |
|
1548 FLOG(_L("****Event key = %d"),aEvent); |
|
1549 |
|
1550 if (aEvent == EEventKey) |
|
1551 { |
|
1552 FLOG(_L("Exiting....")); |
|
1553 TApaTaskList taskList(iFotaServer->GetEikEnv()->WsSession()); |
|
1554 TApaTask task=taskList.FindApp(TUid::Uid(KOmaDMAppUid)); |
|
1555 if(task.Exists()) |
|
1556 { |
|
1557 task.EndTask(); |
|
1558 task.KillTask(); |
|
1559 } |
|
1560 |
|
1561 return; |
|
1562 } |
|
1563 if(naviPane) |
|
1564 naviPane->Pop(); |
|
1565 if( titlePane ) |
|
1566 { |
|
1567 if ( titlePane->Text() && originalTitle ) |
|
1568 { |
|
1569 TRAP_IGNORE( titlePane->SetTextL( *originalTitle ) ); |
|
1570 } |
|
1571 } |
|
1572 CleanupStack::PopAndDestroy( originalTitle ); |
|
1573 task.SendToBackground(); |
|
1574 |
|
1575 CreateNewScheduleL(ret,radioSelectionIndex); |
|
1576 |
|
1577 |
|
1578 } |
|
1579 |
|
1580 // --------------------------------------------------------------------------- |
|
1581 // CFotaUpdate::CreateNewScheduleL |
|
1582 // Creates the new schedule |
|
1583 // --------------------------------------------------------------------------- |
|
1584 // |
|
1585 void CFotaUpdate::CreateNewScheduleL(TInt aRet, TInt aRadioSelectionIndex) |
|
1586 { |
|
1587 |
|
1588 TScheduleEntryInfo2 en=FindScheduleL( EFalse ); |
|
1589 TIntervalType tIntervalType; |
|
1590 TInt tInterval; |
|
1591 if ( aRet && aRadioSelectionIndex== 0 ) |
|
1592 { |
|
1593 FLOG(_L("Creating reminder: for 1st option")); |
|
1594 tIntervalType = (TIntervalType)iIntervalType[aRadioSelectionIndex]; |
|
1595 tInterval = iInterval[aRadioSelectionIndex]; |
|
1596 en=FindScheduleL( ETrue ); |
|
1597 CreateScheduleL ( iUpdateState.iPkgId, tIntervalType ,tInterval ); |
|
1598 iFotaServer->FinalizeUpdateL(); |
|
1599 } |
|
1600 else if(aRet && aRadioSelectionIndex == 1 ) |
|
1601 { |
|
1602 FLOG(_L("Creating reminder: 4 hours")); |
|
1603 tIntervalType = (TIntervalType)iIntervalType[aRadioSelectionIndex]; |
|
1604 tInterval = iInterval[aRadioSelectionIndex]; |
|
1605 en=FindScheduleL( ETrue ); |
|
1606 CreateScheduleL ( iUpdateState.iPkgId, tIntervalType ,tInterval ); |
|
1607 iFotaServer->FinalizeUpdateL(); |
|
1608 } |
|
1609 else if(aRet && aRadioSelectionIndex == 2 ) |
|
1610 { |
|
1611 FLOG(_L("Creating reminder: for 2nd option")); |
|
1612 tIntervalType = (TIntervalType)iIntervalType[aRadioSelectionIndex]; |
|
1613 tInterval = iInterval[aRadioSelectionIndex]; |
|
1614 en=FindScheduleL( ETrue ); |
|
1615 CreateScheduleL ( iUpdateState.iPkgId, tIntervalType ,tInterval ); |
|
1616 iFotaServer->FinalizeUpdateL(); |
|
1617 } |
|
1618 else if(aRet && aRadioSelectionIndex == 3 ) |
|
1619 { |
|
1620 FLOG(_L("Creating reminder: for 3rd option")); |
|
1621 tIntervalType = (TIntervalType)iIntervalType[aRadioSelectionIndex]; |
|
1622 tInterval = iInterval[aRadioSelectionIndex]; |
|
1623 en=FindScheduleL( ETrue ); |
|
1624 CreateScheduleL ( iUpdateState.iPkgId, tIntervalType ,tInterval ); |
|
1625 iFotaServer->FinalizeUpdateL(); |
|
1626 } |
|
1627 else if (!aRet || aRadioSelectionIndex == 4) |
|
1628 { |
|
1629 FLOG(_L("Deleting reminder, btn press %d"),aRet); |
|
1630 TScheduleEntryInfo2 en=FindScheduleL( ETrue ); |
|
1631 |
|
1632 if ( !aRet ) // cancel pressed |
|
1633 { |
|
1634 LaunchNotifierL( ESyncMLFwUpdStartQuery, iUpdateState.iProfileId ); |
|
1635 } |
|
1636 else // ok pressed |
|
1637 { |
|
1638 LaunchNotifierL( ESyncMLFwUpdNoReminder , KErrNone ); |
|
1639 //iFotaServer->FinalizeUpdateL(); |
|
1640 } |
|
1641 } |
|
1642 |
|
1643 } |
|
1644 |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // CFotaUpdate::FindScheduleL |
|
1647 // Finds fotaupdate schedule (named [102072c4]) |
|
1648 // --------------------------------------------------------------------------- |
|
1649 // |
|
1650 TScheduleEntryInfo2 CFotaUpdate::FindScheduleL( const TBool aDelete ) |
|
1651 { |
|
1652 TScheduleEntryInfo2 ret; |
|
1653 TInt err; |
|
1654 RScheduler sc; |
|
1655 |
|
1656 TTsTime time; |
|
1657 TSchedulerItemRef scitem; |
|
1658 CArrayFixFlat<TSchedulerItemRef>* aSchRefArray = new CArrayFixFlat <TSchedulerItemRef>(5); |
|
1659 TScheduleFilter aFilter(EAllSchedules); |
|
1660 User::LeaveIfError( sc.Connect() ); // xx |
|
1661 CleanupClosePushL( sc ); |
|
1662 CleanupStack::PushL(aSchRefArray); |
|
1663 |
|
1664 User::LeaveIfError( sc.GetScheduleRefsL( *aSchRefArray,aFilter) ); // xx |
|
1665 FLOG(_L("Schedule items: ")); |
|
1666 for ( TInt i=0; i<aSchRefArray->Count(); ++i ) |
|
1667 { |
|
1668 TSchedulerItemRef it = (*aSchRefArray)[i]; |
|
1669 if ( it.iName == TUid::Uid(KFotaServerUid).Name() ) |
|
1670 { |
|
1671 TScheduleState2 sc_state; |
|
1672 CArrayFixFlat<TScheduleEntryInfo2>* sc_entries = new CArrayFixFlat <TScheduleEntryInfo2>(5); |
|
1673 CArrayFixFlat<TTaskInfo>* sc_tasks = new CArrayFixFlat <TTaskInfo>(5); |
|
1674 TTsTime sc_duetime; |
|
1675 CleanupStack::PushL( sc_entries ); |
|
1676 CleanupStack::PushL( sc_tasks ); |
|
1677 FLOG (_L("%d. schedule handle: %d name:'%S'"),i,it.iHandle, &(it.iName) ); |
|
1678 |
|
1679 err = sc.GetScheduleL ( it.iHandle , sc_state, *sc_entries,*sc_tasks,sc_duetime ); // xx |
|
1680 |
|
1681 TDateTime dtm = sc_duetime.GetLocalTime().DateTime(); |
|
1682 FLOG(_L(" schedule duetime:%d:%d"), dtm.Hour(), dtm.Minute()); |
|
1683 |
|
1684 if ( err ) FLOG(_L(" schedule sc get err %d"),err); |
|
1685 else |
|
1686 { |
|
1687 for ( TInt k=0; k<sc_entries->Count();++k) |
|
1688 { |
|
1689 TScheduleEntryInfo2 sc_entry = (*sc_entries)[k]; |
|
1690 ret = sc_entry; |
|
1691 TTime sctime = sc_entry.StartTime().GetLocalTime(); |
|
1692 FLOG(_L(" schedule entry %d int-type:%d int:%d start: %d:%d"),k,sc_entry.IntervalType(),sc_entry.Interval(),sctime.DateTime().Hour(),sctime.DateTime().Minute()); |
|
1693 } |
|
1694 |
|
1695 for ( TInt j=0; j<sc_tasks->Count();++j) |
|
1696 { |
|
1697 TTaskInfo sc_task = (*sc_tasks)[j]; |
|
1698 FLOG(_L(" schedule task %d '%S'"),sc_task.iTaskId,&(sc_task.iName) ); |
|
1699 if ( aDelete && sc_task.iName==TUid::Uid(KFotaServerUid).Name() ) |
|
1700 { |
|
1701 FLOG(_L(" schedule DeleteTask %d"),sc_task.iTaskId); |
|
1702 User::LeaveIfError( sc.DeleteTask(sc_task.iTaskId) ); // xx |
|
1703 } |
|
1704 } |
|
1705 } |
|
1706 if ( aDelete ) |
|
1707 { |
|
1708 FLOG(_L(" DeleteSchedule %d"),it.iHandle); |
|
1709 User::LeaveIfError(sc.DeleteSchedule(it.iHandle )); // xx |
|
1710 } |
|
1711 CleanupStack::PopAndDestroy( sc_tasks ); |
|
1712 CleanupStack::PopAndDestroy( sc_entries ); |
|
1713 } |
|
1714 } |
|
1715 CleanupStack::PopAndDestroy( aSchRefArray ); |
|
1716 CleanupStack::PopAndDestroy(&sc); |
|
1717 return ret; |
|
1718 } |
|
1719 |
|
1720 |
|
1721 |
|
1722 // --------------------------------------------------------------------------- |
|
1723 // CFotaUpdate::CreateScheduleL |
|
1724 // Creates fotaupdate schedule (named [102072c4]) |
|
1725 // --------------------------------------------------------------------------- |
|
1726 // |
|
1727 TInt CFotaUpdate::CreateScheduleL ( const TInt aPackageId |
|
1728 ,const TIntervalType aIntervalType |
|
1729 ,const TInt aInterval) |
|
1730 { |
|
1731 FLOG(_L("CFotaUpdate::CreateScheduleL ()") ); |
|
1732 const TInt KRepeatForever = 0; |
|
1733 const TInt KTaskPriority = 1; |
|
1734 _LIT(KFotaScheduleExe, "Z:\\sys\\bin\\fotaschedulehandler.exe"); |
|
1735 RScheduler sc; |
|
1736 TTime t; |
|
1737 TTsTime time; |
|
1738 TSchedulerItemRef scitem; |
|
1739 CArrayFixFlat<TScheduleEntryInfo2>* scentries = new CArrayFixFlat <TScheduleEntryInfo2>(5); |
|
1740 User::LeaveIfError( sc.Connect() ); // xx |
|
1741 CleanupClosePushL( sc ); |
|
1742 CleanupStack::PushL(scentries ); |
|
1743 t.HomeTime(); |
|
1744 switch (aIntervalType) //create schedule based on the interval type |
|
1745 { |
|
1746 case EHourly : |
|
1747 t = t + ((TTimeIntervalHours)aInterval); |
|
1748 break; |
|
1749 case EDaily : |
|
1750 t = t + ((TTimeIntervalDays) aInterval); |
|
1751 break; |
|
1752 case EMonthly : |
|
1753 t = t + ((TTimeIntervalMinutes ) aInterval); |
|
1754 break; |
|
1755 case EYearly : |
|
1756 t = t + ((TTimeIntervalYears ) aInterval); |
|
1757 break; |
|
1758 default : |
|
1759 User::Panic(KFotaPanic, KErrArgument); |
|
1760 |
|
1761 } |
|
1762 |
|
1763 time.SetLocalTime( t ); |
|
1764 TScheduleEntryInfo2 scentry1(time, aIntervalType, aInterval, (TTimeIntervalMinutes)1440 ) ; // xx |
|
1765 scentries->AppendL( scentry1 ); |
|
1766 |
|
1767 scitem.iName = TUid::Uid(KFotaServerUid).Name(); |
|
1768 User::LeaveIfError( sc.Register(TFileName( KFotaScheduleExe ), 0 ) ); // xxx |
|
1769 User::LeaveIfError( sc.CreatePersistentSchedule(scitem, *scentries) ); // xxx |
|
1770 FLOG(_L("created schedule %d %d:%d"),scitem.iHandle, t.DateTime().Hour(),t.DateTime().Minute() ); |
|
1771 TTaskInfo taskInfo; |
|
1772 taskInfo.iName = TUid::Uid(KFotaServerUid).Name(); |
|
1773 taskInfo.iRepeat = KRepeatForever; |
|
1774 taskInfo.iPriority = KTaskPriority; |
|
1775 |
|
1776 TFotaScheduledUpdate fotareminder( aPackageId, scitem.iHandle ); |
|
1777 TPckg<TFotaScheduledUpdate> fotareminderpkg(fotareminder); |
|
1778 |
|
1779 HBufC* data = HBufC::NewLC(fotareminderpkg.Length()); |
|
1780 data->Des().Copy(fotareminderpkg); |
|
1781 |
|
1782 User::LeaveIfError( sc.ScheduleTask(taskInfo, *data, scitem.iHandle) ); // xxx |
|
1783 |
|
1784 CleanupStack::PopAndDestroy( data ); |
|
1785 CleanupStack::PopAndDestroy( scentries ); |
|
1786 CleanupStack::PopAndDestroy(&sc); // xx |
|
1787 return scitem.iHandle; |
|
1788 } |
|
1789 // -------------------------------------------------------------------------- |
|
1790 // CFotaUpdate::CheckUpdateVariations |
|
1791 // Checks the Install update note display,when a phone call is active |
|
1792 // -------------------------------------------------------------------------- |
|
1793 // |
|
1794 TBool CFotaUpdate::CheckUpdateVariations() |
|
1795 { |
|
1796 FLOG(_L("CFotaUpdate::CheckUpdateVariations >>")); |
|
1797 CRepository* centrep( NULL); |
|
1798 TRAPD(err, centrep = CRepository::NewL( KCRUidFotaServer ) ); |
|
1799 if (err) FLOG(_L("Error reading FotaServer cenrep... %d"),err); |
|
1800 TInt supported(KErrNone); |
|
1801 if (centrep ) |
|
1802 { |
|
1803 err = centrep->Get( KFotaUpdateNoteDisplayAlways, supported ); |
|
1804 if (err) FLOG(_L("Error reading cenrep key... %d"),err); |
|
1805 delete centrep; |
|
1806 centrep = NULL; |
|
1807 } |
|
1808 if(supported) //means note to be displayed when a call is active |
|
1809 { |
|
1810 return EFalse; |
|
1811 } |
|
1812 FLOG(_L("CFotaUpdate::CheckUpdateVariations <<")); |
|
1813 return ETrue; //means note should not be displayed when a call is there |
|
1814 } |
|
1815 |
|