Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Use telephony-common - DO NOT MERGE
Browse files Browse the repository at this point in the history
Change-Id: I1710418850040fc20afff4795ee4a85027203fc9
  • Loading branch information
Wink Saville authored and Jean-Baptiste Queru committed Jul 17, 2012
1 parent b24309d commit 086249c
Show file tree
Hide file tree
Showing 28 changed files with 269 additions and 238 deletions.
1 change: 1 addition & 0 deletions Android.mk
Expand Up @@ -20,6 +20,7 @@ include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += \
src/com/android/phone/EventLogTags.logtags \
Expand Down
29 changes: 15 additions & 14 deletions src/com/android/phone/BluetoothHandsfree.java
Expand Up @@ -53,6 +53,7 @@
import com.android.internal.telephony.Call;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.CallManager;

Expand Down Expand Up @@ -126,7 +127,7 @@ public class BluetoothHandsfree {

private final BluetoothPhoneState mBluetoothPhoneState; // for CIND and CIEV updates
private final BluetoothAtPhonebook mPhonebook;
private Phone.State mPhoneState = Phone.State.IDLE;
private PhoneConstants.State mPhoneState = PhoneConstants.State.IDLE;
CdmaPhoneCallState.PhoneCallState mCdmaThreeWayCallState =
CdmaPhoneCallState.PhoneCallState.IDLE;

Expand Down Expand Up @@ -1019,10 +1020,10 @@ private synchronized void handlePreciseCallStateChange(boolean sendUpdate,

// This function will get called when the Precise Call State
// {@link Call.State} changes. Hence, we might get this update
// even if the {@link Phone.state} is same as before.
// even if the {@link PhoneConstants.state} is same as before.
// Check for the same.

Phone.State newState = mCM.getState();
PhoneConstants.State newState = mCM.getState();
if (newState != mPhoneState) {
mPhoneState = newState;
switch (mPhoneState) {
Expand All @@ -1049,7 +1050,7 @@ private synchronized void handlePreciseCallStateChange(boolean sendUpdate,
// +BLND: OK response
// There is a special case handling of the same case
// for CDMA below
if (mCM.getFgPhone().getPhoneType() == Phone.PHONE_TYPE_GSM) {
if (mCM.getFgPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
callStarted();
}
break;
Expand Down Expand Up @@ -1131,7 +1132,7 @@ private synchronized void handlePreciseCallStateChange(boolean sendUpdate,
}
}

if (mCM.getDefaultPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA) {
if (mCM.getDefaultPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
PhoneApp app = PhoneApp.getInstance();
if (app.cdmaPhoneCallState != null) {
CdmaPhoneCallState.PhoneCallState currCdmaThreeWayCallState =
Expand Down Expand Up @@ -1194,7 +1195,7 @@ private synchronized void handlePreciseCallStateChange(boolean sendUpdate,

boolean callsSwitched;

if (mCM.getDefaultPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA &&
if (mCM.getDefaultPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA &&
mCdmaThreeWayCallState == CdmaPhoneCallState.PhoneCallState.CONF_CALL) {
callsSwitched = mCdmaCallsSwapped;
} else {
Expand Down Expand Up @@ -2321,9 +2322,9 @@ public AtCommandResult handleActionCommand() {
result.addResponse(args);
return result;
}
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
return cdmaGetClccResult();
} else if (phoneType == Phone.PHONE_TYPE_GSM) {
} else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
return gsmGetClccResult();
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
Expand Down Expand Up @@ -2353,7 +2354,7 @@ public AtCommandResult handleSetCommand(Object[] args) {
return new AtCommandResult(AtCommandResult.ERROR);
}
} else if (args[0].equals(1)) {
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
if (ringingCall.isRinging()) {
// Hangup the active call and then answer call waiting call.
if (VDBG) log("CHLD:1 Callwaiting Answer call");
Expand All @@ -2366,7 +2367,7 @@ public AtCommandResult handleSetCommand(Object[] args) {
PhoneUtils.hangup(PhoneApp.getInstance().mCM);
}
return new AtCommandResult(AtCommandResult.OK);
} else if (phoneType == Phone.PHONE_TYPE_GSM) {
} else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
// Hangup active call, answer held call
if (PhoneUtils.answerAndEndActive(
PhoneApp.getInstance().mCM, ringingCall)) {
Expand All @@ -2379,7 +2380,7 @@ public AtCommandResult handleSetCommand(Object[] args) {
}
} else if (args[0].equals(2)) {
sendURC("OK");
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
// For CDMA, the way we switch to a new incoming call is by
// calling PhoneUtils.answerCall(). switchAndHoldActive() won't
// properly update the call state within telephony.
Expand All @@ -2399,15 +2400,15 @@ public AtCommandResult handleSetCommand(Object[] args) {
// Toggle the second callers active state flag
cdmaSwapSecondCallState();
}
} else if (phoneType == Phone.PHONE_TYPE_GSM) {
} else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
PhoneUtils.switchHoldingAndActive(backgroundCall);
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
}
return new AtCommandResult(AtCommandResult.UNSOLICITED);
} else if (args[0].equals(3)) {
sendURC("OK");
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
CdmaPhoneCallState.PhoneCallState state =
PhoneApp.getInstance().cdmaPhoneCallState.getCurrentCallState();
// For CDMA, we need to check if the call is in THRWAY_ACTIVE state
Expand All @@ -2419,7 +2420,7 @@ public AtCommandResult handleSetCommand(Object[] args) {
// This can happen when CONF_CALL was entered from a Call Waiting
mBluetoothPhoneState.updateCallHeld();
}
} else if (phoneType == Phone.PHONE_TYPE_GSM) {
} else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
if (mCM.hasActiveFgCall() && mCM.hasActiveBgCall()) {
PhoneUtils.mergeCalls();
}
Expand Down
61 changes: 32 additions & 29 deletions src/com/android/phone/CallCard.java
Expand Up @@ -47,6 +47,7 @@
import com.android.internal.telephony.CallerInfoAsyncQuery;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;

import java.util.List;

Expand Down Expand Up @@ -249,7 +250,7 @@ protected void onFinishInflate() {

// Update the onscreen UI based on the current state of the phone.

Phone.State state = cm.getState(); // IDLE, RINGING, or OFFHOOK
PhoneConstants.State state = cm.getState(); // IDLE, RINGING, or OFFHOOK
Call ringingCall = cm.getFirstActiveRingingCall();
Call fgCall = cm.getActiveFgCall();
Call bgCall = cm.getFirstActiveBgCall();
Expand Down Expand Up @@ -312,8 +313,8 @@ protected void onFinishInflate() {
* Updates the overall size and positioning of mCallInfoContainer and
* the "Call info" blocks, based on the phone state.
*/
private void updateCallInfoLayout(Phone.State state) {
boolean ringing = (state == Phone.State.RINGING);
private void updateCallInfoLayout(PhoneConstants.State state) {
boolean ringing = (state == PhoneConstants.State.RINGING);
if (DBG) log("updateCallInfoLayout()... ringing = " + ringing);

// Based on the current state, update the overall
Expand Down Expand Up @@ -361,7 +362,7 @@ private void updateForegroundCall(CallManager cm) {
Phone phone = fgCall.getPhone();

int phoneType = phone.getPhoneType();
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
if ((mApplication.cdmaPhoneCallState.getCurrentCallState()
== CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE)
&& mApplication.cdmaPhoneCallState.IsThreeWayCallOrigStateDialing()) {
Expand All @@ -371,8 +372,8 @@ private void updateForegroundCall(CallManager cm) {
// we need to clean up the background call area.
displaySecondaryCallStatus(cm, bgCall);
}
} else if ((phoneType == Phone.PHONE_TYPE_GSM)
|| (phoneType == Phone.PHONE_TYPE_SIP)) {
} else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
|| (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
displaySecondaryCallStatus(cm, bgCall);
}
}
Expand Down Expand Up @@ -523,10 +524,10 @@ private void displayMainCallStatus(CallManager cm, Call call) {
// has only one connection.)
Connection conn = null;
int phoneType = call.getPhone().getPhoneType();
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
conn = call.getLatestConnection();
} else if ((phoneType == Phone.PHONE_TYPE_GSM)
|| (phoneType == Phone.PHONE_TYPE_SIP)) {
} else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
|| (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
conn = call.getEarliestConnection();
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
Expand All @@ -539,7 +540,8 @@ private void displayMainCallStatus(CallManager cm, Call call) {
// with the current implementation of getCallerInfo and
// updateDisplayForPerson.
CallerInfo info = PhoneUtils.getCallerInfo(getContext(), null /* conn */);
updateDisplayForPerson(info, Connection.PRESENTATION_ALLOWED, false, call, conn);
updateDisplayForPerson(info, PhoneConstants.PRESENTATION_ALLOWED, false, call,
conn);
} else {
if (DBG) log(" - CONN: " + conn + ", state = " + conn.getState());
int presentation = conn.getNumberPresentation();
Expand All @@ -557,7 +559,7 @@ private void displayMainCallStatus(CallManager cm, Call call) {

// Adding a check to see if the update was caused due to a Phone number update
// or CNAP update. If so then we need to start a new query
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
Object obj = conn.getUserData();
String updatedNumber = conn.getAddress();
String updatedCnapName = conn.getCnapName();
Expand Down Expand Up @@ -660,18 +662,18 @@ public void onQueryComplete(int token, Object cookie, CallerInfo ci) {
Call call = (Call) cookie;
Connection conn = null;
int phoneType = call.getPhone().getPhoneType();
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
conn = call.getLatestConnection();
} else if ((phoneType == Phone.PHONE_TYPE_GSM)
|| (phoneType == Phone.PHONE_TYPE_SIP)) {
} else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
|| (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
conn = call.getEarliestConnection();
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
}
PhoneUtils.CallerInfoToken cit =
PhoneUtils.startGetCallerInfo(getContext(), conn, this, null);

int presentation = Connection.PRESENTATION_ALLOWED;
int presentation = PhoneConstants.PRESENTATION_ALLOWED;
if (conn != null) presentation = conn.getNumberPresentation();
if (DBG) log("- onQueryComplete: presentation=" + presentation
+ ", contactExists=" + ci.contactExists);
Expand All @@ -680,7 +682,7 @@ public void onQueryComplete(int token, Object cookie, CallerInfo ci) {
// CallerInfo (for CNAP). Therefore if ci.contactExists then use the ci passed in.
// Otherwise, regenerate the CIT from the Connection and use the CallerInfo from there.
if (ci.contactExists) {
updateDisplayForPerson(ci, Connection.PRESENTATION_ALLOWED, false, call, conn);
updateDisplayForPerson(ci, PhoneConstants.PRESENTATION_ALLOWED, false, call, conn);
} else {
updateDisplayForPerson(cit.currentInfo, presentation, false, call, conn);
}
Expand Down Expand Up @@ -802,7 +804,7 @@ private void updateCallStateWidgets(Call call) {

// Check a couple of other special cases (these are all CDMA-specific).

if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
if ((state == Call.State.ACTIVE)
&& mApplication.cdmaPhoneCallState.IsThreeWayCallOrigStateDialing()) {
// Display "Dialing" while dialing a 3Way call, even
Expand Down Expand Up @@ -991,7 +993,7 @@ private void displaySecondaryCallStatus(CallManager cm, Call call) {
// CDMA: This is because in CDMA when the user originates the second call,
// although the Foreground call state is still ACTIVE in reality the network
// put the first call on hold.
if (mApplication.phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
if (mApplication.phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
showSecondaryCallInfo();

List<Connection> connections = call.getConnections();
Expand All @@ -1018,7 +1020,7 @@ private void displaySecondaryCallStatus(CallManager cm, Call call) {
String name = PhoneUtils.getCompactNameFromCallerInfo(info, getContext());
boolean forceGenericPhoto = false;
if (info != null && info.numberPresentation !=
Connection.PRESENTATION_ALLOWED) {
PhoneConstants.PRESENTATION_ALLOWED) {
name = PhoneUtils.getPresentationString(
getContext(), info.numberPresentation);
forceGenericPhoto = true;
Expand Down Expand Up @@ -1233,7 +1235,7 @@ private void updateDisplayForPerson(CallerInfo info,
// (or potentially some other default based on the presentation.)
displayName = PhoneUtils.getPresentationString(getContext(), presentation);
if (DBG) log(" ==> no name *or* number! displayName = " + displayName);
} else if (presentation != Connection.PRESENTATION_ALLOWED) {
} else if (presentation != PhoneConstants.PRESENTATION_ALLOWED) {
// This case should never happen since the network should never send a phone #
// AND a restricted presentation. However we leave it here in case of weird
// network behavior
Expand Down Expand Up @@ -1270,7 +1272,7 @@ private void updateDisplayForPerson(CallerInfo info,
} else {
// We do have a valid "name" in the CallerInfo. Display that
// in the "name" slot, and the phone number in the "number" slot.
if (presentation != Connection.PRESENTATION_ALLOWED) {
if (presentation != PhoneConstants.PRESENTATION_ALLOWED) {
// This case should never happen since the network should never send a name
// AND a restricted presentation. However we leave it here in case of weird
// network behavior
Expand Down Expand Up @@ -1384,7 +1386,7 @@ private void updateDisplayForConference(Call call) {
if (DBG) log("updateDisplayForConference()...");

int phoneType = call.getPhone().getPhoneType();
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
// This state corresponds to both 3-Way merged call and
// Call Waiting accepted call.
// In this case we display the UI in a "generic" state, with
Expand All @@ -1393,8 +1395,8 @@ private void updateDisplayForConference(Call call) {
// which caller party he is talking to.
showImage(mPhoto, R.drawable.picture_dialing);
mName.setText(R.string.card_title_in_call);
} else if ((phoneType == Phone.PHONE_TYPE_GSM)
|| (phoneType == Phone.PHONE_TYPE_SIP)) {
} else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
|| (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
// Normal GSM (or possibly SIP?) conference call.
// Display the "conference call" image as the contact photo.
// TODO: Better visual treatment for contact photos in a
Expand Down Expand Up @@ -1490,10 +1492,10 @@ private void updatePhotoForCallState(Call call) {
{
Connection conn = null;
int phoneType = call.getPhone().getPhoneType();
if (phoneType == Phone.PHONE_TYPE_CDMA) {
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
conn = call.getLatestConnection();
} else if ((phoneType == Phone.PHONE_TYPE_GSM)
|| (phoneType == Phone.PHONE_TYPE_SIP)) {
} else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
|| (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
conn = call.getEarliestConnection();
} else {
throw new IllegalStateException("Unexpected phone type: " + phoneType);
Expand Down Expand Up @@ -1629,8 +1631,9 @@ private String getECMCardTitle(Context context, Phone phone) {
* and/or icon to be displayed here.)
*/
private void updateCallTypeLabel(Call call) {
int phoneType = (call != null) ? call.getPhone().getPhoneType() : Phone.PHONE_TYPE_NONE;
if (phoneType == Phone.PHONE_TYPE_SIP) {
int phoneType = (call != null) ? call.getPhone().getPhoneType() :
PhoneConstants.PHONE_TYPE_NONE;
if (phoneType == PhoneConstants.PHONE_TYPE_SIP) {
mCallTypeLabel.setVisibility(View.VISIBLE);
mCallTypeLabel.setText(R.string.incall_call_type_label_sip);
mCallTypeLabel.setTextColor(mTextColorCallTypeSip);
Expand Down

0 comments on commit 086249c

Please sign in to comment.