From 12bccb9d6fa9f5e1daff8d51a0527dbdfb8606bd Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 5 Aug 2014 23:43:31 -0700 Subject: Remove hardcoded audio route in video provider. The video provider always calls exitVideo() and as a result always sets the audio mode to EARPIECE when any call starts, negating any automatic setting done by telecomm (like bluetooth). This change has three items: 1. Only set the audio mode if we are exiting a previously entered video call. 2. When setting audio on exit, set it to the mode that was previously saved when the video call was entered. 3. Convert usages of the private AudioMode to the public CallStateAudio. Change-Id: I484ea8fadc9b7cf43692b517c97f906918fc49f8 --- .../com/android/incallui/AudioModeProvider.java | 8 ++--- .../com/android/incallui/CallButtonFragment.java | 34 +++++++++++----------- .../com/android/incallui/CallButtonPresenter.java | 12 ++++---- .../src/com/android/incallui/ProximitySensor.java | 12 ++++---- .../com/android/incallui/VideoCallPresenter.java | 30 ++++++++++++------- 5 files changed, 53 insertions(+), 43 deletions(-) (limited to 'InCallUI/src') diff --git a/InCallUI/src/com/android/incallui/AudioModeProvider.java b/InCallUI/src/com/android/incallui/AudioModeProvider.java index f3c7da623..2b61642c8 100644 --- a/InCallUI/src/com/android/incallui/AudioModeProvider.java +++ b/InCallUI/src/com/android/incallui/AudioModeProvider.java @@ -18,8 +18,6 @@ package com.android.incallui; import com.google.common.collect.Lists; -import com.android.services.telephony.common.AudioMode; - import android.telecomm.CallAudioState; import android.telecomm.Phone; @@ -30,10 +28,12 @@ import java.util.List; */ /* package */ class AudioModeProvider implements InCallPhoneListener { + static final int AUDIO_MODE_INVALID = 0; + private static AudioModeProvider sAudioModeProvider = new AudioModeProvider(); - private int mAudioMode = AudioMode.EARPIECE; + private int mAudioMode = CallAudioState.ROUTE_EARPIECE; private boolean mMuted = false; - private int mSupportedModes = AudioMode.ALL_MODES; + private int mSupportedModes = CallAudioState.ROUTE_ALL; private final List mListeners = Lists.newArrayList(); private Phone mPhone; diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index e07086879..16eaa68b0 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -18,6 +18,8 @@ package com.android.incallui; import android.graphics.drawable.LayerDrawable; import android.os.Bundle; + +import android.telecomm.CallAudioState; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; @@ -31,8 +33,6 @@ import android.widget.PopupMenu; import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; -import com.android.services.telephony.common.AudioMode; - /** * Fragment for call control buttons */ @@ -386,20 +386,20 @@ public class CallButtonFragment Log.d(this, " id: " + item.getItemId()); Log.d(this, " title: '" + item.getTitle() + "'"); - int mode = AudioMode.WIRED_OR_EARPIECE; + int mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE; switch (item.getItemId()) { case R.id.audio_mode_speaker: - mode = AudioMode.SPEAKER; + mode = CallAudioState.ROUTE_SPEAKER; break; case R.id.audio_mode_earpiece: case R.id.audio_mode_wired_headset: - // InCallAudioMode.EARPIECE means either the handset earpiece, + // InCallCallAudioState.ROUTE_EARPIECE means either the handset earpiece, // or the wired headset (if connected.) - mode = AudioMode.WIRED_OR_EARPIECE; + mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE; break; case R.id.audio_mode_bluetooth: - mode = AudioMode.BLUETOOTH; + mode = CallAudioState.ROUTE_BLUETOOTH; break; default: Log.e(this, "onMenuItemClick: unexpected View ID " + item.getItemId() @@ -428,9 +428,9 @@ public class CallButtonFragment */ private void onAudioButtonClicked() { Log.d(this, "onAudioButtonClicked: " + - AudioMode.toString(getPresenter().getSupportedAudio())); + CallAudioState.audioRouteToString(getPresenter().getSupportedAudio())); - if (isSupported(AudioMode.BLUETOOTH)) { + if (isSupported(CallAudioState.ROUTE_BLUETOOTH)) { showAudioModePopup(); } else { getPresenter().toggleSpeakerphone(); @@ -460,8 +460,8 @@ public class CallButtonFragment * are visible based on the supported audio formats. */ private void updateAudioButtons(int supportedModes) { - final boolean bluetoothSupported = isSupported(AudioMode.BLUETOOTH); - final boolean speakerSupported = isSupported(AudioMode.SPEAKER); + final boolean bluetoothSupported = isSupported(CallAudioState.ROUTE_BLUETOOTH); + final boolean speakerSupported = isSupported(CallAudioState.ROUTE_SPEAKER); boolean audioButtonEnabled = false; boolean audioButtonChecked = false; @@ -483,9 +483,9 @@ public class CallButtonFragment // btn_compound_background layer anyway.) // Update desired layers: - if (isAudio(AudioMode.BLUETOOTH)) { + if (isAudio(CallAudioState.ROUTE_BLUETOOTH)) { showBluetoothIcon = true; - } else if (isAudio(AudioMode.SPEAKER)) { + } else if (isAudio(CallAudioState.ROUTE_SPEAKER)) { showSpeakerphoneIcon = true; } else { showHandsetIcon = true; @@ -501,7 +501,7 @@ public class CallButtonFragment // The audio button *is* a toggle in this state, and indicated the // current state of the speakerphone. - audioButtonChecked = isAudio(AudioMode.SPEAKER); + audioButtonChecked = isAudio(CallAudioState.ROUTE_SPEAKER); // update desired layers: showToggleIndicator = true; @@ -571,7 +571,7 @@ public class CallButtonFragment // See comments below for the exact logic. final MenuItem speakerItem = menu.findItem(R.id.audio_mode_speaker); - speakerItem.setEnabled(isSupported(AudioMode.SPEAKER)); + speakerItem.setEnabled(isSupported(CallAudioState.ROUTE_SPEAKER)); // TODO: Show speakerItem as initially "selected" if // speaker is on. @@ -580,7 +580,7 @@ public class CallButtonFragment final MenuItem earpieceItem = menu.findItem(R.id.audio_mode_earpiece); final MenuItem wiredHeadsetItem = menu.findItem(R.id.audio_mode_wired_headset); - final boolean usingHeadset = isSupported(AudioMode.WIRED_HEADSET); + final boolean usingHeadset = isSupported(CallAudioState.ROUTE_WIRED_HEADSET); earpieceItem.setVisible(!usingHeadset); earpieceItem.setEnabled(!usingHeadset); wiredHeadsetItem.setVisible(usingHeadset); @@ -590,7 +590,7 @@ public class CallButtonFragment // bluetoothIndicatorOn are both false. final MenuItem bluetoothItem = menu.findItem(R.id.audio_mode_bluetooth); - bluetoothItem.setEnabled(isSupported(AudioMode.BLUETOOTH)); + bluetoothItem.setEnabled(isSupported(CallAudioState.ROUTE_BLUETOOTH)); // TODO: Show bluetoothItem as initially "selected" if // bluetoothIndicatorOn is true. diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 2e2ea4ebf..a995042b3 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -16,6 +16,7 @@ package com.android.incallui; +import android.telecomm.CallAudioState; import android.telecomm.CallCapabilities; import android.telecomm.InCallService.VideoCall; import android.telecomm.VideoCallProfile; @@ -26,7 +27,6 @@ import com.android.incallui.AudioModeProvider.AudioModeListener; import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; -import com.android.services.telephony.common.AudioMode; import android.telephony.PhoneNumberUtils; @@ -141,7 +141,7 @@ public class CallButtonPresenter extends Presenter