From 07f5e7af74ae5dd6f75b14ca25fe39cb7183f397 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Mon, 14 Sep 2015 10:41:03 -0700 Subject: Ensure call subject is hidden if disabled for carrier. Even if the carrier config is set to disable call subjects for a carrier, the RIL will still send any incoming call subjects to the InCall UI. We cannot suppress this lower down as the RIL is using the same extra to report caller id presentation reasons. Bug: 22779583 Change-Id: Ic349408014a47e25d62100886ea59b73e4f76709 --- src/com/android/incallui/Call.java | 32 +++++++++++++++++++++++++ src/com/android/incallui/CallCardPresenter.java | 3 ++- src/com/android/incallui/StatusBarNotifier.java | 3 ++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/com/android/incallui/Call.java b/src/com/android/incallui/Call.java index f08653e6..01205ff1 100644 --- a/src/com/android/incallui/Call.java +++ b/src/com/android/incallui/Call.java @@ -30,6 +30,7 @@ import android.telecom.GatewayInfo; import android.telecom.InCallService.VideoCall; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; +import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; @@ -262,6 +263,13 @@ public class Call { private String mChildNumber; private String mLastForwardedNumber; private String mCallSubject; + private PhoneAccountHandle mPhoneAccountHandle; + + /** + * Indicates whether the phone account associated with this call supports specifying a call + * subject. + */ + private boolean mIsCallSubjectSupported; /** * Used only to create mock calls for testing @@ -373,6 +381,22 @@ public class Call { mHandle = newHandle; updateEmergencyCallState(); } + + // If the phone account handle of the call is set, cache capability bit indicating whether + // the phone account supports call subjects. + PhoneAccountHandle newPhoneAccountHandle = mTelecommCall.getDetails().getAccountHandle(); + if (!Objects.equals(mPhoneAccountHandle, newPhoneAccountHandle)) { + mPhoneAccountHandle = newPhoneAccountHandle; + + if (mPhoneAccountHandle != null) { + TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); + PhoneAccount phoneAccount = mgr.getPhoneAccount(mPhoneAccountHandle); + if (phoneAccount != null) { + mIsCallSubjectSupported = phoneAccount.hasCapabilities( + PhoneAccount.CAPABILITY_CALL_SUBJECT); + } + } + } } private static int translateState(int state) { @@ -477,6 +501,14 @@ public class Call { return mCallSubject; } + /** + * @return {@code true} if the call's phone account supports call subjects, {@code false} + * otherwise. + */ + public boolean isCallSubjectSupported() { + return mIsCallSubjectSupported; + } + /** Returns call disconnect cause, defined by {@link DisconnectCause}. */ public DisconnectCause getDisconnectCause() { if (mState == State.DISCONNECTED || mState == State.IDLE) { diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java index 6c2b6b6c..0cc5da1c 100644 --- a/src/com/android/incallui/CallCardPresenter.java +++ b/src/com/android/incallui/CallCardPresenter.java @@ -921,7 +921,8 @@ public class CallCardPresenter extends Presenter boolean isIncomingOrWaiting = mPrimary.getState() == Call.State.INCOMING || mPrimary.getState() == Call.State.CALL_WAITING; return isIncomingOrWaiting && !TextUtils.isEmpty(call.getCallSubject()) && - call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED; + call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED && + call.isCallSubjectSupported(); } /** diff --git a/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java index 3a3cb376..3f862a24 100644 --- a/src/com/android/incallui/StatusBarNotifier.java +++ b/src/com/android/incallui/StatusBarNotifier.java @@ -427,7 +427,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, call.getState() == Call.State.CALL_WAITING; if (isIncomingOrWaiting && !TextUtils.isEmpty(call.getCallSubject()) && - call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED) { + call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED && + call.isCallSubjectSupported()) { return call.getCallSubject(); } -- cgit v1.2.3