Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java +7 −11 Original line number Diff line number Diff line Loading @@ -908,22 +908,18 @@ public class ImsPhoneConnection extends Connection implements * @param extras The ImsCallProfile extras. */ private void updateWifiStateFromExtras(Bundle extras) { if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE)) { // The RIL (sadly) sends us the EXTRA_CALL_RAT_TYPE as a string extra, rather than an // integer extra, so we need to parse it. int radioTechnology; try { radioTechnology = Integer.parseInt(extras.getString( ImsCallProfile.EXTRA_CALL_RAT_TYPE)); } catch (NumberFormatException nfe) { radioTechnology = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; } if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE) || extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT)) { // We've received the extra indicating the radio technology, so we will continue to // prefer the radio technology received via this extra going forward. mIsWifiStateFromExtras = true; boolean isWifi = radioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN; ImsCall call = getImsCall(); boolean isWifi = false; if (call != null) { isWifi = call.isWifiCall(); } // Report any changes if (isWifi() != isWifi) { Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.internal.telephony.imsphone; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.telephony.ServiceState; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; import com.android.internal.telephony.Call; import com.android.internal.telephony.TelephonyTest; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; public class ImsCallTest extends TelephonyTest { private Bundle mBundle; private ImsCallProfile mTestCallProfile; @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mTestCallProfile = new ImsCallProfile(); mBundle = mTestCallProfile.mCallExtras; } @After public void tearDown() throws Exception { super.tearDown(); } @Test @SmallTest public void testSetWifi() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetLteNoWifi() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetLteNoWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); } } tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,8 @@ public class ImsPhoneConnectionTest extends TelephonyTest { public void testSetWifi() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isWifi()); // ImsCall.isWifiCall is tested elsewhere doReturn(true).when(mImsCall).isWifiCall(); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE)); Loading @@ -249,4 +251,21 @@ public class ImsPhoneConnectionTest extends TelephonyTest { //keep using the wifi state from extra, not update assertFalse(mConnectionUT.updateWifiState()); } @Test @SmallTest public void testSetWifi2() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isWifi()); // ImsCall.isWifiCall is tested elsewhere doReturn(true).when(mImsCall).isWifiCall(); // Tests to make sure that the EXTRA_CALL_RAT_TYPE_ALT string is set correctly for newer // devices. mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE)); assertTrue(mConnectionUT.isWifi()); //keep using the wifi state from extra, not update assertFalse(mConnectionUT.updateWifiState()); } } Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java +7 −11 Original line number Diff line number Diff line Loading @@ -908,22 +908,18 @@ public class ImsPhoneConnection extends Connection implements * @param extras The ImsCallProfile extras. */ private void updateWifiStateFromExtras(Bundle extras) { if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE)) { // The RIL (sadly) sends us the EXTRA_CALL_RAT_TYPE as a string extra, rather than an // integer extra, so we need to parse it. int radioTechnology; try { radioTechnology = Integer.parseInt(extras.getString( ImsCallProfile.EXTRA_CALL_RAT_TYPE)); } catch (NumberFormatException nfe) { radioTechnology = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; } if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE) || extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT)) { // We've received the extra indicating the radio technology, so we will continue to // prefer the radio technology received via this extra going forward. mIsWifiStateFromExtras = true; boolean isWifi = radioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN; ImsCall call = getImsCall(); boolean isWifi = false; if (call != null) { isWifi = call.isWifiCall(); } // Report any changes if (isWifi() != isWifi) { Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.internal.telephony.imsphone; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.telephony.ServiceState; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; import com.android.internal.telephony.Call; import com.android.internal.telephony.TelephonyTest; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; public class ImsCallTest extends TelephonyTest { private Bundle mBundle; private ImsCallProfile mTestCallProfile; @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mTestCallProfile = new ImsCallProfile(); mBundle = mTestCallProfile.mCallExtras; } @After public void tearDown() throws Exception { super.tearDown(); } @Test @SmallTest public void testSetWifi() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetLteNoWifi() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); } @Test @SmallTest public void testSetLteNoWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); } }
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,8 @@ public class ImsPhoneConnectionTest extends TelephonyTest { public void testSetWifi() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isWifi()); // ImsCall.isWifiCall is tested elsewhere doReturn(true).when(mImsCall).isWifiCall(); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE)); Loading @@ -249,4 +251,21 @@ public class ImsPhoneConnectionTest extends TelephonyTest { //keep using the wifi state from extra, not update assertFalse(mConnectionUT.updateWifiState()); } @Test @SmallTest public void testSetWifi2() { mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall, false); assertFalse(mConnectionUT.isWifi()); // ImsCall.isWifiCall is tested elsewhere doReturn(true).when(mImsCall).isWifiCall(); // Tests to make sure that the EXTRA_CALL_RAT_TYPE_ALT string is set correctly for newer // devices. mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE)); assertTrue(mConnectionUT.isWifi()); //keep using the wifi state from extra, not update assertFalse(mConnectionUT.updateWifiState()); } }