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 |
29 |
30 |
30 #include "cusbwatcher.h" |
31 #include "cusbwatcher.h" |
31 #include "cusbactivestate.h" |
32 #include "cusbactivestate.h" |
32 #include "cusbactivepersonalityhandler.h" |
33 #include "cusbactivepersonalityhandler.h" |
33 #include "cusbwatchersession.h" |
34 #include "cusbwatchersession.h" |
104 iUsbDeviceLock = CUsbDeviceLock::NewL( *this ); |
105 iUsbDeviceLock = CUsbDeviceLock::NewL( *this ); |
105 iUsbDeviceLock->Subscribe(); |
106 iUsbDeviceLock->Subscribe(); |
106 iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this ); |
107 iGlobalStateObserver = CUsbGlobalSystemStateObserver::NewL( *this ); |
107 iUsbDevConStarter = CUsbDevConStarter::NewL(); |
108 iUsbDevConStarter = CUsbDevConStarter::NewL(); |
108 iActiveState = CUsbActiveState::NewL( iUsbMan, *this ); |
109 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; |
|
152 } |
151 } |
153 |
152 |
154 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
155 // Get personality plugins. Note that this is done only in normal mode. |
154 // Get personality plugins. Note that this is done only in normal mode. |
156 // ---------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
217 |
216 |
218 // ---------------------------------------------------------------------------- |
217 // ---------------------------------------------------------------------------- |
219 // This method notifies CUsbWatcher class about USB state changes. |
218 // This method notifies CUsbWatcher class about USB state changes. |
220 // ---------------------------------------------------------------------------- |
219 // ---------------------------------------------------------------------------- |
221 // |
220 // |
222 void CUsbWatcher::StateChangeNotifyL( TUsbDeviceState aStateOld, |
221 void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld, |
223 TUsbDeviceState aStateNew ) |
222 TUsbDeviceState aStateNew ) |
224 { |
223 { |
225 LOG_FUNC |
224 LOG_FUNC |
226 |
225 |
227 // Handling USB indicator. This is valid for both A- and B-device cases. |
226 // Handling USB indicator. This is valid for both A- and B-device cases. |
228 // Not show USB indicator in charging mode |
227 // Not show USB indicator in charging mode |
229 if ( iNormalStart ) |
228 if ( iNormalStart ) |
230 { |
229 { |
231 iUsbIndicatorHandler->HandleDeviceStateChangeL( aStateOld, aStateNew, iPersonalityId ); |
230 iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew ); |
232 } |
231 } |
233 |
232 |
234 if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher |
233 if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher |
235 { |
234 { |
236 LOG( "Device state change ignored by UsbWatcher in A-device state" ); |
235 LOG( "Device state change ignored by UsbWatcher in A-device state" ); |
982 // ---------------------------------------------------------------------------- |
981 // ---------------------------------------------------------------------------- |
983 // |
982 // |
984 TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId ) |
983 TInt CUsbWatcher::GetChargingPersonalityId( TInt& aPersonalityId ) |
985 { |
984 { |
986 LOG_FUNC |
985 LOG_FUNC |
987 |
986 |
988 TInt ret = iPersonalityRepository->Get( |
987 TUint32 chargingKey( KUsbWatcherChargingDefaultPersonality ); |
989 KUsbWatcherChargingDefaultPersonality, aPersonalityId ); |
988 // Check if it is now in certificate test mode |
|
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 ); |
990 return ret; |
1008 return ret; |
991 } |
1009 } |
992 |
|
993 |
|
994 |
1010 |
995 // ---------------------------------------------------------------------------- |
1011 // ---------------------------------------------------------------------------- |
996 // Check current A or B device state |
1012 // Check current A or B device state |
997 // ---------------------------------------------------------------------------- |
1013 // ---------------------------------------------------------------------------- |
998 // |
1014 // |