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