blob: be1e3b2a2f95c42543553eee04d7336cfd0b49f9 [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2006 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.phone;
18
19import com.android.internal.telephony.Call;
20import com.android.internal.telephony.CallManager;
21import com.android.internal.telephony.CallerInfo;
22import com.android.internal.telephony.CallerInfoAsyncQuery;
23import com.android.internal.telephony.Connection;
24import com.android.internal.telephony.Phone;
25import com.android.internal.telephony.PhoneConstants;
26import com.android.internal.telephony.PhoneBase;
27import com.android.internal.telephony.TelephonyCapabilities;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070028import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaDisplayInfoRec;
29import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaSignalInfoRec;
30import com.android.internal.telephony.cdma.SignalToneUtil;
31
32import android.app.ActivityManagerNative;
33import android.bluetooth.BluetoothAdapter;
34import android.bluetooth.BluetoothHeadset;
35import android.bluetooth.BluetoothProfile;
36import android.content.Context;
John Spurlock6ee06d02014-07-18 20:06:20 -040037import android.media.AudioAttributes;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070038import android.media.AudioManager;
39import android.media.ToneGenerator;
40import android.net.Uri;
41import android.os.AsyncResult;
42import android.os.Handler;
43import android.os.Message;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070044import android.os.SystemProperties;
45import android.os.SystemVibrator;
46import android.os.Vibrator;
47import android.provider.CallLog.Calls;
48import android.provider.Settings;
Anders Kristensen0b35f042014-02-27 14:31:07 -080049import android.telephony.DisconnectCause;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070050import android.telephony.PhoneNumberUtils;
51import android.telephony.PhoneStateListener;
52import android.telephony.TelephonyManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070053import android.util.EventLog;
54import android.util.Log;
55
56/**
57 * Phone app module that listens for phone state changes and various other
58 * events from the telephony layer, and triggers any resulting UI behavior
Santos Cordon5422a8d2014-09-12 04:20:56 -070059 * (like starting the Incoming Call UI, playing in-call tones,
Santos Cordon7d4ddf62013-07-10 11:58:08 -070060 * updating notifications, writing call log entries, etc.)
61 */
Santos Cordon5422a8d2014-09-12 04:20:56 -070062public class CallNotifier extends Handler {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070063 private static final String LOG_TAG = "CallNotifier";
64 private static final boolean DBG =
65 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
66 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
67
Santos Cordon7d4ddf62013-07-10 11:58:08 -070068 // Time to display the DisplayInfo Record sent by CDMA network
69 private static final int DISPLAYINFO_NOTIFICATION_TIME = 2000; // msec
70
John Spurlock6ee06d02014-07-18 20:06:20 -040071 private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
72 .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
73 .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
74 .build();
75
Santos Cordon7d4ddf62013-07-10 11:58:08 -070076 /** The singleton instance. */
77 private static CallNotifier sInstance;
78
Santos Cordon7d4ddf62013-07-10 11:58:08 -070079 // values used to track the query state
80 private static final int CALLERINFO_QUERY_READY = 0;
81 private static final int CALLERINFO_QUERYING = -1;
82
83 // the state of the CallerInfo Query.
84 private int mCallerInfoQueryState;
85
86 // object used to synchronize access to mCallerInfoQueryState
87 private Object mCallerInfoQueryStateGuard = new Object();
88
Santos Cordon7d4ddf62013-07-10 11:58:08 -070089 // Events generated internally:
90 private static final int PHONE_MWI_CHANGED = 21;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070091 private static final int DISPLAYINFO_NOTIFICATION_DONE = 24;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070092 private static final int UPDATE_IN_CALL_NOTIFICATION = 27;
93
Santos Cordon7d4ddf62013-07-10 11:58:08 -070094
95 private PhoneGlobals mApplication;
96 private CallManager mCM;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070097 private BluetoothHeadset mBluetoothHeadset;
98 private CallLogger mCallLogger;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070099
100 // ToneGenerator instance for playing SignalInfo tones
101 private ToneGenerator mSignalInfoToneGenerator;
102
103 // The tone volume relative to other sounds in the stream SignalInfo
104 private static final int TONE_RELATIVE_VOLUME_SIGNALINFO = 80;
105
106 private Call.State mPreviousCdmaCallState;
107 private boolean mVoicePrivacyState = false;
108 private boolean mIsCdmaRedialCall = false;
109
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700110 // Cached AudioManager
111 private AudioManager mAudioManager;
112
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700113 private final BluetoothManager mBluetoothManager;
114
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700115 /**
116 * Initialize the singleton CallNotifier instance.
117 * This is only done once, at startup, from PhoneApp.onCreate().
118 */
Santos Cordon5422a8d2014-09-12 04:20:56 -0700119 /* package */ static CallNotifier init(PhoneGlobals app, Phone phone,
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700120 CallLogger callLogger, CallStateMonitor callStateMonitor,
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700121 BluetoothManager bluetoothManager) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700122 synchronized (CallNotifier.class) {
123 if (sInstance == null) {
Santos Cordon5422a8d2014-09-12 04:20:56 -0700124 sInstance = new CallNotifier(app, phone, callLogger, callStateMonitor,
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700125 bluetoothManager);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700126 } else {
127 Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance);
128 }
129 return sInstance;
130 }
131 }
132
133 /** Private constructor; @see init() */
Santos Cordon5422a8d2014-09-12 04:20:56 -0700134 private CallNotifier(PhoneGlobals app, Phone phone, CallLogger callLogger,
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700135 CallStateMonitor callStateMonitor, BluetoothManager bluetoothManager) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700136 mApplication = app;
137 mCM = app.mCM;
138 mCallLogger = callLogger;
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700139 mBluetoothManager = bluetoothManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700140
141 mAudioManager = (AudioManager) mApplication.getSystemService(Context.AUDIO_SERVICE);
142
143 callStateMonitor.addListener(this);
144
145 createSignalInfoToneGenerator();
146
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700147 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
148 if (adapter != null) {
149 adapter.getProfileProxy(mApplication.getApplicationContext(),
150 mBluetoothProfileServiceListener,
151 BluetoothProfile.HEADSET);
152 }
153
154 TelephonyManager telephonyManager = (TelephonyManager)app.getSystemService(
155 Context.TELEPHONY_SERVICE);
156 telephonyManager.listen(mPhoneStateListener,
157 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
158 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
159 }
160
161 private void createSignalInfoToneGenerator() {
162 // Instantiate the ToneGenerator for SignalInfo and CallWaiting
163 // TODO: We probably don't need the mSignalInfoToneGenerator instance
164 // around forever. Need to change it so as to create a ToneGenerator instance only
165 // when a tone is being played and releases it after its done playing.
166 if (mSignalInfoToneGenerator == null) {
167 try {
168 mSignalInfoToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL,
169 TONE_RELATIVE_VOLUME_SIGNALINFO);
170 Log.d(LOG_TAG, "CallNotifier: mSignalInfoToneGenerator created when toneplay");
171 } catch (RuntimeException e) {
172 Log.w(LOG_TAG, "CallNotifier: Exception caught while creating " +
173 "mSignalInfoToneGenerator: " + e);
174 mSignalInfoToneGenerator = null;
175 }
176 } else {
177 Log.d(LOG_TAG, "mSignalInfoToneGenerator created already, hence skipping");
178 }
179 }
180
181 @Override
182 public void handleMessage(Message msg) {
183 switch (msg.what) {
184 case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
185 log("RINGING... (new)");
186 onNewRingingConnection((AsyncResult) msg.obj);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700187 break;
188
189 case CallStateMonitor.PHONE_STATE_CHANGED:
190 onPhoneStateChanged((AsyncResult) msg.obj);
191 break;
192
193 case CallStateMonitor.PHONE_DISCONNECT:
194 if (DBG) log("DISCONNECT");
195 onDisconnect((AsyncResult) msg.obj);
196 break;
197
198 case CallStateMonitor.PHONE_UNKNOWN_CONNECTION_APPEARED:
199 onUnknownConnectionAppeared((AsyncResult) msg.obj);
200 break;
201
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700202 case PHONE_MWI_CHANGED:
203 onMwiChanged(mApplication.phone.getMessageWaitingIndicator());
204 break;
205
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700206 case CallStateMonitor.PHONE_STATE_DISPLAYINFO:
207 if (DBG) log("Received PHONE_STATE_DISPLAYINFO event");
208 onDisplayInfo((AsyncResult) msg.obj);
209 break;
210
211 case CallStateMonitor.PHONE_STATE_SIGNALINFO:
212 if (DBG) log("Received PHONE_STATE_SIGNALINFO event");
213 onSignalInfo((AsyncResult) msg.obj);
214 break;
215
216 case DISPLAYINFO_NOTIFICATION_DONE:
217 if (DBG) log("Received Display Info notification done event ...");
218 CdmaDisplayInfo.dismissDisplayInfoRecord();
219 break;
220
221 case CallStateMonitor.EVENT_OTA_PROVISION_CHANGE:
222 if (DBG) log("EVENT_OTA_PROVISION_CHANGE...");
223 mApplication.handleOtaspEvent(msg);
224 break;
225
226 case CallStateMonitor.PHONE_ENHANCED_VP_ON:
227 if (DBG) log("PHONE_ENHANCED_VP_ON...");
228 if (!mVoicePrivacyState) {
229 int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
230 new InCallTonePlayer(toneToPlay).start();
231 mVoicePrivacyState = true;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700232 }
233 break;
234
235 case CallStateMonitor.PHONE_ENHANCED_VP_OFF:
236 if (DBG) log("PHONE_ENHANCED_VP_OFF...");
237 if (mVoicePrivacyState) {
238 int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
239 new InCallTonePlayer(toneToPlay).start();
240 mVoicePrivacyState = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700241 }
242 break;
243
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700244 default:
245 // super.handleMessage(msg);
246 }
247 }
248
249 PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
250 @Override
251 public void onMessageWaitingIndicatorChanged(boolean mwi) {
252 onMwiChanged(mwi);
253 }
254
255 @Override
256 public void onCallForwardingIndicatorChanged(boolean cfi) {
257 onCfiChanged(cfi);
258 }
259 };
260
261 /**
262 * Handles a "new ringing connection" event from the telephony layer.
263 */
264 private void onNewRingingConnection(AsyncResult r) {
265 Connection c = (Connection) r.result;
266 log("onNewRingingConnection(): state = " + mCM.getState() + ", conn = { " + c + " }");
267 Call ringing = c.getCall();
268 Phone phone = ringing.getPhone();
269
270 // Check for a few cases where we totally ignore incoming calls.
271 if (ignoreAllIncomingCalls(phone)) {
272 // Immediately reject the call, without even indicating to the user
273 // that an incoming call occurred. (This will generally send the
274 // caller straight to voicemail, just as if we *had* shown the
275 // incoming-call UI and the user had declined the call.)
276 PhoneUtils.hangupRingingCall(ringing);
277 return;
278 }
279
280 if (!c.isRinging()) {
281 Log.i(LOG_TAG, "CallNotifier.onNewRingingConnection(): connection not ringing!");
282 // This is a very strange case: an incoming call that stopped
283 // ringing almost instantly after the onNewRingingConnection()
284 // event. There's nothing we can do here, so just bail out
285 // without doing anything. (But presumably we'll log it in
286 // the call log when the disconnect event comes in...)
287 return;
288 }
289
290 // Stop any signalInfo tone being played on receiving a Call
291 stopSignalInfoTone();
292
293 Call.State state = c.getState();
294 // State will be either INCOMING or WAITING.
295 if (VDBG) log("- connection is ringing! state = " + state);
296 // if (DBG) PhoneUtils.dumpCallState(mPhone);
297
298 // No need to do any service state checks here (like for
299 // "emergency mode"), since in those states the SIM won't let
300 // us get incoming connections in the first place.
301
302 // TODO: Consider sending out a serialized broadcast Intent here
303 // (maybe "ACTION_NEW_INCOMING_CALL"), *before* starting the
304 // ringer and going to the in-call UI. The intent should contain
305 // the caller-id info for the current connection, and say whether
306 // it would be a "call waiting" call or a regular ringing call.
307 // If anybody consumed the broadcast, we'd bail out without
308 // ringing or bringing up the in-call UI.
309 //
310 // This would give 3rd party apps a chance to listen for (and
311 // intercept) new ringing connections. An app could reject the
312 // incoming call by consuming the broadcast and doing nothing, or
313 // it could "pick up" the call (without any action by the user!)
314 // via some future TelephonyManager API.
315 //
316 // See bug 1312336 for more details.
317 // We'd need to protect this with a new "intercept incoming calls"
318 // system permission.
319
320 // Obtain a partial wake lock to make sure the CPU doesn't go to
321 // sleep before we finish bringing up the InCallScreen.
322 // (This will be upgraded soon to a full wake lock; see
323 // showIncomingCall().)
324 if (VDBG) log("Holding wake lock on new incoming connection.");
325 mApplication.requestWakeState(PhoneGlobals.WakeState.PARTIAL);
326
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700327 // Note we *don't* post a status bar notification here, since
328 // we're not necessarily ready to actually show the incoming call
329 // to the user. (For calls in the INCOMING state, at least, we
330 // still need to run a caller-id query, and we may not even ring
331 // at all if the "send directly to voicemail" flag is set.)
332 //
333 // Instead, we update the notification (and potentially launch the
334 // InCallScreen) from the showIncomingCall() method, which runs
335 // when the caller-id query completes or times out.
336
337 if (VDBG) log("- onNewRingingConnection() done.");
338 }
339
340 /**
341 * Determines whether or not we're allowed to present incoming calls to the
342 * user, based on the capabilities and/or current state of the device.
343 *
344 * If this method returns true, that means we should immediately reject the
345 * current incoming call, without even indicating to the user that an
346 * incoming call occurred.
347 *
348 * (We only reject incoming calls in a few cases, like during an OTASP call
349 * when we can't interrupt the user, or if the device hasn't completed the
350 * SetupWizard yet. We also don't allow incoming calls on non-voice-capable
351 * devices. But note that we *always* allow incoming calls while in ECM.)
352 *
353 * @return true if we're *not* allowed to present an incoming call to
354 * the user.
355 */
356 private boolean ignoreAllIncomingCalls(Phone phone) {
357 // Incoming calls are totally ignored on non-voice-capable devices.
358 if (!PhoneGlobals.sVoiceCapable) {
359 // ...but still log a warning, since we shouldn't have gotten this
360 // event in the first place! (Incoming calls *should* be blocked at
361 // the telephony layer on non-voice-capable capable devices.)
362 Log.w(LOG_TAG, "Got onNewRingingConnection() on non-voice-capable device! Ignoring...");
363 return true;
364 }
365
366 // In ECM (emergency callback mode), we ALWAYS allow incoming calls
367 // to get through to the user. (Note that ECM is applicable only to
368 // voice-capable CDMA devices).
369 if (PhoneUtils.isPhoneInEcm(phone)) {
370 if (DBG) log("Incoming call while in ECM: always allow...");
371 return false;
372 }
373
374 // Incoming calls are totally ignored if the device isn't provisioned yet.
375 boolean provisioned = Settings.Global.getInt(mApplication.getContentResolver(),
376 Settings.Global.DEVICE_PROVISIONED, 0) != 0;
377 if (!provisioned) {
378 Log.i(LOG_TAG, "Ignoring incoming call: not provisioned");
379 return true;
380 }
381
382 // Incoming calls are totally ignored if an OTASP call is active.
383 if (TelephonyCapabilities.supportsOtasp(phone)) {
384 boolean activateState = (mApplication.cdmaOtaScreenState.otaScreenState
385 == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION);
386 boolean dialogState = (mApplication.cdmaOtaScreenState.otaScreenState
387 == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG);
388 boolean spcState = mApplication.cdmaOtaProvisionData.inOtaSpcState;
389
390 if (spcState) {
391 Log.i(LOG_TAG, "Ignoring incoming call: OTA call is active");
392 return true;
393 } else if (activateState || dialogState) {
394 // We *are* allowed to receive incoming calls at this point.
395 // But clear out any residual OTASP UI first.
396 // TODO: It's an MVC violation to twiddle the OTA UI state here;
397 // we should instead provide a higher-level API via OtaUtils.
398 if (dialogState) mApplication.dismissOtaDialogs();
399 mApplication.clearOtaState();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700400 return false;
401 }
402 }
403
404 // Normal case: allow this call to be presented to the user.
405 return false;
406 }
407
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700408 private void onUnknownConnectionAppeared(AsyncResult r) {
409 PhoneConstants.State state = mCM.getState();
410
411 if (state == PhoneConstants.State.OFFHOOK) {
Santos Cordon54fdb592013-09-19 05:16:18 -0700412 if (DBG) log("unknown connection appeared...");
Chiao Cheng312b9c92013-09-16 15:40:53 -0700413
Santos Cordon54fdb592013-09-19 05:16:18 -0700414 onPhoneStateChanged(r);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700415 }
416 }
417
Christine Chenb5e4b652013-09-19 11:20:18 -0700418 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700419 * Updates the phone UI in response to phone state changes.
420 *
421 * Watch out: certain state changes are actually handled by their own
422 * specific methods:
423 * - see onNewRingingConnection() for new incoming calls
424 * - see onDisconnect() for calls being hung up or disconnected
425 */
426 private void onPhoneStateChanged(AsyncResult r) {
427 PhoneConstants.State state = mCM.getState();
428 if (VDBG) log("onPhoneStateChanged: state = " + state);
429
430 // Turn status bar notifications on or off depending upon the state
431 // of the phone. Notification Alerts (audible or vibrating) should
432 // be on if and only if the phone is IDLE.
433 mApplication.notificationMgr.statusBarHelper
434 .enableNotificationAlerts(state == PhoneConstants.State.IDLE);
435
436 Phone fgPhone = mCM.getFgPhone();
437 if (fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
438 if ((fgPhone.getForegroundCall().getState() == Call.State.ACTIVE)
439 && ((mPreviousCdmaCallState == Call.State.DIALING)
440 || (mPreviousCdmaCallState == Call.State.ALERTING))) {
441 if (mIsCdmaRedialCall) {
442 int toneToPlay = InCallTonePlayer.TONE_REDIAL;
443 new InCallTonePlayer(toneToPlay).start();
444 }
445 // Stop any signal info tone when call moves to ACTIVE state
446 stopSignalInfoTone();
447 }
448 mPreviousCdmaCallState = fgPhone.getForegroundCall().getState();
449 }
450
451 // Have the PhoneApp recompute its mShowBluetoothIndication
452 // flag based on the (new) telephony state.
453 // There's no need to force a UI update since we update the
454 // in-call notification ourselves (below), and the InCallScreen
455 // listens for phone state changes itself.
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700456 mBluetoothManager.updateBluetoothIndication();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700457
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700458 // Update the phone state and other sensor/lock.
459 mApplication.updatePhoneState(state);
460
461 if (state == PhoneConstants.State.OFFHOOK) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700462
463 if (VDBG) log("onPhoneStateChanged: OFF HOOK");
464 // make sure audio is in in-call mode now
465 PhoneUtils.setAudioMode(mCM);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700466 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700467 }
468
469 void updateCallNotifierRegistrationsAfterRadioTechnologyChange() {
470 if (DBG) Log.d(LOG_TAG, "updateCallNotifierRegistrationsAfterRadioTechnologyChange...");
471
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700472 // Instantiate mSignalInfoToneGenerator
473 createSignalInfoToneGenerator();
474 }
475
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700476 private void onDisconnect(AsyncResult r) {
477 if (VDBG) log("onDisconnect()... CallManager state: " + mCM.getState());
478
479 mVoicePrivacyState = false;
480 Connection c = (Connection) r.result;
481 if (c != null) {
Anders Kristensen0b35f042014-02-27 14:31:07 -0800482 log("onDisconnect: cause = " + DisconnectCause.toString(c.getDisconnectCause())
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700483 + ", incoming = " + c.isIncoming()
484 + ", date = " + c.getCreateTime());
485 } else {
486 Log.w(LOG_TAG, "onDisconnect: null connection");
487 }
488
489 int autoretrySetting = 0;
490 if ((c != null) && (c.getCall().getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)) {
491 autoretrySetting = android.provider.Settings.Global.getInt(mApplication.
492 getContentResolver(),android.provider.Settings.Global.CALL_AUTO_RETRY, 0);
493 }
494
495 // Stop any signalInfo tone being played when a call gets ended
496 stopSignalInfoTone();
497
498 if ((c != null) && (c.getCall().getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)) {
499 // Resetting the CdmaPhoneCallState members
500 mApplication.cdmaPhoneCallState.resetCdmaPhoneCallState();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700501 }
502
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700503 // If this is the end of an OTASP call, pass it on to the PhoneApp.
504 if (c != null && TelephonyCapabilities.supportsOtasp(c.getCall().getPhone())) {
505 final String number = c.getAddress();
506 if (c.getCall().getPhone().isOtaSpNumber(number)) {
507 if (DBG) log("onDisconnect: this was an OTASP call!");
508 mApplication.handleOtaspDisconnect();
509 }
510 }
511
512 // Check for the various tones we might need to play (thru the
513 // earpiece) after a call disconnects.
514 int toneToPlay = InCallTonePlayer.TONE_NONE;
515
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700516 // If we don't need to play BUSY or CONGESTION, then play the
517 // "call ended" tone if this was a "regular disconnect" (i.e. a
518 // normal call where one end or the other hung up) *and* this
519 // disconnect event caused the phone to become idle. (In other
520 // words, we *don't* play the sound if one call hangs up but
521 // there's still an active call on the other line.)
522 // TODO: We may eventually want to disable this via a preference.
523 if ((toneToPlay == InCallTonePlayer.TONE_NONE)
524 && (mCM.getState() == PhoneConstants.State.IDLE)
525 && (c != null)) {
Anders Kristensen0b35f042014-02-27 14:31:07 -0800526 int cause = c.getDisconnectCause();
527 if ((cause == DisconnectCause.NORMAL) // remote hangup
528 || (cause == DisconnectCause.LOCAL)) { // local hangup
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700529 if (VDBG) log("- need to play CALL_ENDED tone!");
530 toneToPlay = InCallTonePlayer.TONE_CALL_ENDED;
531 mIsCdmaRedialCall = false;
532 }
533 }
534
535 // All phone calls are disconnected.
536 if (mCM.getState() == PhoneConstants.State.IDLE) {
537 // Don't reset the audio mode or bluetooth/speakerphone state
538 // if we still need to let the user hear a tone through the earpiece.
539 if (toneToPlay == InCallTonePlayer.TONE_NONE) {
540 resetAudioStateAfterDisconnect();
541 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700542 }
543
544 if (c != null) {
545 mCallLogger.logCall(c);
546
547 final String number = c.getAddress();
548 final Phone phone = c.getCall().getPhone();
549 final boolean isEmergencyNumber =
Yorke Lee36bb2542014-06-05 08:09:52 -0700550 PhoneNumberUtils.isLocalEmergencyNumber(mApplication, number);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700551
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700552 // Possibly play a "post-disconnect tone" thru the earpiece.
553 // We do this here, rather than from the InCallScreen
554 // activity, since we need to do this even if you're not in
555 // the Phone UI at the moment the connection ends.
556 if (toneToPlay != InCallTonePlayer.TONE_NONE) {
557 if (VDBG) log("- starting post-disconnect tone (" + toneToPlay + ")...");
558 new InCallTonePlayer(toneToPlay).start();
559
560 // TODO: alternatively, we could start an InCallTonePlayer
561 // here with an "unlimited" tone length,
562 // and manually stop it later when this connection truly goes
563 // away. (The real connection over the network was closed as soon
564 // as we got the BUSY message. But our telephony layer keeps the
565 // connection open for a few extra seconds so we can show the
566 // "busy" indication to the user. We could stop the busy tone
567 // when *that* connection's "disconnect" event comes in.)
568 }
569
Santos Cordonf68db2e2014-07-02 14:40:44 -0700570 final int cause = c.getDisconnectCause();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700571 if (((mPreviousCdmaCallState == Call.State.DIALING)
572 || (mPreviousCdmaCallState == Call.State.ALERTING))
573 && (!isEmergencyNumber)
Anders Kristensen0b35f042014-02-27 14:31:07 -0800574 && (cause != DisconnectCause.INCOMING_MISSED )
575 && (cause != DisconnectCause.NORMAL)
576 && (cause != DisconnectCause.LOCAL)
577 && (cause != DisconnectCause.INCOMING_REJECTED)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700578 if (!mIsCdmaRedialCall) {
579 if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) {
580 // TODO: (Moto): The contact reference data may need to be stored and use
581 // here when redialing a call. For now, pass in NULL as the URI parameter.
Santos Cordonce02f3a2013-09-19 01:58:42 -0700582 final int status =
583 PhoneUtils.placeCall(mApplication, phone, number, null, false);
584 if (status != PhoneUtils.CALL_STATUS_FAILED) {
585 mIsCdmaRedialCall = true;
586 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700587 } else {
588 mIsCdmaRedialCall = false;
589 }
590 } else {
591 mIsCdmaRedialCall = false;
592 }
593 }
594 }
595 }
596
597 /**
598 * Resets the audio mode and speaker state when a call ends.
599 */
600 private void resetAudioStateAfterDisconnect() {
601 if (VDBG) log("resetAudioStateAfterDisconnect()...");
602
603 if (mBluetoothHeadset != null) {
604 mBluetoothHeadset.disconnectAudio();
605 }
606
607 // call turnOnSpeaker() with state=false and store=true even if speaker
608 // is already off to reset user requested speaker state.
609 PhoneUtils.turnOnSpeaker(mApplication, false, true);
610
611 PhoneUtils.setAudioMode(mCM);
612 }
613
614 private void onMwiChanged(boolean visible) {
615 if (VDBG) log("onMwiChanged(): " + visible);
616
617 // "Voicemail" is meaningless on non-voice-capable devices,
618 // so ignore MWI events.
619 if (!PhoneGlobals.sVoiceCapable) {
620 // ...but still log a warning, since we shouldn't have gotten this
621 // event in the first place!
622 // (PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR events
623 // *should* be blocked at the telephony layer on non-voice-capable
624 // capable devices.)
625 Log.w(LOG_TAG, "Got onMwiChanged() on non-voice-capable device! Ignoring...");
626 return;
627 }
628
629 mApplication.notificationMgr.updateMwi(visible);
630 }
631
632 /**
633 * Posts a delayed PHONE_MWI_CHANGED event, to schedule a "retry" for a
634 * failed NotificationMgr.updateMwi() call.
635 */
636 /* package */ void sendMwiChangedDelayed(long delayMillis) {
637 Message message = Message.obtain(this, PHONE_MWI_CHANGED);
638 sendMessageDelayed(message, delayMillis);
639 }
640
641 private void onCfiChanged(boolean visible) {
642 if (VDBG) log("onCfiChanged(): " + visible);
643 mApplication.notificationMgr.updateCfi(visible);
644 }
645
646 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700647 * Helper class to play tones through the earpiece (or speaker / BT)
648 * during a call, using the ToneGenerator.
649 *
650 * To use, just instantiate a new InCallTonePlayer
651 * (passing in the TONE_* constant for the tone you want)
652 * and start() it.
653 *
654 * When we're done playing the tone, if the phone is idle at that
655 * point, we'll reset the audio routing and speaker state.
656 * (That means that for tones that get played *after* a call
657 * disconnects, like "busy" or "congestion" or "call ended", you
658 * should NOT call resetAudioStateAfterDisconnect() yourself.
659 * Instead, just start the InCallTonePlayer, which will automatically
660 * defer the resetAudioStateAfterDisconnect() call until the tone
661 * finishes playing.)
662 */
663 private class InCallTonePlayer extends Thread {
664 private int mToneId;
665 private int mState;
666 // The possible tones we can play.
667 public static final int TONE_NONE = 0;
668 public static final int TONE_CALL_WAITING = 1;
669 public static final int TONE_BUSY = 2;
670 public static final int TONE_CONGESTION = 3;
671 public static final int TONE_CALL_ENDED = 4;
672 public static final int TONE_VOICE_PRIVACY = 5;
673 public static final int TONE_REORDER = 6;
674 public static final int TONE_INTERCEPT = 7;
675 public static final int TONE_CDMA_DROP = 8;
676 public static final int TONE_OUT_OF_SERVICE = 9;
677 public static final int TONE_REDIAL = 10;
678 public static final int TONE_OTA_CALL_END = 11;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700679 public static final int TONE_UNOBTAINABLE_NUMBER = 13;
680
681 // The tone volume relative to other sounds in the stream
682 static final int TONE_RELATIVE_VOLUME_EMERGENCY = 100;
683 static final int TONE_RELATIVE_VOLUME_HIPRI = 80;
684 static final int TONE_RELATIVE_VOLUME_LOPRI = 50;
685
686 // Buffer time (in msec) to add on to tone timeout value.
687 // Needed mainly when the timeout value for a tone is the
688 // exact duration of the tone itself.
689 static final int TONE_TIMEOUT_BUFFER = 20;
690
691 // The tone state
692 static final int TONE_OFF = 0;
693 static final int TONE_ON = 1;
694 static final int TONE_STOPPED = 2;
695
696 InCallTonePlayer(int toneId) {
697 super();
698 mToneId = toneId;
699 mState = TONE_OFF;
700 }
701
702 @Override
703 public void run() {
704 log("InCallTonePlayer.run(toneId = " + mToneId + ")...");
705
706 int toneType = 0; // passed to ToneGenerator.startTone()
707 int toneVolume; // passed to the ToneGenerator constructor
708 int toneLengthMillis;
709 int phoneType = mCM.getFgPhone().getPhoneType();
710
711 switch (mToneId) {
712 case TONE_CALL_WAITING:
713 toneType = ToneGenerator.TONE_SUP_CALL_WAITING;
714 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
715 // Call waiting tone is stopped by stopTone() method
716 toneLengthMillis = Integer.MAX_VALUE - TONE_TIMEOUT_BUFFER;
717 break;
718 case TONE_BUSY:
719 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
720 toneType = ToneGenerator.TONE_CDMA_NETWORK_BUSY_ONE_SHOT;
721 toneVolume = TONE_RELATIVE_VOLUME_LOPRI;
722 toneLengthMillis = 1000;
Sailesh Nepalcc0375f2013-11-13 09:15:18 -0800723 } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM
724 || phoneType == PhoneConstants.PHONE_TYPE_SIP
Etan Cohen0ca1c802014-07-07 15:35:48 -0700725 || phoneType == PhoneConstants.PHONE_TYPE_IMS
Sailesh Nepalcc0375f2013-11-13 09:15:18 -0800726 || phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700727 toneType = ToneGenerator.TONE_SUP_BUSY;
728 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
729 toneLengthMillis = 4000;
730 } else {
731 throw new IllegalStateException("Unexpected phone type: " + phoneType);
732 }
733 break;
734 case TONE_CONGESTION:
735 toneType = ToneGenerator.TONE_SUP_CONGESTION;
736 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
737 toneLengthMillis = 4000;
738 break;
739
740 case TONE_CALL_ENDED:
741 toneType = ToneGenerator.TONE_PROP_PROMPT;
742 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
743 toneLengthMillis = 200;
744 break;
745 case TONE_OTA_CALL_END:
746 if (mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone ==
747 OtaUtils.OTA_PLAY_SUCCESS_FAILURE_TONE_ON) {
748 toneType = ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD;
749 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
750 toneLengthMillis = 750;
751 } else {
752 toneType = ToneGenerator.TONE_PROP_PROMPT;
753 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
754 toneLengthMillis = 200;
755 }
756 break;
757 case TONE_VOICE_PRIVACY:
758 toneType = ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE;
759 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
760 toneLengthMillis = 5000;
761 break;
762 case TONE_REORDER:
763 toneType = ToneGenerator.TONE_CDMA_REORDER;
764 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
765 toneLengthMillis = 4000;
766 break;
767 case TONE_INTERCEPT:
768 toneType = ToneGenerator.TONE_CDMA_ABBR_INTERCEPT;
769 toneVolume = TONE_RELATIVE_VOLUME_LOPRI;
770 toneLengthMillis = 500;
771 break;
772 case TONE_CDMA_DROP:
773 case TONE_OUT_OF_SERVICE:
774 toneType = ToneGenerator.TONE_CDMA_CALLDROP_LITE;
775 toneVolume = TONE_RELATIVE_VOLUME_LOPRI;
776 toneLengthMillis = 375;
777 break;
778 case TONE_REDIAL:
779 toneType = ToneGenerator.TONE_CDMA_ALERT_AUTOREDIAL_LITE;
780 toneVolume = TONE_RELATIVE_VOLUME_LOPRI;
781 toneLengthMillis = 5000;
782 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700783 case TONE_UNOBTAINABLE_NUMBER:
784 toneType = ToneGenerator.TONE_SUP_ERROR;
785 toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
786 toneLengthMillis = 4000;
787 break;
788 default:
789 throw new IllegalArgumentException("Bad toneId: " + mToneId);
790 }
791
792 // If the mToneGenerator creation fails, just continue without it. It is
793 // a local audio signal, and is not as important.
794 ToneGenerator toneGenerator;
795 try {
796 int stream;
797 if (mBluetoothHeadset != null) {
798 stream = mBluetoothHeadset.isAudioOn() ? AudioManager.STREAM_BLUETOOTH_SCO:
799 AudioManager.STREAM_VOICE_CALL;
800 } else {
801 stream = AudioManager.STREAM_VOICE_CALL;
802 }
803 toneGenerator = new ToneGenerator(stream, toneVolume);
804 // if (DBG) log("- created toneGenerator: " + toneGenerator);
805 } catch (RuntimeException e) {
806 Log.w(LOG_TAG,
807 "InCallTonePlayer: Exception caught while creating ToneGenerator: " + e);
808 toneGenerator = null;
809 }
810
811 // Using the ToneGenerator (with the CALL_WAITING / BUSY /
812 // CONGESTION tones at least), the ToneGenerator itself knows
813 // the right pattern of tones to play; we do NOT need to
814 // manually start/stop each individual tone, or manually
815 // insert the correct delay between tones. (We just start it
816 // and let it run for however long we want the tone pattern to
817 // continue.)
818 //
819 // TODO: When we stop the ToneGenerator in the middle of a
820 // "tone pattern", it sounds bad if we cut if off while the
821 // tone is actually playing. Consider adding API to the
822 // ToneGenerator to say "stop at the next silent part of the
823 // pattern", or simply "play the pattern N times and then
824 // stop."
825 boolean needToStopTone = true;
826 boolean okToPlayTone = false;
827
828 if (toneGenerator != null) {
829 int ringerMode = mAudioManager.getRingerMode();
830 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
831 if (toneType == ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD) {
832 if ((ringerMode != AudioManager.RINGER_MODE_SILENT) &&
833 (ringerMode != AudioManager.RINGER_MODE_VIBRATE)) {
834 if (DBG) log("- InCallTonePlayer: start playing call tone=" + toneType);
835 okToPlayTone = true;
836 needToStopTone = false;
837 }
838 } else if ((toneType == ToneGenerator.TONE_CDMA_NETWORK_BUSY_ONE_SHOT) ||
839 (toneType == ToneGenerator.TONE_CDMA_REORDER) ||
840 (toneType == ToneGenerator.TONE_CDMA_ABBR_REORDER) ||
841 (toneType == ToneGenerator.TONE_CDMA_ABBR_INTERCEPT) ||
842 (toneType == ToneGenerator.TONE_CDMA_CALLDROP_LITE)) {
843 if (ringerMode != AudioManager.RINGER_MODE_SILENT) {
844 if (DBG) log("InCallTonePlayer:playing call fail tone:" + toneType);
845 okToPlayTone = true;
846 needToStopTone = false;
847 }
848 } else if ((toneType == ToneGenerator.TONE_CDMA_ALERT_AUTOREDIAL_LITE) ||
849 (toneType == ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE)) {
850 if ((ringerMode != AudioManager.RINGER_MODE_SILENT) &&
851 (ringerMode != AudioManager.RINGER_MODE_VIBRATE)) {
852 if (DBG) log("InCallTonePlayer:playing tone for toneType=" + toneType);
853 okToPlayTone = true;
854 needToStopTone = false;
855 }
856 } else { // For the rest of the tones, always OK to play.
857 okToPlayTone = true;
858 }
859 } else { // Not "CDMA"
860 okToPlayTone = true;
861 }
862
863 synchronized (this) {
864 if (okToPlayTone && mState != TONE_STOPPED) {
865 mState = TONE_ON;
866 toneGenerator.startTone(toneType);
867 try {
868 wait(toneLengthMillis + TONE_TIMEOUT_BUFFER);
869 } catch (InterruptedException e) {
870 Log.w(LOG_TAG,
871 "InCallTonePlayer stopped: " + e);
872 }
873 if (needToStopTone) {
874 toneGenerator.stopTone();
875 }
876 }
877 // if (DBG) log("- InCallTonePlayer: done playing.");
878 toneGenerator.release();
879 mState = TONE_OFF;
880 }
881 }
882
883 // Finally, do the same cleanup we otherwise would have done
884 // in onDisconnect().
885 //
886 // (But watch out: do NOT do this if the phone is in use,
887 // since some of our tones get played *during* a call (like
888 // CALL_WAITING) and we definitely *don't*
889 // want to reset the audio mode / speaker / bluetooth after
890 // playing those!
891 // This call is really here for use with tones that get played
892 // *after* a call disconnects, like "busy" or "congestion" or
893 // "call ended", where the phone has already become idle but
894 // we need to defer the resetAudioStateAfterDisconnect() call
895 // till the tone finishes playing.)
896 if (mCM.getState() == PhoneConstants.State.IDLE) {
897 resetAudioStateAfterDisconnect();
898 }
899 }
900
901 public void stopTone() {
902 synchronized (this) {
903 if (mState == TONE_ON) {
904 notify();
905 }
906 mState = TONE_STOPPED;
907 }
908 }
909 }
910
911 /**
912 * Displays a notification when the phone receives a DisplayInfo record.
913 */
914 private void onDisplayInfo(AsyncResult r) {
915 // Extract the DisplayInfo String from the message
916 CdmaDisplayInfoRec displayInfoRec = (CdmaDisplayInfoRec)(r.result);
917
918 if (displayInfoRec != null) {
919 String displayInfo = displayInfoRec.alpha;
920 if (DBG) log("onDisplayInfo: displayInfo=" + displayInfo);
921 CdmaDisplayInfo.displayInfoRecord(mApplication, displayInfo);
922
923 // start a 2 second timer
924 sendEmptyMessageDelayed(DISPLAYINFO_NOTIFICATION_DONE,
925 DISPLAYINFO_NOTIFICATION_TIME);
926 }
927 }
928
929 /**
930 * Helper class to play SignalInfo tones using the ToneGenerator.
931 *
932 * To use, just instantiate a new SignalInfoTonePlayer
933 * (passing in the ToneID constant for the tone you want)
934 * and start() it.
935 */
936 private class SignalInfoTonePlayer extends Thread {
937 private int mToneId;
938
939 SignalInfoTonePlayer(int toneId) {
940 super();
941 mToneId = toneId;
942 }
943
944 @Override
945 public void run() {
946 log("SignalInfoTonePlayer.run(toneId = " + mToneId + ")...");
947
948 if (mSignalInfoToneGenerator != null) {
949 //First stop any ongoing SignalInfo tone
950 mSignalInfoToneGenerator.stopTone();
951
952 //Start playing the new tone if its a valid tone
953 mSignalInfoToneGenerator.startTone(mToneId);
954 }
955 }
956 }
957
958 /**
959 * Plays a tone when the phone receives a SignalInfo record.
960 */
961 private void onSignalInfo(AsyncResult r) {
962 // Signal Info are totally ignored on non-voice-capable devices.
963 if (!PhoneGlobals.sVoiceCapable) {
964 Log.w(LOG_TAG, "Got onSignalInfo() on non-voice-capable device! Ignoring...");
965 return;
966 }
967
968 if (PhoneUtils.isRealIncomingCall(mCM.getFirstActiveRingingCall().getState())) {
969 // Do not start any new SignalInfo tone when Call state is INCOMING
970 // and stop any previous SignalInfo tone which is being played
971 stopSignalInfoTone();
972 } else {
973 // Extract the SignalInfo String from the message
974 CdmaSignalInfoRec signalInfoRec = (CdmaSignalInfoRec)(r.result);
975 // Only proceed if a Signal info is present.
976 if (signalInfoRec != null) {
977 boolean isPresent = signalInfoRec.isPresent;
978 if (DBG) log("onSignalInfo: isPresent=" + isPresent);
979 if (isPresent) {// if tone is valid
980 int uSignalType = signalInfoRec.signalType;
981 int uAlertPitch = signalInfoRec.alertPitch;
982 int uSignal = signalInfoRec.signal;
983
984 if (DBG) log("onSignalInfo: uSignalType=" + uSignalType + ", uAlertPitch=" +
985 uAlertPitch + ", uSignal=" + uSignal);
986 //Map the Signal to a ToneGenerator ToneID only if Signal info is present
987 int toneID = SignalToneUtil.getAudioToneFromSignalInfo
988 (uSignalType, uAlertPitch, uSignal);
989
990 //Create the SignalInfo tone player and pass the ToneID
991 new SignalInfoTonePlayer(toneID).start();
992 }
993 }
994 }
995 }
996
997 /**
998 * Stops a SignalInfo tone in the following condition
999 * 1 - On receiving a New Ringing Call
1000 * 2 - On disconnecting a call
1001 * 3 - On answering a Call Waiting Call
1002 */
1003 /* package */ void stopSignalInfoTone() {
1004 if (DBG) log("stopSignalInfoTone: Stopping SignalInfo tone player");
1005 new SignalInfoTonePlayer(ToneGenerator.TONE_CDMA_SIGNAL_OFF).start();
1006 }
1007
1008 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001009 * Return the private variable mPreviousCdmaCallState.
1010 */
1011 /* package */ Call.State getPreviousCdmaCallState() {
1012 return mPreviousCdmaCallState;
1013 }
1014
1015 /**
1016 * Return the private variable mVoicePrivacyState.
1017 */
1018 /* package */ boolean getVoicePrivacyState() {
1019 return mVoicePrivacyState;
1020 }
1021
1022 /**
1023 * Return the private variable mIsCdmaRedialCall.
1024 */
1025 /* package */ boolean getIsCdmaRedialCall() {
1026 return mIsCdmaRedialCall;
1027 }
1028
Santos Cordon5c046722014-09-18 15:41:13 -07001029 private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001030 new BluetoothProfile.ServiceListener() {
1031 public void onServiceConnected(int profile, BluetoothProfile proxy) {
1032 mBluetoothHeadset = (BluetoothHeadset) proxy;
1033 if (VDBG) log("- Got BluetoothHeadset: " + mBluetoothHeadset);
1034 }
1035
1036 public void onServiceDisconnected(int profile) {
1037 mBluetoothHeadset = null;
1038 }
1039 };
1040
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001041 private void log(String msg) {
1042 Log.d(LOG_TAG, msg);
1043 }
1044}