|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <e32cmn.h> |
|
20 #include <UiklafInternalCRKeys.h> |
|
21 |
|
22 // User includes |
|
23 #include "cradioaccessoryobserver.h" |
|
24 #include "cradiorepositorymanager.h" |
|
25 #include "cradiosystemeventcollectorimp.h" |
|
26 #include "cradiosystemeventdetector.h" |
|
27 #include "radioengineutils.h" |
|
28 #include "cradioenginelogger.h" |
|
29 |
|
30 const TInt KVRObserverArrayGranularity( 2 ); |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CRadioSystemEventCollectorImp::CRadioSystemEventCollectorImp() : |
|
37 iSystemEventObservers( KVRObserverArrayGranularity ) |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 void CRadioSystemEventCollectorImp::ConstructL() |
|
46 { |
|
47 RadioEngineUtils::InitializeL(); |
|
48 iSystemEventDetector = CRadioSystemEventDetector::NewL( *this ); |
|
49 |
|
50 iHeadsetObserver = CRadioAccessoryObserver::NewL(); |
|
51 iHeadsetObserver->SetObserver( this ); |
|
52 |
|
53 TInt criticalLevel; |
|
54 CRadioRepositoryManager::GetRepositoryValueL( KCRUidUiklaf, |
|
55 KUikOODDiskCriticalThreshold, criticalLevel ); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CRadioSystemEventCollectorImp* CRadioSystemEventCollectorImp::NewL() |
|
63 { |
|
64 CRadioSystemEventCollectorImp* self = new( ELeave ) CRadioSystemEventCollectorImp; |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CRadioSystemEventCollectorImp::~CRadioSystemEventCollectorImp() |
|
76 { |
|
77 delete iSystemEventDetector; |
|
78 delete iHeadsetObserver; |
|
79 |
|
80 iSystemEventObservers.Close(); |
|
81 RadioEngineUtils::Release(); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Adds a system event observer |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CRadioSystemEventCollectorImp::AddObserverL( MRadioSystemEventObserver* aHeadsetObserver ) |
|
89 { |
|
90 iSystemEventObservers.AppendL( aHeadsetObserver ); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // Removes a system event observer |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CRadioSystemEventCollectorImp::RemoveObserver( MRadioSystemEventObserver* aSystemObserver ) |
|
98 { |
|
99 TInt objectIndex = iSystemEventObservers.Find( aSystemObserver ); |
|
100 |
|
101 if ( objectIndex != KErrNotFound ) |
|
102 { |
|
103 iSystemEventObservers.Remove( objectIndex ); |
|
104 } |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Getter for mobile network state |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CRadioSystemEventCollectorImp::IsMobileNetworkCoverage() const |
|
112 { |
|
113 return iSystemEventDetector->IsMobileNetworkCoverage(); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Getter for network state |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CRadioSystemEventCollectorImp::IsNetworkCoverage() const |
|
121 { |
|
122 return iSystemEventDetector->IsNetworkCoverage(); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // Getter for call state |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 TBool CRadioSystemEventCollectorImp::IsCallActive() const |
|
130 { |
|
131 return iSystemEventDetector->IsCallActive(); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // Getter for audio resource state |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 TBool CRadioSystemEventCollectorImp::IsAudioResourcesAvailable() const |
|
139 { |
|
140 return iSystemEventDetector->IsAudioResourcesAvailable(); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Getter for headset connection status |
|
145 // --------------------------------------------------------------------------- |
|
146 TBool CRadioSystemEventCollectorImp::IsHeadsetConnectedL() const |
|
147 { |
|
148 return iHeadsetObserver->IsHeadsetConnectedL(); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
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 |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CRadioSystemEventCollectorImp::NotifyObserversL( TRadioSystemEventType aEvent ) |
|
164 { |
|
165 for ( TInt i = 0; i < iSystemEventObservers.Count(); ++i ) |
|
166 { |
|
167 iSystemEventObservers[i]->HandleSystemEventL( aEvent ); |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // From class MRadioSystemEventDetectorObserver. |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CRadioSystemEventCollectorImp::NetworkUpCallbackL() |
|
176 { |
|
177 NotifyObserversL( ERadioNetworkCoverageUp ); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // From class MRadioSystemEventDetectorObserver. |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CRadioSystemEventCollectorImp::NetworkDownCallbackL() |
|
185 { |
|
186 NotifyObserversL( ERadioNetworkCoverageDown ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // From class MRadioSystemEventDetectorObserver. |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CRadioSystemEventCollectorImp::CallActivatedCallbackL() |
|
194 { |
|
195 NotifyObserversL( ERadioCallActivated ); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // From class MRadioSystemEventDetectorObserver. |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CRadioSystemEventCollectorImp::CallDeactivatedCallbackL() |
|
203 { |
|
204 NotifyObserversL( ERadioCallDeactivated ); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // From class MRadioSystemEventDetectorObserver. |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CRadioSystemEventCollectorImp::AudioResourcesAvailableL() |
|
212 { |
|
213 NotifyObserversL( ERadioAudioResourcesAvailable ); |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // From class MRadioSystemEventDetectorObserver. |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 void CRadioSystemEventCollectorImp::AudioAutoResumeForbiddenL() |
|
221 { |
|
222 NotifyObserversL( ERadioAudioAutoResumeForbidden ); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // From class MRadioSystemEventDetectorObserver. |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CRadioSystemEventCollectorImp::ErrorCallbackL( TInt DEBUGVAR( aError ) ) |
|
230 { |
|
231 LOG_FORMAT( "CRadioSystemEventCollectorImp::ErrorCallbackL - %d", aError ); |
|
232 // P&S get fail not considered as a critical issue. |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // From class MRadioHeadsetEventObserver. |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CRadioSystemEventCollectorImp::HeadsetConnectedCallbackL() |
|
240 { |
|
241 NotifyObserversL( ERadioHeadsetConnected ); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // From class MRadioHeadsetEventObserver. |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void CRadioSystemEventCollectorImp::HeadsetDisconnectedCallbackL() |
|
249 { |
|
250 NotifyObserversL( ERadioHeadsetDisconnected ); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // From class MRadioAudioRoutingObserver. |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CRadioSystemEventCollectorImp::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute ) |
|
258 { |
|
259 TRadioSystemEventType ev = ERadioAudioRouteHeadset; |
|
260 if ( aRoute != RadioEngine::ERadioHeadset ) |
|
261 { |
|
262 ev = ERadioAudioRouteSpeaker; |
|
263 } |
|
264 |
|
265 NotifyObserversL( ev ); |
|
266 } |