diff options
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 48 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallPresenter.java | 34 |
2 files changed, 75 insertions, 7 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 2941e1e8d..2fcfda549 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -30,7 +30,9 @@ import android.graphics.Point; import android.net.Uri; import android.os.Bundle; import android.telecom.DisconnectCause; +import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; +import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.view.MenuItem; import android.view.animation.Animation; @@ -472,6 +474,20 @@ public class InCallActivity extends Activity { if (intent.getBooleanExtra(NEW_OUTGOING_CALL, false)) { intent.removeExtra(NEW_OUTGOING_CALL); + Call call = CallList.getInstance().getOutgoingCall(); + if (call == null) { + call = CallList.getInstance().getPendingOutgoingCall(); + } + + Bundle extras = null; + if (call != null) { + extras = call.getTelecommCall().getDetails().getExtras(); + } + if (extras == null) { + // Initialize the extras bundle to avoid NPE + extras = new Bundle(); + } + Point touchPoint = null; if (TouchPointManager.getInstance().hasValidPoint()) { @@ -479,17 +495,27 @@ public class InCallActivity extends Activity { touchPoint = TouchPointManager.getInstance().getPoint(); } else { // Otherwise retrieve the touch point from the call intent - Call call = CallList.getInstance().getOutgoingCall(); - if (call == null) { - call = CallList.getInstance().getPendingOutgoingCall(); - } if (call != null) { - Bundle extras = call.getTelecommCall().getDetails().getExtras(); - touchPoint = (Point) (extras == null ? - null : extras.getParcelable(TouchPointManager.TOUCH_POINT)); + touchPoint = (Point) extras.getParcelable(TouchPointManager.TOUCH_POINT); } } mCallCardFragment.animateForNewOutgoingCall(touchPoint); + + /* + * If both a phone account handle and a list of phone accounts to choose from are + * missing, then disconnect the call because there is no way to place an outgoing + * call. + * The exception is emergency calls, which may be waiting for the ConnectionService + * to set the PhoneAccount during the PENDING_OUTGOING state. + */ + if (call != null && !isEmergencyCall(call)) { + final List<PhoneAccountHandle> phoneAccountHandles = extras + .getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS); + if (call.getAccountHandle() == null && + (phoneAccountHandles == null || phoneAccountHandles.isEmpty())) { + TelecomAdapter.getInstance().disconnectCall(call.getId()); + } + } } Call pendingAccountSelectionCall = CallList.getInstance().getWaitingForAccountCall(); @@ -516,6 +542,14 @@ public class InCallActivity extends Activity { } } + private boolean isEmergencyCall(Call call) { + final Uri handle = call.getHandle(); + if (handle == null) { + return false; + } + return PhoneNumberUtils.isEmergencyNumber(handle.getSchemeSpecificPart()); + } + private void relaunchedFromDialer(boolean showDialpad) { mShowDialpadRequested = showDialpad; mAnimateDialpadOnShow = true; diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index c7a512266..a51aa9169 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -21,6 +21,9 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.os.Bundle; +import android.telecom.DisconnectCause; +import android.telecom.PhoneAccount; import android.telecom.PhoneCapabilities; import android.telecom.Phone; import android.telecom.PhoneAccountHandle; @@ -742,6 +745,9 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { private void maybeShowErrorDialogOnDisconnect(Call call) { // For newly disconnected calls, we may want to show a dialog on specific error conditions if (isActivityStarted() && call.getState() == Call.State.DISCONNECTED) { + if (call.getAccountHandle() == null && !call.isConferenceCall()) { + setDisconnectCauseForMissingAccounts(call); + } mInCallActivity.maybeShowErrorDialogOnDisconnect(call.getDisconnectCause()); } } @@ -857,6 +863,34 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { return newState; } + /** + * Sets the DisconnectCause for a call that was disconnected because it was missing a + * PhoneAccount or PhoneAccounts to select from. + * @param call + */ + private void setDisconnectCauseForMissingAccounts(Call call) { + android.telecom.Call telecomCall = call.getTelecommCall(); + + Bundle extras = telecomCall.getDetails().getExtras(); + // Initialize the extras bundle to avoid NPE + if (extras == null) { + extras = new Bundle(); + } + + final List<PhoneAccountHandle> phoneAccountHandles = extras.getParcelableArrayList( + android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS); + + if (phoneAccountHandles == null || phoneAccountHandles.isEmpty()) { + String scheme = telecomCall.getDetails().getHandle().getScheme(); + final String errorMsg = PhoneAccount.SCHEME_TEL.equals(scheme) ? + mContext.getString(R.string.callFailed_simError) : + mContext.getString(R.string.incall_error_supp_service_unknown); + DisconnectCause disconnectCause = + new DisconnectCause(DisconnectCause.ERROR, null, errorMsg, errorMsg); + call.setDisconnectCause(disconnectCause); + } + } + private boolean startUi(InCallState inCallState) { boolean isCallWaiting = mCallList.getActiveCall() != null && mCallList.getIncomingCall() != null; |