diff options
author | Santos Cordon <santoscordon@google.com> | 2014-08-06 20:03:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-06 17:19:40 +0000 |
commit | 624d9e3ea71b6777fa3bcfa03ea68c60b0e7e6cb (patch) | |
tree | c0855aa0bc74a05f6d88b0450ae22e17ad44b8b6 | |
parent | 4d6896f4d422d39f8cd0b3cc0c7992fbb71696ad (diff) | |
parent | 12bccb9d6fa9f5e1daff8d51a0527dbdfb8606bd (diff) |
Merge "Remove hardcoded audio route in video provider." into lmp-dev
5 files changed, 53 insertions, 43 deletions
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<AudioModeListener> 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 66a384126..9c2703ca1 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 */ @@ -387,20 +387,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() @@ -429,9 +429,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(); @@ -461,8 +461,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; @@ -484,9 +484,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; @@ -502,7 +502,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; @@ -572,7 +572,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. @@ -581,7 +581,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); @@ -591,7 +591,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<CallButtonPresenter.CallButto // an update for onAudioMode(). This will make UI response immediate // if it turns out to be slow - Log.d(this, "Sending new Audio Mode: " + AudioMode.toString(mode)); + Log.d(this, "Sending new Audio Mode: " + CallAudioState.audioRouteToString(mode)); TelecommAdapter.getInstance().setAudioRoute(mode); } @@ -150,7 +150,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto */ public void toggleSpeakerphone() { // this function should not be called if bluetooth is available - if (0 != (AudioMode.BLUETOOTH & getSupportedAudio())) { + if (0 != (CallAudioState.ROUTE_BLUETOOTH & getSupportedAudio())) { // It's clear the UI is wrong, so update the supported mode once again. Log.e(this, "toggling speakerphone not allowed when bluetooth supported."); @@ -158,11 +158,11 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto return; } - int newMode = AudioMode.SPEAKER; + int newMode = CallAudioState.ROUTE_SPEAKER; // if speakerphone is already on, change to wired/earpiece - if (getAudioMode() == AudioMode.SPEAKER) { - newMode = AudioMode.WIRED_OR_EARPIECE; + if (getAudioMode() == CallAudioState.ROUTE_SPEAKER) { + newMode = CallAudioState.ROUTE_WIRED_OR_EARPIECE; } setAudioMode(newMode); diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java index fc783b2f5..768a71478 100644 --- a/InCallUI/src/com/android/incallui/ProximitySensor.java +++ b/InCallUI/src/com/android/incallui/ProximitySensor.java @@ -20,10 +20,11 @@ import android.content.Context; import android.content.res.Configuration; import android.os.PowerManager; +import android.telecomm.CallAudioState; + import com.android.incallui.AudioModeProvider.AudioModeListener; import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallStateListener; -import com.android.services.telephony.common.AudioMode; import com.google.common.base.Objects; /** @@ -176,9 +177,9 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene // turn proximity sensor off and turn screen on immediately if // we are using a headset, the keyboard is open, or the device // is being held in a horizontal position. - boolean screenOnImmediately = (AudioMode.WIRED_HEADSET == audioMode - || AudioMode.SPEAKER == audioMode - || AudioMode.BLUETOOTH == audioMode + boolean screenOnImmediately = (CallAudioState.ROUTE_WIRED_HEADSET == audioMode + || CallAudioState.ROUTE_SPEAKER == audioMode + || CallAudioState.ROUTE_BLUETOOTH == audioMode || mIsHardKeyboardOpen); // We do not keep the screen off when the user is outside in-call screen and we are @@ -202,7 +203,8 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene .add("offhook", mIsPhoneOffhook ? 1 : 0) .add("hor", horizontal ? 1 : 0) .add("ui", mUiShowing ? 1 : 0) - .add("aud", AudioMode.toString(audioMode)).toString()); + .add("aud", CallAudioState.audioRouteToString(audioMode)) + .toString()); if (mIsPhoneOffhook && !screenOnImmediately) { Log.d(this, "Turning on proximity sensor"); diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 1d3e62b5b..77aa4ac0c 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -16,20 +16,19 @@ package com.android.incallui; -import com.google.common.base.Preconditions; -import com.android.incallui.InCallVideoCallListenerNotifier.SurfaceChangeListener; -import com.android.incallui.InCallVideoCallListenerNotifier.VideoEventListener; -import com.android.incallui.InCallPresenter.InCallDetailsListener; -import com.android.incallui.InCallPresenter.InCallOrientationListener; -import com.android.incallui.InCallPresenter.InCallStateListener; -import com.android.incallui.InCallPresenter.IncomingCallListener; - import android.content.Context; import android.content.res.Configuration; +import android.telecomm.CallAudioState; import android.telecomm.InCallService.VideoCall; import android.view.Surface; -import com.android.services.telephony.common.AudioMode; +import com.android.incallui.InCallPresenter.InCallDetailsListener; +import com.android.incallui.InCallPresenter.InCallOrientationListener; +import com.android.incallui.InCallPresenter.InCallStateListener; +import com.android.incallui.InCallPresenter.IncomingCallListener; +import com.android.incallui.InCallVideoCallListenerNotifier.SurfaceChangeListener; +import com.android.incallui.InCallVideoCallListenerNotifier.VideoEventListener; +import com.google.common.base.Preconditions; import java.util.Objects; @@ -142,6 +141,11 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi private boolean mIsFullScreen = false; /** + * Saves the audio mode which was selected prior to going into a video call. + */ + private int mPreVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; + + /** * Initializes the presenter. * * @param context The current context. @@ -410,7 +414,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } } - TelecommAdapter.getInstance().setAudioRoute(AudioMode.SPEAKER); + mPreVideoAudioMode = AudioModeProvider.getInstance().getAudioMode(); + TelecommAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_SPEAKER); } /** @@ -424,7 +429,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().setInCallAllowsOrientationChange(false); ui.showVideoUi(false); - TelecommAdapter.getInstance().setAudioRoute(AudioMode.WIRED_OR_EARPIECE); + if (mPreVideoAudioMode != AudioModeProvider.AUDIO_MODE_INVALID) { + TelecommAdapter.getInstance().setAudioRoute(mPreVideoAudioMode); + mPreVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; + } } /** |