diff options
Diffstat (limited to 'InCallUI/src/com/android')
-rw-r--r-- | InCallUI/src/com/android/incallui/Call.java | 14 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 109 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 10 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallList.java | 16 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 79 |
5 files changed, 47 insertions, 181 deletions
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 90a9d0645..7b21665e1 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; @@ -485,19 +485,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())) { @@ -637,11 +641,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; @@ -699,7 +703,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); @@ -710,84 +717,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 ef7b4acc1..3cbba7d47 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -22,13 +22,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; @@ -234,7 +235,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); @@ -654,8 +655,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(); |