usbengines/usbwatcher/src/cusbwatcher.cpp
branchRCL_3
changeset 79 25fce757be94
parent 77 5b2a402e96ac
child 80 e02eb84a14d2
equal deleted inserted replaced
77:5b2a402e96ac 79:25fce757be94
    24 #include <UsbWatcherInternalCRKeys.h>
    24 #include <UsbWatcherInternalCRKeys.h>
    25 #include <cusbpersonalitynotifier.h>
    25 #include <cusbpersonalitynotifier.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    27 #include <e32property.h>
    27 #include <e32property.h>
    28 #include <startupdomainpskeys.h> //for global system state
    28 #include <startupdomainpskeys.h> //for global system state
    29 #include <featmgr.h> //FeatureManager
       
    30 
    29 
    31 #include "cusbwatcher.h"
    30 #include "cusbwatcher.h"
    32 #include "cusbactivestate.h"
    31 #include "cusbactivestate.h"
    33 #include "cusbactivepersonalityhandler.h"
    32 #include "cusbactivepersonalityhandler.h"
    34 #include "cusbwatchersession.h"
    33 #include "cusbwatchersession.h"
   105     iUsbDeviceLock = CUsbDeviceLock::NewL( *this );
   104     iUsbDeviceLock = CUsbDeviceLock::NewL( *this );
   106     iUsbDeviceLock->Subscribe();
   105     iUsbDeviceLock->Subscribe();
   107     iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this );
   106     iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this );
   108     iUsbDevConStarter = CUsbDevConStarter::NewL();
   107     iUsbDevConStarter = CUsbDevConStarter::NewL();
   109     iActiveState = CUsbActiveState::NewL( iUsbMan, *this );
   108     iActiveState = CUsbActiveState::NewL( iUsbMan, *this );
       
   109     iUsbIndicatorHandler   = CUsbIndicatorHandler::NewL();
   110     }
   110     }
   111 
   111 
   112 // ----------------------------------------------------------------------------
   112 // ----------------------------------------------------------------------------
   113 // Two-phased constructor.
   113 // Two-phased constructor.
   114 // ----------------------------------------------------------------------------
   114 // ----------------------------------------------------------------------------
   146     delete iPersonalityRepository;
   146     delete iPersonalityRepository;
   147     delete iOtgWatcher;
   147     delete iOtgWatcher;
   148     delete iUsbDeviceLock;
   148     delete iUsbDeviceLock;
   149     delete iGlobalStateObserver;
   149     delete iGlobalStateObserver;
   150     iSupportedPersonalities.Close();
   150     iSupportedPersonalities.Close();
       
   151     delete iUsbIndicatorHandler;
   151     }
   152     }
   152 
   153 
   153 // ----------------------------------------------------------------------------
   154 // ----------------------------------------------------------------------------
   154 // Get personality plugins. Note that this is done only in normal mode.
   155 // Get personality plugins. Note that this is done only in normal mode.
   155 // ----------------------------------------------------------------------------
   156 // ----------------------------------------------------------------------------
   216 
   217 
   217 // ----------------------------------------------------------------------------
   218 // ----------------------------------------------------------------------------
   218 // This method notifies CUsbWatcher class about USB state changes.
   219 // This method notifies CUsbWatcher class about USB state changes.
   219 // ----------------------------------------------------------------------------
   220 // ----------------------------------------------------------------------------
   220 //
   221 //
   221 void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld,  
   222 void CUsbWatcher::StateChangeNotifyL( TUsbDeviceState aStateOld,  
   222         TUsbDeviceState aStateNew )
   223         TUsbDeviceState aStateNew )
   223     {
   224     {
   224     LOG_FUNC
   225     LOG_FUNC
   225 
   226 
   226     // Handling USB indicator. This is valid for both A- and B-device cases.
   227     // Handling USB indicator. This is valid for both A- and B-device cases.
   227     // Not show USB indicator in charging mode
   228     // Not show USB indicator in charging mode
   228     if ( iNormalStart ) 
   229     if ( iNormalStart ) 
   229         {
   230         {
   230         iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew );
   231         iUsbIndicatorHandler->HandleDeviceStateChangeL( aStateOld, aStateNew, iPersonalityId );
   231         }
   232         }
   232         
   233         
   233     if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher
   234     if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher
   234         {
   235         {
   235         LOG( "Device state change ignored by UsbWatcher in A-device state" );
   236         LOG( "Device state change ignored by UsbWatcher in A-device state" );
   981 // ----------------------------------------------------------------------------
   982 // ----------------------------------------------------------------------------
   982 //
   983 //
   983 TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId )
   984 TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId )
   984     {
   985     {
   985     LOG_FUNC
   986     LOG_FUNC
   986     
   987 
   987     TUint32 chargingKey( KUsbWatcherChargingDefaultPersonality );
   988     TInt ret = iPersonalityRepository->Get(
   988     // Check if it is now in certificate test mode
   989             KUsbWatcherChargingDefaultPersonality, aPersonalityId );
   989     TRAPD(ret, FeatureManager::InitializeLibL());
       
   990     LOG1( "FeatureManager::InitializeLibL(): %d", ret );
       
   991     if ( KErrNone == ret )
       
   992         {
       
   993         if( FeatureManager::FeatureSupported(
       
   994              KFeatureIdEnableIsiCommunicationInUsbChargingMode  ) )
       
   995             {
       
   996             chargingKey = KUsbWatcherCertTestChargingPersonality;
       
   997             LOG( "KFeatureIdEnableIsiCommunicationInUsbChargingMode true" );
       
   998             }
       
   999         else
       
  1000             {
       
  1001             LOG( "KFeatureIdEnableIsiCommunicationInUsbChargingMode false" );
       
  1002             }
       
  1003         FeatureManager::UnInitializeLib();
       
  1004         }
       
  1005 
       
  1006     ret = iPersonalityRepository->Get( chargingKey, aPersonalityId );
       
  1007     LOG2( "ret = %d ( aPersonalityId: %d )", ret, aPersonalityId );
       
  1008     return ret;
   990     return ret;
  1009     }
   991     }
       
   992 
       
   993 
  1010 
   994 
  1011 // ----------------------------------------------------------------------------
   995 // ----------------------------------------------------------------------------
  1012 // Check current A or B device state
   996 // Check current A or B device state
  1013 // ----------------------------------------------------------------------------
   997 // ----------------------------------------------------------------------------
  1014 //
   998 //