76
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Acessory and Bluetooth handler.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "phoneaudioutil.h"
|
|
21 |
#include "phonenoteutil.h"
|
|
22 |
#include "cphoneaccessorybthandler.h"
|
|
23 |
#include "cphonecenrepproxy.h"
|
|
24 |
#include "cphonemainresourceresolver.h"
|
|
25 |
#include "mphoneneclearedhandler.h"
|
|
26 |
#include "mphonestatemachine.h"
|
|
27 |
#include "mphoneviewcommandhandle.h"
|
|
28 |
#include "cphonestatehandle.h"
|
|
29 |
#include "tphonecmdparamboolean.h"
|
|
30 |
#include "tphonecmdparamaudiooutput.h"
|
|
31 |
#include "cphonebtaadisconnecthandler.h"
|
|
32 |
#include "phonerssbase.h"
|
|
33 |
#include "tphonecmdparaminteger.h"
|
|
34 |
#include "tphonecmdparamaudioavailability.h"
|
|
35 |
|
|
36 |
#include <mpeengineinfo.h>
|
|
37 |
|
|
38 |
// CONSTANTS
|
|
39 |
|
|
40 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------
|
|
43 |
// PhoneAudioUtil::HandleAudioMuteChangedL
|
|
44 |
// Default handling for EPEMessageAudioMuteChanged message
|
|
45 |
// (other items were commented in a header).
|
|
46 |
// -----------------------------------------------------------
|
|
47 |
//
|
|
48 |
void PhoneAudioUtil::HandleAudioMuteChangedL()
|
|
49 |
{
|
|
50 |
TPhoneCmdParamBoolean booleanParam;
|
|
51 |
const TBool audioMute = StateMachine()->PhoneEngineInfo()->AudioMute();
|
|
52 |
booleanParam.SetBoolean( audioMute );
|
|
53 |
ViewCommandHandle()->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
|
|
54 |
&booleanParam );
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// PhoneAudioUtil::HandleAudioOutputChangedL
|
|
59 |
// ---------------------------------------------------------
|
|
60 |
//
|
|
61 |
void PhoneAudioUtil::HandleAudioOutputChangedL()
|
|
62 |
{
|
|
63 |
MPhoneViewCommandHandle* viewCommandHandle =
|
|
64 |
ViewCommandHandle();
|
|
65 |
|
|
66 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
67 |
|
|
68 |
TPhoneCmdParamAudioOutput outputParam;
|
|
69 |
const TPEAudioOutput audioOutput =
|
|
70 |
stateMachine->PhoneEngineInfo()->AudioOutput();
|
|
71 |
outputParam.SetAudioOutput( audioOutput );
|
|
72 |
|
|
73 |
viewCommandHandle->ExecuteCommandL( EPhoneViewActivateAudioPathUIChanges,
|
|
74 |
&outputParam );
|
|
75 |
|
|
76 |
// Previous Output
|
|
77 |
TPEPhoneAudioRouteParameters RouteParameters = stateMachine->
|
|
78 |
PhoneEngineInfo()->RouteParameters();
|
|
79 |
const TPEAudioOutput previousOutput =
|
|
80 |
RouteParameters.iPreviousOutput;
|
|
81 |
|
|
82 |
TBool btAvailable = stateMachine->PhoneEngineInfo()->AudioOutputAvailable(
|
|
83 |
EPEBTAudioAccessory );
|
|
84 |
// Show note or BT disconnect handler
|
|
85 |
if ( audioOutput != EPENotActive &&
|
|
86 |
previousOutput == EPEBTAudioAccessory &&
|
|
87 |
!btAvailable )
|
|
88 |
{
|
|
89 |
CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
|
|
90 |
}
|
|
91 |
else if ( audioOutput == EPEBTAudioAccessory &&
|
|
92 |
previousOutput != EPEBTAudioAccessory &&
|
|
93 |
btAvailable )
|
|
94 |
{
|
|
95 |
CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
|
|
96 |
viewCommandHandle, stateMachine );
|
|
97 |
bt->ShowBTActivatedL();
|
|
98 |
CleanupStack::PopAndDestroy( bt );
|
|
99 |
}
|
|
100 |
else if ( audioOutput == EPENotActive &&
|
|
101 |
CPhoneBtaaDisconnectHandler::InstanceL()->IsQuery() )
|
|
102 |
{
|
|
103 |
CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
|
|
104 |
}
|
|
105 |
else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
|
|
106 |
{
|
|
107 |
// Avkon removal
|
|
108 |
// TODO Play tone
|
|
109 |
}
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------
|
|
113 |
// PhoneAudioUtil::DecreaseAudioVolume()
|
|
114 |
// -----------------------------------------------------------
|
|
115 |
//
|
|
116 |
void PhoneAudioUtil::DecreaseAudioVolumeL()
|
|
117 |
{
|
|
118 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
119 |
TPEAudioOutput output( stateMachine->PhoneEngineInfo()->AudioOutput() );
|
|
120 |
|
|
121 |
if( output == EPETTY )
|
|
122 |
{
|
|
123 |
PhoneNoteUtil::SendGlobalInfoNoteL(
|
|
124 |
EPhoneNoteTTYNoAudioControl, ETrue );
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
TInt audioVolume( stateMachine->PhoneEngineInfo()->AudioVolume() );
|
|
129 |
audioVolume--;
|
|
130 |
ChangeAudioVolumeL( audioVolume, ETrue );
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------
|
|
135 |
// PhoneAudioUtil::IncreaceAudioVolume()
|
|
136 |
// -----------------------------------------------------------
|
|
137 |
//
|
|
138 |
void PhoneAudioUtil::IncreaseAudioVolumeL()
|
|
139 |
{
|
|
140 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
141 |
TPEAudioOutput output( stateMachine->PhoneEngineInfo()->AudioOutput() );
|
|
142 |
|
|
143 |
if( output == EPETTY )
|
|
144 |
{
|
|
145 |
PhoneNoteUtil::SendGlobalInfoNoteL(
|
|
146 |
EPhoneNoteTTYNoAudioControl, ETrue );
|
|
147 |
}
|
|
148 |
else
|
|
149 |
{
|
|
150 |
TInt audioVolume( stateMachine->PhoneEngineInfo()->AudioVolume() );
|
|
151 |
audioVolume++;
|
|
152 |
ChangeAudioVolumeL( audioVolume, ETrue );
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
// -----------------------------------------------------------
|
|
157 |
// PhoneAudioUtil::ChangeAudioVolumeL()
|
|
158 |
// -----------------------------------------------------------
|
|
159 |
//
|
|
160 |
void PhoneAudioUtil::ChangeAudioVolumeL( TInt aLevel, TBool aUpdateControl )
|
|
161 |
{
|
|
162 |
TInt valueToControl = aLevel;
|
|
163 |
// sets value between 1 -10
|
|
164 |
if ( aLevel>=KPhoneVolumeMinValue && aLevel<=KPhoneVolumeMaxValue )
|
|
165 |
{
|
|
166 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
167 |
|
|
168 |
stateMachine->PhoneEngineInfo()->SetAudioVolumeCommand( aLevel );
|
|
169 |
// Syncronizes audio volume level between engine and ui
|
|
170 |
// causes EPEMessageAudioVolumeChanged message to phoneUI
|
|
171 |
stateMachine->SendPhoneEngineMessage(
|
|
172 |
MPEPhoneModel::EPEMessageSetAudioVolume );
|
|
173 |
}
|
|
174 |
|
|
175 |
if ( aUpdateControl )
|
|
176 |
{
|
|
177 |
// Update the volume display.
|
|
178 |
// Upper max (11) and under min (-1)
|
|
179 |
// values are also updated to volume popup.
|
|
180 |
TPhoneCmdParamInteger volumeParam;
|
|
181 |
volumeParam.SetInteger( valueToControl );
|
|
182 |
ViewCommandHandle()->ExecuteCommandL(
|
|
183 |
EPhoneViewSetNaviPaneAudioVolume,
|
|
184 |
&volumeParam );
|
|
185 |
}
|
|
186 |
}
|
|
187 |
|
|
188 |
// -----------------------------------------------------------
|
|
189 |
// PhoneAudioUtil::GetVolumeLevel
|
|
190 |
// -----------------------------------------------------------
|
|
191 |
//
|
|
192 |
TInt PhoneAudioUtil::GetVolumeLevel()
|
|
193 |
{
|
|
194 |
TPhoneCmdParamInteger integerParam;
|
|
195 |
ViewCommandHandle()->ExecuteCommand( EPhoneViewGetAudioVolumeLevel,
|
|
196 |
&integerParam );
|
|
197 |
return integerParam.Integer();
|
|
198 |
}
|
|
199 |
|
|
200 |
// -----------------------------------------------------------
|
|
201 |
// PhoneAudioUtil::HandleAudioAvailableOutputChangedL
|
|
202 |
// Default handling for EPEMessageAvailableAudioOutputsChanged message
|
|
203 |
// (other items were commented in a header).
|
|
204 |
// -----------------------------------------------------------
|
|
205 |
//
|
|
206 |
void PhoneAudioUtil::HandleAudioAvailableOutputChangedL()
|
|
207 |
{
|
|
208 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
209 |
TPhoneCmdParamAudioAvailability outputParam;
|
|
210 |
// Output
|
|
211 |
const TPEAudioOutput audioOutput =
|
|
212 |
stateMachine->PhoneEngineInfo()->AudioOutput();
|
|
213 |
// BT availability
|
|
214 |
TBool btAvailable = stateMachine->PhoneEngineInfo()->
|
|
215 |
AudioOutputAvailable( EPEBTAudioAccessory );
|
|
216 |
outputParam.SetBTAccAvailable( btAvailable );
|
|
217 |
// Wired availability
|
|
218 |
TBool wiredAvailable = stateMachine->PhoneEngineInfo()->
|
|
219 |
AudioOutputAvailable( EPEWiredAudioAccessory );
|
|
220 |
outputParam.SetWiredAccAvailable( wiredAvailable );
|
|
221 |
// BTA disconnect handler check
|
|
222 |
if( btAvailable )
|
|
223 |
{
|
|
224 |
CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
|
|
225 |
}
|
|
226 |
|
|
227 |
ViewCommandHandle()->ExecuteCommandL(
|
|
228 |
EPhoneViewActivateAudioAvailabilityUIChanges,
|
|
229 |
&outputParam );
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------
|
|
233 |
// PhoneAudioUtil::ToggleMute
|
|
234 |
// -----------------------------------------------------------
|
|
235 |
//
|
|
236 |
void PhoneAudioUtil::ToggleMute()
|
|
237 |
{
|
|
238 |
MPhoneStateMachine* stateMachine = StateMachine();
|
|
239 |
stateMachine->PhoneEngineInfo()->AudioMute() ?
|
|
240 |
stateMachine->PhoneEngineInfo()->SetAudioMuteCommand( EFalse ):
|
|
241 |
stateMachine->PhoneEngineInfo()->SetAudioMuteCommand( ETrue );
|
|
242 |
|
|
243 |
stateMachine->SendPhoneEngineMessage(
|
|
244 |
MPEPhoneModel::EPEMessageSetAudioMute );
|
|
245 |
}
|
|
246 |
|
|
247 |
// ---------------------------------------------------------
|
|
248 |
// PhoneAudioUtil::SetHandsfreeModeL
|
|
249 |
// ---------------------------------------------------------
|
|
250 |
//
|
|
251 |
void PhoneAudioUtil::SetHandsfreeModeL( TBool aHandsfreeMode )
|
|
252 |
{
|
|
253 |
CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
|
|
254 |
ViewCommandHandle(), StateMachine() );
|
|
255 |
if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
|
|
256 |
{
|
|
257 |
PhoneNoteUtil::SendGlobalErrorNoteL(
|
|
258 |
EPhoneNoteTextNotAllowed, ETrue );
|
|
259 |
}
|
|
260 |
CleanupStack::PopAndDestroy( bt );
|
|
261 |
}
|
|
262 |
|
|
263 |
// ---------------------------------------------------------
|
|
264 |
// PhoneAudioUtil::SetBTHandsfreeModeL
|
|
265 |
// ---------------------------------------------------------
|
|
266 |
//
|
|
267 |
void PhoneAudioUtil::SetBtHandsfreeModeL( TBool aHandsfreeMode )
|
|
268 |
{
|
|
269 |
CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
|
|
270 |
ViewCommandHandle(), StateMachine() );
|
|
271 |
if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
|
|
272 |
{
|
|
273 |
PhoneNoteUtil::SendGlobalErrorNoteL(
|
|
274 |
EPhoneNoteTextNotAllowed, ETrue );
|
|
275 |
}
|
|
276 |
CleanupStack::PopAndDestroy( bt );
|
|
277 |
}
|
|
278 |
|
|
279 |
// ---------------------------------------------------------
|
|
280 |
// PhoneAudioUtil::ViewCommandHandle
|
|
281 |
// ---------------------------------------------------------
|
|
282 |
//
|
|
283 |
MPhoneViewCommandHandle* PhoneAudioUtil::ViewCommandHandle()
|
|
284 |
{
|
|
285 |
return CPhoneStateHandle::Instance()->ViewCommandHandle();
|
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------
|
|
289 |
// PhoneAudioUtil::StateMachine
|
|
290 |
// ---------------------------------------------------------
|
|
291 |
//
|
|
292 |
MPhoneStateMachine* PhoneAudioUtil::StateMachine()
|
|
293 |
{
|
|
294 |
return CPhoneStateHandle::Instance()->StateMachine();
|
|
295 |
}
|
|
296 |
|
|
297 |
// End of File
|