Merge "Revert the ANSWERING state." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
708e42512a
@@ -238,9 +238,7 @@ public final class CallManager {
|
||||
Phone.State s = Phone.State.IDLE;
|
||||
|
||||
for (Phone phone : mPhones) {
|
||||
if (phone.getState() == Phone.State.ANSWERING) {
|
||||
return Phone.State.ANSWERING;
|
||||
} else if (phone.getState() == Phone.State.RINGING) {
|
||||
if (phone.getState() == Phone.State.RINGING) {
|
||||
s = Phone.State.RINGING;
|
||||
} else if (phone.getState() == 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() {
|
||||
for (Phone phone : mPhones) {
|
||||
if (phone.getState() == Phone.State.ANSWERING) {
|
||||
return phone.getForegroundCall();
|
||||
public void unregisterPhone(Phone phone) {
|
||||
if (phone != null && mPhones.contains(phone)) {
|
||||
mPhones.remove(phone);
|
||||
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() {
|
||||
Context context = getContext();
|
||||
if (context == null) return;
|
||||
@@ -1359,7 +1364,7 @@ public final class CallManager {
|
||||
*/
|
||||
public Call getFirstActiveBgCall() {
|
||||
for (Call call : mBackgroundCalls) {
|
||||
if (!call.isIdle()) {
|
||||
if (call.getState() != Call.State.IDLE) {
|
||||
return call;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,10 @@ public interface Phone {
|
||||
* <li>OFFHOOK = The phone is off hook. At least one call
|
||||
* exists that is dialing, active or holding and no calls are
|
||||
* ringing or waiting.</li>
|
||||
* <li>ANSWERING = The incoming call is picked up but the
|
||||
* call is not established yet.</li>
|
||||
* </ul>
|
||||
*/
|
||||
enum State {
|
||||
IDLE, RINGING, OFFHOOK, ANSWERING;
|
||||
IDLE, RINGING, OFFHOOK;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,23 +143,15 @@ public class SipPhone extends SipPhoneBase {
|
||||
// in case the active/holding call disappeared and this
|
||||
// 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");
|
||||
// Always unmute when answering a new call
|
||||
setMute(false);
|
||||
// make ringingCall foreground
|
||||
foregroundCall.switchWith(ringingCall);
|
||||
foregroundCall.acceptCall();
|
||||
} else if (ringingCall.getState() == Call.State.WAITING) {
|
||||
setMute(false);
|
||||
switchHoldingAndActive();
|
||||
// make ringingCall foreground
|
||||
foregroundCall.switchWith(ringingCall);
|
||||
foregroundCall.acceptCall();
|
||||
ringingCall.acceptCall();
|
||||
} else {
|
||||
throw new CallStateException("phone not ringing");
|
||||
}
|
||||
updatePhoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,8 +474,8 @@ public class SipPhone extends SipPhoneBase {
|
||||
}
|
||||
|
||||
void acceptCall() throws CallStateException {
|
||||
if (this != foregroundCall) {
|
||||
throw new CallStateException("acceptCall() in a non-fg call");
|
||||
if (this != ringingCall) {
|
||||
throw new CallStateException("acceptCall() in a non-ringing call");
|
||||
}
|
||||
if (connections.size() != 1) {
|
||||
throw new CallStateException("acceptCall() in a conf call");
|
||||
@@ -646,6 +638,18 @@ public class SipPhone extends SipPhoneBase {
|
||||
if (newState == Call.State.INCOMING) {
|
||||
setState(mOwner.getState()); // INCOMING or WAITING
|
||||
} 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();
|
||||
setState(newState);
|
||||
}
|
||||
|
||||
@@ -538,8 +538,6 @@ abstract class SipPhoneBase extends PhoneBase {
|
||||
|
||||
if (getRingingCall().isRinging()) {
|
||||
state = State.RINGING;
|
||||
} else if (getForegroundCall().isRinging()) {
|
||||
state = State.ANSWERING;
|
||||
} else if (getForegroundCall().isIdle()
|
||||
&& getBackgroundCall().isIdle()) {
|
||||
state = State.IDLE;
|
||||
|
||||
Reference in New Issue
Block a user