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