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: Keyguard UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappkeyguardcontrol.h" |
|
20 #include "lockappstatecontrolinterface.h" |
|
21 #include "lockappcenrepobserver.h" |
|
22 #include "lockapppubsubobserver.h" |
|
23 #include "lockapputils.h" |
|
24 #include "lockapplockednote.h" // keyguard notes |
|
25 #include "lockappkeycapturecontroller.h" |
|
26 |
|
27 #include <avkon.rsg> // general avkon resources |
|
28 #include <aknnotpi.rsg> // keyguard spesific resources |
|
29 #include <AknUtils.h> |
|
30 #include <activitymanager.h> |
|
31 // this is not needed |
|
32 // #include <SecondaryDisplay/AknSecondaryDisplayDefs.h> // publishing keyguard notes to secondary display |
|
33 #include <featmgr.h> // feature manager |
|
34 #include <eikcba.h> // keyguard soft buttons |
|
35 #include <eikspane.h> |
|
36 |
|
37 #include "AutolockPrivateCRKeys.h" |
|
38 #include <settingsinternalcrkeys.h> |
|
39 #include <ScreensaverInternalPSKeys.h> |
|
40 #include <hwrmdomainpskeys.h> |
|
41 #include <activeidle2domainpskeys.h> |
|
42 //#include <CoreApplicationUIsPrivateCRKeys.h> TODO remove |
|
43 #include <coreapplicationuisdomainpskeys.h> |
|
44 #include <ctsydomainpskeys.h> |
|
45 #include <startupdomainpskeys.h> |
|
46 |
|
47 // Asterisk key's scan code for the keylock |
|
48 const TUint KStdKeyAsterisk = 42; |
|
49 //const TUint KAknChineseAsterisk = 0xFF0A; |
|
50 |
|
51 // timeout defined in keyguard ui specification custom value |
|
52 // since avkon note TTimeout values don't support 1 second timeout |
|
53 const TInt KKeyLockCustomShortTimeout = 1000000; |
|
54 |
|
55 // Auto Keyguard Off value |
|
56 const TInt KAutoKeyguardOff( 60000 ); |
|
57 |
|
58 // Flip open value |
|
59 const TInt KFlipOpen = 1; |
|
60 |
|
61 // Screensaver started fron idle status value |
|
62 const TInt KSsStartedFromIdle = 1; |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Standard Symbian OS construction sequence |
|
66 // --------------------------------------------------------------------------- |
|
67 CLockAppKeyguardControl* CLockAppKeyguardControl::NewL(MLockAppStateControl& aStateControl ) |
|
68 { |
|
69 CLockAppKeyguardControl* self = new (ELeave) CLockAppKeyguardControl( aStateControl ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL( ); |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Notes, cba and localized resources are freed in Keyguard UI destruction. |
|
78 // --------------------------------------------------------------------------- |
|
79 CLockAppKeyguardControl::~CLockAppKeyguardControl( ) |
|
80 { |
|
81 #ifdef RD_AUTO_KEYGUARD |
|
82 if ( iActivityManager ) |
|
83 { |
|
84 iActivityManager->Cancel( ); |
|
85 delete iActivityManager; |
|
86 iActivityManager = NULL; |
|
87 } |
|
88 // CenRep observers |
|
89 if ( iCRAutoKeyguardTime ) |
|
90 { |
|
91 delete iCRAutoKeyguardTime; |
|
92 iCRAutoKeyguardTime = NULL; |
|
93 } |
|
94 #endif //RD_AUTO_KEYGUARD |
|
95 if ( iCRPersistentKeyguardStatus ) |
|
96 { |
|
97 delete iCRPersistentKeyguardStatus; |
|
98 iCRPersistentKeyguardStatus = NULL; |
|
99 } |
|
100 if ( iPSStartupObserver ) |
|
101 { |
|
102 delete iPSStartupObserver; |
|
103 iPSStartupObserver = NULL; |
|
104 } |
|
105 // child notes |
|
106 delete iConfirmationNote; |
|
107 delete iLockedNote; |
|
108 delete iKeypadUnlockedNote; |
|
109 delete iKeypadLockedNote; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Constructor passes the reference to the main state control. |
|
114 // --------------------------------------------------------------------------- |
|
115 CLockAppKeyguardControl::CLockAppKeyguardControl(MLockAppStateControl& aStateControl ) : |
|
116 CLockAppBaseControl(aStateControl) |
|
117 { |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Keyguard UI constructor reserves localized resources, configures itself |
|
122 // using CenRep and FeatureManager and reserves child controls. |
|
123 // --------------------------------------------------------------------------- |
|
124 void CLockAppKeyguardControl::ConstructL( ) |
|
125 { |
|
126 INFO( "CLockAppKeyguardControl::ConstructL started" ); |
|
127 CLockAppBaseControl::ConstructL( ); |
|
128 |
|
129 // feature manager is used for determining if the phone is a slider |
|
130 TBool aFeatureKeypadNoSlider(ETrue); |
|
131 FeatureManager::InitializeLibL( ); |
|
132 aFeatureKeypadNoSlider = FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider ); |
|
133 INFO_1("CLockAppKeyguardControl::ConstructL - aFeatureKeypadNoSlider: %d", aFeatureKeypadNoSlider); |
|
134 FeatureManager::UnInitializeLib( ); |
|
135 |
|
136 // keyguard hardware switch support |
|
137 CRepository* repository = CRepository::NewLC( KCRUidLockConf ); |
|
138 TInt hardwareSupport(0); |
|
139 repository->Get( KKeyguardHardwareConf, hardwareSupport ); |
|
140 CleanupStack::PopAndDestroy( repository ); |
|
141 iHardwareSupport = TLockHardware( hardwareSupport ); |
|
142 iHardwareSupport = TLockHardware( 0 ); |
|
143 |
|
144 TBool touchEnabled( AknLayoutUtils::PenEnabled() ); |
|
145 |
|
146 // Cba control |
|
147 iCba = CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::ECba, |
|
148 CEikButtonGroupContainer::EHorizontal, |
|
149 this, |
|
150 touchEnabled ? R_AVKON_SOFTKEYS_EMPTY : |
|
151 R_KEYLOCK_SOFTKEYS_UNLOCK_EMPTY ); |
|
152 TRect screenRect; |
|
153 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
154 iCba->SetBoundingRect( screenRect ); |
|
155 iCba->MakeVisible( EFalse ); |
|
156 |
|
157 // Construct Keyguard Notes |
|
158 iKeypadLockedNote = new (ELeave) CLockAppLockedNote(); |
|
159 iKeypadLockedNote->ConstructSleepingNoteL( touchEnabled ? R_KEYLOCK_NOTE_DISPLAY_LOCK_ON_TOUCH : |
|
160 R_KEYLOCK_NOTE_LOCK_ON ); |
|
161 iKeypadLockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 ); |
|
162 // this is not needed |
|
163 // iKeypadLockedNote->PublishDialogL( EAknKeysLockedNote ); |
|
164 |
|
165 iKeypadUnlockedNote = new (ELeave) CLockAppLockedNote(); |
|
166 iKeypadUnlockedNote->ConstructSleepingNoteL( touchEnabled ? R_KEYLOCK_NOTE_DISPLAY_LOCK_OFF_TOUCH : |
|
167 R_KEYLOCK_NOTE_LOCK_OFF ); |
|
168 iKeypadUnlockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 ); |
|
169 // this is not needed |
|
170 // iKeypadUnlockedNote->PublishDialogL( EAknKeysReleasedNote ); |
|
171 |
|
172 iLockedNote = new (ELeave) CLockAppLockedNote(); |
|
173 if ( touchEnabled ) |
|
174 { |
|
175 iLockedNote->ConstructSleepingNoteL( R_KEYLOCK_NOTE_DISPLAY_LOCKED_TOUCH ); |
|
176 } |
|
177 else |
|
178 { |
|
179 switch ( iHardwareSupport ) |
|
180 { |
|
181 case EKeyguardOnePositionSwitch: |
|
182 case EKeyguardTwoPositionSwitch: |
|
183 { |
|
184 iLockedNote->ConstructSleepingNoteL( R_KEYLOCK_NOTE_KEYLOCKED_SWITCH ); |
|
185 break; |
|
186 } |
|
187 case EKeyguardDefaultHardware: |
|
188 default: |
|
189 { |
|
190 iLockedNote->ConstructSleepingNoteL( R_KEYLOCK_NOTE_KEYLOCKED ); |
|
191 break; |
|
192 } |
|
193 } |
|
194 } |
|
195 iLockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 ); |
|
196 |
|
197 // These are created only if touch is not enabled, since |
|
198 // currently in touch devices the keylock state is controlled |
|
199 // with switch. |
|
200 if ( !touchEnabled ) |
|
201 { |
|
202 //Note showing "Now Press *" - when user has pressed "Unlock" in locked state. |
|
203 if ( aFeatureKeypadNoSlider ) |
|
204 { |
|
205 // for normal phones |
|
206 iConfirmationNote = new (ELeave) CLockAppLockedNote(); |
|
207 iConfirmationNote->ConstructSleepingNoteL( R_KEYLOCK_NOTE_UNLOCK_ASTERISK ); |
|
208 } |
|
209 else |
|
210 { |
|
211 // for special slider phones |
|
212 iConfirmationNote = new (ELeave) CLockAppLockedNote(); |
|
213 iConfirmationNote->ConstructSleepingNoteL( R_KEYLOCK_NOTE_UNLOCK_CONFIRM ); |
|
214 } |
|
215 iConfirmationNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 ); |
|
216 |
|
217 } |
|
218 |
|
219 |
|
220 // CenRep observers |
|
221 // TODO create private CR key for storing persistent keyguard state (currently in Sysap) |
|
222 // iCRPersistentKeyguardStatus = CLockAppCenRepObserver::NewL ( this, KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive ); |
|
223 |
|
224 #ifdef RD_AUTO_KEYGUARD |
|
225 iCRAutoKeyguardTime = CLockAppCenRepObserver::NewL ( this, KCRUidSecuritySettings, KSettingsAutomaticKeyguardTime ); |
|
226 // Activity manager |
|
227 iActivityManager = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
228 StartActivityMonitoringL( ); |
|
229 #endif //RD_AUTO_KEYGUARD |
|
230 |
|
231 // PubSub observers |
|
232 iPSStartupObserver = CLockAppPubSubObserver::NewL( this, KPSUidStartup, KPSGlobalSystemState ); |
|
233 |
|
234 // Setup key pattern matcher |
|
235 if ( !SetupKeyPatternsWithPolicyL( EPolicyDeactivateKeyguard ) ) |
|
236 { |
|
237 INFO( "CLockAppKeyguardControl::ConstructL - No CenRep policy defined" ); |
|
238 if ( aFeatureKeypadNoSlider ) |
|
239 { |
|
240 iKeyPattern->AddPattern( EStdKeyDevice0, KStdKeyAsterisk ); // LSK + * |
|
241 } |
|
242 else |
|
243 { |
|
244 iKeyPattern->AddPattern( EStdKeyDevice0, EStdKeyDevice1 ); // LSK + RSK |
|
245 } |
|
246 } |
|
247 #ifdef __WINS__ |
|
248 // In Emulator add the LSK+* pattern also. |
|
249 iKeyPattern->AddPattern( EStdKeyDevice0, EStdKeyNkpAsterisk ); // LSK + * |
|
250 #endif |
|
251 |
|
252 INFO( "CLockAppKeyguardControl::ConstructL completed" ); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // Check weather its allowed to automatically lock the keys |
|
257 // --------------------------------------------------------------------------- |
|
258 TBool CLockAppKeyguardControl::AutoActivationAllowedL( ) |
|
259 { |
|
260 #ifdef RD_AUTO_KEYGUARD |
|
261 TInt value = 0; |
|
262 TBool flipOpen(EFalse); |
|
263 RProperty::Get( KPSUidHWRM, KHWRMFlipStatus, value ); |
|
264 flipOpen = (value = KFlipOpen); |
|
265 INFO_1("CLockAppKeyguardControl::AutoActivationAllowedL - flipOpen: %d", flipOpen); |
|
266 if ( flipOpen ) |
|
267 { |
|
268 CRepository* repository = CRepository::NewL( KCRUidAutolockConf ); |
|
269 repository->Get( KAutoKeyLockConf, value ); |
|
270 delete repository; |
|
271 if ( value & KAutoKeylockFeatureIdFlipOpenDisabled ) |
|
272 { |
|
273 INFO( "CLockAppKeyguardControl::AutoActivationAllowedL : False because flipOpenDisabled" ); |
|
274 return EFalse; |
|
275 } |
|
276 } |
|
277 |
|
278 TInt lightStatus=EForcedLightsUninitialized; |
|
279 RProperty::Get(KPSUidCoreApplicationUIs,KLightsVTForcedLightsOn,lightStatus ); |
|
280 INFO_1("CLockAppKeyguardControl::AutoActivationAllowedL - lightStatus: %d", lightStatus); |
|
281 if ( lightStatus == EForcedLightsOn ) |
|
282 { |
|
283 INFO( "CLockAppKeyguardControl::AutoActivationAllowedL : False because EForcedLightsOn" ); |
|
284 return EFalse; |
|
285 } |
|
286 |
|
287 TBool keysLocked(EFalse); |
|
288 TBool idle(EFalse); |
|
289 TBool ongoingCall(EFalse); |
|
290 TBool screenSaverOn(EFalse); |
|
291 TBool screenSaverStertedFromIdle(EFalse); |
|
292 |
|
293 keysLocked = (iStateControl.LockStatus() != ELockNotActive); |
|
294 INFO_1("CLockAppKeyguardControl::AutoActivationAllowedL - keysLocked: %d", keysLocked); |
|
295 value = 0; |
|
296 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, value ); |
|
297 ongoingCall = (value > EPSCTsyCallStateNone); |
|
298 INFO_2("CLockAppKeyguardControl::AutoActivationAllowedL - ongoingCall: %d %d", value, ongoingCall); |
|
299 value = 0; |
|
300 RProperty::Get( KPSUidAiInformation, KActiveIdleState, value ); |
|
301 idle = (value == EPSAiForeground); |
|
302 INFO_2("CLockAppKeyguardControl::AutoActivationAllowedL - idle: %d %d", value, idle); |
|
303 value = 0; |
|
304 RProperty::Get( KPSUidScreenSaver, KScreenSaverOn, value ); |
|
305 screenSaverOn = (value > 0); |
|
306 INFO_2("CLockAppKeyguardControl::AutoActivationAllowedL - screenSaverOn: %d %d", value, screenSaverOn); |
|
307 value = 0; |
|
308 RProperty::Get( KPSUidScreenSaver, KScreenSaverActivatedFromIdle, value ); |
|
309 screenSaverStertedFromIdle = (value == KSsStartedFromIdle); |
|
310 INFO_2("CLockAppKeyguardControl::AutoActivationAllowedL - screenSaverStertedFromIdle: %d %d", value, screenSaverStertedFromIdle); |
|
311 |
|
312 // If a call is ongoing or idle doesnt have foreground and |
|
313 // screensaver is not started from idle -> dont lock keys |
|
314 if ( keysLocked || ongoingCall || (!idle && !(screenSaverOn && screenSaverStertedFromIdle)) ) |
|
315 { |
|
316 INFO("CLockAppKeyguardControl::AutoActivationAllowedL : False"); |
|
317 return EFalse; |
|
318 } |
|
319 #endif //RD_AUTO_KEYGUARD |
|
320 INFO("CLockAppKeyguardControl::AutoActivationAllowedL : True"); |
|
321 return ETrue; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // Check weather its allowed to activate the control |
|
326 // --------------------------------------------------------------------------- |
|
327 TBool CLockAppKeyguardControl::ActivationAllowedL( ) |
|
328 { |
|
329 return ETrue; |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // Check weather its allowed to deactivate the control |
|
334 // --------------------------------------------------------------------------- |
|
335 TBool CLockAppKeyguardControl::DeActivationAllowedL( ) |
|
336 { |
|
337 return ETrue; |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // Activate control |
|
342 // --------------------------------------------------------------------------- |
|
343 void CLockAppKeyguardControl::HandleActivateEventL( TUint aEnvMask ) |
|
344 { |
|
345 INFO_1("CLockAppKeyguardControl::HandleActivateEventL - aEnvMask: %x", aEnvMask); |
|
346 |
|
347 CLockAppBaseControl::HandleActivateEventL( aEnvMask ); |
|
348 |
|
349 if ( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ) |
|
350 { |
|
351 // if screensaver is on - capture primary keys |
|
352 CapturePrimaryKeys( ETrue ); |
|
353 } |
|
354 |
|
355 // capture keys |
|
356 CLockAppKeyCaptureController::CaptureKey( EStdKeyApplication0, EKeyApplication0, EKeyCaptureAllEvents ); // App key |
|
357 CLockAppKeyCaptureController::CaptureKey( EStdKeyDevice2, EKeyDevice2, EKeyCaptureAllEvents ); // Power key (for lights) |
|
358 CLockAppKeyCaptureController::CaptureKey( EStdKeyDevice6, EKeyDevice6, EKeyCaptureAllEvents ); // Voice key (for lights) |
|
359 CLockAppKeyCaptureController::CaptureKey( EStdKeyNo, EKeyNo, EKeyCaptureAllEvents ); // End key (for Rosetta lights) |
|
360 |
|
361 SetPointerEventCapture( ETrue ); |
|
362 SetKeyguardIndicatorStateL( ETrue ); |
|
363 ShowCba( ETrue ); |
|
364 // close task-list in case it is displayed : fast-swap window |
|
365 iEikonEnv->DismissTaskList( ); |
|
366 if ( iCba ) |
|
367 { |
|
368 TBool areWeInIdleState = CEikStatusPaneBase::Current()->PaneCapabilities(TUid::Uid(EEikStatusPaneUidClock)).IsInCurrentLayout( ); |
|
369 if ( areWeInIdleState ) |
|
370 { |
|
371 (static_cast<CEikCba*>(iCba->ButtonGroup()))->SetSkinBackgroundId( KAknsIIDQsnBgAreaControlIdle ); |
|
372 } |
|
373 else |
|
374 { |
|
375 (static_cast<CEikCba*>(iCba->ButtonGroup()))->SetSkinBackgroundId( KAknsIIDQsnBgAreaControl ); |
|
376 } |
|
377 } |
|
378 |
|
379 if ( iCRPersistentKeyguardStatus ) |
|
380 { |
|
381 iCRPersistentKeyguardStatus->SetValue( 1 ); |
|
382 } |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------------------------- |
|
386 // DeActivate control |
|
387 // --------------------------------------------------------------------------- |
|
388 void CLockAppKeyguardControl::HandleDeActivateEventL( TUint aEnvMask ) |
|
389 { |
|
390 INFO_1("CLockAppKeyguardControl::HandleDeActivateEventL - aEnvMask: 0x%x", aEnvMask); |
|
391 |
|
392 CLockAppBaseControl::HandleDeActivateEventL( aEnvMask ); |
|
393 |
|
394 if ( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ) |
|
395 { |
|
396 // if screensaver is on - uncapture primary keys |
|
397 CapturePrimaryKeys( EFalse ); |
|
398 } |
|
399 |
|
400 // phonecall or not - uncapture keys anyway |
|
401 CLockAppKeyCaptureController::ReleaseKey( EStdKeyApplication0 ); |
|
402 CLockAppKeyCaptureController::ReleaseKey( EStdKeyDevice2 ); |
|
403 CLockAppKeyCaptureController::ReleaseKey( EStdKeyDevice6 ); |
|
404 CLockAppKeyCaptureController::ReleaseKey( EStdKeyNo ); |
|
405 |
|
406 SetPointerEventCapture( EFalse ); |
|
407 SetKeyguardIndicatorStateL( EFalse ); |
|
408 ShowCba( EFalse ); |
|
409 |
|
410 if ( iCRPersistentKeyguardStatus ) |
|
411 { |
|
412 iCRPersistentKeyguardStatus->SetValue( 0 ); |
|
413 } |
|
414 } |
|
415 |
|
416 // --------------------------------------------------------------------------- |
|
417 // Handle environment changes (Screensaver, Telephony, etc.) |
|
418 // --------------------------------------------------------------------------- |
|
419 void CLockAppKeyguardControl::HandleEnvironmentChange( TUint aEnvMask, TUint aEventMask ) |
|
420 { |
|
421 if ( IsBitFieldSet( aEventMask, KLockAppEnvScreenSaverOn ) ) |
|
422 { |
|
423 // screen saver state changed |
|
424 CapturePrimaryKeys( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ); |
|
425 } |
|
426 if ( IsBitFieldSet( aEventMask, KLockAppEnvFPS ) ) |
|
427 { |
|
428 // iStateControl.DisableKeyguardL( ETrue ); |
|
429 // iStateControl.LockStatus() != ELockNotActive // no need to check, because keyguard will catch fingerprint only if not locked |
|
430 iStateControl.EnableDevicelockL( EDevicelockManual ); |
|
431 } |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------------------------- |
|
435 // Inform the user that keys are locked (i.e. "Please press LSK+'*' to unlock). |
|
436 // --------------------------------------------------------------------------- |
|
437 void CLockAppKeyguardControl::DisplayLockedNote( ) |
|
438 { |
|
439 ShowNote( iLockedNote, CAknNoteDialog::ELongTimeout, CAknNoteDialog::ENoTone ); |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // Handle all Central Repository observer callbacks. |
|
444 // --------------------------------------------------------------------------- |
|
445 void CLockAppKeyguardControl::HandleCenRepNotify(TUid aCenRepUid, TUint32 aKeyId, TInt aValue ) |
|
446 { |
|
447 if ( aCenRepUid == KCRUidSecuritySettings ) |
|
448 { |
|
449 switch ( aKeyId ) |
|
450 { |
|
451 case KSettingsAutomaticKeyguardTime: |
|
452 { |
|
453 INFO_1( "CLockAppKeyguardControl::HandleCenRepNotify - KSettingsAutomaticKeyguardTime = %d", aValue ); |
|
454 ResetInactivityTimeout( ); |
|
455 } |
|
456 break; |
|
457 default: |
|
458 break; |
|
459 } |
|
460 } |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // Handle all Publish & Subscribe observer callbacks. |
|
465 // --------------------------------------------------------------------------- |
|
466 void CLockAppKeyguardControl::HandlePubSubNotify(TUid aPubSubUid, TUint aKeyId, TInt aValue ) |
|
467 { |
|
468 if ( aPubSubUid == KPSUidStartup ) |
|
469 { |
|
470 switch ( aKeyId ) |
|
471 { |
|
472 case KPSGlobalSystemState: |
|
473 { |
|
474 // In case of unexpected reset (e.g. hidden boot) the keylock must be enabled silently. |
|
475 if ( !iAlreadyNormalState && (aValue == ESwStateNormalRfOn || aValue == ESwStateNormalRfOff) ) |
|
476 { |
|
477 iAlreadyNormalState = ETrue; |
|
478 TInt keylockWasEnabled = 0; |
|
479 if ( iCRPersistentKeyguardStatus ) |
|
480 { |
|
481 iCRPersistentKeyguardStatus->GetValue( keylockWasEnabled ); |
|
482 if ( keylockWasEnabled ) |
|
483 { |
|
484 TRAPD(err, iStateControl.EnableKeyguardL( EFalse )); |
|
485 ERROR(err, "CLockAppKeyguardControl::HandlePubSubNotify - EnableKeyguardL"); |
|
486 } |
|
487 } |
|
488 } |
|
489 } |
|
490 break; |
|
491 default: |
|
492 break; |
|
493 } |
|
494 } |
|
495 INFO_3( "CLockAppKeyguardControl::HandlePubSubNotify %x %x = %x", aPubSubUid.iUid, aKeyId, aValue ); |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // Show that keys are locked. |
|
500 // --------------------------------------------------------------------------- |
|
501 void CLockAppKeyguardControl::DisplayKeysLockedNote( ) |
|
502 { |
|
503 ShowNote( iKeypadLockedNote, KKeyLockCustomShortTimeout, CAknNoteDialog::ENoTone ); |
|
504 } |
|
505 |
|
506 // --------------------------------------------------------------------------- |
|
507 // Show that keys are unlocked. |
|
508 // --------------------------------------------------------------------------- |
|
509 void CLockAppKeyguardControl::DisplayKeysActiveNote( ) |
|
510 { |
|
511 ShowNote( iKeypadUnlockedNote, KKeyLockCustomShortTimeout, CAknNoteDialog::ENoTone ); |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // Show confirmation note when user has pressed "Unlock". |
|
516 // --------------------------------------------------------------------------- |
|
517 void CLockAppKeyguardControl::DisplayConfirmationNote( ) |
|
518 { |
|
519 ShowNote( iConfirmationNote, CAknNoteDialog::EShortTimeout, CAknNoteDialog::EConfirmationTone ); |
|
520 // inform sysap to put lights on left soft key press |
|
521 SendMessageToSysAp( EEikKeyLockLightsOnRequest ); |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // Keyguard UI key events are handled trough here. |
|
526 // --------------------------------------------------------------------------- |
|
527 TKeyResponse CLockAppKeyguardControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
528 { |
|
529 |
|
530 INFO_4( "%s %s (%u) iActive=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iActive ); |
|
531 INFO_4( "%s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __LINE__, aKeyEvent.iCode, aType ); |
|
532 |
|
533 if ( iActive ) |
|
534 { |
|
535 if(AknLayoutUtils::PenEnabled()) |
|
536 { |
|
537 if(aKeyEvent.iCode == EKeyDeviceF) // any Type |
|
538 { |
|
539 iStateControl.DisableKeyguardL( ETrue ); |
|
540 } |
|
541 } |
|
542 if ( aType == EEventKeyDown ) |
|
543 { |
|
544 switch ( iKeyPattern->HandleKeyEvent( aKeyEvent.iScanCode ) ) |
|
545 { |
|
546 case EPatternNoMatch: |
|
547 DisplayLockedNote( ); |
|
548 break; |
|
549 case EPatternPrimaryMatch: |
|
550 DisplayConfirmationNote( ); |
|
551 break; |
|
552 case EPatternSecondaryMatch: |
|
553 iStateControl.DisableKeyguardL( ETrue ); |
|
554 break; |
|
555 default: |
|
556 INFO_4( "%s %s (%u) default=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
557 break; |
|
558 } |
|
559 } |
|
560 } |
|
561 return EKeyWasConsumed; |
|
562 } |
|
563 |
|
564 // --------------------------------------------------------------------------- |
|
565 // Get autokeyguard timeout (in seconds) |
|
566 // @return 0 means Off |
|
567 // --------------------------------------------------------------------------- |
|
568 TInt CLockAppKeyguardControl::GetAutoKeyguardTimeout( ) |
|
569 { |
|
570 TInt timeoutInSeconds( 0 ); |
|
571 #ifdef RD_AUTO_KEYGUARD |
|
572 iCRAutoKeyguardTime->GetValue( timeoutInSeconds ); |
|
573 #endif //RD_AUTO_KEYGUARD |
|
574 return timeoutInSeconds; |
|
575 } |
|
576 |
|
577 // ---------------------------------------------------------- |
|
578 // Starts monitoring user activity |
|
579 // ---------------------------------------------------------- |
|
580 void CLockAppKeyguardControl::StartActivityMonitoringL( ) |
|
581 { |
|
582 #ifdef RD_AUTO_KEYGUARD |
|
583 __ASSERT_DEBUG( iActivityManager, DoPanic(ELockIllegalState)); |
|
584 if ( iActivityManager && !iActivityManager->IsActive() ) |
|
585 { |
|
586 TInt value = GetAutoKeyguardTimeout( ); |
|
587 INFO_1( "CLockAppKeyguardControl::StartActivityMonitoringL - %d sec", value); |
|
588 if ( value ) |
|
589 { |
|
590 iActivityManager->Start( value, |
|
591 TCallBack( HandleInactiveEventL, this ), |
|
592 TCallBack( HandleActiveEventL, this ) ); |
|
593 } |
|
594 else |
|
595 { |
|
596 iActivityManager->Start( KAutoKeyguardOff, |
|
597 TCallBack( HandleInactiveEventL, this ), |
|
598 TCallBack( HandleActiveEventL, this ) ); |
|
599 } |
|
600 } |
|
601 #endif //RD_AUTO_KEYGUARD |
|
602 } |
|
603 |
|
604 // ---------------------------------------------------------- |
|
605 // Gets keyguard period and starts monitoring user activity |
|
606 // ---------------------------------------------------------- |
|
607 void CLockAppKeyguardControl::ResetInactivityTimeout( ) |
|
608 { |
|
609 #ifdef RD_AUTO_KEYGUARD |
|
610 __ASSERT_DEBUG( iActivityManager, DoPanic(ELockIllegalState)); |
|
611 if ( iActivityManager ) |
|
612 { |
|
613 TInt value = GetAutoKeyguardTimeout( ); |
|
614 INFO_1( "CLockAppKeyguardControl::ResetInactivityTimeout - %d sec", value); |
|
615 if ( value ) |
|
616 { |
|
617 iActivityManager->SetInactivityTimeout( value ); |
|
618 } |
|
619 else |
|
620 { |
|
621 iActivityManager->SetInactivityTimeout( KAutoKeyguardOff ); |
|
622 } |
|
623 } |
|
624 #endif //RD_AUTO_KEYGUARD |
|
625 } |
|
626 |
|
627 // ---------------------------------------------------------- |
|
628 // Stop monitoring user activity. |
|
629 // ---------------------------------------------------------- |
|
630 void CLockAppKeyguardControl::StopActivityMonitoring( ) |
|
631 { |
|
632 #ifdef RD_AUTO_KEYGUARD |
|
633 if ( iActivityManager ) |
|
634 { |
|
635 iActivityManager->Cancel( ); |
|
636 } |
|
637 #endif //RD_AUTO_KEYGUARD |
|
638 } |
|
639 |
|
640 // ---------------------------------------------------------- |
|
641 // Handle Active event. Called by ActivityManager |
|
642 // ---------------------------------------------------------- |
|
643 TInt CLockAppKeyguardControl::HandleActiveEventL(TAny* /*aPtr*/) |
|
644 { |
|
645 return KErrNone; |
|
646 } |
|
647 |
|
648 // ---------------------------------------------------------- |
|
649 // Handles InActive event. Called by ActivityManager |
|
650 // ---------------------------------------------------------- |
|
651 TInt CLockAppKeyguardControl::HandleInactiveEventL(TAny* aPtr ) |
|
652 { |
|
653 #ifdef RD_AUTO_KEYGUARD |
|
654 CLockAppKeyguardControl* keyguard = STATIC_CAST(CLockAppKeyguardControl*, aPtr); |
|
655 if ( keyguard->GetAutoKeyguardTimeout( ) && keyguard->AutoActivationAllowedL( ) ) |
|
656 { |
|
657 keyguard->iStateControl.EnableKeyguardL( EFalse ); |
|
658 } |
|
659 #endif //RD_AUTO_KEYGUARD |
|
660 return KErrNone; |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------------------------- |
|
664 // Handle UI commands received from the child controls |
|
665 // --------------------------------------------------------------------------- |
|
666 void CLockAppKeyguardControl::ProcessCommandL( TInt aCommandId ) |
|
667 { |
|
668 INFO_1("CLockAppKeyguardControl::ProcessCommandL : %d ", aCommandId ); |
|
669 } |
|
670 |
|
671 TInt CLockAppKeyguardControl::CountComponentControls( ) const |
|
672 { |
|
673 return 1; |
|
674 } |
|
675 |
|
676 CCoeControl* CLockAppKeyguardControl::ComponentControl(TInt /*aIndex*/) const |
|
677 { |
|
678 return iCba; |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // Notification if layout changes. |
|
683 // --------------------------------------------------------------------------- |
|
684 void CLockAppKeyguardControl::HandleResourceChange(TInt aType ) |
|
685 { |
|
686 if ( aType == KEikDynamicLayoutVariantSwitch && iCba ) |
|
687 { |
|
688 TRect screenRect; |
|
689 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
690 iCba->SetBoundingRect( screenRect ); |
|
691 } |
|
692 CCoeControl::HandleResourceChange( aType ); |
|
693 } |
|
694 |
|
695 // END OF FILE |
|