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