From 479c50f6d4fac0fa44210c9bad4346f64dba3f1e Mon Sep 17 00:00:00 2001 From: Anders Kristensen Date: Thu, 27 Feb 2014 14:26:43 -0800 Subject: Remove duplicate call disconnect codes. The Android code base defines call disconnect codes in three places: - android.telephony.DisconnectCause - android.internal.telephony.Connection.DisconnectCause - com.android.services.telephony.common.Call.DisconnectCause This CL consolidates the code to use the integer codes from android.telephony.DisconnectCause everywhere. Change-Id: I84a3fd5182a51d07fc7d81076e4b2c15ff26c61c --- .../src/com/android/incallui/CallCardFragment.java | 43 ++++++++++++---------- .../com/android/incallui/CallCardPresenter.java | 5 ++- InCallUI/src/com/android/incallui/CallList.java | 11 +++--- .../src/com/android/incallui/InCallActivity.java | 18 +++++---- 4 files changed, 43 insertions(+), 34 deletions(-) (limited to 'InCallUI/src/com/android') diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 0d26b82cc..9b452cd98 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -22,6 +22,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.telephony.DisconnectCause; import android.text.TextUtils; import android.view.Gravity; import android.view.LayoutInflater; @@ -233,7 +234,7 @@ public class CallCardFragment extends BaseFragment ui.setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn, getGatewayLabel(), getGatewayNumber()); } else { - ui.setCallState(Call.State.IDLE, Call.DisconnectCause.UNKNOWN, false, null, null); + ui.setCallState(Call.State.IDLE, DisconnectCause.NOT_VALID, false, null, null); } } @@ -462,7 +463,7 @@ public class CallCardPresenter extends Presenter void setSecondary(boolean show, String name, boolean nameIsNumber, String label, Drawable photo, boolean isConference, boolean isGeneric); void setSecondaryImage(Drawable image); - void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn, + void setCallState(int state, int cause, boolean bluetoothOn, String gatewayLabel, String gatewayNumber); void setPrimaryCallElapsedTime(boolean show, String duration); void setPrimaryName(String name, boolean nameIsNumber); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index ba123b0c1..4c43db7bb 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -23,6 +23,7 @@ import com.google.common.base.Preconditions; import android.os.Handler; import android.os.Message; +import android.telephony.DisconnectCause; import com.android.services.telephony.common.Call; @@ -373,17 +374,17 @@ public class CallList { Preconditions.checkState(call.getState() == Call.State.DISCONNECTED); - final Call.DisconnectCause cause = call.getDisconnectCause(); + final int cause = call.getDisconnectCause(); final int delay; switch (cause) { - case LOCAL: + case DisconnectCause.LOCAL: delay = DISCONNECTED_CALL_SHORT_TIMEOUT_MS; break; - case NORMAL: + case DisconnectCause.NORMAL: delay = DISCONNECTED_CALL_MEDIUM_TIMEOUT_MS; break; - case INCOMING_REJECTED: - case INCOMING_MISSED: + case DisconnectCause.INCOMING_REJECTED: + case DisconnectCause.INCOMING_MISSED: // no delay for missed/rejected incoming calls delay = 0; break; diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 08a8f12d0..aa4a715ad 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -27,6 +27,7 @@ import android.content.DialogInterface.OnCancelListener; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; +import android.telephony.DisconnectCause; import android.view.KeyEvent; import android.view.View; import android.view.Window; @@ -432,7 +433,10 @@ public class InCallActivity extends Activity { return super.dispatchPopulateAccessibilityEvent(event); } - public void maybeShowErrorDialogOnDisconnect(Call.DisconnectCause cause) { + /** + * @param cause disconnect cause as defined in {@link DisconnectCause} + */ + public void maybeShowErrorDialogOnDisconnect(int cause) { Log.d(this, "maybeShowErrorDialogOnDisconnect"); if (!isFinishing()) { @@ -478,18 +482,18 @@ public class InCallActivity extends Activity { mDialog.show(); } - private int getResIdForDisconnectCause(Call.DisconnectCause cause) { + private int getResIdForDisconnectCause(int cause) { int resId = INVALID_RES_ID; - if (cause == Call.DisconnectCause.CALL_BARRED) { + if (cause == DisconnectCause.CALL_BARRED) { resId = R.string.callFailed_cb_enabled; - } else if (cause == Call.DisconnectCause.FDN_BLOCKED) { + } else if (cause == DisconnectCause.FDN_BLOCKED) { resId = R.string.callFailed_fdn_only; - } else if (cause == Call.DisconnectCause.CS_RESTRICTED) { + } else if (cause == DisconnectCause.CS_RESTRICTED) { resId = R.string.callFailed_dsac_restricted; - } else if (cause == Call.DisconnectCause.CS_RESTRICTED_EMERGENCY) { + } else if (cause == DisconnectCause.CS_RESTRICTED_EMERGENCY) { resId = R.string.callFailed_dsac_restricted_emergency; - } else if (cause == Call.DisconnectCause.CS_RESTRICTED_NORMAL) { + } else if (cause == DisconnectCause.CS_RESTRICTED_NORMAL) { resId = R.string.callFailed_dsac_restricted_normal; } -- cgit v1.2.3 From 2a4212c888f4d6f326cbea2934203307949b0f0b Mon Sep 17 00:00:00 2001 From: Anders Kristensen Date: Fri, 28 Mar 2014 14:39:13 -0700 Subject: Fix issue introduced by 5feee861: there is no longer an UNKNOWN DisconnectsCause. Change-Id: Id1796282d1948b43d28601664750ae8a78e78234 --- InCallUI/src/com/android/incallui/CallList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'InCallUI/src/com/android') diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index d4ad5bbe5..c16105803 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -313,7 +313,7 @@ public class CallList { state != Call.State.DISCONNECTED) { call.setState(Call.State.DISCONNECTED); - call.setDisconnectCause(DisconnectCause.UNKNOWN); + call.setDisconnectCause(DisconnectCause.NOT_VALID); updateCallInMap(call); } } -- cgit v1.2.3