Merge "Remove unused Telephony files" into klp-dev
diff --git a/common/src/com/android/services/telephony/common/Call.java b/common/src/com/android/services/telephony/common/Call.java
index f5cc904..4a74114 100644
--- a/common/src/com/android/services/telephony/common/Call.java
+++ b/common/src/com/android/services/telephony/common/Call.java
@@ -47,10 +47,11 @@
public static final int INCOMING = 3; /* A normal incoming phone call */
public static final int CALL_WAITING = 4; /* Incoming call while another is active */
public static final int DIALING = 5; /* An outgoing call during dial phase */
- public static final int ONHOLD = 6; /* An active phone call placed on hold */
- public static final int DISCONNECTING = 7; /* A call is being ended. */
- public static final int DISCONNECTED = 8; /* State after a call disconnects */
- public static final int CONFERENCED = 9; /* Call part of a conference call */
+ public static final int REDIALING = 6; /* Subsequent dialing attempt after a failure */
+ public static final int ONHOLD = 7; /* An active phone call placed on hold */
+ public static final int DISCONNECTING = 8; /* A call is being ended. */
+ public static final int DISCONNECTED = 9; /* State after a call disconnects */
+ public static final int CONFERENCED = 10; /* Call part of a conference call */
public static boolean isConnected(int state) {
switch(state) {
@@ -58,6 +59,7 @@
case INCOMING:
case CALL_WAITING:
case DIALING:
+ case REDIALING:
case ONHOLD:
case CONFERENCED:
return true;
@@ -65,11 +67,17 @@
}
return false;
}
+
+ public static boolean isDialing(int state) {
+ return state == DIALING || state == REDIALING;
+ }
}
/**
* Defines a set of capabilities that a call can have as a bit mask.
* TODO: Should some of these be capabilities of the Phone instead of the call?
+ * TODO: This is starting to be a mix of capabilities and call properties. Capabilities
+ * and properties should be separated.
*/
public static class Capabilities {
public static final int HOLD = 0x00000001; /* has ability to hold the call */
@@ -139,6 +147,7 @@
.put(Call.State.ACTIVE, "ACTIVE")
.put(Call.State.CALL_WAITING, "CALL_WAITING")
.put(Call.State.DIALING, "DIALING")
+ .put(Call.State.REDIALING, "REDIALING")
.put(Call.State.IDLE, "IDLE")
.put(Call.State.INCOMING, "INCOMING")
.put(Call.State.ONHOLD, "ONHOLD")
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 1b05214..18b77ef 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -297,7 +297,8 @@
// always have an in call ui.
unbind();
- // TODO(klp): hang up all calls.
+ // We were disconnected from the UI. End all calls.
+ PhoneUtils.hangupAllCalls(PhoneGlobals.getInstance().getCallManager());
}
}
}
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 02f0809..23f442a 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -117,6 +117,8 @@
case CallStateMonitor.PHONE_DISCONNECT:
onDisconnect((Connection) ((AsyncResult) msg.obj).result);
break;
+ case CallStateMonitor.PHONE_UNKNOWN_CONNECTION_APPEARED:
+ // fall through
case CallStateMonitor.PHONE_STATE_CHANGED:
onPhoneStateChanged((AsyncResult) msg.obj);
break;
@@ -223,6 +225,7 @@
state == Call.State.CALL_WAITING ||
state == Call.State.CONFERENCED ||
state == Call.State.DIALING ||
+ state == Call.State.REDIALING ||
state == Call.State.INCOMING ||
state == Call.State.ONHOLD ||
state == Call.State.DISCONNECTING) {
@@ -241,8 +244,7 @@
HashMap<Connection, Call> map) {
for (Call call : map.values()) {
final int state = call.getState();
- if (state == Call.State.ACTIVE ||
- state == Call.State.DIALING) {
+ if (state == Call.State.ACTIVE || Call.State.isDialing(state)) {
return true;
}
}
@@ -475,7 +477,7 @@
// for the call, if available, and set it.
final RawGatewayInfo info = mCallGatewayManager.getGatewayInfo(connection);
- if (newState == Call.State.DIALING) {
+ if (Call.State.isDialing(newState)) {
if (!info.isEmpty()) {
call.setGatewayNumber(info.getFormattedGatewayNumber());
call.setGatewayPackage(info.packageName);
@@ -690,13 +692,15 @@
private int translateStateFromTelephony(Connection connection, boolean isForConference) {
+ com.android.internal.telephony.Call.State connState = connection.getState();
+
// For the "fake" outgoing CDMA call, we need to always treat it as an outgoing call.
if (mCdmaOutgoingConnection == connection) {
- return State.DIALING;
+ connState = com.android.internal.telephony.Call.State.DIALING;
}
int retval = State.IDLE;
- switch (connection.getState()) {
+ switch (connState) {
case ACTIVE:
retval = State.ACTIVE;
break;
@@ -705,7 +709,11 @@
break;
case DIALING:
case ALERTING:
- retval = State.DIALING;
+ if (PhoneGlobals.getInstance().notifier.getIsCdmaRedialCall()) {
+ retval = State.REDIALING;
+ } else {
+ retval = State.DIALING;
+ }
break;
case WAITING:
retval = State.CALL_WAITING;
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 9655371..c9ad397 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -641,12 +641,9 @@
PhoneConstants.State state = mCM.getState();
if (state == PhoneConstants.State.OFFHOOK) {
- // basically do onPhoneStateChanged + display the incoming call UI
- onPhoneStateChanged(r);
+ if (DBG) log("unknown connection appeared...");
- if (DBG) log("- showing incoming call (unknown connection appeared)...");
- final Connection c = (Connection) r.result;
- ringAndNotifyOfIncomingCall(c);
+ onPhoneStateChanged(r);
}
}
@@ -1097,8 +1094,11 @@
if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) {
// TODO: (Moto): The contact reference data may need to be stored and use
// here when redialing a call. For now, pass in NULL as the URI parameter.
- PhoneUtils.placeCall(mApplication, phone, number, null, false);
- mIsCdmaRedialCall = true;
+ final int status =
+ PhoneUtils.placeCall(mApplication, phone, number, null, false);
+ if (status != PhoneUtils.CALL_STATUS_FAILED) {
+ mIsCdmaRedialCall = true;
+ }
} else {
mIsCdmaRedialCall = false;
}
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 42c73ae..26bfc73 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -166,7 +166,7 @@
lp.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
// When no proximity sensor is available, use a shorter timeout.
- // TODO(klp): Do we enable this for non proximity devices any more?
+ // TODO: Do we enable this for non proximity devices any more?
// lp.userActivityTimeout = USER_ACTIVITY_TIMEOUT_WHEN_NO_PROX_SENSOR;
getWindow().setAttributes(lp);
diff --git a/src/com/android/phone/InCallScreenShowActivation.java b/src/com/android/phone/InCallScreenShowActivation.java
index 15abb11..8542ae9 100644
--- a/src/com/android/phone/InCallScreenShowActivation.java
+++ b/src/com/android/phone/InCallScreenShowActivation.java
@@ -78,7 +78,7 @@
// On voice-capable devices, we perform CDMA provisioning in
// "interactive" mode by directly launching the InCallScreen.
// boolean interactiveMode = PhoneGlobals.sVoiceCapable;
- // TODO(klp): Renable interactive mode for device provisioning.
+ // TODO: Renable interactive mode for device provisioning.
boolean interactiveMode = false;
Log.d(LOG_TAG, "ACTION_PERFORM_CDMA_PROVISIONING (interactiveMode = "
+ interactiveMode + ")...");
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 6744d33..5474a62 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -651,6 +651,10 @@
return callModeler;
}
+ /* package */ CallManager getCallManager() {
+ return mCM;
+ }
+
/**
* Returns an Intent that can be used to go to the "Call log"
* UI (aka CallLogActivity) in the Contacts app.
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 6e8abfd..e4c9a72 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -326,6 +326,28 @@
}
/**
+ * Hangs up all active calls.
+ */
+ static void hangupAllCalls(CallManager cm) {
+ final Call ringing = cm.getFirstActiveRingingCall();
+ final Call fg = cm.getActiveFgCall();
+ final Call bg = cm.getFirstActiveBgCall();
+
+ // We go in reverse order, BG->FG->RINGING because hanging up a ringing call or an active
+ // call can move a bg call to a fg call which would force us to loop over each call
+ // several times. This ordering works best to ensure we dont have any more calls.
+ if (bg != null && !bg.isIdle()) {
+ hangup(bg);
+ }
+ if (fg != null && !fg.isIdle()) {
+ hangup(fg);
+ }
+ if (ringing != null && !ringing.isIdle()) {
+ hangupRingingCall(fg);
+ }
+ }
+
+ /**
* Smart "hang up" helper method which hangs up exactly one connection,
* based on the current Phone state, as follows:
* <ul>
@@ -727,6 +749,12 @@
info.phoneNumber = number;
connection.setUserData(info);
}
+
+ // Always set mute to off when we are dialing an emergency number
+ if (isEmergencyCall) {
+ setMute(false);
+ }
+
setAudioMode();
if (DBG) log("about to activate speaker");
@@ -1935,6 +1963,11 @@
static void setMute(boolean muted) {
CallManager cm = PhoneGlobals.getInstance().mCM;
+ // Emergency calls never get muted.
+ if (isInEmergencyCall(cm)) {
+ muted = false;
+ }
+
// make the call to mute the audio
setMuteInternal(cm.getFgPhone(), muted);
@@ -1948,6 +1981,16 @@
}
}
+ static boolean isInEmergencyCall(CallManager cm) {
+ for (Connection cn : cm.getActiveFgCall().getConnections()) {
+ if (PhoneNumberUtils.isLocalEmergencyNumber(cn.getAddress(),
+ PhoneGlobals.getInstance())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Internally used muting function.
*/