summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-12-19 19:15:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-12-19 19:15:14 +0000
commitb16bc3bb33bb17e0b05e82f085ba4df405d5e201 (patch)
tree00eabf60f2109e3af3254142892a828410e7446d
parenta6e15ec2ca6b134c412d50c2a2032e7f547b20e3 (diff)
parentcb5ce98130681ef07f513fd3f9c332b183b61772 (diff)
Merge "Show error dialog and end call for service not supported error" into lmp-mr1-dev
-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 6f48a359b..f75c33b23 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -519,20 +519,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);
@@ -576,14 +566,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 5ad31b17a..dc41d416e 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;
/**
@@ -931,6 +935,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
@@ -968,6 +983,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