summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2014-08-06 20:03:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-06 17:19:40 +0000
commitbc7a0e30d614091dc4da3a12794759cf34975f56 (patch)
treeb82976c590b9bfa0c4c710eeaff119c43b4365c6
parent2fda254bf9d57859945675392193cac1027671b2 (diff)
parent4ed8d8d7d2c6766e3712a407551f79322e544aa8 (diff)
downloadpackages_apps_InCallUI-bc7a0e30d614091dc4da3a12794759cf34975f56.tar.gz
packages_apps_InCallUI-bc7a0e30d614091dc4da3a12794759cf34975f56.tar.bz2
packages_apps_InCallUI-bc7a0e30d614091dc4da3a12794759cf34975f56.zip
Merge "Remove hardcoded audio route in video provider." into lmp-dev
-rw-r--r--src/com/android/incallui/AudioModeProvider.java8
-rw-r--r--src/com/android/incallui/CallButtonFragment.java34
-rw-r--r--src/com/android/incallui/CallButtonPresenter.java12
-rw-r--r--src/com/android/incallui/ProximitySensor.java12
-rw-r--r--src/com/android/incallui/VideoCallPresenter.java30
5 files changed, 53 insertions, 43 deletions
diff --git a/src/com/android/incallui/AudioModeProvider.java b/src/com/android/incallui/AudioModeProvider.java
index f3c7da62..2b61642c 100644
--- a/src/com/android/incallui/AudioModeProvider.java
+++ b/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/src/com/android/incallui/CallButtonFragment.java b/src/com/android/incallui/CallButtonFragment.java
index 66a38412..9c2703ca 100644
--- a/src/com/android/incallui/CallButtonFragment.java
+++ b/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/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index 2e2ea4eb..a995042b 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/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/src/com/android/incallui/ProximitySensor.java b/src/com/android/incallui/ProximitySensor.java
index fc783b2f..768a7147 100644
--- a/src/com/android/incallui/ProximitySensor.java
+++ b/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/src/com/android/incallui/VideoCallPresenter.java b/src/com/android/incallui/VideoCallPresenter.java
index 1d3e62b5..77aa4ac0 100644
--- a/src/com/android/incallui/VideoCallPresenter.java
+++ b/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;
+ }
}
/**