Commit 126265d8 authored by Anthony Lee's avatar Anthony Lee Committed by Android (Google) Code Review
Browse files

Merge "Ensure call subject is hidden if disabled for carrier." into mnc-dr-dev

parents 7bfb8135 07f5e7af
......@@ -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) {
......
......@@ -921,7 +921,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
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();
}
/**
......
......@@ -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();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment