blob: 979a51a516db91653d0da560f1d79c35d0708266 [file] [log] [blame]
Sailesh Nepal810735e2014-03-18 18:15:46 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.telecomm;
18
19import android.content.Context;
20import android.media.AudioManager;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070021import android.telecomm.CallAudioState;
Sailesh Nepal810735e2014-03-18 18:15:46 -070022import android.telecomm.CallState;
23
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070024import com.google.common.base.Preconditions;
Santos Cordon1ae2b852014-03-19 03:03:10 -070025
Sailesh Nepal810735e2014-03-18 18:15:46 -070026/**
27 * This class manages audio modes, streams and other properties.
28 */
Sailesh Nepalb88795a2014-07-15 14:53:27 -070029final class CallAudioManager extends CallsManagerListenerBase
30 implements WiredHeadsetManager.Listener {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070031 private static final int STREAM_NONE = -1;
Santos Cordon1ae2b852014-03-19 03:03:10 -070032
Santos Cordondeb8c892014-05-30 01:38:03 -070033 private final StatusBarNotifier mStatusBarNotifier;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070034 private final AudioManager mAudioManager;
Santos Cordonc7e85d42014-05-22 02:51:48 -070035 private final BluetoothManager mBluetoothManager;
Sailesh Nepalb88795a2014-07-15 14:53:27 -070036 private final WiredHeadsetManager mWiredHeadsetManager;
Santos Cordondeb8c892014-05-30 01:38:03 -070037
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070038 private CallAudioState mAudioState;
39 private int mAudioFocusStreamType;
40 private boolean mIsRinging;
Santos Cordona56f2762014-03-24 15:55:53 -070041 private boolean mIsTonePlaying;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070042 private boolean mWasSpeakerOn;
Santos Cordon1ae2b852014-03-19 03:03:10 -070043
Sailesh Nepalb88795a2014-07-15 14:53:27 -070044 CallAudioManager(Context context, StatusBarNotifier statusBarNotifier,
45 WiredHeadsetManager wiredHeadsetManager) {
Santos Cordondeb8c892014-05-30 01:38:03 -070046 mStatusBarNotifier = statusBarNotifier;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070047 mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
Santos Cordonc7e85d42014-05-22 02:51:48 -070048 mBluetoothManager = new BluetoothManager(context, this);
Sailesh Nepalb88795a2014-07-15 14:53:27 -070049 mWiredHeadsetManager = wiredHeadsetManager;
Sailesh Nepald0a76aa2014-07-16 22:12:23 -070050 mWiredHeadsetManager.addListener(this);
Sailesh Nepalb88795a2014-07-15 14:53:27 -070051
Santos Cordondeb8c892014-05-30 01:38:03 -070052 saveAudioState(getInitialAudioState(null));
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070053 mAudioFocusStreamType = STREAM_NONE;
54 }
Santos Cordon1ae2b852014-03-19 03:03:10 -070055
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070056 CallAudioState getAudioState() {
57 return mAudioState;
58 }
Santos Cordon1ae2b852014-03-19 03:03:10 -070059
60 @Override
61 public void onCallAdded(Call call) {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070062 updateAudioStreamAndMode();
63 if (CallsManager.getInstance().getCalls().size() == 1) {
64 Log.v(this, "first call added, reseting system audio to default state");
Santos Cordonc7e85d42014-05-22 02:51:48 -070065 setInitialAudioState(call);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070066 } else if (!call.isIncoming()) {
67 // Unmute new outgoing call.
68 setSystemAudioState(false, mAudioState.route, mAudioState.supportedRouteMask);
Santos Cordon1ae2b852014-03-19 03:03:10 -070069 }
Santos Cordon1ae2b852014-03-19 03:03:10 -070070 }
71
72 @Override
73 public void onCallRemoved(Call call) {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070074 if (CallsManager.getInstance().getCalls().isEmpty()) {
75 Log.v(this, "all calls removed, reseting system audio to default state");
Santos Cordonc7e85d42014-05-22 02:51:48 -070076 setInitialAudioState(null);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070077 }
78 updateAudioStreamAndMode();
Santos Cordon1ae2b852014-03-19 03:03:10 -070079 }
80
Sailesh Nepal810735e2014-03-18 18:15:46 -070081 @Override
82 public void onCallStateChanged(Call call, CallState oldState, CallState newState) {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070083 updateAudioStreamAndMode();
Santos Cordon1ae2b852014-03-19 03:03:10 -070084 }
85
86 @Override
87 public void onIncomingCallAnswered(Call call) {
Santos Cordonc7e85d42014-05-22 02:51:48 -070088 int route = mAudioState.route;
89
90 // We do two things:
91 // (1) If this is the first call, then we can to turn on bluetooth if available.
92 // (2) Unmute the audio for the new incoming call.
93 boolean isOnlyCall = CallsManager.getInstance().getCalls().size() == 1;
94 if (isOnlyCall && mBluetoothManager.isBluetoothAvailable()) {
95 mBluetoothManager.connectBluetoothAudio();
96 route = CallAudioState.ROUTE_BLUETOOTH;
97 }
98
99 setSystemAudioState(false /* isMute */, route, mAudioState.supportedRouteMask);
Santos Cordon1ae2b852014-03-19 03:03:10 -0700100 }
101
102 @Override
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700103 public void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall) {
104 updateAudioStreamAndMode();
105 // Ensure that the foreground call knows about the latest audio state.
106 updateAudioForForegroundCall();
Santos Cordon1ae2b852014-03-19 03:03:10 -0700107 }
108
Sailesh Nepal7e669572014-07-08 21:29:12 -0700109 @Override
110 public void onAudioModeIsVoipChanged(Call call) {
111 updateAudioStreamAndMode();
112 }
113
Sailesh Nepalb88795a2014-07-15 14:53:27 -0700114 /**
115 * Updates the audio route when the headset plugged in state changes. For example, if audio is
116 * being routed over speakerphone and a headset is plugged in then switch to wired headset.
117 */
118 @Override
119 public void onWiredHeadsetPluggedInChanged(boolean oldIsPluggedIn, boolean newIsPluggedIn) {
120 int newRoute = CallAudioState.ROUTE_EARPIECE;
121 if (newIsPluggedIn) {
122 newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
123 } else if (mWasSpeakerOn) {
124 Call call = getForegroundCall();
125 if (call != null && call.isAlive()) {
126 // Restore the speaker state.
127 newRoute = CallAudioState.ROUTE_SPEAKER;
128 }
129 }
130 setSystemAudioState(mAudioState.isMuted, newRoute, calculateSupportedRoutes());
131 }
132
Santos Cordondeb8c892014-05-30 01:38:03 -0700133 void toggleMute() {
134 mute(!mAudioState.isMuted);
135 }
136
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700137 void mute(boolean shouldMute) {
138 Log.v(this, "mute, shouldMute: %b", shouldMute);
Santos Cordon1ae2b852014-03-19 03:03:10 -0700139
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700140 // Don't mute if there are any emergency calls.
141 if (CallsManager.getInstance().hasEmergencyCall()) {
142 shouldMute = false;
143 Log.v(this, "ignoring mute for emergency call");
Santos Cordon1ae2b852014-03-19 03:03:10 -0700144 }
145
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700146 if (mAudioState.isMuted != shouldMute) {
147 setSystemAudioState(shouldMute, mAudioState.route, mAudioState.supportedRouteMask);
Sailesh Nepal810735e2014-03-18 18:15:46 -0700148 }
149 }
150
Santos Cordon1ae2b852014-03-19 03:03:10 -0700151 /**
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700152 * Changed the audio route, for example from earpiece to speaker phone.
Santos Cordon1ae2b852014-03-19 03:03:10 -0700153 *
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700154 * @param route The new audio route to use. See {@link CallAudioState}.
Santos Cordon1ae2b852014-03-19 03:03:10 -0700155 */
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700156 void setAudioRoute(int route) {
157 Log.v(this, "setAudioRoute, route: %s", CallAudioState.audioRouteToString(route));
Santos Cordon1ae2b852014-03-19 03:03:10 -0700158
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700159 // Change ROUTE_WIRED_OR_EARPIECE to a single entry.
160 int newRoute = selectWiredOrEarpiece(route, mAudioState.supportedRouteMask);
161
162 // If route is unsupported, do nothing.
163 if ((mAudioState.supportedRouteMask | newRoute) == 0) {
164 Log.wtf(this, "Asking to set to a route that is unsupported: %d", newRoute);
165 return;
166 }
167
168 if (mAudioState.route != newRoute) {
169 // Remember the new speaker state so it can be restored when the user plugs and unplugs
170 // a headset.
171 mWasSpeakerOn = newRoute == CallAudioState.ROUTE_SPEAKER;
172 setSystemAudioState(mAudioState.isMuted, newRoute, mAudioState.supportedRouteMask);
173 }
174 }
175
176 void setIsRinging(boolean isRinging) {
177 if (mIsRinging != isRinging) {
178 Log.v(this, "setIsRinging %b -> %b", mIsRinging, isRinging);
179 mIsRinging = isRinging;
180 updateAudioStreamAndMode();
Santos Cordon1ae2b852014-03-19 03:03:10 -0700181 }
Sailesh Nepal810735e2014-03-18 18:15:46 -0700182 }
183
Santos Cordon1ae2b852014-03-19 03:03:10 -0700184 /**
Santos Cordona56f2762014-03-24 15:55:53 -0700185 * Sets the tone playing status. Some tones can play even when there are no live calls and this
186 * status indicates that we should keep audio focus even for tones that play beyond the life of
187 * calls.
188 *
189 * @param isPlayingNew The status to set.
190 */
191 void setIsTonePlaying(boolean isPlayingNew) {
192 ThreadUtil.checkOnMainThread();
193
194 if (mIsTonePlaying != isPlayingNew) {
195 Log.v(this, "mIsTonePlaying %b -> %b.", mIsTonePlaying, isPlayingNew);
196 mIsTonePlaying = isPlayingNew;
197 updateAudioStreamAndMode();
198 }
199 }
200
201 /**
Santos Cordonc7e85d42014-05-22 02:51:48 -0700202 * Updates the audio routing according to the bluetooth state.
203 */
204 void onBluetoothStateChange(BluetoothManager bluetoothManager) {
205 int newRoute = mAudioState.route;
206 if (bluetoothManager.isBluetoothAudioConnectedOrPending()) {
207 newRoute = CallAudioState.ROUTE_BLUETOOTH;
208 } else if (mAudioState.route == CallAudioState.ROUTE_BLUETOOTH) {
209 newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
210 // Do not switch to speaker when bluetooth disconnects.
211 mWasSpeakerOn = false;
212 }
213
214 setSystemAudioState(mAudioState.isMuted, newRoute, calculateSupportedRoutes());
215 }
216
217 boolean isBluetoothAudioOn() {
218 return mBluetoothManager.isBluetoothAudioConnected();
219 }
220
221 boolean isBluetoothDeviceAvailable() {
222 return mBluetoothManager.isBluetoothAvailable();
223 }
224
Santos Cordondeb8c892014-05-30 01:38:03 -0700225 private void saveAudioState(CallAudioState audioState) {
226 mAudioState = audioState;
227 mStatusBarNotifier.notifyMute(mAudioState.isMuted);
228 mStatusBarNotifier.notifySpeakerphone(mAudioState.route == CallAudioState.ROUTE_SPEAKER);
229 }
230
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700231 private void setSystemAudioState(boolean isMuted, int route, int supportedRouteMask) {
232 CallAudioState oldAudioState = mAudioState;
Santos Cordondeb8c892014-05-30 01:38:03 -0700233 saveAudioState(new CallAudioState(isMuted, route, supportedRouteMask));
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700234 Log.i(this, "changing audio state from %s to %s", oldAudioState, mAudioState);
Santos Cordon1ae2b852014-03-19 03:03:10 -0700235
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700236 // Mute.
237 if (mAudioState.isMuted != mAudioManager.isMicrophoneMute()) {
238 Log.i(this, "changing microphone mute state to: %b", mAudioState.isMuted);
239 mAudioManager.setMicrophoneMute(mAudioState.isMuted);
Santos Cordon1ae2b852014-03-19 03:03:10 -0700240 }
241
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700242 // Audio route.
Santos Cordonc7e85d42014-05-22 02:51:48 -0700243 if (mAudioState.route == CallAudioState.ROUTE_BLUETOOTH) {
244 turnOnSpeaker(false);
245 turnOnBluetooth(true);
246 } else if (mAudioState.route == CallAudioState.ROUTE_SPEAKER) {
247 turnOnBluetooth(false);
248 turnOnSpeaker(true);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700249 } else if (mAudioState.route == CallAudioState.ROUTE_EARPIECE ||
250 mAudioState.route == CallAudioState.ROUTE_WIRED_HEADSET) {
Santos Cordonc7e85d42014-05-22 02:51:48 -0700251 turnOnBluetooth(false);
252 turnOnSpeaker(false);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700253 }
254
255 if (!oldAudioState.equals(mAudioState)) {
256 CallsManager.getInstance().onAudioStateChanged(oldAudioState, mAudioState);
257 updateAudioForForegroundCall();
258 }
259 }
260
Santos Cordonc7e85d42014-05-22 02:51:48 -0700261 private void turnOnSpeaker(boolean on) {
262 // Wired headset and earpiece work the same way
263 if (mAudioManager.isSpeakerphoneOn() != on) {
264 Log.i(this, "turning speaker phone off");
265 mAudioManager.setSpeakerphoneOn(on);
266 }
267 }
268
269 private void turnOnBluetooth(boolean on) {
270 if (mBluetoothManager.isBluetoothAvailable()) {
271 boolean isAlreadyOn = mBluetoothManager.isBluetoothAudioConnected();
272 if (on != isAlreadyOn) {
273 if (on) {
274 mBluetoothManager.connectBluetoothAudio();
275 } else {
276 mBluetoothManager.disconnectBluetoothAudio();
277 }
278 }
279 }
280 }
281
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700282 private void updateAudioStreamAndMode() {
Santos Cordona56f2762014-03-24 15:55:53 -0700283 Log.v(this, "updateAudioStreamAndMode, mIsRinging: %b, mIsTonePlaying: %b", mIsRinging,
284 mIsTonePlaying);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700285 if (mIsRinging) {
286 requestAudioFocusAndSetMode(AudioManager.STREAM_RING, AudioManager.MODE_RINGTONE);
287 } else {
Santos Cordon5ba7f272014-05-28 13:59:49 -0700288 Call call = getForegroundCall();
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700289 if (call != null) {
Sailesh Nepal7e669572014-07-08 21:29:12 -0700290 int mode = call.getAudioModeIsVoip() ?
291 AudioManager.MODE_IN_COMMUNICATION : AudioManager.MODE_IN_CALL;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700292 requestAudioFocusAndSetMode(AudioManager.STREAM_VOICE_CALL, mode);
Santos Cordona56f2762014-03-24 15:55:53 -0700293 } else if (mIsTonePlaying) {
294 // There is no call, however, we are still playing a tone, so keep focus.
295 requestAudioFocusAndSetMode(
296 AudioManager.STREAM_VOICE_CALL, AudioManager.MODE_IN_COMMUNICATION);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700297 } else {
298 abandonAudioFocus();
299 }
300 }
301 }
302
303 private void requestAudioFocusAndSetMode(int stream, int mode) {
304 Log.v(this, "setSystemAudioStreamAndMode, stream: %d -> %d", mAudioFocusStreamType, stream);
305 Preconditions.checkState(stream != STREAM_NONE);
306
Santos Cordon5ba7f272014-05-28 13:59:49 -0700307 // Even if we already have focus, if the stream is different we update audio manager to give
308 // it a hint about the purpose of our focus.
309 if (mAudioFocusStreamType != stream) {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700310 Log.v(this, "requesting audio focus for stream: %d", stream);
311 mAudioManager.requestAudioFocusForCall(stream,
312 AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
313 }
314 mAudioFocusStreamType = stream;
315 setMode(mode);
316 }
317
318 private void abandonAudioFocus() {
319 if (mAudioFocusStreamType != STREAM_NONE) {
320 setMode(AudioManager.MODE_NORMAL);
321 Log.v(this, "abandoning audio focus");
322 mAudioManager.abandonAudioFocusForCall();
323 mAudioFocusStreamType = STREAM_NONE;
324 }
Santos Cordon1ae2b852014-03-19 03:03:10 -0700325 }
326
327 /**
328 * Sets the audio mode.
329 *
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700330 * @param newMode Mode constant from AudioManager.MODE_*.
Santos Cordon1ae2b852014-03-19 03:03:10 -0700331 */
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700332 private void setMode(int newMode) {
333 Preconditions.checkState(mAudioFocusStreamType != STREAM_NONE);
334 int oldMode = mAudioManager.getMode();
335 Log.v(this, "Request to change audio mode from %d to %d", oldMode, newMode);
336 if (oldMode != newMode) {
337 mAudioManager.setMode(newMode);
338 }
339 }
340
341 private int selectWiredOrEarpiece(int route, int supportedRouteMask) {
342 // Since they are mutually exclusive and one is ALWAYS valid, we allow a special input of
343 // ROUTE_WIRED_OR_EARPIECE so that callers dont have to make a call to check which is
344 // supported before calling setAudioRoute.
345 if (route == CallAudioState.ROUTE_WIRED_OR_EARPIECE) {
346 route = CallAudioState.ROUTE_WIRED_OR_EARPIECE & supportedRouteMask;
347 if (route == 0) {
348 Log.wtf(this, "One of wired headset or earpiece should always be valid.");
349 // assume earpiece in this case.
350 route = CallAudioState.ROUTE_EARPIECE;
Santos Cordon1ae2b852014-03-19 03:03:10 -0700351 }
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700352 }
353 return route;
354 }
355
356 private int calculateSupportedRoutes() {
357 int routeMask = CallAudioState.ROUTE_SPEAKER;
358
359 if (mWiredHeadsetManager.isPluggedIn()) {
360 routeMask |= CallAudioState.ROUTE_WIRED_HEADSET;
Santos Cordon1ae2b852014-03-19 03:03:10 -0700361 } else {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700362 routeMask |= CallAudioState.ROUTE_EARPIECE;
Santos Cordon1ae2b852014-03-19 03:03:10 -0700363 }
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700364
Santos Cordonc7e85d42014-05-22 02:51:48 -0700365 if (mBluetoothManager.isBluetoothAvailable()) {
366 routeMask |= CallAudioState.ROUTE_BLUETOOTH;
367 }
368
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700369 return routeMask;
Santos Cordon1ae2b852014-03-19 03:03:10 -0700370 }
371
Santos Cordonc7e85d42014-05-22 02:51:48 -0700372 private CallAudioState getInitialAudioState(Call call) {
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700373 int supportedRouteMask = calculateSupportedRoutes();
Santos Cordonc7e85d42014-05-22 02:51:48 -0700374 int route = selectWiredOrEarpiece(
375 CallAudioState.ROUTE_WIRED_OR_EARPIECE, supportedRouteMask);
376
377 // We want the UI to indicate that "bluetooth is in use" in two slightly different cases:
378 // (a) The obvious case: if a bluetooth headset is currently in use for an ongoing call.
379 // (b) The not-so-obvious case: if an incoming call is ringing, and we expect that audio
380 // *will* be routed to a bluetooth headset once the call is answered. In this case, just
381 // check if the headset is available. Note this only applies when we are dealing with
382 // the first call.
383 if (call != null && mBluetoothManager.isBluetoothAvailable()) {
384 switch(call.getState()) {
385 case ACTIVE:
386 case ON_HOLD:
387 if (mBluetoothManager.isBluetoothAudioConnectedOrPending()) {
388 route = CallAudioState.ROUTE_BLUETOOTH;
389 }
390 break;
391 case RINGING:
392 route = CallAudioState.ROUTE_BLUETOOTH;
393 break;
394 default:
395 break;
396 }
397 }
398
399 return new CallAudioState(false, route, supportedRouteMask);
Santos Cordon1ae2b852014-03-19 03:03:10 -0700400 }
401
Santos Cordonc7e85d42014-05-22 02:51:48 -0700402 private void setInitialAudioState(Call call) {
403 CallAudioState audioState = getInitialAudioState(call);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700404 setSystemAudioState(audioState.isMuted, audioState.route, audioState.supportedRouteMask);
405 }
406
407 private void updateAudioForForegroundCall() {
408 Call call = CallsManager.getInstance().getForegroundCall();
Sailesh Nepalc92c4362014-07-04 18:33:21 -0700409 if (call != null && call.getConnectionService() != null) {
410 call.getConnectionService().onAudioStateChanged(call, mAudioState);
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700411 }
Sailesh Nepal810735e2014-03-18 18:15:46 -0700412 }
Santos Cordon5ba7f272014-05-28 13:59:49 -0700413
414 /**
415 * Returns the current foreground call in order to properly set the audio mode.
416 */
417 private Call getForegroundCall() {
418 Call call = CallsManager.getInstance().getForegroundCall();
419
420 // We ignore any foreground call that is in the ringing state because we deal with ringing
421 // calls exclusively through the mIsRinging variable set by {@link Ringer}.
422 if (call != null && call.getState() == CallState.RINGING) {
423 call = null;
424 }
425 return call;
426 }
Sailesh Nepal810735e2014-03-18 18:15:46 -0700427}