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

Commit 8525f5dc authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android (Google) Code Review
Browse files

Merge "Avoid hostname lookup in NetworkProperties"

parents a69fbc8e 1cf56ab9
Loading
Loading
Loading
Loading
+5 −9
Original line number Original line Diff line number Diff line
@@ -123,18 +123,17 @@ public class NetworkProperties implements Parcelable {
    public synchronized void writeToParcel(Parcel dest, int flags) {
    public synchronized void writeToParcel(Parcel dest, int flags) {
        dest.writeString(getInterfaceName());
        dest.writeString(getInterfaceName());
        dest.writeInt(mAddresses.size());
        dest.writeInt(mAddresses.size());
        //TODO: explore an easy alternative to preserve hostname
        // without doing a lookup
        for(InetAddress a : mAddresses) {
        for(InetAddress a : mAddresses) {
            dest.writeString(a.getHostName());
            dest.writeByteArray(a.getAddress());
            dest.writeByteArray(a.getAddress());
        }
        }
        dest.writeInt(mDnses.size());
        dest.writeInt(mDnses.size());
        for(InetAddress d : mDnses) {
        for(InetAddress d : mDnses) {
            dest.writeString(d.getHostName());
            dest.writeByteArray(d.getAddress());
            dest.writeByteArray(d.getAddress());
        }
        }
        if (mGateway != null) {
        if (mGateway != null) {
            dest.writeByte((byte)1);
            dest.writeByte((byte)1);
            dest.writeString(mGateway.getHostName());
            dest.writeByteArray(mGateway.getAddress());
            dest.writeByteArray(mGateway.getAddress());
        } else {
        } else {
            dest.writeByte((byte)0);
            dest.writeByte((byte)0);
@@ -166,21 +165,18 @@ public class NetworkProperties implements Parcelable {
                int addressCount = in.readInt();
                int addressCount = in.readInt();
                for (int i=0; i<addressCount; i++) {
                for (int i=0; i<addressCount; i++) {
                    try {
                    try {
                        netProp.addAddress(InetAddress.getByAddress(in.readString(),
                        netProp.addAddress(InetAddress.getByAddress(in.createByteArray()));
                                in.createByteArray()));
                    } catch (UnknownHostException e) { }
                    } catch (UnknownHostException e) { }
                }
                }
                addressCount = in.readInt();
                addressCount = in.readInt();
                for (int i=0; i<addressCount; i++) {
                for (int i=0; i<addressCount; i++) {
                    try {
                    try {
                        netProp.addDns(InetAddress.getByAddress(in.readString(),
                        netProp.addDns(InetAddress.getByAddress(in.createByteArray()));
                                in.createByteArray()));
                    } catch (UnknownHostException e) { }
                    } catch (UnknownHostException e) { }
                }
                }
                if (in.readByte() == 1) {
                if (in.readByte() == 1) {
                    try {
                    try {
                        netProp.setGateway(InetAddress.getByAddress(in.readString(),
                        netProp.setGateway(InetAddress.getByAddress(in.createByteArray()));
                                in.createByteArray()));
                    } catch (UnknownHostException e) {}
                    } catch (UnknownHostException e) {}
                }
                }
                if (in.readByte() == 1) {
                if (in.readByte() == 1) {