From ee9ec0928055307dc5d1f5c7509c301951a444a5 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Sat, 9 Aug 2014 18:45:36 -0700 Subject: Hookup StatusHints to call state label This CL hooks up StatusHints to the call state label. This is used by Hangouts to show WiFi calling and handoff status. This CL also fixes a bug where the callback number was not displayed for non-emergency numbers. Bug: 13333680 Change-Id: I012967a0ccbffe87f1a365e2e3537b2f1d832501 --- .../src/com/android/incallui/CallCardFragment.java | 8 +- .../com/android/incallui/CallCardPresenter.java | 97 +++++++++++----------- 2 files changed, 51 insertions(+), 54 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index cb89b8559..1b23b0127 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -512,12 +512,12 @@ public class CallCardFragment extends BaseFragment int callState = Call.State.IDLE; if (mPrimary != null) { callState = mPrimary.getState(); - - getUi().setCallState( - callState, - mPrimary.getVideoState(), - mPrimary.getSessionModificationState(), - mPrimary.getDisconnectCause(), - getConnectionLabel(), - getCallProviderIcon(mPrimary), - getGatewayNumber()); - - String currentNumber = getNumberFromHandle(mPrimary.getHandle()); - if (PhoneNumberUtils.isEmergencyNumber(currentNumber)) { - String callbackNumber = getSubscriptionNumber(); - setCallbackNumber(callbackNumber, true); - } + updatePrimaryCallState(); } else { getUi().setCallState( callState, @@ -272,11 +258,7 @@ public class CallCardPresenter extends Presenter @Override public void onDetailsChanged(Call call, android.telecomm.Call.Details details) { - getUi().setCallDetails(details); - - if (mPrimary != null) { - setCallbackNumberIfSet(details); - } + updatePrimaryCallState(); } private String getSubscriptionNumber() { @@ -295,45 +277,45 @@ public class CallCardPresenter extends Presenter return null; } - private void setCallbackNumberIfSet(android.telecomm.Call.Details details) { - String callbackNumber = null; - - String currentNumber = getNumberFromHandle(mPrimary.getHandle()); - boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber(currentNumber); + private void updatePrimaryCallState() { + if (getUi() != null && mPrimary != null) { + getUi().setCallState( + mPrimary.getState(), + mPrimary.getVideoState(), + mPrimary.getSessionModificationState(), + mPrimary.getDisconnectCause(), + getConnectionLabel(), + getConnectionIcon(), + getGatewayNumber()); + setCallbackNumber(); + } + } - StatusHints statusHints = details.getStatusHints(); - if (statusHints != null) { - Bundle extras = statusHints.getExtras(); - if (extras != null) { - callbackNumber = extras.getString( - TelecommManager.EXTRA_CALL_BACK_NUMBER, null); + private void setCallbackNumber() { + String callbackNumber = null; - if (isEmergencyCall) { - callbackNumber = getSubscriptionNumber(); + boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber( + getNumberFromHandle(mPrimary.getHandle())); + if (isEmergencyCall) { + callbackNumber = getSubscriptionNumber(); + } else { + StatusHints statusHints = mPrimary.getTelecommCall().getDetails().getStatusHints(); + if (statusHints != null) { + Bundle extras = statusHints.getExtras(); + if (extras != null) { + callbackNumber = extras.getString(TelecommManager.EXTRA_CALL_BACK_NUMBER); } - } else { - Log.d(this, "No extras; not updating callback number"); } - } else { - Log.d(this, "No status hints; not updating callback number"); - } - - setCallbackNumber(callbackNumber, isEmergencyCall); - } - - private void setCallbackNumber(String callbackNumber, boolean isEmergencyCall) { - if (TextUtils.isEmpty(callbackNumber)) { - Log.d(this, "No callback number; aborting"); - return; } - final TelephonyManager telephonyManager = + TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); String simNumber = telephonyManager.getLine1Number(); - if (!PhoneNumberUtils.compare(callbackNumber, simNumber) && !isEmergencyCall) { + if (PhoneNumberUtils.compare(callbackNumber, simNumber)) { Log.d(this, "Numbers are the same; not showing the callback number"); - return; + callbackNumber = null; } + getUi().setCallbackNumber(callbackNumber, isEmergencyCall); } @@ -600,6 +582,11 @@ public class CallCardPresenter extends Presenter * For example, "calling via [Account/Google Voice]" for outgoing calls. */ private String getConnectionLabel() { + StatusHints statusHints = mPrimary.getTelecommCall().getDetails().getStatusHints(); + if (statusHints != null && !TextUtils.isEmpty(statusHints.getLabel())) { + return statusHints.getLabel().toString(); + } + if (hasOutgoingGatewayCall() && getUi() != null) { // Return the label for the gateway app on outgoing calls. final PackageManager pm = mContext.getPackageManager(); @@ -615,6 +602,17 @@ public class CallCardPresenter extends Presenter return getCallProviderLabel(mPrimary); } + private Drawable getConnectionIcon() { + StatusHints statusHints = mPrimary.getTelecommCall().getDetails().getStatusHints(); + if (statusHints != null && statusHints.getIconId() != 0) { + Drawable icon = statusHints.getIcon(mContext); + if (icon != null) { + return icon; + } + } + return getCallProviderIcon(mPrimary); + } + private boolean hasOutgoingGatewayCall() { // We only display the gateway information while DIALING so return false for any othe // call state. @@ -704,7 +702,6 @@ public class CallCardPresenter extends Presenter void setPrimaryLabel(String label); void setEndCallButtonEnabled(boolean enabled); void setCallbackNumber(String number, boolean isEmergencyCalls); - void setCallDetails(android.telecomm.Call.Details details); void setPhotoVisible(boolean isVisible); void setProgressSpinnerVisible(boolean visible); } -- cgit v1.2.3