Loading src/java/com/android/internal/telephony/dataconnection/ApnSetting.java +3 −0 Original line number Diff line number Diff line Loading @@ -505,7 +505,10 @@ public class ApnSetting { proxy.equals(other.proxy) && mmsc.equals(other.mmsc) && mmsProxy.equals(other.mmsProxy) && TextUtils.equals(mmsPort, other.mmsPort) && port.equals(other.port) && TextUtils.equals(user, other.user) && TextUtils.equals(password, other.password) && authType == other.authType && Arrays.deepEquals(types, other.types) && protocol.equals(other.protocol) && Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +41 −1 Original line number Diff line number Diff line Loading @@ -28,11 +28,14 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; public class ApnSettingTest extends TelephonyTest { Loading Loading @@ -495,4 +498,41 @@ public class ApnSettingTest extends TelephonyTest { isMetered(mContext, 4, isRoaming)); } @Test @SmallTest public void testEquals() throws Exception { final int dummyInt = 1; final String dummyString = "dummy"; final String[] dummyStringArr = new String[] {"dummy"}; // base apn ApnSetting baseApn = createApnSetting(new String[] {"mms", "default"}); Field[] fields = ApnSetting.class.getDeclaredFields(); for (Field f : fields) { int modifiers = f.getModifiers(); if (Modifier.isStatic(modifiers) || !Modifier.isFinal(modifiers)) { continue; } f.setAccessible(true); ApnSetting testApn = null; if (int.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.setInt(testApn, dummyInt + f.getInt(testApn)); } else if (boolean.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.setBoolean(testApn, !f.getBoolean(testApn)); } else if (String.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.set(testApn, dummyString); } else if (String[].class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.set(testApn, dummyStringArr); } else { fail("Unsupported field:" + f.getName()); } if (testApn != null) { assertFalse(f.getName() + " is NOT checked", testApn.equals(baseApn)); } } } } Loading
src/java/com/android/internal/telephony/dataconnection/ApnSetting.java +3 −0 Original line number Diff line number Diff line Loading @@ -505,7 +505,10 @@ public class ApnSetting { proxy.equals(other.proxy) && mmsc.equals(other.mmsc) && mmsProxy.equals(other.mmsProxy) && TextUtils.equals(mmsPort, other.mmsPort) && port.equals(other.port) && TextUtils.equals(user, other.user) && TextUtils.equals(password, other.password) && authType == other.authType && Arrays.deepEquals(types, other.types) && protocol.equals(other.protocol) && Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +41 −1 Original line number Diff line number Diff line Loading @@ -28,11 +28,14 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; public class ApnSettingTest extends TelephonyTest { Loading Loading @@ -495,4 +498,41 @@ public class ApnSettingTest extends TelephonyTest { isMetered(mContext, 4, isRoaming)); } @Test @SmallTest public void testEquals() throws Exception { final int dummyInt = 1; final String dummyString = "dummy"; final String[] dummyStringArr = new String[] {"dummy"}; // base apn ApnSetting baseApn = createApnSetting(new String[] {"mms", "default"}); Field[] fields = ApnSetting.class.getDeclaredFields(); for (Field f : fields) { int modifiers = f.getModifiers(); if (Modifier.isStatic(modifiers) || !Modifier.isFinal(modifiers)) { continue; } f.setAccessible(true); ApnSetting testApn = null; if (int.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.setInt(testApn, dummyInt + f.getInt(testApn)); } else if (boolean.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.setBoolean(testApn, !f.getBoolean(testApn)); } else if (String.class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.set(testApn, dummyString); } else if (String[].class.equals(f.getType())) { testApn = new ApnSetting(baseApn); f.set(testApn, dummyStringArr); } else { fail("Unsupported field:" + f.getName()); } if (testApn != null) { assertFalse(f.getName() + " is NOT checked", testApn.equals(baseApn)); } } } }