aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChinmay Dhodapkar <chinmayd@google.com>2022-06-08 11:56:11 -0700
committerChinmay Dhodapkar <chinmayd@google.com>2022-06-10 18:08:02 +0000
commit2838d3908eecbc55c57076c142ac1c204f2761f9 (patch)
tree894d7705a6661a995030bc51b8334a5f9c93fa48
parentd342f0b2901e81723e4d4d0c1f613c65dc791d6f (diff)
downloadims-2838d3908eecbc55c57076c142ac1c204f2761f9.tar.gz
Fix shouldProcessCall in ImsManager
There can be call attempts made before the ims service is initialized. In this case, shouldProcessCall should throw an exception, else it might result in subsequent call failure in IMS. Bug: 232514463 Test: atest ImsManagerTest Change-Id: I81a25250a65bf6af0910c57f093ebbc71bad1dba (cherry picked from commit 7b6fb80d5ec80d4ef996453f16403727d17ff279)
-rw-r--r--src/java/com/android/ims/ImsManager.java3
-rw-r--r--tests/src/com/android/ims/ImsManagerTest.java16
2 files changed, 18 insertions, 1 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java
index cf95a20b..c41426d0 100644
--- a/src/java/com/android/ims/ImsManager.java
+++ b/src/java/com/android/ims/ImsManager.java
@@ -3035,7 +3035,8 @@ public class ImsManager implements FeatureUpdates {
public @MmTelFeature.ProcessCallResult int shouldProcessCall(boolean isEmergency,
String[] numbers) throws ImsException {
try {
- return mMmTelConnectionRef.get().shouldProcessCall(isEmergency, numbers);
+ MmTelFeatureConnection c = getOrThrowExceptionIfServiceUnavailable();
+ return c.shouldProcessCall(isEmergency, numbers);
} catch (RemoteException e) {
throw new ImsException("shouldProcessCall()", e,
ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
diff --git a/tests/src/com/android/ims/ImsManagerTest.java b/tests/src/com/android/ims/ImsManagerTest.java
index 42f110dc..0653908d 100644
--- a/tests/src/com/android/ims/ImsManagerTest.java
+++ b/tests/src/com/android/ims/ImsManagerTest.java
@@ -22,6 +22,7 @@ import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TE
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.anyInt;
@@ -968,6 +969,21 @@ public class ImsManagerTest extends ImsTestBase {
anyInt());
}
+ @Test @SmallTest
+ public void testShouldProcessCall_ThrowsExceptionIfServiceIsStillInitializing() {
+ ImsManager imsManager = getImsManagerAndInitProvisionedValues();
+ doReturn(-1).when(mMmTelFeatureConnection).getSubId();
+ assertThrows(ImsException.class, () -> imsManager.shouldProcessCall(true, new String[1]));
+ }
+
+ @Test @SmallTest
+ public void testShouldProcessCall_DoesNotThrowExceptionWhenServiceInitialized()
+ throws Exception {
+ ImsManager imsManager = getImsManagerAndInitProvisionedValues();
+ int ret = imsManager.shouldProcessCall(true, new String[1]);
+ assertEquals(MmTelFeature.PROCESS_CALL_IMS, ret);
+ }
+
/**
* Tests the operation of setWfcRoamingSetting and ensures that the user setting for WFC roaming
* and the ImsConfig setting are both called properly.