summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-12-17 17:46:34 -0800
committerYorke Lee <yorkelee@google.com>2014-12-18 09:51:08 -0800
commitcb5ce98130681ef07f513fd3f9c332b183b61772 (patch)
tree7520b8ccd3432aeb511f76fd9a98fe14a422c936 /InCallUI
parentf5ca18ec40748d4a73fd987ac526a9c40ccb0f77 (diff)
Show error dialog and end call for service not supported error
Add another condition for which InCallActivity is launched so that it can disconnect the call and show the error dialog. Slight refactor of code that checks if a call has valid accounts so that it can be shared. Bug: 18781230 Change-Id: I83a9c4ee30f2a80168f3244f4929f70aa46b9d83
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java26
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java52
2 files changed, 56 insertions, 22 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index 006936411..f059bd436 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -512,20 +512,10 @@ public class InCallActivity extends Activity {
intent.getBooleanExtra(SHOW_CIRCULAR_REVEAL_EXTRA, false);
mCallCardFragment.animateForNewOutgoingCall(touchPoint, showCircularReveal);
- /*
- * 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());
- }
+ // InCallActivity is responsible for disconnecting a new outgoing call if there
+ // is no way of making it (i.e. no valid call capable accounts)
+ if (InCallPresenter.isCallWithNoValidAccounts(call)) {
+ TelecomAdapter.getInstance().disconnectCall(call.getId());
}
dismissKeyguard(true);
@@ -569,14 +559,6 @@ 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 0004d4618..455f3d266 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Point;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.telecom.DisconnectCause;
@@ -29,6 +30,7 @@ import android.telecom.Phone;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.Surface;
import android.view.View;
@@ -60,6 +62,8 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener {
private static final String EXTRA_FIRST_TIME_SHOWN =
"com.android.incallui.intent.extra.FIRST_TIME_SHOWN";
+ private static final Bundle EMPTY_EXTRAS = new Bundle();
+
private static InCallPresenter sInCallPresenter;
/**
@@ -926,6 +930,17 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener {
showCallUi |= (InCallState.PENDING_OUTGOING == mInCallState
&& InCallState.INCALL == newState && !isActivityStarted());
+ // Another exception - InCallActivity is in charge of disconnecting a call with no
+ // valid accounts set. Bring the UI up if this is true for the current pending outgoing
+ // call so that:
+ // 1) The call can be disconnected correctly
+ // 2) The UI comes up and correctly displays the error dialog.
+ // TODO: Remove these special case conditions by making InCallPresenter a true state
+ // machine. Telecom should also be the component responsible for disconnecting a call
+ // with no valid accounts.
+ showCallUi |= InCallState.PENDING_OUTGOING == newState && mainUiNotVisible
+ && isCallWithNoValidAccounts(CallList.getInstance().getPendingOutgoingCall());
+
// The only time that we have an instance of mInCallActivity and it isn't started is
// when it is being destroyed. In that case, lets avoid bringing up another instance of
// the activity. When it is finally destroyed, we double check if we should bring it back
@@ -963,6 +978,43 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener {
}
/**
+ * Determines whether or not a call has no valid phone accounts that can be used to make the
+ * call with. Emergency calls do not require a phone account.
+ *
+ * @param call to check accounts for.
+ * @return {@code true} if the call has no call capable phone accounts set, {@code false} if
+ * the call contains a phone account that could be used to initiate it with, or is an emergency
+ * call.
+ */
+ public static boolean isCallWithNoValidAccounts(Call call) {
+ if (call != null && !isEmergencyCall(call)) {
+ Bundle extras = call.getTelecommCall().getDetails().getExtras();
+
+ if (extras == null) {
+ extras = EMPTY_EXTRAS;
+ }
+
+ final List<PhoneAccountHandle> phoneAccountHandles = extras
+ .getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS);
+
+ if ((call.getAccountHandle() == null &&
+ (phoneAccountHandles == null || phoneAccountHandles.isEmpty()))) {
+ Log.i(InCallPresenter.getInstance(), "No valid accounts for call " + call);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isEmergencyCall(Call call) {
+ final Uri handle = call.getHandle();
+ if (handle == null) {
+ return false;
+ }
+ return PhoneNumberUtils.isEmergencyNumber(handle.getSchemeSpecificPart());
+ }
+
+ /**
* Sets the DisconnectCause for a call that was disconnected because it was missing a
* PhoneAccount or PhoneAccounts to select from.
* @param call