25
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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: Engine implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// System Include Files
|
|
20 |
#include <e32std.h> // User
|
|
21 |
#include <f32file.h> // RFs
|
|
22 |
#include <DiagEngine.h> // CDiagEngine
|
|
23 |
#include <DiagPlugin.h> // MDiagPlugin
|
|
24 |
#include <DiagSuitePlugin.h> // MDiagSuitePlugin
|
|
25 |
#include <DiagResultsDatabaseItem.h> // CDiagResultsDatabaseItem
|
|
26 |
#include <DiagPluginPool.h> // CDiagPluginPool
|
|
27 |
#include <DiagResultsDatabaseTestRecordInfo.h>
|
|
28 |
// TDiagResultsDatabaseTestRecordInfo
|
|
29 |
#include <drmserviceapi.h> // CDrmServiceApi
|
|
30 |
#include <e32property.h> // RProperty
|
|
31 |
#include <PSVariables.h> // Property values
|
|
32 |
#include <startupdomainpskeys.h> // Property values
|
|
33 |
#include <centralrepository.h> // CRepository
|
|
34 |
#include <ProfileEngineSDKCRKeys.h> // CR Keys for Profile
|
|
35 |
#include <DiagFrameworkDebug.h> // Debug Logger
|
|
36 |
#include <DiagResultsDbRecordEngineParam.h>
|
|
37 |
|
|
38 |
// User Include Files
|
|
39 |
#include "devdiagapp.hrh" // UID definition
|
|
40 |
#include "devdiagengine.h" // CDevDiagEngine
|
|
41 |
#include "devdiagengineobserver.h" // CDevDiagEngineObserver
|
|
42 |
#include "devdiagexecutionresults.h" // CDevDiagExecResults
|
|
43 |
#include "devdiag.pan" // Panic
|
|
44 |
#include "devdiagcommoncanceldialogs.h" // CDevDiagCancelExecutionDialog
|
|
45 |
#include "devdiagcommonskipdialogs.h"
|
|
46 |
// Local Constants
|
|
47 |
const TInt KErrDevDiagAlreadyInitialized = ( -1 );
|
|
48 |
const TInt KErrDevDiagAlreadyLoaded = ( -2 );
|
|
49 |
const TInt KErrDevDiagUninitialized = ( -3 );
|
|
50 |
|
|
51 |
///@@@KSR: changes for BAD Warnings - #177-D: variable "KErrDevDiagExecuting" was declared but never referenced
|
|
52 |
//const TInt KErrDevDiagExecuting = ( -4 );
|
|
53 |
|
|
54 |
const TInt KErrDevDiagAlreadyRunning = ( -5 );
|
|
55 |
const TInt KErrDevDiagNotRunning = ( -6 );
|
|
56 |
const TInt KErrDevDiagSuspendResume = ( -7 );
|
|
57 |
const TUid KUidDevDiagApplication = { _UID3 };
|
|
58 |
///@@@KSR: changes for BAD Warnings - #177-D: variable "KProgressGranularity" was declared but never referenced
|
|
59 |
//const TInt KProgressGranularity = ( 2 );
|
|
60 |
|
|
61 |
// Local Data Types
|
|
62 |
typedef CArrayFixFlat< TDiagResultsDatabaseTestRecordInfo > CDatabaseRecordInfoArray;
|
|
63 |
|
|
64 |
const TInt KArrayGranuality(50);
|
|
65 |
|
|
66 |
|
|
67 |
// ============================ MEMBER FUNCTIONS =============================
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
// Static two-phase constructor.
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CDevDiagEngine* CDevDiagEngine::NewL()
|
|
74 |
{
|
|
75 |
LOGSTRING( "CDevDiagEngine::NewL()" )
|
|
76 |
|
|
77 |
CDevDiagEngine* self = CDevDiagEngine::NewLC();
|
|
78 |
CleanupStack::Pop( self );
|
|
79 |
return self;
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// Static two-phase constructor.
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CDevDiagEngine* CDevDiagEngine::NewLC()
|
|
87 |
{
|
|
88 |
LOGSTRING( "CDevDiagEngine::NewLC()" )
|
|
89 |
|
|
90 |
CDevDiagEngine* self = new ( ELeave ) CDevDiagEngine();
|
|
91 |
CleanupStack::PushL( self );
|
|
92 |
self->ConstructL();
|
|
93 |
return self;
|
|
94 |
}
|
|
95 |
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
// Destructor.
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
CDevDiagEngine::~CDevDiagEngine()
|
|
101 |
{
|
|
102 |
LOGSTRING( "CDevDiagEngine::~CDevDiagEngine()" )
|
|
103 |
|
|
104 |
// Cancel any outstanding asynchronous requests.
|
|
105 |
Cancel();
|
|
106 |
|
|
107 |
// Delete the member variables.
|
|
108 |
delete iResults;
|
|
109 |
delete iDiagEngine;
|
|
110 |
delete iPluginPool;
|
|
111 |
|
|
112 |
if ( iUids )
|
|
113 |
{
|
|
114 |
delete iUids;
|
|
115 |
iUids = NULL;
|
|
116 |
}
|
|
117 |
|
|
118 |
iLastResults.ResetAndDestroy();
|
|
119 |
iLastResults.Close();
|
|
120 |
|
|
121 |
// Close the session with the results database.
|
|
122 |
iResultsDatabase.Close();
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
// This function allows the UI to receive application engine callbacks by
|
|
128 |
// implementing the MDevDiagEngineObserver interface.
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void CDevDiagEngine::SetObserver( MDevDiagEngineObserver* aObserver )
|
|
132 |
{
|
|
133 |
LOGSTRING2( "CDevDiagEngine::SetObserver( 0x%x )", aObserver )
|
|
134 |
|
|
135 |
if ( iObserver && aObserver )
|
|
136 |
{
|
|
137 |
// We have cannot leave here.
|
|
138 |
TRAP_IGNORE( iObserver->HandleEngineCommandL(
|
|
139 |
MDevDiagEngineObserver::EDevDiagEngineCommandObserverChanged,
|
|
140 |
KErrNone,
|
|
141 |
NULL ) )
|
|
142 |
}
|
|
143 |
|
|
144 |
iObserver = aObserver;
|
|
145 |
}
|
|
146 |
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
// This function begins test execution. It is the responsibility of the
|
|
149 |
// caller to check the runtime requirements prior to calling this function.
|
|
150 |
// This is an asynchronous request.
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
void CDevDiagEngine::ExecuteTestL( TUid aUid, CAknViewAppUi& aAppUi )
|
|
154 |
{
|
|
155 |
LOGSTRING2( "CDevDiagEngine::ExecuteTestL( 0x%x )", aUid.iUid )
|
|
156 |
|
|
157 |
// Reset the member variables to prepare for a new execution run.
|
|
158 |
delete iDiagEngine;
|
|
159 |
iDiagEngine = NULL;
|
|
160 |
delete iResults;
|
|
161 |
iResults = NULL;
|
|
162 |
iSuspendCounter = 0;
|
|
163 |
|
|
164 |
RArray< TUid > uidArray;
|
|
165 |
uidArray.Append( aUid );
|
|
166 |
CleanupClosePushL( uidArray );
|
|
167 |
|
|
168 |
// Create an engine instance and execute the test or suite.
|
|
169 |
iDiagEngine = CDiagEngine::NewL( aAppUi,
|
|
170 |
*this,
|
|
171 |
iResultsDatabase,
|
|
172 |
*iPluginPool,
|
|
173 |
EFalse,
|
|
174 |
uidArray );
|
|
175 |
CleanupStack::PopAndDestroy(); // uidArray
|
|
176 |
iDiagEngine->ExecuteL();
|
|
177 |
|
|
178 |
// Do the state transition now that we are successfully starting.
|
|
179 |
SetState( EStateStartingExecution );
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// This function will provides the execution results, which may be from an
|
|
184 |
// execution run which is ongoing, or from logged test results.
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
const CDevDiagExecResults& CDevDiagEngine::ExecutionResults() const
|
|
188 |
{
|
|
189 |
LOGSTRING( "CDevDiagEngine::ExecutionResults()" )
|
|
190 |
|
|
191 |
__ASSERT_ALWAYS( HasExecutionResults(),
|
|
192 |
Panic( EDevDiagApplicationNotInitialized ) );
|
|
193 |
return *iResults;
|
|
194 |
}
|
|
195 |
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
// This function will handle getting the results information for the most
|
|
198 |
// recent test execution.
|
|
199 |
// ---------------------------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CDevDiagEngine::LoadLastLoggedResultsL()
|
|
202 |
{
|
|
203 |
LOGSTRING( "CDevDiagEngine::LoadLastLoggedResultsL()" )
|
|
204 |
|
|
205 |
// Check the state.
|
|
206 |
__ASSERT_ALWAYS( iState == EStateReady,
|
|
207 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
208 |
|
|
209 |
// If there are any existing results, just use them.
|
|
210 |
if ( iResults )
|
|
211 |
{
|
|
212 |
return;
|
|
213 |
}
|
|
214 |
|
|
215 |
// Get info about the last test record. If there are no existing records,
|
|
216 |
// just return -- the caller must check if there are results before they
|
|
217 |
// do anything.
|
|
218 |
TUid lastExecutionRecord;
|
|
219 |
if ( iResultsDatabase.GetLastRecord( lastExecutionRecord ) != KErrNone )
|
|
220 |
{
|
|
221 |
return;
|
|
222 |
}
|
|
223 |
|
|
224 |
// Now, load the logged results.
|
|
225 |
iResults = CDevDiagExecResults::NewL( lastExecutionRecord,
|
|
226 |
*iPluginPool,
|
|
227 |
iResultsDatabase );
|
|
228 |
}
|
|
229 |
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
// This function will stop test execution. The argument specifies whether all
|
|
232 |
// execution should be stopped, or just the currently running test.
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
void CDevDiagEngine::ExecutionStopL( TDevDiagAppEngineStopMode aReason )
|
|
236 |
{
|
|
237 |
LOGSTRING2( "CDevDiagEngine::ExecutionStopL( %d )", aReason )
|
|
238 |
|
|
239 |
// Check the state.
|
|
240 |
__ASSERT_ALWAYS( IsRunningPlugins(),
|
|
241 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
242 |
|
|
243 |
// Stop the execution.
|
|
244 |
switch ( aReason )
|
|
245 |
{
|
|
246 |
case EStopModeSkip:
|
|
247 |
iDiagEngine->ExecutionStopL( MDiagEngineCommon::ESkip );
|
|
248 |
break;
|
|
249 |
|
|
250 |
case EStopModeCancel:
|
|
251 |
SetState( EStateStoppingExecution );
|
|
252 |
|
|
253 |
|
|
254 |
// Start an idle active object, which will handle deleting the
|
|
255 |
// diagnostics engine. This cannot be done here because the
|
|
256 |
// engine may be executing a test which is displaying the "Cancel
|
|
257 |
// Execution" dialog, which calls this function. The priority of
|
|
258 |
// this CIdle MUST be higher than then diagnostics engine and ALL
|
|
259 |
// of its active objects.
|
|
260 |
delete iIdle;
|
|
261 |
iIdle = NULL;
|
|
262 |
iIdle = CIdle::NewL( CActive::EPriorityHigh );
|
|
263 |
iIdle->Start( TCallBack( HandleExecutionCancelledL, this ) );
|
|
264 |
|
|
265 |
// Inform the observer. In the case where the observer is
|
|
266 |
// displaying a dialog, this will allow the observer to cancel it.
|
|
267 |
if ( iObserver )
|
|
268 |
{
|
|
269 |
iObserver->HandleEngineCommandL(
|
|
270 |
MDevDiagEngineObserver::EDevDiagEngineCommandExecutionStopping,
|
|
271 |
KErrCancel,
|
|
272 |
NULL );
|
|
273 |
}
|
|
274 |
|
|
275 |
break;
|
|
276 |
|
|
277 |
case EStopModeSuspend:
|
|
278 |
// Increment the suspend counter and check the state.
|
|
279 |
LOGSTRING2( "CDevDiagEngine::ExecutionStopL, counter: %d",
|
|
280 |
iSuspendCounter )
|
|
281 |
iSuspendCounter++;
|
|
282 |
if ( iState == EStateExecutionSuspended )
|
|
283 |
{
|
|
284 |
// Do nothing - we're already suspended.
|
|
285 |
__ASSERT_DEBUG( iSuspendCounter > 1,
|
|
286 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
287 |
break;
|
|
288 |
}
|
|
289 |
|
|
290 |
SetState( EStateExecutionSuspended );
|
|
291 |
iDiagEngine->SuspendL();
|
|
292 |
break;
|
|
293 |
|
|
294 |
case EStopModeWatchdog:
|
|
295 |
iDiagEngine->StopWatchdogTemporarily();
|
|
296 |
break;
|
|
297 |
|
|
298 |
default:
|
|
299 |
__ASSERT_DEBUG( EFalse, Panic( EDevDiagApplicationInvalidStopMode ) );
|
|
300 |
break;
|
|
301 |
}
|
|
302 |
}
|
|
303 |
|
|
304 |
|
|
305 |
TInt CDevDiagEngine::HandleExecutionCancelledL( TAny* aPtr )
|
|
306 |
{
|
|
307 |
LOGSTRING2( "CDevDiagEngine::HandleExecutionCancelledL( 0x%x )", aPtr )
|
|
308 |
|
|
309 |
CDevDiagEngine* myThis = static_cast< CDevDiagEngine* >( aPtr );
|
|
310 |
myThis->iResults->Finalize( EFalse );
|
|
311 |
|
|
312 |
delete myThis->iDiagEngine;
|
|
313 |
myThis->iDiagEngine = NULL;
|
|
314 |
|
|
315 |
delete myThis->iIdle;
|
|
316 |
myThis->iIdle = NULL;
|
|
317 |
|
|
318 |
myThis->SetState( EStateReady );
|
|
319 |
|
|
320 |
// Inform the observer object.
|
|
321 |
if ( myThis->iObserver )
|
|
322 |
{
|
|
323 |
|
|
324 |
myThis->iObserver->HandleEngineCommandL(
|
|
325 |
MDevDiagEngineObserver::EDevDiagEngineCommandTestExecutionCancelled,
|
|
326 |
KErrCancel,
|
|
327 |
NULL );
|
|
328 |
|
|
329 |
}
|
|
330 |
|
|
331 |
return KErrNone;
|
|
332 |
|
|
333 |
}
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// This function will resume suspended test execution.
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
void CDevDiagEngine::ExecutionResumeL( TDevDiagAppEngineResumeMode aReason )
|
|
339 |
{
|
|
340 |
LOGSTRING2( "CDevDiagEngine::ExecutionResumeL( %d )", aReason )
|
|
341 |
|
|
342 |
// Check the state.
|
|
343 |
__ASSERT_ALWAYS( IsRunningPlugins(),
|
|
344 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
345 |
|
|
346 |
// Resume the execution.
|
|
347 |
switch ( aReason )
|
|
348 |
{
|
|
349 |
case EResumeModeResume:
|
|
350 |
{
|
|
351 |
LOGSTRING2( "CDevDiagEngine::ExecutionResumeL, counter: %d",
|
|
352 |
iSuspendCounter )
|
|
353 |
// Decrement the suspend counter and check the state.
|
|
354 |
--iSuspendCounter;
|
|
355 |
__ASSERT_DEBUG( iSuspendCounter >= 0,
|
|
356 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
357 |
__ASSERT_ALWAYS( iState == EStateExecutionSuspended,
|
|
358 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
359 |
|
|
360 |
// Resume the execution, but only if there have been enough
|
|
361 |
// "resume" calls to match the number of "suspend" calls.
|
|
362 |
if ( iSuspendCounter == 0 )
|
|
363 |
{
|
|
364 |
SetState( EStateRunningTests );
|
|
365 |
iDiagEngine->ResumeL();
|
|
366 |
}
|
|
367 |
|
|
368 |
break;
|
|
369 |
}
|
|
370 |
|
|
371 |
case EResumeModeWatchdog:
|
|
372 |
// iDiagEngine->ResetWatchdogL();
|
|
373 |
break;
|
|
374 |
|
|
375 |
default:
|
|
376 |
__ASSERT_DEBUG( EFalse,
|
|
377 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
378 |
break;
|
|
379 |
}
|
|
380 |
}
|
|
381 |
|
|
382 |
// ---------------------------------------------------------------------------
|
|
383 |
// Returns the plugin pool.
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
const CDiagPluginPool& CDevDiagEngine::PluginPool() const
|
|
387 |
{
|
|
388 |
LOGSTRING( "CDevDiagEngine::PluginPool()" )
|
|
389 |
|
|
390 |
__ASSERT_ALWAYS( ArePluginsLoaded(),
|
|
391 |
Panic( EDevDiagApplicationNotInitialized ) );
|
|
392 |
return *iPluginPool;
|
|
393 |
}
|
|
394 |
|
|
395 |
// ---------------------------------------------------------------------------
|
|
396 |
// Returns whether or not tests are running.
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
//
|
|
399 |
TBool CDevDiagEngine::IsRunningPlugins() const
|
|
400 |
{
|
|
401 |
LOGSTRING( "CDevDiagEngine::IsRunningPlugins()" )
|
|
402 |
|
|
403 |
return ( iState == EStateStartingExecution ||
|
|
404 |
iState == EStateRunningTests ||
|
|
405 |
iState == EStateStoppingExecution ||
|
|
406 |
iState == EStateExecutionSuspended );
|
|
407 |
}
|
|
408 |
|
|
409 |
// ---------------------------------------------------------------------------
|
|
410 |
// Checks if the engine is currently stopping execution.
|
|
411 |
// ---------------------------------------------------------------------------
|
|
412 |
//
|
|
413 |
TBool CDevDiagEngine::IsStoppingExecution() const
|
|
414 |
{
|
|
415 |
LOGSTRING( "CDevDiagEngine::IsStoppingExecution()" )
|
|
416 |
|
|
417 |
return ( iState == EStateStoppingExecution );
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------------------------
|
|
421 |
// Returns whether or not plugins are done loading.
|
|
422 |
// ---------------------------------------------------------------------------
|
|
423 |
//
|
|
424 |
TBool CDevDiagEngine::ArePluginsLoaded() const
|
|
425 |
{
|
|
426 |
LOGSTRING( "CDevDiagEngine::ArePluginsLoaded()" )
|
|
427 |
|
|
428 |
return ( iState != EStateInitial &&
|
|
429 |
iState != EStateLoadingPlugins );
|
|
430 |
}
|
|
431 |
|
|
432 |
// ---------------------------------------------------------------------------
|
|
433 |
// Returns whether execution results are available.
|
|
434 |
// ---------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
TBool CDevDiagEngine::HasExecutionResults() const
|
|
437 |
{
|
|
438 |
LOGSTRING( "CDevDiagEngine::HasExecutionResults()" )
|
|
439 |
|
|
440 |
if ( iResults )
|
|
441 |
{
|
|
442 |
return ETrue;
|
|
443 |
}
|
|
444 |
|
|
445 |
return EFalse;
|
|
446 |
}
|
|
447 |
|
|
448 |
// ---------------------------------------------------------------------------
|
|
449 |
// The default constructor.
|
|
450 |
// ---------------------------------------------------------------------------
|
|
451 |
//
|
|
452 |
CDevDiagEngine::CDevDiagEngine() : CActive( EPriorityStandard ),
|
|
453 |
iDiagEngine( NULL )
|
|
454 |
{
|
|
455 |
LOGSTRING( "CDevDiagEngine::CDevDiagEngine()" )
|
|
456 |
|
|
457 |
}
|
|
458 |
|
|
459 |
// ---------------------------------------------------------------------------
|
|
460 |
// The second phase constructor.
|
|
461 |
// ---------------------------------------------------------------------------
|
|
462 |
//
|
|
463 |
void CDevDiagEngine::ConstructL()
|
|
464 |
{
|
|
465 |
LOGSTRING( "CDevDiagEngine::ConstructL()" )
|
|
466 |
|
|
467 |
// Connect to the results database.
|
|
468 |
User::LeaveIfError( iResultsDatabase.Connect( KUidDevDiagApplication ) );
|
|
469 |
LOGSTRING( "CDevDiagEngine::ResultDB connect");
|
|
470 |
// Load the plugins.
|
|
471 |
iPluginPool = CDiagPluginPool::NewL( *this );
|
|
472 |
LOGSTRING( "CDevDiagEngine::NewL");
|
|
473 |
SetState( EStateLoadingPlugins );
|
|
474 |
iPluginPool->LoadAsyncL( KDiagPluginInterfaceUid );
|
|
475 |
LOGSTRING( "CDevDiagEngine::LoadPlugin");
|
|
476 |
// Add the application engine to the active scheduler.
|
|
477 |
CActiveScheduler::Add( this );
|
|
478 |
}
|
|
479 |
|
|
480 |
|
|
481 |
// ---------------------------------------------------------------------------
|
|
482 |
// To obtain the current engine state
|
|
483 |
// ---------------------------------------------------------------------------
|
|
484 |
TInt CDevDiagEngine::GetState()
|
|
485 |
{
|
|
486 |
return iState;
|
|
487 |
}
|
|
488 |
|
|
489 |
|
|
490 |
// ---------------------------------------------------------------------------
|
|
491 |
// The state machine transition handler. If there is an error in changing
|
|
492 |
// states, then it will be returned and the state will be left unchanged.
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
//
|
|
495 |
void CDevDiagEngine::SetState( TDevDiagAppEngineState aNextState )
|
|
496 |
{
|
|
497 |
LOGSTRING3( "CDevDiagEngine::SetState( %d ), iState = %d",
|
|
498 |
aNextState,
|
|
499 |
iState )
|
|
500 |
|
|
501 |
// The state transition table. Structure: State in / State to go to.
|
|
502 |
static const TInt KStateTable[ EStateMax ][ EStateMax ] =
|
|
503 |
{
|
|
504 |
// EStateInitial
|
|
505 |
{
|
|
506 |
KErrNone, // To EStateInitial
|
|
507 |
KErrNone, // To EStateLoadingPlugins
|
|
508 |
KErrDevDiagUninitialized, // To EStateReady
|
|
509 |
KErrDevDiagUninitialized, // To EStateStartingExecution
|
|
510 |
KErrDevDiagUninitialized, // To EStateRunningTests
|
|
511 |
KErrDevDiagUninitialized, // To EStateStoppingExecution
|
|
512 |
KErrDevDiagUninitialized // To EStateExecutionSuspended
|
|
513 |
},
|
|
514 |
|
|
515 |
// EStateLoadingPlugins
|
|
516 |
{
|
|
517 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
518 |
KErrNone, // To EStateLoadingPlugins
|
|
519 |
KErrNone, // To EStateReady
|
|
520 |
KErrDevDiagUninitialized, // To EStateStartingExecution
|
|
521 |
KErrDevDiagUninitialized, // To EStateRunningTests
|
|
522 |
KErrDevDiagUninitialized, // To EStateStoppingExecution
|
|
523 |
KErrDevDiagUninitialized // To EStateExecutionSuspended
|
|
524 |
},
|
|
525 |
|
|
526 |
// EStateReady
|
|
527 |
{
|
|
528 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
529 |
KErrDevDiagAlreadyLoaded, // To EStateLoadingPlugins
|
|
530 |
KErrNone, // To EStateReady
|
|
531 |
KErrNone, // To EStateStartingExecution
|
|
532 |
KErrDevDiagNotRunning, // To EStateRunningTests
|
|
533 |
KErrDevDiagNotRunning, // To EStateStoppingExecution
|
|
534 |
KErrDevDiagNotRunning // To EStateExecutionSuspended
|
|
535 |
},
|
|
536 |
|
|
537 |
// EStateStartingExecution
|
|
538 |
{
|
|
539 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
540 |
KErrDevDiagAlreadyLoaded, // To EStateLoadingPlugins
|
|
541 |
KErrNone, // To EStateReady
|
|
542 |
KErrNone, // To EStateStartingExecution
|
|
543 |
KErrNone, // To EStateRunningTests
|
|
544 |
KErrNone, // To EStateStoppingExecution
|
|
545 |
KErrDevDiagNotRunning // To EStateExecutionSuspended
|
|
546 |
},
|
|
547 |
|
|
548 |
// EStateRunningTests
|
|
549 |
{
|
|
550 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
551 |
KErrDevDiagAlreadyLoaded, // To EStateLoadingPlugins
|
|
552 |
KErrNone, // To EStateReady
|
|
553 |
KErrDevDiagAlreadyRunning, // To EStateStartingExecution
|
|
554 |
KErrNone, // To EStateRunningTests
|
|
555 |
KErrNone, // To EStateStoppingExecution
|
|
556 |
KErrNone // To EStateExecutionSuspended
|
|
557 |
},
|
|
558 |
|
|
559 |
// EStateStoppingExecution
|
|
560 |
{
|
|
561 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
562 |
KErrDevDiagAlreadyLoaded, // To EStateLoadingPlugins
|
|
563 |
KErrNone, // To EStateReady
|
|
564 |
KErrDevDiagAlreadyRunning, // To EStateStartingExecution
|
|
565 |
KErrDevDiagAlreadyRunning, // To EStateRunningTests
|
|
566 |
KErrNone, // To EStateStoppingExecution
|
|
567 |
KErrDevDiagNotRunning // To EStateExecutionSuspended
|
|
568 |
},
|
|
569 |
|
|
570 |
// EStateExecutionSuspended
|
|
571 |
{
|
|
572 |
KErrDevDiagAlreadyInitialized, // To EStateInitial
|
|
573 |
KErrDevDiagAlreadyLoaded, // To EStateLoadingPlugins
|
|
574 |
KErrDevDiagSuspendResume, // To EStateReady
|
|
575 |
KErrDevDiagAlreadyRunning, // To EStateStartingExecution
|
|
576 |
KErrNone, // To EStateRunningTests
|
|
577 |
KErrNone, // To EStateStoppingExecution
|
|
578 |
KErrNone // To EStateExecutionSuspended
|
|
579 |
}
|
|
580 |
};
|
|
581 |
|
|
582 |
// Check if there is an invalid state.
|
|
583 |
__ASSERT_DEBUG( ( iState < EStateMax && aNextState < EStateMax ),
|
|
584 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
585 |
|
|
586 |
// Change the state if there was no error, and return.
|
|
587 |
__ASSERT_ALWAYS( KStateTable[ iState ][ aNextState ] == KErrNone,
|
|
588 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
589 |
iState = aNextState;
|
|
590 |
|
|
591 |
}
|
|
592 |
|
|
593 |
// ---------------------------------------------------------------------------
|
|
594 |
// From class CActive.
|
|
595 |
// The active object completion function. This is only used for checking the
|
|
596 |
// runtime requirements.
|
|
597 |
// ---------------------------------------------------------------------------
|
|
598 |
//
|
|
599 |
void CDevDiagEngine::RunL()
|
|
600 |
{
|
|
601 |
LOGSTRING( "CDevDiagEngine::RunL()" )
|
|
602 |
|
|
603 |
if ( iStatus.Int() == KErrNone )
|
|
604 |
{
|
|
605 |
TInt error = iResultsDatabase.GetLastResults( iLastResults );
|
|
606 |
|
|
607 |
if ( error != KErrNone )
|
|
608 |
{
|
|
609 |
LOGSTRING2( "CDevDiagEngine::RunL GetLastResults error: %d", error );
|
|
610 |
|
|
611 |
}
|
|
612 |
|
|
613 |
if ( iObserver )
|
|
614 |
{
|
|
615 |
iObserver->HandleEngineCommandL(
|
|
616 |
MDevDiagEngineObserver::EDevDiagEngineCommandGetLastResults,
|
|
617 |
error,
|
|
618 |
&iLastResults );
|
|
619 |
}
|
|
620 |
}
|
|
621 |
else
|
|
622 |
{
|
|
623 |
LOGSTRING2( "CDevDiagEngine::RunL error: %d", iStatus.Int() );
|
|
624 |
}
|
|
625 |
|
|
626 |
}
|
|
627 |
|
|
628 |
// ---------------------------------------------------------------------------
|
|
629 |
// CDevDiagEngine::RunError
|
|
630 |
// ---------------------------------------------------------------------------
|
|
631 |
//
|
|
632 |
TInt CDevDiagEngine::RunError( TInt aError )
|
|
633 |
{
|
|
634 |
LOGSTRING2( "CDevDiagEngine::RunError error: %d", aError );
|
|
635 |
return KErrNone;
|
|
636 |
}
|
|
637 |
|
|
638 |
// ---------------------------------------------------------------------------
|
|
639 |
// From class CActive.
|
|
640 |
// The active object cancellation function.
|
|
641 |
// ---------------------------------------------------------------------------
|
|
642 |
//
|
|
643 |
void CDevDiagEngine::DoCancel()
|
|
644 |
{
|
|
645 |
LOGSTRING( "CDevDiagEngine::DoCancel()" )
|
|
646 |
|
|
647 |
// Stop plugin loading, if it is ongoing.
|
|
648 |
if ( iState == EStateLoadingPlugins )
|
|
649 |
{
|
|
650 |
// Cannot leave here.
|
|
651 |
TRAP_IGNORE( iPluginPool->CancelLoadPluginsL() )
|
|
652 |
}
|
|
653 |
}
|
|
654 |
|
|
655 |
// ---------------------------------------------------------------------------
|
|
656 |
// From class MDiagEngineObserver.
|
|
657 |
// The callback to indicate that test execution is starting.
|
|
658 |
// ---------------------------------------------------------------------------
|
|
659 |
//
|
|
660 |
void CDevDiagEngine::TestExecutionBeginL()
|
|
661 |
{
|
|
662 |
LOGSTRING( "CDevDiagEngine::TestExecutionBeginL()" )
|
|
663 |
|
|
664 |
SetState( EStateRunningTests );
|
|
665 |
|
|
666 |
// Get the record info, so we can get the record uid.
|
|
667 |
TDiagResultsDatabaseTestRecordInfo recordInfo;
|
|
668 |
User::LeaveIfError( iDiagEngine->DbRecord().GetRecordInfo( recordInfo ) );
|
|
669 |
|
|
670 |
// Get the engine parameters, so we can get the executed uid.
|
|
671 |
CDiagResultsDbRecordEngineParam* execParam;
|
|
672 |
User::LeaveIfError( iDiagEngine->DbRecord().GetEngineParam( execParam ) );
|
|
673 |
CleanupStack::PushL( execParam );
|
|
674 |
|
|
675 |
// Initialize the results data.
|
|
676 |
delete iResults;
|
|
677 |
iResults = NULL;
|
|
678 |
iResults = CDevDiagExecResults::NewL( recordInfo.iRecordId,
|
|
679 |
*iPluginPool,
|
|
680 |
iResultsDatabase,
|
|
681 |
execParam->ExecutionsUidArray()[ 0 ],
|
|
682 |
iDiagEngine );
|
|
683 |
|
|
684 |
CleanupStack::PopAndDestroy( execParam );
|
|
685 |
|
|
686 |
// Inform the observer object.
|
|
687 |
if ( iObserver )
|
|
688 |
{
|
|
689 |
iObserver->HandleEngineCommandL(
|
|
690 |
MDevDiagEngineObserver::EDevDiagEngineCommandTestExecutionBegin,
|
|
691 |
KErrNone,
|
|
692 |
NULL );
|
|
693 |
}
|
|
694 |
}
|
|
695 |
|
|
696 |
// ---------------------------------------------------------------------------
|
|
697 |
// From class MDiagEngineObserver.
|
|
698 |
// The callback to indicate test progress.
|
|
699 |
// ---------------------------------------------------------------------------
|
|
700 |
//
|
|
701 |
void CDevDiagEngine::TestExecutionProgressL( TUint aCurrentItemStep,
|
|
702 |
TUint aCurrentItemTotalSteps )
|
|
703 |
{
|
|
704 |
LOGSTRING3( "CDevDiagEngine::TestExecutionProgressL( %d, %d )",
|
|
705 |
aCurrentItemStep,
|
|
706 |
aCurrentItemTotalSteps )
|
|
707 |
|
|
708 |
// Update the results data.
|
|
709 |
__ASSERT_ALWAYS( iResults, Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
710 |
iResults->SetProgressL( aCurrentItemStep, aCurrentItemTotalSteps );
|
|
711 |
|
|
712 |
// Inform the observer object.
|
|
713 |
if ( iObserver )
|
|
714 |
{
|
|
715 |
iObserver->HandleEngineCommandL(
|
|
716 |
MDevDiagEngineObserver::EDevDiagEngineCommandProgressDataUpdated,
|
|
717 |
KErrNone,
|
|
718 |
NULL );
|
|
719 |
}
|
|
720 |
}
|
|
721 |
|
|
722 |
|
|
723 |
// ---------------------------------------------------------------------------
|
|
724 |
// From class MDiagEngineObserver.
|
|
725 |
// The callback to indicate that a plugin has completed and provide the
|
|
726 |
// result. Ownership of aResult is transferred.
|
|
727 |
// ---------------------------------------------------------------------------
|
|
728 |
//
|
|
729 |
void CDevDiagEngine::TestExecutionPluginExecutedL(
|
|
730 |
TInt aError,
|
|
731 |
CDiagResultsDatabaseItem* aResult )
|
|
732 |
{
|
|
733 |
LOGSTRING3( "CDevDiagEngine::TestExecutionPluginExecutedL( %d, 0x%x )",
|
|
734 |
aError,
|
|
735 |
aResult )
|
|
736 |
|
|
737 |
// Update the results data.
|
|
738 |
__ASSERT_ALWAYS( iResults, Panic( EDevDiagApplicationNoExecutionResults ) );
|
|
739 |
iResults->AddEntryL( aResult, aError );
|
|
740 |
|
|
741 |
if ( aResult )
|
|
742 |
{
|
|
743 |
TInt result = aResult->TestResult();
|
|
744 |
}
|
|
745 |
|
|
746 |
|
|
747 |
const MDiagPlugin& plugin = iResults->CurrentItemL().Plugin();
|
|
748 |
|
|
749 |
if ( plugin.Type() == MDiagPlugin::ETypeTestPlugin )
|
|
750 |
{
|
|
751 |
//Now we are executing a test (NULL indicates a test suite).
|
|
752 |
if ( aResult )
|
|
753 |
{
|
|
754 |
MDevDiagEngineObserver::TAppEngineCommand cmd = MDevDiagEngineObserver::EDevDiagEngineCommandSinglePluginExecutionDone;
|
|
755 |
if ( iObserver )
|
|
756 |
iObserver->HandleEngineCommandL(cmd,aError,NULL );
|
|
757 |
}
|
|
758 |
}
|
|
759 |
|
|
760 |
/*
|
|
761 |
MDevDiagEngineObserver::TAppEngineCommand cmd;
|
|
762 |
|
|
763 |
const MDiagPlugin& plugin = iResults->CurrentItemL().Plugin();
|
|
764 |
|
|
765 |
if ( plugin.Type() == MDiagPlugin::ETypeTestPlugin )
|
|
766 |
{
|
|
767 |
//Now we are executing a test (NULL indicates a test suite).
|
|
768 |
if ( aResult )
|
|
769 |
{ javascript:submitForm('CreateAccountServlet', target='/accounts/my/create_selectService.jsp', '')
|
|
770 |
9
|
|
771 |
cmd = MDevDiagEngineObserver::EDevDiagEngineCommandSinglePluginExecutionDone;
|
|
772 |
|
|
773 |
}
|
|
774 |
else
|
|
775 |
{
|
|
776 |
//cmd = MDevDiagEngineObserver::EDevDiagEngineCommandGroupExecutionProgress;
|
|
777 |
}
|
|
778 |
|
|
779 |
if ( iObserver )
|
|
780 |
{
|
|
781 |
iObserver->HandleEngineCommandL(
|
|
782 |
cmd,
|
|
783 |
aError,
|
|
784 |
NULL );
|
|
785 |
}
|
|
786 |
}
|
|
787 |
*/
|
|
788 |
}
|
|
789 |
|
|
790 |
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
// From class MDiagEngineObserver.
|
|
793 |
// The callback to indicate that the diagnostics engine has finished executing
|
|
794 |
// plugins. This can also indicate a failure to begin executing plugins.
|
|
795 |
// ---------------------------------------------------------------------------
|
|
796 |
//
|
|
797 |
void CDevDiagEngine::TestExecutionCompletedL( TInt aError )
|
|
798 |
{
|
|
799 |
LOGSTRING2( "CDevDiagEngine::TestExecutionCompletedL( %d )", aError )
|
|
800 |
|
|
801 |
SetState( EStateReady );
|
|
802 |
|
|
803 |
TBool singleExecution = iResults->SinglePluginExecutionL();
|
|
804 |
|
|
805 |
// Clean up the execution information.
|
|
806 |
if ( iResults )
|
|
807 |
{
|
|
808 |
// The results are fully complete only if execution cannot be resumed,
|
|
809 |
// so these are the only error codes that indicate that.
|
|
810 |
iResults->Finalize( aError == KErrNone ||
|
|
811 |
aError == KErrCancel ||
|
|
812 |
aError == KErrArgument );
|
|
813 |
}
|
|
814 |
|
|
815 |
delete iDiagEngine;
|
|
816 |
iDiagEngine = NULL;
|
|
817 |
|
|
818 |
// Inform the observer object.
|
|
819 |
if ( iObserver && !singleExecution )
|
|
820 |
{
|
|
821 |
|
|
822 |
iObserver->HandleEngineCommandL(
|
|
823 |
MDevDiagEngineObserver::EDevDiagEngineCommandGroupExecutionDone,
|
|
824 |
aError,
|
|
825 |
NULL );
|
|
826 |
}
|
|
827 |
|
|
828 |
}
|
|
829 |
|
|
830 |
// ---------------------------------------------------------------------------
|
|
831 |
// From class MDiagEngineObserver.
|
|
832 |
// The callback to indicate that test execution has been suspended.
|
|
833 |
// ---------------------------------------------------------------------------
|
|
834 |
//
|
|
835 |
void CDevDiagEngine::TestExecutionSuspendedL( TSuspendReason aSuspendReason )
|
|
836 |
{
|
|
837 |
LOGSTRING2( "CDevDiagEngine::TestExecutionSuspendedL( %d )",
|
|
838 |
aSuspendReason )
|
|
839 |
|
|
840 |
// Don't do anything if this suspend came from the application, as this
|
|
841 |
// would duplicate the counter increase.
|
|
842 |
if ( aSuspendReason == ESuspendByClient )
|
|
843 |
{
|
|
844 |
__ASSERT_DEBUG(
|
|
845 |
( iSuspendCounter > 0 && iState == EStateExecutionSuspended ),
|
|
846 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
847 |
return;
|
|
848 |
}
|
|
849 |
|
|
850 |
LOGSTRING3( "CDevDiagEngine::TestExecutionSuspendedL: counter %d, state: %d",
|
|
851 |
iSuspendCounter,
|
|
852 |
iState )
|
|
853 |
// Increment the suspend counter and check the state.
|
|
854 |
iSuspendCounter++;
|
|
855 |
if ( iState == EStateExecutionSuspended )
|
|
856 |
{
|
|
857 |
// If we are already suspended, then this suspend has no effect.
|
|
858 |
return;
|
|
859 |
}
|
|
860 |
|
|
861 |
// Suspend ourself and inform the user.
|
|
862 |
SetState( EStateExecutionSuspended );
|
|
863 |
if ( iObserver )
|
|
864 |
{
|
|
865 |
iObserver->HandleEngineCommandL(
|
|
866 |
MDevDiagEngineObserver::EDevDiagEngineCommandTestExecutionSuspended,
|
|
867 |
KErrNone,
|
|
868 |
NULL );
|
|
869 |
}
|
|
870 |
}
|
|
871 |
|
|
872 |
// ---------------------------------------------------------------------------
|
|
873 |
// From class MDiagEngineObserver.
|
|
874 |
// The callback to indicate that test execution has been resumed.
|
|
875 |
// ---------------------------------------------------------------------------
|
|
876 |
//
|
|
877 |
void CDevDiagEngine::TestExecutionResumedL( TResumeReason aResumeReason )
|
|
878 |
{
|
|
879 |
LOGSTRING2( "CDevDiagEngine::TestExecutionResumedL( %d )", aResumeReason )
|
|
880 |
|
|
881 |
// Don't do anything if this suspend came from the application, as this
|
|
882 |
// would duplicate the counter decrease.
|
|
883 |
if ( aResumeReason == EResumedByClient )
|
|
884 |
{
|
|
885 |
return;
|
|
886 |
}
|
|
887 |
|
|
888 |
LOGSTRING3( "CDevDiagEngine::TestExecutionResumedL: counter %d, state: %d",
|
|
889 |
iSuspendCounter,
|
|
890 |
iState )
|
|
891 |
// Decrement the suspend counter and check the state.
|
|
892 |
--iSuspendCounter;
|
|
893 |
__ASSERT_DEBUG( iSuspendCounter >= 0,
|
|
894 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
895 |
if ( iState != EStateExecutionSuspended )
|
|
896 |
{
|
|
897 |
// The resume was already done, so just return.
|
|
898 |
return;
|
|
899 |
}
|
|
900 |
|
|
901 |
// Resume ourself and inform the user.
|
|
902 |
SetState( EStateRunningTests );
|
|
903 |
if ( iObserver )
|
|
904 |
{
|
|
905 |
iObserver->HandleEngineCommandL(
|
|
906 |
MDevDiagEngineObserver::EDevDiagEngineCommandTestExecutionResumed,
|
|
907 |
KErrNone,
|
|
908 |
NULL );
|
|
909 |
}
|
|
910 |
}
|
|
911 |
|
|
912 |
// ---------------------------------------------------------------------------
|
|
913 |
// From class MDiagEngineObserver.
|
|
914 |
// The callback to to create a custom common-use dialog. This may ONLY be
|
|
915 |
// called by the Diagnostics Engine. Any application classes must use the
|
|
916 |
// dialog classes directly.
|
|
917 |
// ---------------------------------------------------------------------------
|
|
918 |
//
|
|
919 |
CAknDialog* CDevDiagEngine::CreateCommonDialogLC( TDiagCommonDialog aDialogType,
|
|
920 |
TAny* aInitData )
|
|
921 |
{
|
|
922 |
LOGSTRING3( "CDevDiagEngine::CreateCommonDialogLC( %d, 0x%x )",
|
|
923 |
aDialogType,
|
|
924 |
aInitData )
|
|
925 |
|
|
926 |
switch ( aDialogType )
|
|
927 |
{
|
|
928 |
case EDiagCommonDialogConfirmCancelAll:
|
|
929 |
{
|
|
930 |
__ASSERT_ALWAYS( !aInitData,
|
|
931 |
Panic( EDevDiagApplicationGeneral ) );
|
|
932 |
return CDevDiagCommonCancelDialogs::NewLC( *this, EFalse );
|
|
933 |
}
|
|
934 |
|
|
935 |
case EDiagCommonDialogConfirmSkipAll:
|
|
936 |
{
|
|
937 |
__ASSERT_ALWAYS( !aInitData,
|
|
938 |
Panic( EDevDiagApplicationGeneral ) );
|
|
939 |
return CDevDiagCommonSkipDialogs::NewLC( *this, EFalse );
|
|
940 |
}
|
|
941 |
}
|
|
942 |
|
|
943 |
__ASSERT_DEBUG( EFalse, Panic( EDevDiagApplicationBadType ) );
|
|
944 |
return NULL;
|
|
945 |
}
|
|
946 |
|
|
947 |
|
|
948 |
|
|
949 |
// ---------------------------------------------------------------------------
|
|
950 |
// From class MDiagEngineObserver.
|
|
951 |
// The callback to to execute an application command. This may ONLY be
|
|
952 |
// called by the Diagnostics Engine.
|
|
953 |
// ---------------------------------------------------------------------------
|
|
954 |
//
|
|
955 |
void CDevDiagEngine::ExecuteAppCommandL( TDiagAppCommand aCommand,
|
|
956 |
TAny* aParam1,
|
|
957 |
TAny* aParam2 )
|
|
958 |
{
|
|
959 |
LOGSTRING4( "CDevDiagEngine::ExecuteAppCommandL( %d, 0x%x, 0x%x )",
|
|
960 |
aCommand,
|
|
961 |
aParam1,
|
|
962 |
aParam2 )
|
|
963 |
|
|
964 |
switch ( aCommand )
|
|
965 |
{
|
|
966 |
case EDiagAppCommandSwitchToMainView:
|
|
967 |
{
|
|
968 |
__ASSERT_ALWAYS( ( !aParam1 && !aParam2 ),
|
|
969 |
Panic( EDevDiagApplicationGeneral ) );
|
|
970 |
if ( iObserver )
|
|
971 |
{
|
|
972 |
iObserver->HandleEngineCommandL(
|
|
973 |
MDevDiagEngineObserver::EDevDiagEngineCommandViewSwitch,
|
|
974 |
KErrNone,
|
|
975 |
NULL );
|
|
976 |
}
|
|
977 |
break;
|
|
978 |
}
|
|
979 |
|
|
980 |
default:
|
|
981 |
User::Leave( KErrNotSupported );
|
|
982 |
}
|
|
983 |
}
|
|
984 |
|
|
985 |
// ---------------------------------------------------------------------------
|
|
986 |
// From class MDiagPluginPoolObserver.
|
|
987 |
// The callback to indicate plugin loading progress.
|
|
988 |
// ---------------------------------------------------------------------------
|
|
989 |
//
|
|
990 |
void CDevDiagEngine::LoadProgressL( TUint aCurrentStep,
|
|
991 |
TUint aTotalSteps,
|
|
992 |
const TUid& aLoadedPluginUid )
|
|
993 |
{
|
|
994 |
|
|
995 |
LOGSTRING4( "CDevDiagEngine::LoadProgressL( %d, %d, 0x%x )",
|
|
996 |
aCurrentStep,
|
|
997 |
aTotalSteps,
|
|
998 |
aLoadedPluginUid.iUid )
|
|
999 |
|
|
1000 |
__ASSERT_ALWAYS( iState == EStateLoadingPlugins,
|
|
1001 |
Panic( EDevDiagApplicationInvalidEngineState ) );
|
|
1002 |
|
|
1003 |
// Inform the observer with the loading information.
|
|
1004 |
if ( iObserver )
|
|
1005 |
{
|
|
1006 |
MDiagPlugin* plugin = NULL;
|
|
1007 |
iPluginPool->FindPlugin( aLoadedPluginUid, plugin );
|
|
1008 |
|
|
1009 |
iObserver->HandleEngineCommandL(
|
|
1010 |
MDevDiagEngineObserver::EDevDiagEngineCommandPluginLoadProgress,
|
|
1011 |
KErrNone,
|
|
1012 |
plugin );
|
|
1013 |
}
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
// ---------------------------------------------------------------------------
|
|
1017 |
// From class MDiagPluginPoolObserver.
|
|
1018 |
// The callback to indicate plugin loading completion.
|
|
1019 |
// ---------------------------------------------------------------------------
|
|
1020 |
//
|
|
1021 |
void CDevDiagEngine::LoadCompletedL( TInt aError )
|
|
1022 |
{
|
|
1023 |
LOGSTRING2( "CDevDiagEngine::LoadCompletedL( %d )", aError )
|
|
1024 |
|
|
1025 |
SetState( EStateReady );
|
|
1026 |
|
|
1027 |
// Inform the observer of the loading completion. The observer will
|
|
1028 |
// display error messages for loading failures.
|
|
1029 |
if ( iObserver )
|
|
1030 |
{
|
|
1031 |
iObserver->HandleEngineCommandL(
|
|
1032 |
MDevDiagEngineObserver::EDevDiagEngineCommandPluginLoadComplete,
|
|
1033 |
aError,
|
|
1034 |
NULL );
|
|
1035 |
}
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
// ---------------------------------------------------------------------------
|
|
1039 |
// Get Last results from the Results Database.
|
|
1040 |
// ---------------------------------------------------------------------------
|
|
1041 |
//
|
|
1042 |
void CDevDiagEngine::GetLastResultsL( TUid aParentUid )
|
|
1043 |
{
|
|
1044 |
LOGSTRING( "CDevDiagEngine::GetLastResultsL");
|
|
1045 |
|
|
1046 |
RPointerArray<MDiagPlugin> children;
|
|
1047 |
CleanupClosePushL( children );
|
|
1048 |
|
|
1049 |
MDiagPlugin* plugin;
|
|
1050 |
///@@@KSR: changes for BAD Warnings - #177-D: variable "formattedName" was declared but never referenced
|
|
1051 |
//HBufC* formattedName = NULL;
|
|
1052 |
|
|
1053 |
if ( PluginPool().FindPlugin( aParentUid, plugin ) == KErrNone )
|
|
1054 |
{
|
|
1055 |
MDiagSuitePlugin* suite = static_cast< MDiagSuitePlugin* >( plugin );
|
|
1056 |
suite->GetChildrenL( children, MDiagSuitePlugin::ESortByPosition );
|
|
1057 |
}
|
|
1058 |
else
|
|
1059 |
{
|
|
1060 |
User::Leave(KErrNotFound);
|
|
1061 |
}
|
|
1062 |
|
|
1063 |
if ( iUids )
|
|
1064 |
{
|
|
1065 |
delete iUids;
|
|
1066 |
iUids = NULL;
|
|
1067 |
}
|
|
1068 |
|
|
1069 |
iUids = new (ELeave) CArrayFixFlat<TUid>( KArrayGranuality );
|
|
1070 |
|
|
1071 |
iLastResults.ResetAndDestroy();
|
|
1072 |
|
|
1073 |
//Create UID array that is needed when results are searched from the DB.
|
|
1074 |
for ( TInt i = 0; i < children.Count(); ++i )
|
|
1075 |
{
|
|
1076 |
iUids->AppendL( children[i]->Uid() );
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
CleanupStack::PopAndDestroy( &children );
|
|
1080 |
|
|
1081 |
//Start search. This is an asynchronous call.
|
|
1082 |
iResultsDatabase.InitiateGetLastResults( *iUids, iStatus );
|
|
1083 |
|
|
1084 |
SetActive();
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
|
|
1088 |
// ---------------------------------------------------------------------------
|
|
1089 |
// Get last plug-in that crashed (if any).
|
|
1090 |
//
|
|
1091 |
// CDiagResultsDatabaseItem::EQueuedToRun indicates that the test was not
|
|
1092 |
// executed properly.
|
|
1093 |
// ---------------------------------------------------------------------------
|
|
1094 |
//
|
|
1095 |
TBool CDevDiagEngine::CrashedPluginL( TUid& aPluginUid )
|
|
1096 |
{
|
|
1097 |
LOGSTRING( "CDevDiagEngine::CrashedPluginL");
|
|
1098 |
TUid recordUid;
|
|
1099 |
TInt error = iResultsDatabase.GetLastNotCompletedRecord ( recordUid );
|
|
1100 |
LOGSTRING2("crashedpluginL::dbconnect error %d",error);
|
|
1101 |
TBool found = EFalse;
|
|
1102 |
if ( error == KErrNone )
|
|
1103 |
{
|
|
1104 |
RDiagResultsDatabaseRecord crashedRecord;
|
|
1105 |
|
|
1106 |
error = crashedRecord.Connect( iResultsDatabase, recordUid, EFalse );
|
|
1107 |
CleanupClosePushL( crashedRecord );
|
|
1108 |
|
|
1109 |
if ( error != KErrNone )
|
|
1110 |
{
|
|
1111 |
LOGSTRING2( "CDevDiagEngine::CrashedPluginL connect error: %d", error );
|
|
1112 |
User::Leave( error );
|
|
1113 |
}
|
|
1114 |
|
|
1115 |
//ResetAndDestroy + Close would be better
|
|
1116 |
RPointerArray<CDiagResultsDatabaseItem> resultsArray;
|
|
1117 |
CleanupClosePushL( resultsArray );
|
|
1118 |
|
|
1119 |
error = crashedRecord.GetTestResults ( resultsArray );
|
|
1120 |
|
|
1121 |
if ( error != KErrNone )
|
|
1122 |
{
|
|
1123 |
LOGSTRING2( "CDevDiagEngine::CrashedPluginL GetTestResults error: %d", error );
|
|
1124 |
User::Leave( error );
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
for ( TInt i = 0; i < resultsArray.Count(); ++i )
|
|
1128 |
{
|
|
1129 |
if ( resultsArray[i]->TestResult() == CDiagResultsDatabaseItem::EQueuedToRun )
|
|
1130 |
{
|
|
1131 |
aPluginUid = resultsArray[i]->TestUid();
|
|
1132 |
found = ETrue;
|
|
1133 |
break;
|
|
1134 |
}
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
resultsArray.ResetAndDestroy();
|
|
1138 |
CleanupStack::PopAndDestroy();
|
|
1139 |
CleanupStack::PopAndDestroy(); //crashedRecord
|
|
1140 |
}
|
|
1141 |
|
|
1142 |
LOGSTRING( "CDevDiagEngine::CrashedPluginL end" );
|
|
1143 |
|
|
1144 |
return found;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
|
|
1148 |
// ---------------------------------------------------------------------------
|
|
1149 |
// Completes the crashed test record.
|
|
1150 |
// ---------------------------------------------------------------------------
|
|
1151 |
//
|
|
1152 |
///@@@KSR: changes for Codescanner error val = High
|
|
1153 |
//TInt CDevDiagEngine::CompleteCrashedTestRecord()
|
|
1154 |
TInt CDevDiagEngine::CompleteCrashedTestRecordL()
|
|
1155 |
{
|
|
1156 |
LOGSTRING( "CDevDiagEngine::CompleteCrashedTestRecordL");
|
|
1157 |
TUid recordUid;
|
|
1158 |
TInt error = iResultsDatabase.GetLastNotCompletedRecord ( recordUid );
|
|
1159 |
|
|
1160 |
if ( error == KErrNone )
|
|
1161 |
{
|
|
1162 |
RDiagResultsDatabaseRecord crashedRecord;
|
|
1163 |
|
|
1164 |
error = crashedRecord.Connect( iResultsDatabase, recordUid, EFalse );
|
|
1165 |
CleanupClosePushL( crashedRecord );
|
|
1166 |
|
|
1167 |
if ( error != KErrNone )
|
|
1168 |
{
|
|
1169 |
LOGSTRING2( "CDevDiagEngine::CompleteCrashedTestRecordL connect error: %d", error );
|
|
1170 |
return error;
|
|
1171 |
}
|
|
1172 |
|
|
1173 |
error = crashedRecord.TestCompleted( ETrue );
|
|
1174 |
|
|
1175 |
if ( error != KErrNone )
|
|
1176 |
{
|
|
1177 |
LOGSTRING2( "CDevDiagEngine::CompleteCrashedTestRecordL TestCompleted error: %d", error );
|
|
1178 |
return error;
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
CleanupStack::PopAndDestroy(); //crashedRecord
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
LOGSTRING( "CDevDiagEngine::CompleteCrashedTestRecordL end");
|
|
1185 |
|
|
1186 |
return error;
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
|
|
1190 |
// ADO & Platformization Changes
|
|
1191 |
TBool CDevDiagEngine::GetPluginDependencyL()
|
|
1192 |
{
|
|
1193 |
///@@@KSR: changes for Codescanner error val = High
|
|
1194 |
//return iDiagEngine->GetPluginDependency();
|
|
1195 |
return iDiagEngine->GetPluginDependencyL();
|
|
1196 |
}
|
|
1197 |
|
|
1198 |
// End of File
|