summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-09-16 22:03:19 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-16 22:03:19 +0000
commit9d48c5467b431c82791ed545cf440f253527e33e (patch)
treef02d4d0dcc0742109bacefce9d1ad0ff4d06e18c /InCallUI
parentad852cc5428a6522b057fa4e2fe095f6d2ab5819 (diff)
parent46d1605c5a6997e074a677ccf12d142601112483 (diff)
am b4374c7e: am 833b300b: Merge "Update InCallUi to use telecomm DisconnectCause." into lmp-dev
* commit 'b4374c7e7ca6525a8beb23ed62802e05becab582': Update InCallUi to use telecomm DisconnectCause.
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/res/values/strings.xml40
-rw-r--r--InCallUI/src/com/android/incallui/Call.java14
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java109
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java10
-rw-r--r--InCallUI/src/com/android/incallui/CallList.java16
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java79
6 files changed, 47 insertions, 221 deletions
diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml
index 06602cb2c..8e8a8e2bd 100644
--- a/InCallUI/res/values/strings.xml
+++ b/InCallUI/res/values/strings.xml
@@ -36,44 +36,6 @@
<!-- Incoming call screen, string when called from a pay phone -->
<string name="payphone">Pay phone</string>
- <!-- In-call screen: call failure reason (busy) -->
- <string name="callFailed_userBusy">Line busy</string>
- <!-- In-call screen: call failure reason (network congestion) -->
- <string name="callFailed_congestion">Network busy</string>
- <!-- In-call screen: call failure reason (client timed out) -->
- <string name="callFailed_timedOut">No response, timed out</string>
- <!-- In-call screen: call failure reason (server unreachable) -->
- <string name="callFailed_server_unreachable">Server unreachable</string>
- <!-- In-call screen: call failure reason (peer unreachable) -->
- <string name="callFailed_number_unreachable">Number unreachable</string>
- <!-- In-call screen: call failure reason (incorrect username or password) -->
- <string name="callFailed_invalid_credentials">Incorrect username or password</string>
- <!-- In-call screen: call failure reason (calling from out of network is not allowed) -->
- <string name="callFailed_out_of_network">Called from out-of-network</string>
- <!-- In-call screen: call failure reason (server error) -->
- <string name="callFailed_server_error">Server error. Try again later.</string>
- <!-- In-call screen: call failure reason (no signal) -->
- <string name="callFailed_noSignal">No signal</string>
- <!-- In-call screen: call failure reason (GSM ACM limit exceeded) -->
- <string name="callFailed_limitExceeded">ACM limit exceeded</string>
- <!-- In-call screen: call failure reason (radio is off) -->
- <string name="callFailed_powerOff">Radio off</string>
- <!-- In-call screen: call failure reason (SIM error) -->
- <string name="callFailed_simError">No SIM or SIM error</string>
- <!-- In-call screen: call failure reason (out of service) -->
- <string name="callFailed_outOfService">Mobile network not available</string>
- <!-- In-call screen: call failure reason (call denied because of current FDN setting) -->
- <string name="callFailed_fdn_only">Outgoing calls are restricted by FDN.</string>
- <!-- In-call screen: call failure reason (call denied because call barring is on) -->
- <string name="callFailed_cb_enabled">You can\'t make outgoing calls while call barring is on.</string>
- <!-- In-call screen: call failure reason (call denied because domain specific access control is on) -->
- <string name="callFailed_dsac_restricted">All calls are restricted by access control.</string>
- <!-- In-call screen: call failure reason (Emergency call denied because domain specific access control is on)-->
- <string name="callFailed_dsac_restricted_emergency">Emergency calls are restricted by access control.</string>
- <!-- In-call screen: call failure reason (Normal call denied because domain specific access control is on)-->
- <string name="callFailed_dsac_restricted_normal">Normal calls are restricted by access control.</string>
- <!-- In-call screen: call failure reason (Dialed number doesn't exist) -->
- <string name="callFailed_unobtainable_number">Invalid number</string>
<!-- In-call screen: status label for a conference call -->
<string name="confCall">Conference call</string>
<!-- In-call screen: call lost dialog text -->
@@ -265,8 +227,6 @@
<string name="incall_error_supp_service_reject">Unable to reject call.</string>
<!-- In-call screen: message displayed in an error dialog -->
<string name="incall_error_supp_service_hangup">Unable to release call(s).</string>
- <!-- In-call screen: message displayed in an error dialog -->
- <string name="incall_error_missing_voicemail_number">Voicemail number unknown.</string>
<!-- In-call screen: "call type" indication for a SIP call [CHAR LIMIT=30] -->
<string name="incall_call_type_label_sip">SIP call</string>
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index fe3feea55..d21da7888 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -21,12 +21,12 @@ import com.android.contacts.common.CallUtil;
import android.content.Context;
import android.net.Uri;
import android.telecom.CallProperties;
+import android.telecom.DisconnectCause;
import android.telecom.PhoneCapabilities;
import android.telecom.GatewayInfo;
import android.telecom.InCallService.VideoCall;
import android.telecom.PhoneAccountHandle;
import android.telecom.VideoProfile;
-import android.telephony.DisconnectCause;
import java.util.ArrayList;
import java.util.List;
@@ -172,7 +172,7 @@ public final class Call {
private final android.telecom.Call mTelecommCall;
private final String mId;
private int mState = State.INVALID;
- private int mDisconnectCause;
+ private DisconnectCause mDisconnectCause;
private int mSessionModificationState;
private final List<String> mChildCallIds = new ArrayList<>();
@@ -202,7 +202,7 @@ public final class Call {
private void updateFromTelecommCall() {
Log.d(this, "updateFromTelecommCall: " + mTelecommCall);
setState(translateState(mTelecommCall.getState()));
- setDisconnectCause(mTelecommCall.getDetails().getDisconnectCauseCode());
+ setDisconnectCause(mTelecommCall.getDetails().getDisconnectCause());
if (mTelecommCall.getVideoCall() != null) {
if (mVideoCallListener == null) {
@@ -281,16 +281,16 @@ public final class Call {
return getTelecommCall().getDetails().getCallerDisplayName();
}
- /** Returns call disconnect cause; values are defined in {@link DisconnectCause}. */
- public int getDisconnectCause() {
+ /** Returns call disconnect cause, defined by {@link DisconnectCause}. */
+ public DisconnectCause getDisconnectCause() {
if (mState == State.DISCONNECTED || mState == State.IDLE) {
return mDisconnectCause;
}
- return DisconnectCause.NOT_DISCONNECTED;
+ return new DisconnectCause(DisconnectCause.UNKNOWN);
}
- public void setDisconnectCause(int disconnectCause) {
+ public void setDisconnectCause(DisconnectCause disconnectCause) {
mDisconnectCause = disconnectCause;
}
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 19c1882f2..7848c4e2c 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -27,8 +27,8 @@ import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.telecom.DisconnectCause;
import android.telecom.VideoProfile;
-import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.Display;
@@ -494,19 +494,23 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
} else {
mSecondaryCallInfo.setVisibility(View.GONE);
}
-
-
}
@Override
- public void setCallState(int state, int videoState, int sessionModificationState, int cause,
- String connectionLabel, Drawable connectionIcon, String gatewayNumber) {
+ public void setCallState(
+ int state,
+ int videoState,
+ int sessionModificationState,
+ DisconnectCause disconnectCause,
+ String connectionLabel,
+ Drawable connectionIcon,
+ String gatewayNumber) {
boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber);
- String callStateLabel = getCallStateLabelFromState(
- state, videoState, sessionModificationState, cause, connectionLabel, isGatewayCall);
+ CharSequence callStateLabel = getCallStateLabelFromState(state, videoState,
+ sessionModificationState, disconnectCause, connectionLabel, isGatewayCall);
Log.v(this, "setCallState " + callStateLabel);
- Log.v(this, "DisconnectCause " + DisconnectCause.toString(cause));
+ Log.v(this, "DisconnectCause " + disconnectCause.toString());
Log.v(this, "gateway " + connectionLabel + gatewayNumber);
if (TextUtils.equals(callStateLabel, mCallStateLabel.getText())) {
@@ -646,11 +650,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
* 3. Incoming calls will only display "Incoming via..." for accounts.
* 4. Video calls, and session modification states (eg. requesting video).
*/
- private String getCallStateLabelFromState(int state, int videoState,
- int sessionModificationState, int disconnectCause, String label,
+ private CharSequence getCallStateLabelFromState(int state, int videoState,
+ int sessionModificationState, DisconnectCause disconnectCause, String label,
boolean isGatewayCall) {
final Context context = getView().getContext();
- String callStateLabel = null; // Label to display as part of the call banner
+ CharSequence callStateLabel = null; // Label to display as part of the call banner
boolean isSpecialCall = label != null;
boolean isAccount = isSpecialCall && !isGatewayCall;
@@ -708,7 +712,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
callStateLabel = context.getString(R.string.card_title_hanging_up);
break;
case Call.State.DISCONNECTED:
- callStateLabel = getCallFailedString(disconnectCause);
+ callStateLabel = disconnectCause.getLabel();
+ if (TextUtils.isEmpty(callStateLabel)) {
+ callStateLabel = context.getString(R.string.card_title_call_ended);
+ }
break;
case Call.State.CONFERENCED:
callStateLabel = context.getString(R.string.card_title_conf_call);
@@ -719,84 +726,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
return callStateLabel;
}
- /**
- * Maps the disconnect cause to a resource string.
- *
- * @param cause disconnect cause as defined in {@link DisconnectCause}
- */
- private String getCallFailedString(int disconnectCause) {
- int resID = R.string.card_title_call_ended;
-
- // TODO: The card *title* should probably be "Call ended" in all
- // cases, but if the DisconnectCause was an error condition we should
- // probably also display the specific failure reason somewhere...
-
- switch (disconnectCause) {
- case DisconnectCause.BUSY:
- resID = R.string.callFailed_userBusy;
- break;
-
- case DisconnectCause.CONGESTION:
- resID = R.string.callFailed_congestion;
- break;
-
- case DisconnectCause.TIMED_OUT:
- resID = R.string.callFailed_timedOut;
- break;
-
- case DisconnectCause.SERVER_UNREACHABLE:
- resID = R.string.callFailed_server_unreachable;
- break;
-
- case DisconnectCause.NUMBER_UNREACHABLE:
- resID = R.string.callFailed_number_unreachable;
- break;
-
- case DisconnectCause.INVALID_CREDENTIALS:
- resID = R.string.callFailed_invalid_credentials;
- break;
-
- case DisconnectCause.SERVER_ERROR:
- resID = R.string.callFailed_server_error;
- break;
-
- case DisconnectCause.OUT_OF_NETWORK:
- resID = R.string.callFailed_out_of_network;
- break;
-
- case DisconnectCause.LOST_SIGNAL:
- case DisconnectCause.CDMA_DROP:
- resID = R.string.callFailed_noSignal;
- break;
-
- case DisconnectCause.LIMIT_EXCEEDED:
- resID = R.string.callFailed_limitExceeded;
- break;
-
- case DisconnectCause.POWER_OFF:
- resID = R.string.callFailed_powerOff;
- break;
-
- case DisconnectCause.ICC_ERROR:
- resID = R.string.callFailed_simError;
- break;
-
- case DisconnectCause.OUT_OF_SERVICE:
- resID = R.string.callFailed_outOfService;
- break;
-
- case DisconnectCause.INVALID_NUMBER:
- case DisconnectCause.UNOBTAINABLE_NUMBER:
- resID = R.string.callFailed_unobtainable_number;
- break;
-
- default:
- resID = R.string.card_title_call_ended;
- break;
- }
- return this.getView().getContext().getString(resID);
- }
-
private void showAndInitializeSecondaryCallInfo(boolean hasProvider) {
mSecondaryCallInfo.setVisibility(View.VISIBLE);
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 3baa07267..3e793ce45 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -24,13 +24,14 @@ import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
+import android.telecom.DisconnectCause;
import android.telecom.PhoneCapabilities;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.StatusHints;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
-import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -237,7 +238,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
callState,
VideoProfile.VideoState.AUDIO_ONLY,
Call.SessionModificationState.NO_REQUEST,
- DisconnectCause.NOT_VALID,
+ new DisconnectCause(DisconnectCause.UNKNOWN),
null,
null,
null);
@@ -665,8 +666,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
String providerLabel, Drawable providerIcon, boolean isConference,
boolean canManageConference);
- void setCallState(int state, int videoState, int sessionModificationState, int cause,
- String connectionLabel, Drawable connectionIcon, String gatewayNumber);
+ void setCallState(int state, int videoState, int sessionModificationState,
+ DisconnectCause disconnectCause, String connectionLabel,
+ Drawable connectionIcon, String gatewayNumber);
void setPrimaryCallElapsedTime(boolean show, String duration);
void setPrimaryName(String name, boolean nameIsNumber);
void setPrimaryImage(Drawable image);
diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java
index ea0448705..ed52071e9 100644
--- a/InCallUI/src/com/android/incallui/CallList.java
+++ b/InCallUI/src/com/android/incallui/CallList.java
@@ -22,8 +22,8 @@ import com.google.common.base.Preconditions;
import android.os.Handler;
import android.os.Message;
+import android.telecom.DisconnectCause;
import android.telecom.Phone;
-import android.telephony.DisconnectCause;
import java.util.Collections;
import java.util.HashMap;
@@ -84,7 +84,7 @@ public class CallList implements InCallPhoneListener {
if (mCallByTelecommCall.containsKey(telecommCall)) {
Call call = mCallByTelecommCall.get(telecommCall);
call.setState(Call.State.DISCONNECTED);
- call.setDisconnectCause(DisconnectCause.NOT_VALID);
+ call.setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN));
if (updateCallInMap(call)) {
Log.w(this, "Removing call not previously disconnected " + call.getId());
}
@@ -364,7 +364,7 @@ public class CallList implements InCallPhoneListener {
state != Call.State.DISCONNECTED) {
call.setState(Call.State.DISCONNECTED);
- call.setDisconnectCause(DisconnectCause.NOT_VALID);
+ call.setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN));
updateCallInMap(call);
}
}
@@ -442,18 +442,18 @@ public class CallList implements InCallPhoneListener {
Preconditions.checkState(call.getState() == Call.State.DISCONNECTED);
- final int cause = call.getDisconnectCause();
+ final int cause = call.getDisconnectCause().getCode();
final int delay;
switch (cause) {
case DisconnectCause.LOCAL:
delay = DISCONNECTED_CALL_SHORT_TIMEOUT_MS;
break;
- case DisconnectCause.NORMAL:
+ case DisconnectCause.REMOTE:
delay = DISCONNECTED_CALL_MEDIUM_TIMEOUT_MS;
break;
- case DisconnectCause.INCOMING_REJECTED:
- case DisconnectCause.INCOMING_MISSED:
- case DisconnectCause.OUTGOING_CANCELED:
+ case DisconnectCause.REJECTED:
+ case DisconnectCause.MISSED:
+ case DisconnectCause.CANCELED:
// no delay for missed/rejected incoming calls and canceled outgoing calls.
delay = 0;
break;
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index f4f8ca602..b511df467 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -29,7 +29,7 @@ import android.content.res.Configuration;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
-import android.telephony.DisconnectCause;
+import android.telecom.DisconnectCause;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.animation.Animation;
@@ -56,8 +56,6 @@ public class InCallActivity extends Activity {
public static final String DIALPAD_TEXT_EXTRA = "InCallActivity.dialpad_text";
public static final String NEW_OUTGOING_CALL = "InCallActivity.new_outgoing_call";
- private static final int INVALID_RES_ID = -1;
-
private CallButtonFragment mCallButtonFragment;
private CallCardFragment mCallCardFragment;
private AnswerFragment mAnswerFragment;
@@ -635,17 +633,13 @@ public class InCallActivity extends Activity {
return super.dispatchPopulateAccessibilityEvent(event);
}
- /**
- * @param cause disconnect cause as defined in {@link DisconnectCause}
- */
- public void maybeShowErrorDialogOnDisconnect(int cause) {
+ public void maybeShowErrorDialogOnDisconnect(DisconnectCause disconnectCause) {
Log.d(this, "maybeShowErrorDialogOnDisconnect");
- if (!isFinishing()) {
- final int resId = getResIdForDisconnectCause(cause);
- if (resId != INVALID_RES_ID) {
- showErrorDialog(resId);
- }
+ if (!isFinishing() && !TextUtils.isEmpty(disconnectCause.getDescription())
+ && (disconnectCause.getCode() == DisconnectCause.ERROR ||
+ disconnectCause.getCode() == DisconnectCause.RESTRICTED)) {
+ showErrorDialog(disconnectCause.getDescription());
}
}
@@ -660,8 +654,7 @@ public class InCallActivity extends Activity {
/**
* Utility function to bring up a generic "error" dialog.
*/
- private void showErrorDialog(int resId) {
- final CharSequence msg = getResources().getText(resId);
+ private void showErrorDialog(CharSequence msg) {
Log.i(this, "Show Dialog: " + msg);
dismissPendingDialogs();
@@ -684,64 +677,6 @@ public class InCallActivity extends Activity {
mDialog.show();
}
- private int getResIdForDisconnectCause(int cause) {
- switch (cause) {
- case DisconnectCause.CALL_BARRED:
- return R.string.callFailed_cb_enabled;
- case DisconnectCause.FDN_BLOCKED:
- return R.string.callFailed_fdn_only;
- case DisconnectCause.CS_RESTRICTED:
- return R.string.callFailed_dsac_restricted;
- case DisconnectCause.CS_RESTRICTED_EMERGENCY:
- return R.string.callFailed_dsac_restricted_emergency;
- case DisconnectCause.CS_RESTRICTED_NORMAL:
- return R.string.callFailed_dsac_restricted_normal;
- case DisconnectCause.OUTGOING_FAILURE:
- // We couldn't successfully place the call; there was some
- // failure in the telephony layer.
- // TODO: Need UI spec for this failure case; for now just
- // show a generic error.
- return R.string.incall_error_call_failed;
- case DisconnectCause.OUTGOING_CANCELED:
- // We don't want to show any dialog for the canceled case since the call was
- // either canceled by the user explicitly (end-call button pushed immediately)
- // or some other app canceled the call and immediately issued a new CALL to
- // replace it.
- return INVALID_RES_ID;
- case DisconnectCause.POWER_OFF:
- // Radio is explictly powered off, presumably because the
- // device is in airplane mode.
- //
- // TODO: For now this UI is ultra-simple: we simply display
- // a message telling the user to turn off airplane mode.
- // But it might be nicer for the dialog to offer the option
- // to turn the radio on right there (and automatically retry
- // the call once network registration is complete.)
- return R.string.incall_error_power_off;
- case DisconnectCause.EMERGENCY_ONLY:
- // Only emergency numbers are allowed, but we tried to dial
- // a non-emergency number.
- return R.string.incall_error_emergency_only;
- case DisconnectCause.OUT_OF_SERVICE:
- // No network connection.
- return R.string.incall_error_out_of_service;
- case DisconnectCause.NO_PHONE_NUMBER_SUPPLIED:
- // The supplied Intent didn't contain a valid phone number.
- // (This is rare and should only ever happen with broken
- // 3rd-party apps.) For now just show a generic error.
- return R.string.incall_error_no_phone_number_supplied;
- case DisconnectCause.VOICEMAIL_NUMBER_MISSING:
- // TODO: Need to bring up the "Missing Voicemail Number" dialog, which
- // will ultimately take us to the Call Settings.
- return R.string.incall_error_missing_voicemail_number;
- case DisconnectCause.DIALED_MMI:
- // TODO: Implement MMI; see MMIDialogActivity in packages/services/Telephony
- return INVALID_RES_ID;
- default:
- return INVALID_RES_ID;
- }
- }
-
private void onDialogDismissed() {
mDialog = null;
InCallPresenter.getInstance().onDismissDialog();