Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java +72 −1 Original line number Original line Diff line number Diff line Loading @@ -157,6 +157,11 @@ public class ImsPhoneConnection extends Connection implements */ */ private boolean mIsHeldByRemote = false; private boolean mIsHeldByRemote = false; /** * Used to indicate if both the user and carrier config have enabled the business composer. */ private boolean mIsBusinessComposerFeatureEnabled = false; //***** Event Constants //***** Event Constants private static final int EVENT_DTMF_DONE = 1; private static final int EVENT_DTMF_DONE = 1; private static final int EVENT_PAUSE_DONE = 2; private static final int EVENT_PAUSE_DONE = 2; Loading Loading @@ -230,6 +235,10 @@ public class ImsPhoneConnection extends Connection implements mCreateTime = System.currentTimeMillis(); mCreateTime = System.currentTimeMillis(); mUusInfo = null; mUusInfo = null; if (com.android.server.telecom.flags.Flags.businessCallComposer()) { setIsBusinessComposerFeatureEnabled(phone); } // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally // in the ImsPhoneConnection. This isn't going to inform any listeners (since the original // in the ImsPhoneConnection. This isn't going to inform any listeners (since the original // connection is not likely to be associated with a TelephonyConnection yet). // connection is not likely to be associated with a TelephonyConnection yet). Loading Loading @@ -1389,10 +1398,18 @@ public class ImsPhoneConnection extends Connection implements * ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME). This helper notifies Telecom of the business * ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME). This helper notifies Telecom of the business * composer values which will then be injected into the android.telecom.Call object. * composer values which will then be injected into the android.telecom.Call object. */ */ private void maybeInjectBusinessComposerExtras(Bundle extras) { @VisibleForTesting public void maybeInjectBusinessComposerExtras(Bundle extras) { if (extras == null) { if (extras == null) { return; return; } } // Telephony should check that the business composer features is on BEFORE // propagating the business call extras. This prevents the user from getting // business call info when they turned the feature off. if (!mIsBusinessComposerFeatureEnabled) { Rlog.i(LOG_TAG, "mIBCE: business composer feature is NOT enabled"); return; } try { try { if (extras.containsKey(ImsCallProfile.EXTRA_IS_BUSINESS_CALL) if (extras.containsKey(ImsCallProfile.EXTRA_IS_BUSINESS_CALL) && !extras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)) { && !extras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)) { Loading @@ -1413,6 +1430,60 @@ public class ImsPhoneConnection extends Connection implements } } } } @VisibleForTesting public boolean getIsBusinessComposerFeatureEnabled() { return mIsBusinessComposerFeatureEnabled; } @VisibleForTesting public void setIsBusinessComposerFeatureEnabled(Phone phone) { mIsBusinessComposerFeatureEnabled = isBusinessComposerEnabledByConfig(phone) && isBusinessOnlyCallComposerEnabledByUser(phone); Rlog.i(LOG_TAG, String.format( "setIsBusinessComposerFeatureEnabled: mIsBusinessComposerFeatureEnabled=[%b], " + "phone=[%s]", mIsBusinessComposerFeatureEnabled, phone)); } /** * Returns whether the carrier supports and has enabled the business composer */ @VisibleForTesting public boolean isBusinessComposerEnabledByConfig(Phone phone) { PersistableBundle b = null; CarrierConfigManager configMgr = phone.getContext().getSystemService( CarrierConfigManager.class); if (configMgr != null) { // If an invalid subId is used, this bundle will contain default values. b = configMgr.getConfigForSubId(phone.getSubId()); } if (b != null) { return b.getBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL); } else { // Return static default defined in CarrierConfigManager. return CarrierConfigManager.getDefaultConfig() .getBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL); } } /** * Returns whether the user has enabled the business composer */ @VisibleForTesting public boolean isBusinessOnlyCallComposerEnabledByUser(Phone phone) { if (phone == null || phone.getContext() == null) { return false; } TelephonyManager tm = (TelephonyManager) phone.getContext().getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { Rlog.e(LOG_TAG, "isBusinessOnlyCallComposerEnabledByUser: TelephonyManager is null"); return false; } return tm.getCallComposerStatus() == TelephonyManager.CALL_COMPOSER_STATUS_BUSINESS_ONLY || tm.getCallComposerStatus() == TelephonyManager.CALL_COMPOSER_STATUS_ON; } private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) { private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) { if (extras == null || newExtras == null) { if (extras == null || newExtras == null) { return extras == newExtras; return extras == newExtras; Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java +128 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.telephony.DisconnectCause; import android.telephony.DisconnectCause; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; import android.telephony.ServiceState; Loading @@ -57,6 +59,7 @@ import com.android.ims.ImsException; import com.android.internal.telephony.Call; import com.android.internal.telephony.Call; import com.android.internal.telephony.Connection; import com.android.internal.telephony.Connection; import com.android.internal.telephony.GsmCdmaCall; import com.android.internal.telephony.GsmCdmaCall; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.imsphone.ImsPhone.ImsDialArgs; import com.android.internal.telephony.imsphone.ImsPhone.ImsDialArgs; Loading Loading @@ -95,6 +98,8 @@ public class ImsPhoneConnectionTest extends TelephonyTest { mForeGroundCall = mock(ImsPhoneCall.class); mForeGroundCall = mock(ImsPhoneCall.class); mBackGroundCall = mock(ImsPhoneCall.class); mBackGroundCall = mock(ImsPhoneCall.class); mRingGroundCall = mock(ImsPhoneCall.class); mRingGroundCall = mock(ImsPhoneCall.class); mTelephonyManager = mock(TelephonyManager.class); mCarrierConfigManager = mock(CarrierConfigManager.class); replaceInstance(Handler.class, "mLooper", mImsCT, Looper.myLooper()); replaceInstance(Handler.class, "mLooper", mImsCT, Looper.myLooper()); replaceInstance(ImsPhoneCallTracker.class, "mForegroundCall", mImsCT, mForeGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mForegroundCall", mImsCT, mForeGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mBackgroundCall", mImsCT, mBackGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mBackgroundCall", mImsCT, mBackGroundCall); Loading @@ -103,6 +108,10 @@ public class ImsPhoneConnectionTest extends TelephonyTest { mImsCallProfile.mCallExtras = mBundle; mImsCallProfile.mCallExtras = mBundle; doReturn(ImsPhoneCall.State.IDLE).when(mForeGroundCall).getState(); doReturn(ImsPhoneCall.State.IDLE).when(mForeGroundCall).getState(); // By default, turn off the business composer setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(false); } } @After @After Loading Loading @@ -431,6 +440,97 @@ public class ImsPhoneConnectionTest extends TelephonyTest { ImsPhoneConnection.toTelecomVerificationStatus(90210)); ImsPhoneConnection.toTelecomVerificationStatus(90210)); } } /** * Assert the helper method * {@link ImsPhoneConnection#isBusinessOnlyCallComposerEnabledByUser(Phone)} is Working As * Intended. */ @Test @SmallTest public void testIsBusinessOnlyCallComposerEnabledByUser() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); setUserEnabledBusinessComposer(true); assertTrue(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); setUserEnabledBusinessComposer(false); assertFalse(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); } /** * Assert the helper method * {@link ImsPhoneConnection#isBusinessComposerEnabledByConfig(Phone)} is Working As * Intended. */ @Test @SmallTest public void testBusinessComposerEnabledByCarrierConfig() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); setCarrierConfigBusinessComposer(true); assertTrue(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); setCarrierConfigBusinessComposer(false); assertFalse(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); } /** * Verify that the {@link ImsPhoneConnection#getIsBusinessComposerFeatureEnabled()} only * returns true when it is enabled by the CarrierConfigManager and user. */ @Test @SmallTest public void testIncomingImsCallSetsTheBusinessComposerFeatureStatus() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(false); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertTrue(mConnectionUT.getIsBusinessComposerFeatureEnabled()); } /** * If the business composer feature is off but ImsCallProfile extras still injected by the lower * layer, Telephony should NOT inject the telecom call extras. */ @Test @SmallTest public void testMaybeInjectBusinessExtrasWithFeatureOff() { setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(false); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); Bundle businessExtras = getBusinessExtras(); mConnectionUT.maybeInjectBusinessComposerExtras(businessExtras); assertFalse(businessExtras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)); assertFalse(businessExtras.containsKey(android.telecom.Call.EXTRA_ASSERTED_DISPLAY_NAME)); } /** * Verify if the business composer feature is on, telephony is injecting the telecom call extras */ @Test @SmallTest public void testMaybeInjectBusinessExtrasWithFeatureOn() { setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertTrue(mConnectionUT.getIsBusinessComposerFeatureEnabled()); Bundle businessExtras = getBusinessExtras(); mConnectionUT.maybeInjectBusinessComposerExtras(businessExtras); assertTrue(businessExtras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)); assertTrue(businessExtras.containsKey(android.telecom.Call.EXTRA_ASSERTED_DISPLAY_NAME)); } @Test @Test @SmallTest @SmallTest public void testSetRedirectingAddress() { public void testSetRedirectingAddress() { Loading Loading @@ -481,4 +581,32 @@ public class ImsPhoneConnectionTest extends TelephonyTest { latch.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); latch.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); assertTrue(receivedCountCallback[0]); assertTrue(receivedCountCallback[0]); } } private void setUserEnabledBusinessComposer(boolean isEnabled) { when(mPhone.getContext()).thenReturn(mContext); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); if (isEnabled) { when(mTelephonyManager.getCallComposerStatus()).thenReturn( TelephonyManager.CALL_COMPOSER_STATUS_BUSINESS_ONLY); } else { when(mTelephonyManager.getCallComposerStatus()).thenReturn( TelephonyManager.CALL_COMPOSER_STATUS_OFF); } } private void setCarrierConfigBusinessComposer(boolean isEnabled) { when(mPhone.getContext()).thenReturn(mContext); when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn( mCarrierConfigManager); PersistableBundle b = new PersistableBundle(); b.putBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL, isEnabled); when(mCarrierConfigManager.getConfigForSubId(mPhone.getSubId())).thenReturn(b); } private Bundle getBusinessExtras() { Bundle businessExtras = new Bundle(); businessExtras.putBoolean(ImsCallProfile.EXTRA_IS_BUSINESS_CALL, true); businessExtras.putString(ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME, "Google"); return businessExtras; } } } Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java +72 −1 Original line number Original line Diff line number Diff line Loading @@ -157,6 +157,11 @@ public class ImsPhoneConnection extends Connection implements */ */ private boolean mIsHeldByRemote = false; private boolean mIsHeldByRemote = false; /** * Used to indicate if both the user and carrier config have enabled the business composer. */ private boolean mIsBusinessComposerFeatureEnabled = false; //***** Event Constants //***** Event Constants private static final int EVENT_DTMF_DONE = 1; private static final int EVENT_DTMF_DONE = 1; private static final int EVENT_PAUSE_DONE = 2; private static final int EVENT_PAUSE_DONE = 2; Loading Loading @@ -230,6 +235,10 @@ public class ImsPhoneConnection extends Connection implements mCreateTime = System.currentTimeMillis(); mCreateTime = System.currentTimeMillis(); mUusInfo = null; mUusInfo = null; if (com.android.server.telecom.flags.Flags.businessCallComposer()) { setIsBusinessComposerFeatureEnabled(phone); } // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally // in the ImsPhoneConnection. This isn't going to inform any listeners (since the original // in the ImsPhoneConnection. This isn't going to inform any listeners (since the original // connection is not likely to be associated with a TelephonyConnection yet). // connection is not likely to be associated with a TelephonyConnection yet). Loading Loading @@ -1389,10 +1398,18 @@ public class ImsPhoneConnection extends Connection implements * ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME). This helper notifies Telecom of the business * ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME). This helper notifies Telecom of the business * composer values which will then be injected into the android.telecom.Call object. * composer values which will then be injected into the android.telecom.Call object. */ */ private void maybeInjectBusinessComposerExtras(Bundle extras) { @VisibleForTesting public void maybeInjectBusinessComposerExtras(Bundle extras) { if (extras == null) { if (extras == null) { return; return; } } // Telephony should check that the business composer features is on BEFORE // propagating the business call extras. This prevents the user from getting // business call info when they turned the feature off. if (!mIsBusinessComposerFeatureEnabled) { Rlog.i(LOG_TAG, "mIBCE: business composer feature is NOT enabled"); return; } try { try { if (extras.containsKey(ImsCallProfile.EXTRA_IS_BUSINESS_CALL) if (extras.containsKey(ImsCallProfile.EXTRA_IS_BUSINESS_CALL) && !extras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)) { && !extras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)) { Loading @@ -1413,6 +1430,60 @@ public class ImsPhoneConnection extends Connection implements } } } } @VisibleForTesting public boolean getIsBusinessComposerFeatureEnabled() { return mIsBusinessComposerFeatureEnabled; } @VisibleForTesting public void setIsBusinessComposerFeatureEnabled(Phone phone) { mIsBusinessComposerFeatureEnabled = isBusinessComposerEnabledByConfig(phone) && isBusinessOnlyCallComposerEnabledByUser(phone); Rlog.i(LOG_TAG, String.format( "setIsBusinessComposerFeatureEnabled: mIsBusinessComposerFeatureEnabled=[%b], " + "phone=[%s]", mIsBusinessComposerFeatureEnabled, phone)); } /** * Returns whether the carrier supports and has enabled the business composer */ @VisibleForTesting public boolean isBusinessComposerEnabledByConfig(Phone phone) { PersistableBundle b = null; CarrierConfigManager configMgr = phone.getContext().getSystemService( CarrierConfigManager.class); if (configMgr != null) { // If an invalid subId is used, this bundle will contain default values. b = configMgr.getConfigForSubId(phone.getSubId()); } if (b != null) { return b.getBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL); } else { // Return static default defined in CarrierConfigManager. return CarrierConfigManager.getDefaultConfig() .getBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL); } } /** * Returns whether the user has enabled the business composer */ @VisibleForTesting public boolean isBusinessOnlyCallComposerEnabledByUser(Phone phone) { if (phone == null || phone.getContext() == null) { return false; } TelephonyManager tm = (TelephonyManager) phone.getContext().getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { Rlog.e(LOG_TAG, "isBusinessOnlyCallComposerEnabledByUser: TelephonyManager is null"); return false; } return tm.getCallComposerStatus() == TelephonyManager.CALL_COMPOSER_STATUS_BUSINESS_ONLY || tm.getCallComposerStatus() == TelephonyManager.CALL_COMPOSER_STATUS_ON; } private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) { private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) { if (extras == null || newExtras == null) { if (extras == null || newExtras == null) { return extras == newExtras; return extras == newExtras; Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java +128 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.telephony.DisconnectCause; import android.telephony.DisconnectCause; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; import android.telephony.ServiceState; Loading @@ -57,6 +59,7 @@ import com.android.ims.ImsException; import com.android.internal.telephony.Call; import com.android.internal.telephony.Call; import com.android.internal.telephony.Connection; import com.android.internal.telephony.Connection; import com.android.internal.telephony.GsmCdmaCall; import com.android.internal.telephony.GsmCdmaCall; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.imsphone.ImsPhone.ImsDialArgs; import com.android.internal.telephony.imsphone.ImsPhone.ImsDialArgs; Loading Loading @@ -95,6 +98,8 @@ public class ImsPhoneConnectionTest extends TelephonyTest { mForeGroundCall = mock(ImsPhoneCall.class); mForeGroundCall = mock(ImsPhoneCall.class); mBackGroundCall = mock(ImsPhoneCall.class); mBackGroundCall = mock(ImsPhoneCall.class); mRingGroundCall = mock(ImsPhoneCall.class); mRingGroundCall = mock(ImsPhoneCall.class); mTelephonyManager = mock(TelephonyManager.class); mCarrierConfigManager = mock(CarrierConfigManager.class); replaceInstance(Handler.class, "mLooper", mImsCT, Looper.myLooper()); replaceInstance(Handler.class, "mLooper", mImsCT, Looper.myLooper()); replaceInstance(ImsPhoneCallTracker.class, "mForegroundCall", mImsCT, mForeGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mForegroundCall", mImsCT, mForeGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mBackgroundCall", mImsCT, mBackGroundCall); replaceInstance(ImsPhoneCallTracker.class, "mBackgroundCall", mImsCT, mBackGroundCall); Loading @@ -103,6 +108,10 @@ public class ImsPhoneConnectionTest extends TelephonyTest { mImsCallProfile.mCallExtras = mBundle; mImsCallProfile.mCallExtras = mBundle; doReturn(ImsPhoneCall.State.IDLE).when(mForeGroundCall).getState(); doReturn(ImsPhoneCall.State.IDLE).when(mForeGroundCall).getState(); // By default, turn off the business composer setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(false); } } @After @After Loading Loading @@ -431,6 +440,97 @@ public class ImsPhoneConnectionTest extends TelephonyTest { ImsPhoneConnection.toTelecomVerificationStatus(90210)); ImsPhoneConnection.toTelecomVerificationStatus(90210)); } } /** * Assert the helper method * {@link ImsPhoneConnection#isBusinessOnlyCallComposerEnabledByUser(Phone)} is Working As * Intended. */ @Test @SmallTest public void testIsBusinessOnlyCallComposerEnabledByUser() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); setUserEnabledBusinessComposer(true); assertTrue(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); setUserEnabledBusinessComposer(false); assertFalse(mConnectionUT.isBusinessOnlyCallComposerEnabledByUser(mImsPhone)); } /** * Assert the helper method * {@link ImsPhoneConnection#isBusinessComposerEnabledByConfig(Phone)} is Working As * Intended. */ @Test @SmallTest public void testBusinessComposerEnabledByCarrierConfig() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); setCarrierConfigBusinessComposer(true); assertTrue(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); setCarrierConfigBusinessComposer(false); assertFalse(mConnectionUT.isBusinessComposerEnabledByConfig(mImsPhone)); } /** * Verify that the {@link ImsPhoneConnection#getIsBusinessComposerFeatureEnabled()} only * returns true when it is enabled by the CarrierConfigManager and user. */ @Test @SmallTest public void testIncomingImsCallSetsTheBusinessComposerFeatureStatus() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(false); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertTrue(mConnectionUT.getIsBusinessComposerFeatureEnabled()); } /** * If the business composer feature is off but ImsCallProfile extras still injected by the lower * layer, Telephony should NOT inject the telecom call extras. */ @Test @SmallTest public void testMaybeInjectBusinessExtrasWithFeatureOff() { setUserEnabledBusinessComposer(false); setCarrierConfigBusinessComposer(false); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.getIsBusinessComposerFeatureEnabled()); Bundle businessExtras = getBusinessExtras(); mConnectionUT.maybeInjectBusinessComposerExtras(businessExtras); assertFalse(businessExtras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)); assertFalse(businessExtras.containsKey(android.telecom.Call.EXTRA_ASSERTED_DISPLAY_NAME)); } /** * Verify if the business composer feature is on, telephony is injecting the telecom call extras */ @Test @SmallTest public void testMaybeInjectBusinessExtrasWithFeatureOn() { setUserEnabledBusinessComposer(true); setCarrierConfigBusinessComposer(true); mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertTrue(mConnectionUT.getIsBusinessComposerFeatureEnabled()); Bundle businessExtras = getBusinessExtras(); mConnectionUT.maybeInjectBusinessComposerExtras(businessExtras); assertTrue(businessExtras.containsKey(android.telecom.Call.EXTRA_IS_BUSINESS_CALL)); assertTrue(businessExtras.containsKey(android.telecom.Call.EXTRA_ASSERTED_DISPLAY_NAME)); } @Test @Test @SmallTest @SmallTest public void testSetRedirectingAddress() { public void testSetRedirectingAddress() { Loading Loading @@ -481,4 +581,32 @@ public class ImsPhoneConnectionTest extends TelephonyTest { latch.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); latch.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); assertTrue(receivedCountCallback[0]); assertTrue(receivedCountCallback[0]); } } private void setUserEnabledBusinessComposer(boolean isEnabled) { when(mPhone.getContext()).thenReturn(mContext); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); if (isEnabled) { when(mTelephonyManager.getCallComposerStatus()).thenReturn( TelephonyManager.CALL_COMPOSER_STATUS_BUSINESS_ONLY); } else { when(mTelephonyManager.getCallComposerStatus()).thenReturn( TelephonyManager.CALL_COMPOSER_STATUS_OFF); } } private void setCarrierConfigBusinessComposer(boolean isEnabled) { when(mPhone.getContext()).thenReturn(mContext); when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn( mCarrierConfigManager); PersistableBundle b = new PersistableBundle(); b.putBoolean(CarrierConfigManager.KEY_SUPPORTS_BUSINESS_CALL_COMPOSER_BOOL, isEnabled); when(mCarrierConfigManager.getConfigForSubId(mPhone.getSubId())).thenReturn(b); } private Bundle getBusinessExtras() { Bundle businessExtras = new Bundle(); businessExtras.putBoolean(ImsCallProfile.EXTRA_IS_BUSINESS_CALL, true); businessExtras.putString(ImsCallProfile.EXTRA_ASSERTED_DISPLAY_NAME, "Google"); return businessExtras; } } }