Merge changes from topics "cp_rcs_uce_setting", "ims_uce_system"
* changes:
Add default implementations for RcsUceAdapter methods
Implement Get/Set UCE property from subinfo database
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index dd000ce..f5f5c66 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -540,7 +540,7 @@
if (mConferenceHost == null) {
return;
}
- mConferenceHost.performReject();
+ mConferenceHost.performReject(android.telecom.Call.REJECT_REASON_DECLINED);
}
/**
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index fdf302c..919d3b2 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -1009,7 +1009,7 @@
* @param handle The {@link PhoneAccountHandle}.
* @return {@code True} if merging calls is supported.
*/
- public boolean isMergeCallSupported(PhoneAccountHandle handle) {
+ boolean isMergeCallSupported(PhoneAccountHandle handle) {
synchronized (mAccountsLock) {
for (AccountEntry entry : mAccounts) {
if (entry.getPhoneAccountHandle().equals(handle)) {
@@ -1027,7 +1027,7 @@
* @param handle The {@link PhoneAccountHandle}.
* @return {@code True} if video conferencing is supported.
*/
- public boolean isVideoConferencingSupported(PhoneAccountHandle handle) {
+ boolean isVideoConferencingSupported(PhoneAccountHandle handle) {
synchronized (mAccountsLock) {
for (AccountEntry entry : mAccounts) {
if (entry.getPhoneAccountHandle().equals(handle)) {
@@ -1045,7 +1045,7 @@
* @param handle The {@link PhoneAccountHandle}.
* @return {@code True} if merging of wifi calls is allowed when VoWIFI is disabled.
*/
- public boolean isMergeOfWifiCallsAllowedWhenVoWifiOff(final PhoneAccountHandle handle) {
+ boolean isMergeOfWifiCallsAllowedWhenVoWifiOff(final PhoneAccountHandle handle) {
synchronized (mAccountsLock) {
Optional<AccountEntry> result = mAccounts.stream().filter(
entry -> entry.getPhoneAccountHandle().equals(handle)).findFirst();
@@ -1065,7 +1065,7 @@
* @param handle The {@link PhoneAccountHandle}.
* @return {@code True} if merging IMS calls is supported.
*/
- public boolean isMergeImsCallSupported(PhoneAccountHandle handle) {
+ boolean isMergeImsCallSupported(PhoneAccountHandle handle) {
synchronized (mAccountsLock) {
for (AccountEntry entry : mAccounts) {
if (entry.getPhoneAccountHandle().equals(handle)) {
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 95f4a04..2f5e2a6 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -113,6 +113,7 @@
private static final int MSG_SET_CALL_RADIO_TECH = 18;
private static final int MSG_ON_CONNECTION_EVENT = 19;
private static final int MSG_REDIAL_CONNECTION_CHANGED = 20;
+ private static final int MSG_REJECT = 21;
private List<Uri> mParticipants;
private boolean mIsAdhocConferenceCall;
@@ -273,6 +274,10 @@
int cause = (int) msg.obj;
hangup(cause);
break;
+ case MSG_REJECT:
+ int rejectReason = (int) msg.obj;
+ reject(rejectReason);
+ break;
case MSG_SET_CALL_RADIO_TECH:
int vrat = (int) msg.obj;
@@ -926,13 +931,18 @@
@Override
public void onReject() {
- performReject();
+ performReject(android.telecom.Call.REJECT_REASON_DECLINED);
}
- public void performReject() {
+ @Override
+ public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
+ performReject(rejectReason);
+ }
+
+ public void performReject(int rejectReason) {
Log.v(this, "performReject");
if (isValidRingingCall()) {
- mHandler.obtainMessage(MSG_HANGUP, android.telephony.DisconnectCause.INCOMING_REJECTED)
+ mHandler.obtainMessage(MSG_REJECT, rejectReason)
.sendToTarget();
}
super.onReject();
@@ -1678,6 +1688,46 @@
}
}
+ protected void reject(@android.telecom.Call.RejectReason int rejectReason) {
+ if (mOriginalConnection != null) {
+ mHangupDisconnectCause = android.telephony.DisconnectCause.INCOMING_REJECTED;
+ try {
+ // Hanging up a ringing call requires that we invoke call.hangup() as opposed to
+ // connection.hangup(). Without this change, the party originating the call
+ // will not get sent to voicemail if the user opts to reject the call.
+ if (isValidRingingCall()) {
+ Call call = getCall();
+ if (call != null) {
+ call.hangup(rejectReason);
+ } else {
+ Log.w(this, "Attempting to hangup a connection without backing call.");
+ }
+ } else {
+ // We still prefer to call connection.hangup() for non-ringing calls
+ // in order to support hanging-up specific calls within a conference call.
+ // If we invoked call.hangup() while in a conference, we would end up
+ // hanging up the entire conference call instead of the specific connection.
+ mOriginalConnection.hangup();
+ }
+ } catch (CallStateException e) {
+ Log.e(this, e, "Call to Connection.hangup failed with exception");
+ }
+ } else {
+ if (getState() == STATE_DISCONNECTED) {
+ Log.i(this, "hangup called on an already disconnected call!");
+ close();
+ } else {
+ // There are a few cases where mOriginalConnection has not been set yet. For
+ // example, when the radio has to be turned on to make an emergency call,
+ // mOriginalConnection could not be set for many seconds.
+ setTelephonyConnectionDisconnected(DisconnectCauseUtil.toTelecomDisconnectCause(
+ android.telephony.DisconnectCause.LOCAL,
+ "Local Disconnect before connection established."));
+ close();
+ }
+ }
+ }
+
com.android.internal.telephony.Connection getOriginalConnection() {
return mOriginalConnection;
}
@@ -2465,8 +2515,8 @@
PhoneAccountHandle phoneAccountHandle = isIms ? PhoneUtils
.makePstnPhoneAccountHandle(phone.getDefaultPhone())
: PhoneUtils.makePstnPhoneAccountHandle(phone);
- TelecomAccountRegistry telecomAccountRegistry = getTelecomAccountRegistry(
- getPhone().getContext());
+ TelecomAccountRegistry telecomAccountRegistry = TelecomAccountRegistry
+ .getInstance(getPhone().getContext());
boolean isConferencingSupported = telecomAccountRegistry
.isMergeCallSupported(phoneAccountHandle);
boolean isImsConferencingSupported = telecomAccountRegistry
@@ -2475,17 +2525,6 @@
.isVideoConferencingSupported(phoneAccountHandle);
boolean isMergeOfWifiCallsAllowedWhenVoWifiOff = telecomAccountRegistry
.isMergeOfWifiCallsAllowedWhenVoWifiOff(phoneAccountHandle);
- ImsCall imsCall = ((ImsPhoneConnection) getOriginalConnection()).getImsCall();
- CarrierConfigManager configManager = (CarrierConfigManager) phone.getContext()
- .getSystemService(Context.CARRIER_CONFIG_SERVICE);
- boolean downGradedVideoCall = false;
- if (configManager != null) {
- PersistableBundle config = configManager.getConfigForSubId(phone.getSubId());
- if (config != null) {
- downGradedVideoCall = config.getBoolean(
- CarrierConfigManager.KEY_TREAT_DOWNGRADED_VIDEO_CALLS_AS_VIDEO_CALLS_BOOL);
- }
- }
Log.v(this, "refreshConferenceSupported : isConfSupp=%b, isImsConfSupp=%b, " +
"isVidConfSupp=%b, isMergeOfWifiAllowed=%b, " +
@@ -2506,12 +2545,6 @@
} else if (isVideoCall && !mIsCarrierVideoConferencingSupported) {
isConferenceSupported = false;
Log.d(this, "refreshConferenceSupported = false; video conf not supported.");
- } else if ((imsCall.wasVideoCall() && downGradedVideoCall)
- && !mIsCarrierVideoConferencingSupported) {
- isConferenceSupported = false;
- Log.d(this,
- "refreshConferenceSupported = false;"
- + " video conf not supported for downgraded audio call.");
} else if (!isMergeOfWifiCallsAllowedWhenVoWifiOff && isWifi() && !isVoWifiEnabled) {
isConferenceSupported = false;
Log.d(this,
@@ -2954,8 +2987,4 @@
listener.onStatusHintsChanged(this, statusHints);
}
}
-
- public TelecomAccountRegistry getTelecomAccountRegistry(Context context) {
- return TelecomAccountRegistry.getInstance(context);
- }
}
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionTest.java
index 6f5e5c9..7d15680 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionTest.java
@@ -1,17 +1,15 @@
package com.android.services.telephony;
import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.TestCase.assertFalse;
import android.os.Bundle;
import android.telecom.Connection;
-import androidx.test.runner.AndroidJUnit4;
-
import org.junit.Test;
import org.junit.runner.RunWith;
+import androidx.test.runner.AndroidJUnit4;
+
@RunWith(AndroidJUnit4.class)
public class TelephonyConnectionTest {
@@ -24,17 +22,4 @@
assertEquals(codec, Connection.AUDIO_CODEC_AMR);
}
- @Test
- public void testConferenceNotSupportedForDownGradedVideoCall() {
- TestTelephonyConnection c = new TestTelephonyConnection();
- c.setIsImsConnection(true);
- c.setIsVideoCall(false);
- c.setWasVideoCall(true);
- c.setDownGradeVideoCall(true);
- c.refreshConferenceSupported();
- assertFalse(c.isConferenceSupported());
- c.setDownGradeVideoCall(false);
- c.refreshConferenceSupported();
- assertTrue(c.isConferenceSupported());
- }
}
diff --git a/tests/src/com/android/services/telephony/TestTelephonyConnection.java b/tests/src/com/android/services/telephony/TestTelephonyConnection.java
index d42ef5e..5b31c0f 100644
--- a/tests/src/com/android/services/telephony/TestTelephonyConnection.java
+++ b/tests/src/com/android/services/telephony/TestTelephonyConnection.java
@@ -16,29 +16,24 @@
package com.android.services.telephony;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.notNull;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.telecom.PhoneAccountHandle;
-import android.telecom.VideoProfile;
-import android.telephony.CarrierConfigManager;
-import com.android.ims.ImsCall;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.android.internal.telephony.Call;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
-import com.android.internal.telephony.imsphone.ImsPhoneConnection;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -67,45 +62,23 @@
@Mock
EmergencyNumberTracker mEmergencyNumberTracker;
- @Mock
- ImsPhoneConnection mImsPhoneConnection;
-
- @Mock
- ImsCall mImsCall;
-
- @Mock
- TelecomAccountRegistry mTelecomAccountRegistry;
-
- @Mock
- CarrierConfigManager mCarrierConfigManager;
-
- private boolean mIsImsConnection;
- private boolean mIsConferenceSupported = true;
private Phone mMockPhone;
private int mNotifyPhoneAccountChangedCount = 0;
private List<String> mLastConnectionEvents = new ArrayList<>();
private List<Bundle> mLastConnectionEventExtras = new ArrayList<>();
- private Object mLock = new Object();
@Override
public com.android.internal.telephony.Connection getOriginalConnection() {
- if (mIsImsConnection) {
- return mImsPhoneConnection;
- } else {
- return mMockRadioConnection;
- }
+ return mMockRadioConnection;
}
public TestTelephonyConnection() {
super(null, null, false);
MockitoAnnotations.initMocks(this);
- mIsImsConnection = false;
mMockPhone = mock(Phone.class);
mMockContext = mock(Context.class);
mOriginalConnection = mock(Connection.class);
- mTelecomAccountRegistry = mock(TelecomAccountRegistry.class);
-
// Set up mMockRadioConnection and mMockPhone to contain an active call
when(mMockRadioConnection.getState()).thenReturn(Call.State.ACTIVE);
when(mOriginalConnection.getState()).thenReturn(Call.State.ACTIVE);
@@ -127,17 +100,11 @@
when(mMockPhone.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_IMS);
when(mMockCall.getState()).thenReturn(Call.State.ACTIVE);
when(mMockCall.getPhone()).thenReturn(mMockPhone);
- when(mMockPhone.getDefaultPhone()).thenReturn(mMockPhone);
- when(mImsPhoneConnection.getImsCall()).thenReturn(mImsCall);
- when(mTelecomAccountRegistry.isMergeCallSupported(notNull(PhoneAccountHandle.class)))
- .thenReturn(mIsConferenceSupported);
- when(mTelecomAccountRegistry.isMergeImsCallSupported(notNull(PhoneAccountHandle.class)))
- .thenReturn(mIsImsConnection);
- when(mTelecomAccountRegistry
- .isVideoConferencingSupported(notNull(PhoneAccountHandle.class))).thenReturn(false);
- when(mTelecomAccountRegistry
- .isMergeOfWifiCallsAllowedWhenVoWifiOff(notNull(PhoneAccountHandle.class)))
- .thenReturn(false);
+ }
+
+ @Override
+ public boolean isConferenceSupported() {
+ return true;
}
public void setMockPhone(Phone newPhone) {
@@ -177,13 +144,6 @@
}
@Override
- public void refreshConferenceSupported() {
- if (mIsImsConnection) {
- super.refreshConferenceSupported();
- }
- }
-
- @Override
public CharSequence getResourceText(int messageId) {
return "TEST";
}
@@ -194,30 +154,8 @@
}
@Override
- public void setConferenceSupported(boolean conferenceSupported) {
- mIsConferenceSupported = conferenceSupported;
- }
-
- @Override
- public boolean isConferenceSupported() {
- return mIsConferenceSupported;
- }
-
- @Override
- public TelecomAccountRegistry getTelecomAccountRegistry(Context context) {
- return mTelecomAccountRegistry;
- }
-
- public void setIsVideoCall(boolean isVideoCall) {
- if (isVideoCall) {
- setVideoState(VideoProfile.STATE_TX_ENABLED);
- } else {
- setVideoState(VideoProfile.STATE_AUDIO_ONLY);
- }
- }
-
- public void setWasVideoCall(boolean wasVideoCall) {
- when(mImsCall.wasVideoCall()).thenReturn(wasVideoCall);
+ void refreshConferenceSupported() {
+ // Requires ImsManager dependencies, do not implement during testing.
}
public int getNotifyPhoneAccountChangedCount() {
@@ -231,19 +169,4 @@
public List<Bundle> getLastConnectionEventExtras() {
return mLastConnectionEventExtras;
}
-
- public void setIsImsConnection(boolean isImsConnection) {
- mIsImsConnection = isImsConnection;
- when(mTelecomAccountRegistry.isMergeImsCallSupported(notNull(PhoneAccountHandle.class)))
- .thenReturn(isImsConnection && mIsConferenceSupported);
- }
-
- public void setDownGradeVideoCall(boolean downgrade) {
- PersistableBundle bundle = new PersistableBundle();
- bundle.putBoolean(CarrierConfigManager.KEY_TREAT_DOWNGRADED_VIDEO_CALLS_AS_VIDEO_CALLS_BOOL,
- downgrade);
- when(mMockContext.getSystemService(Context.CARRIER_CONFIG_SERVICE))
- .thenReturn(mCarrierConfigManager);
- when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
- }
}