radioengine/utils/src/cradiosystemeventcollectorimp.cpp
changeset 28 075425b8d9a4
parent 24 6df133bd92e1
child 37 451b2e1545b2
child 38 f8c3d4e6102c
equal deleted inserted replaced
24:6df133bd92e1 28:075425b8d9a4
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <e32cmn.h>
    19 #include <e32cmn.h>
    20 #include <UiklafInternalCRKeys.h>
       
    21 
    20 
    22 // User includes
    21 // User includes
    23 #include "cradioaccessoryobserver.h"
    22 #include "cradioaccessoryobserver.h"
    24 #include "cradiorepositorymanager.h"
    23 #include "cradiorepositorymanager.h"
    25 #include "cradiosystemeventcollectorimp.h"
    24 #include "cradiosystemeventcollectorimp.h"
    34 // ---------------------------------------------------------------------------
    33 // ---------------------------------------------------------------------------
    35 //
    34 //
    36 CRadioSystemEventCollectorImp::CRadioSystemEventCollectorImp() :
    35 CRadioSystemEventCollectorImp::CRadioSystemEventCollectorImp() :
    37     iSystemEventObservers( KVRObserverArrayGranularity )
    36     iSystemEventObservers( KVRObserverArrayGranularity )
    38     {
    37     {
       
    38     LEVEL3( LOG_METHOD_AUTO );
    39     }
    39     }
    40 
    40 
    41 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    42 //
    42 //
    43 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    44 //
    44 //
    45 void CRadioSystemEventCollectorImp::ConstructL()
    45 void CRadioSystemEventCollectorImp::ConstructL()
    46     {
    46     {
       
    47     LEVEL3( LOG_METHOD_AUTO );
    47     RadioEngineUtils::InitializeL();
    48     RadioEngineUtils::InitializeL();
    48     iSystemEventDetector = CRadioSystemEventDetector::NewL( *this );
    49     iSystemEventDetector = CRadioSystemEventDetector::NewL( *this );
    49 
    50 
    50     iHeadsetObserver = CRadioAccessoryObserver::NewL();
    51     iHeadsetObserver = CRadioAccessoryObserver::NewL();
    51     iHeadsetObserver->SetObserver( this );
    52     iHeadsetObserver->SetObserver( this );
    52 
       
    53     TInt criticalLevel;
       
    54     CRadioRepositoryManager::GetRepositoryValueL( KCRUidUiklaf,
       
    55         KUikOODDiskCriticalThreshold, criticalLevel );
       
    56     }
    53     }
    57 
    54 
    58 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    59 //
    56 //
    60 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    61 //
    58 //
    62 CRadioSystemEventCollectorImp* CRadioSystemEventCollectorImp::NewL()
    59 CRadioSystemEventCollectorImp* CRadioSystemEventCollectorImp::NewL()
    63     {
    60     {
       
    61     LEVEL3( LOG_METHOD_AUTO );
    64     CRadioSystemEventCollectorImp* self = new( ELeave ) CRadioSystemEventCollectorImp;
    62     CRadioSystemEventCollectorImp* self = new( ELeave ) CRadioSystemEventCollectorImp;
    65     CleanupStack::PushL( self );
    63     CleanupStack::PushL( self );
    66     self->ConstructL();
    64     self->ConstructL();
    67     CleanupStack::Pop( self );
    65     CleanupStack::Pop( self );
    68     return self;
    66     return self;
    72 //
    70 //
    73 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    74 //
    72 //
    75 CRadioSystemEventCollectorImp::~CRadioSystemEventCollectorImp()
    73 CRadioSystemEventCollectorImp::~CRadioSystemEventCollectorImp()
    76     {
    74     {
       
    75     LEVEL3( LOG_METHOD_AUTO );
    77     delete iSystemEventDetector;
    76     delete iSystemEventDetector;
    78     delete iHeadsetObserver;
    77     delete iHeadsetObserver;
    79 
    78 
    80     iSystemEventObservers.Close();
    79     iSystemEventObservers.Close();
    81     RadioEngineUtils::Release();
    80     RadioEngineUtils::Release();
    85 // Adds a system event observer
    84 // Adds a system event observer
    86 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
    87 //
    86 //
    88 void CRadioSystemEventCollectorImp::AddObserverL( MRadioSystemEventObserver* aHeadsetObserver )
    87 void CRadioSystemEventCollectorImp::AddObserverL( MRadioSystemEventObserver* aHeadsetObserver )
    89     {
    88     {
       
    89     LEVEL3( LOG_METHOD_AUTO );
    90     iSystemEventObservers.AppendL( aHeadsetObserver );
    90     iSystemEventObservers.AppendL( aHeadsetObserver );
    91     }
    91     }
    92 
    92 
    93 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    94 // Removes a system event observer
    94 // Removes a system event observer
    95 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
    96 //
    96 //
    97  void CRadioSystemEventCollectorImp::RemoveObserver( MRadioSystemEventObserver* aSystemObserver )
    97  void CRadioSystemEventCollectorImp::RemoveObserver( MRadioSystemEventObserver* aSystemObserver )
    98     {
    98     {
       
    99      LEVEL3( LOG_METHOD_AUTO );
    99     TInt objectIndex = iSystemEventObservers.Find( aSystemObserver );
   100     TInt objectIndex = iSystemEventObservers.Find( aSystemObserver );
   100 
   101 
   101     if ( objectIndex != KErrNotFound )
   102     if ( objectIndex != KErrNotFound )
   102         {
   103         {
   103         iSystemEventObservers.Remove( objectIndex );
   104         iSystemEventObservers.Remove( objectIndex );
   108 // Getter for mobile network state
   109 // Getter for mobile network state
   109 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   110 //
   111 //
   111 TBool CRadioSystemEventCollectorImp::IsMobileNetworkCoverage() const
   112 TBool CRadioSystemEventCollectorImp::IsMobileNetworkCoverage() const
   112     {
   113     {
       
   114     LEVEL3( LOG_METHOD_AUTO );
   113     return iSystemEventDetector->IsMobileNetworkCoverage();
   115     return iSystemEventDetector->IsMobileNetworkCoverage();
   114     }
   116     }
   115 
   117 
   116 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   117 // Getter for network state
   119 // Getter for network state
   118 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   119 //
   121 //
   120 TBool CRadioSystemEventCollectorImp::IsNetworkCoverage() const
   122 TBool CRadioSystemEventCollectorImp::IsNetworkCoverage() const
   121     {
   123     {
       
   124     LEVEL3( LOG_METHOD_AUTO );
   122     return iSystemEventDetector->IsNetworkCoverage();
   125     return iSystemEventDetector->IsNetworkCoverage();
   123     }
   126     }
   124 
   127 
   125 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   126 // Getter for call state
   129 // Getter for call state
   127 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   128 //
   131 //
   129 TBool CRadioSystemEventCollectorImp::IsCallActive() const
   132 TBool CRadioSystemEventCollectorImp::IsCallActive() const
   130     {
   133     {
       
   134     LEVEL3( LOG_METHOD_AUTO );
   131     return iSystemEventDetector->IsCallActive();
   135     return iSystemEventDetector->IsCallActive();
   132     }
   136     }
   133 
   137 
   134 // ---------------------------------------------------------------------------
   138 // ---------------------------------------------------------------------------
   135 // Getter for audio resource state
   139 // Getter for audio resource state
   136 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   137 //
   141 //
   138 TBool CRadioSystemEventCollectorImp::IsAudioResourcesAvailable() const
   142 TBool CRadioSystemEventCollectorImp::IsAudioResourcesAvailable() const
   139     {
   143     {
       
   144     LEVEL3( LOG_METHOD_AUTO );
   140     return iSystemEventDetector->IsAudioResourcesAvailable();
   145     return iSystemEventDetector->IsAudioResourcesAvailable();
   141     }
   146     }
   142 
   147 
   143 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   144 // Getter for headset connection status
   149 // Getter for headset connection status
   145 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   146 TBool CRadioSystemEventCollectorImp::IsHeadsetConnectedL() const
   151 TBool CRadioSystemEventCollectorImp::IsHeadsetConnectedL() const
   147     {
   152     {
       
   153     LEVEL3( LOG_METHOD_AUTO );
   148     return iHeadsetObserver->IsHeadsetConnectedL();
   154     return iHeadsetObserver->IsHeadsetConnectedL();
   149     }
   155     }
   150 
   156 
   151 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   152 // Getter Vocie UI state
       
   153 // ---------------------------------------------------------------------------
       
   154 TBool CRadioSystemEventCollectorImp::IsVoiceUiActive() const
       
   155     {
       
   156     return iSystemEventDetector->IsVoiceUiActive();
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // Notifies the observers of system event
   158 // Notifies the observers of system event
   161 // ---------------------------------------------------------------------------
   159 // ---------------------------------------------------------------------------
   162 //
   160 //
   163 void CRadioSystemEventCollectorImp::NotifyObserversL( TRadioSystemEventType aEvent )
   161 void CRadioSystemEventCollectorImp::NotifyObserversL( TRadioSystemEventType aEvent )
   164     {
   162     {
       
   163     LEVEL3( LOG_METHOD_AUTO );
   165     for ( TInt i = 0; i < iSystemEventObservers.Count(); ++i )
   164     for ( TInt i = 0; i < iSystemEventObservers.Count(); ++i )
   166         {
   165         {
   167         iSystemEventObservers[i]->HandleSystemEventL( aEvent );
   166         iSystemEventObservers[i]->HandleSystemEventL( aEvent );
   168         }
   167         }
   169     }
   168     }
   172 // From class MRadioSystemEventDetectorObserver.
   171 // From class MRadioSystemEventDetectorObserver.
   173 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   174 //
   173 //
   175 void CRadioSystemEventCollectorImp::NetworkUpCallbackL()
   174 void CRadioSystemEventCollectorImp::NetworkUpCallbackL()
   176     {
   175     {
       
   176     LEVEL3( LOG_METHOD_AUTO );
   177     NotifyObserversL( ERadioNetworkCoverageUp );
   177     NotifyObserversL( ERadioNetworkCoverageUp );
   178     }
   178     }
   179 
   179 
   180 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   181 // From class MRadioSystemEventDetectorObserver.
   181 // From class MRadioSystemEventDetectorObserver.
   182 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   183 //
   183 //
   184 void CRadioSystemEventCollectorImp::NetworkDownCallbackL()
   184 void CRadioSystemEventCollectorImp::NetworkDownCallbackL()
   185     {
   185     {
       
   186     LEVEL3( LOG_METHOD_AUTO );
   186     NotifyObserversL( ERadioNetworkCoverageDown );
   187     NotifyObserversL( ERadioNetworkCoverageDown );
   187     }
   188     }
   188 
   189 
   189 // ---------------------------------------------------------------------------
   190 // ---------------------------------------------------------------------------
   190 // From class MRadioSystemEventDetectorObserver.
   191 // From class MRadioSystemEventDetectorObserver.
   191 // ---------------------------------------------------------------------------
   192 // ---------------------------------------------------------------------------
   192 //
   193 //
   193 void CRadioSystemEventCollectorImp::CallActivatedCallbackL()
   194 void CRadioSystemEventCollectorImp::CallActivatedCallbackL()
   194     {
   195     {
       
   196     LEVEL3( LOG_METHOD_AUTO );
   195     NotifyObserversL( ERadioCallActivated );
   197     NotifyObserversL( ERadioCallActivated );
   196     }
   198     }
   197 
   199 
   198 // ---------------------------------------------------------------------------
   200 // ---------------------------------------------------------------------------
   199 // From class MRadioSystemEventDetectorObserver.
   201 // From class MRadioSystemEventDetectorObserver.
   200 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   201 //
   203 //
   202 void CRadioSystemEventCollectorImp::CallDeactivatedCallbackL()
   204 void CRadioSystemEventCollectorImp::CallDeactivatedCallbackL()
   203     {
   205     {
       
   206     LEVEL3( LOG_METHOD_AUTO );
   204     NotifyObserversL( ERadioCallDeactivated );
   207     NotifyObserversL( ERadioCallDeactivated );
   205     }
   208     }
   206 
   209 
   207 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   208 // From class MRadioSystemEventDetectorObserver.
   211 // From class MRadioSystemEventDetectorObserver.
   209 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   210 //
   213 //
   211 void CRadioSystemEventCollectorImp::AudioResourcesAvailableL()
   214 void CRadioSystemEventCollectorImp::AudioResourcesAvailableL()
   212     {
   215     {
       
   216     LEVEL3( LOG_METHOD_AUTO );
   213     NotifyObserversL( ERadioAudioResourcesAvailable );
   217     NotifyObserversL( ERadioAudioResourcesAvailable );
   214     }
   218     }
   215 
   219 
   216 // ---------------------------------------------------------------------------
   220 // ---------------------------------------------------------------------------
   217 // From class MRadioSystemEventDetectorObserver.
   221 // From class MRadioSystemEventDetectorObserver.
   218 // ---------------------------------------------------------------------------
   222 // ---------------------------------------------------------------------------
   219 //
   223 //
   220 void CRadioSystemEventCollectorImp::AudioAutoResumeForbiddenL()
   224 void CRadioSystemEventCollectorImp::AudioAutoResumeForbiddenL()
   221     {
   225     {
       
   226     LEVEL3( LOG_METHOD_AUTO );
   222     NotifyObserversL( ERadioAudioAutoResumeForbidden );
   227     NotifyObserversL( ERadioAudioAutoResumeForbidden );
   223     }
   228     }
   224 
   229 
   225 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   226 // From class MRadioSystemEventDetectorObserver.
   231 // From class MRadioSystemEventDetectorObserver.
   227 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   228 //
   233 //
   229 void CRadioSystemEventCollectorImp::ErrorCallbackL( TInt DEBUGVAR( aError ) )
   234 void CRadioSystemEventCollectorImp::ErrorCallbackL( TInt DEBUGVAR3( aError ) )
   230     {
   235     {
   231     LOG_FORMAT( "CRadioSystemEventCollectorImp::ErrorCallbackL - %d", aError );
   236     LEVEL3( LOG_METHOD_AUTO );
       
   237     LEVEL3( LOG_FORMAT( "aError = %d", aError ) );
   232     // P&S get fail not considered as a critical issue.
   238     // P&S get fail not considered as a critical issue.
   233     }
   239     }
   234 
   240 
   235 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   236 // From class MRadioHeadsetEventObserver.
   242 // From class MRadioHeadsetEventObserver.
   237 // ---------------------------------------------------------------------------
   243 // ---------------------------------------------------------------------------
   238 //
   244 //
   239 void CRadioSystemEventCollectorImp::HeadsetConnectedCallbackL()
   245 void CRadioSystemEventCollectorImp::HeadsetConnectedCallbackL()
   240     {
   246     {
       
   247     LEVEL3( LOG_METHOD_AUTO );
   241     NotifyObserversL( ERadioHeadsetConnected );
   248     NotifyObserversL( ERadioHeadsetConnected );
   242     }
   249     }
   243 
   250 
   244 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   245 // From class MRadioHeadsetEventObserver.
   252 // From class MRadioHeadsetEventObserver.
   246 // ---------------------------------------------------------------------------
   253 // ---------------------------------------------------------------------------
   247 //
   254 //
   248 void CRadioSystemEventCollectorImp::HeadsetDisconnectedCallbackL()
   255 void CRadioSystemEventCollectorImp::HeadsetDisconnectedCallbackL()
   249     {
   256     {
       
   257     LEVEL3( LOG_METHOD_AUTO );
   250     NotifyObserversL( ERadioHeadsetDisconnected );
   258     NotifyObserversL( ERadioHeadsetDisconnected );
   251     }
   259     }
   252 
   260 
   253 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   254 // From class MRadioAudioRoutingObserver.
   262 // From class MRadioAudioRoutingObserver.
   255 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   256 //
   264 //
   257 void CRadioSystemEventCollectorImp::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute )
   265 void CRadioSystemEventCollectorImp::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute )
   258     {
   266     {
       
   267     LEVEL3( LOG_METHOD_AUTO );
   259     TRadioSystemEventType ev = ERadioAudioRouteHeadset;
   268     TRadioSystemEventType ev = ERadioAudioRouteHeadset;
   260     if ( aRoute != RadioEngine::ERadioHeadset )
   269     if ( aRoute != RadioEngine::ERadioHeadset )
   261         {
   270         {
   262         ev = ERadioAudioRouteSpeaker;
   271         ev = ERadioAudioRouteSpeaker;
   263         }
   272         }