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