summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/CallManager.java52
-rwxr-xr-xtelephony/java/com/android/internal/telephony/sip/SipPhone.java42
2 files changed, 84 insertions, 10 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java
index 819cfbe..8e08592 100644
--- a/telephony/java/com/android/internal/telephony/CallManager.java
+++ b/telephony/java/com/android/internal/telephony/CallManager.java
@@ -16,16 +16,17 @@
package com.android.internal.telephony;
+import com.android.internal.telephony.sip.SipPhone;
+
import android.content.Context;
+import android.media.AudioManager;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
import android.os.RegistrantList;
-import android.util.Log;
-
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
-
+import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
@@ -52,7 +53,7 @@ import java.util.List;
*/
public final class CallManager {
- private static final String LOG_TAG ="GSM";
+ private static final String LOG_TAG ="Phone";
private static final boolean LOCAL_DEBUG = true;
private static final int EVENT_DISCONNECT = 100;
@@ -303,6 +304,32 @@ public final class CallManager {
}
}
+ public void setAudioMode() {
+ Context context = getContext();
+ if (context == null) return;
+ AudioManager audioManager = (AudioManager)
+ context.getSystemService(Context.AUDIO_SERVICE);
+
+ int mode = AudioManager.MODE_NORMAL;
+ switch (getState()) {
+ case RINGING:
+ mode = AudioManager.MODE_RINGTONE;
+ break;
+ case OFFHOOK:
+ Phone fgPhone = getFgPhone();
+ if (!(fgPhone instanceof SipPhone)) {
+ mode = AudioManager.MODE_IN_CALL;
+ }
+ break;
+ }
+ audioManager.setMode(mode);
+ }
+
+ private Context getContext() {
+ Phone defaultPhone = getDefaultPhone();
+ return ((defaultPhone == null) ? null : defaultPhone.getContext());
+ }
+
private void registerForPhoneStates(Phone phone) {
phone.registerForPreciseCallStateChanged(mHandler, EVENT_PRECISE_CALL_STATE_CHANGED, null);
phone.registerForDisconnect(mHandler, EVENT_DISCONNECT, null);
@@ -453,7 +480,7 @@ public final class CallManager {
heldPhone = heldCall.getPhone();
}
- return (heldPhone == activePhone);
+ return heldPhone.getClass().equals(activePhone.getClass());
}
/**
@@ -466,10 +493,14 @@ public final class CallManager {
* In these cases, this operation may not be performed.
*/
public void conference(Call heldCall) throws CallStateException {
- if (canConference(heldCall))
+ Phone fgPhone = getFgPhone();
+ if (fgPhone instanceof SipPhone) {
+ ((SipPhone) fgPhone).conference(heldCall);
+ } else if (canConference(heldCall)) {
+ fgPhone.conference();
+ } else {
throw(new CallStateException("Can't conference foreground and selected background call"));
-
- heldCall.getPhone().conference();
+ }
}
/**
@@ -1288,7 +1319,10 @@ public final class CallManager {
mUnknownConnectionRegistrants.notifyRegistrants((AsyncResult) msg.obj);
break;
case EVENT_INCOMING_RING:
- mIncomingRingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ // The event may come from RIL who's not aware of an ongoing fg call
+ if (!hasActiveFgCall()) {
+ mIncomingRingRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+ }
break;
case EVENT_RINGBACK_TONE:
mRingbackToneRegistrants.notifyRegistrants((AsyncResult) msg.obj);
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index b35814c..81dfaeb 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.net.rtp.AudioGroup;
+import android.net.rtp.AudioStream;
import android.net.sip.SipAudioCall;
import android.net.sip.SipManager;
import android.net.sip.SipProfile;
@@ -224,7 +225,21 @@ public class SipPhone extends SipPhoneBase {
}
public void conference() throws CallStateException {
- // TODO
+ if ((foregroundCall.getState() != SipCall.State.ACTIVE)
+ || (foregroundCall.getState() != SipCall.State.ACTIVE)) {
+ throw new CallStateException("wrong state to merge calls: fg="
+ + foregroundCall.getState() + ", bg="
+ + backgroundCall.getState());
+ }
+ foregroundCall.merge(backgroundCall);
+ }
+
+ public void conference(Call that) throws CallStateException {
+ if (!(that instanceof SipCall)) {
+ throw new CallStateException("expect " + SipCall.class
+ + ", cannot merge with " + that.getClass());
+ }
+ foregroundCall.merge((SipCall) that);
}
public boolean canTransfer() {
@@ -470,6 +485,18 @@ public class SipPhone extends SipPhoneBase {
return (audioGroup.getMode() == AudioGroup.MODE_MUTED);
}
+ void merge(SipCall that) throws CallStateException {
+ AudioGroup myGroup = getAudioGroup();
+ for (Connection c : that.connections) {
+ SipConnection conn = (SipConnection) c;
+ conn.mergeTo(myGroup);
+ connections.add(conn);
+ conn.changeOwner(this);
+ }
+ that.connections.clear();
+ that.setState(Call.State.IDLE);
+ }
+
void sendDtmf(char c) {
AudioGroup audioGroup = getAudioGroup();
if (audioGroup == null) return;
@@ -544,6 +571,7 @@ public class SipPhone extends SipPhoneBase {
private class SipConnection extends SipConnectionBase {
private SipCall mOwner;
private SipAudioCall mSipAudioCall;
+ private AudioGroup mOriginalGroup;
private Call.State mState = Call.State.IDLE;
private SipProfile mPeer;
private boolean mIncoming = false;
@@ -663,6 +691,16 @@ public class SipPhone extends SipPhoneBase {
}
}
+ void mergeTo(AudioGroup group) throws CallStateException {
+ AudioStream stream = mSipAudioCall.getAudioStream();
+ if (stream == null) {
+ throw new CallStateException("wrong state to merge: "
+ + mSipAudioCall.getState());
+ }
+ if (mOriginalGroup == null) mOriginalGroup = getAudioGroup();
+ stream.join(group);
+ }
+
@Override
protected void setState(Call.State state) {
if (state == mState) return;
@@ -697,6 +735,8 @@ public class SipPhone extends SipPhoneBase {
@Override
public void hangup() throws CallStateException {
+ // TODO: need to pull AudioStream out of the AudioGroup in case
+ // this conn was part of a conf call
Log.v(LOG_TAG, "hangup conn: " + mPeer.getUriString() + ": "
+ ": on phone " + getPhone());
try {