51
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Fota server update and download functionality
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
// INCLUDE FILES
|
|
18 |
#include <apgtask.h>
|
|
19 |
#include <apgwgnam.h>
|
|
20 |
#include <schtime.h>
|
|
21 |
#include <csch_cli.h>
|
|
22 |
#include <e32property.h>
|
54
|
23 |
#include <cmmanager.h>
|
|
24 |
#include <cmconnectionmethod.h>
|
51
|
25 |
#include <DevManInternalCRKeys.h>
|
|
26 |
#include <nsmlconstants.h>
|
|
27 |
#include <centralrepository.h>
|
|
28 |
#include <sysversioninfo.h>
|
|
29 |
#include <hbstackedlayout.h>
|
|
30 |
#include <hbmainwindow.h>
|
|
31 |
#include <hbview.h>
|
|
32 |
#include <featmgr.h>
|
|
33 |
#include <DevEncProtectedPSKey.h>
|
|
34 |
#include <hbapplication.h>
|
|
35 |
#include <xqconversions.h>
|
|
36 |
#include <hbtransparentwindow.h>
|
|
37 |
#include <es_sock.h>
|
|
38 |
#include <es_enum_internal.h>
|
|
39 |
#include <es_sock_partner.h>
|
|
40 |
#include <e32property.h>
|
|
41 |
#include <xqserviceutil.h>
|
|
42 |
|
|
43 |
#include "FotaServer.h"
|
|
44 |
#include "FotaSrvDebug.h"
|
|
45 |
#include "FotasrvSession.h"
|
|
46 |
#include "fotaConst.h"
|
|
47 |
#include "nsmldmtreedbclient.h"
|
|
48 |
#include "fotaserverPrivatePSKeys.h"
|
|
49 |
#include "FotaNetworkRegStatus.h"
|
|
50 |
#include "FotaDlMgrClient.h"
|
|
51 |
#include "fotadevicedialogobserver.h"
|
|
52 |
#include "fotanotifiers.h"
|
|
53 |
#include "fotaserverPrivatePSKeys.h"
|
|
54 |
|
|
55 |
#define __LEAVE_IF_ERROR(x) if(KErrNone!=x) {FLOG(_L("LEAVE in %s: %d"), __FILE__, __LINE__); User::Leave(x); }
|
|
56 |
|
|
57 |
TInt CFotaServer::iSessionCount = 0;
|
|
58 |
|
|
59 |
|
|
60 |
// ============================= LOCAL FUNCTIONS =============================
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// GetPredefinedNodeL
|
|
64 |
// function to get preconfigured node for FUMO
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
void GetPredefinedNodeL(TDes8& aNode)
|
|
67 |
{
|
|
68 |
FLOG(_L("GetPredefinedNodeL() Begin"));
|
|
69 |
CRepository* centrep(NULL);
|
|
70 |
aNode.Zero();
|
|
71 |
centrep = CRepository::NewLC(TUid::Uid(0x101F9A0A));
|
|
72 |
|
|
73 |
if (centrep)
|
|
74 |
{
|
|
75 |
FLOG(_L("centralrepository found End"));
|
|
76 |
TFullName temp;
|
|
77 |
|
|
78 |
if (centrep->Get(KDevManFUMOPredefinedNodes, temp) == KErrNone
|
|
79 |
&& temp.Length())
|
|
80 |
{
|
|
81 |
temp.Trim();
|
|
82 |
aNode.Copy(temp);
|
|
83 |
}
|
|
84 |
CleanupStack::PopAndDestroy(centrep);
|
|
85 |
}
|
|
86 |
FLOG(_L("GetPredefinedNodeL() End"));
|
|
87 |
}
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// DeleteFUMOTreeL
|
|
90 |
// function to get preconfigured node for FUMO
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
void DeleteFUMOTreeL()
|
|
93 |
{
|
|
94 |
FLOG(_L("DeleteFUMOTreeL() Begin"));
|
|
95 |
const TUint32 KNSmlFotaAdapterUid = 0x101F9A09;
|
|
96 |
_LIT8( KNSmlFumoPath, "FUMO" );
|
|
97 |
_LIT8( KNSmlFumoSeparator, "/" );
|
|
98 |
const TInt KGranularity = 10;
|
|
99 |
TBuf8<KMaxFullName> temp;
|
|
100 |
GetPredefinedNodeL(temp);
|
|
101 |
RNSmlDMCallbackSession session;
|
|
102 |
__LEAVE_IF_ERROR(session.Connect());
|
|
103 |
CleanupClosePushL(session);
|
|
104 |
|
|
105 |
CBufBase *emptyList = CBufFlat::NewL(0);
|
|
106 |
CleanupStack::PushL(emptyList);
|
|
107 |
CArrayFixFlat<TSmlDmMappingInfo>* UriSegList;
|
|
108 |
UriSegList = new (ELeave) CArrayFixFlat<TSmlDmMappingInfo> (KGranularity);
|
|
109 |
|
|
110 |
CleanupStack::PushL(UriSegList);
|
|
111 |
|
|
112 |
session.GetUriSegListL(KNSmlFotaAdapterUid, KNSmlFumoPath, *UriSegList);
|
|
113 |
|
|
114 |
for (TUint16 i = 0; i < UriSegList->Count(); i++)
|
|
115 |
{
|
|
116 |
if (temp.Length() && UriSegList->At(i).iURISeg.Find(temp)
|
|
117 |
!= KErrNotFound)
|
|
118 |
{
|
|
119 |
FLOG(_L("DeleteFUMOTreeL predefined match =%S"), &temp);
|
|
120 |
continue;
|
|
121 |
}
|
|
122 |
|
|
123 |
TBuf8<KMaxFullName> tempFumo;
|
|
124 |
tempFumo.Append(KNSmlFumoPath);
|
|
125 |
tempFumo.Append(KNSmlFumoSeparator);
|
|
126 |
tempFumo.Append(UriSegList->At(i).iURISeg);
|
|
127 |
FLOG(_L("DeleteFUMOTreeL() call update mapping info for node %S"), &tempFumo);
|
|
128 |
session.UpdateMappingInfoL(KNSmlFotaAdapterUid, tempFumo, *emptyList);
|
|
129 |
|
|
130 |
}
|
|
131 |
// session.UpdateMappingInfoL(KNSmlFotaAdapterUid,KNSmlFumoPath,*emptyList);
|
|
132 |
CleanupStack::PopAndDestroy(UriSegList);
|
|
133 |
CleanupStack::PopAndDestroy(emptyList);
|
|
134 |
CleanupStack::PopAndDestroy(&session); //session
|
|
135 |
FLOG(_L("DeleteFUMOTreeL() End"));
|
|
136 |
}
|
|
137 |
|
|
138 |
// ----------------------------------------------------------------------------------------
|
|
139 |
// CFotaServer::NewInstance
|
|
140 |
// ----------------------------------------------------------------------------------------
|
|
141 |
CFotaServer* CFotaServer::NewInstance(HbMainWindow& mainwindow)
|
|
142 |
{
|
|
143 |
FLOG(_L("CFotaServer::NewInstance >>"));
|
|
144 |
|
|
145 |
CFotaServer* self = new CFotaServer(mainwindow);
|
|
146 |
|
|
147 |
if (self)
|
|
148 |
{
|
|
149 |
TRAPD( err, self->ConstructL());
|
|
150 |
|
|
151 |
if (err != KErrNone)
|
|
152 |
{
|
|
153 |
delete self; self = NULL;
|
|
154 |
}
|
|
155 |
}
|
|
156 |
FLOG(_L("CFotaServer::NewInstance >>"));
|
|
157 |
return self;
|
|
158 |
}
|
|
159 |
|
|
160 |
// ----------------------------------------------------------------------------------------
|
|
161 |
// CFotaSrvSession::NewSessionL()
|
|
162 |
// ----------------------------------------------------------------------------------------
|
|
163 |
CSession2* CFotaServer::NewSessionL(const TVersion&, const RMessage2&) const
|
|
164 |
{
|
|
165 |
iSessionCount++;
|
|
166 |
FLOG(_L("Number of active sessions = %d"), iSessionCount);
|
|
167 |
return new (ELeave) CFotaSrvSession();
|
|
168 |
}
|
|
169 |
|
|
170 |
void CFotaServer::ReportFwUpdateStatusL(TPackageState& aState)
|
|
171 |
{
|
|
172 |
FLOG(_L("CFotaServer::ReportFwUpdateStatusL >>"));
|
|
173 |
|
|
174 |
TFotaClient requester = GetUpdateRequester();
|
|
175 |
|
|
176 |
if (requester == EDMHostServer)
|
|
177 |
{
|
|
178 |
FLOG(_L("Reporting status back to hostserver..."));
|
|
179 |
ServerCanShut(EFalse);
|
|
180 |
CreateDeviceManagementSessionL(aState);
|
|
181 |
}
|
|
182 |
else
|
|
183 |
{
|
|
184 |
//iServerCanShut = EFalse; Don't do here. Should be set in downloadmgrcli based on error type.
|
|
185 |
//ResetFotaStateL(aState.iPkgId);
|
|
186 |
SetStartupReason(EFotaDefault);
|
|
187 |
StopServerWhenPossible();
|
|
188 |
FLOG(_L("Not reporting status as requester is unknown!"));
|
|
189 |
}
|
|
190 |
|
|
191 |
FLOG(_L("CFotaServer::ReportFwUpdateStatusL >>"));
|
|
192 |
}
|
|
193 |
|
|
194 |
void CFotaServer::StartDownloadDialog(const QString &aName,
|
|
195 |
const QString &aVersion, const TInt &aSize)
|
|
196 |
{
|
|
197 |
FLOG(_L("CFotaServer::StartDownloadDialog >>"));
|
|
198 |
//The dialog should not timeout here.
|
|
199 |
if (!iFullScreenDialog)
|
|
200 |
{
|
|
201 |
//ConstructApplicationUI(ETrue);
|
|
202 |
iFullScreenDialog = new FotaFullscreenDialog(this);
|
|
203 |
}
|
|
204 |
|
|
205 |
iFullScreenDialog->SetSoftwareDetails(aSize, aVersion, aName);
|
|
206 |
|
|
207 |
iFullScreenDialog->SetWarningDetails(EHbFotaDownload);
|
|
208 |
|
|
209 |
TBool postpone = IsUserPostponeAllowed();
|
|
210 |
if (!postpone)
|
|
211 |
{
|
|
212 |
FLOG(_L("Disabling option to resume later!"));
|
|
213 |
iFullScreenDialog->DisableRSK(ETrue);
|
|
214 |
}
|
|
215 |
|
|
216 |
FLOG(_L("CFotaServer::StartDownloadDialog <<"));
|
|
217 |
}
|
|
218 |
|
|
219 |
void CFotaServer::UpdateDownloadDialog(TInt aProgress)
|
|
220 |
{
|
|
221 |
FLOG(_L("CFotaServer::UpdateDownloadDialog >>"));
|
|
222 |
if (!iFullScreenDialog)
|
|
223 |
{
|
|
224 |
QString name = XQConversions::s60Desc8ToQString(
|
|
225 |
iPackageState.iPkgName);
|
|
226 |
QString version = XQConversions::s60Desc8ToQString(
|
|
227 |
iPackageState.iPkgVersion);
|
|
228 |
StartDownloadDialog(name, version, iPackageState.iPkgSize);
|
|
229 |
ConstructApplicationUI(ETrue);
|
|
230 |
}
|
|
231 |
|
|
232 |
iFullScreenDialog->UpdateProgressBar(aProgress);
|
|
233 |
FLOG(_L("CFotaServer::UpdateDownloadDialog <<"));
|
|
234 |
}
|
|
235 |
|
|
236 |
void CFotaServer::ShowDialogL(TFwUpdNoteTypes adialogid)
|
|
237 |
{
|
|
238 |
FLOG(_L("CFotaServer::ShowDialogL adialogid = %d<<"), adialogid);
|
|
239 |
|
|
240 |
if (iNotifier)
|
|
241 |
{
|
|
242 |
FLOG(_L("Deleting the open device dialog!!"));
|
|
243 |
iNotifier->Cancel();
|
|
244 |
}
|
|
245 |
|
|
246 |
ServerCanShut(EFalse);
|
|
247 |
iDialogId = (TInt) adialogid;
|
|
248 |
|
|
249 |
iNotifParams = CHbSymbianVariantMap::NewL();
|
|
250 |
|
|
251 |
HBufC* keyDialog = HBufC::NewL(10);
|
|
252 |
CleanupStack::PushL(keyDialog);
|
|
253 |
*keyDialog = KKeyDialog;
|
|
254 |
|
|
255 |
HBufC* keyParam1 = HBufC::NewL(10);
|
|
256 |
CleanupStack::PushL(keyParam1);
|
|
257 |
*keyParam1 = KKeyParam1;
|
|
258 |
|
|
259 |
HBufC* keyParam2 = HBufC::NewL(10);
|
|
260 |
CleanupStack::PushL(keyParam2);
|
|
261 |
*keyParam2 = KKeyParam2;
|
|
262 |
|
|
263 |
HBufC* keyParam3 = HBufC::NewL(10);
|
|
264 |
CleanupStack::PushL(keyParam3);
|
|
265 |
*keyParam3 = KKeyParam3;
|
|
266 |
|
|
267 |
HBufC* keyParam4 = HBufC::NewL(10);
|
|
268 |
CleanupStack::PushL(keyParam4);
|
|
269 |
*keyParam4 = KKeyParam4;
|
|
270 |
|
|
271 |
CHbSymbianVariant* dialogId = CHbSymbianVariant::NewL(&adialogid,
|
|
272 |
CHbSymbianVariant::EInt);
|
|
273 |
CleanupStack::PushL(dialogId);
|
|
274 |
iNotifParams->Add(*keyDialog, dialogId);
|
|
275 |
|
|
276 |
if (!iNotifier)
|
|
277 |
iNotifier = CFotaDownloadNotifHandler::NewL(this);
|
|
278 |
|
|
279 |
switch (adialogid)
|
|
280 |
{
|
|
281 |
case EFwUpdNotEnoughBattery:
|
|
282 |
case EFwUpdDeviceBusy:
|
|
283 |
{
|
|
284 |
FLOG(_L("CFotaServer::EFwUpdNotEnoughBattery/EFwUpdDeviceBusy"));
|
|
285 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
286 |
}
|
|
287 |
break;
|
|
288 |
case EFwUpdResumeUpdate:
|
|
289 |
case EFwUpdResumeDownload:
|
|
290 |
{
|
|
291 |
FLOG(_L("CFotaServer::EFwUpdResumeUpdate / EFwUpdResumeDownload"));
|
|
292 |
CHbSymbianVariant* param1Val = CHbSymbianVariant::NewL(
|
|
293 |
&iPackageState.iPkgSize, CHbSymbianVariant::EInt);
|
|
294 |
CleanupStack::PushL(param1Val);
|
|
295 |
iNotifParams->Add(*keyParam1, param1Val);
|
|
296 |
TBuf16<KFotaMaxPkgNameLength> temp1;
|
|
297 |
temp1.Copy(iPackageState.iPkgVersion);
|
|
298 |
CHbSymbianVariant* param2Val = CHbSymbianVariant::NewL(
|
|
299 |
//&iPackageState.iPkgVersion, CHbSymbianVariant::EDes);
|
|
300 |
&temp1, CHbSymbianVariant::EDes);
|
|
301 |
CleanupStack::PushL(param2Val);
|
|
302 |
iNotifParams->Add(*keyParam2, param2Val);
|
|
303 |
TBuf16<KFotaMaxPkgNameLength> temp2;
|
|
304 |
temp2.Copy(iPackageState.iPkgName);
|
|
305 |
CHbSymbianVariant* param3Val = CHbSymbianVariant::NewL(
|
|
306 |
&temp2, CHbSymbianVariant::EDes);
|
|
307 |
CleanupStack::PushL(param3Val);
|
|
308 |
iNotifParams->Add(*keyParam3, param3Val);
|
|
309 |
TBool postpone = IsUserPostponeAllowed();
|
|
310 |
CHbSymbianVariant* param4Val = CHbSymbianVariant::NewL(&postpone,
|
|
311 |
CHbSymbianVariant::EInt);
|
|
312 |
CleanupStack::PushL(param4Val);
|
|
313 |
iNotifParams->Add(*keyParam4, param4Val);
|
|
314 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
315 |
CleanupStack::PopAndDestroy(4);
|
|
316 |
|
|
317 |
}
|
|
318 |
break;
|
|
319 |
|
|
320 |
default:
|
|
321 |
{
|
|
322 |
FLOG(_L("CFotaServer::default"));
|
|
323 |
//Do nothing
|
|
324 |
}
|
|
325 |
break;
|
|
326 |
}
|
|
327 |
CleanupStack::PopAndDestroy(6);
|
|
328 |
FLOG(_L("CFotaServer::ShowDialogL >>"));
|
|
329 |
|
|
330 |
}
|
|
331 |
|
|
332 |
void CFotaServer::HandleDialogResponse(int response, TInt aDialogId)
|
|
333 |
{
|
|
334 |
FLOG( _L("CFotaServer::HandleDialogResponse, response = %d dialog = %d >>"), response, aDialogId);
|
|
335 |
|
|
336 |
switch (aDialogId)
|
|
337 |
{
|
|
338 |
case EFwUpdNotEnoughBattery:
|
|
339 |
case EFwUpdDeviceBusy:
|
|
340 |
{
|
|
341 |
SetServerActive(EFalse);
|
|
342 |
|
|
343 |
StopServerWhenPossible();
|
|
344 |
}
|
|
345 |
break;
|
|
346 |
case EFwUpdResumeDownload:
|
|
347 |
{
|
|
348 |
if (response == EHbLSK) //Continue
|
|
349 |
{
|
|
350 |
FLOG(_L("User accepted to resume the download"));
|
|
351 |
|
|
352 |
TRAP_IGNORE(CancelFmsL());
|
|
353 |
TRAP_IGNORE(DownloaderL()->TryResumeDownloadL());
|
|
354 |
}
|
|
355 |
else //Resume Later
|
|
356 |
{
|
|
357 |
FLOG(_L("User denied resuming the download"));
|
|
358 |
DecrementUserPostponeCount();
|
|
359 |
SetServerActive(EFalse);
|
|
360 |
SetStartupReason(EFotaDownloadInterrupted);
|
|
361 |
|
|
362 |
TRAP_IGNORE(InvokeFmsL());
|
|
363 |
|
|
364 |
StopServerWhenPossible();
|
|
365 |
}
|
|
366 |
}
|
|
367 |
break;
|
|
368 |
case EFwUpdResumeUpdate:
|
|
369 |
{
|
|
370 |
if (response == EHbLSK) //Continue
|
|
371 |
{
|
|
372 |
FLOG(_L("User accepted to resume the update"));
|
|
373 |
iPackageState.iResult = KErrNotFound;
|
|
374 |
TRAPD(err,
|
|
375 |
iDatabase->OpenDBL();
|
|
376 |
iDatabase->SetStateL( iPackageState ,KNullDesC8,EFDBResult );
|
|
377 |
);
|
|
378 |
FLOG(_L("Updating the fota database... err = %d"), err);
|
|
379 |
iDatabase->CloseAndCommitDB();
|
|
380 |
|
|
381 |
TRAP(err, iUpdater->StartUpdateL( iPackageState ));
|
|
382 |
FLOG(_L("Starting update, err = %d"), err);
|
|
383 |
}
|
|
384 |
else //Update Later
|
|
385 |
{
|
|
386 |
FLOG(_L("User denied resuming the update"));
|
|
387 |
iPackageState.iState = RFotaEngineSession::EStartingUpdate;
|
|
388 |
iPackageState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
389 |
TRAPD(err,
|
|
390 |
iDatabase->OpenDBL();
|
|
391 |
iDatabase->SetStateL( iPackageState ,KNullDesC8,EFDBState|EFDBResult );
|
|
392 |
iDatabase->CloseAndCommitDB();
|
|
393 |
);
|
|
394 |
FLOG(_L("Updating the fota database... err = %d"), err);
|
|
395 |
|
|
396 |
DecrementUserPostponeCount();
|
|
397 |
SetServerActive(EFalse);
|
|
398 |
SetStartupReason(EFotaUpdateInterrupted);
|
|
399 |
|
|
400 |
TRAP(err, InvokeFmsL());
|
|
401 |
FLOG(_L("Invoking fms, err = %d"), err);
|
|
402 |
|
|
403 |
StopServerWhenPossible();
|
|
404 |
}
|
|
405 |
}
|
|
406 |
break;
|
|
407 |
default:
|
|
408 |
{
|
|
409 |
//Do nothing
|
|
410 |
}
|
|
411 |
break;
|
|
412 |
}
|
|
413 |
/*
|
|
414 |
if(iNotifParams)
|
|
415 |
{
|
|
416 |
delete iNotifParams; iNotifParams = NULL;
|
|
417 |
}
|
|
418 |
|
|
419 |
if(iNotifier)
|
|
420 |
{
|
|
421 |
delete iNotifier; iNotifier = NULL;
|
|
422 |
}*/
|
|
423 |
iDialogId = 0;
|
|
424 |
FLOG(_L("CFotaServer::HandleDialogResponse<<"));
|
|
425 |
}
|
|
426 |
|
|
427 |
void CFotaServer::SetServerActive(TBool aValue)
|
|
428 |
{
|
|
429 |
FLOG(_L("CFotaServer::SetServerActive, aValue = %d"), aValue);
|
|
430 |
|
|
431 |
TInt err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KFotaServerActive,
|
|
432 |
aValue);
|
|
433 |
FLOG(_L("RProperty SetServerActive Set %d, err = %d"), aValue, err);
|
|
434 |
|
|
435 |
if (err == KErrNotFound)
|
|
436 |
{
|
|
437 |
err = RProperty::Define(TUid::Uid(KOmaDMAppUid), KFotaServerActive,
|
|
438 |
RProperty::EInt, KReadPolicy, KWritePolicy);
|
|
439 |
err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KFotaServerActive,
|
|
440 |
aValue);
|
|
441 |
FLOG(_L("RProperty SetServerActive Set %d, err = %d"), aValue,
|
|
442 |
err);
|
|
443 |
}
|
|
444 |
|
|
445 |
FLOG(_L("CFotaServer::SetServerActive <<"));
|
|
446 |
}
|
|
447 |
|
|
448 |
void CFotaServer::ShowFullScreenDialog(TInt aType)
|
|
449 |
{
|
|
450 |
FLOG(_L("CFotaServer::ShowFullScreenDialog, type = %d >>"), aType);
|
|
451 |
|
|
452 |
if (!iFullScreenDialog)
|
|
453 |
{
|
|
454 |
const QString ver = QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgVersion.Ptr()), iPackageState.iPkgVersion.Length());
|
|
455 |
const QString name = QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgName.Ptr()), iPackageState.iPkgName.Length());
|
|
456 |
iFullScreenDialog = new FotaFullscreenDialog(this);
|
|
457 |
|
|
458 |
iFullScreenDialog->SetSoftwareDetails(iPackageState.iPkgSize, ver, name);
|
|
459 |
iFullScreenDialog->SetWarningDetails(EHbFotaDownload);
|
|
460 |
ConstructApplicationUI(ETrue);
|
|
461 |
}
|
|
462 |
|
|
463 |
if (aType == EHbFotaUpdate)
|
|
464 |
{
|
|
465 |
iFullScreenDialog->UpdateProgressBar(100);
|
|
466 |
TBool postpone = IsUserPostponeAllowed();
|
|
467 |
if (!postpone)
|
|
468 |
{
|
|
469 |
FLOG(_L("Disabling option to resume later!"));
|
|
470 |
iFullScreenDialog->DisableRSK(ETrue);
|
|
471 |
}
|
|
472 |
|
|
473 |
iFullScreenDialog->ShowUpdateDialog();
|
|
474 |
}
|
|
475 |
else if (aType == EHbFotaLowBattery)
|
|
476 |
{
|
|
477 |
iFullScreenDialog->UpdateProgressBar(100);
|
|
478 |
iFullScreenDialog->DisableRSK(EFalse);
|
|
479 |
iFullScreenDialog->SetWarningDetails(EHbFotaLowBattery);
|
|
480 |
}
|
|
481 |
|
|
482 |
FLOG(_L("CFotaServer::ShowFullScreenDialog <<"));
|
|
483 |
}
|
|
484 |
|
|
485 |
// --------------------------------------------------------------------------
|
|
486 |
// CreateDeviceManagementSessionL
|
|
487 |
// Creates DM session
|
|
488 |
// --------------------------------------------------------------------------
|
|
489 |
void CFotaServer::CreateDeviceManagementSessionL(TPackageState& aState)
|
|
490 |
{
|
|
491 |
FLOG(
|
|
492 |
_L("[cfotasever] CreateDeviceManagementSessionL dms >> profid %d\
|
|
493 |
%d counts left ,sml handle %d, iNetworkAvailable=%d"),
|
|
494 |
aState.iProfileId, aState.iSmlTryCount, iSyncMLSession.Handle(),
|
|
495 |
iNetworkAvailable);
|
|
496 |
|
|
497 |
SetStartupReason(EFotaPendingGenAlert);
|
|
498 |
|
|
499 |
if (!iNetworkAvailable)
|
|
500 |
{
|
|
501 |
iRetryingGASend = ETrue;
|
|
502 |
iPackageState = aState;
|
|
503 |
StartNetworkMonitorL();
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
|
|
508 |
TBool dbAlreadyOpen = iDatabase->IsOpen();
|
|
509 |
TBool triesLeft(EFalse);
|
|
510 |
|
|
511 |
iNetworkAvailable = EFalse; // to check network again when GA is sent next time
|
|
512 |
|
|
513 |
if (iSyncMLSession.Handle())
|
|
514 |
{
|
|
515 |
__LEAVE_IF_ERROR( KErrAlreadyExists );
|
|
516 |
}
|
|
517 |
|
|
518 |
if (!dbAlreadyOpen)
|
|
519 |
iDatabase->OpenDBL();
|
|
520 |
// There is still tries left
|
|
521 |
if (aState.iSmlTryCount > 0)
|
|
522 |
{
|
|
523 |
triesLeft = ETrue;
|
|
524 |
FLOG(_L(" decrementing the retry count"));
|
|
525 |
aState.iSmlTryCount = aState.iSmlTryCount - 1;
|
|
526 |
iDatabase->SetStateL(aState, KNullDesC8, EFDBSmlTryCount);
|
|
527 |
}
|
|
528 |
// out of tries, set state to idle
|
|
529 |
else
|
|
530 |
{
|
|
531 |
triesLeft = EFalse;
|
|
532 |
FLOG(_L(" out of tries, resetting pkg state"));
|
|
533 |
|
|
534 |
SetStartupReason(EFotaDefault);
|
|
535 |
aState.iState = RFotaEngineSession::EIdle;
|
|
536 |
aState.iResult = KErrNotFound;
|
|
537 |
iDatabase->SetStateL(aState, KNullDesC8, EFDBState | EFDBResult);
|
|
538 |
}
|
|
539 |
if (!dbAlreadyOpen)
|
|
540 |
iDatabase->CloseAndCommitDB();
|
|
541 |
|
|
542 |
if (triesLeft)
|
|
543 |
{
|
|
544 |
|
|
545 |
CRepository *cenrep = CRepository::NewL(
|
|
546 |
KCRUidDeviceManagementInternalKeys);
|
|
547 |
TInt x = cenrep->Set(KDevManClientInitiatedFwUpdateId,
|
|
548 |
iPackageState.iProfileId);
|
|
549 |
delete cenrep;
|
|
550 |
FLOG(_L("Status writing the cenrep for GA: %d"), x);
|
|
551 |
|
|
552 |
iSyncMLSession.OpenL();
|
|
553 |
|
|
554 |
if (aState.iIapId <0)
|
|
555 |
aState.iIapId = 0;
|
|
556 |
|
|
557 |
FLOG(_L("IAP set in the Fota profile %d is :%d"),
|
|
558 |
aState.iProfileId, aState.iIapId);
|
|
559 |
|
|
560 |
FLOG(_L("From Db Using IAP: %d to send GA"), aState.iIapId);
|
|
561 |
|
|
562 |
RSyncMLDevManJob dmJob;
|
|
563 |
TBuf<10> genalertap, temp;
|
|
564 |
genalertap.Zero();
|
|
565 |
temp.Zero();
|
|
566 |
genalertap.Append(KNSmlDMJobIapPrefix);
|
|
567 |
temp.Num(aState.iIapId);//Decimal Iap
|
|
568 |
if (temp.Length() <= KNSmlHalfTransportIdLength && aState.iIapId
|
|
569 |
> KErrNotFound && CheckIapExistsL(aState.iIapId))
|
|
570 |
{
|
|
571 |
genalertap.AppendFill('0', KNSmlHalfTransportIdLength
|
|
572 |
- temp.Length());
|
|
573 |
genalertap.Append(temp);
|
|
574 |
TLex gavalue(genalertap);
|
|
575 |
TInt temp2(0);
|
|
576 |
gavalue.Val(temp2);
|
|
577 |
dmJob.CreateL(iSyncMLSession, aState.iProfileId, temp2);
|
|
578 |
iSyncMLAttempts = KSyncmlAttemptCount;
|
|
579 |
}
|
|
580 |
else
|
|
581 |
{
|
|
582 |
iSyncMLAttempts = 0;
|
|
583 |
dmJob.CreateL(iSyncMLSession, aState.iProfileId);
|
|
584 |
}
|
|
585 |
|
|
586 |
// If there's no iapid defined, sml will pop up connection dialog.
|
|
587 |
// In that case, only one connection attempt is allowed.
|
|
588 |
iSyncJobId = dmJob.Identifier();
|
|
589 |
iSyncProfile = aState.iProfileId;
|
|
590 |
dmJob.Close();
|
|
591 |
iSyncMLSession.RequestEventL(*this);
|
|
592 |
}
|
|
593 |
}
|
|
594 |
|
|
595 |
FLOG(_L("[cfotasever] CreateDeviceManagementSessionL dms << profid %d"), aState.iProfileId);
|
|
596 |
}
|
|
597 |
|
|
598 |
// ============================= MEMBER FUNCTIONS ============================
|
|
599 |
|
|
600 |
// --------------------------------------------------------------------------
|
|
601 |
// CFotaServer::CFotaServer()
|
|
602 |
// --------------------------------------------------------------------------
|
|
603 |
//
|
|
604 |
CFotaServer::CFotaServer(HbMainWindow& mainwindow) :
|
|
605 |
CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/,
|
|
606 |
iDatabase(0), iInitialized(EFalse), iDownloader(0), iUpdater(0),
|
|
607 |
iDownloadFinalizer(0), iUpdateFinalizer(0), iTimedExecuteResultFile(0), iTimedSMLSessionClose(0),
|
|
608 |
iAppShutter(0), iMonitor(NULL), iSyncMLAttempts(0), iSyncJobId(-1),iRetryingGASend(EFalse),
|
|
609 |
iNetworkAvailable(EFalse),iFullScreenDialog(NULL), iNotifParams(NULL), iNotifier(NULL),
|
|
610 |
iServerCanShut(EFalse), iAsyncOperation(EFalse),iDialogId (0), iConstructed(EFalse), iMainwindow(mainwindow)
|
|
611 |
{
|
|
612 |
RProcess pr;
|
|
613 |
TFullName fn = pr.FullName();
|
|
614 |
TUint prid = pr.Id();
|
|
615 |
FLOG(_L( "CFotaServer::CFotaServer process(id %d)%S. this 0x%x"), prid,
|
|
616 |
&fn, this);
|
|
617 |
|
|
618 |
}
|
|
619 |
|
|
620 |
// --------------------------------------------------------------------------
|
|
621 |
// CFotaServer::DoExecuteResultFileL
|
|
622 |
// Interprets result of update (file update.resp)
|
|
623 |
// --------------------------------------------------------------------------
|
|
624 |
//
|
|
625 |
void CFotaServer::DoExecuteResultFileL()
|
|
626 |
{
|
|
627 |
FLOG(_L("CFotaServer::DoExecuteResultFileL() >>"));
|
|
628 |
|
|
629 |
if (iTimedExecuteResultFile)
|
|
630 |
{
|
|
631 |
iTimedExecuteResultFile->Cancel();
|
|
632 |
delete iTimedExecuteResultFile;
|
|
633 |
iTimedExecuteResultFile = NULL;
|
|
634 |
}
|
|
635 |
iUpdater = CFotaUpdate::NewL(this);
|
|
636 |
iUpdater->ExecuteUpdateResultFileL();
|
|
637 |
FLOG(_L("CFotaServer::DoExecuteResultFileL() <<"));
|
|
638 |
}
|
|
639 |
|
|
640 |
// --------------------------------------------------------------------------
|
|
641 |
// StaticDoExecuteResultFile
|
|
642 |
// --------------------------------------------------------------------------
|
|
643 |
//
|
|
644 |
static TInt StaticDoExecuteResultFile(TAny *aPtr)
|
|
645 |
{
|
|
646 |
FLOG(_L("[cfotaserver] StaticDoExecuteResultFile() >>"));
|
|
647 |
__ASSERT_ALWAYS( aPtr, User::Panic(KFotaPanic, KErrBadHandle) );
|
|
648 |
CFotaServer* srv = (CFotaServer*) aPtr;
|
|
649 |
TRAPD( err, srv->DoExecuteResultFileL() );
|
|
650 |
if (err)
|
|
651 |
{
|
|
652 |
FLOG(_L("[cfotaserver] StaticDoExecuteResultFile ERROR %d"), err);
|
|
653 |
}
|
|
654 |
|
|
655 |
FLOG(_L("[cfotaserver] StaticDoExecuteResultFile() <<"));
|
|
656 |
return err;
|
|
657 |
}
|
|
658 |
|
|
659 |
// --------------------------------------------------------------------------
|
|
660 |
// CFotaServer::CFotaServer()
|
|
661 |
// Constructor. Can't do all constructing since fotaserver might call itself
|
|
662 |
// recursively (via downloadmgr).
|
|
663 |
// --------------------------------------------------------------------------
|
|
664 |
//
|
|
665 |
void CFotaServer::ConstructL()
|
|
666 |
{
|
|
667 |
FLOG(_L("CFotaServer::ConstructL() >>"));
|
|
668 |
TBool updated(EFalse);
|
|
669 |
TInt err;
|
|
670 |
iLastFwUrl.Zero();
|
|
671 |
StartL(KFotaServerName);
|
|
672 |
|
|
673 |
__LEAVE_IF_ERROR(iFs.Connect());
|
|
674 |
|
|
675 |
err = iFs.CreatePrivatePath(EDriveC);
|
|
676 |
if (err != KErrNone && err != KErrAlreadyExists)
|
|
677 |
{
|
|
678 |
__LEAVE_IF_ERROR(err);
|
|
679 |
}
|
|
680 |
__LEAVE_IF_ERROR(iFs.SetSessionToPrivate(EDriveC));
|
|
681 |
|
|
682 |
if (!iDatabase)
|
|
683 |
{
|
|
684 |
TRAPD( err,iDatabase = CFotaDB::NewL() );
|
|
685 |
if (err)
|
|
686 |
{
|
|
687 |
FLOG(_L("CFotaServer:: DB creationg error %d"), err);
|
|
688 |
__LEAVE_IF_ERROR(err);
|
|
689 |
}
|
|
690 |
}
|
|
691 |
|
|
692 |
updated = CFotaUpdate::CheckUpdateResults(iFs);
|
|
693 |
|
|
694 |
// Update has happened, and result file is in place
|
|
695 |
if (updated)
|
|
696 |
{
|
|
697 |
FLOG(_L("scheduling update result file execution"));
|
|
698 |
ServerCanShut(EFalse);
|
|
699 |
|
|
700 |
if (iTimedExecuteResultFile)
|
|
701 |
{
|
|
702 |
iTimedExecuteResultFile->Cancel();
|
|
703 |
delete iTimedExecuteResultFile;
|
|
704 |
iTimedExecuteResultFile = NULL;
|
|
705 |
}
|
|
706 |
iTimedExecuteResultFile = CPeriodic::NewL(EPriorityNormal);
|
|
707 |
iTimedExecuteResultFile->Start(TTimeIntervalMicroSeconds32(
|
|
708 |
KDownloadFinalizerWaitTime), TTimeIntervalMicroSeconds32(
|
|
709 |
KDownloadFinalizerWaitTime), TCallBack(
|
|
710 |
StaticDoExecuteResultFile, this));
|
|
711 |
}
|
|
712 |
|
|
713 |
FLOG(_L("CFotaServer::ConstructL() <<"));
|
|
714 |
}
|
|
715 |
|
|
716 |
// --------------------------------------------------------------------------
|
|
717 |
// CFotaServer::ClientAwareConstructL
|
|
718 |
// Does rest of constructing, if not done. If parent of this fotaserver
|
|
719 |
// instance is another fotaserver, skip maintenance operations (since parent
|
|
720 |
// takes care of them). DmHOstserver triggers cleanup for states: 20,70,80
|
|
721 |
// ,90,100 , must handle state 60 here
|
|
722 |
// --------------------------------------------------------------------------
|
|
723 |
void CFotaServer::ClientAwareConstructL(const RMessage2 &aMessage)
|
|
724 |
{
|
|
725 |
FLOG(_L("CFotaServer::ClientAwareConstructL >>"));
|
|
726 |
if (iInitialized)
|
|
727 |
return;
|
|
728 |
|
|
729 |
ConstructApplicationUI(EFalse);
|
|
730 |
CreateDiskReservation();
|
|
731 |
|
|
732 |
TFotaClient client = CFotaSrvSession::CheckClientSecureIdL(aMessage);
|
|
733 |
|
|
734 |
RArray<TInt> states;
|
|
735 |
TPackageState state;
|
|
736 |
CleanupClosePushL(states);
|
|
737 |
iDatabase->OpenDBL();
|
|
738 |
iDatabase->GetAllL(states);
|
|
739 |
TBool dlactive(EFalse);
|
|
740 |
|
|
741 |
dlactive = DownloaderL()->IsDownloadActive();
|
|
742 |
|
|
743 |
FLOG(_L("Download active value is:%d "), (TInt) dlactive);
|
|
744 |
// Loop states.
|
|
745 |
for (TInt i = 0; i < states.Count(); ++i)
|
|
746 |
{
|
|
747 |
TPackageState tmp;
|
|
748 |
|
|
749 |
tmp = iDatabase->GetStateL(states[i],iLastFwUrl);
|
|
750 |
FLOG(_L(" 1 got state id:%d state:%d result:%d"), tmp.iPkgId,
|
|
751 |
tmp.iState, tmp.iResult);
|
|
752 |
|
|
753 |
//Download was started earlier and was interrupted.
|
|
754 |
if (tmp.iState == RFotaEngineSession::EStartingUpdate || tmp.iState
|
|
755 |
== RFotaEngineSession::EDownloadProgressing || tmp.iState
|
|
756 |
== RFotaEngineSession::EDownloadProgressing)
|
|
757 |
|
|
758 |
{
|
|
759 |
TBool ispkgvalid = ETrue;
|
|
760 |
//Software version check from the time download started.
|
|
761 |
TRAPD(err1,ispkgvalid= CheckSWVersionL() )
|
|
762 |
if (err1 == KErrNone && !ispkgvalid)
|
|
763 |
{
|
|
764 |
FLOG(_L("Mismatch in software version since the download started! Hence resetting!"));
|
|
765 |
|
|
766 |
DownloaderL()->DeleteUpdatePackageL();
|
|
767 |
|
|
768 |
tmp.iState = RFotaEngineSession::EUpdateFailed;
|
|
769 |
tmp.iResult = RFotaEngineSession::EResPackageMismatch;
|
|
770 |
iDatabase->SetStateL(tmp, KNullDesC8, EFDBState | EFDBResult);
|
|
771 |
|
|
772 |
}
|
|
773 |
|
|
774 |
}
|
|
775 |
// Update has been started (60)
|
|
776 |
// If there is no result file, means that update agent failed
|
|
777 |
// to run. Must get back to 50 to allow user to try again.
|
|
778 |
if (tmp.iState == RFotaEngineSession::EUpdateProgressing
|
|
779 |
&& iTimedExecuteResultFile == NULL)
|
|
780 |
{
|
|
781 |
FLOG(_L(" State EUpdateProgressing found, UA didnt run! id %d "), tmp.iPkgId);
|
|
782 |
|
|
783 |
tmp.iState = RFotaEngineSession::EStartingUpdate;
|
|
784 |
iDatabase->SetStateL(tmp, KNullDesC8, EFDBState);
|
|
785 |
}
|
|
786 |
|
|
787 |
// These states need must trigger generic alert! (70+ )
|
|
788 |
if (tmp.iState >= RFotaEngineSession::EUpdateFailed && client != EDMHostServer)
|
|
789 |
{
|
|
790 |
if (iSyncMLSession.Handle() == NULL)
|
|
791 |
{
|
|
792 |
iDatabase->CloseAndCommitDB();
|
|
793 |
ReportFwUpdateStatusL(tmp);
|
|
794 |
iDatabase->OpenDBL();
|
|
795 |
}
|
|
796 |
}
|
|
797 |
|
|
798 |
if (tmp.iState == RFotaEngineSession::EDownloadComplete
|
|
799 |
&& tmp.iResult == RFotaEngineSession::EResSuccessful && client != EDMHostServer)
|
|
800 |
{
|
|
801 |
ReportFwUpdateStatusL(tmp);
|
|
802 |
}
|
|
803 |
|
|
804 |
if (dlactive == EFalse) //if download is not active, EStartingDownload should be reset to EDownloadFailed
|
|
805 |
{
|
|
806 |
if (tmp.iState == RFotaEngineSession::EStartingDownload)
|
|
807 |
{
|
|
808 |
FLOG(_L("Resetting state %d to 20..."), tmp.iState);
|
|
809 |
tmp.iState = RFotaEngineSession::EDownloadFailed;
|
|
810 |
iDatabase->SetStateL(tmp, KNullDesC8, EFDBState);
|
|
811 |
iDatabase->CloseAndCommitDB();
|
|
812 |
iDatabase->OpenDBL();
|
|
813 |
}
|
|
814 |
else if (tmp.iState == RFotaEngineSession::EStartingDownload)
|
|
815 |
{
|
|
816 |
FLOG(_L("Resetting state %d to 30..."), tmp.iState);
|
|
817 |
tmp.iState = RFotaEngineSession::EDownloadProgressing;
|
|
818 |
iDatabase->SetStateL(tmp, KNullDesC8, EFDBState);
|
|
819 |
iDatabase->CloseAndCommitDB();
|
|
820 |
iDatabase->OpenDBL();
|
|
821 |
}
|
|
822 |
}
|
|
823 |
if (tmp.iState == RFotaEngineSession::EDownloadProgressing)
|
|
824 |
{
|
|
825 |
FLOG(_L("Firmware update state is EDownloadProgressing"));
|
|
826 |
//FMS will start fota server when it is appropriate to resume download.
|
|
827 |
}
|
|
828 |
else if (tmp.iState == RFotaEngineSession::EStartingUpdate)
|
|
829 |
{
|
|
830 |
FLOG(_L("Firmware update state is EStartingUpdate"));
|
|
831 |
//FMS will start fota server when it is appropriate to start install.
|
|
832 |
}
|
|
833 |
if (tmp.iState == RFotaEngineSession::EDownloadFailed && client != EDMHostServer)
|
|
834 |
{
|
|
835 |
FLOG(_L("Resetting state %d to 20..."), tmp.iState);
|
|
836 |
DownloaderL()->DeleteUpdatePackageL();
|
|
837 |
tmp.iResult = RFotaEngineSession::EResDLFailDueToNWIssues;
|
|
838 |
iDatabase->SetStateL(tmp, KNullDesC8, EFDBResult);
|
|
839 |
iDatabase->CloseAndCommitDB();
|
|
840 |
ReportFwUpdateStatusL(tmp);
|
|
841 |
iDatabase->OpenDBL();
|
|
842 |
}
|
|
843 |
|
|
844 |
}
|
|
845 |
iDatabase->CloseAndCommitDB();
|
|
846 |
CleanupStack::PopAndDestroy(&states);
|
|
847 |
|
|
848 |
iInitialized = ETrue;
|
|
849 |
FLOG(_L("CFotaServer::ClientAwareConstructL <<"));
|
|
850 |
}
|
|
851 |
|
|
852 |
// --------------------------------------------------------------------------
|
|
853 |
// StaticDoFinalizeDownload
|
|
854 |
// Intermediate function
|
|
855 |
// --------------------------------------------------------------------------
|
|
856 |
static TInt StaticDoFinalizeDownload(TAny *aPtr)
|
|
857 |
{
|
|
858 |
FLOG(_L("[cfotaserver] StaticDoFinalizeDownload() >>"));
|
|
859 |
CFotaServer* srv = (CFotaServer*) aPtr;
|
|
860 |
TRAPD( err, srv->DoFinalizeDownloadL() );
|
|
861 |
if (err)
|
|
862 |
{
|
|
863 |
FLOG(_L("[cfotaserver] StaticDoFinalizeDownload ERROR %d"), err);
|
|
864 |
}
|
|
865 |
|
|
866 |
FLOG(_L("[cfotaserver] StaticDoFinalizeDownload() <<"));
|
|
867 |
return err;
|
|
868 |
}
|
|
869 |
|
|
870 |
// --------------------------------------------------------------------------
|
|
871 |
// CFotaServer::FinalizeDownload
|
|
872 |
// Initialize finalization of download
|
|
873 |
// --------------------------------------------------------------------------
|
|
874 |
//
|
|
875 |
void CFotaServer::FinalizeDownloadL()
|
|
876 |
{
|
|
877 |
FLOG(_L("CFotaServer::FinalizeDownload() >> state:%d result:%d"),
|
|
878 |
iPackageState.iState, iPackageState.iResult);
|
|
879 |
__ASSERT_ALWAYS( iDownloader, User::Panic(KFotaPanic, KErrBadHandle ));
|
|
880 |
|
|
881 |
if (iDownloadFinalizer)
|
|
882 |
{
|
|
883 |
iDownloadFinalizer->Cancel();
|
|
884 |
delete iDownloadFinalizer;
|
|
885 |
iDownloadFinalizer = NULL;
|
|
886 |
}
|
|
887 |
iDownloadFinalizer = CPeriodic::NewL(EPriorityMuchMore);
|
|
888 |
|
|
889 |
// Not restarting,quick finalize
|
|
890 |
iDownloadFinalizer->Start(TTimeIntervalMicroSeconds32(
|
|
891 |
KDownloadFinalizerWaitTime), TTimeIntervalMicroSeconds32(
|
|
892 |
KDownloadFinalizerWaitTime), TCallBack(StaticDoFinalizeDownload,
|
|
893 |
this));
|
|
894 |
FLOG(_L("CFotaServer::FinalizeDownload() <<"));
|
|
895 |
}
|
|
896 |
|
|
897 |
// --------------------------------------------------------------------------
|
|
898 |
// CFotaServer::DoFinalizeDownloadL
|
|
899 |
// Finalize download. Free resources
|
|
900 |
// --------------------------------------------------------------------------
|
|
901 |
//
|
|
902 |
void CFotaServer::DoFinalizeDownloadL()
|
|
903 |
{
|
|
904 |
|
|
905 |
FLOG(_L("CFotaServer::DoFinalizeDownloadL() >> state:%d result:%d"),
|
|
906 |
iPackageState.iState, iPackageState.iResult);
|
|
907 |
__ASSERT_ALWAYS( iDownloader, User::Panic(KFotaPanic, KErrBadHandle ));
|
|
908 |
|
|
909 |
|
|
910 |
if (iDownloadFinalizer)
|
|
911 |
{
|
|
912 |
iDownloadFinalizer->Cancel();
|
|
913 |
delete iDownloadFinalizer;
|
|
914 |
iDownloadFinalizer = NULL;
|
|
915 |
}
|
|
916 |
|
|
917 |
// Set downloader's ending state to DB
|
|
918 |
iDatabase->OpenDBL();
|
|
919 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBState | EFDBResult);
|
|
920 |
iDatabase->CloseAndCommitDB();
|
|
921 |
|
|
922 |
if (iPackageState.iResult != RFotaEngineSession::EResDLFailDueToDeviceOOM)
|
|
923 |
{
|
|
924 |
FLOG(_L("Adjusting the reserved memory..."));
|
|
925 |
DownloaderL()->CreateDiskReservation();
|
|
926 |
}
|
|
927 |
|
|
928 |
// Initiate update
|
|
929 |
if (iPackageState.iState == RFotaEngineSession::EDownloadComplete
|
|
930 |
&& iPackageState.iUpdateLtr)
|
|
931 |
{
|
|
932 |
TRAP_IGNORE(TryUpdateL(EOMADMAppUi));
|
|
933 |
|
|
934 |
}
|
|
935 |
else if (iPackageState.iState == RFotaEngineSession::EDownloadProgressing)
|
|
936 |
{
|
|
937 |
FLOG(_L("Download has paused due to an error. Invoking FMS..."));
|
|
938 |
if (iFullScreenDialog)
|
|
939 |
{
|
|
940 |
iFullScreenDialog->Close();
|
|
941 |
iFullScreenDialog->deleteLater();
|
|
942 |
iFullScreenDialog = NULL;
|
|
943 |
}
|
|
944 |
SetStartupReason(EFotaDownloadInterrupted);
|
|
945 |
InvokeFmsL();
|
|
946 |
StopServerWhenPossible();
|
|
947 |
SetServerActive(EFalse);
|
|
948 |
iAsyncOperation = EFalse;
|
|
949 |
}
|
|
950 |
else
|
|
951 |
{
|
|
952 |
if (iFullScreenDialog)
|
|
953 |
{
|
|
954 |
iFullScreenDialog->Close();
|
|
955 |
iFullScreenDialog->deleteLater();
|
|
956 |
iFullScreenDialog = NULL;
|
|
957 |
}
|
|
958 |
ConstructApplicationUI(EFalse);
|
|
959 |
ReportFwUpdateStatusL(iPackageState);
|
|
960 |
SetServerActive(EFalse);
|
|
961 |
iAsyncOperation = EFalse;
|
|
962 |
}
|
|
963 |
|
|
964 |
FLOG(_L("CFotaServer::DoFinalizeDownloadL() <<"));
|
|
965 |
}
|
|
966 |
|
|
967 |
// --------------------------------------------------------------------------
|
|
968 |
// StaticDoCloseSMLSession
|
|
969 |
// Intermediate function
|
|
970 |
// --------------------------------------------------------------------------
|
|
971 |
static TInt StaticDoCloseSMLSession(TAny *aPtr)
|
|
972 |
{
|
|
973 |
FLOG(_L("[cfotaserver] StaticDoCloseSMLSession() >>"));
|
|
974 |
CFotaServer* srv = (CFotaServer*) aPtr;
|
|
975 |
TRAPD( err, srv->DoCloseSMLSessionL() );
|
|
976 |
if (err)
|
|
977 |
{
|
|
978 |
FLOG(_L("[cfotaserver] StaticDoCloseSMLSession ERROR %d"), err);
|
|
979 |
}
|
|
980 |
|
|
981 |
FLOG(_L("[cfotaserver] StaticDoCloseSMLSession() <<"));
|
|
982 |
return err;
|
|
983 |
}
|
|
984 |
|
|
985 |
// --------------------------------------------------------------------------
|
|
986 |
// CFotaServer::DoCloseSMLSessionL
|
|
987 |
// Close syncml session, or resync
|
|
988 |
// --------------------------------------------------------------------------
|
|
989 |
//
|
|
990 |
void CFotaServer::DoCloseSMLSessionL()
|
|
991 |
{
|
|
992 |
FLOG(_L("CFotaServer::DoCloseSMLSessionL() >>"));
|
|
993 |
|
|
994 |
// Must still try to sync
|
|
995 |
if (iSyncMLAttempts > 0)
|
|
996 |
{
|
|
997 |
FLOG(_L(" trycount %d => creating new job"), iSyncMLAttempts);
|
|
998 |
RSyncMLDevManJob dmJob;
|
|
999 |
if (iPackageState.iIapId > KErrNotFound)
|
|
1000 |
{
|
|
1001 |
FLOG(_L("DoCloseSMLSessionL new job uses iap from fotadb %d"),
|
|
1002 |
iPackageState.iIapId);
|
|
1003 |
dmJob.CreateL(iSyncMLSession, iSyncProfile, iPackageState.iIapId);
|
|
1004 |
}
|
|
1005 |
else
|
|
1006 |
{
|
|
1007 |
FLOG(_L("DoCloseSMLSessionL new job uses iap from profile"));
|
|
1008 |
dmJob.CreateL(iSyncMLSession, iSyncProfile);
|
|
1009 |
}
|
|
1010 |
iSyncMLAttempts--;
|
|
1011 |
iSyncJobId = dmJob.Identifier();
|
|
1012 |
dmJob.Close();
|
|
1013 |
}
|
|
1014 |
else
|
|
1015 |
// We ran out of attempts, close sml
|
|
1016 |
{
|
|
1017 |
if (iSyncMLSession.Handle())
|
|
1018 |
{
|
|
1019 |
FLOG(_L(" Closing syncml session"));
|
|
1020 |
iSyncMLSession.CancelEvent();
|
|
1021 |
iSyncMLSession.Close();
|
|
1022 |
}
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
if (iTimedSMLSessionClose)
|
|
1026 |
{
|
|
1027 |
FLOG(_L(" closing smlsession timer"));
|
|
1028 |
iTimedSMLSessionClose->Cancel();
|
|
1029 |
delete iTimedSMLSessionClose;
|
|
1030 |
iTimedSMLSessionClose = NULL;
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
FLOG(_L("CFotaServer::DoCloseSMLSessionL() <<"));
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
// --------------------------------------------------------------------------
|
|
1037 |
// CFotaServer::TryResumeDownloadL
|
|
1038 |
// Tries to resume the download operation
|
|
1039 |
// --------------------------------------------------------------------------
|
|
1040 |
//
|
|
1041 |
void CFotaServer::TryResumeDownloadL(TFotaClient aClient, TBool aSilentDl)
|
|
1042 |
{
|
|
1043 |
FLOG(_L("CFotaServer::TryResumeDownloadL, client = %d aSilent = %d >>"),
|
|
1044 |
(TInt) aClient, aSilentDl);
|
|
1045 |
//Check whether there is a paused resume actually.
|
|
1046 |
iAsyncOperation = ETrue;
|
|
1047 |
SetServerActive(ETrue);
|
|
1048 |
WakeupServer();
|
|
1049 |
|
|
1050 |
if (DownloaderL()->IsDownloadActive())
|
|
1051 |
{
|
|
1052 |
FLOG(_L("Another download is already active, hence returning..."));
|
|
1053 |
__LEAVE_IF_ERROR (KErrAlreadyExists);
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
if (iPackageState.iPkgId == KErrNotFound)
|
|
1057 |
iPackageState = GetStateL(-1); //Gets the state of the current/last fota download
|
|
1058 |
|
|
1059 |
FLOG(_L("Session type is =%d "), iPackageState.iSessionType);
|
|
1060 |
|
|
1061 |
if (iPackageState.iState != RFotaEngineSession::EDownloadProgressing)
|
|
1062 |
{
|
|
1063 |
FLOG(_L("There are no paused downloads currently; hence leaving with KErrNotFound..."));
|
|
1064 |
SetServerActive(EFalse);
|
|
1065 |
__LEAVE_IF_ERROR (KErrNotFound);
|
|
1066 |
}
|
|
1067 |
|
|
1068 |
//Resume download now
|
|
1069 |
|
|
1070 |
iPackageState.iSessionType = aSilentDl;
|
|
1071 |
|
|
1072 |
if (aSilentDl && iPackageState.iResult
|
|
1073 |
== RFotaEngineSession::EResUserCancelled)
|
|
1074 |
{
|
|
1075 |
//If user has paused download earlier, then resume should be non-silent.
|
|
1076 |
FLOG(_L("Converting to non-silent download as user had paused it earlier!"));
|
|
1077 |
iPackageState.iSessionType = EFalse;
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
TRAP_IGNORE(SetIapToUseL());
|
|
1081 |
FLOG(_L("Using IAP = %d for the download"), iPackageState.iIapId);
|
|
1082 |
|
|
1083 |
FLOG(_L("Session type = %d"), iPackageState.iSessionType);
|
|
1084 |
iDatabase->OpenDBL();
|
|
1085 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBIapId||EFDBSessionType);
|
|
1086 |
iDatabase->CloseAndCommitDB();
|
|
1087 |
|
|
1088 |
if (iPackageState.iSessionType || aClient == EOMADMAppUi)
|
|
1089 |
{
|
|
1090 |
ConstructApplicationUI(EFalse);
|
|
1091 |
DownloaderL()->TryResumeDownloadL();
|
|
1092 |
}
|
|
1093 |
else
|
|
1094 |
{
|
|
1095 |
ShowDialogL(EFwUpdResumeDownload);
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
FLOG(_L("CFotaServer::TryResumeDownloadL <<"));
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
void CFotaServer::PauseDownloadL()
|
|
1102 |
{
|
|
1103 |
|
|
1104 |
if (DownloaderL()->IsDownloadActive())
|
|
1105 |
{
|
|
1106 |
DownloaderL()->PauseDownloadL();
|
|
1107 |
}
|
|
1108 |
else
|
|
1109 |
{
|
|
1110 |
FLOG(_L("No download is active. Hence leaving with KErrNotFound"));
|
|
1111 |
__LEAVE_IF_ERROR(KErrNotFound);
|
|
1112 |
}
|
|
1113 |
}
|
|
1114 |
// --------------------------------------------------------------------------
|
|
1115 |
// CFotaServer::InvokeFmsL
|
|
1116 |
// Starts Fota Monitory Service with relevant parameters for monitoring.
|
|
1117 |
// --------------------------------------------------------------------------
|
|
1118 |
//
|
|
1119 |
void CFotaServer::InvokeFmsL()
|
|
1120 |
{
|
|
1121 |
FLOG(_L("CFotaServer::InvokeFmsL >>"));
|
|
1122 |
//Collect all information needed to invoke FMS.
|
|
1123 |
CancelFmsL();
|
|
1124 |
|
|
1125 |
FLOG(_L("State as recorded in fota db:"));
|
|
1126 |
FLOG(_L("iPkgId = %d"), iPackageState.iPkgId);
|
|
1127 |
FLOG(_L("iProfileId = %d"), iPackageState.iProfileId);
|
|
1128 |
FLOG(_L("iPkgName = %S"), &iPackageState.iPkgName);
|
|
1129 |
FLOG(_L("iPkgVersion = %S"), &iPackageState.iPkgVersion);
|
|
1130 |
FLOG(_L("iSendAlert = %d"), iPackageState.iSendAlert);
|
|
1131 |
FLOG(_L("iIapId = %d"), iPackageState.iIapId);
|
|
1132 |
FLOG(_L("iPkgSize = %d"), iPackageState.iPkgSize);
|
|
1133 |
FLOG(_L("iSessionType = %d"), iPackageState.iSessionType);
|
|
1134 |
FLOG(_L("iState = %d"), iPackageState.iState);
|
|
1135 |
FLOG(_L("iResult = %d"), iPackageState.iResult);
|
|
1136 |
|
|
1137 |
if (iPackageState.iState == RFotaEngineSession::EDownloadProgressing)
|
|
1138 |
{
|
|
1139 |
//Finding the reason for download interrupt
|
|
1140 |
TFmsIpcCommands reason(EDLGeneralInterrupt); // 13
|
|
1141 |
|
|
1142 |
switch (iPackageState.iResult)
|
|
1143 |
{
|
|
1144 |
case RFotaEngineSession::EResUserCancelled:
|
|
1145 |
{
|
|
1146 |
reason = EDLUserInterrupt; //10
|
|
1147 |
break;
|
|
1148 |
}
|
|
1149 |
case RFotaEngineSession::EResDLFailDueToNWIssues:
|
|
1150 |
{
|
|
1151 |
reason = EDLNetworkInterrupt; //11
|
|
1152 |
break;
|
|
1153 |
}
|
|
1154 |
case RFotaEngineSession::EResDLFailDueToDeviceOOM:
|
|
1155 |
{
|
|
1156 |
reason = EDLMemoryInterrupt; //12
|
|
1157 |
break;
|
|
1158 |
}
|
|
1159 |
default:
|
|
1160 |
{
|
|
1161 |
//reason is already EGeneralInterrupt
|
|
1162 |
break;
|
|
1163 |
}
|
|
1164 |
}
|
|
1165 |
|
|
1166 |
//Finding the drive number
|
|
1167 |
TBuf<KMaxPath> path;
|
|
1168 |
path.Zero();
|
|
1169 |
DownloaderL()->GetUpdatePackageLocation(path);
|
|
1170 |
|
|
1171 |
TInt drive(EDriveC); //Default drive is Phone Memory
|
|
1172 |
TParse p;
|
|
1173 |
if (path.Length() && !p.Set(path, NULL, NULL))
|
|
1174 |
{
|
|
1175 |
TDriveName drivename(p.Drive());
|
|
1176 |
TDriveUnit driveunit(drivename);
|
|
1177 |
if (iFs.IsValidDrive((TInt) driveunit)) //some crash here
|
|
1178 |
drive = driveunit;
|
|
1179 |
}
|
|
1180 |
else
|
|
1181 |
{
|
|
1182 |
FLOG(_L("Error while parsing for drive number! defaulting to Phone Memory (C)"));
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
TInt dlsize = DownloaderL()->GetDownloadPackageSize();
|
|
1186 |
|
|
1187 |
TInt neededsize = iPackageState.iPkgSize - dlsize;
|
|
1188 |
|
|
1189 |
if (neededsize < 0)
|
|
1190 |
neededsize = 0;
|
|
1191 |
|
|
1192 |
FLOG(_L("Launching FMS with params... reason = %d, iapid = %d, drive = %d, neededsize = %d"),
|
|
1193 |
reason, iPackageState.iIapId, drive, neededsize);
|
|
1194 |
iFMSClient.OpenL();
|
|
1195 |
iFMSClient.NotifyForResumeL(reason, iPackageState.iIapId,
|
|
1196 |
(TDriveNumber) drive, neededsize);
|
|
1197 |
iFMSClient.Close();
|
|
1198 |
}
|
|
1199 |
else if (iPackageState.iState == RFotaEngineSession::EStartingUpdate)
|
|
1200 |
{
|
|
1201 |
//Finding the reason for update interrupt
|
|
1202 |
TFmsIpcCommands reason(ENoInterrupt);
|
|
1203 |
|
|
1204 |
switch (iPackageState.iResult)
|
|
1205 |
{
|
|
1206 |
case RFotaEngineSession::EResUserCancelled:
|
|
1207 |
{
|
|
1208 |
reason = EDLUserInterrupt;
|
|
1209 |
}
|
|
1210 |
break;
|
|
1211 |
case RFotaEngineSession::EResLowBattery:
|
|
1212 |
{
|
|
1213 |
reason = EUpdMonitorbattery;
|
|
1214 |
}
|
|
1215 |
default:
|
|
1216 |
{
|
|
1217 |
break;
|
|
1218 |
}
|
|
1219 |
}
|
|
1220 |
FLOG(_L("Launching FMS with params... reason = %d, iapid = %d"), reason, iPackageState.iIapId);
|
|
1221 |
iFMSClient.OpenL();
|
|
1222 |
iFMSClient.NotifyForUpdateL(reason);
|
|
1223 |
iFMSClient.Close();
|
|
1224 |
|
|
1225 |
}
|
|
1226 |
FLOG(_L("CFotaServer::InvokeFmsL <<"));
|
|
1227 |
}
|
|
1228 |
|
|
1229 |
// --------------------------------------------------------------------------
|
|
1230 |
// CFotaServer::CancelFmsL
|
|
1231 |
// Cancels any outstanding monitoring requests in Fota Monitory Service
|
|
1232 |
// --------------------------------------------------------------------------
|
|
1233 |
//
|
|
1234 |
void CFotaServer::CancelFmsL()
|
|
1235 |
{
|
|
1236 |
FLOG(_L("CFotaServer::CancelFmsL >>"));
|
|
1237 |
|
|
1238 |
iFMSClient.OpenL();
|
|
1239 |
iFMSClient.Cancel();
|
|
1240 |
iFMSClient.Close();
|
|
1241 |
|
|
1242 |
FLOG(_L("CFotaServer::CancelFmsL <<"));
|
|
1243 |
}
|
|
1244 |
|
|
1245 |
// --------------------------------------------------------------------------
|
|
1246 |
// CFotaServer::SetStartupReason
|
|
1247 |
// Sets the startup reason for Fota. This is used in Fota Startup pluggin.
|
|
1248 |
// --------------------------------------------------------------------------
|
|
1249 |
//
|
|
1250 |
void CFotaServer::SetStartupReason(TInt aReason)
|
|
1251 |
{
|
|
1252 |
FLOG(_L("CFotaServer::SetStartupReason, aReason = %d >>"), aReason);
|
|
1253 |
|
|
1254 |
CRepository* centrep = NULL;
|
|
1255 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
1256 |
if (err == KErrNone)
|
|
1257 |
{
|
|
1258 |
err = centrep->Set(KFotaUpdateState, aReason);
|
|
1259 |
}
|
|
1260 |
delete centrep;
|
|
1261 |
centrep = NULL;
|
|
1262 |
|
|
1263 |
FLOG(_L("CFotaServer::SetStartupReason, err = %d <<"), err);
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
void CFotaServer::SetUpdateRequester(TFotaClient aRequester)
|
|
1267 |
{
|
|
1268 |
FLOG(_L("CFotaServer::SetUpdateRequester, requester = %d >>"),
|
|
1269 |
aRequester);
|
|
1270 |
|
|
1271 |
CRepository* centrep = NULL;
|
|
1272 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) )
|
|
1273 |
if (err == KErrNone)
|
|
1274 |
{
|
|
1275 |
err = centrep->Set(KUpdateRequesterUid, (TInt) aRequester);
|
|
1276 |
}
|
|
1277 |
delete centrep;
|
|
1278 |
centrep = NULL;
|
|
1279 |
|
|
1280 |
FLOG(_L("CFotaServer::SetUpdateRequester, err = %d <<"), err);
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
TFotaClient CFotaServer::GetUpdateRequester()
|
|
1284 |
{
|
|
1285 |
FLOG(_L("CFotaServer::GetUpdateRequester >>"));
|
|
1286 |
|
|
1287 |
TInt ret(EUnknown);
|
|
1288 |
|
|
1289 |
CRepository* centrep = NULL;
|
|
1290 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
1291 |
if (err == KErrNone)
|
|
1292 |
{
|
|
1293 |
err = centrep->Get(KUpdateRequesterUid, ret);
|
|
1294 |
}
|
|
1295 |
delete centrep;
|
|
1296 |
centrep = NULL;
|
|
1297 |
|
|
1298 |
FLOG(_L("CFotaServer::GetUpdateRequester, requester = %d, err = %d <<"),
|
|
1299 |
ret, err);
|
|
1300 |
|
|
1301 |
return (TFotaClient) ret;
|
|
1302 |
}
|
|
1303 |
|
|
1304 |
// --------------------------------------------------------------------------
|
|
1305 |
// CFotaServer::~CFotaServer()
|
|
1306 |
// Frees database, download, chunk, filewriter, etc resources
|
|
1307 |
// --------------------------------------------------------------------------
|
|
1308 |
//
|
|
1309 |
CFotaServer::~CFotaServer()
|
|
1310 |
{
|
|
1311 |
FLOG(_L("CFotaServer::~CFotaServer >>"));
|
|
1312 |
|
|
1313 |
if (iDatabase)
|
|
1314 |
{
|
|
1315 |
iDatabase->CloseAndCommitDB();
|
|
1316 |
delete iDatabase;
|
|
1317 |
iDatabase = NULL;
|
|
1318 |
}
|
|
1319 |
|
|
1320 |
if (iUpdater)
|
|
1321 |
{
|
|
1322 |
delete iUpdater;
|
|
1323 |
iUpdater = NULL;
|
|
1324 |
}
|
|
1325 |
|
|
1326 |
if (iDownloadFinalizer)
|
|
1327 |
{
|
|
1328 |
iDownloadFinalizer->Cancel();
|
|
1329 |
delete iDownloadFinalizer;
|
|
1330 |
iDownloadFinalizer = NULL;
|
|
1331 |
}
|
|
1332 |
|
|
1333 |
if (iUpdateFinalizer)
|
|
1334 |
{
|
|
1335 |
iUpdateFinalizer->Cancel();
|
|
1336 |
delete iUpdateFinalizer;
|
|
1337 |
iUpdateFinalizer = NULL;
|
|
1338 |
}
|
|
1339 |
|
|
1340 |
if (iTimedExecuteResultFile)
|
|
1341 |
{
|
|
1342 |
iTimedExecuteResultFile->Cancel();
|
|
1343 |
delete iTimedExecuteResultFile;
|
|
1344 |
iTimedExecuteResultFile = NULL;
|
|
1345 |
}
|
|
1346 |
|
|
1347 |
if (iTimedSMLSessionClose)
|
|
1348 |
{
|
|
1349 |
iTimedSMLSessionClose->Cancel();
|
|
1350 |
delete iTimedSMLSessionClose;
|
|
1351 |
iTimedSMLSessionClose = NULL;
|
|
1352 |
}
|
|
1353 |
|
|
1354 |
if (iFs.Handle())
|
|
1355 |
iFs.Close();
|
|
1356 |
|
|
1357 |
if (iSyncMLSession.Handle())
|
|
1358 |
iSyncMLSession.Close();
|
|
1359 |
|
|
1360 |
if (iMonitor)
|
|
1361 |
{
|
|
1362 |
delete iMonitor;
|
|
1363 |
iMonitor = NULL;
|
|
1364 |
}
|
|
1365 |
|
|
1366 |
if (iFMSClient.Handle())
|
|
1367 |
iFMSClient.Close();
|
|
1368 |
|
|
1369 |
if (iDownloader)
|
|
1370 |
{
|
|
1371 |
delete iDownloader;
|
|
1372 |
iDownloader = NULL;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
if (iFullScreenDialog)
|
|
1376 |
{
|
|
1377 |
iFullScreenDialog->deleteLater();
|
|
1378 |
}
|
|
1379 |
|
|
1380 |
/*
|
|
1381 |
if (iNotifParams)
|
|
1382 |
{
|
|
1383 |
delete iNotifParams;
|
|
1384 |
iNotifParams = NULL;
|
|
1385 |
}
|
|
1386 |
|
|
1387 |
if (iNotifier)
|
|
1388 |
{
|
|
1389 |
delete iNotifier;
|
|
1390 |
iNotifier = NULL;
|
|
1391 |
}*/
|
|
1392 |
|
|
1393 |
FLOG(_L("CFotaServer::~CFotaServer <<"));
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
// ---------------------------------------------------------------------------
|
|
1397 |
// CFotaServer::DeletePackageL
|
|
1398 |
// Deletes update package from db
|
|
1399 |
// ---------------------------------------------------------------------------
|
|
1400 |
void CFotaServer::DeletePackageL(const TInt aPkgId)
|
|
1401 |
{
|
|
1402 |
FLOG(_L("CFotaServer::DeletePackageL >> id %d"), aPkgId);
|
|
1403 |
|
|
1404 |
DownloaderL()->DeleteUpdatePackageL();
|
|
1405 |
|
|
1406 |
FLOG(_L("CFotaServer::DeletePackageL <<"));
|
|
1407 |
}
|
|
1408 |
|
|
1409 |
// ---------------------------------------------------------------------------
|
|
1410 |
// CFotaServer::DownloadL
|
|
1411 |
// Create package downloader and download update package.
|
|
1412 |
// ---------------------------------------------------------------------------
|
|
1413 |
void CFotaServer::DownloadL(TDownloadIPCParams aParams,
|
|
1414 |
const TDesC8& aPkgURL, TFotaClient aRequester, TBool aSilent,
|
|
1415 |
TBool aUpdateLtr)
|
|
1416 |
{
|
|
1417 |
FLOG(_L("[FotaServer] Download >>"));
|
|
1418 |
iAsyncOperation = ETrue;
|
|
1419 |
SetServerActive(ETrue);
|
|
1420 |
WakeupServer();
|
|
1421 |
|
|
1422 |
|
|
1423 |
if (DownloaderL()->IsDownloadActive())
|
|
1424 |
{
|
|
1425 |
FLOG(_L("One download is already active, hence leaving!"));
|
|
1426 |
__LEAVE_IF_ERROR(KErrAlreadyExists);
|
|
1427 |
}
|
|
1428 |
|
|
1429 |
TBuf<KSysVersionInfoTextLength> temp;
|
|
1430 |
if (GetSoftwareVersion(temp) == KErrNone)
|
|
1431 |
{
|
|
1432 |
|
|
1433 |
RFileWriteStream wstr;
|
|
1434 |
CleanupClosePushL(wstr);
|
|
1435 |
TInt err1 = wstr.Replace(iFs, KSWversionFile, EFileWrite);
|
|
1436 |
if (err1 == KErrNone)
|
|
1437 |
{
|
|
1438 |
HBufC16* swv;
|
|
1439 |
swv = HBufC16::NewLC(temp.Length());
|
|
1440 |
swv->Des().Copy(temp);
|
|
1441 |
wstr.WriteInt16L(swv->Des().Length()); // length
|
|
1442 |
wstr.WriteL(swv->Des());
|
|
1443 |
wstr.WriteInt16L(0);
|
|
1444 |
CleanupStack::PopAndDestroy(swv);
|
|
1445 |
|
|
1446 |
}
|
|
1447 |
|
|
1448 |
CleanupStack::PopAndDestroy(&wstr); // wstr
|
|
1449 |
}
|
|
1450 |
|
|
1451 |
iPackageState = aParams;
|
|
1452 |
iPackageState.iUpdateLtr = aUpdateLtr;
|
|
1453 |
iPackageState.iSessionType = aSilent;
|
|
1454 |
iPackageState.iIapId = -2; //Signifies default connection to use.
|
|
1455 |
TRAP_IGNORE(SetIapToUseL());
|
|
1456 |
FLOG(_L("Using IAP = %d for the download"), iPackageState.iIapId);
|
|
1457 |
|
|
1458 |
//First entry to fota database
|
|
1459 |
FLOG(_L("DownloadManagerClient::DownloadL, State 1 - writing to database"));
|
|
1460 |
|
|
1461 |
iDatabase->OpenDBL();
|
|
1462 |
iDatabase->SetStateL(iPackageState, aPkgURL, EFDBState | EFDBResult
|
|
1463 |
| EFDBProfileId | EFDBPkgUrl | EFDBPkgName | EFDBVersion
|
|
1464 |
| EFDBUpdateLtr | EFDBSessionType | EFDBIapId);
|
|
1465 |
iDatabase->CloseAndCommitDB();
|
|
1466 |
|
|
1467 |
//Cancel any outstanding requests to monitor.
|
|
1468 |
CancelFmsL();
|
|
1469 |
SetUpdateRequester(aRequester);
|
|
1470 |
ResetCounters();
|
|
1471 |
|
|
1472 |
DownloaderL()->DownloadL(aPkgURL);
|
|
1473 |
|
|
1474 |
|
|
1475 |
FLOG(_L("[FotaServer] Download <<"));
|
|
1476 |
}
|
|
1477 |
|
|
1478 |
// --------------------------------------------------------------------------
|
|
1479 |
// CFotaServer::UpdateL
|
|
1480 |
// Start update
|
|
1481 |
// --------------------------------------------------------------------------
|
|
1482 |
//
|
|
1483 |
void CFotaServer::TryUpdateL(TFotaClient aClient)
|
|
1484 |
{
|
|
1485 |
FLOG(_L("CFotaServer::TryUpdateL, client = %d >>"), (TInt) aClient);
|
|
1486 |
iAsyncOperation = ETrue;
|
|
1487 |
SetServerActive(ETrue);
|
|
1488 |
WakeupServer();
|
|
1489 |
|
|
1490 |
TBool isPkgvalid(ETrue);
|
|
1491 |
isPkgvalid = CheckSWVersionL();
|
|
1492 |
|
|
1493 |
if (!isPkgvalid)
|
|
1494 |
{
|
|
1495 |
FLOG( _L("Fota Update:: Firmware version mismatch! Resetting fota state"));
|
|
1496 |
|
|
1497 |
ResetFotaStateToFailL();
|
|
1498 |
SetServerActive(EFalse);
|
|
1499 |
__LEAVE_IF_ERROR(KErrNotFound);
|
|
1500 |
}
|
|
1501 |
|
|
1502 |
if (iPackageState.iPkgId == KErrNotFound)
|
|
1503 |
iPackageState = GetStateL(-1);
|
|
1504 |
|
|
1505 |
iPackageState.iState = RFotaEngineSession::EStartingUpdate;
|
|
1506 |
iPackageState.iResult = KErrNotFound;
|
|
1507 |
iPackageState.iSendAlert = EFalse;
|
|
1508 |
|
|
1509 |
iDatabase->OpenDBL();
|
|
1510 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBState | EFDBResult);
|
|
1511 |
iDatabase->CloseAndCommitDB();
|
|
1512 |
|
|
1513 |
SetStartupReason(EFotaUpdateInterrupted);
|
|
1514 |
|
|
1515 |
if (IsDeviceDriveBusyL())
|
|
1516 |
{
|
|
1517 |
FLOG(
|
|
1518 |
_L("Fota Update:: Device encryption is onging, hence aborting update!"));
|
|
1519 |
ShowDialogL(EFwUpdDeviceBusy);
|
|
1520 |
|
|
1521 |
__LEAVE_IF_ERROR(KErrNotReady);
|
|
1522 |
}
|
|
1523 |
|
|
1524 |
FLOG(_L("Fota Update:: Firmware version check okie"));
|
|
1525 |
|
|
1526 |
if (!iUpdater)
|
|
1527 |
{
|
|
1528 |
iUpdater = CFotaUpdate::NewL(this);
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
if (aClient != EFMSServer)
|
|
1532 |
{
|
|
1533 |
//Check any active phone call
|
|
1534 |
TInt callactive(EFalse);
|
|
1535 |
iFMSClient.OpenL();
|
|
1536 |
TInt err1 = iFMSClient.IsPhoneCallActive(callactive);
|
|
1537 |
|
|
1538 |
if (callactive)
|
|
1539 |
{
|
|
1540 |
FLOG(_L("Fota Update:: Active call found; differing showing the install dialog!"));
|
|
1541 |
|
|
1542 |
iPackageState.iResult = RFotaEngineSession::EResUpdateFailed;
|
|
1543 |
iDatabase->OpenDBL();
|
|
1544 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBResult);
|
|
1545 |
iDatabase->CloseAndCommitDB();
|
|
1546 |
|
|
1547 |
iFMSClient.NotifyForUpdateL(EUpdMonitorPhoneCallEnd);
|
|
1548 |
iFMSClient.Close();
|
|
1549 |
SetServerActive(EFalse);
|
|
1550 |
__LEAVE_IF_ERROR(KErrNotReady);
|
|
1551 |
}
|
|
1552 |
iFMSClient.Close();
|
|
1553 |
|
|
1554 |
FLOG(_L("Fota Update:: Active phone call check okie "));
|
|
1555 |
|
|
1556 |
TBool batt = iUpdater->CheckBatteryL();
|
|
1557 |
|
|
1558 |
#if defined (__WINS__)
|
|
1559 |
batt = ETrue;
|
|
1560 |
#endif
|
|
1561 |
|
|
1562 |
if (aClient == EOMADMAppUi || aClient == EDMHostServer)
|
|
1563 |
{
|
|
1564 |
FLOG(_L("Device Updates/Adapter. Show Full screen dialog."));
|
|
1565 |
LoopBatteryCheckL(batt);
|
|
1566 |
}
|
|
1567 |
else
|
|
1568 |
{
|
|
1569 |
if (batt)
|
|
1570 |
{
|
|
1571 |
FLOG(_L("Not Device Updates. Show device dialog."));
|
|
1572 |
|
|
1573 |
ShowDialogL(EFwUpdResumeUpdate);
|
|
1574 |
}
|
|
1575 |
else
|
|
1576 |
{
|
|
1577 |
FLOG(_L("Not Device Updates. Leave and monitor for battery."));
|
|
1578 |
|
|
1579 |
iPackageState.iState = RFotaEngineSession::EStartingUpdate;
|
|
1580 |
iPackageState.iResult = RFotaEngineSession::EResLowBattery;
|
|
1581 |
|
|
1582 |
iDatabase->OpenDBL();
|
|
1583 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBState
|
|
1584 |
| EFDBResult);
|
|
1585 |
iDatabase->CloseAndCommitDB();
|
|
1586 |
|
|
1587 |
InvokeFmsL();
|
|
1588 |
|
|
1589 |
__LEAVE_IF_ERROR(KErrBadPower);
|
|
1590 |
}
|
|
1591 |
}
|
|
1592 |
}
|
|
1593 |
else
|
|
1594 |
{
|
|
1595 |
ShowDialogL(EFwUpdResumeUpdate);
|
|
1596 |
}
|
|
1597 |
FLOG(_L("CFotaServer::TryUpdateL <<"));
|
|
1598 |
}
|
|
1599 |
|
|
1600 |
void CFotaServer::LoopBatteryCheckL(TBool aBatteryLevel)
|
|
1601 |
{
|
|
1602 |
FLOG(_L("CFotaServer::LoopBatteryCheckL, level = %d"), aBatteryLevel);
|
|
1603 |
if (aBatteryLevel)
|
|
1604 |
{
|
|
1605 |
FLOG(_L("Fota Update:: Battery check success; monitoring battery until update"));
|
|
1606 |
ShowFullScreenDialog(EHbFotaUpdate);
|
|
1607 |
ConstructApplicationUI(ETrue);
|
|
1608 |
iUpdater->MonitorBatteryChargeLevel();
|
|
1609 |
}
|
|
1610 |
else
|
|
1611 |
{
|
|
1612 |
FLOG(_L("Fota Update:: Battery check failed; monitoring for charger connection"));
|
|
1613 |
|
|
1614 |
iPackageState.iState = RFotaEngineSession::EStartingUpdate;
|
|
1615 |
iPackageState.iResult = RFotaEngineSession::EResLowBattery;
|
|
1616 |
iDatabase->OpenDBL();
|
|
1617 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBResult);
|
|
1618 |
iDatabase->CloseAndCommitDB();
|
|
1619 |
|
|
1620 |
ShowFullScreenDialog(EHbFotaLowBattery);
|
|
1621 |
ConstructApplicationUI(ETrue);
|
|
1622 |
iUpdater->MonitorBatteryChargingStatus();
|
|
1623 |
}
|
|
1624 |
FLOG(_L("CFotaServer::LoopBatteryCheckL <<"));
|
|
1625 |
}
|
|
1626 |
|
|
1627 |
|
|
1628 |
void CFotaServer::FinalizeUpdate()
|
|
1629 |
{
|
|
1630 |
FLOG(_L("CFotaServer::FinalizeUpdate >>"));
|
|
1631 |
|
|
1632 |
if (iPackageState.iResult == RFotaEngineSession::EResLowBattery)
|
|
1633 |
{
|
|
1634 |
TRAP_IGNORE(InvokeFmsL());
|
|
1635 |
}
|
|
1636 |
SetServerActive(EFalse);
|
|
1637 |
ServerCanShut(ETrue);
|
|
1638 |
StopServerWhenPossible();
|
|
1639 |
FLOG(_L("CFotaServer::FinalizeUpdate <<"));
|
|
1640 |
}
|
|
1641 |
|
|
1642 |
|
|
1643 |
FotaFullscreenDialog* CFotaServer::FullScreenDialog()
|
|
1644 |
{
|
|
1645 |
return iFullScreenDialog;
|
|
1646 |
}
|
|
1647 |
|
|
1648 |
void CFotaServer::HandleFullScreenDialogResponse(TInt aResponse)
|
|
1649 |
{
|
|
1650 |
FLOG(_L("CFotaServer::HandleFullScreenDialogResponse, response = %d >>"),
|
|
1651 |
aResponse);
|
|
1652 |
|
|
1653 |
TBool active (EFalse);
|
|
1654 |
TRAP_IGNORE(active = DownloaderL()->IsDownloadActive());
|
|
1655 |
CEikonEnv* env = CEikonEnv::Static();
|
|
1656 |
|
|
1657 |
if (iPackageState.iState == RFotaEngineSession::EDownloadProgressing)
|
|
1658 |
{
|
|
1659 |
|
|
1660 |
//swapProcess(EFalse);
|
|
1661 |
ConstructApplicationUI(EFalse);
|
|
1662 |
if (aResponse == EHbLSK)
|
|
1663 |
{
|
|
1664 |
//HIDE is pressed
|
|
1665 |
FLOG(_L("HIDE is pressed"));
|
|
1666 |
if (env)
|
|
1667 |
{
|
|
1668 |
CApaWindowGroupName* wgName (NULL);
|
|
1669 |
TRAP_IGNORE( wgName = CApaWindowGroupName::NewL(env->WsSession()));
|
|
1670 |
if (wgName)
|
|
1671 |
{
|
|
1672 |
wgName->SetHidden(EFalse); // hides us from FSW and protects us from OOM FW etc.
|
|
1673 |
delete wgName;
|
|
1674 |
}
|
|
1675 |
}
|
|
1676 |
}
|
|
1677 |
else
|
|
1678 |
{
|
|
1679 |
DecrementUserPostponeCount();
|
|
1680 |
if (active)
|
|
1681 |
{
|
|
1682 |
FLOG(_L("CONTINUE LATER is pressed on update dialog"));
|
|
1683 |
/*
|
|
1684 |
if (env)
|
|
1685 |
{
|
|
1686 |
CApaWindowGroupName* wgName;
|
|
1687 |
TRAP_IGNORE(wgName = CApaWindowGroupName::NewL(env->WsSession()));
|
|
1688 |
if (wgName)
|
|
1689 |
{
|
|
1690 |
wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
|
|
1691 |
delete wgName;
|
|
1692 |
}
|
|
1693 |
}*/
|
|
1694 |
TRAP_IGNORE(PauseDownloadL());
|
|
1695 |
}
|
|
1696 |
}
|
|
1697 |
}
|
|
1698 |
else if (iPackageState.iState == RFotaEngineSession::EDownloadComplete
|
|
1699 |
|| iPackageState.iState == RFotaEngineSession::EStartingUpdate)
|
|
1700 |
{
|
|
1701 |
if (aResponse == EHbLSK)
|
|
1702 |
{
|
|
1703 |
FLOG(_L("CONTINUE is pressed/Timeout on update dialog"));
|
|
1704 |
iPackageState.iResult = KErrNotFound;
|
|
1705 |
TRAPD(err,
|
|
1706 |
iDatabase->OpenDBL();
|
|
1707 |
iDatabase->SetStateL( iPackageState ,KNullDesC8,EFDBResult );
|
|
1708 |
iDatabase->CloseAndCommitDB();
|
|
1709 |
);
|
|
1710 |
FLOG(_L("Updating the fota database... err = %d"), err);
|
|
1711 |
|
|
1712 |
TInt callactive(EFalse);
|
|
1713 |
|
|
1714 |
TRAP(err,
|
|
1715 |
iFMSClient.OpenL();
|
|
1716 |
TInt err1 = iFMSClient.IsPhoneCallActive(callactive);
|
|
1717 |
iFMSClient.Close();
|
|
1718 |
);
|
|
1719 |
|
|
1720 |
if (callactive)
|
|
1721 |
{
|
|
1722 |
FLOG(_L("Fota Update:: Active call found; differing showing the install dialog!"));
|
|
1723 |
|
|
1724 |
iPackageState.iResult = RFotaEngineSession::EResUpdateFailed;
|
|
1725 |
TRAP(err,
|
|
1726 |
iDatabase->OpenDBL();
|
|
1727 |
iDatabase->SetStateL(iPackageState, KNullDesC8, EFDBResult);
|
|
1728 |
iDatabase->CloseAndCommitDB();
|
|
1729 |
);
|
|
1730 |
|
|
1731 |
TRAP(err,
|
|
1732 |
iFMSClient.OpenL();
|
|
1733 |
iFMSClient.NotifyForUpdateL(EUpdMonitorPhoneCallEnd);
|
|
1734 |
iFMSClient.Close();
|
|
1735 |
);
|
|
1736 |
|
|
1737 |
FLOG(_L("Deleting the fullscreen dialog..."));
|
|
1738 |
iFullScreenDialog->deleteLater();
|
|
1739 |
iFullScreenDialog = NULL;
|
|
1740 |
SetServerActive(EFalse);
|
|
1741 |
return;
|
|
1742 |
}
|
|
1743 |
|
|
1744 |
TRAP(err, iUpdater->StartUpdateL( iPackageState ));
|
|
1745 |
FLOG(_L("Starting update, err = %d"), err);
|
|
1746 |
}
|
|
1747 |
else
|
|
1748 |
{
|
|
1749 |
FLOG(_L("CONTINUE LATER is pressed on update dialog"));
|
|
1750 |
ConstructApplicationUI(EFalse);
|
|
1751 |
|
|
1752 |
iUpdater->CancelMonitor();
|
|
1753 |
|
|
1754 |
if (iFullScreenDialog->IsLSKEnabled())
|
|
1755 |
{
|
|
1756 |
DecrementUserPostponeCount();
|
|
1757 |
}
|
|
1758 |
|
|
1759 |
iPackageState.iState = RFotaEngineSession::EStartingUpdate;
|
|
1760 |
iPackageState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
1761 |
TRAPD(err,
|
|
1762 |
iDatabase->OpenDBL();
|
|
1763 |
iDatabase->SetStateL( iPackageState ,KNullDesC8,EFDBState|EFDBResult );
|
|
1764 |
iDatabase->CloseAndCommitDB();
|
|
1765 |
);
|
|
1766 |
FLOG(_L("Updating the fota database... err = %d"), err);
|
|
1767 |
|
|
1768 |
SetStartupReason(EFotaUpdateInterrupted);
|
|
1769 |
SetServerActive(EFalse);
|
|
1770 |
TRAP(err, InvokeFmsL());
|
|
1771 |
StopServerWhenPossible();
|
|
1772 |
|
|
1773 |
iAsyncOperation = EFalse;
|
|
1774 |
FLOG(_L("Invoking fms, err = %d"), err);
|
|
1775 |
}
|
|
1776 |
}
|
|
1777 |
FLOG(_L("CFotaServer::HandleFullScreenDialogResponse <<"));
|
|
1778 |
}
|
|
1779 |
|
|
1780 |
void CFotaServer::UpdateBatteryLowInfo(TBool aValue)
|
|
1781 |
{
|
|
1782 |
FLOG(_L("CFotaServer::UpdateBatteryLowInfo >>"));
|
|
1783 |
|
|
1784 |
if (aValue)
|
|
1785 |
{
|
|
1786 |
FLOG(
|
|
1787 |
_L("Fota Update:: Battery has become low; disabling installation"));
|
|
1788 |
iPackageState.iResult = RFotaEngineSession::EResUpdateFailed;
|
|
1789 |
TRAP_IGNORE(
|
|
1790 |
iDatabase->OpenDBL();
|
|
1791 |
iDatabase->SetStateL( iPackageState ,KNullDesC8,EFDBResult );
|
|
1792 |
iDatabase->CloseAndCommitDB();
|
|
1793 |
);
|
|
1794 |
|
|
1795 |
ShowFullScreenDialog(EHbFotaLowBattery);
|
|
1796 |
}
|
|
1797 |
else
|
|
1798 |
{
|
|
1799 |
ShowFullScreenDialog(EHbFotaUpdate);
|
|
1800 |
FLOG(
|
|
1801 |
_L("Fota Update:: Battery is still sufficient; enabling installation"));
|
|
1802 |
}
|
|
1803 |
FLOG(_L("CFotaServer::UpdateBatteryLowInfo <<"));
|
|
1804 |
}
|
|
1805 |
|
|
1806 |
// --------------------------------------------------------------------------
|
|
1807 |
// CFotaServer::CheckSWVersionL
|
|
1808 |
// Check the s/w version
|
|
1809 |
// --------------------------------------------------------------------------
|
|
1810 |
//
|
|
1811 |
|
|
1812 |
TBool CFotaServer::CheckSWVersionL()
|
|
1813 |
|
|
1814 |
{
|
|
1815 |
FLOG(_L("CFotaServer::CheckSWVersionL >>"));
|
|
1816 |
TBuf<KSysVersionInfoTextLength> temp;
|
|
1817 |
HBufC16* message16 = NULL;
|
|
1818 |
TBool isPkgvalid(ETrue);
|
|
1819 |
if (GetSoftwareVersion(temp) == KErrNone)
|
|
1820 |
{
|
|
1821 |
|
|
1822 |
//TBuf<KSysVersionInfoTextLength>swvfromfile;
|
|
1823 |
//Fetch the software version ...
|
|
1824 |
RFileReadStream rstr;
|
|
1825 |
TInt err1 = rstr.Open(iFs, KSWversionFile, EFileRead);
|
|
1826 |
if (err1 == KErrNone)
|
|
1827 |
{
|
|
1828 |
CleanupClosePushL(rstr);
|
|
1829 |
TInt msglen = rstr.ReadInt16L();
|
|
1830 |
if (msglen > 0)
|
|
1831 |
{
|
|
1832 |
message16 = HBufC16::NewLC(msglen + 1);
|
|
1833 |
TPtr16 tempswv = message16->Des();
|
|
1834 |
TRAPD(err, rstr.ReadL(tempswv,msglen ));
|
|
1835 |
|
|
1836 |
if (err != KErrNone && err != KErrEof)
|
|
1837 |
{
|
|
1838 |
FLOG(_L(" file read err %d"), err); //User::Leave( err );
|
|
1839 |
msglen = 0;
|
|
1840 |
}
|
|
1841 |
else
|
|
1842 |
{
|
|
1843 |
FLOG(_L(" msglen %d"), msglen);
|
|
1844 |
TPtr swvfromfile = message16->Des();
|
|
1845 |
|
|
1846 |
FLOG(_L(" swvfromfile=%S"), message16);
|
|
1847 |
|
|
1848 |
//Compare the software versions to decide whether the download is still valid or not.
|
|
1849 |
if (msglen != temp.Length() || temp.Compare(tempswv)
|
|
1850 |
!= KErrNone)
|
|
1851 |
{
|
|
1852 |
isPkgvalid = EFalse;
|
|
1853 |
FLOG(_L("CFotaServer::software not matching >>"));
|
|
1854 |
|
|
1855 |
}
|
|
1856 |
}
|
|
1857 |
|
|
1858 |
CleanupStack::PopAndDestroy(message16);
|
|
1859 |
}
|
|
1860 |
CleanupStack::PopAndDestroy(&rstr);
|
|
1861 |
|
|
1862 |
}
|
|
1863 |
|
|
1864 |
}
|
|
1865 |
|
|
1866 |
FLOG(_L("CFotaServer::CheckSWVersionL <<"));
|
|
1867 |
return isPkgvalid;
|
|
1868 |
|
|
1869 |
}
|
|
1870 |
|
|
1871 |
// --------------------------------------------------------------------------
|
|
1872 |
// CFotaServer::ScheduledUpdateL
|
|
1873 |
// Update, triggered by scheduler
|
|
1874 |
// --------------------------------------------------------------------------
|
|
1875 |
void CFotaServer::ScheduledUpdateL(TFotaScheduledUpdate aUpdate,
|
|
1876 |
TFotaClient aClient)
|
|
1877 |
{
|
|
1878 |
FLOG(_L("CFotaServer::ScheduledUpdateL >>"));
|
|
1879 |
|
|
1880 |
iAsyncOperation = ETrue;
|
|
1881 |
WakeupServer();
|
|
1882 |
|
|
1883 |
TPackageState s = GetStateL(aUpdate.iPkgId);
|
|
1884 |
|
|
1885 |
if (s.iState == RFotaEngineSession::EDownloadProgressing)
|
|
1886 |
{
|
|
1887 |
FLOG(_L("Trying to resume the download in non-silent mode"));
|
|
1888 |
iPackageState = s;
|
|
1889 |
TryResumeDownloadL(aClient, EFalse);
|
|
1890 |
}
|
|
1891 |
else if (s.iState == RFotaEngineSession::EStartingUpdate)
|
|
1892 |
{
|
|
1893 |
// If update is in progress, do not start new one (multiple popups)
|
|
1894 |
if (iUpdater)
|
|
1895 |
{
|
|
1896 |
FLOG(_L("\t\tupdate in progress"));
|
|
1897 |
return;
|
|
1898 |
}
|
|
1899 |
else
|
|
1900 |
{
|
|
1901 |
FLOG(_L("Trying to resume the installation in non-silent mode"));
|
|
1902 |
iPackageState = s;
|
|
1903 |
TryUpdateL(aClient);
|
|
1904 |
}
|
|
1905 |
}
|
|
1906 |
FLOG(_L("CFotaServer::ScheduledUpdateL <<"));
|
|
1907 |
}
|
|
1908 |
|
|
1909 |
// --------------------------------------------------------------------------
|
|
1910 |
// CFotaServer::DoConnect
|
|
1911 |
// From CServer2. Initializes class members.
|
|
1912 |
// --------------------------------------------------------------------------
|
|
1913 |
void CFotaServer::DoConnect(const RMessage2 &aMessage)
|
|
1914 |
{
|
|
1915 |
FLOG(_L("CFotaServer::DoConnect(const RMessage2 &aMessage) >>"));
|
|
1916 |
|
|
1917 |
// In case shutdown is in progress, cancel it.
|
|
1918 |
if (iInitialized == EFalse)
|
|
1919 |
{
|
|
1920 |
TRAPD( err, ClientAwareConstructL( aMessage ) );
|
|
1921 |
if (err)
|
|
1922 |
FLOG(_L(" ClientAwareConstructL err %d"), err);
|
|
1923 |
}
|
|
1924 |
CServer2::DoConnect(aMessage);
|
|
1925 |
FLOG(_L("CFotaServer::DoConnect(const RMessage2 &aMessage) <<"));
|
|
1926 |
}
|
|
1927 |
|
|
1928 |
// --------------------------------------------------------------------------
|
|
1929 |
// CFotaServer::GetStateL
|
|
1930 |
// Get state of a download package
|
|
1931 |
// --------------------------------------------------------------------------
|
|
1932 |
TPackageState CFotaServer::GetStateL(const TInt aPkgId)
|
|
1933 |
{
|
|
1934 |
FLOG(_L("CFotaServer::GetStateL >>"));
|
|
1935 |
TPackageState s = RFotaEngineSession::EIdle;
|
|
1936 |
|
|
1937 |
if (aPkgId >= 0) // Used by all clients
|
|
1938 |
{
|
|
1939 |
iDatabase->OpenDBL();
|
|
1940 |
s = iDatabase->GetStateL(aPkgId,iLastFwUrl);
|
|
1941 |
iDatabase->CloseAndCommitDB();
|
|
1942 |
}
|
|
1943 |
else if (aPkgId == -1) //Used by DM UI to get the state of last fota operation
|
|
1944 |
{
|
|
1945 |
//Read status from fotastate last entry
|
|
1946 |
|
|
1947 |
iDatabase->OpenDBL();
|
|
1948 |
|
|
1949 |
RArray<TInt> states;
|
|
1950 |
CleanupClosePushL(states);
|
|
1951 |
iDatabase->GetAllL(states);
|
|
1952 |
// Loop states.
|
|
1953 |
for (TInt i = 0; i < states.Count(); ++i)
|
|
1954 |
{
|
|
1955 |
TPackageState tmp;
|
|
1956 |
TBuf8<KMaxFileName> tmpurl;
|
|
1957 |
tmp = iDatabase->GetStateL(states[i], tmpurl);
|
|
1958 |
FLOG(_L("***Package: %d, State = %d"), states[i],
|
|
1959 |
(TInt) tmp.iState);
|
|
1960 |
if (tmp.iState != RFotaEngineSession::EIdle)
|
|
1961 |
{
|
|
1962 |
s = tmp;
|
|
1963 |
iLastFwUrl.Copy(tmpurl);
|
|
1964 |
}
|
|
1965 |
}
|
|
1966 |
FLOG(_L("Status of current operation is %d"), (TInt) s.iState);
|
|
1967 |
|
|
1968 |
CleanupStack::PopAndDestroy(&states);
|
|
1969 |
iDatabase->CloseAndCommitDB();
|
|
1970 |
}
|
|
1971 |
FLOG(_L("CFotaServer::GetStateL <<"));
|
|
1972 |
return s;
|
|
1973 |
}
|
|
1974 |
|
|
1975 |
// --------------------------------------------------------------------------
|
|
1976 |
// CFotaServer::OnSyncMLSessionEvent
|
|
1977 |
// --------------------------------------------------------------------------
|
|
1978 |
//
|
|
1979 |
void CFotaServer::OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier,
|
|
1980 |
TInt aError, TInt /*aAdditionalData*/)
|
|
1981 |
{
|
|
1982 |
FLOG(_L("CFotaServer::OnSyncMLSessionEvent >>"));
|
|
1983 |
|
|
1984 |
if (iSyncJobId != aIdentifier)
|
|
1985 |
return;
|
|
1986 |
FLOG(_L("CFotaServer::OnSyncMLSessionEvent %d err:%d (id %d==%d?)"),
|
|
1987 |
aEvent, aError, aIdentifier, iSyncJobId);
|
|
1988 |
TBool end(EFalse);
|
|
1989 |
|
|
1990 |
if (iSyncJobId == aIdentifier)
|
|
1991 |
{
|
|
1992 |
|
|
1993 |
switch (aEvent)
|
|
1994 |
{
|
|
1995 |
//EJobStart = 0
|
|
1996 |
case EJobStartFailed: // 1 E
|
|
1997 |
{
|
|
1998 |
end = ETrue;
|
|
1999 |
}
|
|
2000 |
break;
|
|
2001 |
case EJobStop: // 2 E
|
|
2002 |
{
|
|
2003 |
end = ETrue;
|
|
2004 |
// Sync ok => do not try anymore
|
|
2005 |
if (aError == KErrNone)
|
|
2006 |
{
|
|
2007 |
iSyncMLAttempts = 0;
|
|
2008 |
}
|
|
2009 |
}
|
|
2010 |
break;
|
|
2011 |
case EJobRejected: // 3 E
|
|
2012 |
{
|
|
2013 |
end = ETrue;
|
|
2014 |
}
|
|
2015 |
break;
|
|
2016 |
// ETransportTimeout , // 7
|
|
2017 |
default:
|
|
2018 |
{
|
|
2019 |
}
|
|
2020 |
break;
|
|
2021 |
}
|
|
2022 |
}
|
|
2023 |
|
|
2024 |
if (end && iSyncMLAttempts == 0)
|
|
2025 |
{
|
|
2026 |
if (iTimedSMLSessionClose)
|
|
2027 |
{
|
|
2028 |
FLOG(_L(" closing smlsession timer"));
|
|
2029 |
iTimedSMLSessionClose->Cancel();
|
|
2030 |
delete iTimedSMLSessionClose;
|
|
2031 |
iTimedSMLSessionClose = NULL;
|
|
2032 |
}
|
|
2033 |
StopServerWhenPossible();
|
|
2034 |
|
|
2035 |
}
|
|
2036 |
else if (end)
|
|
2037 |
{
|
|
2038 |
|
|
2039 |
if (iTimedSMLSessionClose)
|
|
2040 |
{
|
|
2041 |
FLOG(_L(" closing smlsession timer"));
|
|
2042 |
iTimedSMLSessionClose->Cancel();
|
|
2043 |
delete iTimedSMLSessionClose;
|
|
2044 |
iTimedSMLSessionClose = NULL;
|
|
2045 |
}
|
|
2046 |
|
|
2047 |
FLOG(_L(" starting smlsession timer"));
|
|
2048 |
TRAPD( err2, iTimedSMLSessionClose = CPeriodic::NewL (EPriorityNormal) );
|
|
2049 |
if (!err2)
|
|
2050 |
{
|
|
2051 |
iTimedSMLSessionClose->Start(TTimeIntervalMicroSeconds32(
|
|
2052 |
KSyncmlSessionRetryInterval),
|
|
2053 |
TTimeIntervalMicroSeconds32(
|
|
2054 |
KSyncmlSessionRetryInterval), TCallBack(
|
|
2055 |
StaticDoCloseSMLSession, this));
|
|
2056 |
}
|
|
2057 |
else
|
|
2058 |
FLOG(_L(" iTimedSMLSessionClose err %d"), err2);
|
|
2059 |
}
|
|
2060 |
FLOG(_L("CFotaServer::OnSyncMLSessionEvent <<"));
|
|
2061 |
}
|
|
2062 |
|
|
2063 |
// --------------------------------------------------------------------------
|
|
2064 |
// CFotaServer::GetUpdateTimeStampL
|
|
2065 |
// Gets time of last update. It is stored in a file.
|
|
2066 |
// --------------------------------------------------------------------------
|
|
2067 |
void CFotaServer::GetUpdateTimeStampL(TDes16& aTime)
|
|
2068 |
{
|
|
2069 |
FLOG(_L("CFotaServer::GetUpdateTimeStampL >>"));
|
|
2070 |
TInt err;
|
|
2071 |
|
|
2072 |
RFileReadStream rstr;
|
|
2073 |
err = rstr.Open(iFs, _L("updatetimestamp"), EFileRead);
|
|
2074 |
|
|
2075 |
if (err == KErrNone)
|
|
2076 |
{
|
|
2077 |
FLOG(_L(" update time stamp file found,reading"));
|
|
2078 |
CleanupClosePushL(rstr);
|
|
2079 |
TInt year = rstr.ReadInt32L();
|
|
2080 |
TInt month = rstr.ReadInt32L();
|
|
2081 |
TInt day = rstr.ReadInt32L();
|
|
2082 |
TInt hour = rstr.ReadInt32L();
|
|
2083 |
TInt minute = rstr.ReadInt32L();
|
|
2084 |
TInt year16 = year;
|
|
2085 |
TInt month16 = month;
|
|
2086 |
TInt day16 = day;
|
|
2087 |
TInt hour16 = hour;
|
|
2088 |
TInt minute16 = minute;
|
|
2089 |
CleanupStack::PopAndDestroy(&rstr);
|
|
2090 |
aTime.Append(year16);
|
|
2091 |
aTime.Append(month16);
|
|
2092 |
aTime.Append(day16);
|
|
2093 |
aTime.Append(hour16);
|
|
2094 |
aTime.Append(minute16);
|
|
2095 |
}
|
|
2096 |
else if (err != KErrNotFound)
|
|
2097 |
{
|
|
2098 |
__LEAVE_IF_ERROR ( err );
|
|
2099 |
}
|
|
2100 |
|
|
2101 |
if (err == KErrNotFound)
|
|
2102 |
{
|
|
2103 |
FLOG(_L(" update time stamp not found "));
|
|
2104 |
}
|
|
2105 |
|
|
2106 |
FLOG(_L("CFotaServer::GetUpdateTimeStampL <<"));
|
|
2107 |
}
|
|
2108 |
|
|
2109 |
void CFotaServer::GetCurrentFwDetailsL(TDes8& aName, TDes8& aVersion,
|
|
2110 |
TInt& aSize)
|
|
2111 |
{
|
|
2112 |
FLOG(_L("CFotaServer::GetCurrentFwDetailsL >>"));
|
|
2113 |
|
|
2114 |
TPackageState package = GetStateL(-1);
|
|
2115 |
|
|
2116 |
aName.Copy(package.iPkgName);
|
|
2117 |
aVersion.Copy(package.iPkgVersion);
|
|
2118 |
aSize = package.iPkgSize;
|
|
2119 |
|
|
2120 |
FLOG(_L("CFotaServer::GetCurrentFwDetailsL <<"));
|
|
2121 |
}
|
|
2122 |
// --------------------------------------------------------------------------
|
|
2123 |
// CFotaServer::GetUpdatePackageIdsL
|
|
2124 |
// --------------------------------------------------------------------------
|
|
2125 |
//
|
|
2126 |
void CFotaServer::GetUpdatePackageIdsL(TDes16& aPackageIdList)
|
|
2127 |
{
|
|
2128 |
FLOG(_L("CFotaServer::GetUpdatePackageIdsL()"));
|
|
2129 |
__LEAVE_IF_ERROR(KErrNotSupported);
|
|
2130 |
}
|
|
2131 |
|
|
2132 |
// --------------------------------------------------------------------------
|
|
2133 |
// CFotaServer::GenericAlertSentL
|
|
2134 |
// Generic alert sent, do cleanup. FUMO spec specifies cleanup need to have
|
|
2135 |
// for states 20,70,80,90,100. Called by syncml framework when it has sent
|
|
2136 |
// generic alert
|
|
2137 |
// --------------------------------------------------------------------------
|
|
2138 |
//
|
|
2139 |
void CFotaServer::ResetFotaStateL(const TInt aPackageID)
|
|
2140 |
{
|
|
2141 |
FLOG(_L("CFotaServer::ResetFotaStateL %d"), aPackageID);
|
|
2142 |
TPackageState state;
|
|
2143 |
TBool toidle(EFalse);
|
|
2144 |
TBool deletepkg(EFalse);
|
|
2145 |
|
|
2146 |
iDatabase->OpenDBL();
|
|
2147 |
state = iDatabase->GetStateL(aPackageID, iLastFwUrl);
|
|
2148 |
|
|
2149 |
switch (state.iState)
|
|
2150 |
{
|
|
2151 |
case RFotaEngineSession::EDownloadFailed:
|
|
2152 |
{
|
|
2153 |
toidle = ETrue;
|
|
2154 |
deletepkg = ETrue;
|
|
2155 |
}
|
|
2156 |
break;
|
|
2157 |
case RFotaEngineSession::EUpdateFailed:
|
|
2158 |
{
|
|
2159 |
toidle = ETrue;
|
|
2160 |
deletepkg = ETrue;
|
|
2161 |
}
|
|
2162 |
break;
|
|
2163 |
case RFotaEngineSession::EUpdateFailedNoData:
|
|
2164 |
{
|
|
2165 |
toidle = ETrue;
|
|
2166 |
}
|
|
2167 |
break;
|
|
2168 |
case RFotaEngineSession::EUpdateSuccessful:
|
|
2169 |
{
|
|
2170 |
toidle = ETrue;
|
|
2171 |
}
|
|
2172 |
break;
|
|
2173 |
case RFotaEngineSession::EUpdateSuccessfulNoData:
|
|
2174 |
{
|
|
2175 |
toidle = ETrue;
|
|
2176 |
}
|
|
2177 |
break;
|
|
2178 |
case RFotaEngineSession::EDownloadComplete:
|
|
2179 |
{
|
|
2180 |
state.iState = RFotaEngineSession::EStartingUpdate;
|
|
2181 |
state.iResult = KErrNotFound;
|
|
2182 |
iDatabase->SetStateL(state, KNullDesC8, EFDBState);
|
|
2183 |
toidle = EFalse;
|
|
2184 |
}
|
|
2185 |
break;
|
|
2186 |
default:
|
|
2187 |
{
|
|
2188 |
FLOG(_L(" pkg %d (state:%d) doesnt need cleanup"), aPackageID,
|
|
2189 |
state.iState);
|
|
2190 |
}
|
|
2191 |
break;
|
|
2192 |
|
|
2193 |
}
|
|
2194 |
|
|
2195 |
if (toidle)
|
|
2196 |
{
|
|
2197 |
state.iState = RFotaEngineSession::EIdle;
|
|
2198 |
state.iResult = KErrNotFound;
|
|
2199 |
iDatabase->SetStateL(state, KNullDesC8, EFDBState | EFDBResult);
|
|
2200 |
DeleteFUMOTreeL();
|
|
2201 |
}
|
|
2202 |
|
|
2203 |
iDatabase->CloseAndCommitDB();
|
|
2204 |
|
|
2205 |
SetStartupReason(EFotaDefault);
|
|
2206 |
|
|
2207 |
if (deletepkg)
|
|
2208 |
{
|
|
2209 |
DownloaderL()->DeleteUpdatePackageL();
|
|
2210 |
}
|
|
2211 |
}
|
|
2212 |
|
|
2213 |
void CFotaServer::ResetCounters()
|
|
2214 |
{
|
|
2215 |
FLOG(_L("CFotaServer::ResetCounters >>"));
|
|
2216 |
|
|
2217 |
CRepository* centrep = NULL;
|
|
2218 |
TInt maxcount(0);
|
|
2219 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
2220 |
if (err == KErrNone)
|
|
2221 |
{
|
|
2222 |
err = centrep->Get(KFOTAMaxPostponeCount, maxcount);
|
|
2223 |
err = centrep->Set(KFOTAUserPostponeCount, maxcount);
|
|
2224 |
err = centrep->Set(KFOTADownloadRestartCount, KMaxDownloadRestartCount);
|
|
2225 |
}
|
|
2226 |
delete centrep;
|
|
2227 |
centrep = NULL;
|
|
2228 |
|
|
2229 |
FLOG(_L("CFotaServer::ResetCounters, postpone count set to %d, err = %d <<"), maxcount, err);
|
|
2230 |
}
|
|
2231 |
|
|
2232 |
TBool CFotaServer::IsUserPostponeAllowed()
|
|
2233 |
{
|
|
2234 |
FLOG(_L("CFotaServer::IsUserPostponeAllowed >>"));
|
|
2235 |
|
|
2236 |
TBool ret(ETrue);
|
|
2237 |
CRepository* centrep = NULL;
|
|
2238 |
TInt count(1);
|
|
2239 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
2240 |
if (err == KErrNone)
|
|
2241 |
{
|
|
2242 |
err = centrep->Get(KFOTAUserPostponeCount, count);
|
|
2243 |
}
|
|
2244 |
delete centrep;
|
|
2245 |
centrep = NULL;
|
|
2246 |
|
|
2247 |
if (count == 0)
|
|
2248 |
ret = EFalse;
|
|
2249 |
else if (count == -1) //-1 signifies infinite postpone
|
|
2250 |
ret = ETrue;
|
|
2251 |
|
|
2252 |
FLOG(_L("CFotaServer::IsUserPostponeAllowed, count = %d, ret = %d, err = %d >>"), count, ret, err);
|
|
2253 |
|
|
2254 |
return ret;
|
|
2255 |
}
|
|
2256 |
|
|
2257 |
void CFotaServer::DecrementUserPostponeCount()
|
|
2258 |
{
|
|
2259 |
FLOG(_L("CFotaServer::DecrementUserPostponeCount >>"));
|
|
2260 |
|
|
2261 |
CRepository* centrep = NULL;
|
|
2262 |
TInt count;
|
|
2263 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
2264 |
if (err == KErrNone)
|
|
2265 |
{
|
|
2266 |
err = centrep->Get(KFOTAUserPostponeCount, count);
|
|
2267 |
if (--count < 0)
|
|
2268 |
count = 0;
|
|
2269 |
err = centrep->Set(KFOTAUserPostponeCount, count);
|
|
2270 |
}
|
|
2271 |
delete centrep;
|
|
2272 |
centrep = NULL;
|
|
2273 |
|
|
2274 |
FLOG(
|
|
2275 |
_L("CFotaServer::DecrementUserPostponeCount, tries left: %d, err = %d >>"),
|
|
2276 |
count, err);
|
|
2277 |
}
|
|
2278 |
|
|
2279 |
TBool CFotaServer::DecrementDownloadRestartCount()
|
|
2280 |
{
|
|
2281 |
FLOG(_L("CFotaServer::DecrementDownloadRestartCount >>"));
|
|
2282 |
|
|
2283 |
TBool ret (ETrue);
|
|
2284 |
CRepository* centrep = NULL;
|
|
2285 |
TInt count;
|
|
2286 |
|
|
2287 |
TRAPD( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
2288 |
if (err == KErrNone)
|
|
2289 |
{
|
|
2290 |
err = centrep->Get(KFOTADownloadRestartCount, count);
|
|
2291 |
if (--count < 0)
|
|
2292 |
count = 0;
|
|
2293 |
err = centrep->Set(KFOTADownloadRestartCount, count);
|
|
2294 |
}
|
|
2295 |
delete centrep;
|
|
2296 |
centrep = NULL;
|
|
2297 |
|
|
2298 |
if (count == 0)
|
|
2299 |
ret = EFalse;
|
|
2300 |
|
|
2301 |
FLOG(_L("CFotaServer::DecrementDownloadRestartCount, ret = %d, err = %d <<"), ret, err);
|
|
2302 |
return ret;
|
|
2303 |
}
|
|
2304 |
|
|
2305 |
|
|
2306 |
// --------------------------------------------------------------------------
|
|
2307 |
// CFotaServer::StartNetworkMonitorL
|
|
2308 |
// Starts Network Monitoring operation for defined interval and retries (FotaNetworkRegMonitor.h)
|
|
2309 |
// --------------------------------------------------------------------------
|
|
2310 |
void CFotaServer::StartNetworkMonitorL()
|
|
2311 |
{
|
|
2312 |
FLOG(_L("CFotaServer::StartNetworkMonitorL >>"));
|
|
2313 |
if (!iMonitor)
|
|
2314 |
iMonitor = CFotaNetworkRegStatus::NewL(this);
|
|
2315 |
iMonitor->StartMonitoringL();
|
|
2316 |
|
|
2317 |
FLOG(_L("CFotaServer::StartNetworkMonitorL <<"));
|
|
2318 |
}
|
|
2319 |
|
|
2320 |
// --------------------------------------------------------------------------
|
|
2321 |
// CFotaServer::ReportNetworkStatus
|
|
2322 |
// called by CFotaNetworkRegStatus for reporting status
|
|
2323 |
// --------------------------------------------------------------------------
|
|
2324 |
void CFotaServer::ReportNetworkStatus(TBool status)
|
|
2325 |
{
|
|
2326 |
FLOG(_L("CFotaServer::ReportNetworkStatus, status = %d >>"), status);
|
|
2327 |
iRetryingGASend = EFalse;
|
|
2328 |
iNetworkAvailable = status;
|
|
2329 |
|
|
2330 |
if (iNetworkAvailable)
|
|
2331 |
{
|
|
2332 |
TRAPD (err, CreateDeviceManagementSessionL (iPackageState));
|
|
2333 |
if (err != KErrNone)
|
|
2334 |
{
|
|
2335 |
FLOG(_L("Error %d occured while sending GA after retries"), err);
|
|
2336 |
}
|
|
2337 |
}
|
|
2338 |
//No need of iMonitor anymore
|
|
2339 |
if (iMonitor)
|
|
2340 |
{
|
|
2341 |
delete iMonitor;
|
|
2342 |
iMonitor = NULL;
|
|
2343 |
}
|
|
2344 |
|
|
2345 |
FLOG(_L("CFotaServer::ReportNetworkStatus >>"));
|
|
2346 |
}
|
|
2347 |
|
|
2348 |
// --------------------------------------------------------------------------
|
|
2349 |
// CFotaServer::CheckIapExistsL
|
|
2350 |
// Checks for IAP Id exists or not in commsdb
|
|
2351 |
// IAP Id used for resuming the download or for sending Generic alert
|
|
2352 |
// --------------------------------------------------------------------------
|
|
2353 |
//
|
|
2354 |
TBool CFotaServer::CheckIapExistsL(TUint32 aIapId)
|
|
2355 |
{
|
|
2356 |
FLOG(_L("CFotaServer::CheckIapExistsL >>"));
|
54
|
2357 |
TBool exists = EFalse;
|
|
2358 |
RCmManager cmManager;
|
|
2359 |
cmManager.OpenLC();
|
|
2360 |
RCmConnectionMethod conn;
|
|
2361 |
TRAPD(err, conn = cmManager.ConnectionMethodL( aIapId ));
|
|
2362 |
if(err == KErrNone)//connection method exists
|
|
2363 |
exists = ETrue;
|
|
2364 |
conn.Close();
|
|
2365 |
CleanupStack::PopAndDestroy();//cmManager
|
51
|
2366 |
FLOG(_L("CFotaServer::CheckIapExistsL <<"));
|
|
2367 |
return exists;
|
|
2368 |
}
|
|
2369 |
|
|
2370 |
// --------------------------------------------------------------------------
|
|
2371 |
// CFotaServer::IsDeviceDriveBusyL
|
|
2372 |
// Finds if device encryption or decryption is in progress.
|
|
2373 |
// It is harmful to restart device whilst encryption/decryption is in progress
|
|
2374 |
// --------------------------------------------------------------------------
|
|
2375 |
//
|
|
2376 |
TBool CFotaServer::IsDeviceDriveBusyL()
|
|
2377 |
{
|
|
2378 |
FLOG(_L("CFotaServer::IsDeviceDriveBusyL >>"));
|
|
2379 |
|
|
2380 |
TBool ret(EFalse);
|
|
2381 |
FeatureManager::InitializeLibL();
|
|
2382 |
TBool defeature = FeatureManager::FeatureSupported(
|
|
2383 |
KFeatureIdFfDeviceEncryptionFeature);
|
|
2384 |
FeatureManager::UnInitializeLib();
|
|
2385 |
|
|
2386 |
if (defeature)
|
|
2387 |
{
|
|
2388 |
TInt value(EOpIdle); // Encryption idle
|
|
2389 |
RProperty::Get(KDevEncProtectedUid, KDevEncOperationKey, value);
|
|
2390 |
|
|
2391 |
if (value != EOpIdle)
|
|
2392 |
ret = ETrue;
|
|
2393 |
}
|
|
2394 |
|
|
2395 |
FLOG(_L("CFotaServer::IsDeviceDriveBusyL, ret = %d <<"), ret);
|
|
2396 |
return ret;
|
|
2397 |
}
|
|
2398 |
// --------------------------------------------------------------------------
|
|
2399 |
// CFotaDownload::SetIapToUseL
|
|
2400 |
// Sets the IAP ID to use. This menthod is used in fresh and resume download.
|
|
2401 |
// --------------------------------------------------------------------------
|
|
2402 |
//
|
|
2403 |
void CFotaServer::SetIapToUseL()
|
|
2404 |
{
|
|
2405 |
FLOG(_L("CFotaServer::SetIapToUseL >>"));
|
|
2406 |
|
|
2407 |
TInt aIapId(KErrNotFound);
|
|
2408 |
|
|
2409 |
// GET IAP FROM PROFILE ----------------------------------------------
|
|
2410 |
|
|
2411 |
FLOG(_L("[FotaServer] 1"));
|
|
2412 |
RSyncMLSession syncsession;
|
|
2413 |
syncsession.OpenL();
|
|
2414 |
FLOG(_L("[FotaServer] 2"));
|
|
2415 |
RSyncMLDevManProfile smlprof;
|
|
2416 |
RArray<TSmlTransportId> connections;
|
|
2417 |
TSmlTransportId transport;
|
|
2418 |
RSyncMLConnection connection;
|
|
2419 |
|
|
2420 |
CleanupClosePushL(syncsession);
|
|
2421 |
CleanupClosePushL(smlprof);
|
|
2422 |
CleanupClosePushL(connections);
|
|
2423 |
CleanupClosePushL(connection);
|
|
2424 |
|
|
2425 |
FLOG(_L("[FotaServer] 1.1 opening syncml profileid %d "),
|
|
2426 |
iPackageState.iProfileId);
|
|
2427 |
smlprof.OpenL(syncsession, iPackageState.iProfileId, ESmlOpenRead);
|
|
2428 |
FLOG(_L("[FotaServer] 1.1"));
|
|
2429 |
smlprof.ListConnectionsL(connections);
|
|
2430 |
FLOG(_L("[FotaServer] 1.3"));
|
|
2431 |
transport = connections[0];
|
|
2432 |
connection.OpenL(smlprof, transport);
|
|
2433 |
TBuf8<20> iapid2 = connection.GetPropertyL(KNSmlIAPId);
|
|
2434 |
TLex8 iapid3(iapid2);
|
|
2435 |
iapid3.Val(aIapId);
|
|
2436 |
|
|
2437 |
CleanupStack::PopAndDestroy(&connection);
|
|
2438 |
CleanupStack::PopAndDestroy(&connections);
|
|
2439 |
CleanupStack::PopAndDestroy(&smlprof);
|
|
2440 |
CleanupStack::PopAndDestroy(&syncsession);
|
|
2441 |
|
|
2442 |
if (aIapId > KErrNotFound)
|
|
2443 |
{
|
|
2444 |
iPackageState.iIapId = aIapId;
|
|
2445 |
}
|
|
2446 |
else if (iPackageState.iState != RFotaEngineSession::EDownloadProgressing)
|
|
2447 |
{
|
|
2448 |
// GET IAP FROM CURRENT CONNECTION ----------------------------------------------
|
|
2449 |
|
|
2450 |
FLOG(_L("IAP in DM profile is default. Hence reading from the connection manager..."));
|
|
2451 |
TInt sockIapid(-1);
|
|
2452 |
RSocketServ serv;
|
|
2453 |
CleanupClosePushL(serv);
|
|
2454 |
User::LeaveIfError(serv.Connect());
|
|
2455 |
|
|
2456 |
RConnection conn;
|
|
2457 |
CleanupClosePushL(conn);
|
|
2458 |
User::LeaveIfError(conn.Open(serv));
|
|
2459 |
|
|
2460 |
TUint count(0);
|
|
2461 |
User::LeaveIfError(conn.EnumerateConnections(count));
|
|
2462 |
// enumerate connections
|
|
2463 |
for (TUint idx = 1; idx <= count; ++idx)
|
|
2464 |
{
|
|
2465 |
TConnectionInfo connectionInfo;
|
|
2466 |
TConnectionInfoBuf connInfo(connectionInfo);
|
|
2467 |
|
|
2468 |
TInt err = conn.GetConnectionInfo(idx, connInfo); // iapid
|
|
2469 |
if (err != KErrNone)
|
|
2470 |
{
|
|
2471 |
CleanupStack::PopAndDestroy(2); // conn, serv
|
|
2472 |
User::Leave(err);
|
|
2473 |
}
|
|
2474 |
// enumerate connectionclients
|
|
2475 |
TConnectionEnumArg conArg;
|
|
2476 |
conArg.iIndex = idx;
|
|
2477 |
TConnEnumArgBuf conArgBuf(conArg);
|
|
2478 |
err = conn.Control(KCOLConnection, KCoEnumerateConnectionClients,
|
|
2479 |
conArgBuf);
|
|
2480 |
if (err != KErrNone)
|
|
2481 |
{
|
|
2482 |
CleanupStack::PopAndDestroy(2); // conn, serv
|
|
2483 |
User::Leave(err);
|
|
2484 |
}
|
|
2485 |
TInt cliCount = conArgBuf().iCount;
|
|
2486 |
for (TUint j = 1; j <= cliCount; ++j)
|
|
2487 |
{
|
|
2488 |
TConnectionGetClientInfoArg conCliInfo;
|
|
2489 |
conCliInfo.iIndex = j;
|
|
2490 |
TConnGetClientInfoArgBuf conCliInfoBuf(conCliInfo);
|
|
2491 |
err = conn.Control(KCOLConnection,
|
|
2492 |
KCoGetConnectionClientInfo, conCliInfoBuf);
|
|
2493 |
|
|
2494 |
if (err != KErrNone)
|
|
2495 |
{
|
|
2496 |
CleanupStack::PopAndDestroy(2); // conn, serv
|
|
2497 |
User::Leave(err);
|
|
2498 |
}
|
|
2499 |
TConnectionClientInfo conCliInf = conCliInfoBuf().iClientInfo;
|
|
2500 |
TUid uid = conCliInf.iUid;
|
|
2501 |
if (uid == TUid::Uid(KSosServerUid))
|
|
2502 |
{
|
|
2503 |
sockIapid = connInfo().iIapId;
|
|
2504 |
FLOG(_L("[FotaServer] IAP found from ESOCK %d"), sockIapid);
|
|
2505 |
iPackageState.iIapId = sockIapid;
|
|
2506 |
}
|
|
2507 |
|
|
2508 |
FLOG(_L("[FotaServer] CFotaDownload::DownloadL uid %x"),
|
|
2509 |
uid.iUid);
|
|
2510 |
}
|
|
2511 |
}
|
|
2512 |
CleanupStack::PopAndDestroy(2); // conn, serv
|
|
2513 |
}
|
|
2514 |
|
|
2515 |
FLOG(_L("CFotaDownload::SetIapToUseL, iap = %d <<"), iPackageState.iIapId);
|
|
2516 |
}
|
|
2517 |
// --------------------------------------------------------------------------
|
|
2518 |
// CFotaServer::GetSoftwareVersion
|
|
2519 |
// Gets the software version
|
|
2520 |
//
|
|
2521 |
// --------------------------------------------------------------------------
|
|
2522 |
//
|
|
2523 |
TInt CFotaServer::GetSoftwareVersion(TDes& aVersion)
|
|
2524 |
{
|
|
2525 |
FLOG(_L("CFotaServer::GetSoftwareVersion >>"));
|
|
2526 |
aVersion.Zero();
|
|
2527 |
|
|
2528 |
SysVersionInfo::TVersionInfoType what = SysVersionInfo::EFWVersion;
|
|
2529 |
TInt error(KErrNone);
|
|
2530 |
error = SysVersionInfo::GetVersionInfo(what, aVersion);
|
|
2531 |
FLOG(_L("CFotaServer::GetSoftwareVersion,SwV=%S <<"), &aVersion);
|
|
2532 |
return error;
|
|
2533 |
}
|
|
2534 |
|
|
2535 |
// --------------------------------------------------------------------------
|
|
2536 |
// CFotaServer::ResetFotaStateL
|
|
2537 |
// Resets the Fotastate
|
|
2538 |
//
|
|
2539 |
// --------------------------------------------------------------------------
|
|
2540 |
//
|
|
2541 |
void CFotaServer::ResetFotaStateToFailL()
|
|
2542 |
{
|
|
2543 |
FLOG(_L("CFotaServer::ResetFotaStateToFailL >>"));
|
|
2544 |
|
|
2545 |
TPackageState state;
|
|
2546 |
if (!iDatabase->IsOpen())
|
|
2547 |
iDatabase->OpenDBL();
|
|
2548 |
//Fetch the software version that was before download from db.
|
|
2549 |
state = iDatabase->GetStateL(iPackageState.iPkgId, iLastFwUrl);
|
|
2550 |
state.iState = RFotaEngineSession::EUpdateFailed;
|
|
2551 |
state.iResult = RFotaEngineSession::EResPackageMismatch;
|
|
2552 |
iDatabase->SetStateL(state, KNullDesC8, EFDBState | EFDBResult);
|
|
2553 |
iDatabase->CloseAndCommitDB();
|
|
2554 |
|
|
2555 |
DownloaderL()->DeleteUpdatePackageL();
|
|
2556 |
|
|
2557 |
ReportFwUpdateStatusL(state);
|
|
2558 |
|
|
2559 |
FLOG(_L("CFotaServer::ResetFotaStateToFailL <<"));
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
void CFotaServer::CreateDiskReservation()
|
|
2563 |
{
|
|
2564 |
FLOG(_L("CFotaServer::CreateDiskReservation >>"));
|
|
2565 |
|
|
2566 |
TRAP_IGNORE(DownloaderL()->CreateDiskReservation());
|
|
2567 |
|
|
2568 |
FLOG(_L("CFotaServer::CreateDiskReservation <<"));
|
|
2569 |
}
|
|
2570 |
|
|
2571 |
void CFotaServer::DeleteDiskReservation(TDesC& path)
|
|
2572 |
{
|
|
2573 |
FLOG(_L("CFotaServer::DeleteDiskReservation >>"));
|
|
2574 |
|
|
2575 |
QString temp = QString::fromUtf8(reinterpret_cast<const char*> (path.Ptr()), path.Length());
|
|
2576 |
|
|
2577 |
TRAP_IGNORE(DownloaderL()->DeleteDiskReservation(temp));
|
|
2578 |
|
|
2579 |
FLOG(_L("CFotaServer::DeleteDiskReservation <<"));
|
|
2580 |
}
|
|
2581 |
|
|
2582 |
inline DownloadManagerClient* CFotaServer::DownloaderL()
|
|
2583 |
{
|
|
2584 |
if (!iDownloader)
|
|
2585 |
{
|
|
2586 |
FLOG(_L("Creating new download client..."));
|
|
2587 |
iDownloader = DownloadManagerClient::NewL(this);
|
|
2588 |
}
|
|
2589 |
|
|
2590 |
return iDownloader;
|
|
2591 |
}
|
|
2592 |
|
|
2593 |
void CFotaServer::DropSession()
|
|
2594 |
{
|
|
2595 |
FLOG(_L("CFotaServer::DropSession >>"));
|
|
2596 |
|
|
2597 |
iSessionCount--;
|
|
2598 |
|
|
2599 |
FLOG(_L("Number of active sessions = %d"), iSessionCount);
|
|
2600 |
|
|
2601 |
if (iSessionCount == 0 && !iAsyncOperation)
|
|
2602 |
{
|
|
2603 |
StopServerWhenPossible();
|
|
2604 |
ServerCanShut(ETrue);
|
|
2605 |
}
|
|
2606 |
|
|
2607 |
FLOG(_L("CFotaServer::DropSession <<"));
|
|
2608 |
}
|
|
2609 |
|
|
2610 |
static TInt StaticApplicationShutter(TAny *aPtr)
|
|
2611 |
{
|
|
2612 |
__ASSERT_ALWAYS( aPtr, User::Panic(KFotaPanic, KErrArgument) );
|
|
2613 |
CFotaServer* srv = (CFotaServer*) aPtr;
|
|
2614 |
srv->StopServerWhenPossible();
|
|
2615 |
return KErrNone;
|
|
2616 |
}
|
|
2617 |
|
|
2618 |
void CFotaServer::WakeupServer()
|
|
2619 |
{
|
|
2620 |
FLOG(_L("CFotaServer::WakeupServer >>"));
|
|
2621 |
ServerCanShut(EFalse);
|
|
2622 |
if (iAppShutter)
|
|
2623 |
{
|
|
2624 |
iAppShutter->Cancel();
|
|
2625 |
delete iAppShutter;
|
|
2626 |
iAppShutter = NULL;
|
|
2627 |
}
|
|
2628 |
|
|
2629 |
FLOG(_L("CFotaServer::WakeupServer >>"));
|
|
2630 |
}
|
|
2631 |
|
|
2632 |
void CFotaServer::StopServerWhenPossible()
|
|
2633 |
{
|
|
2634 |
FLOG(_L("CFotaServer::StopServerWhenPossible, sessioncount = %d, servercanshut = %d >>"), iSessionCount, iServerCanShut);
|
|
2635 |
//Check if it's the right time to do so..
|
|
2636 |
|
|
2637 |
if (iSessionCount == 0 && iServerCanShut)
|
|
2638 |
{
|
|
2639 |
FLOG(_L("Shutting down the Fota server..."));
|
|
2640 |
//Do some cleanup
|
|
2641 |
|
|
2642 |
if (iAppShutter)
|
|
2643 |
{
|
|
2644 |
iAppShutter->Cancel();
|
|
2645 |
delete iAppShutter;
|
|
2646 |
iAppShutter = NULL;
|
|
2647 |
}
|
|
2648 |
|
|
2649 |
//Exit. This will stop the active scheduler too.
|
|
2650 |
QApplication::exit();
|
|
2651 |
}
|
|
2652 |
else if (iSessionCount == 0)
|
|
2653 |
{
|
|
2654 |
FLOG(_L("Diferring shutdown now. Started shutdown timer..."));
|
|
2655 |
|
|
2656 |
if (!iAppShutter)
|
|
2657 |
{
|
|
2658 |
TRAP_IGNORE(
|
|
2659 |
iAppShutter = CPeriodic::NewL (EPriorityNormal);
|
|
2660 |
iAppShutter->Start(KFotaTimeShutDown, KFotaTimeShutDown,
|
|
2661 |
TCallBack(StaticApplicationShutter, this));
|
|
2662 |
);
|
|
2663 |
}
|
|
2664 |
|
|
2665 |
}
|
|
2666 |
else
|
|
2667 |
{
|
|
2668 |
//one or more client is still open
|
|
2669 |
FLOG(_L("Diferring shutdown now."));
|
|
2670 |
WakeupServer();
|
|
2671 |
}
|
|
2672 |
FLOG(_L("CFotaServer::StopServerWhenPossible <<"));
|
|
2673 |
}
|
|
2674 |
|
|
2675 |
void CFotaServer::ServerCanShut(TBool aParam)
|
|
2676 |
{
|
|
2677 |
FLOG(_L("CFotaServer::ServerCanShut, param = %d >>"), aParam);
|
|
2678 |
|
|
2679 |
iServerCanShut = aParam;
|
|
2680 |
|
|
2681 |
FLOG(_L("CFotaServer::ServerCanShut <<"));
|
|
2682 |
|
|
2683 |
}
|
|
2684 |
|
|
2685 |
void CFotaServer::ConstructApplicationUI(TBool aVal)
|
|
2686 |
{
|
|
2687 |
FLOG(_L("CFotaServer::ConstructApplicationUI, value = %d >>"), aVal);
|
|
2688 |
|
|
2689 |
if (!aVal)
|
|
2690 |
iMainwindow.lower();
|
|
2691 |
else
|
|
2692 |
iMainwindow.raise();
|
|
2693 |
|
|
2694 |
FLOG(_L("CFotaServer::ConstructApplicationUI <<"));
|
|
2695 |
}
|
|
2696 |
|
|
2697 |
|
|
2698 |
void CFotaServer::SetVisible(TBool aVisible)
|
|
2699 |
{
|
|
2700 |
FLOG(_L("CFotaServer::SetVisible >>"));
|
|
2701 |
|
|
2702 |
if(iFullScreenDialog)
|
|
2703 |
iFullScreenDialog->SetVisible(aVisible);
|
|
2704 |
|
|
2705 |
FLOG(_L("CFotaServer::SetVisible <<"));
|
|
2706 |
}
|
|
2707 |
|
|
2708 |
//End of file
|