Ensure WFC international call check only happens for outgoing calls.
Add TelephonyConnection isOutgoingCall property.
Use property when checking if the call is an international call.
Test: Manual
Bug: 62162029
Change-Id: Ibade505eef29ee6fa2d6881f2a6377a4e67d57c6
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index 29ccc6c..ffa9dbc 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -65,7 +65,6 @@
* {@code True} if the CDMA connection should allow mute.
*/
private boolean mAllowMute;
- private final boolean mIsOutgoing;
// Queue of pending short-DTMF characters.
private final Queue<Character> mDtmfQueue = new LinkedList<>();
private final EmergencyTonePlayer mEmergencyTonePlayer;
@@ -80,10 +79,9 @@
boolean allowMute,
boolean isOutgoing,
String telecomCallId) {
- super(connection, telecomCallId);
+ super(connection, telecomCallId, isOutgoing);
mEmergencyTonePlayer = emergencyTonePlayer;
mAllowMute = allowMute;
- mIsOutgoing = isOutgoing;
mIsCallWaiting = connection != null && connection.getState() == Call.State.WAITING;
boolean isImsCall = getOriginalConnection() instanceof ImsPhoneConnection;
// Start call waiting timer for CDMA waiting call.
diff --git a/src/com/android/services/telephony/GsmConnection.java b/src/com/android/services/telephony/GsmConnection.java
index c480baa..ca547fa 100644
--- a/src/com/android/services/telephony/GsmConnection.java
+++ b/src/com/android/services/telephony/GsmConnection.java
@@ -22,8 +22,8 @@
* Manages a single phone call handled by GSM.
*/
final class GsmConnection extends TelephonyConnection {
- GsmConnection(Connection connection, String telecomCallId) {
- super(connection, telecomCallId);
+ GsmConnection(Connection connection, String telecomCallId, boolean isOutgoing) {
+ super(connection, telecomCallId, isOutgoing);
}
/**
@@ -36,7 +36,7 @@
@Override
public TelephonyConnection cloneConnection() {
GsmConnection gsmConnection = new GsmConnection(getOriginalConnection(),
- getTelecomCallId());
+ getTelecomCallId(), mIsOutgoing);
return gsmConnection;
}
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index c5a0896..603c3f4 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -879,7 +879,8 @@
if (mConferenceHost.getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
Log.i(this,"handleOriginalConnectionChange : SRVCC to GSM");
- GsmConnection c = new GsmConnection(originalConnection, getTelecomCallId());
+ GsmConnection c = new GsmConnection(originalConnection, getTelecomCallId(),
+ mConferenceHost.isOutgoingCall());
// This is a newly created conference connection as a result of SRVCC
c.setConferenceSupported(true);
c.addCapability(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN);
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 5ae1a26..785145b 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -484,13 +484,19 @@
private boolean mIsCdmaVoicePrivacyEnabled;
/**
+ * Indicates whether this call is an outgoing call.
+ */
+ protected final boolean mIsOutgoing;
+
+ /**
* Listeners to our TelephonyConnection specific callbacks
*/
private final Set<TelephonyConnectionListener> mTelephonyListeners = Collections.newSetFromMap(
new ConcurrentHashMap<TelephonyConnectionListener, Boolean>(8, 0.9f, 1));
protected TelephonyConnection(com.android.internal.telephony.Connection originalConnection,
- String callId) {
+ String callId, boolean isOutgoingCall) {
+ mIsOutgoing = isOutgoingCall;
setTelecomCallId(callId);
if (originalConnection != null) {
setOriginalConnection(originalConnection);
@@ -1513,6 +1519,13 @@
}
/**
+ * @return {@code true} if this is an outgoing call, {@code false} otherwise.
+ */
+ boolean isOutgoingCall() {
+ return mIsOutgoing;
+ }
+
+ /**
* Sets the current call audio quality. Used during rebuild of the properties
* to set or unset the {@link Connection#PROPERTY_HIGH_DEF_AUDIO} property.
*
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index d25cebe..1dfc550 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -963,7 +963,7 @@
TelephonyConnection returnConnection = null;
int phoneType = phone.getPhoneType();
if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
- returnConnection = new GsmConnection(originalConnection, telecomCallId);
+ returnConnection = new GsmConnection(originalConnection, telecomCallId, isOutgoing);
} else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
boolean allowsMute = allowsMute(phone);
returnConnection = new CdmaConnection(originalConnection, mEmergencyTonePlayer,
@@ -1250,12 +1250,18 @@
TelecomManager.TTY_MODE_OFF) != TelecomManager.TTY_MODE_OFF);
}
+ /**
+ * For outgoing dialed calls, potentially send a ConnectionEvent if the user is on WFC and is
+ * dialing an international number.
+ * @param telephonyConnection The connection.
+ */
private void maybeSendInternationalCallEvent(TelephonyConnection telephonyConnection) {
Phone phone = telephonyConnection.getPhone().getDefaultPhone();
if (phone instanceof GsmCdmaPhone) {
GsmCdmaPhone gsmCdmaPhone = (GsmCdmaPhone) phone;
- if (gsmCdmaPhone.isNotificationOfWfcCallRequired(
- telephonyConnection.getOriginalConnection().getOrigDialString())) {
+ if (telephonyConnection.isOutgoingCall() &&
+ gsmCdmaPhone.isNotificationOfWfcCallRequired(
+ telephonyConnection.getOriginalConnection().getOrigDialString())) {
// Send connection event to InCall UI to inform the user of the fact they
// are potentially placing an international call on WFC.
Log.i(this, "placeOutgoingConnection - sending international call on WFC " +
diff --git a/tests/src/com/android/services/telephony/MockTelephonyConnection.java b/tests/src/com/android/services/telephony/MockTelephonyConnection.java
index b2d6ed8..634cbb5 100644
--- a/tests/src/com/android/services/telephony/MockTelephonyConnection.java
+++ b/tests/src/com/android/services/telephony/MockTelephonyConnection.java
@@ -45,7 +45,7 @@
}
public MockTelephonyConnection() {
- super(null, null);
+ super(null, null, false);
MockitoAnnotations.initMocks(this);
// Set up mMockRadioConnection and mMockPhone to contain an active call