usbengines/usbwatcher/src/cusbwatcher.cpp
branchRCL_3
changeset 24 e02eb84a14d2
parent 23 25fce757be94
--- a/usbengines/usbwatcher/src/cusbwatcher.cpp	Tue Aug 31 16:13:57 2010 +0300
+++ b/usbengines/usbwatcher/src/cusbwatcher.cpp	Wed Sep 01 12:20:49 2010 +0100
@@ -26,6 +26,7 @@
 #include <UsbWatcherInternalPSKeys.h>
 #include <e32property.h>
 #include <startupdomainpskeys.h> //for global system state
+#include <featmgr.h> //FeatureManager
 
 #include "cusbwatcher.h"
 #include "cusbactivestate.h"
@@ -106,7 +107,6 @@
     iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this );
     iUsbDevConStarter = CUsbDevConStarter::NewL();
     iActiveState = CUsbActiveState::NewL( iUsbMan, *this );
-    iUsbIndicatorHandler   = CUsbIndicatorHandler::NewL();
     }
 
 // ----------------------------------------------------------------------------
@@ -148,7 +148,6 @@
     delete iUsbDeviceLock;
     delete iGlobalStateObserver;
     iSupportedPersonalities.Close();
-    delete iUsbIndicatorHandler;
     }
 
 // ----------------------------------------------------------------------------
@@ -219,7 +218,7 @@
 // This method notifies CUsbWatcher class about USB state changes.
 // ----------------------------------------------------------------------------
 //
-void CUsbWatcher::StateChangeNotifyL( TUsbDeviceState aStateOld,  
+void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld,  
         TUsbDeviceState aStateNew )
     {
     LOG_FUNC
@@ -228,7 +227,7 @@
     // Not show USB indicator in charging mode
     if ( iNormalStart ) 
         {
-        iUsbIndicatorHandler->HandleDeviceStateChangeL( aStateOld, aStateNew, iPersonalityId );
+        iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew );
         }
         
     if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher
@@ -984,14 +983,31 @@
 TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId )
     {
     LOG_FUNC
+    
+    TUint32 chargingKey( KUsbWatcherChargingDefaultPersonality );
+    // Check if it is now in certificate test mode
+    TRAPD(ret, FeatureManager::InitializeLibL());
+    LOG1( "FeatureManager::InitializeLibL(): %d", ret );
+    if ( KErrNone == ret )
+        {
+        if( FeatureManager::FeatureSupported(
+             KFeatureIdEnableIsiCommunicationInUsbChargingMode  ) )
+            {
+            chargingKey = KUsbWatcherCertTestChargingPersonality;
+            LOG( "KFeatureIdEnableIsiCommunicationInUsbChargingMode true" );
+            }
+        else
+            {
+            LOG( "KFeatureIdEnableIsiCommunicationInUsbChargingMode false" );
+            }
+        FeatureManager::UnInitializeLib();
+        }
 
-    TInt ret = iPersonalityRepository->Get(
-            KUsbWatcherChargingDefaultPersonality, aPersonalityId );
+    ret = iPersonalityRepository->Get( chargingKey, aPersonalityId );
+    LOG2( "ret = %d ( aPersonalityId: %d )", ret, aPersonalityId );
     return ret;
     }
 
-
-
 // ----------------------------------------------------------------------------
 // Check current A or B device state
 // ----------------------------------------------------------------------------