am 708e4251: Merge "Revert the ANSWERING state." into gingerbread

Merge commit '708e42512a8b14202cd872d96d1f071ccb4cf915' into gingerbread-plus-aosp

* commit '708e42512a8b14202cd872d96d1f071ccb4cf915':
  Revert the ANSWERING state.
This commit is contained in:
Chung-yih Wang
2010-09-20 22:06:49 -07:00
committed by Android Git Automerger
4 changed files with 35 additions and 30 deletions

View File

@@ -238,9 +238,7 @@ public final class CallManager {
Phone.State s = Phone.State.IDLE; Phone.State s = Phone.State.IDLE;
for (Phone phone : mPhones) { for (Phone phone : mPhones) {
if (phone.getState() == Phone.State.ANSWERING) { if (phone.getState() == Phone.State.RINGING) {
return Phone.State.ANSWERING;
} else if (phone.getState() == Phone.State.RINGING) {
s = Phone.State.RINGING; s = Phone.State.RINGING;
} else if (phone.getState() == Phone.State.OFFHOOK) { } else if (phone.getState() == Phone.State.OFFHOOK) {
if (s == Phone.State.IDLE) s = Phone.State.OFFHOOK; if (s == Phone.State.IDLE) s = Phone.State.OFFHOOK;
@@ -358,19 +356,26 @@ public final class CallManager {
} }
/** /**
* @return the first answering call * unregister phone from CallManager
* @param phone
*/ */
public Call getFirstAnsweringCall() { public void unregisterPhone(Phone phone) {
for (Phone phone : mPhones) { if (phone != null && mPhones.contains(phone)) {
if (phone.getState() == Phone.State.ANSWERING) { mPhones.remove(phone);
return phone.getForegroundCall(); mRingingCalls.remove(phone.getRingingCall());
mBackgroundCalls.remove(phone.getBackgroundCall());
mForegroundCalls.remove(phone.getForegroundCall());
unregisterForPhoneStates(phone);
if (phone == mDefaultPhone) {
if (mPhones.isEmpty()) {
mDefaultPhone = null;
} else {
mDefaultPhone = mPhones.get(0);
}
} }
} }
return null;
} }
public void setAudioMode() { public void setAudioMode() {
Context context = getContext(); Context context = getContext();
if (context == null) return; if (context == null) return;
@@ -1359,7 +1364,7 @@ public final class CallManager {
*/ */
public Call getFirstActiveBgCall() { public Call getFirstActiveBgCall() {
for (Call call : mBackgroundCalls) { for (Call call : mBackgroundCalls) {
if (!call.isIdle()) { if (call.getState() != Call.State.IDLE) {
return call; return call;
} }
} }

View File

@@ -55,12 +55,10 @@ public interface Phone {
* <li>OFFHOOK = The phone is off hook. At least one call * <li>OFFHOOK = The phone is off hook. At least one call
* exists that is dialing, active or holding and no calls are * exists that is dialing, active or holding and no calls are
* ringing or waiting.</li> * ringing or waiting.</li>
* <li>ANSWERING = The incoming call is picked up but the
* call is not established yet.</li>
* </ul> * </ul>
*/ */
enum State { enum State {
IDLE, RINGING, OFFHOOK, ANSWERING; IDLE, RINGING, OFFHOOK;
}; };
/** /**

View File

@@ -143,23 +143,15 @@ public class SipPhone extends SipPhoneBase {
// in case the active/holding call disappeared and this // in case the active/holding call disappeared and this
// is no longer call waiting // is no longer call waiting
if (ringingCall.getState() == Call.State.INCOMING) { if ((ringingCall.getState() == Call.State.INCOMING) ||
(ringingCall.getState() == Call.State.WAITING)) {
Log.v(LOG_TAG, "acceptCall"); Log.v(LOG_TAG, "acceptCall");
// Always unmute when answering a new call // Always unmute when answering a new call
setMute(false); setMute(false);
// make ringingCall foreground ringingCall.acceptCall();
foregroundCall.switchWith(ringingCall);
foregroundCall.acceptCall();
} else if (ringingCall.getState() == Call.State.WAITING) {
setMute(false);
switchHoldingAndActive();
// make ringingCall foreground
foregroundCall.switchWith(ringingCall);
foregroundCall.acceptCall();
} else { } else {
throw new CallStateException("phone not ringing"); throw new CallStateException("phone not ringing");
} }
updatePhoneState();
} }
} }
@@ -482,8 +474,8 @@ public class SipPhone extends SipPhoneBase {
} }
void acceptCall() throws CallStateException { void acceptCall() throws CallStateException {
if (this != foregroundCall) { if (this != ringingCall) {
throw new CallStateException("acceptCall() in a non-fg call"); throw new CallStateException("acceptCall() in a non-ringing call");
} }
if (connections.size() != 1) { if (connections.size() != 1) {
throw new CallStateException("acceptCall() in a conf call"); throw new CallStateException("acceptCall() in a conf call");
@@ -646,6 +638,18 @@ public class SipPhone extends SipPhoneBase {
if (newState == Call.State.INCOMING) { if (newState == Call.State.INCOMING) {
setState(mOwner.getState()); // INCOMING or WAITING setState(mOwner.getState()); // INCOMING or WAITING
} else { } else {
if (mOwner == ringingCall) {
if (ringingCall.getState() == Call.State.WAITING) {
try {
switchHoldingAndActive();
} catch (CallStateException e) {
// disconnect the call.
onCallEnded(DisconnectCause.LOCAL);
return;
}
}
foregroundCall.switchWith(ringingCall);
}
if (newState == Call.State.ACTIVE) call.startAudio(); if (newState == Call.State.ACTIVE) call.startAudio();
setState(newState); setState(newState);
} }

View File

@@ -538,8 +538,6 @@ abstract class SipPhoneBase extends PhoneBase {
if (getRingingCall().isRinging()) { if (getRingingCall().isRinging()) {
state = State.RINGING; state = State.RINGING;
} else if (getForegroundCall().isRinging()) {
state = State.ANSWERING;
} else if (getForegroundCall().isIdle() } else if (getForegroundCall().isIdle()
&& getBackgroundCall().isIdle()) { && getBackgroundCall().isIdle()) {
state = State.IDLE; state = State.IDLE;