|
1 /* |
|
2 * Copyright (c) 2005-2008 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: CSysApLightsController implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <activitymanager.h> |
|
21 #include "SysApLightsController.h" |
|
22 #include "SysApAppUi.h" |
|
23 #include "CoreApplicationUIsInternalPSKeys.h" |
|
24 #include <e32svr.h> |
|
25 #include <hwrmdomainpskeys.h> |
|
26 #include "SysApFeatureManager.h" |
|
27 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
28 #include "sysaplightpluginhandler.h" |
|
29 #endif // RD_LIGHT_CONTROL_CHANGE |
|
30 |
|
31 #include "SysApFeatureManager.h" |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec |
|
36 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec |
|
37 const TInt KLightsOnRepeatMinPeriod( 3 ); // Do not set lights on again for concecutive calls within this period (seconds) |
|
38 const TInt KLightsOnUnlockNotePeriodMs( 1500 ); // 1.5 second timeout when unlock note is shown |
|
39 |
|
40 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
41 const TInt KMilliSecondCoefficient = 1000; |
|
42 #endif // RD_LIGHT_CONTROL_CHANGE |
|
43 // ========================== MEMBER FUNCTIONS ================================ |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CSysApLightsController* CSysApLightsController::NewL( ) |
|
47 // ---------------------------------------------------------------------------- |
|
48 |
|
49 CSysApLightsController* CSysApLightsController::NewL(CSysApAppUi& aSysApAppUi, const TInt aTimeout, const TBool aCoverDisplay ) |
|
50 { |
|
51 TRACES( RDebug::Print( _L("CSysApLightsController::NewL") ) ); |
|
52 CSysApLightsController* self = new ( ELeave ) CSysApLightsController( aSysApAppUi, aTimeout, aCoverDisplay ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop(); //self |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CSysApLightsController::ConstructL( ) |
|
61 // ---------------------------------------------------------------------------- |
|
62 |
|
63 void CSysApLightsController::ConstructL( ) |
|
64 { |
|
65 TRACES( RDebug::Print( _L("CSysApLightsController::ConstructL: lights timeout=%d"), iLightsTimeout ) ); |
|
66 TRACES( RDebug::Print( _L("CSysApLightsController::ConstructL: cover display supported=%d"), iCoverDisplaySupported ) ); |
|
67 iSysApTimer = new ( ELeave ) CSysApTimer( *this ); |
|
68 |
|
69 iLight = CHWRMLight::NewL(); |
|
70 |
|
71 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
72 iLightPluginHandler = CSysApLightPluginHandler::NewL(); |
|
73 #endif // RD_LIGHT_CONTROL_CHANGE |
|
74 |
|
75 iSysApFeatureManager = CSysApFeatureManager::NewL(); |
|
76 |
|
77 EnableActivityManagerL(); |
|
78 |
|
79 SetFlipOpenNoLights( iFlipOpen, ETrue ); |
|
80 |
|
81 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
82 iLightPluginHandler->HandleEvent( SysApLightExtension::EInitialLightsOn ); |
|
83 #endif // RD_LIGHT_CONTROL_CHANGE |
|
84 SetLightsOnL(); |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------------------------- |
|
88 // CSysApLightsController::CSysApLightsController() |
|
89 // ---------------------------------------------------------------------------- |
|
90 |
|
91 CSysApLightsController::CSysApLightsController( CSysApAppUi& aSysApAppUi, const TInt aTimeout, const TBool aCoverDisplay ) |
|
92 : |
|
93 iGripOpen( ETrue ), |
|
94 iFlipOpen( ETrue ), |
|
95 iSysApAppUi( aSysApAppUi ), |
|
96 iLightsTimeout( aTimeout ), |
|
97 iCoverDisplaySupported( aCoverDisplay ), |
|
98 iInactivityDetected( EFalse ) |
|
99 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
100 , iKeyEventsObserved( EFalse ) |
|
101 #endif // RD_LIGHT_CONTROL_CHANGE |
|
102 { |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CSysApLightsController::~CSysApLightsController() |
|
107 // ---------------------------------------------------------------------------- |
|
108 |
|
109 CSysApLightsController::~CSysApLightsController() |
|
110 { |
|
111 TRACES( RDebug::Print( _L("~CSysApLightsController") ) ); |
|
112 DisableActivityManager(); |
|
113 |
|
114 if ( iSysApTimer ) |
|
115 { |
|
116 if ( iSysApTimer->IsActive() ) |
|
117 { |
|
118 iSysApTimer->Cancel(); |
|
119 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
120 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOffTimerStop, |
|
121 TPckgBuf<TBool>(EFalse) ); |
|
122 #endif // RD_LIGHT_CONTROL_CHANGE |
|
123 } |
|
124 |
|
125 delete iSysApTimer; |
|
126 } |
|
127 |
|
128 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
129 delete iLightPluginHandler; |
|
130 #endif // RD_LIGHT_CONTROL_CHANGE |
|
131 |
|
132 delete iLight; |
|
133 delete iSysApFeatureManager; |
|
134 |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CSysApLightsController::AlarmOccuredL( const TBool aAlarmActive ) |
|
139 // ---------------------------------------------------------------------------- |
|
140 |
|
141 void CSysApLightsController::AlarmOccuredL( const TBool aAlarmActive ) |
|
142 { |
|
143 TRACES( RDebug::Print( _L("CSysApLightsController::AlarmOccuredL: %d"), aAlarmActive ) ); |
|
144 iAlarmAlerting = aAlarmActive; |
|
145 |
|
146 CancelLightsExplicitlyOffWithDelayL(); |
|
147 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
148 iLightPluginHandler->HandleEvent( SysApLightExtension::EAlarmState, TPckgBuf<TBool>(aAlarmActive) ); |
|
149 #endif // RD_LIGHT_CONTROL_CHANGE |
|
150 |
|
151 TBool blinkEnabled = ETrue; |
|
152 |
|
153 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode ) ) |
|
154 { |
|
155 blinkEnabled = EFalse; |
|
156 } |
|
157 |
|
158 // Incoming call overrides alarm when lights are concerned |
|
159 if( !iCallRinging && aAlarmActive ) |
|
160 { |
|
161 ReserveLightL(); |
|
162 SetLightsOnL( blinkEnabled ); // set lights blinking (if enabled) |
|
163 } |
|
164 else |
|
165 { |
|
166 SetLightsOnL( iCallRinging && iSilent && blinkEnabled ); // keep on blinking if call is ringing in silent mode |
|
167 ReleaseLight(); |
|
168 } |
|
169 } |
|
170 |
|
171 // ---------------------------------------------------------------------------- |
|
172 // CSysApLightsController::AccessoryConnectedL() |
|
173 // ---------------------------------------------------------------------------- |
|
174 |
|
175 void CSysApLightsController::AccessoryConnectedL( TBool aConnected ) |
|
176 { |
|
177 TRACES( RDebug::Print( _L("CSysApLightsController::AccessoryConnectedL()" ) ) ); |
|
178 |
|
179 if ( aConnected && !Alerting() ) |
|
180 { |
|
181 CancelLightsExplicitlyOffWithDelayL(); |
|
182 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
183 iLightPluginHandler->HandleEvent( SysApLightExtension::EAccessoryConnection, TPckgBuf<TBool>(aConnected) ); |
|
184 #endif // RD_LIGHT_CONTROL_CHANGE |
|
185 SetLightsOnL(); |
|
186 } |
|
187 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
188 else |
|
189 { |
|
190 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EAccessoryConnection, TPckgBuf<TBool>(aConnected) ); |
|
191 } |
|
192 #endif // RD_LIGHT_CONTROL_CHANGE |
|
193 |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CSysApLightsController::ChargerConnectedL() |
|
198 // ---------------------------------------------------------------------------- |
|
199 void CSysApLightsController::ChargerConnectedL( TBool aConnected ) |
|
200 { |
|
201 TRACES( RDebug::Print( _L("CSysApLightsController::ChargerConnectedL(): aConnected=%d" ), aConnected ) ); |
|
202 |
|
203 TBool isLocked( iSysApAppUi.DeviceLockState() || iSysApAppUi.KeyLockState() ); |
|
204 |
|
205 // if the device is not locked user activity will switch on the lights upon charger removal |
|
206 if ( ((!isLocked && aConnected) || isLocked ) && !Alerting() ) |
|
207 { |
|
208 CancelLightsExplicitlyOffWithDelayL(); |
|
209 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
210 iLightPluginHandler->HandleEvent( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
|
211 #endif // RD_LIGHT_CONTROL_CHANGE |
|
212 SetLightsOnL(); |
|
213 } |
|
214 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
215 else |
|
216 { |
|
217 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
|
218 } |
|
219 #endif // RD_LIGHT_CONTROL_CHANGE |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CSysApLightsController::ChargingCompleteL() |
|
224 // ---------------------------------------------------------------------------- |
|
225 void CSysApLightsController::ChargingCompleteL() |
|
226 { |
|
227 TRACES( RDebug::Print( _L("CSysApLightsController::ChargingCompleteL()" ) ) ); |
|
228 |
|
229 if ( !Alerting() ) |
|
230 { |
|
231 CancelLightsExplicitlyOffWithDelayL(); |
|
232 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
233 iLightPluginHandler->HandleEvent( SysApLightExtension::EChargingComplete ); |
|
234 #endif // RD_LIGHT_CONTROL_CHANGE |
|
235 SetLightsOnL(); |
|
236 } |
|
237 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
238 else |
|
239 { |
|
240 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargingComplete ); |
|
241 } |
|
242 #endif // RD_LIGHT_CONTROL_CHANGE |
|
243 } |
|
244 |
|
245 // ---------------------------------------------------------------------------- |
|
246 // CSysApLightsController::ProfileChangedL() |
|
247 // ---------------------------------------------------------------------------- |
|
248 void CSysApLightsController::ProfileChangedL() |
|
249 { |
|
250 TRACES( RDebug::Print( _L("CSysApLightsController::ProfileChangedL()" ) ) ); |
|
251 |
|
252 // If device is not locked, activity event turns on lights. |
|
253 if ( ( iSysApAppUi.DeviceLockState() || iSysApAppUi.KeyLockState() ) && !Alerting() ) |
|
254 { |
|
255 CancelLightsExplicitlyOffWithDelayL(); |
|
256 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
257 iLightPluginHandler->HandleEvent( SysApLightExtension::EProfileChanged ); |
|
258 #endif // RD_LIGHT_CONTROL_CHANGE |
|
259 SetLightsOnL(); |
|
260 } |
|
261 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
262 else |
|
263 { |
|
264 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EProfileChanged ); |
|
265 } |
|
266 #endif // RD_LIGHT_CONTROL_CHANGE |
|
267 } |
|
268 |
|
269 // ---------------------------------------------------------------------------- |
|
270 // CSysApLightsController::MemoryCardInsertedL() |
|
271 // ---------------------------------------------------------------------------- |
|
272 void CSysApLightsController::MemoryCardInsertedL() |
|
273 { |
|
274 TRACES( RDebug::Print( _L("CSysApLightsController::MemoryCardInsertedL()" ) ) ); |
|
275 |
|
276 if ( !Alerting() ) |
|
277 { |
|
278 CancelLightsExplicitlyOffWithDelayL(); |
|
279 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
280 iLightPluginHandler->HandleEvent( SysApLightExtension::EMemoryCardInserted ); |
|
281 #endif // RD_LIGHT_CONTROL_CHANGE |
|
282 SetLightsOnL(); |
|
283 } |
|
284 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
285 else |
|
286 { |
|
287 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EMemoryCardInserted ); |
|
288 } |
|
289 #endif // RD_LIGHT_CONTROL_CHANGE |
|
290 |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // CSysApLightsController::CallComingInL( const TBool aCallringing ) |
|
295 // ---------------------------------------------------------------------------- |
|
296 |
|
297 void CSysApLightsController::CallComingInL( const TBool aCallringing ) |
|
298 { |
|
299 TRACES( RDebug::Print( _L("CSysApLightsController::CallComingInL: %d"), aCallringing ) ); |
|
300 iCallRinging = aCallringing; |
|
301 |
|
302 CancelLightsExplicitlyOffWithDelayL(); |
|
303 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
304 iLightPluginHandler->HandleEvent( SysApLightExtension::ECallStateRinging, TPckgBuf<TBool>(aCallringing) ); |
|
305 #endif // RD_LIGHT_CONTROL_CHANGE |
|
306 |
|
307 if( aCallringing ) |
|
308 { |
|
309 ReserveLightL(); |
|
310 |
|
311 // Incoming call overrides alarm when lights are concerned |
|
312 if( iSilent ) |
|
313 { |
|
314 |
|
315 // default we want blink while in call |
|
316 TBool blink = ETrue; |
|
317 |
|
318 // in some touch products we don't want lights to blink while call is incoming |
|
319 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode ) ) |
|
320 { |
|
321 blink = EFalse; |
|
322 } |
|
323 |
|
324 SetLightsOnL( blink ); // set lights blinking |
|
325 } |
|
326 else |
|
327 { |
|
328 SetLightsOnL(); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 SetLightsOnL(); |
|
334 ReleaseLight(); |
|
335 } |
|
336 } |
|
337 |
|
338 // ---------------------------------------------------------------------------- |
|
339 // CSysApLightsController::PowerKeyPressedL() |
|
340 // ---------------------------------------------------------------------------- |
|
341 |
|
342 void CSysApLightsController::PowerKeyPressedL() |
|
343 { |
|
344 TRACES( RDebug::Print( _L("CSysApLightsController::PowerKeyPressedL()") ) ); |
|
345 |
|
346 if ( !Alerting() ) |
|
347 { |
|
348 CancelLightsExplicitlyOffWithDelayL(); |
|
349 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
350 iLightPluginHandler->HandleEvent( SysApLightExtension::EPowerKeyPressed ); |
|
351 #endif // RD_LIGHT_CONTROL_CHANGE |
|
352 SetLightsOnL(); |
|
353 } |
|
354 else |
|
355 { |
|
356 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
357 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EPowerKeyPressed ); |
|
358 #endif // RD_LIGHT_CONTROL_CHANGE |
|
359 } |
|
360 } |
|
361 |
|
362 // ---------------------------------------------------------------------------- |
|
363 // CSysApLightsController::SetGripOpenL( const TBool aOpen ) |
|
364 // ---------------------------------------------------------------------------- |
|
365 void CSysApLightsController::SetGripOpenL( const TBool aOpen ) |
|
366 { |
|
367 TRACES( RDebug::Print( _L("CSysApLightsController::SetGripOpenL( aOpen:%d )"), aOpen ) ); |
|
368 iGripOpen = aOpen; |
|
369 |
|
370 CancelLightsExplicitlyOffWithDelayL(); |
|
371 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
372 iLightPluginHandler->HandleEvent( SysApLightExtension::EGripOpenState, TPckgBuf<TBool>(aOpen) ); |
|
373 #endif // RD_LIGHT_CONTROL_CHANGE |
|
374 |
|
375 TurnOffInactiveTargetsL(); |
|
376 SetLightsOnL(); |
|
377 } |
|
378 |
|
379 // ---------------------------------------------------------------------------- |
|
380 // CSysApLightsController::SetFlipOpenL( const TBool aOpen ) |
|
381 // ---------------------------------------------------------------------------- |
|
382 void CSysApLightsController::SetFlipOpenL( const TBool aOpen ) |
|
383 { |
|
384 TRACES( RDebug::Print( _L("CSysApLightsController::SetFlipOpenL( aOpen:%d )"), aOpen ) ); |
|
385 |
|
386 SetFlipOpenNoLights( aOpen, EFalse ); |
|
387 |
|
388 CancelLightsExplicitlyOffWithDelayL(); |
|
389 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
390 iLightPluginHandler->HandleEvent( SysApLightExtension::EFlipOpenState, TPckgBuf<TBool>(aOpen) ); |
|
391 #endif // RD_LIGHT_CONTROL_CHANGE |
|
392 |
|
393 TurnOffInactiveTargetsL(); |
|
394 |
|
395 SetLightsOnL(); |
|
396 } |
|
397 |
|
398 // ---------------------------------------------------------------------------- |
|
399 // CSysApLightsController::SetSilentModeOn( const TBool aSilent ) |
|
400 // ---------------------------------------------------------------------------- |
|
401 |
|
402 void CSysApLightsController::SetSilentModeOn( const TBool aSilent ) |
|
403 { |
|
404 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
405 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ESilentMode, TPckgBuf<TBool>(aSilent) ); |
|
406 #endif // RD_LIGHT_CONTROL_CHANGE |
|
407 |
|
408 iSilent = aSilent; |
|
409 } |
|
410 |
|
411 // ---------------------------------------------------------------------------- |
|
412 // CSysApLightsController::HandleLightsRequireL( ) |
|
413 // ---------------------------------------------------------------------------- |
|
414 |
|
415 void CSysApLightsController::HandleLightsRequireL() |
|
416 { |
|
417 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleLightsRequireL" ) ) ); |
|
418 |
|
419 CancelLightsExplicitlyOffWithDelayL(); |
|
420 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
421 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsRequire ); |
|
422 #endif // RD_LIGHT_CONTROL_CHANGE |
|
423 |
|
424 SetLightsOnL(); |
|
425 } |
|
426 |
|
427 // ---------------------------------------------------------------------------- |
|
428 // CSysApLightsController::HandleRawKeyEventLightsRequireL |
|
429 // ---------------------------------------------------------------------------- |
|
430 void CSysApLightsController::HandleRawKeyEventLightsRequireL() |
|
431 { |
|
432 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleLightsRequireL" ) ) ); |
|
433 |
|
434 // This request comes from NspsWsPlugin via System Application Notification API |
|
435 if ( !iSysApAppUi.DeviceLockState() && !iSysApAppUi.KeyLockState() |
|
436 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
437 && iKeyEventsObserved |
|
438 #endif // RD_LIGHT_CONTROL_CHANGE |
|
439 ) |
|
440 { |
|
441 CancelLightsExplicitlyOffWithDelayL(); |
|
442 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
443 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsRequireRawKeyEvent ); |
|
444 #endif // RD_LIGHT_CONTROL_CHANGE |
|
445 SetLightsOnL(); |
|
446 } |
|
447 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
448 else |
|
449 { |
|
450 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsRequireRawKeyEvent ); |
|
451 } |
|
452 #endif // RD_LIGHT_CONTROL_CHANGE |
|
453 } |
|
454 |
|
455 // ---------------------------------------------------------------------------- |
|
456 // CSysApLightsController::HandleForcedLightsVTRequireL( const TInt aLightParameter ) |
|
457 // ---------------------------------------------------------------------------- |
|
458 |
|
459 void CSysApLightsController::HandleForcedLightsVTRequireL( const TInt aLightsParameter ) |
|
460 { |
|
461 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleForcedLightsVTRequireL: aLightsParameter: %d" ), aLightsParameter ) ); |
|
462 |
|
463 iForcedLightsOn = aLightsParameter != EForcedLightsOn ? EFalse : ETrue; |
|
464 |
|
465 CancelLightsExplicitlyOffWithDelayL(); |
|
466 |
|
467 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
468 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsForcedVideoTel, |
|
469 TPckgBuf<TBool>(aLightsParameter == EForcedLightsOn) ); |
|
470 #endif // RD_LIGHT_CONTROL_CHANGE |
|
471 |
|
472 if ( aLightsParameter != EForcedLightsOn) |
|
473 { |
|
474 ReleaseLight(); |
|
475 } |
|
476 else |
|
477 { |
|
478 ReserveLightL(); |
|
479 } |
|
480 |
|
481 SetLightsOnL(); |
|
482 } |
|
483 |
|
484 // ---------------------------------------------------------------------------- |
|
485 // CSysApLightsController::HandleForcedLightsSSRequireL( const TInt aLightParameter ) |
|
486 // ---------------------------------------------------------------------------- |
|
487 |
|
488 void CSysApLightsController::HandleForcedLightsSSRequireL( const TInt aLightsParameter ) |
|
489 { |
|
490 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleForcedLightsSSRequireL: aLightsParameter: %d" ), aLightsParameter ) ); |
|
491 |
|
492 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
493 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsForcedScreenSaver, |
|
494 TPckgBuf<TBool>(aLightsParameter > 0) ); |
|
495 #endif // RD_LIGHT_CONTROL_CHANGE |
|
496 |
|
497 if ( aLightsParameter == 0) |
|
498 { |
|
499 SetLightsOffL(); |
|
500 } |
|
501 else if ( aLightsParameter > 0 ) |
|
502 { |
|
503 SetDisplayLightsOnWithoutResettingInactivityTimersL(); |
|
504 iSysApTimer->ActivateTimerL( KMaxLightsOffPeriodForScreenSaverAnimation ); |
|
505 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
506 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOffTimerStart, |
|
507 TPckgBuf<TInt>( KMaxLightsOffPeriodForScreenSaverAnimation*KMilliSecondCoefficient ) ); |
|
508 #endif // RD_LIGHT_CONTROL_CHANGE |
|
509 } |
|
510 } |
|
511 |
|
512 // ---------------------------------------------------------------------------- |
|
513 // CSysApLightsController::HandleForcedLightsATCRequireL( const TInt aLightParameter ) |
|
514 // ---------------------------------------------------------------------------- |
|
515 void CSysApLightsController::HandleForcedLightsATCRequireL( const TInt aLightsParameter ) |
|
516 { |
|
517 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleForcedLightsATCRequireL: aLightsParameter: %d" ), aLightsParameter ) ); |
|
518 |
|
519 if ( aLightsParameter != EForcedLightsOn ) |
|
520 { |
|
521 TRACES( RDebug::Print( _L( "Cancel inactivity timer" ) ) ); |
|
522 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
523 iLightPluginHandler->HandleEvent( SysApLightExtension::EInactivityDetected ); |
|
524 #endif // RD_LIGHT_CONTROL_CHANGE |
|
525 SetLightsOffL(); |
|
526 } |
|
527 else |
|
528 { |
|
529 CancelLightsExplicitlyOffWithDelayL(); |
|
530 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
531 iLightPluginHandler->HandleEvent( SysApLightExtension::EActivityDetected ); |
|
532 #endif // RD_LIGHT_CONTROL_CHANGE |
|
533 SetLightsOnL(); |
|
534 } |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CSysApLightsController::DeviceLockStateChangedL() |
|
539 // ---------------------------------------------------------------------------- |
|
540 void CSysApLightsController::DeviceLockStateChangedL( TBool aEnabled ) |
|
541 { |
|
542 TRACES( RDebug::Print( _L( "CSysApLightsController::DeviceLockStateChangedL(): aEnabled=%d" ), aEnabled ) ); |
|
543 |
|
544 CancelLightsExplicitlyOffWithDelayL(); |
|
545 |
|
546 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
547 iLightPluginHandler->HandleEvent( SysApLightExtension::EDeviceLockState, TPckgBuf<TBool>(aEnabled) ); |
|
548 #endif // RD_LIGHT_CONTROL_CHANGE |
|
549 EnableActivityManagerL(aEnabled); |
|
550 |
|
551 if ( aEnabled ) |
|
552 { |
|
553 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
554 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); // complete previous event |
|
555 #endif // RD_LIGHT_CONTROL_CHANGE |
|
556 SetLightsExplicitlyOffWithDelayL(); |
|
557 } |
|
558 else |
|
559 { |
|
560 ReportUserActivity(); |
|
561 if ( !Alerting() ) |
|
562 { |
|
563 SetLightsOnL(); |
|
564 } |
|
565 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
566 else |
|
567 { |
|
568 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); // complete previous event |
|
569 } |
|
570 #endif // RD_LIGHT_CONTROL_CHANGE |
|
571 |
|
572 } |
|
573 } |
|
574 |
|
575 // ---------------------------------------------------------------------------- |
|
576 // CSysApLightsController::KeylockStateChangedL() |
|
577 // ---------------------------------------------------------------------------- |
|
578 void CSysApLightsController::KeylockStateChangedL( TBool aEnabled ) |
|
579 { |
|
580 TRACES( RDebug::Print( _L( "CSysApLightsController::KeylockStateChangedL(): aEnabled=%d" ), aEnabled ) ); |
|
581 |
|
582 CancelLightsExplicitlyOffWithDelayL(); |
|
583 |
|
584 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
585 iLightPluginHandler->HandleEvent( SysApLightExtension::EKeyLockState, TPckgBuf<TBool>(aEnabled) ); |
|
586 #endif // RD_LIGHT_CONTROL_CHANGE |
|
587 EnableActivityManagerL(aEnabled); |
|
588 |
|
589 if ( aEnabled ) |
|
590 { |
|
591 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
592 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); // complete previous event |
|
593 #endif // RD_LIGHT_CONTROL_CHANGE |
|
594 SetLightsExplicitlyOffWithDelayL(); |
|
595 } |
|
596 else |
|
597 { |
|
598 ReportUserActivity(); |
|
599 if ( !Alerting() ) |
|
600 { |
|
601 SetLightsOnL(); |
|
602 } |
|
603 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
604 else |
|
605 { |
|
606 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); // complete previous event |
|
607 } |
|
608 #endif // RD_LIGHT_CONTROL_CHANGE |
|
609 } |
|
610 } |
|
611 |
|
612 // ---------------------------------------------------------------------------- |
|
613 // CSysApLightsController::SwitchLightsOnSoftRejectL() |
|
614 // ---------------------------------------------------------------------------- |
|
615 |
|
616 void CSysApLightsController::SwitchLightsOnSoftRejectL() |
|
617 { |
|
618 TRACES( RDebug::Print( _L( "CSysApLightsController::SwitchLightsOnSoftRejectL()" ) ) ); |
|
619 |
|
620 ReportUserActivity(); |
|
621 |
|
622 // When soft reject is used in silent mode, the lights are set on because otherwise |
|
623 // blinking light disturb user when they are using phone UI |
|
624 if ( ( !iCallRinging || ( iCallRinging && iSilent ) ) |
|
625 && !iAlarmAlerting ) |
|
626 { |
|
627 CancelLightsExplicitlyOffWithDelayL(); |
|
628 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
629 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOnSoftReject ); |
|
630 #endif // RD_LIGHT_CONTROL_CHANGE |
|
631 SetLightsOnL(); |
|
632 } |
|
633 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
634 else |
|
635 { |
|
636 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOnSoftReject ); |
|
637 } |
|
638 #endif // RD_LIGHT_CONTROL_CHANGE |
|
639 } |
|
640 |
|
641 // ---------------------------------------------------------------------------- |
|
642 // CSysApLightsController::SetLightsExplicitlyOffWithDelayL() |
|
643 // ---------------------------------------------------------------------------- |
|
644 |
|
645 void CSysApLightsController::SetLightsExplicitlyOffWithDelayL() |
|
646 { |
|
647 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
648 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOffTimerStart, |
|
649 TPckgBuf<TInt>(KLightsOffPeriodLockJustActivated*KMilliSecondCoefficient) ); |
|
650 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
651 #endif // RD_LIGHT_CONTROL_CHANGE |
|
652 iSysApTimer->ActivateTimerL( KLightsOffPeriodLockJustActivated ); |
|
653 } |
|
654 |
|
655 // ---------------------------------------------------------------------------- |
|
656 // CSysApLightsController::CancelLightsExplicitlyOffWithDelayL() |
|
657 // ---------------------------------------------------------------------------- |
|
658 |
|
659 void CSysApLightsController::CancelLightsExplicitlyOffWithDelayL() |
|
660 { |
|
661 if ( iSysApTimer->IsActive() ) |
|
662 { |
|
663 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
664 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOffTimerStop, |
|
665 TPckgBuf<TBool>(EFalse) ); |
|
666 #endif // RD_LIGHT_CONTROL_CHANGE |
|
667 iSysApTimer->Cancel(); |
|
668 } |
|
669 } |
|
670 |
|
671 // ---------------------------------------------------------------------------- |
|
672 // CSysApLightsController::SetLightsOnUnlockNoteL() |
|
673 // ---------------------------------------------------------------------------- |
|
674 |
|
675 void CSysApLightsController::SetLightsOnUnlockNoteL() |
|
676 { |
|
677 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnUnlockNoteL()" ) ) ); |
|
678 |
|
679 if ( !Alerting() ) |
|
680 { |
|
681 CancelLightsExplicitlyOffWithDelayL(); |
|
682 |
|
683 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
684 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOnUnlockNote ); |
|
685 #endif // RD_LIGHT_CONTROL_CHANGE |
|
686 |
|
687 SetLightsOnL(); |
|
688 |
|
689 iSysApTimer->ActivateMsTimerL( KLightsOnUnlockNotePeriodMs ); |
|
690 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
691 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOffTimerStart, |
|
692 TPckgBuf<TBool>(KLightsOnUnlockNotePeriodMs) ); |
|
693 #endif // RD_LIGHT_CONTROL_CHANGE |
|
694 } |
|
695 else |
|
696 { |
|
697 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
698 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOnUnlockNote ); |
|
699 #endif // RD_LIGHT_CONTROL_CHANGE |
|
700 } |
|
701 } |
|
702 |
|
703 // ---------------------------------------------------------------------------- |
|
704 // CSysApLightsController::SetLightsOnEcsQueryL() |
|
705 // ---------------------------------------------------------------------------- |
|
706 |
|
707 void CSysApLightsController::SetLightsOnEcsQueryL() |
|
708 { |
|
709 TRACES( RDebug::Print( _L("CSysApLightsController::SetLightsOnEcsQueryL()") ) ); |
|
710 |
|
711 if ( !Alerting() ) |
|
712 { |
|
713 CancelLightsExplicitlyOffWithDelayL(); |
|
714 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
715 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOnEcsQuery ); |
|
716 #endif // RD_LIGHT_CONTROL_CHANGE |
|
717 SetLightsOnL(); |
|
718 } |
|
719 else |
|
720 { |
|
721 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
722 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOnEcsQuery ); |
|
723 #endif // RD_LIGHT_CONTROL_CHANGE |
|
724 } |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------------------------------- |
|
728 // CSysApLightsController::SetLightsOnSecurityQueryL() |
|
729 // ---------------------------------------------------------------------------- |
|
730 |
|
731 void CSysApLightsController::SetLightsOnSecurityQueryL() |
|
732 { |
|
733 TRACES( RDebug::Print( _L("CSysApLightsController::SetLightsOnSecurityQueryL()") ) ); |
|
734 |
|
735 if ( !Alerting() ) |
|
736 { |
|
737 CancelLightsExplicitlyOffWithDelayL(); |
|
738 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
739 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOnSecQuery ); |
|
740 #endif // RD_LIGHT_CONTROL_CHANGE |
|
741 SetLightsOnL(); |
|
742 } |
|
743 else |
|
744 { |
|
745 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
746 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::ELightsOnSecQuery ); |
|
747 #endif // RD_LIGHT_CONTROL_CHANGE |
|
748 } |
|
749 } |
|
750 |
|
751 // ---------------------------------------------------------------------------- |
|
752 // CSysApLightsController::DoLightsTimeoutChangedL() |
|
753 // ---------------------------------------------------------------------------- |
|
754 |
|
755 void CSysApLightsController::DoLightsTimeoutChangedL( const TInt aTimeout ) |
|
756 { |
|
757 TRACES( RDebug::Print( _L( "CSysApLightsController::DoLightsTimeoutChangedL(): aTimeout=%d" ), aTimeout ) ); |
|
758 |
|
759 if ( aTimeout < KMinimumLightsTimeout ) |
|
760 { |
|
761 iLightsTimeout = KMinimumLightsTimeout; |
|
762 } |
|
763 else if ( aTimeout > KMaximumLightsTimeout ) |
|
764 { |
|
765 iLightsTimeout = KMaximumLightsTimeout; |
|
766 } |
|
767 else |
|
768 { |
|
769 iLightsTimeout = aTimeout; |
|
770 } |
|
771 |
|
772 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
773 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EInactivityTimeoutChanged, |
|
774 TPckgBuf<TInt>(iLightsTimeout*KMilliSecondCoefficient) ); |
|
775 #endif // RD_LIGHT_CONTROL_CHANGE |
|
776 |
|
777 EnableActivityManagerL(); // activity manager reset |
|
778 } |
|
779 |
|
780 // ---------------------------------------------------------------------------- |
|
781 // CSysApLightsController::EnableActivityManagerL() |
|
782 // ---------------------------------------------------------------------------- |
|
783 |
|
784 void CSysApLightsController::EnableActivityManagerL() |
|
785 { |
|
786 TRACES( RDebug::Print( _L( "CSysApLightsController::EnableActivityManager: lights timeout: %d sec" ), iLightsTimeout ) ); |
|
787 if ( iActivityManager ) |
|
788 { |
|
789 DisableActivityManager(); |
|
790 } |
|
791 iActivityManager = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
792 iActivityManager->Start( iLightsTimeout, |
|
793 TCallBack( HandleInactiveEventL, this ), |
|
794 TCallBack( HandleActiveEventL, this ) ); |
|
795 } |
|
796 |
|
797 // ---------------------------------------------------------------------------- |
|
798 // CSysApLightsController::EnableActivityManagerL(TBool aIsLocked) |
|
799 // ---------------------------------------------------------------------------- |
|
800 |
|
801 void CSysApLightsController::EnableActivityManagerL(TBool aIsLocked) |
|
802 { |
|
803 TRACES( RDebug::Print( _L( "CSysApLightsController::EnableActivityManager: isLocked: %d " ), aIsLocked ) ); |
|
804 if ( iActivityManager ) |
|
805 { |
|
806 DisableActivityManager(); |
|
807 } |
|
808 iActivityManager = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
809 if(aIsLocked) |
|
810 { |
|
811 iActivityManager->Start( KMinimumLightsTimeout, |
|
812 TCallBack( HandleInactiveEventL, this ), |
|
813 TCallBack( HandleActiveEventL, this ) ); |
|
814 TRACES( RDebug::Print( _L( "CSysApLightsController::EnableActivityManager: locked: lights timeout: %d sec" ), |
|
815 KMinimumLightsTimeout ) ); |
|
816 } |
|
817 else |
|
818 { |
|
819 iActivityManager->Start( iLightsTimeout , |
|
820 TCallBack( HandleInactiveEventL, this ), |
|
821 TCallBack( HandleActiveEventL, this ) ); |
|
822 TRACES( RDebug::Print( _L( "CSysApLightsController::EnableActivityManager: not locked: lights timeout: %d sec" ), |
|
823 iLightsTimeout ) ); |
|
824 } |
|
825 } |
|
826 |
|
827 // ---------------------------------------------------------------------------- |
|
828 // CSysApLightsController::DisableActivityManager() |
|
829 // ---------------------------------------------------------------------------- |
|
830 |
|
831 void CSysApLightsController::DisableActivityManager() |
|
832 { |
|
833 TRACES( RDebug::Print( _L( "CSysApLightsController::DisableActivityManager()" ) ) ); |
|
834 if ( iActivityManager ) |
|
835 { |
|
836 iActivityManager->Cancel(); |
|
837 delete iActivityManager; |
|
838 iActivityManager = NULL; |
|
839 } |
|
840 } |
|
841 |
|
842 // ---------------------------------------------------------------------------- |
|
843 // TInt CSysApLightsController::HandleActiveEventL( TAny* aPtr ) |
|
844 // ---------------------------------------------------------------------------- |
|
845 |
|
846 TInt CSysApLightsController::HandleActiveEventL( TAny* aPtr ) |
|
847 { |
|
848 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleActiveEvent" ) ) ); |
|
849 |
|
850 CSysApLightsController* lightsController = static_cast<CSysApLightsController*>(aPtr); |
|
851 |
|
852 lightsController->iInactivityDetected = EFalse; |
|
853 |
|
854 if ( !lightsController->Alerting() && !lightsController->iForcedLightsOn ) |
|
855 { |
|
856 TBool locked = lightsController->iSysApAppUi.DeviceLockState() |
|
857 || lightsController->iSysApAppUi.KeyLockState(); |
|
858 |
|
859 if ( !locked ) |
|
860 { |
|
861 lightsController->CancelLightsExplicitlyOffWithDelayL(); |
|
862 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
863 lightsController->iLightPluginHandler->HandleEvent( SysApLightExtension::EActivityDetected ); |
|
864 #endif // RD_LIGHT_CONTROL_CHANGE |
|
865 lightsController->SetLightsOnL(); |
|
866 return KErrNone; |
|
867 } |
|
868 else if ( lightsController->iSysApAppUi.SysApFeatureManager().LockedStateLightsSupported() ) |
|
869 { |
|
870 // lights on only if they are not already on |
|
871 if ( !lightsController->iLightsCurrentlyOn ) |
|
872 { |
|
873 lightsController->CancelLightsExplicitlyOffWithDelayL(); |
|
874 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
875 lightsController->iLightPluginHandler->HandleEvent( SysApLightExtension::EActivityDetected ); |
|
876 #endif // RD_LIGHT_CONTROL_CHANGE |
|
877 lightsController->SetLockedStatePrimaryLightsL(); |
|
878 return KErrNone; |
|
879 } |
|
880 } |
|
881 } |
|
882 |
|
883 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
884 lightsController->iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EActivityDetected ); |
|
885 #endif // RD_LIGHT_CONTROL_CHANGE |
|
886 |
|
887 |
|
888 return KErrNone; |
|
889 } |
|
890 |
|
891 // ---------------------------------------------------------------------------- |
|
892 // TInt CSysApLightsController::HandleInactiveEventL( TAny* aPtr ) |
|
893 // ---------------------------------------------------------------------------- |
|
894 |
|
895 TInt CSysApLightsController::HandleInactiveEventL( TAny* aPtr ) |
|
896 { |
|
897 TRACES( RDebug::Print( _L( "CSysApLightsController::HandleInactiveEvent" ) ) ); |
|
898 |
|
899 CSysApLightsController* lightsController = STATIC_CAST( CSysApLightsController*, aPtr ); |
|
900 |
|
901 lightsController->iInactivityDetected = ETrue; |
|
902 |
|
903 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
904 lightsController->iLightPluginHandler->HandleEvent( SysApLightExtension::EInactivityDetected ); |
|
905 #endif // RD_LIGHT_CONTROL_CHANGE |
|
906 |
|
907 if ( !lightsController->Alerting() && !lightsController->iForcedLightsOn ) |
|
908 { |
|
909 lightsController->SetLightsOffL(); |
|
910 } |
|
911 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
912 else |
|
913 { |
|
914 lightsController->iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
915 } |
|
916 #endif // RD_LIGHT_CONTROL_CHANGE |
|
917 |
|
918 return KErrNone; |
|
919 } |
|
920 |
|
921 // ---------------------------------------------------------------------------- |
|
922 // CSysApLightsController::ReportUserActivity() |
|
923 // ---------------------------------------------------------------------------- |
|
924 |
|
925 void CSysApLightsController::ReportUserActivity() const |
|
926 { |
|
927 TRACES( RDebug::Print( _L( "CSysApLightsController::ReportUserActivity" ) ) ); |
|
928 User::ResetInactivityTime(); |
|
929 } |
|
930 |
|
931 // ---------------------------------------------------------------------------- |
|
932 // CSysApLightsController::BatteryEmptyL() |
|
933 // ---------------------------------------------------------------------------- |
|
934 void CSysApLightsController::BatteryEmptyL( TBool aEmpty ) |
|
935 { |
|
936 TRACES( RDebug::Print( _L( "CSysApLightsController::BatteryEmptyL: aEmpty=%d" ), aEmpty ) ); |
|
937 iBatteryEmpty = aEmpty; |
|
938 |
|
939 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
940 iLightPluginHandler->HandleEvent( SysApLightExtension::EBatteryEmptyState, TPckgBuf<TBool>(aEmpty) ); |
|
941 #endif // RD_LIGHT_CONTROL_CHANGE |
|
942 |
|
943 if ( aEmpty ) |
|
944 { |
|
945 SetLightsOffL(); |
|
946 } |
|
947 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
948 else |
|
949 { |
|
950 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
951 } |
|
952 #endif // RD_LIGHT_CONTROL_CHANGE |
|
953 } |
|
954 |
|
955 // ---------------------------------------------------------------------------- |
|
956 // CSysApLightsController::SetLightsOffL() |
|
957 // ---------------------------------------------------------------------------- |
|
958 |
|
959 void CSysApLightsController::SetLightsOffL() |
|
960 { |
|
961 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL: iBatteryEmpty=%d, iLightsCurrentlyOn=%d, iForcedLightsOn=%d" ), |
|
962 iBatteryEmpty, iLightsCurrentlyOn, iForcedLightsOn ) ); |
|
963 |
|
964 if ( !iBatteryEmpty && iForcedLightsOn ) |
|
965 { |
|
966 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
967 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
968 #endif // RD_LIGHT_CONTROL_CHANGE |
|
969 return; |
|
970 } |
|
971 |
|
972 TInt err(KErrNone); |
|
973 |
|
974 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
975 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
|
976 { |
|
977 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
|
978 } |
|
979 #else // RD_LIGHT_CONTROL_CHANGE |
|
980 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
|
981 #endif // RD_LIGHT_CONTROL_CHANGE |
|
982 // Ignore unreserved in use warnings. |
|
983 if ( err != KErrNone && err != KErrInUse ) |
|
984 { |
|
985 // Only trace as leaving here accomplishes nothing. |
|
986 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL failed: err: %d" ), err ) ); |
|
987 } |
|
988 iLightsCurrentlyOn = EFalse; |
|
989 |
|
990 #ifdef __SYSAP_MODULE_TEST |
|
991 iSysApAppUi.Beep(); |
|
992 #endif |
|
993 |
|
994 #ifndef RD_LIGHT_CONTROL_CHANGE |
|
995 iSysApAppUi.ActivateKeyeventForwardingForLights(ETrue); |
|
996 #else // RD_LIGHT_CONTROL_CHANGE |
|
997 iKeyEventsObserved = ETrue; |
|
998 #endif // RD_LIGHT_CONTROL_CHANGE |
|
999 |
|
1000 if ( iSysApAppUi.SysApFeatureManager().LockedStateLightsSupported() ) |
|
1001 { |
|
1002 // If low intensity lights are supported in locked state, then the lights must be set on with low intensity |
|
1003 // as until active timeout has been reached |
|
1004 // Otherwise we may end up into a situation where lights are not lit because activity cannot be detected without first entering |
|
1005 // inactive state |
|
1006 if ( !iInactivityDetected ) // inactivity not yet detected, so use small intensity lights |
|
1007 { |
|
1008 TBool locked = iSysApAppUi.DeviceLockState() || iSysApAppUi.KeyLockState(); |
|
1009 |
|
1010 if ( locked ) // applied only if the device is in locked state |
|
1011 { |
|
1012 SetLockedStatePrimaryLightsL(); |
|
1013 } |
|
1014 } |
|
1015 } |
|
1016 } |
|
1017 |
|
1018 // ---------------------------------------------------------------------------- |
|
1019 // CSysApLightsController::SetLightsOnL() |
|
1020 // ---------------------------------------------------------------------------- |
|
1021 |
|
1022 void CSysApLightsController::SetLightsOnL( TBool aBlinking ) |
|
1023 { |
|
1024 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL: aBlinking=%d, iGripOpen=%d, iFlipOpen=%d" ), |
|
1025 aBlinking, iGripOpen, iFlipOpen ) ); |
|
1026 |
|
1027 ReportUserActivity(); |
|
1028 |
|
1029 if( iBatteryEmpty ) |
|
1030 { |
|
1031 SetLightsOffL(); |
|
1032 return; |
|
1033 } |
|
1034 |
|
1035 #ifndef RD_LIGHT_CONTROL_CHANGE |
|
1036 // Deactivate raw keyevent forwarding as those are only interesting when lights are off due inactivity. |
|
1037 iSysApAppUi.ActivateKeyeventForwardingForLights(EFalse); |
|
1038 #else // RD_LIGHT_CONTROL_CHANGE |
|
1039 iKeyEventsObserved = EFalse; |
|
1040 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1041 |
|
1042 TInt err(KErrNone); |
|
1043 |
|
1044 if ( aBlinking ) |
|
1045 { |
|
1046 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS BLINK" ) ) ); |
|
1047 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1048 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandBlink ) ) |
|
1049 { |
|
1050 TRAP(err, iLight->LightBlinkL(CHWRMLight::ESystemTarget)); |
|
1051 } |
|
1052 #else // RD_LIGHT_CONTROL_CHANGE |
|
1053 TRAP(err, iLight->LightBlinkL(CHWRMLight::ESystemTarget)); |
|
1054 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1055 // Do not remember this lights on, if lights were set to blink (as next normal lights on must be done anyway) |
|
1056 iLightsCurrentlyOn = EFalse; |
|
1057 } |
|
1058 else |
|
1059 { |
|
1060 // Filter excess consequtive lights on calls within short time period as they are likely to be caused by same event. |
|
1061 TTime now; |
|
1062 now.HomeTime(); |
|
1063 |
|
1064 if ( !iLightsCurrentlyOn || ( iAllowLightsOn && (iLastLightsOnTime <= now - TTimeIntervalSeconds(KLightsOnRepeatMinPeriod) ) ) |
|
1065 || Alerting() ) |
|
1066 { |
|
1067 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON" ) ) ); |
|
1068 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1069 if ( iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOn ) ) |
|
1070 { |
|
1071 return; |
|
1072 } |
|
1073 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1074 TRAP(err, iLight->LightOnL(CHWRMLight::ESystemTarget)); |
|
1075 |
|
1076 if ( err == KErrNone ) |
|
1077 { |
|
1078 iLightsCurrentlyOn = ETrue; |
|
1079 iLastLightsOnTime.HomeTime(); |
|
1080 } |
|
1081 } |
|
1082 else |
|
1083 { |
|
1084 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) ); |
|
1085 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1086 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
1087 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 if ( err != KErrNone ) |
|
1092 { |
|
1093 // Only trace as leaving here accomplishes nothing. |
|
1094 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL failed: err: %d" ), err ) ); |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 // ---------------------------------------------------------------------------- |
|
1099 // CSysApLightsController::SetDisplayLightsOnWithoutResettingInactivityTimersL() |
|
1100 // ---------------------------------------------------------------------------- |
|
1101 |
|
1102 void CSysApLightsController::SetDisplayLightsOnWithoutResettingInactivityTimersL() |
|
1103 { |
|
1104 if( iBatteryEmpty ) |
|
1105 { |
|
1106 SetLightsOffL(); |
|
1107 return; |
|
1108 } |
|
1109 |
|
1110 TInt err(KErrNone); |
|
1111 |
|
1112 TRACES( RDebug::Print( _L( "CSysApLightsController::SetDisplayLightsOnWithoutResettingInactivityTimersL LIGHTS ON" ) ) ); |
|
1113 |
|
1114 TTime now; |
|
1115 now.HomeTime(); |
|
1116 if ( !iLightsCurrentlyOn || ( iAllowLightsOn && (iLastLightsOnTime <= now - TTimeIntervalSeconds(KLightsOnRepeatMinPeriod) ) ) ) |
|
1117 { |
|
1118 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1119 if ( iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOn ) ) |
|
1120 { |
|
1121 return; |
|
1122 } |
|
1123 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1124 TRAP(err, iLight->LightOnL(CHWRMLight::ESystemTarget)); |
|
1125 |
|
1126 if ( err != KErrNone ) |
|
1127 { |
|
1128 // Only trace as leaving here accomplishes nothing. |
|
1129 TRACES( RDebug::Print( _L( "CSysApLightsController::SetDisplayLightsOnWithoutResettingInactivityTimersL failed err: %d" ), err ) ); |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 iLightsCurrentlyOn = ETrue; |
|
1134 iLastLightsOnTime.HomeTime(); |
|
1135 } |
|
1136 } |
|
1137 else |
|
1138 { |
|
1139 TRACES( RDebug::Print( _L( "CSysApLightsController::SetDisplayLightsOnWithoutResettingInactivityTimersL - LIGHTS ON denied - Not necessary" ) ) ); |
|
1140 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1141 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
1142 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1143 } |
|
1144 } |
|
1145 |
|
1146 // ---------------------------------------------------------------------------- |
|
1147 // CSysApLightsController::TimerExpiredL() |
|
1148 // ---------------------------------------------------------------------------- |
|
1149 |
|
1150 void CSysApLightsController::TimerExpiredL() |
|
1151 { |
|
1152 TRACES( RDebug::Print( _L( "CSysApLightsController::TimerExpiredL" ) ) ); |
|
1153 |
|
1154 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1155 iLightPluginHandler->HandleEvent( SysApLightExtension::ELightsOffTimerStop, TPckgBuf<TBool>(ETrue) ); |
|
1156 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1157 |
|
1158 SetLightsOffL(); |
|
1159 } |
|
1160 |
|
1161 // ---------------------------------------------------------------------------- |
|
1162 // CSysApLightsController::ReserveLightL() |
|
1163 // ---------------------------------------------------------------------------- |
|
1164 |
|
1165 void CSysApLightsController::ReserveLightL() |
|
1166 { |
|
1167 TRACES( RDebug::Print( _L( "CSysApLightsController::ReserveLightL: iReserved=%d" ), iReserved ) ); |
|
1168 |
|
1169 if ( !iReserved ) |
|
1170 { |
|
1171 iLight->ReserveLightL( CHWRMLight::ESystemTarget, EFalse, ETrue); |
|
1172 iReserved = ETrue; |
|
1173 } |
|
1174 } |
|
1175 |
|
1176 // ---------------------------------------------------------------------------- |
|
1177 // CSysApLightsController::ReleaseLight() |
|
1178 // ---------------------------------------------------------------------------- |
|
1179 |
|
1180 void CSysApLightsController::ReleaseLight() |
|
1181 { |
|
1182 TRACES( RDebug::Print( _L( "CSysApLightsController::ReleaseLight(): iCallRinging=%d, iAlarmAlerting=%d, iForcedLightsOn=%d" ), |
|
1183 iCallRinging, iAlarmAlerting, iForcedLightsOn ) ); |
|
1184 |
|
1185 if ( !Alerting() && !iForcedLightsOn) |
|
1186 { |
|
1187 iLight->ReleaseLight(CHWRMLight::ESystemTarget); |
|
1188 iReserved = EFalse; |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 // ---------------------------------------------------------------------------- |
|
1193 // CSysApLightsController::AllowLightsOn() |
|
1194 // ---------------------------------------------------------------------------- |
|
1195 |
|
1196 void CSysApLightsController::AllowLightsOn() |
|
1197 { |
|
1198 TRACES( RDebug::Print( _L( "CSysApLightsController::AllowLightsOn: iAllowLightsOn=%d" ), iAllowLightsOn ) ); |
|
1199 |
|
1200 iAllowLightsOn = ETrue; |
|
1201 |
|
1202 } |
|
1203 |
|
1204 // ---------------------------------------------------------------------------- |
|
1205 // CSysApLightsController::SetFlipOpenNoLights( const TBool aOpen, const TBool aFetchFlipStatus ) |
|
1206 // ---------------------------------------------------------------------------- |
|
1207 void CSysApLightsController::SetFlipOpenNoLights( const TBool aOpen, const TBool aFetchFlipStatus ) |
|
1208 { |
|
1209 // if aReadFlipStatus is ETrue, aOpen is ignored and flip status is read directly from P&S key |
|
1210 TRACES( RDebug::Print( _L("CSysApLightsController::SetFlipOpenNoLights( aOpen:%d, aFetchFlipStatus:%d )"), |
|
1211 aOpen, aFetchFlipStatus ) ); |
|
1212 if ( aFetchFlipStatus ) |
|
1213 { |
|
1214 TInt err; |
|
1215 TInt flipStatus; |
|
1216 err = RProperty::Get( KPSUidHWRM, KHWRMFlipStatus, flipStatus ); |
|
1217 if ( err ) |
|
1218 { |
|
1219 TRACES( RDebug::Print( _L("CSysApLightsController::SetFlipOpenNoLights. RProperty::Get: err=%d."), err ) ); |
|
1220 return; |
|
1221 } |
|
1222 if ( flipStatus == EPSHWRMFlipOpen || flipStatus == EPSHWRMFlipStatusUninitialized ) |
|
1223 { |
|
1224 iFlipOpen = ETrue; |
|
1225 } |
|
1226 TRACES( RDebug::Print( _L("CSysApLightsController::SetFlipOpenNoLights: KHWRMFlipStatus read, flipStatus=%d"), flipStatus ) ); |
|
1227 } |
|
1228 else |
|
1229 { |
|
1230 iFlipOpen = aOpen; |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 |
|
1235 // ---------------------------------------------------------------------------- |
|
1236 // CSysApLightsController::TurnOffInactiveTargetsL |
|
1237 // ---------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CSysApLightsController::TurnOffInactiveTargetsL() |
|
1240 { |
|
1241 TRACES( RDebug::Print( _L("CSysApLightsController::TurnOffInactiveTargetsL: iFlipOpen=%d, iGripOpen=%d, iCoverDisplaySupported=%d"), |
|
1242 iFlipOpen, iGripOpen, iCoverDisplaySupported ) ); |
|
1243 |
|
1244 TInt turnoffTarget = CHWRMLight::ENoTarget; |
|
1245 |
|
1246 // Then turn off inactive lights depending on device configuration |
|
1247 // Flip state is interesting only when cover display is supported |
|
1248 if ( iCoverDisplaySupported ) |
|
1249 { |
|
1250 if ( iFlipOpen ) |
|
1251 { |
|
1252 turnoffTarget = CHWRMLight::ESecondaryDisplayAndKeyboard; |
|
1253 } |
|
1254 else |
|
1255 { |
|
1256 turnoffTarget = CHWRMLight::EPrimaryDisplayAndKeyboard; |
|
1257 } |
|
1258 } |
|
1259 else |
|
1260 { |
|
1261 if ( !iFlipOpen ) |
|
1262 { |
|
1263 turnoffTarget = CHWRMLight::EPrimaryKeyboard; |
|
1264 } |
|
1265 } |
|
1266 |
|
1267 if ( iGripOpen ) |
|
1268 { |
|
1269 // No action, grip is open or not supported |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 turnoffTarget |= CHWRMLight::EPrimaryKeyboard; |
|
1274 } |
|
1275 |
|
1276 // Don't try to turn off unsupported targets |
|
1277 turnoffTarget &= iLight->SupportedTargets(); |
|
1278 |
|
1279 if ( turnoffTarget != CHWRMLight::ENoTarget ) |
|
1280 { |
|
1281 TRACES( RDebug::Print( _L("CSysApLightsController::TurnOffInactiveTargetsL: turnoffTarget=0x%x"), turnoffTarget ) ); |
|
1282 |
|
1283 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1284 if ( iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
|
1285 { |
|
1286 iLightsCurrentlyOn = EFalse; // ensure that forthcoming commands set lights on |
|
1287 return; |
|
1288 } |
|
1289 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1290 |
|
1291 TRAPD(err, iLight->LightOffL( turnoffTarget, KHWRMInfiniteDuration, EFalse ) ); |
|
1292 |
|
1293 if ( err != KErrNone ) |
|
1294 { |
|
1295 TRACES( RDebug::Print(_L("CSysApLightsController::TurnOffInactiveTargetsL: Turning off inactive targets failed") ) ); |
|
1296 } |
|
1297 } |
|
1298 |
|
1299 iLightsCurrentlyOn = EFalse; |
|
1300 } |
|
1301 |
|
1302 |
|
1303 // ---------------------------------------------------------------------------- |
|
1304 // CSysApLightsController::SetLockedStatePrimaryLightsL() |
|
1305 // ---------------------------------------------------------------------------- |
|
1306 |
|
1307 void CSysApLightsController::SetLockedStatePrimaryLightsL() |
|
1308 { |
|
1309 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLockedStatePrimaryLightsL" ) ) ); |
|
1310 |
|
1311 TInt err(KErrNone); |
|
1312 |
|
1313 TInt target = ResolveLockedStateLightTarget(); |
|
1314 |
|
1315 // Turn lights on if allowed by CSysApAppUi (to reduce boottime calls). |
|
1316 if ( iAllowLightsOn && (target != CHWRMLight::ENoTarget) ) |
|
1317 { |
|
1318 TInt intensity = iSysApAppUi.SysApFeatureManager().LockedStateLightsIntensity(); |
|
1319 |
|
1320 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLockedStatePrimaryLightsL - LIGHTS ON: target=%d intensity=%d"), target, intensity ) ); |
|
1321 |
|
1322 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1323 if ( iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOn ) ) |
|
1324 { |
|
1325 return; |
|
1326 } |
|
1327 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1328 TRAP(err, iLight->LightOnL( CHWRMLight::ESystemTarget, // always use system target, resolved target is used only for denying light command |
|
1329 KHWRMInfiniteDuration, |
|
1330 intensity, |
|
1331 ETrue ) ); |
|
1332 } |
|
1333 else |
|
1334 { |
|
1335 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLockedStatePrimaryLightsL LIGHTS ON denied - Not necessary" ) ) ); |
|
1336 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1337 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
|
1338 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1339 } |
|
1340 |
|
1341 |
|
1342 } |
|
1343 |
|
1344 // ---------------------------------------------------------------------------- |
|
1345 // CSysApLightsController::ResolveLockedStateLightTarget() |
|
1346 // ---------------------------------------------------------------------------- |
|
1347 |
|
1348 TInt CSysApLightsController::ResolveLockedStateLightTarget() const |
|
1349 { |
|
1350 TRACES( RDebug::Print( _L( "CSysApLightsController::ResolveLockedStateLightTarget" ) ) ); |
|
1351 |
|
1352 // This is a bit questionable whether SysAp should take any considerations about the target now when |
|
1353 // system target is in use. However, alternative way would be to define a new API into HWRM for handling this situation. |
|
1354 TInt target(CHWRMLight::ESystemTarget); // always allow system target, except when a device with Cover UI has flip closed |
|
1355 |
|
1356 if ( iCoverDisplaySupported && !iFlipOpen ) |
|
1357 { |
|
1358 target = CHWRMLight::ENoTarget; |
|
1359 } |
|
1360 |
|
1361 return target; |
|
1362 } |
|
1363 |
|
1364 // ---------------------------------------------------------------------------- |
|
1365 // CSysApLightsController::GetHwrmLight() |
|
1366 // ---------------------------------------------------------------------------- |
|
1367 // |
|
1368 CHWRMLight* CSysApLightsController::GetHwrmLight() |
|
1369 { |
|
1370 return iLight; |
|
1371 } |
|
1372 |
|
1373 // ---------------------------------------------------------------------------- |
|
1374 // CSysApLightsController::Alerting() |
|
1375 // The device is alerting, either due to a call or an alarm |
|
1376 // ---------------------------------------------------------------------------- |
|
1377 // |
|
1378 TBool CSysApLightsController::Alerting() const |
|
1379 { |
|
1380 return iAlarmAlerting || iCallRinging; |
|
1381 } |
|
1382 |
|
1383 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
1384 // ---------------------------------------------------------------------------- |
|
1385 // CSysApLightsController::KeyEventForwardingReady() |
|
1386 // |
|
1387 // ---------------------------------------------------------------------------- |
|
1388 // |
|
1389 void CSysApLightsController::KeyEventForwardingReady() |
|
1390 { |
|
1391 iSysApAppUi.ActivateKeyeventForwardingForLights( ETrue ); |
|
1392 } |
|
1393 #endif // RD_LIGHT_CONTROL_CHANGE |
|
1394 |
|
1395 // End of File |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |