Merge "Call duration should be verbalized as hours, minutes, seconds." into lmp-mr1-dev
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 0bfcc80..5c67862 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -27,6 +27,7 @@
import android.os.Bundle;
import android.telecom.AudioState;
import android.view.ContextThemeWrapper;
+import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -152,6 +153,7 @@
int id = view.getId();
Log.d(this, "onClick(View " + view + ", id " + id + ")...");
+ boolean isClickHandled = true;
switch(id) {
case R.id.audioButton:
onAudioButtonClicked();
@@ -197,9 +199,16 @@
mOverflowPopup.show();
break;
default:
+ isClickHandled = false;
Log.wtf(this, "onClick: unexpected");
break;
}
+
+ if (isClickHandled) {
+ view.performHapticFeedback(
+ HapticFeedbackConstants.VIRTUAL_KEY,
+ HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
}
public void updateColors() {
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index 6f48a35..f75c33b 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -519,20 +519,10 @@
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 @@
}
}
- 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 5ad31b1..dc41d41 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -21,6 +21,7 @@
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.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 @@
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 @@
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 @@
}
/**
+ * 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
diff --git a/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java b/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java
index a5733de..fe008f3 100644
--- a/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java
+++ b/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java
@@ -402,7 +402,6 @@
case STATE_TRACKING:
mHandleDrawable.setAlpha(0.0f);
- showGlow(REVEAL_GLOW_DURATION , REVEAL_GLOW_DELAY, 1.0f, null);
break;
case STATE_SNAP: