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 |
child 41 | 3a6b55c6390c |
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 |
#include <e32def.h> // Define before audiopolicy defs |
|
19 |
#include <e32std.h> // Define before audiopolicy defs |
|
20 |
#include <eikdef.h> |
|
21 |
||
22 |
#ifndef __WINS__ |
|
23 |
||
24 |
#include <audiopolicypubsubdata.h> |
|
25 |
#include <audiosw_pubsubkeys.h> |
|
26 |
||
27 |
#endif //__WINS__ |
|
28 |
||
29 |
#include <ctsydomainpskeys.h> |
|
30 |
#include <publicruntimeids.hrh> |
|
31 |
#include <sacls.h> |
|
32 |
||
33 |
// User includes |
|
34 |
#include "cradioenginelogger.h" |
|
35 |
#include "cradiosystemeventdetector.h" |
|
36 |
#include "mradiosystemeventdetectorobserver.h" |
|
37 |
||
38 |
/** Granularity for audio category arrays. */ |
|
39 |
const TInt KVRAudioCategoryArrayGranularity = 3; |
|
40 |
||
41 |
// This has to be the last include. |
|
42 |
#ifdef STUB_CONSTELLATION |
|
43 |
# include "RadioStubManager.h" |
|
44 |
# define KUidSystemCategory KStub_KUidSystemCategory |
|
45 |
# define KPSUidCtsyCallInformation KStub_KPSUidCtsyCallInformation |
|
46 |
# define KPSUidVoiceUiAccMonitor KStub_KPSUidVoiceUiAccMonitor |
|
47 |
# define KPSUidMMFAudioServer KStub_KPSUidMMFAudioServer |
|
48 |
#endif //STUB_CONSTELLATION |
|
49 |
||
50 |
// ================= MEMBER FUNCTIONS ======================= |
|
51 |
||
52 |
// --------------------------------------------------------------------------- |
|
53 |
// |
|
54 |
// --------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
CRadioSystemEventDetector::CRadioSystemEventDetector( MRadioSystemEventDetectorObserver& aObserver ) |
|
57 |
: iObserver( aObserver ) |
|
58 |
, iIsMobileNetworkCoverage( EFalse ) |
|
59 |
, iIsCallActive( EFalse ) |
|
60 |
, iIsAudioResourcesAvailable( ETrue ) |
|
61 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 63 |
} |
64 |
||
65 |
// --------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
// --------------------------------------------------------------------------- |
|
68 |
// |
|
69 |
void CRadioSystemEventDetector::ConstructL() |
|
70 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
71 |
LOG_METHOD_AUTO; |
24 | 72 |
iNetworkStatusObserver = CRadioPropertyObserver::NewL( *this, |
73 |
KUidSystemCategory, |
|
74 |
KUidNetworkStatusValue, |
|
75 |
CRadioPropertyObserver::ERadioPropertyInt ); |
|
76 |
iNetworkStatusObserver->ActivateL(); |
|
77 |
||
78 |
iIsMobileNetworkCoverage = iNetworkStatusObserver->ValueInt() == ESANetworkAvailable; |
|
79 |
||
80 |
// Initialize call state observer. |
|
81 |
iCallStatusObserver = CRadioPropertyObserver::NewL( *this, |
|
82 |
KPSUidCtsyCallInformation, |
|
83 |
KCTsyCallState, |
|
84 |
CRadioPropertyObserver::ERadioPropertyInt ); |
|
85 |
iCallStatusObserver->ActivateL(); |
|
86 |
iIsCallActive = iCallStatusObserver->ValueInt() != EPSCTsyCallStateNone; |
|
87 |
||
88 |
#ifndef __WINS__ |
|
89 |
// Define audio types for not resuming. |
|
90 |
iNoAutoResumeAudioCategories = RArray<TInt>( KVRAudioCategoryArrayGranularity ); |
|
91 |
iNoAutoResumeAudioCategories.AppendL( ECatMediaPlayer ); |
|
92 |
iNoAutoResumeAudioCategories.AppendL( ECatMobileTv ); |
|
93 |
iNoAutoResumeAudioCategories.AppendL( ECatUnknownPlayer ); |
|
94 |
iNoAutoResumeAudioCategories.Compress(); |
|
95 |
// Start listening audio client events. |
|
96 |
iAudioPolicyObserver = CRadioPropertyObserver::NewL( *this, KPSUidMMFAudioServer, KAudioPolicyAudioClients, CRadioPropertyObserver::ERadioPropertyByteArray ); |
|
97 |
iAudioPolicyObserver->ActivateL(); |
|
98 |
#endif |
|
99 |
} |
|
100 |
||
101 |
// --------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
// --------------------------------------------------------------------------- |
|
104 |
// |
|
105 |
CRadioSystemEventDetector::~CRadioSystemEventDetector() |
|
106 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
107 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 108 |
delete iCallStatusObserver; |
109 |
delete iNetworkStatusObserver; |
|
110 |
delete iAudioPolicyObserver; |
|
111 |
||
112 |
iNoAutoResumeAudioCategories.Close(); |
|
113 |
} |
|
114 |
||
115 |
// --------------------------------------------------------------------------- |
|
116 |
// |
|
117 |
// --------------------------------------------------------------------------- |
|
118 |
// |
|
119 |
CRadioSystemEventDetector* CRadioSystemEventDetector::NewL( MRadioSystemEventDetectorObserver& aObserver ) |
|
120 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
121 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 122 |
CRadioSystemEventDetector* self = new ( ELeave ) CRadioSystemEventDetector( aObserver ); |
123 |
CleanupStack::PushL( self ); |
|
124 |
self->ConstructL(); |
|
125 |
CleanupStack::Pop( self ); |
|
126 |
return self; |
|
127 |
} |
|
128 |
||
129 |
// --------------------------------------------------------------------------- |
|
130 |
// Handling of the int property changes is done here. |
|
131 |
// Observer components are getting notifications in correspondence with what |
|
132 |
// has changed |
|
133 |
// --------------------------------------------------------------------------- |
|
134 |
// |
|
135 |
void CRadioSystemEventDetector::HandlePropertyChangeL( const TUid& aCategory, |
|
136 |
const TUint aKey, |
|
137 |
const TInt aValue ) |
|
138 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
139 |
LEVEL2( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
140 |
if ( aCategory == KPSUidCtsyCallInformation && aKey == KCTsyCallState ) |
24 | 141 |
{ |
142 |
if ( (!iIsCallActive ) && ( aValue > EPSCTsyCallStateNone )) |
|
143 |
{ |
|
144 |
iIsCallActive = ETrue; |
|
145 |
iObserver.CallActivatedCallbackL(); |
|
146 |
} |
|
147 |
else if ( ( iIsCallActive ) && ( aValue <= EPSCTsyCallStateNone )) |
|
148 |
{ |
|
149 |
iIsCallActive = EFalse; |
|
150 |
iObserver.CallDeactivatedCallbackL(); |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
#ifndef __WINS__ |
|
156 |
// --------------------------------------------------------------------------- |
|
157 |
// Handling of the byte array property changes is done here. |
|
158 |
// Observer components are getting notifications in correspondence with what |
|
159 |
// has changed |
|
160 |
// --------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
void CRadioSystemEventDetector::HandlePropertyChangeL( const TUid& aCategory, |
|
163 |
const TUint aKey, |
|
164 |
const TDesC8& aValue ) |
|
165 |
{ |
|
166 |
#if 0 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
167 |
LEVEL2( LOG_METHOD_AUTO ); |
24 | 168 |
LOG_FORMAT( "Category: %d, Key: %d", aCategory, aKey ); |
169 |
if ( aCategory == KPSUidMMFAudioServer ) |
|
170 |
{ |
|
171 |
if ( aKey == KAudioPolicyAudioClients ) |
|
172 |
{ |
|
173 |
TBool atLeastOneAutoResumeAudioPlaying( EFalse ); |
|
174 |
TBool atLeastOneNoAutoResumeAudioPlaying( EFalse ); |
|
175 |
TBool radioPlaying( EFalse ); |
|
176 |
TAudioClientList audioClients; |
|
177 |
audioClients.Copy( aValue ); |
|
178 |
// Check all playing audios! |
|
179 |
for ( TInt i = 0; i < audioClients().iNumOfProcesses ; i++ ) |
|
180 |
{ |
|
181 |
TInt cat = audioClients().iClientCategoryList[i]; |
|
182 |
LOG_FORMAT( "Check audio cat %x", cat ); |
|
183 |
if ( cat == ECatFmRadio ) |
|
184 |
{ |
|
185 |
radioPlaying = ETrue; |
|
186 |
} |
|
187 |
else if ( iNoAutoResumeAudioCategories.Find( cat ) != KErrNotFound ) |
|
188 |
{ |
|
189 |
atLeastOneNoAutoResumeAudioPlaying = ETrue; |
|
190 |
} |
|
191 |
else |
|
192 |
{ |
|
193 |
atLeastOneAutoResumeAudioPlaying = ETrue; |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
if ( !radioPlaying ) |
|
198 |
{ |
|
199 |
// Decide audio resource availability from audio category info. |
|
200 |
if ( atLeastOneNoAutoResumeAudioPlaying ) |
|
201 |
{ |
|
202 |
LOG( "Audio resources not available. Change informed." ); |
|
203 |
iIsAudioResourcesAvailable = EFalse; |
|
204 |
iObserver.AudioAutoResumeForbiddenL(); |
|
205 |
} |
|
206 |
else if ( !atLeastOneAutoResumeAudioPlaying ) |
|
207 |
{ |
|
208 |
if ( !iIsVoiceUiActive ) |
|
209 |
{ |
|
210 |
LOG( "Audio resources available. Change informed." ); |
|
211 |
iIsAudioResourcesAvailable = ETrue; |
|
212 |
iObserver.AudioResourcesAvailableL(); |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
LOG( "Audio resources available. Change not informed." ); |
|
217 |
iIsAudioResourcesAvailable = ETrue; |
|
218 |
} |
|
219 |
} |
|
220 |
else |
|
221 |
{ |
|
222 |
LOG( "Audio resources not available. Change not informed." ); |
|
223 |
iIsAudioResourcesAvailable = EFalse; |
|
224 |
} |
|
225 |
} |
|
226 |
else // audio resources are considered to be available when radio is playing |
|
227 |
{ |
|
228 |
iIsAudioResourcesAvailable = ETrue; |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
#endif |
|
233 |
} |
|
234 |
||
235 |
#else //__WINS__ |
|
236 |
// --------------------------------------------------------------------------- |
|
237 |
// Dummy version for WINS in order to avoid compiler warnings. |
|
238 |
// The real implementation of function is above. |
|
239 |
// --------------------------------------------------------------------------- |
|
240 |
// |
|
241 |
void CRadioSystemEventDetector::HandlePropertyChangeL( const TUid& /*aCategory*/, |
|
242 |
const TUint /*aKey*/, |
|
243 |
const TDesC8& /*aValue*/) |
|
244 |
{ |
|
245 |
} |
|
246 |
#endif |
|
247 |
||
248 |
// --------------------------------------------------------------------------- |
|
249 |
// Handling of the text property changes is done here. |
|
250 |
// Observer components are getting notifications in correspondence with what |
|
251 |
// has changed |
|
252 |
// --------------------------------------------------------------------------- |
|
253 |
// |
|
254 |
void CRadioSystemEventDetector::HandlePropertyChangeL( const TUid& /*aCategory*/, |
|
255 |
const TUint /*aKey*/, |
|
256 |
const TDesC& /*aValue*/) |
|
257 |
{ |
|
258 |
} |
|
259 |
||
260 |
// --------------------------------------------------------------------------- |
|
261 |
// This is a callback function which is called when a P&S components returns |
|
262 |
// an error |
|
263 |
// --------------------------------------------------------------------------- |
|
264 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
265 |
void CRadioSystemEventDetector::HandlePropertyChangeErrorL( const TUid& /*aCategory*/, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
266 |
const TUint /*aKey*/, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
267 |
TInt /*aError*/ ) |
24 | 268 |
{ |
269 |
} |
|
270 |
||
271 |
// --------------------------------------------------------------------------- |
|
272 |
// |
|
273 |
// --------------------------------------------------------------------------- |
|
274 |
// |
|
275 |
TBool CRadioSystemEventDetector::IsMobileNetworkCoverage() const |
|
276 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
277 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 278 |
return iIsMobileNetworkCoverage; |
279 |
} |
|
280 |
||
281 |
// --------------------------------------------------------------------------- |
|
282 |
// |
|
283 |
// --------------------------------------------------------------------------- |
|
284 |
// |
|
285 |
TBool CRadioSystemEventDetector::IsNetworkCoverage() const |
|
286 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
287 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
288 |
return iIsMobileNetworkCoverage; |
24 | 289 |
} |
290 |
||
291 |
// --------------------------------------------------------------------------- |
|
292 |
// |
|
293 |
// --------------------------------------------------------------------------- |
|
294 |
// |
|
295 |
TBool CRadioSystemEventDetector::IsCallActive() const |
|
296 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
297 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 298 |
return iIsCallActive; |
299 |
} |
|
300 |
||
301 |
// --------------------------------------------------------------------------- |
|
302 |
// |
|
303 |
// --------------------------------------------------------------------------- |
|
304 |
// |
|
305 |
TBool CRadioSystemEventDetector::IsAudioResourcesAvailable() const |
|
306 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
307 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 308 |
return iIsAudioResourcesAvailable; |
309 |
} |