58
|
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: This is the implementation class for the engine of Battery charger cable
|
|
15 |
* test plug-in
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
// Class declaration
|
|
22 |
#include "diagbatterychargercableengine.h"
|
|
23 |
|
|
24 |
// System includes
|
|
25 |
#include <DiagFrameworkDebug.h> // Debugging Macros
|
|
26 |
#include <StringLoader.h> // StringLoader
|
|
27 |
#include <e32property.h> // RProperty
|
|
28 |
#include <hwrmpowerstatesdkpskeys.h> // P&S keys of HW Resource Manager
|
|
29 |
#include <DiagPluginWaitingDialogWrapper.h> // CDiagPluginWaitingDialogWrapper
|
|
30 |
#include <aknmessagequerydialog.h> // CAknQueryDialog
|
|
31 |
#include <devdiagbatterychargercabletestpluginrsc.rsg> // Resource definitions
|
|
32 |
|
|
33 |
|
|
34 |
// User includes
|
|
35 |
#include "diagbatterychargercabletestplugin.hrh" // command ids
|
|
36 |
#include "diagbatterychargercallbackinterface.h" //MDiagBatteryChargerTestCallBackInterface
|
|
37 |
|
|
38 |
|
|
39 |
// EXTERNAL DATA STRUCTURES
|
|
40 |
|
|
41 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
42 |
|
|
43 |
// CONSTANTS
|
|
44 |
|
|
45 |
// MACROS
|
|
46 |
|
|
47 |
// LOCAL CONSTANTS AND MACROS
|
|
48 |
|
|
49 |
// MODULE DATA STRUCTURES
|
|
50 |
|
|
51 |
// LOCAL FUNCTION PROTOTYPES
|
|
52 |
|
|
53 |
// FORWARD DECLARATIONS
|
|
54 |
|
|
55 |
// ============================= LOCAL FUNCTIONS ==============================
|
|
56 |
|
|
57 |
// ========================= MEMBER FUNCTIONS ================================
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// CDiagBatteryChargerCableTestEngine::NewL()
|
|
61 |
//
|
|
62 |
// Symbian OS default constructor
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
CDiagBatteryChargerCableTestEngine* CDiagBatteryChargerCableTestEngine::NewL(
|
|
65 |
MDiagBatteryChargerTestCallBackInterface& aInterface,
|
|
66 |
TBool aIsSinglePluginExecution)
|
|
67 |
{
|
|
68 |
CDiagBatteryChargerCableTestEngine* self =
|
|
69 |
new (ELeave)CDiagBatteryChargerCableTestEngine(
|
|
70 |
aInterface, aIsSinglePluginExecution);
|
|
71 |
CleanupStack::PushL( self );
|
|
72 |
self->ConstructL();
|
|
73 |
CleanupStack::Pop( self );
|
|
74 |
return self;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
// CDiagBatteryChargerCableTestEngine::CDiagBatteryChargerCableTestEngine()
|
|
80 |
//
|
|
81 |
// Constructor
|
|
82 |
// ----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
CDiagBatteryChargerCableTestEngine::CDiagBatteryChargerCableTestEngine(
|
|
85 |
MDiagBatteryChargerTestCallBackInterface& aInterface,
|
|
86 |
TBool aIsSinglePluginExecution)
|
|
87 |
: CActive( EPriorityStandard ),
|
|
88 |
iInterface(aInterface),
|
|
89 |
iWaitingDialogWrapper( NULL ),
|
|
90 |
iIsSinglePluginExecution(aIsSinglePluginExecution)
|
|
91 |
{
|
|
92 |
CActiveScheduler::Add( this );
|
|
93 |
}
|
|
94 |
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
// CDiagBatteryChargerCableTestEngine::~CDiagBatteryChargerCableTestEngine
|
|
97 |
//
|
|
98 |
// Destructor
|
|
99 |
// ----------------------------------------------------------------------------
|
|
100 |
CDiagBatteryChargerCableTestEngine::~CDiagBatteryChargerCableTestEngine()
|
|
101 |
{
|
|
102 |
Cancel();
|
|
103 |
|
|
104 |
delete iWaitingDialogWrapper; // deleting will dismiss active dialog
|
|
105 |
iWaitingDialogWrapper = NULL;
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// CDiagBatteryChargerCableTestEngine::ConstructL()
|
|
110 |
//
|
|
111 |
// Symbian OS two-phased constructor
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
void CDiagBatteryChargerCableTestEngine::ConstructL()
|
|
114 |
{
|
|
115 |
// nothing to do here
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
// ----------------------------------------------------------------------------
|
|
120 |
// CDiagBatteryChargerCableTestEngine::RunBatteryChargerTestL
|
|
121 |
//
|
|
122 |
// This function starts the Battery charger cable test
|
|
123 |
// ----------------------------------------------------------------------------
|
|
124 |
void CDiagBatteryChargerCableTestEngine::RunBatteryChargerTestL()
|
|
125 |
{
|
|
126 |
TInt userResponse;
|
|
127 |
|
|
128 |
if ( !ConnectAndPressOkL( userResponse ) )
|
|
129 |
{
|
|
130 |
// Return immediately. "this" object may have been deleted.
|
|
131 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Connect Battery charger and press ok dialog was dismissed internally" )
|
|
132 |
return;
|
|
133 |
}
|
|
134 |
|
|
135 |
switch( userResponse )
|
|
136 |
{
|
|
137 |
// User selects OK "Connect charger & press ok" dialog
|
|
138 |
case EAknSoftkeyOk:
|
|
139 |
{
|
|
140 |
//TInt keySelect;
|
|
141 |
// check if headset cable is connected
|
|
142 |
if( CheckIfChargerDetected() )
|
|
143 |
{
|
|
144 |
// battery charger is detected
|
|
145 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Headset detected" );
|
|
146 |
/*
|
|
147 |
if ( !RemoveAllCablesL( keySelect ) )
|
|
148 |
{
|
|
149 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Remove All Cable dialog was dismissed internally pressed" )
|
|
150 |
return;
|
|
151 |
}
|
|
152 |
|
|
153 |
if ( keySelect != EAknSoftkeyOk )
|
|
154 |
{
|
|
155 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : EndKey has pressed" )
|
|
156 |
return;
|
|
157 |
}
|
|
158 |
*/ // ADO & Platformization Changes
|
|
159 |
|
|
160 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Report result Success" )
|
|
161 |
ReportResultToPluginL( CDiagResultsDatabaseItem::ESuccess );
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
// no cable detected
|
|
166 |
if ( !AskIfRetryL( userResponse ) )
|
|
167 |
{
|
|
168 |
// Ask for retry dialog dismissed by framework internally
|
|
169 |
// Return immediately
|
|
170 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine Test Ask for retry dialog dismissed by framework internally" )
|
|
171 |
return;
|
|
172 |
}
|
|
173 |
|
|
174 |
switch(userResponse)
|
|
175 |
{
|
|
176 |
|
|
177 |
//case EAknSoftkeyOk: // ADO & Platformization Changes
|
|
178 |
case EBatteryTestConnectBatteryChargerNo:
|
|
179 |
{
|
|
180 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : user selected OK" )
|
|
181 |
ReportResultToPluginL(CDiagResultsDatabaseItem::EFailed);
|
|
182 |
}
|
|
183 |
break;
|
|
184 |
//case EBatteryTestConnectBatteryChargerBack: // ADO & Platformization Changes
|
|
185 |
case EBatteryTestConnectBatteryChargerYes:
|
|
186 |
{
|
|
187 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : user selected Back" )
|
|
188 |
// user selected "Back" to retry
|
|
189 |
// do a self-trigger to start again
|
|
190 |
TRequestStatus* status = &iStatus;
|
|
191 |
SetActive();
|
|
192 |
User::RequestComplete( status, KErrNone );
|
|
193 |
}
|
|
194 |
break;
|
|
195 |
default:
|
|
196 |
{
|
|
197 |
// the dialog was dismissed by cancel key
|
|
198 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : user selected cancel key" )
|
|
199 |
}
|
|
200 |
break;
|
|
201 |
};
|
|
202 |
}
|
|
203 |
}
|
|
204 |
break;
|
|
205 |
|
|
206 |
// User selects SKIP on "Connect charger & press ok" dialog
|
|
207 |
case EBatteryTestConnectBatteryChargerCancel:
|
|
208 |
case EBatteryTestConnectBatteryChargerSkip:
|
|
209 |
{
|
|
210 |
if(iIsSinglePluginExecution)
|
|
211 |
{
|
|
212 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine Test skipped by user" )
|
|
213 |
ReportResultToPluginL(CDiagResultsDatabaseItem::ESkipped);
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
if( iInterface.AskCancelExecutionL(userResponse) )
|
|
218 |
{
|
|
219 |
// cancel dialog was dismissed by user action
|
|
220 |
if(userResponse)
|
|
221 |
{
|
|
222 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine Test cancelled by user" )
|
|
223 |
return;
|
|
224 |
}
|
|
225 |
else
|
|
226 |
{
|
|
227 |
// currently no way to distinguish between "No" and "Cancel" key
|
|
228 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : User selected No to Cancel dialog" )
|
|
229 |
// do a self-trigger to start again
|
|
230 |
TRequestStatus* status = &iStatus;
|
|
231 |
SetActive();
|
|
232 |
User::RequestComplete( status, KErrNone );
|
|
233 |
}
|
|
234 |
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
// Though this should not happedn, Cancel All Test execution query dialog was dismissed internally by the framework,
|
|
239 |
// not by user action. Return immediately
|
|
240 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Cancel query dialog was dismissed internally by the framework, not by user action." )
|
|
241 |
return;
|
|
242 |
}
|
|
243 |
}
|
|
244 |
}
|
|
245 |
break;
|
|
246 |
|
|
247 |
// User selectes CANCEL command (Red Key) on "Connect charger & press ok" dialog
|
|
248 |
default:
|
|
249 |
{
|
|
250 |
// Do nothing
|
|
251 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Connect Battery charger and press ok dialog was dismissed by end key" )
|
|
252 |
}
|
|
253 |
break;
|
|
254 |
};
|
|
255 |
}
|
|
256 |
|
|
257 |
// ----------------------------------------------------------------------------
|
|
258 |
// CDiagBatteryChargerCableTestEngine::CheckIfChargerDetected
|
|
259 |
//
|
|
260 |
// This function detects the battery charger status
|
|
261 |
// ----------------------------------------------------------------------------
|
|
262 |
TBool CDiagBatteryChargerCableTestEngine::CheckIfChargerDetected()
|
|
263 |
{
|
|
264 |
TInt charger = -1, retval = EFalse;
|
|
265 |
TInt error = RProperty::Get( KPSUidHWRMPowerState, KHWRMChargingStatus, charger ) ;
|
|
266 |
|
|
267 |
if( error == KErrNone )
|
|
268 |
{
|
|
269 |
LOGSTRING2( "CDiagBatteryChargerCableTestEngine charging status = %d", charger )
|
|
270 |
switch(charger)
|
|
271 |
{
|
|
272 |
case EChargingStatusCharging: // Device is charging.
|
|
273 |
case EChargingStatusAlmostComplete: // Charging almost completed.
|
|
274 |
case EChargingStatusChargingComplete: // Charging completed.
|
|
275 |
case EChargingStatusChargingContinued : // Charging continued after brief interruption.
|
|
276 |
{
|
|
277 |
retval = ETrue;
|
|
278 |
}
|
|
279 |
break;
|
|
280 |
|
|
281 |
|
|
282 |
case EChargingStatusError: // Some error has occurred when charger is connected or charging.
|
|
283 |
case EChargingStatusNotConnected: // Charger not connected/uninitialized.
|
|
284 |
case EChargingStatusNotCharging: // Charger is connected, device not charging.
|
|
285 |
default:
|
|
286 |
{
|
|
287 |
retval = EFalse;
|
|
288 |
}
|
|
289 |
|
|
290 |
}
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
LOGSTRING( "CDiagBatteryChargerCableTestEngine : Error in obtaining charger status ")
|
|
295 |
retval = EFalse;
|
|
296 |
}
|
|
297 |
|
|
298 |
return retval;
|
|
299 |
}
|
|
300 |
|
|
301 |
// ----------------------------------------------------------------------------
|
|
302 |
// CDiagBatteryChargerCableTestEngine::ReportResultToPluginL
|
|
303 |
//
|
|
304 |
// This function reports the result to plugin
|
|
305 |
// ----------------------------------------------------------------------------
|
|
306 |
void CDiagBatteryChargerCableTestEngine::ReportResultToPluginL(
|
|
307 |
CDiagResultsDatabaseItem::TResult aResult)
|
|
308 |
{
|
|
309 |
iInterface.ReportTestResultL(aResult);
|
|
310 |
}
|
|
311 |
|
|
312 |
|
|
313 |
// ---------------------------------------------------------------------------------------
|
|
314 |
// CDiagBatteryChargerCableTestPlugin::ConnectAndPressOkL
|
|
315 |
// This function shows the query dialog : Connect your battery charger. Press OK when ready
|
|
316 |
// ---------------------------------------------------------------------------------------
|
|
317 |
TBool CDiagBatteryChargerCableTestEngine::ConnectAndPressOkL( TInt& aUserResponse )
|
|
318 |
{
|
|
319 |
|
|
320 |
ASSERT( iWaitingDialogWrapper == NULL );
|
|
321 |
|
|
322 |
CAknQueryDialog* dialog = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
|
|
323 |
CleanupStack::PushL( dialog );
|
|
324 |
|
|
325 |
dialog->PrepareLC( R_DIAG_BATTERY_CHARGER_CABLE_TEST_CONNECT_AND_PRESS_OK );
|
|
326 |
|
|
327 |
if( iIsSinglePluginExecution )
|
|
328 |
{
|
|
329 |
CEikButtonGroupContainer& cba = dialog->ButtonGroupContainer();
|
|
330 |
cba.SetCommandSetL( R_CBA_CONNECT_AND_PRESS_OK_SINGLE_EXECUTION );
|
|
331 |
}
|
|
332 |
|
|
333 |
CleanupStack::Pop( dialog );
|
|
334 |
|
|
335 |
// dialog ownership to bepassed to iWaitingDialogWrapper
|
|
336 |
// CDiagPluginWaitingDialogWrapper::NewL will push dialog into clean up stack
|
|
337 |
iWaitingDialogWrapper = CDiagPluginWaitingDialogWrapper::NewL( dialog );
|
|
338 |
dialog = NULL;
|
|
339 |
|
|
340 |
TBool isDialogDismissedByUser = iWaitingDialogWrapper->RunLD( aUserResponse );
|
|
341 |
if ( isDialogDismissedByUser )
|
|
342 |
{
|
|
343 |
// local variable can be accessed only if it was returned due to
|
|
344 |
// user response. iWaitingDialogWrapper self destructs.
|
|
345 |
iWaitingDialogWrapper = NULL;
|
|
346 |
}
|
|
347 |
|
|
348 |
return isDialogDismissedByUser;
|
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------------------------------------
|
|
352 |
// CDiagBatteryChargerCableTestPlugin::RemoveAllCables
|
|
353 |
// This function shows the query dialog : Please remove all cables
|
|
354 |
// ---------------------------------------------------------------------------------------
|
|
355 |
TBool CDiagBatteryChargerCableTestEngine::RemoveAllCablesL( TInt& aUserResponse )
|
|
356 |
{
|
|
357 |
ASSERT( iWaitingDialogWrapper == NULL );
|
|
358 |
|
|
359 |
CAknQueryDialog* dialog = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
|
|
360 |
|
|
361 |
dialog->PrepareLC( R_DIAG_CABLE_TEST_REMOVE_ALL_CABLES );
|
|
362 |
|
|
363 |
// dialog ownership to bepassed to iWaitingDialogWrapper
|
|
364 |
// CDiagPluginWaitingDialogWrapper::NewL will push dialog into clean up stack
|
|
365 |
iWaitingDialogWrapper = CDiagPluginWaitingDialogWrapper::NewL( dialog );
|
|
366 |
dialog = NULL;
|
|
367 |
|
|
368 |
TBool isDialogDismissedByUser = iWaitingDialogWrapper->RunLD( aUserResponse );
|
|
369 |
if ( isDialogDismissedByUser )
|
|
370 |
{
|
|
371 |
// local variable can be accessed only if it was returned due to
|
|
372 |
// user response. iWaitingDialogWrapper self destructs.
|
|
373 |
iWaitingDialogWrapper = NULL;
|
|
374 |
}
|
|
375 |
|
|
376 |
return isDialogDismissedByUser;
|
|
377 |
}
|
|
378 |
|
|
379 |
// ---------------------------------------------------------------------------------------
|
|
380 |
// CDiagBatteryChargerCableTestPlugin::AskIfRetryL
|
|
381 |
// This function shows the query dialog : No cable detected. Press OK to continue tests
|
|
382 |
// or press Back to retry this test.
|
|
383 |
// ---------------------------------------------------------------------------------------
|
|
384 |
TBool CDiagBatteryChargerCableTestEngine::AskIfRetryL( TInt& aUserResponse )
|
|
385 |
{
|
|
386 |
return DisplayQueryDialogWithHeaderL(
|
|
387 |
R_DIAG_BATTERY_CHARGER_CABLE_TEST_NO_CABLE_DETECTED,
|
|
388 |
aUserResponse);
|
|
389 |
}
|
|
390 |
|
|
391 |
|
|
392 |
// ---------------------------------------------------------------------------------------
|
|
393 |
// CDiagBatteryChargerCableTestPlugin::DisplayQueryDialogWithHeaderL
|
|
394 |
// This function shows the query dialog. It returns ETrue, if the dialog is dismissed by user
|
|
395 |
// if the dialog was dismissed because of time-out, it returns EFalse.
|
|
396 |
// The user response (softkey) is returned in the reference argument aUserResponse
|
|
397 |
// ---------------------------------------------------------------------------------------
|
|
398 |
|
|
399 |
TBool CDiagBatteryChargerCableTestEngine::DisplayQueryDialogWithHeaderL(
|
|
400 |
TInt aDialogResourceId,
|
|
401 |
TInt& aUserResponse )
|
|
402 |
{
|
|
403 |
ASSERT( iWaitingDialogWrapper == NULL );
|
|
404 |
|
|
405 |
CAknMessageQueryDialog * dialog = new ( ELeave )
|
|
406 |
CAknMessageQueryDialog ( CAknQueryDialog::ENoTone );
|
|
407 |
CleanupStack::PushL( dialog );
|
|
408 |
dialog->PrepareLC( aDialogResourceId );
|
|
409 |
CleanupStack::Pop( dialog );
|
|
410 |
|
|
411 |
// dialog ownership to bepassed to iWaitingDialogWrapper
|
|
412 |
// CDiagPluginWaitingDialogWrapper::NewL will push dialog into clean up stack
|
|
413 |
iWaitingDialogWrapper = CDiagPluginWaitingDialogWrapper::NewL( dialog );
|
|
414 |
dialog = NULL;
|
|
415 |
|
|
416 |
TBool isDialogDismissedByUser = iWaitingDialogWrapper->RunLD( aUserResponse );
|
|
417 |
if ( isDialogDismissedByUser )
|
|
418 |
{
|
|
419 |
// local variable can be accessed only if it was returned due to
|
|
420 |
// user response. iWaitingDialogWrapper self destructs.
|
|
421 |
iWaitingDialogWrapper = NULL;
|
|
422 |
}
|
|
423 |
|
|
424 |
return isDialogDismissedByUser;
|
|
425 |
}
|
|
426 |
|
|
427 |
// ---------------------------------------------------------------------------------------
|
|
428 |
// CDiagHeadsetCableTestEngine::RunL
|
|
429 |
// RunL() function is used in this plug-in to handle internal trigger
|
|
430 |
// ---------------------------------------------------------------------------------------
|
|
431 |
void CDiagBatteryChargerCableTestEngine::RunL()
|
|
432 |
{
|
|
433 |
if(iStatus == KErrNone)
|
|
434 |
{
|
|
435 |
RunBatteryChargerTestL();
|
|
436 |
}
|
|
437 |
}
|
|
438 |
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
// CDiagBatteryChargerCableTestEngine::RunError
|
|
441 |
// ---------------------------------------------------------------------------
|
|
442 |
//
|
|
443 |
TInt CDiagBatteryChargerCableTestEngine::RunError( TInt aError )
|
|
444 |
{
|
|
445 |
LOGSTRING2( "CDiagBatteryChargerCableTestEngine::RunError( %d )", aError )
|
|
446 |
return KErrNone;
|
|
447 |
}
|
|
448 |
|
|
449 |
// ---------------------------------------------------------------------------------------
|
|
450 |
// CDiagHeadsetCableTestEngine::DoCancel
|
|
451 |
// Handles cancel request
|
|
452 |
// ---------------------------------------------------------------------------------------
|
|
453 |
void CDiagBatteryChargerCableTestEngine::DoCancel()
|
|
454 |
{
|
|
455 |
// no implementation needed
|
|
456 |
}
|
|
457 |
|
|
458 |
// End of File
|
|
459 |
|