mediakeys/MMKeyBearer/src/MMKeyBearerImplementation.cpp
branchRCL_3
changeset 19 924385140d98
parent 18 0818dd463d41
child 20 c2c61fdca848
equal deleted inserted replaced
18:0818dd463d41 19:924385140d98
    24 #include <remconcoreapi.h>
    24 #include <remconcoreapi.h>
    25 #include <mediakeysinternalpskeys.h>
    25 #include <mediakeysinternalpskeys.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    27 #include <usbpersonalityids.h>
    27 #include <usbpersonalityids.h>
    28 #include <PSVariables.h>   // Property values
    28 #include <PSVariables.h>   // Property values
       
    29 #include <keyguardaccessapi.h>
    29 
    30 
    30 // Include this once it is exported
    31 // Include this once it is exported
    31 // #include <RemConExtensionApi.h>
    32 // #include <RemConExtensionApi.h>
    32 
    33 
    33 #include "MMKeyBearerImplementation.h"
    34 #include "MMKeyBearerImplementation.h"
    72 
    73 
    73     delete iMMKeyBearerObserver;
    74     delete iMMKeyBearerObserver;
    74     delete iMediaKeyObserver;
    75     delete iMediaKeyObserver;
    75     delete iAccessoryVolKeyObserver;
    76     delete iAccessoryVolKeyObserver;
    76     delete iUSBFileTransferObserver;
    77     delete iUSBFileTransferObserver;
    77     iAknServer.Close();
    78     delete iKeyguardAccess;
    78     }
    79     }
    79 
    80 
    80 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
    81 // CMMKeyBearer::CMMKeyBearer()
    82 // CMMKeyBearer::CMMKeyBearer()
    82 // construction.
    83 // construction.
    83 // ---------------------------------------------------------
    84 // ---------------------------------------------------------
    84 //
    85 //
    85 CMMKeyBearer::CMMKeyBearer(TBearerParams& aParams)
    86 CMMKeyBearer::CMMKeyBearer(TBearerParams& aParams)
    86 :   CRemConBearerPlugin(aParams),
    87 :   CRemConBearerPlugin(aParams),
    87     iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone),
    88     iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone)
    88     iAknServerConnected(EFalse)
    89     {
    89     {
    90     FUNC_LOG;
    90     FUNC_LOG;
    91     
    91 
       
    92     //Pass
    92     //Pass
    93     }
    93     }
    94 
    94 
    95 // ---------------------------------------------------------
    95 // ---------------------------------------------------------
    96 // CMMKeyBearer::ConstructL()
    96 // CMMKeyBearer::ConstructL()
   103 
   103 
   104     // throw an indication up to RemCon.
   104     // throw an indication up to RemCon.
   105     TRemConAddress addr;
   105     TRemConAddress addr;
   106     addr.BearerUid() = Uid();
   106     addr.BearerUid() = Uid();
   107     TInt err = Observer().ConnectIndicate(addr);
   107     TInt err = Observer().ConnectIndicate(addr);
       
   108     iKeyguardAccess = CKeyguardAccessApi::NewL();
   108 
   109 
   109     // Start Active object for listening key events from P&S
   110     // Start Active object for listening key events from P&S
   110     TRAP_AND_LEAVE(
   111     TRAP_AND_LEAVE(
   111         iMMKeyBearerObserver = CMMKeyBearerObserver::NewL(*this, ESideVolumeKeys),
   112         iMMKeyBearerObserver = CMMKeyBearerObserver::NewL(*this, ESideVolumeKeys),
   112         "Volume key observer init failed" );
   113         "Volume key observer init failed" );
   340     FUNC_LOG;
   341     FUNC_LOG;
   341 
   342 
   342     INFO_3( "Received key: enumValue = %d, keyType = %d, usbFileTransfer = %d",
   343     INFO_3( "Received key: enumValue = %d, keyType = %d, usbFileTransfer = %d",
   343         aEnumValue, aKeyType, iUSBFileTransfer );
   344         aEnumValue, aKeyType, iUSBFileTransfer );
   344 
   345 
   345 	//Start the listener once again
       
   346     if (aKeyType == ESideVolumeKeys)
       
   347         {
       
   348         iMMKeyBearerObserver->Start();
       
   349         }
       
   350 
       
   351     // Mediakeys must be disabled when MTP (Music Transfer) is happening.
   346     // Mediakeys must be disabled when MTP (Music Transfer) is happening.
   352     if (aKeyType == EFileTransferStatus)
   347     if (aKeyType == EFileTransferStatus)
   353         {
   348         {
   354         iUSBFileTransferObserver->Start(); // Ensure first that no status change gets missed
   349         iUSBFileTransferObserver->Start(); // Ensure first that no status change gets missed
   355         iUSBFileTransfer = iUSBFileTransferObserver->GetValue(); // Read the MTP status
   350         iUSBFileTransfer = iUSBFileTransferObserver->GetValue(); // Read the MTP status
   365 
   360 
   366     // Check for keypadlock if the events are from device keypad
   361     // Check for keypadlock if the events are from device keypad
   367     // If events are from accessory device,then do not check for keypadlock
   362     // If events are from accessory device,then do not check for keypadlock
   368     if (aKeyType != EAccessoryVolumeKeys && aKeyType != ESideVolumeKeys )
   363     if (aKeyType != EAccessoryVolumeKeys && aKeyType != ESideVolumeKeys )
   369         {
   364         {
   370         TBool keysLocked = EFalse;
   365                
   371         if (!(iAknServerConnected))  // Connect to server for first time
   366         TInt err=iKeyguardAccess->ShowKeysLockedNote();
       
   367 
       
   368         if (err==KErrNone)
   372             {
   369             {
   373             if(iAknServer.Connect() == KErrNone)
   370             // Device is locked , Discard the key event
   374                 {
   371 
   375                 iAknServerConnected = ETrue;
   372             //Start the listener once again
   376                 }
   373             
   377             else if (aKeyType == EMediaKeys)                 // If connection fails, then return
   374             if (aKeyType == EMediaKeys)
   378                 {
   375                 {
   379                 iMediaKeyObserver->Start();
   376                 iMediaKeyObserver->Start();
   380 	    	return ;
       
   381                 }
   377                 }
   382             }
   378 
   383         iAknServer.ShowKeysLockedNote(keysLocked);
       
   384 
       
   385         if (keysLocked && aKeyType == EMediaKeys)
       
   386             {
       
   387             // Device is locked , Discard the key event
       
   388             iMediaKeyObserver->Start();
       
   389             return;
   379             return;
   390             }
   380             }
   391         }
   381         }
   392 
   382 
   393     /* To keep the background light on */
   383     /* To keep the background light on */
   416 
   406 
   417     // Msgtype  is ERemConCommand
   407     // Msgtype  is ERemConCommand
   418     TInt aError = Observer().NewCommand(addr);
   408     TInt aError = Observer().NewCommand(addr);
   419 
   409 
   420     //Start the listener once again
   410     //Start the listener once again
   421     if (aKeyType == EMediaKeys)
   411     if (aKeyType == ESideVolumeKeys)
       
   412         {
       
   413         iMMKeyBearerObserver->Start();
       
   414         }
       
   415     else if (aKeyType == EMediaKeys)
   422         {
   416         {
   423         iMediaKeyObserver->Start();
   417         iMediaKeyObserver->Start();
   424         }
   418         }
   425     else if (aKeyType == EAccessoryVolumeKeys)
   419     else if (aKeyType == EAccessoryVolumeKeys)
   426         {
   420         {