diff options
author | Sailesh Nepal <sail@google.com> | 2014-08-09 18:45:36 -0700 |
---|---|---|
committer | Sailesh Nepal <sail@google.com> | 2014-08-12 09:58:57 -0700 |
commit | ee9ec0928055307dc5d1f5c7509c301951a444a5 (patch) | |
tree | 0d3971e297ce5a47f9664a5975f4e07c3bca9649 | |
parent | 5dcd1e938b790614cc9c397dcfab35344f3aa98e (diff) |
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
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 8 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 97 |
2 files changed, 51 insertions, 54 deletions
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 @@ -513,11 +513,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } @Override - public void setCallDetails(android.telecomm.Call.Details details) { - } - - @Override public void setCallbackNumber(String callbackNumber, boolean isEmergencyCall) { + if (mInCallMessageLabel == null) { + return; + } + if (TextUtils.isEmpty(callbackNumber)) { mInCallMessageLabel.setVisibility(View.GONE); return; diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 99d7f33f1..ce30f7a6e 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -232,21 +232,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> @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<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> * 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<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> 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); } |