coreapplicationuis/SysAp/Src/sysapdefaultkeyhandler.cpp
changeset 0 2e3d3ce01487
child 1 0fdb7f6b0309
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Default key event handling of System Application
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32property.h>
       
    20 #include <eikon.hrh>
       
    21 #include <coemain.h>
       
    22 #include <aknkeylock.h>
       
    23 #include <AknTaskList.h>
       
    24 #include <apgtask.h>
       
    25 #include <apgcli.h>
       
    26 #include <apgwgnam.h>
       
    27 #include <apacmdln.h>
       
    28 #include <AiwPoCParameters.h>
       
    29 #include <AiwServiceHandler.h>
       
    30 #include <featmgr.h>
       
    31 #include <coreapplicationuisdomainpskeys.h>
       
    32 #include <PSVariables.h>
       
    33 #include <startupdomainpskeys.h>
       
    34 #include <hwrmdomainpskeys.h>
       
    35 #include <u32hal.h>
       
    36 #include <SysAp.rsg>
       
    37 #include "sysapdefaultkeyhandler.h"
       
    38 #include "sysapcallback.h"
       
    39 #include "SysAp.hrh"
       
    40 #include "AknSgcc.h"
       
    41 
       
    42 
       
    43 const TInt KModifierMask( 0 );
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CSysApDefaultKeyHandler::CSysApDefaultKeyHandler
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CSysApDefaultKeyHandler::CSysApDefaultKeyHandler( MSysapCallback& aCallback ) :
       
    52                                                      iCallback(aCallback),
       
    53                                                      iCameraSupported(EFalse),
       
    54                                                      iCoverDisplaySupported(EFalse),
       
    55                                                      iKeylock(NULL),
       
    56                                                      iCapturedEKeyCamera(0),
       
    57                                                      iCapturedEKeyTwistOpen(0),
       
    58                                                      iCapturedEKeyTwistClose(0),
       
    59                                                      iCapturedEKeyGripOpen(0),
       
    60                                                      iCapturedEKeyGripClose(0),
       
    61                                                      iCapturedEKeyPoC(0),
       
    62                                                      iAknUiServerConnected(EFalse)
       
    63     {
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CSysApDefaultKeyHandler::ConstructL
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CSysApDefaultKeyHandler::ConstructL()
       
    71     {
       
    72     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::ConstructL()") ) );
       
    73     
       
    74     RWindowGroup groupWin = CCoeEnv::Static()->RootWin();
       
    75     User::LeaveIfError ( iCapturedEKeyCamera = groupWin.CaptureKey( EKeyCamera, KModifierMask, KModifierMask ) );
       
    76     User::LeaveIfError ( iCapturedEKeyTwistOpen = groupWin.CaptureKey( EKeyTwistOpen, KModifierMask, KModifierMask ) );
       
    77     User::LeaveIfError ( iCapturedEKeyTwistClose = groupWin.CaptureKey( EKeyTwistClose, KModifierMask, KModifierMask ) );   
       
    78     User::LeaveIfError ( iCapturedEKeyGripOpen = groupWin.CaptureKey( EKeyGripOpen, KModifierMask, KModifierMask ) ); 
       
    79     User::LeaveIfError ( iCapturedEKeyGripClose = groupWin.CaptureKey( EKeyGripClose, KModifierMask, KModifierMask ) ); 
       
    80     User::LeaveIfError ( iCapturedEKeyPoC = groupWin.CaptureKey( EKeyPoC, KModifierMask, KModifierMask ) ); 
       
    81     
       
    82     // flip key events don't need to be captured, because in current setup they are not real events but simulated by SysAp
       
    83     // according to notifications received from P&S key that stores flip information
       
    84     
       
    85     FeatureManager::InitializeLibL();
       
    86     iCameraSupported = FeatureManager::FeatureSupported( KFeatureIdCamera );
       
    87     iCoverDisplaySupported = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay );
       
    88     FeatureManager::UnInitializeLib();
       
    89     
       
    90     TKeyLockBuf lockBuf;
       
    91     iCallback.ExecQueryL( MSysapCallback::EGetKeylock, lockBuf );  
       
    92     iKeylock = lockBuf();
       
    93     
       
    94     __ASSERT_DEBUG( iKeylock, User::Panic( _L("CSysApDefaultKeyHandler::ConstructL: iKeylock not initialized"), KErrBadHandle ) );
       
    95     
       
    96     if ( iCoverDisplaySupported ) // if flip status is monitored, set the initial flip status now
       
    97         {
       
    98         TInt flipValue;
       
    99         TInt err = RProperty::Get( KPSUidHWRM, KHWRMFlipStatus, flipValue );
       
   100 
       
   101         TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::ConstructL: flipValue=%d, err=%d"), flipValue, err ) );
       
   102         
       
   103         if ( err == KErrNone )
       
   104             {
       
   105             switch ( flipValue )
       
   106                 {
       
   107                 case EPSHWRMFlipOpen:
       
   108                     SetDisplayState( ETrue );
       
   109                     break;
       
   110                     
       
   111                 case EPSHWRMFlipClosed:
       
   112                     SetDisplayState( EFalse );
       
   113                     break;
       
   114                     
       
   115                 case EPSHWRMFlipStatusUninitialized:
       
   116                 default:
       
   117                     // set display state only if the current flip position is known
       
   118                     break;
       
   119                 }
       
   120             }
       
   121         }
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CSysApDefaultKeyHandler::NewL
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 CSysApDefaultKeyHandler* CSysApDefaultKeyHandler::NewL( MSysapCallback& aCallback )
       
   129     {
       
   130     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::NewL()") ) );
       
   131     
       
   132     CSysApDefaultKeyHandler* self = new( ELeave ) CSysApDefaultKeyHandler( aCallback) ;
       
   133     CleanupStack::PushL( self );
       
   134     self->ConstructL();
       
   135     CleanupStack::Pop( self );
       
   136     return self;
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CSysApDefaultKeyHandler::~CSysApDefaultKeyHandler
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 CSysApDefaultKeyHandler::~CSysApDefaultKeyHandler()
       
   145     {
       
   146     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::~CSysApDefaultKeyHandler()") ) );
       
   147     
       
   148     iAknUiServer.Close();
       
   149     
       
   150     RWindowGroup groupWin = CCoeEnv::Static()->RootWin();
       
   151     groupWin.CancelCaptureKey( iCapturedEKeyCamera );
       
   152     groupWin.CancelCaptureKey( iCapturedEKeyTwistOpen );
       
   153     groupWin.CancelCaptureKey( iCapturedEKeyTwistClose );
       
   154     groupWin.CancelCaptureKey( iCapturedEKeyGripOpen );
       
   155     groupWin.CancelCaptureKey( iCapturedEKeyGripClose );
       
   156     groupWin.CancelCaptureKey( iCapturedEKeyPoC );
       
   157     
       
   158     }
       
   159     
       
   160 
       
   161 // ----------------------------------------------------------------------------
       
   162 // CSysApDefaultKeyHandler::HandleKeyEventL()
       
   163 // ----------------------------------------------------------------------------
       
   164 //
       
   165 TKeyResponse CSysApDefaultKeyHandler::HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   166 {
       
   167     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::HandleKeyEventL: aKeyEvent.iCode=%d, aKeyEvent.iScanCode=%d, aType=%d"),
       
   168                                 aKeyEvent.iCode, aKeyEvent.iScanCode, aType ) );
       
   169     
       
   170     TKeyResponse response = EKeyWasNotConsumed;
       
   171     
       
   172     __ASSERT_DEBUG( aType == EEventKey, User::Invariant() ); // other than event keys should not provided
       
   173         
       
   174     if( aType == EEventKey )
       
   175         {
       
   176         response = EKeyWasConsumed; // set again in default case if not consumed
       
   177         
       
   178         switch ( aKeyEvent.iCode )
       
   179             {
       
   180             case EKeyGripOpen:
       
   181                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyGripOpen") ) );
       
   182                 RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripOpen );
       
   183                 if (!IsDeviceLocked())
       
   184                     {
       
   185                     iCallback.ExecCommandL( MSysapCallback::EResetKeyguardState );
       
   186                     iKeylock->DisableKeyLock();
       
   187                     iCallback.ExecCommandL( MSysapCallback::ECancelPowermenu );
       
   188                     }
       
   189                 // apply default light control
       
   190                 iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyGripOpen) );
       
   191                 break;
       
   192             
       
   193             case EKeyGripClose:
       
   194                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyGripClosed") ) );
       
   195                 RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripClosed );
       
   196                 iCallback.ExecCommandL( MSysapCallback::ECancelPowermenu );
       
   197                 if ( !IsDeviceLocked() && UiReady() )
       
   198                     {
       
   199                     iKeylock->OfferKeyLock();
       
   200                     }
       
   201                 // apply default light control
       
   202                 iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyGripClose) );
       
   203                 break;
       
   204             
       
   205             case EKeyFlipOpen: // simulated key event
       
   206                 {
       
   207                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyFlipOpen") ) );
       
   208                 SetDisplayState( ETrue );
       
   209                 // apply default light control
       
   210                 iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyFlipOpen) );
       
   211                 }
       
   212                 break;
       
   213             
       
   214             case EKeyFlipClose: // simulated key event
       
   215                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyFlipClose") ) );
       
   216                 SetDisplayState( EFalse );
       
   217                 // apply default light control
       
   218                 iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyFlipClose) );
       
   219                 break;
       
   220                 
       
   221             case EKeyTwistOpen:
       
   222                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyTwistOpen") ) );
       
   223                 RProperty::Set( KPSUidHWRM, KHWRMTwistStatus, EPSHWRMTwistOpen );
       
   224                 break;
       
   225                 
       
   226             case EKeyTwistClose:
       
   227                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyTwistClose") ) );
       
   228                 RProperty::Set( KPSUidHWRM, KHWRMTwistStatus, EPSHWRMTwistClose );
       
   229                 break;                
       
   230 
       
   231             case EKeyCamera:
       
   232                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyCamera") ) );
       
   233                 if ( iCameraSupported && !IsDeviceLocked() && !DoShowKeysLockedNote() )
       
   234                     {
       
   235                     ActivateApplicationL( KSysApCamcorderUid );
       
   236                     }
       
   237                 break;
       
   238                 
       
   239             case EKeyPoC:
       
   240                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyPoC") ) );
       
   241                 LaunchPocL();
       
   242                 break;                
       
   243              
       
   244             default:
       
   245                 response = EKeyWasNotConsumed;
       
   246                 TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::CSysApDefaultKeyHandler: key was not consumed.") ) ); 
       
   247                 break;
       
   248                     
       
   249             }
       
   250         }
       
   251     
       
   252     return response;
       
   253 }  
       
   254     
       
   255   
       
   256 
       
   257 #ifndef SYSAP_USE_STARTUP_UI_PHASE    
       
   258 // -----------------------------------------------------------------------------
       
   259 // CSysApDefaultKeyHandler::IsStateNormal()
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 TBool CSysApDefaultKeyHandler::IsStateNormal() const
       
   263     {
       
   264     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::IsStateNormal")) );
       
   265 
       
   266     TInt state;
       
   267     TInt errorCode = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
       
   268     
       
   269     if ( errorCode == KErrNone )
       
   270         {
       
   271         return state == ESwStateNormalRfOn ||
       
   272                state == ESwStateNormalRfOff ||
       
   273                state == ESwStateNormalBTSap;
       
   274         }
       
   275     else
       
   276         {
       
   277         TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::IsStateNormal: Failed to read global system state, error code %d." ), errorCode ) );
       
   278         return EFalse;
       
   279         }
       
   280     }
       
   281 #endif // SYSAP_USE_STARTUP_UI_PHASE
       
   282 
       
   283 // ----------------------------------------------------------------------------
       
   284 // CSysApDefaultKeyHandler::UiReady()
       
   285 // 
       
   286 // ----------------------------------------------------------------------------
       
   287 
       
   288 TBool CSysApDefaultKeyHandler::UiReady() const
       
   289     {
       
   290 #ifdef SYSAP_USE_STARTUP_UI_PHASE    
       
   291     TInt state( 0 );
       
   292     
       
   293     TInt err = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
       
   294     
       
   295     if ( err != KErrNone || state == ESwStateEmergencyCallsOnly ) // emergency calls only state must block UI operations
       
   296         {
       
   297         TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::UiReady: KPSGlobalSystemState=%d, err=%d." ), state, err ) );
       
   298         return EFalse;
       
   299         }
       
   300     
       
   301     err = RProperty::Get( KPSUidStartup, KPSStartupUiPhase, state );
       
   302     
       
   303     if ( err != KErrNone )
       
   304         {
       
   305         TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::UiReady: Failed to read KPSStartupUiPhase, err=%d." ), err ) );
       
   306         return EFalse;
       
   307         }
       
   308     return state == EStartupUiPhaseAllDone;
       
   309 #else // SYSAP_USE_STARTUP_UI_PHASE
       
   310     // if KPSSStartupUiPhase is not used, global system state normal is handled as UI idle state
       
   311     return IsStateNormal();
       
   312 #endif // SYSAP_USE_STARTUP_UI_PHASE        
       
   313     }
       
   314     
       
   315 // ----------------------------------------------------------------------------
       
   316 // CSysApDefaultKeyHandler::ActivateApplicationL()
       
   317 // ----------------------------------------------------------------------------
       
   318 //
       
   319 void CSysApDefaultKeyHandler::ActivateApplicationL( const TUid aUid ) const
       
   320     {
       
   321     TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL") ) );
       
   322     
       
   323     // Applications must not be activated before reaching normal system operation state
       
   324     if ( UiReady() )
       
   325         {
       
   326         CAknTaskList* apaTaskList = CAknTaskList::NewL( CCoeEnv::Static()->WsSession() );
       
   327         TApaTask apaTask = apaTaskList->FindRootApp( aUid ); // only root application should not be activated
       
   328         delete apaTaskList;
       
   329         
       
   330         if ( apaTask.Exists() )
       
   331             {
       
   332             TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL: application brought to foreground") ) );
       
   333 #ifdef _DEBUG
       
   334             // camery latency measurement environment instrumentation, don't remove
       
   335             if ( aUid == KSysApCamcorderUid )
       
   336                 {
       
   337                 TRACES( RDebug::Print( _L("e_CAM_PRI_OFF_TO_ON 1") ) );
       
   338                 }
       
   339 #endif // _DEBUG            
       
   340             CAknSgcClient::MoveApp ( apaTask.WgId(), ESgcMoveAppToForeground );
       
   341             }
       
   342         else
       
   343             {
       
   344             TInt err( KErrNone );
       
   345             TApaAppInfo appInfo;
       
   346             RApaLsSession apaLsSession;
       
   347             User::LeaveIfError( apaLsSession.Connect() );
       
   348             CleanupClosePushL( apaLsSession );
       
   349             err = apaLsSession.GetAppInfo( appInfo, aUid );
       
   350             if ( !err )
       
   351                 {
       
   352                 TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL: starting application") ) );
       
   353                 CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
       
   354                 apaCommandLine->SetExecutableNameL( appInfo.iFullName );
       
   355                 apaCommandLine->SetCommandL( EApaCommandRun );
       
   356 #ifdef _DEBUG
       
   357                 // camery latency measurement environment instrumentation, don't remove
       
   358                 if ( aUid == KSysApCamcorderUid )
       
   359                     {
       
   360                     TRACES( RDebug::Print( _L("e_CAM_PRI_OFF_TO_ON 1") ) );
       
   361                     }
       
   362 #endif // _DEBUG                   
       
   363                 apaLsSession.StartApp( *apaCommandLine );
       
   364                 CleanupStack::PopAndDestroy( apaCommandLine );
       
   365                 }
       
   366             else
       
   367                 {
       
   368                 TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL err=%d"), err ) );
       
   369                 }                
       
   370             // pop and destroy will also close this session
       
   371             CleanupStack::PopAndDestroy( &apaLsSession );
       
   372             }
       
   373         }
       
   374     }
       
   375     
       
   376 // ----------------------------------------------------------------------------
       
   377 // CSysApDefaultKeyHandler::LaunchPocL()
       
   378 // ----------------------------------------------------------------------------
       
   379 //
       
   380 void CSysApDefaultKeyHandler::LaunchPocL()
       
   381     {
       
   382     TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::LaunchPocL") ) );
       
   383     
       
   384     if ( UiReady() && !IsDeviceLocked() && !DoShowKeysLockedNote() )
       
   385         {
       
   386         CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewLC();
       
   387         serviceHandler->AttachL( R_POC_AIW_INTEREST );
       
   388             
       
   389         CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
       
   390         inParams->AppendL(TAiwGenericParam( EGenericParamPoCLaunchView, TAiwVariant(EAiwPoCMainView)));
       
   391         serviceHandler->ExecuteServiceCmdL( KAiwCmdPoC, *inParams, serviceHandler->OutParamListL());
       
   392         
       
   393         CleanupStack::PopAndDestroy( inParams );
       
   394         CleanupStack::PopAndDestroy( serviceHandler);
       
   395         }
       
   396     }
       
   397     
       
   398 // ----------------------------------------------------------------------------
       
   399 // CSysApDefaultKeyHandler::IsDeviceLocked()
       
   400 // ----------------------------------------------------------------------------
       
   401 TBool CSysApDefaultKeyHandler::IsDeviceLocked() const    
       
   402     {
       
   403     TInt value(0);
       
   404     TBool retval(EFalse);
       
   405 
       
   406     RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, value );
       
   407     if ( value > EAutolockOff )
       
   408         {
       
   409         retval = ETrue;
       
   410         }
       
   411     
       
   412     TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::IsDeviceLocked()=%d" ), retval ) );
       
   413     
       
   414     return retval;
       
   415     }
       
   416 
       
   417 
       
   418 // ----------------------------------------------------------------------------
       
   419 // CSysApDefaultKeyHandler::SetDisplayState
       
   420 // ----------------------------------------------------------------------------
       
   421 void CSysApDefaultKeyHandler::SetDisplayState( TBool aFlipOpen ) const
       
   422     {
       
   423     TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::SetDisplayState: aFlipOpen=%d" ), aFlipOpen ) );
       
   424     
       
   425     if ( iCoverDisplaySupported )
       
   426         {
       
   427         // Turn on/off the main display 
       
   428         TInt err = UserSvr::HalFunction(EHalGroupDisplay, EDisplayHalSetState, (TAny*)aFlipOpen, NULL);
       
   429     
       
   430         if ( err == KErrNone )
       
   431             {
       
   432             TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::SetDisplayState: Main display state set: %d" ), aFlipOpen ) );
       
   433             }
       
   434         else
       
   435             {
       
   436             TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::SetDisplayState: Main display state set failed: %d." ), err ) );
       
   437             }    
       
   438         }
       
   439 
       
   440     }
       
   441 
       
   442 // ----------------------------------------------------------------------------
       
   443 // CSysApDefaultKeyHandler::DoShowKeysLockedNote
       
   444 // ----------------------------------------------------------------------------
       
   445 //
       
   446 TBool CSysApDefaultKeyHandler::DoShowKeysLockedNote()
       
   447     {
       
   448     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: iAknUiServerConnected=%d"), iAknUiServerConnected ) );
       
   449     
       
   450     TInt err(KErrNone);
       
   451     
       
   452     if ( !iAknUiServerConnected )
       
   453         {
       
   454         err = iAknUiServer.Connect();
       
   455         
       
   456         if ( err != KErrNone )
       
   457             {
       
   458             TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: RAknUiServer::Connect failed, err=%d"), err ) );
       
   459             return ETrue; // assume that keypad/device is locked
       
   460             }
       
   461         iAknUiServerConnected = ETrue;            
       
   462         }
       
   463     
       
   464     TBool keysLocked;
       
   465     err = iAknUiServer.ShowKeysLockedNote( keysLocked );
       
   466     
       
   467     if ( err != KErrNone )
       
   468         {
       
   469         TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: RAknUiServer::ShowKeysLockedNote failed, err=%d"), err ) );
       
   470         keysLocked = ETrue; // assume that keypad/device is locked
       
   471         }
       
   472         
       
   473     return keysLocked;        
       
   474     }
       
   475 
       
   476 // ----------------------------------------------------------------------------
       
   477 // CSysApDefaultKeyHandler::IsDeviceModeKey
       
   478 // ----------------------------------------------------------------------------
       
   479 //
       
   480 TBool CSysApDefaultKeyHandler::IsDeviceModeKey( const TKeyEvent& aKeyEvent )
       
   481     {
       
   482     TBool response( EFalse );
       
   483     
       
   484     switch ( aKeyEvent.iCode )
       
   485         {
       
   486         case EKeyGripOpen:
       
   487         case EKeyGripClose:
       
   488         case EKeyFlipOpen:
       
   489         case EKeyFlipClose:
       
   490         case EKeyTwistOpen:
       
   491         case EKeyTwistClose:
       
   492             response = ETrue;
       
   493             break;
       
   494             
       
   495         default:
       
   496             break; // not a device mode key            
       
   497         }
       
   498 
       
   499     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::IsDeviceModeKey: aKeyEvent.iCode=%d, response=%d"), aKeyEvent.iCode, response ) );
       
   500     
       
   501     return response;        
       
   502     }