Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf93cbb0 authored by Wei Huang's avatar Wei Huang Committed by android-build-merger
Browse files

Merge "Fix : Reconnection not triggered when APN changed" am: 8d90dccd

am: 1d21b84b

Change-Id: Id5f1dfb5efc806f7cc3714ecc4990cd1b821bc2f
parents c328eea4 1d21b84b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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) &&
+41 −1
Original line number Diff line number Diff line
@@ -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 {
@@ -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));
            }
        }
    }
}