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

Commit 277c7d24 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Used LinkAddress insteaad of InterfaceAddress"

parents e8fc3d23 8100a8ae
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -4076,11 +4076,11 @@ package android.telephony {
package android.telephony.data {

  public final class DataCallResponse implements android.os.Parcelable {
    ctor public DataCallResponse(int, int, int, int, java.lang.String, java.lang.String, java.util.List<android.telephony.data.InterfaceAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.lang.String>, int);
    ctor public DataCallResponse(int, int, int, int, java.lang.String, java.lang.String, java.util.List<android.net.LinkAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.lang.String>, int);
    ctor public DataCallResponse(android.os.Parcel);
    method public int describeContents();
    method public int getActive();
    method public java.util.List<android.telephony.data.InterfaceAddress> getAddresses();
    method public java.util.List<android.net.LinkAddress> getAddresses();
    method public int getCallId();
    method public java.util.List<java.net.InetAddress> getDnses();
    method public java.util.List<java.net.InetAddress> getGateways();
@@ -4123,17 +4123,6 @@ package android.telephony.data {
    field public static final int TYPE_COMMON = 0; // 0x0
  }

  public final class InterfaceAddress implements android.os.Parcelable {
    ctor public InterfaceAddress(java.net.InetAddress, int);
    ctor public InterfaceAddress(java.lang.String, int) throws java.net.UnknownHostException;
    ctor public InterfaceAddress(android.os.Parcel);
    method public int describeContents();
    method public java.net.InetAddress getAddress();
    method public int getNetworkPrefixLength();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.telephony.data.InterfaceAddress> CREATOR;
  }

}

package android.telephony.ims {
+6 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package android.telephony.data;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.LinkAddress;
import android.os.Parcel;
import android.os.Parcelable;

@@ -40,7 +41,7 @@ public final class DataCallResponse implements Parcelable {
    private final int mActive;
    private final String mType;
    private final String mIfname;
    private final List<InterfaceAddress> mAddresses;
    private final List<LinkAddress> mAddresses;
    private final List<InetAddress> mDnses;
    private final List<InetAddress> mGateways;
    private final List<String> mPcscfs;
@@ -71,7 +72,7 @@ public final class DataCallResponse implements Parcelable {
     */
    public DataCallResponse(int status, int suggestedRetryTime, int cid, int active,
                            @Nullable String type, @Nullable String ifname,
                            @Nullable List<InterfaceAddress> addresses,
                            @Nullable List<LinkAddress> addresses,
                            @Nullable List<InetAddress> dnses,
                            @Nullable List<InetAddress> gateways,
                            @Nullable List<String> pcscfs, int mtu) {
@@ -96,7 +97,7 @@ public final class DataCallResponse implements Parcelable {
        mType = source.readString();
        mIfname = source.readString();
        mAddresses = new ArrayList<>();
        source.readList(mAddresses, InterfaceAddress.class.getClassLoader());
        source.readList(mAddresses, LinkAddress.class.getClassLoader());
        mDnses = new ArrayList<>();
        source.readList(mDnses, InetAddress.class.getClassLoader());
        mGateways = new ArrayList<>();
@@ -140,10 +141,10 @@ public final class DataCallResponse implements Parcelable {
    public String getIfname() { return mIfname; }

    /**
     * @return A list of {@link InterfaceAddress}
     * @return A list of {@link LinkAddress}
     */
    @NonNull
    public List<InterfaceAddress> getAddresses() { return mAddresses; }
    public List<LinkAddress> getAddresses() { return mAddresses; }

    /**
     * @return A list of DNS server addresses, e.g., "192.0.1.3" or
+0 −20
Original line number Diff line number Diff line
/*
 * Copyright 2017 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.
 */

/** @hide */
package android.telephony.data;

parcelable InterfaceAddress;
+0 −127
Original line number Diff line number Diff line
/*
 * Copyright 2017 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 android.telephony.data;

import android.annotation.SystemApi;
import android.net.NetworkUtils;
import android.os.Parcel;
import android.os.Parcelable;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * This class represents a Network Interface address. In short it's an IP address, a subnet mask
 * when the address is an IPv4 one. An IP address and a network prefix length in the case of IPv6
 * address.
 *
 * @hide
 */
@SystemApi
public final class InterfaceAddress implements Parcelable {

    private final InetAddress mInetAddress;

    private final int mPrefixLength;

    /**
     * @param inetAddress A {@link InetAddress} of the address
     * @param prefixLength The network prefix length for this address.
     */
    public InterfaceAddress(InetAddress inetAddress, int prefixLength) {
        mInetAddress = inetAddress;
        mPrefixLength = prefixLength;
    }

    /**
     * @param address The address in string format
     * @param prefixLength The network prefix length for this address.
     * @throws UnknownHostException
     */
    public InterfaceAddress(String address, int prefixLength) throws UnknownHostException {
        InetAddress ia;
        try {
            ia = NetworkUtils.numericToInetAddress(address);
        } catch (IllegalArgumentException e) {
            throw new UnknownHostException("Non-numeric ip addr=" + address);
        }
        mInetAddress = ia;
        mPrefixLength = prefixLength;
    }

    public InterfaceAddress(Parcel source) {
        mInetAddress = (InetAddress) source.readSerializable();
        mPrefixLength = source.readInt();
    }

    /**
     * @return an InetAddress for this address.
     */
    public InetAddress getAddress() { return mInetAddress; }

    /**
     * @return The network prefix length for this address.
     */
    public int getNetworkPrefixLength() { return mPrefixLength; }

    @Override
    public boolean equals (Object o) {
        if (this == o) return true;

        if (o == null || !(o instanceof InterfaceAddress)) {
            return false;
        }

        InterfaceAddress other = (InterfaceAddress) o;
        return this.mInetAddress.equals(other.mInetAddress)
                && this.mPrefixLength == other.mPrefixLength;
    }

    @Override
    public int hashCode() {
        return mInetAddress.hashCode() * 31 + mPrefixLength * 37;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public String toString() {
        return mInetAddress + "/" + mPrefixLength;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeSerializable(mInetAddress);
        dest.writeInt(mPrefixLength);
    }

    public static final Parcelable.Creator<InterfaceAddress> CREATOR =
            new Parcelable.Creator<InterfaceAddress>() {
        @Override
        public InterfaceAddress createFromParcel(Parcel source) {
            return new InterfaceAddress(source);
        }

        @Override
        public InterfaceAddress[] newArray(int size) {
            return new InterfaceAddress[size];
        }
    };
}