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: Controls lock states (unlocked, keylock, devicelock) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappstatecontrol.h" |
|
20 |
|
21 // child controls |
|
22 #include "lockappidlecontrol.h" |
|
23 #include "lockappkeyguardcontrol.h" |
|
24 #include "lockappdevicelockcontrol.h" |
|
25 |
|
26 #include "lockapppubsubobserver.h" |
|
27 #include "lockappcenrepobserver.h" |
|
28 |
|
29 #include "lockappkeycapturecontroller.h" |
|
30 #include "lockappstatepublisher.h" |
|
31 #include "lockappecsdetector.h" |
|
32 #include "lockapputils.h" |
|
33 #include <featmgr.h> |
|
34 |
|
35 #include <settingsinternalcrkeys.h> |
|
36 #include <ScreensaverInternalPSKeys.h> |
|
37 #include <ctsydomainpskeys.h> |
|
38 #include <activeidle2domainpskeys.h> |
|
39 |
|
40 #include "GlobalWindowPriorities.h" |
|
41 |
|
42 #include <avkon.rsg> // general avkon resources |
|
43 #include <aknnotpi.rsg> // keyguard spesific resources |
|
44 #include <aknsoundsystem.h> |
|
45 #include <AknIncallBubbleNotify.h> // incall bubble |
|
46 #include <bautils.h> // BaflUtils |
|
47 #include <apgwgnam.h> |
|
48 |
|
49 #include <keylockpolicyapi.h> |
|
50 |
|
51 #include <hwrmdomainpskeys.h> |
|
52 TUid KUidFpsCategory = {0x1020507E}; |
|
53 const TInt KFpsAuthenticationKey = 1; |
|
54 |
|
55 // used avkon dialog resources |
|
56 _LIT(KRESOURCEFILE, "z:\\resource\\aknnotpi.rsc"); |
|
57 |
|
58 // Visibility gate WG priority's relative offset from ECoeWinPriorityAlwaysAtFront |
|
59 // Now equals -1000 to be an absolute 0. |
|
60 const TInt KGlobalWindowPriority_LockVisibilityGate = -1000; |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Standard Symbian OS construction sequence |
|
64 // --------------------------------------------------------------------------- |
|
65 CLockAppStateControl* CLockAppStateControl::NewL( ) |
|
66 { |
|
67 CLockAppStateControl* self = new (ELeave) CLockAppStateControl(); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL( ); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Destruction releases key captures. |
|
76 // --------------------------------------------------------------------------- |
|
77 CLockAppStateControl::~CLockAppStateControl( ) |
|
78 { |
|
79 // localized resources are freed |
|
80 if ( iResourceFileOffset ) |
|
81 { |
|
82 // We implicitely trust that eikon env exists (though in practice it does not make the |
|
83 // difference as this destructor is really never called...) |
|
84 iEikonEnv->DeleteResourceFile(iResourceFileOffset); |
|
85 } |
|
86 |
|
87 // PuSub observers |
|
88 if ( iPSScreenSaverObserver ) |
|
89 { |
|
90 delete iPSScreenSaverObserver; |
|
91 iPSScreenSaverObserver = NULL; |
|
92 } |
|
93 |
|
94 if ( iPSTelephonyObserver ) |
|
95 { |
|
96 delete iPSTelephonyObserver; |
|
97 iPSTelephonyObserver = NULL; |
|
98 } |
|
99 |
|
100 if ( iPSGripObserver ) |
|
101 { |
|
102 delete iPSGripObserver; |
|
103 iPSGripObserver = NULL; |
|
104 } |
|
105 |
|
106 if ( iPSFPSObserver ) |
|
107 { |
|
108 delete iPSFPSObserver; |
|
109 iPSFPSObserver = NULL; |
|
110 } |
|
111 |
|
112 CLockAppKeyCaptureController::Destroy( ); |
|
113 |
|
114 if ( iIncallBubble ) |
|
115 { |
|
116 delete iIncallBubble; |
|
117 iIncallBubble = NULL; |
|
118 } |
|
119 |
|
120 if ( iSoundsMuted ) |
|
121 { |
|
122 MuteSounds( EFalse ); |
|
123 } |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // The uninitialized status is ELockNoteActive. |
|
128 // --------------------------------------------------------------------------- |
|
129 CLockAppStateControl::CLockAppStateControl( ) : |
|
130 iLockStatus( ELockNotActive), |
|
131 iWGEventGate( iEikonEnv->RootWin()), |
|
132 iEnvState( 0 ) |
|
133 { |
|
134 // no implementation required |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // All lock state observers are created here. |
|
139 // --------------------------------------------------------------------------- |
|
140 void CLockAppStateControl::ConstructL( ) |
|
141 { |
|
142 INFO( "CLockAppStateControl::ConstructL started" ); |
|
143 |
|
144 // creates observer list |
|
145 BaseConstructL( ); |
|
146 |
|
147 // localized resources are loaded |
|
148 TFileName resourceFile; |
|
149 resourceFile.Append( KRESOURCEFILE ); |
|
150 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resourceFile ); |
|
151 iResourceFileOffset = iEikonEnv->AddResourceFileL(resourceFile); |
|
152 |
|
153 // fetch power key configuration from feature manager |
|
154 FeatureManager::InitializeLibL( ); |
|
155 iFeatureNoPowerkey = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey ); |
|
156 FeatureManager::UnInitializeLib( ); |
|
157 |
|
158 // allow autoforwarding for the application (stacked bringforwards) |
|
159 iEikonEnv->SetAutoForwarding( ETrue ); |
|
160 |
|
161 CLockAppKeyCaptureController::InitL( iEikonEnv->RootWin() ); |
|
162 |
|
163 // Create second windowgroup for visibility gate |
|
164 CreateVisibilityGateWgL( ); |
|
165 |
|
166 INFO_1( "CLockAppStateControl - EventGate WgID = %d", iWGEventGate.WindowGroupId() ); |
|
167 INFO_1( "CLockAppStateControl - VisibilityGate WgID = %d", iWGVisibilityGate.WindowGroupId() ); |
|
168 |
|
169 // |
|
170 // Construct Controls |
|
171 // |
|
172 iIdle = CLockAppIdleControl::NewL( *this ); |
|
173 AddObserverL( iIdle ); // ownership is transfered |
|
174 |
|
175 iCurrentControl = iIdle; |
|
176 iCurrentControl->HandleActivateEventL( iEnvState ); |
|
177 |
|
178 iKeyguard = CLockAppKeyguardControl::NewL( *this ); |
|
179 AddObserverL( iKeyguard ); // ownership is transfered |
|
180 |
|
181 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
182 iDevicelock = CLockAppDevicelockControl::NewL( *this, iWGVisibilityGate ); |
|
183 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
184 iDevicelock->ConnectToPhoneL( iWGVisibilityGate ); |
|
185 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
186 AddObserverL( iDevicelock ); // ownership is transfered |
|
187 |
|
188 // Emergency support |
|
189 iLockEcsDetector = CLockAppEcsDetector::NewL( ); |
|
190 AddObserverL( iLockEcsDetector ); // ownership is transfered |
|
191 |
|
192 // Lock state publisher |
|
193 CLockAppStatePublisher* lockPublisher = CLockAppStatePublisher::NewL( ); |
|
194 AddObserverL( lockPublisher ); // ownership is transfered |
|
195 |
|
196 // PubSub observers |
|
197 iPSScreenSaverObserver = CLockAppPubSubObserver::NewL( this, KPSUidScreenSaver, KScreenSaverOn ); |
|
198 iPSTelephonyObserver = CLockAppPubSubObserver::NewL( this, KPSUidCtsyCallInformation, KCTsyCallState ); |
|
199 iPSGripObserver = CLockAppPubSubObserver::NewL( this, KPSUidHWRM, KHWRMGripStatus ); |
|
200 |
|
201 iPSFPSObserver = CLockAppPubSubObserver::NewL( this, KUidFpsCategory, KFpsAuthenticationKey ); |
|
202 |
|
203 // Call bubble |
|
204 iIncallBubble = CAknIncallBubble::NewL( ); |
|
205 |
|
206 ActivateL( ); |
|
207 |
|
208 INFO( "CLockAppStateControl::ConstructL completed" ); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Create visibility gate window group |
|
213 // --------------------------------------------------------------------------- |
|
214 void CLockAppStateControl::CreateVisibilityGateWgL( ) |
|
215 { |
|
216 INFO( "CLockAppStateControl - CreateVisibilityGateL" ); |
|
217 |
|
218 iWGVisibilityGate = RWindowGroup( iCoeEnv->WsSession( ) ); |
|
219 User::LeaveIfError( iWGVisibilityGate.Construct( (TUint32) &iWGVisibilityGate ) ); |
|
220 |
|
221 /* hide this window group from the app switcher */ |
|
222 iWGVisibilityGate.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront ); |
|
223 iWGVisibilityGate.EnableReceiptOfFocus( EFalse ); |
|
224 |
|
225 /*CApaWindowGroupName* wn = CApaWindowGroupName::NewLC( ws ); |
|
226 wn->SetHidden( ETrue ); |
|
227 wn->SetWindowGroupName( iWGVisibilityGate ); |
|
228 CleanupStack::PopAndDestroy( wn );*/ |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // This method should be called to enable keyguard. |
|
233 // --------------------------------------------------------------------------- |
|
234 TInt CLockAppStateControl::EnableKeyguardL( TBool aWithNote ) |
|
235 { |
|
236 INFO_1( "CLockAppStateControl::EnableKeyguardL aWithNote= %d", aWithNote ); |
|
237 TInt err = CheckIfLegal( ELockAppEnableKeyguard ); |
|
238 if ( err == KErrNone && !iKeyguard->ActivationAllowedL( ) ) |
|
239 { |
|
240 err = KErrPermissionDenied; |
|
241 } |
|
242 if ( err == KErrNone ) |
|
243 { |
|
244 PostStatusChangeL( EKeyguardActive ); |
|
245 __ASSERT_DEBUG( iLockStatus == EKeyguardActive, DoPanic(ELockIllegalState)); |
|
246 INFO( "CLockAppStateControl - Keyguard Enabled" ); |
|
247 if ( aWithNote ) |
|
248 { |
|
249 iKeyguard->DisplayKeysLockedNote( ); |
|
250 } |
|
251 } |
|
252 return err; |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // This method should be called to disable keyguard. |
|
257 // --------------------------------------------------------------------------- |
|
258 TInt CLockAppStateControl::DisableKeyguardL( TBool aWithNote ) |
|
259 { |
|
260 INFO_1( "CLockAppStateControl::DisableKeyguardL aWithNote= %d", aWithNote ); |
|
261 TInt err = CheckIfLegal( ELockAppDisableKeyguard ); |
|
262 if ( err == KErrNone && !iKeyguard->DeActivationAllowedL( ) ) |
|
263 { |
|
264 err = KErrPermissionDenied; |
|
265 } |
|
266 if ( err == KErrNone ) |
|
267 { |
|
268 PostStatusChangeL( ELockNotActive ); |
|
269 __ASSERT_DEBUG( iLockStatus == ELockNotActive, DoPanic(ELockIllegalState)); |
|
270 INFO( "CLockAppStateControl - Keyguard Disabled" ); |
|
271 if ( aWithNote ) |
|
272 { |
|
273 iKeyguard->DisplayKeysActiveNote( ); |
|
274 } |
|
275 } |
|
276 return err; |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // This method should be called to enable device lock. |
|
281 // --------------------------------------------------------------------------- |
|
282 TInt CLockAppStateControl::EnableDevicelockL( TDevicelockReason aReason ) |
|
283 { |
|
284 INFO_1( "CLockAppStateControl::EnableDevicelockL aReason= %d", aReason ); |
|
285 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
286 TInt err = CheckIfLegal( ELockAppEnableDevicelock ); |
|
287 if ( err == KErrNone && !iDevicelock->ActivationAllowedL( aReason ) ) |
|
288 { |
|
289 err = KErrPermissionDenied; |
|
290 } |
|
291 if ( err == KErrNone ) |
|
292 { |
|
293 PostStatusChangeL( EDevicelockActive ); |
|
294 __ASSERT_DEBUG( iLockStatus == EDevicelockActive, DoPanic(ELockIllegalState)); |
|
295 iDevicelock->SetLockingReason( aReason ); |
|
296 INFO( "CLockAppStateControl - Devicelock Enabled" ); |
|
297 } |
|
298 return err; |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // This method should be called to disable device lock. |
|
303 // --------------------------------------------------------------------------- |
|
304 TInt CLockAppStateControl::DisableDevicelockL( ) |
|
305 { |
|
306 INFO_1( "CLockAppStateControl::DisableDevicelockL 1= %d", 1 ); |
|
307 TInt err = CheckIfLegal( ELockAppDisableDevicelock ); |
|
308 if ( err == KErrNone && !iDevicelock->DeActivationAllowedL( ) ) |
|
309 { |
|
310 err = KErrPermissionDenied; |
|
311 } |
|
312 if ( err == KErrNone ) |
|
313 { |
|
314 PostStatusChangeL( ELockNotActive ); |
|
315 __ASSERT_DEBUG( iLockStatus == ELockNotActive, DoPanic(ELockIllegalState)); |
|
316 INFO( "CLockAppStateControl - Devicelock Disabled" ); |
|
317 } |
|
318 return err; |
|
319 } |
|
320 |
|
321 // --------------------------------------------------------------------------- |
|
322 // Checks if offer keyguard is allowed and if it is, offers to lock keyguard. |
|
323 // --------------------------------------------------------------------------- |
|
324 TInt CLockAppStateControl::OfferKeyguard( ) |
|
325 { |
|
326 INFO_1( "CLockAppStateControl::OfferKeyguard 1= %d", 1 ); |
|
327 TInt err = CheckIfLegal( ELockAppOfferKeyguard ); |
|
328 if ( err == KErrNone ) |
|
329 { |
|
330 __ASSERT_DEBUG( iLockStatus == ELockNotActive, DoPanic(ELockIllegalState)); |
|
331 INFO( "CLockAppStateControl - OfferKeyguard" ); |
|
332 iIdle->OfferKeyLock( ); |
|
333 } |
|
334 return err; |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // Shows keys locked note if keyguard is enabled. |
|
339 // --------------------------------------------------------------------------- |
|
340 TInt CLockAppStateControl::ShowKeysLockedNote( ) |
|
341 { |
|
342 INFO_1( "CLockAppStateControl::ShowKeysLockedNote 1= %d", 1 ); |
|
343 TInt err = CheckIfLegal( ELockAppShowKeysLockedNote ); |
|
344 if ( err == KErrNone ) |
|
345 { |
|
346 __ASSERT_DEBUG( iLockStatus == EKeyguardActive, DoPanic(ELockIllegalState)); |
|
347 INFO( "CLockAppStateControl - ShowKeysLockedNote" ); |
|
348 iKeyguard->DisplayLockedNote( ); |
|
349 } |
|
350 return err; |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // A method for returning the lock status. |
|
355 // --------------------------------------------------------------------------- |
|
356 TLockStatus CLockAppStateControl::LockStatus( ) const |
|
357 { |
|
358 INFO_1( "CLockAppStateControl::LockStatus iLockStatus= %d", iLockStatus ); |
|
359 return iLockStatus; |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // A method for returning the environment status bitmask. |
|
364 // --------------------------------------------------------------------------- |
|
365 TUint CLockAppStateControl::EnvironmentStatus( ) const |
|
366 { |
|
367 return iEnvState; |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // A method for executing different internal tests. |
|
372 // --------------------------------------------------------------------------- |
|
373 TInt CLockAppStateControl::ExecuteInternalTest( ) |
|
374 { |
|
375 #ifdef _DEBUG |
|
376 return iLockEcsDetector->TestEcsNote( ); |
|
377 #else |
|
378 return KErrNone; |
|
379 #endif |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // Number of owned UI controls (idle, keyguard, devicelock) |
|
384 // --------------------------------------------------------------------------- |
|
385 TInt CLockAppStateControl::CountComponentControls( ) const |
|
386 { |
|
387 return 3; |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // Owned UI controls (idle, keyguard, devicelock) |
|
392 // --------------------------------------------------------------------------- |
|
393 CCoeControl* CLockAppStateControl::ComponentControl( TInt aIndex ) const |
|
394 { |
|
395 RDebug::Printf( "%s %s (%u) aIndex=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aIndex ); |
|
396 switch ( aIndex ) |
|
397 { |
|
398 case 0: |
|
399 return iIdle; |
|
400 case 1: |
|
401 return iKeyguard; |
|
402 case 2: |
|
403 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
404 return iDevicelock; |
|
405 default: |
|
406 return NULL; |
|
407 } |
|
408 } |
|
409 |
|
410 // ---------------------------------------------------------- |
|
411 // Handle window-server events |
|
412 // ---------------------------------------------------------- |
|
413 void CLockAppStateControl::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* /*aDestination*/) |
|
414 { |
|
415 TInt type = aEvent.Type( ); |
|
416 RDebug::Printf( "%s %s (%u) type=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, type ); |
|
417 switch ( type ) |
|
418 { |
|
419 case KAknFullOrPartialForegroundLost: // partial or full fg lost |
|
420 case KAknFullOrPartialForegroundGained: // partial or full fg gained |
|
421 { |
|
422 RDebug::Printf( "%s %s (%u) type=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, type ); |
|
423 RWsSession& ws = iCoeEnv->WsSession( ); |
|
424 TFileName windowName; |
|
425 TInt fwgid = ws.GetFocusWindowGroup( ); |
|
426 ws.GetWindowGroupNameFromIdentifier( fwgid, windowName ); |
|
427 INFO_3( "CLockAppStateControl::HandleWsEventL type: %d - FocusWg: %d %S", type, fwgid, &windowName); |
|
428 } |
|
429 break; |
|
430 case EEventKeyUp: |
|
431 case EEventKey: |
|
432 case EEventKeyDown: |
|
433 { |
|
434 RDebug::Printf( "%s %s (%u) EEventKey*=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EEventKeyDown ); |
|
435 TKeyEvent* aKeyEvent = aEvent.Key(); |
|
436 TKeyResponse response = OfferKeyEventL( *aKeyEvent, (TEventCode)type ); |
|
437 } |
|
438 break; |
|
439 default: |
|
440 break; |
|
441 } |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // From @c CAknAppUiBase. Overriden the parent method, because otherwise |
|
446 // the main lock state control would not receive the call, because is is not |
|
447 // window-owning control (=without window->not visible). The call is needed |
|
448 // because the main state control owns window-owning child controls. |
|
449 // --------------------------------------------------------------------------- |
|
450 void CLockAppStateControl::HandleResourceChange( TInt aType ) |
|
451 { |
|
452 // these would not normally get handleresource call since they do not own window |
|
453 RDebug::Printf( "%s %s (%u) aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aType ); |
|
454 if(iIdle) |
|
455 iIdle->HandleResourceChange( aType ); |
|
456 if(iKeyguard) |
|
457 iKeyguard->HandleResourceChange( aType ); |
|
458 if(iDevicelock) |
|
459 iDevicelock->HandleResourceChange( aType ); |
|
460 // call parent |
|
461 CCoeControl::HandleResourceChange( aType ); |
|
462 } |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // Update the environment state variable with the event. |
|
466 // --------------------------------------------------------------------------- |
|
467 TBool CLockAppStateControl::HandleEnvironmentChange( TUint aEventMask, TBool aEnable ) |
|
468 { |
|
469 // check if there will be a change |
|
470 |
|
471 if ( IsBitFieldSet( iEnvState, aEventMask ) != aEnable ) |
|
472 { |
|
473 // set the bit-field |
|
474 SetBitField( iEnvState, aEventMask, aEnable ); |
|
475 // notify current control |
|
476 __ASSERT_DEBUG( iCurrentControl, DoPanic(ELockIllegalState)); |
|
477 iCurrentControl->HandleEnvironmentChange( iEnvState, aEventMask ); |
|
478 // return true because the environment changed |
|
479 return ETrue; |
|
480 } |
|
481 return EFalse; |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------------------------- |
|
485 // Handle all Central Repository observer callbacks. |
|
486 // --------------------------------------------------------------------------- |
|
487 void CLockAppStateControl::HandleCenRepNotify(TUid aCenRepUid, TUint32 aKeyId, TInt aValue ) |
|
488 { |
|
489 RDebug::Printf( "%s %s (%u) ???? Nothing done for aKeyId=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyId ); |
|
490 |
|
491 INFO_3( "CLockAppStateControl::HandleCenRepNotify %d %d = %d", aCenRepUid.iUid, aKeyId, aValue ); |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 // Handle all Publish & Subscribe observer callbacks. |
|
496 // --------------------------------------------------------------------------- |
|
497 void CLockAppStateControl::HandlePubSubNotify(TUid aPubSubUid, TUint aKeyId, TInt aValue ) |
|
498 { |
|
499 INFO_3( "CLockAppStateControl::HandlePubSubNotify %x %x = %d", aPubSubUid.iUid, aKeyId, aValue ); |
|
500 INFO_3( "CLockAppStateControl::HandlePubSubNotify KPSUidScreenSaver=%x KPSUidCtsyCallInformation=%x KPSUidAiInformation=%x", KPSUidScreenSaver, KPSUidCtsyCallInformation, KPSUidAiInformation ); |
|
501 INFO_3( "CLockAppStateControl::HandlePubSubNotify KPSUidHWRM=%x KHWRMGripStatus=%x KPSUidAiInformation=%x", KPSUidHWRM, KHWRMGripStatus, KPSUidAiInformation ); |
|
502 if ( aPubSubUid == KPSUidScreenSaver ) |
|
503 { |
|
504 switch ( aKeyId ) |
|
505 { |
|
506 case KScreenSaverOn: |
|
507 { |
|
508 INFO_1("CLockAppStateControl::ScreenSaver - %d", (aValue > 0)); |
|
509 HandleEnvironmentChange( KLockAppEnvScreenSaverOn, (aValue > 0) ); |
|
510 } |
|
511 break; |
|
512 default: |
|
513 break; |
|
514 } |
|
515 } |
|
516 else if ( aPubSubUid == KPSUidCtsyCallInformation ) |
|
517 { |
|
518 switch ( aKeyId ) |
|
519 { |
|
520 case KCTsyCallState: |
|
521 { |
|
522 PrintCallState( aValue ); |
|
523 HandleEnvironmentChange( KLockAppEnvPhonecallOngoing, (aValue > EPSCTsyCallStateNone) ); |
|
524 } |
|
525 break; |
|
526 default: |
|
527 break; |
|
528 } |
|
529 } |
|
530 else if ( aPubSubUid == KPSUidAiInformation ) // ActiveIdle |
|
531 { |
|
532 switch ( aKeyId ) |
|
533 { |
|
534 case KActiveIdleState: |
|
535 { |
|
536 INFO_1("CLockAppStateControl::ActiveIdle - %d", (aValue == EPSAiForeground)); |
|
537 HandleEnvironmentChange( KLockAppEnvIdleOnForeground, (aValue == EPSAiForeground) ); |
|
538 } |
|
539 break; |
|
540 default: |
|
541 break; |
|
542 } |
|
543 } |
|
544 else if ( aPubSubUid == KPSUidHWRM ) |
|
545 { |
|
546 switch ( aKeyId ) |
|
547 { |
|
548 case KHWRMGripStatus: |
|
549 { |
|
550 INFO_1("CLockAppStateControl::Grip - %d", aValue ); |
|
551 HandleEnvironmentChange( KLockAppEnvGrip, (aValue == EPSHWRMGripOpen) ); |
|
552 } |
|
553 break; |
|
554 default: |
|
555 break; |
|
556 } |
|
557 } |
|
558 else if ( aPubSubUid == KUidFpsCategory ) |
|
559 { |
|
560 switch ( aKeyId ) |
|
561 { |
|
562 case KFpsAuthenticationKey: |
|
563 { |
|
564 INFO_1("CLockAppStateControl::Grip - %d", aValue ); |
|
565 #define EAuthenticationSuccess 1 |
|
566 HandleEnvironmentChange( KLockAppEnvFPS, (aValue == EAuthenticationSuccess) ); |
|
567 } |
|
568 break; |
|
569 default: |
|
570 break; |
|
571 } |
|
572 } |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // All keyevents should go trough here. |
|
577 // --------------------------------------------------------------------------- |
|
578 TKeyResponse CLockAppStateControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
579 { |
|
580 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
581 RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, aType ); |
|
582 TKeyResponse keyResponse = PreCheckKeyEvents( aKeyEvent, aType ); |
|
583 if ( keyResponse == EKeyWasNotConsumed ) |
|
584 { |
|
585 if ( aKeyEvent.iRepeats == 0 ) |
|
586 { |
|
587 // handle only without the repeats |
|
588 INFO_3("KeyEvent %d, %d, %d", aType, aKeyEvent.iCode, aKeyEvent.iScanCode ); |
|
589 __ASSERT_DEBUG( iCurrentControl, DoPanic(ELockIllegalState)); |
|
590 keyResponse = iCurrentControl->OfferKeyEventL( aKeyEvent, aType ); |
|
591 } |
|
592 else |
|
593 { |
|
594 // set consumed which are repeated |
|
595 keyResponse = EKeyWasConsumed; |
|
596 } |
|
597 } |
|
598 |
|
599 return keyResponse; |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // From @c CLockAppObserverList. The main state control is the first |
|
604 // to handle the lock state changes, locks/unlocks the phone depending |
|
605 // on the state change. |
|
606 // --------------------------------------------------------------------------- |
|
607 void CLockAppStateControl::HandleLockStatusChangedL( TLockStatus aLockStatus ) |
|
608 { |
|
609 __ASSERT_DEBUG( iCurrentControl, DoPanic(ELockIllegalState)); |
|
610 INFO_1("CLockAppStateControl::HandleLockStatusChangedL - %d", aLockStatus); |
|
611 iCurrentControl->HandleDeActivateEventL( iEnvState ); |
|
612 |
|
613 switch ( aLockStatus ) |
|
614 { |
|
615 case ELockNotActive: |
|
616 { |
|
617 iCurrentControl = iIdle; |
|
618 MuteSounds( EFalse ); |
|
619 BringForward( EFalse ); |
|
620 } |
|
621 break; |
|
622 case EKeyguardActive: |
|
623 { |
|
624 iCurrentControl = iKeyguard; |
|
625 MuteSounds( ETrue ); |
|
626 BringForward( ETrue ); |
|
627 } |
|
628 break; |
|
629 case EDevicelockActive: |
|
630 { |
|
631 RDebug::Printf( "%s %s (%u) iDevicelock=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iDevicelock ); |
|
632 iCurrentControl = iDevicelock; |
|
633 MuteSounds( ETrue ); |
|
634 BringForward( ETrue ); |
|
635 } |
|
636 break; |
|
637 default: |
|
638 INFO_1("CLockAppStateControl::HandleLockStatusChangedL - ???? aLockStatus=%d", aLockStatus); |
|
639 DoPanic( ELockUnknownValue ); |
|
640 break; |
|
641 } |
|
642 |
|
643 __ASSERT_DEBUG( iCurrentControl, DoPanic(ELockIllegalState)); |
|
644 iCurrentControl->HandleActivateEventL( iEnvState ); |
|
645 |
|
646 // finally we update the value (only place were changing the status is allowed) |
|
647 iLockStatus = aLockStatus; |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // Check if requested transition is valid. |
|
652 // --------------------------------------------------------------------------- |
|
653 TInt CLockAppStateControl::CheckIfLegal( TLockAppMessageReason aReason ) |
|
654 { |
|
655 INFO_1("CLockAppStateControl::CheckIfLegal aReason=%d", aReason); |
|
656 INFO_1("CLockAppStateControl::CheckIfLegal iLockStatus=%d", iLockStatus); |
|
657 switch ( aReason ) |
|
658 { |
|
659 case ELockAppEnableKeyguard: |
|
660 { |
|
661 RDebug::Printf( "%s %s (%u) ELockAppEnableKeyguard iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
662 switch ( iLockStatus ) |
|
663 { |
|
664 case ELockNotActive: |
|
665 if ( !CKeyLockPolicyApi::KeyguardAllowed() ) |
|
666 return KErrPermissionDenied; |
|
667 else |
|
668 return KErrNone; |
|
669 case EKeyguardActive: |
|
670 return KErrAlreadyExists; |
|
671 case EDevicelockActive: |
|
672 return KErrPermissionDenied; |
|
673 } |
|
674 } |
|
675 break; |
|
676 case ELockAppDisableKeyguard: |
|
677 { |
|
678 RDebug::Printf( "%s %s (%u) ELockAppDisableKeyguard iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
679 switch ( iLockStatus ) |
|
680 { |
|
681 case ELockNotActive: |
|
682 return KErrAlreadyExists; |
|
683 case EKeyguardActive: |
|
684 return KErrNone; |
|
685 case EDevicelockActive: |
|
686 return KErrPermissionDenied; |
|
687 } |
|
688 } |
|
689 break; |
|
690 case ELockAppEnableDevicelock: |
|
691 { |
|
692 RDebug::Printf( "%s %s (%u) ELockAppEnableDevicelock iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
693 switch ( iLockStatus ) |
|
694 { |
|
695 case ELockNotActive: |
|
696 return KErrNone; |
|
697 case EKeyguardActive: |
|
698 return KErrNone; |
|
699 case EDevicelockActive: |
|
700 return KErrAlreadyExists; |
|
701 } |
|
702 } |
|
703 break; |
|
704 case ELockAppDisableDevicelock: |
|
705 { |
|
706 RDebug::Printf( "%s %s (%u) ELockAppDisableDevicelock iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
707 switch ( iLockStatus ) |
|
708 { |
|
709 case ELockNotActive: |
|
710 return KErrAlreadyExists; |
|
711 case EKeyguardActive: |
|
712 return KErrPermissionDenied; |
|
713 case EDevicelockActive: |
|
714 return KErrNone; |
|
715 } |
|
716 } |
|
717 break; |
|
718 case ELockAppOfferKeyguard: |
|
719 { |
|
720 RDebug::Printf( "%s %s (%u) ELockAppOfferKeyguard iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
721 switch ( iLockStatus ) |
|
722 { |
|
723 case ELockNotActive: |
|
724 return KErrNone; |
|
725 case EKeyguardActive: |
|
726 return KErrPermissionDenied; |
|
727 case EDevicelockActive: |
|
728 return KErrPermissionDenied; |
|
729 } |
|
730 } |
|
731 break; |
|
732 case ELockAppShowKeysLockedNote: |
|
733 { |
|
734 RDebug::Printf( "%s %s (%u) ELockAppShowKeysLockedNote iLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus ); |
|
735 switch ( iLockStatus ) |
|
736 { |
|
737 case ELockNotActive: |
|
738 return KErrPermissionDenied; |
|
739 case EKeyguardActive: |
|
740 return KErrNone; |
|
741 case EDevicelockActive: |
|
742 return KErrPermissionDenied; |
|
743 } |
|
744 } |
|
745 break; |
|
746 } |
|
747 return KErrPermissionDenied; |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // Prescreen key events for special cases before giving them to child controls |
|
752 // --------------------------------------------------------------------------- |
|
753 TKeyResponse CLockAppStateControl::PreCheckKeyEvents(const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
754 { |
|
755 RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, aType ); |
|
756 TKeyResponse keyResponse = EKeyWasNotConsumed; |
|
757 // power key always turns the lights on |
|
758 CheckForPowerKeyLights( aKeyEvent, aType ); |
|
759 if ( iLockEcsDetector->EcsNoteOnScreen( ) ) |
|
760 { |
|
761 // the key events are fully handled by the emergency |
|
762 // detector when emergency note is shown |
|
763 keyResponse = EKeyWasConsumed; |
|
764 } |
|
765 else |
|
766 { |
|
767 if ( CheckForPhoneKeys( aKeyEvent, aType ) ) |
|
768 { |
|
769 keyResponse = EKeyWasConsumed; |
|
770 } |
|
771 else if ( aKeyEvent.iCode == EKeyLeftShift || aKeyEvent.iCode == EKeyRightShift ) |
|
772 { |
|
773 // eat these modifier events as they just cause problems elsewhere |
|
774 keyResponse = EKeyWasConsumed; |
|
775 } |
|
776 } |
|
777 return keyResponse; |
|
778 } |
|
779 |
|
780 // --------------------------------------------------------------------------- |
|
781 // Checks if power key has been pressed and inform the sysap accordingly. |
|
782 // --------------------------------------------------------------------------- |
|
783 void CLockAppStateControl::CheckForPowerKeyLights( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
784 { |
|
785 // only handle power key when keys are locked |
|
786 RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, aType ); |
|
787 RDebug::Printf( "%s %s (%u) iLockStatus=%x ELockNotActive=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus, ELockNotActive ); |
|
788 if ( iLockStatus != ELockNotActive ) |
|
789 { |
|
790 RDebug::Printf( "%s %s (%u) iFeatureNoPowerkey=%x EStdKeyDevice2=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iFeatureNoPowerkey, EStdKeyDevice2 ); |
|
791 if ( (aType == EEventKey && aKeyEvent.iRepeats == 0) || (aType == EEventKeyDown && aKeyEvent.iScanCode == EStdKeyDevice2) ) // Power key |
|
792 { |
|
793 // If power key pressed, tell SysAp about if |
|
794 if ( (aKeyEvent.iScanCode == EStdKeyDevice2 && aType == EEventKeyDown) || (iFeatureNoPowerkey && aKeyEvent.iCode == EKeyNo) ) |
|
795 { |
|
796 // normal power key event |
|
797 RDebug::Printf( "%s %s (%u) EEikKeyLockPowerKeyPressed=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iFeatureNoPowerkey ); |
|
798 SendMessageToSysAp( EEikKeyLockPowerKeyPressed ); |
|
799 if ( iFeatureNoPowerkey ) |
|
800 { |
|
801 RDebug::Printf( "%s %s (%u) EEikKeyLockLightsOnRequest=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EEikKeyLockLightsOnRequest ); |
|
802 // end key as power key needs additional info (ugly solution) |
|
803 SendMessageToSysAp( EEikKeyLockLightsOnRequest ); |
|
804 } |
|
805 } |
|
806 } |
|
807 } |
|
808 } |
|
809 |
|
810 // --------------------------------------------------------------------------- |
|
811 // Checks if green or red key has been pressed and forward it to phone |
|
812 // in case there is a phone call ongoing. |
|
813 // --------------------------------------------------------------------------- |
|
814 TBool CLockAppStateControl::CheckForPhoneKeys( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
815 { |
|
816 RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, aType ); |
|
817 #ifndef RD_GLOBALWG_PRIORITY_CHANGE |
|
818 // only handle phone keys when locked and phonecall ongoing |
|
819 RDebug::Printf( "%s %s (%u) iLockStatus=%x ELockNotActive=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLockStatus, ELockNotActive ); |
|
820 if ( iLockStatus != ELockNotActive ) |
|
821 { |
|
822 if ( aKeyEvent.iScanCode == EStdKeyYes || aKeyEvent.iScanCode == EStdKeyNo ) |
|
823 { |
|
824 if ( IsBitFieldSet( iEnvState, KLockAppEnvPhonecallOngoing ) ) // TODO what about video-call |
|
825 { |
|
826 // send Green and Red keys to phoneapp's windowgroup |
|
827 INFO( "CLockAppStateControl::CheckForPhoneKeys - SendKeyToPhoneApp"); |
|
828 SendKeyToPhoneApp( aKeyEvent, aType ); |
|
829 return ETrue; |
|
830 } |
|
831 } |
|
832 } |
|
833 #endif // !RD_GLOBALWG_PRIORITY_CHANGE |
|
834 return EFalse; |
|
835 } |
|
836 |
|
837 // --------------------------------------------------------------------------- |
|
838 // Brings foreground/background the root window. |
|
839 // --------------------------------------------------------------------------- |
|
840 void CLockAppStateControl::BringForward(TBool aForeground ) |
|
841 { |
|
842 RDebug::Printf( "%s %s (%u) aForeground=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aForeground ); |
|
843 if ( aForeground ) |
|
844 { |
|
845 INFO_4( "CLockAppStateControl::BringForward(1) STA - EvWG(%d,%d) ViWG(%d,%d)", |
|
846 iWGEventGate.OrdinalPosition(), iWGEventGate.OrdinalPriority(), |
|
847 iWGVisibilityGate.OrdinalPosition(), iWGVisibilityGate.OrdinalPriority()); |
|
848 // not sure if these cause flush in WindowServer |
|
849 iWGVisibilityGate.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront + KGlobalWindowPriority_LockVisibilityGate ); |
|
850 iWGEventGate.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront + KGlobalWindowPriority_LockVisibilityGate ); |
|
851 iEikonEnv->BringForwards( ETrue, ECoeWinPriorityAlwaysAtFront + KGlobalWindowPriority_KeyLock ); |
|
852 /*if ( iIncallBubble ) |
|
853 { |
|
854 iIncallBubble->SetIncallBubbleAllowedInIdleL( ETrue ); |
|
855 }*/ |
|
856 } |
|
857 else |
|
858 { |
|
859 INFO_4( "CLockAppStateControl::BringForward(0) STA - EvWG(%d,%d) ViWG(%d,%d)", |
|
860 iWGEventGate.OrdinalPosition(), iWGEventGate.OrdinalPriority(), |
|
861 iWGVisibilityGate.OrdinalPosition(), iWGVisibilityGate.OrdinalPriority()); |
|
862 |
|
863 // not sure if these cause flush in WindowServer |
|
864 iWGVisibilityGate.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront ); |
|
865 iWGEventGate.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront ); |
|
866 iEikonEnv->BringForwards( EFalse ); |
|
867 /*if ( iIncallBubble ) |
|
868 { |
|
869 iIncallBubble->SetIncallBubbleAllowedInIdleL( EFalse ); |
|
870 }*/ |
|
871 } |
|
872 |
|
873 INFO_4( "CLockAppStateControl::BringForward END - EvWG(%d,%d) ViWG(%d,%d)", |
|
874 iWGEventGate.OrdinalPosition(), iWGEventGate.OrdinalPriority(), |
|
875 iWGVisibilityGate.OrdinalPosition(), iWGVisibilityGate.OrdinalPriority()); |
|
876 } |
|
877 |
|
878 // --------------------------------------------------------------------------- |
|
879 // Mute key sounds when phone is locked. |
|
880 // --------------------------------------------------------------------------- |
|
881 void CLockAppStateControl::MuteSounds(TBool aMuteSounds ) |
|
882 { |
|
883 RDebug::Printf( "%s %s (%u) aMuteSounds=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aMuteSounds ); |
|
884 if ( iSoundsMuted != aMuteSounds ) |
|
885 { |
|
886 if ( aMuteSounds ) |
|
887 { |
|
888 TRAPD(err, iAvkonAppUiBase->KeySounds()->PushContextL(R_AVKON_SILENT_SKEY_LIST)) |
|
889 if ( !err ) |
|
890 { |
|
891 iAvkonAppUiBase->KeySounds()->BringToForeground(); |
|
892 iAvkonAppUiBase->KeySounds()->LockContext(); |
|
893 iSoundsMuted = ETrue; |
|
894 } |
|
895 } |
|
896 else |
|
897 { |
|
898 iAvkonAppUiBase->KeySounds()->ReleaseContext(); |
|
899 iAvkonAppUiBase->KeySounds()->PopContext(); |
|
900 iSoundsMuted = EFalse; |
|
901 } |
|
902 } |
|
903 } |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // Print out call state. |
|
907 // --------------------------------------------------------------------------- |
|
908 void CLockAppStateControl::PrintCallState( TInt aValue ) |
|
909 { |
|
910 RDebug::Printf( "%s %s (%u) aValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aValue ); |
|
911 switch ( aValue ) |
|
912 { |
|
913 case EPSCTsyCallStateUninitialized: |
|
914 INFO("CLockAppStateControl::PrintCallState - Uninitialized") |
|
915 break; |
|
916 case EPSCTsyCallStateNone: |
|
917 INFO("CLockAppStateControl::PrintCallState - None") |
|
918 break; |
|
919 case EPSCTsyCallStateAlerting: |
|
920 INFO("CLockAppStateControl::PrintCallState - Alerting") |
|
921 break; |
|
922 case EPSCTsyCallStateRinging: |
|
923 INFO("CLockAppStateControl::PrintCallState - Ringing") |
|
924 break; |
|
925 case EPSCTsyCallStateDialling: |
|
926 INFO("CLockAppStateControl::PrintCallState - Dialling") |
|
927 break; |
|
928 case EPSCTsyCallStateAnswering: |
|
929 INFO("CLockAppStateControl::PrintCallState - Answering") |
|
930 break; |
|
931 case EPSCTsyCallStateDisconnecting: |
|
932 INFO("CLockAppStateControl::PrintCallState - Disconnecting") |
|
933 break; |
|
934 case EPSCTsyCallStateConnected: |
|
935 INFO("CLockAppStateControl::PrintCallState - Connected") |
|
936 break; |
|
937 case EPSCTsyCallStateHold: |
|
938 INFO("CLockAppStateControl::PrintCallState - Hold") |
|
939 break; |
|
940 default: |
|
941 break; |
|
942 } |
|
943 } |
|
944 |
|
945 // END OF FILE |
|