equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
249 { |
249 { |
250 LOG1( "Not starting personality, previous state: %d", |
250 LOG1( "Not starting personality, previous state: %d", |
251 aStateOld); |
251 aStateOld); |
252 break; |
252 break; |
253 } |
253 } |
254 LOG1( "Starting USB personality in device state: %d", aStateNew ); |
254 LOG1( "Starting USB personality in device state: %d", aStateNew ); |
255 iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew ); |
255 iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew ); |
256 // Check AskOnConnection setting every time |
256 // Check AskOnConnection setting every time |
257 if( ( iSupportedPersonalities.Count() > 1 ) && |
257 if( ( iSupportedPersonalities.Count() > 1 ) && |
258 !IsAskOnConnectionSuppression() ) |
258 !IsAskOnConnectionSuppression() ) |
259 { |
259 { |
385 switch ( iState ) |
385 switch ( iState ) |
386 { |
386 { |
387 case EUsbStarting: |
387 case EUsbStarting: |
388 LOG( "Personality started" ); |
388 LOG( "Personality started" ); |
389 Notify( ret ); |
389 Notify( ret ); |
|
390 if( iStopStartScenario ) |
|
391 { |
|
392 iStopStartScenario = EFalse; |
|
393 } |
|
394 //check if StartPersonality() fails |
|
395 LEAVEIFERROR( ret ); |
390 iState = EUsbStarted; |
396 iState = EUsbStarted; |
391 if( iStopStartScenario ) |
|
392 { |
|
393 iStopStartScenario = EFalse; |
|
394 } |
|
395 break; |
397 break; |
396 |
398 |
397 case EUsbStopping: |
399 case EUsbStopping: |
398 LOG( "Personality stopped" ); |
400 LOG( "Personality stopped" ); |
399 iState = EUsbIdle; |
401 iState = EUsbIdle; |
451 |
453 |
452 // ---------------------------------------------------------------------------- |
454 // ---------------------------------------------------------------------------- |
453 // This method is not called cause RunL() never leaves. |
455 // This method is not called cause RunL() never leaves. |
454 // ---------------------------------------------------------------------------- |
456 // ---------------------------------------------------------------------------- |
455 // |
457 // |
456 TInt CUsbWatcher::RunError(TInt /*aError*/) |
458 TInt CUsbWatcher::RunError(TInt aError) |
457 { |
459 { |
458 LOG_FUNC |
460 LOG_FUNC |
459 // Left empty cause this can't happend |
461 |
|
462 LOG2("Returned error: %d, iState: %d", aError, iState); |
|
463 if ( iState == EUsbStarting ) |
|
464 { |
|
465 RProperty::Set( KPSUidUsbWatcher, |
|
466 KUsbWatcherSelectedPersonality, |
|
467 KUsbWatcherSelectedPersonalityNone ); |
|
468 LOG( "personality set to none" ); |
|
469 |
|
470 iState = EUsbIdle; |
|
471 } |
|
472 |
460 return KErrNone; |
473 return KErrNone; |
461 } |
474 } |
462 |
475 |
463 // ---------------------------------------------------------------------------- |
476 // ---------------------------------------------------------------------------- |
464 // Function is called when state of the device is locked. |
477 // Function is called when state of the device is locked. |
1030 //NOT LOGGED |
1043 //NOT LOGGED |
1031 // return EFalse in non-OTG configuration otherwise ask UsbOtgWatcher |
1044 // return EFalse in non-OTG configuration otherwise ask UsbOtgWatcher |
1032 return iOtgWatcher ? iOtgWatcher->IsDeviceA() : EFalse; |
1045 return iOtgWatcher ? iOtgWatcher->IsDeviceA() : EFalse; |
1033 } |
1046 } |
1034 |
1047 |
|
1048 // ---------------------------------------------------------------------------- |
|
1049 // Write new personality to central repository. |
|
1050 // ---------------------------------------------------------------------------- |
|
1051 // |
|
1052 TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId ) |
|
1053 { |
|
1054 LOG_FUNC |
|
1055 |
|
1056 // Save as the default personality only if it is not hidden |
|
1057 TUint32 property(0); |
|
1058 TInt ret = iUsbMan.GetPersonalityProperty( aPersonalityId, property ); |
|
1059 if ( ret == KErrNone ) |
|
1060 { |
|
1061 LOG2( "Personality %d property: 0x%x", aPersonalityId, property ); |
|
1062 } |
|
1063 else |
|
1064 { |
|
1065 //Not fatal, treat as non-hidden |
|
1066 LOG1( "ERROR: GetPersonalityProperty = %d", ret ); |
|
1067 property = 0; |
|
1068 } |
|
1069 if ( property & KUsbPersonalityPropertyHidden ) //Bitwise AND |
|
1070 { |
|
1071 LOG( "Hidden personality not saved to central repository" ); |
|
1072 ret = KErrNone; |
|
1073 } |
|
1074 else |
|
1075 { |
|
1076 ret = iPersonalityRepository->Set( KUsbWatcherPersonality, |
|
1077 aPersonalityId ); |
|
1078 } |
|
1079 return ret; |
|
1080 } |
|
1081 |
1035 // End of file |
1082 // End of file |