equal
deleted
inserted
replaced
220 void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld, |
220 void CUsbWatcher::StateChangeNotify( TUsbDeviceState aStateOld, |
221 TUsbDeviceState aStateNew ) |
221 TUsbDeviceState aStateNew ) |
222 { |
222 { |
223 LOG_FUNC |
223 LOG_FUNC |
224 |
224 |
225 if( IsDeviceA() ) // Will be handled by UsbOtgWatcher |
225 // Handling USB indicator. This is valid for both A- and B-device cases. |
|
226 // Not show USB indicator in charging mode |
|
227 if ( iNormalStart ) |
|
228 { |
|
229 iUsbIndicatorHandler.HandleDeviceStateChange( aStateOld, aStateNew ); |
|
230 } |
|
231 |
|
232 if ( IsDeviceA() ) // Will be handled by UsbOtgWatcher |
226 { |
233 { |
227 LOG( "Device state change ignored by UsbWatcher in A-device state" ); |
234 LOG( "Device state change ignored by UsbWatcher in A-device state" ); |
228 return; |
235 return; |
229 } |
236 } |
230 |
237 |
531 { |
538 { |
532 LOG_FUNC |
539 LOG_FUNC |
533 |
540 |
534 LOG2( "aPersonalityId=%d, aNonBlocking=%d", aPersonalityId, aNonBlocking ); |
541 LOG2( "aPersonalityId=%d, aNonBlocking=%d", aPersonalityId, aNonBlocking ); |
535 |
542 |
536 if( IsDeviceA() ) |
|
537 { |
|
538 LOG( "SetPersonality not allowed in A-device state" ); |
|
539 Notify( KErrAccessDenied ); |
|
540 return; |
|
541 } |
|
542 |
|
543 // Check if personality is exist |
543 // Check if personality is exist |
544 TBool found = EFalse; |
544 TBool found = EFalse; |
545 |
545 |
546 for( TInt i = 0; i < iSupportedPersonalities.Count(); i++ ) |
546 for( TInt i = 0; i < iSupportedPersonalities.Count(); i++ ) |
547 { |
547 { |
677 // |
677 // |
678 void CUsbWatcher::SwitchPersonality( TBool aNonBlocking ) |
678 void CUsbWatcher::SwitchPersonality( TBool aNonBlocking ) |
679 { |
679 { |
680 LOG_FUNC |
680 LOG_FUNC |
681 |
681 |
682 if( IsDeviceA() ) |
|
683 { |
|
684 LOG( "Not allowed in A-device state" ); |
|
685 Notify( KErrAccessDenied ); |
|
686 return; |
|
687 } |
|
688 |
682 |
689 TUsbDeviceState state = iActiveState->CurrentState(); |
683 TUsbDeviceState state = iActiveState->CurrentState(); |
690 LOG1( "Device state : %d", state ); |
684 LOG2( "IsDeviceA: %d, Device state : %d", IsDeviceA(), state ); |
691 |
685 |
692 if( state != EUsbDeviceStateUndefined ) |
686 // As A-device, only cenrep will be updated for the reasons of |
|
687 // - In A-host state, device state will be undefined |
|
688 // - In A-peripheral state, personality change can not happen otherwise |
|
689 // the connection will be lost |
|
690 if ( IsDeviceA() || ( EUsbDeviceStateUndefined == state ) ) |
|
691 { |
|
692 // if no connection -> just save the setting |
|
693 LOG( "CUsbWatcher::SwitchPersonality: Notify" ); |
|
694 Notify( KErrNone ); |
|
695 } |
|
696 else |
693 { |
697 { |
694 switch ( iState ) |
698 switch ( iState ) |
695 { |
699 { |
696 case EUsbStopping: |
700 case EUsbStopping: |
697 case EUsbStarting: |
701 case EUsbStarting: |
720 Start(); |
724 Start(); |
721 } |
725 } |
722 break; |
726 break; |
723 } |
727 } |
724 } |
728 } |
725 else |
|
726 { |
|
727 // if no connection -> just save the setting |
|
728 LOG( "CUsbWatcher::SwitchPersonality: Notify" ); |
|
729 Notify( KErrNone ); |
|
730 } |
|
731 } |
729 } |
732 |
730 |
733 // ---------------------------------------------------------------------------- |
731 // ---------------------------------------------------------------------------- |
734 // This method starts personality loading or continues stop start scenario. |
732 // This method starts personality loading or continues stop start scenario. |
735 // ---------------------------------------------------------------------------- |
733 // ---------------------------------------------------------------------------- |
741 TInt globalState = CUsbGlobalSystemStateObserver::GlobalSystemState(); |
739 TInt globalState = CUsbGlobalSystemStateObserver::GlobalSystemState(); |
742 |
740 |
743 if( iState == EUsbIdle ) |
741 if( iState == EUsbIdle ) |
744 { |
742 { |
745 iStarted = EFalse; |
743 iStarted = EFalse; |
|
744 iNormalStart = EFalse; |
746 if( globalState == ESwStateCharging ) |
745 if( globalState == ESwStateCharging ) |
747 { |
746 { |
748 LOG( "Global state: charging" ); |
747 LOG( "Global state: charging" ); |
749 iGlobalStateObserver->Subscribe(); |
748 iGlobalStateObserver->Subscribe(); |
750 iPrevPersonalityId=iPersonalityId; |
749 iPrevPersonalityId=iPersonalityId; |
768 else if( ( ( ESwStateNormalRfOn == globalState ) || |
767 else if( ( ( ESwStateNormalRfOn == globalState ) || |
769 ( ESwStateNormalRfOff == globalState ) || |
768 ( ESwStateNormalRfOff == globalState ) || |
770 ( ESwStateNormalBTSap == globalState ) )) |
769 ( ESwStateNormalBTSap == globalState ) )) |
771 { |
770 { |
772 LOG( "Global state: normal" ); |
771 LOG( "Global state: normal" ); |
|
772 iNormalStart = ETrue; |
773 if( ! iUsbDeviceLock->Locked() ) |
773 if( ! iUsbDeviceLock->Locked() ) |
774 { |
774 { |
775 iGlobalStateObserver->Cancel(); |
775 iGlobalStateObserver->Cancel(); |
776 RProperty::Set( KPSUidUsbWatcher, |
776 RProperty::Set( KPSUidUsbWatcher, |
777 KUsbWatcherSelectedPersonality, iPersonalityId ); |
777 KUsbWatcherSelectedPersonality, iPersonalityId ); |