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

Commit 442f8ea3 authored by Chalard Jean's avatar Chalard Jean Committed by Automerger Merge Worker
Browse files

Merge "Revert "Add new network quirk parcelable in the NetworkAttributes.""...

Merge "Revert "Add new network quirk parcelable in the NetworkAttributes."" am: 8964e737 am: f5f4cf55 am: e588b57b am: 4d58883d

Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/1353490

Change-Id: Icb8287db1df6812c2396d536d59f3557881ea13e
parents d31f695d 4d58883d
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ aidl_interface {
        "src/android/net/IIpMemoryStore.aidl",
        "src/android/net/IIpMemoryStore.aidl",
        "src/android/net/IIpMemoryStoreCallbacks.aidl",
        "src/android/net/IIpMemoryStoreCallbacks.aidl",
        "src/android/net/ipmemorystore/**/*.aidl",
        "src/android/net/ipmemorystore/**/*.aidl",
        "src/android/net/quirks/IPv6ProvisioningLossQuirkParcelable.aidl",
    ],
    ],
    backend: {
    backend: {
        java: {
        java: {
@@ -133,7 +132,6 @@ java_library {
        "src/android/net/IpMemoryStoreClient.java",
        "src/android/net/IpMemoryStoreClient.java",
        "src/android/net/ipmemorystore/**/*.java",
        "src/android/net/ipmemorystore/**/*.java",
        "src/android/net/networkstack/**/*.java",
        "src/android/net/networkstack/**/*.java",
        "src/android/net/quirks/**/*.java",
        "src/android/net/shared/**/*.java",
        "src/android/net/shared/**/*.java",
    ],
    ],
    static_libs: [
    static_libs: [
+0 −1
Original line number Original line Diff line number Diff line
@@ -23,5 +23,4 @@ parcelable NetworkAttributesParcelable {
  String cluster;
  String cluster;
  android.net.ipmemorystore.Blob[] dnsAddresses;
  android.net.ipmemorystore.Blob[] dnsAddresses;
  int mtu;
  int mtu;
  @nullable android.net.quirks.IPv6ProvisioningLossQuirkParcelable ipv6ProvLossQuirk;
}
}
+0 −22
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.net.quirks;
parcelable IPv6ProvisioningLossQuirkParcelable {
  int detectionCount;
  long quirkExpiry;
}
+8 −48
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package android.net.ipmemorystore;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.net.quirks.IPv6ProvisioningLossQuirk;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


@@ -84,13 +83,6 @@ public class NetworkAttributes {
    public final Integer mtu;
    public final Integer mtu;
    private static final float WEIGHT_MTU = 50.0f;
    private static final float WEIGHT_MTU = 50.0f;


    // IPv6 provisioning quirk info about this network, if applicable.
    @Nullable
    public final IPv6ProvisioningLossQuirk ipv6ProvLossQuirk;
    // quirk information doesn't imply any correlation between "the same quirk detection count and
    // expiry" and "the same L3 network".
    private static final float WEIGHT_V6PROVLOSSQUIRK = 0.0f;

    // The sum of all weights in this class. Tests ensure that this stays equal to the total of
    // The sum of all weights in this class. Tests ensure that this stays equal to the total of
    // all weights.
    // all weights.
    /** @hide */
    /** @hide */
@@ -99,8 +91,7 @@ public class NetworkAttributes {
            + WEIGHT_ASSIGNEDV4ADDREXPIRY
            + WEIGHT_ASSIGNEDV4ADDREXPIRY
            + WEIGHT_CLUSTER
            + WEIGHT_CLUSTER
            + WEIGHT_DNSADDRESSES
            + WEIGHT_DNSADDRESSES
            + WEIGHT_MTU
            + WEIGHT_MTU;
            + WEIGHT_V6PROVLOSSQUIRK;


    /** @hide */
    /** @hide */
    @VisibleForTesting
    @VisibleForTesting
@@ -109,8 +100,7 @@ public class NetworkAttributes {
            @Nullable final Long assignedV4AddressExpiry,
            @Nullable final Long assignedV4AddressExpiry,
            @Nullable final String cluster,
            @Nullable final String cluster,
            @Nullable final List<InetAddress> dnsAddresses,
            @Nullable final List<InetAddress> dnsAddresses,
            @Nullable final Integer mtu,
            @Nullable final Integer mtu) {
            @Nullable final IPv6ProvisioningLossQuirk ipv6ProvLossQuirk) {
        if (mtu != null && mtu < 0) throw new IllegalArgumentException("MTU can't be negative");
        if (mtu != null && mtu < 0) throw new IllegalArgumentException("MTU can't be negative");
        if (assignedV4AddressExpiry != null && assignedV4AddressExpiry <= 0) {
        if (assignedV4AddressExpiry != null && assignedV4AddressExpiry <= 0) {
            throw new IllegalArgumentException("lease expiry can't be negative or zero");
            throw new IllegalArgumentException("lease expiry can't be negative or zero");
@@ -121,7 +111,6 @@ public class NetworkAttributes {
        this.dnsAddresses = null == dnsAddresses ? null :
        this.dnsAddresses = null == dnsAddresses ? null :
                Collections.unmodifiableList(new ArrayList<>(dnsAddresses));
                Collections.unmodifiableList(new ArrayList<>(dnsAddresses));
        this.mtu = mtu;
        this.mtu = mtu;
        this.ipv6ProvLossQuirk = ipv6ProvLossQuirk;
    }
    }


    @VisibleForTesting
    @VisibleForTesting
@@ -133,8 +122,7 @@ public class NetworkAttributes {
                        ? parcelable.assignedV4AddressExpiry : null,
                        ? parcelable.assignedV4AddressExpiry : null,
                parcelable.cluster,
                parcelable.cluster,
                blobArrayToInetAddressList(parcelable.dnsAddresses),
                blobArrayToInetAddressList(parcelable.dnsAddresses),
                parcelable.mtu >= 0 ? parcelable.mtu : null,
                parcelable.mtu >= 0 ? parcelable.mtu : null);
                IPv6ProvisioningLossQuirk.fromStableParcelable(parcelable.ipv6ProvLossQuirk));
    }
    }


    @Nullable
    @Nullable
@@ -183,8 +171,6 @@ public class NetworkAttributes {
        parcelable.cluster = cluster;
        parcelable.cluster = cluster;
        parcelable.dnsAddresses = inetAddressListToBlobArray(dnsAddresses);
        parcelable.dnsAddresses = inetAddressListToBlobArray(dnsAddresses);
        parcelable.mtu = (null == mtu) ? -1 : mtu;
        parcelable.mtu = (null == mtu) ? -1 : mtu;
        parcelable.ipv6ProvLossQuirk =
                (null == ipv6ProvLossQuirk) ? null : ipv6ProvLossQuirk.toStableParcelable();
        return parcelable;
        return parcelable;
    }
    }


@@ -198,16 +184,13 @@ public class NetworkAttributes {


    /** @hide */
    /** @hide */
    public float getNetworkGroupSamenessConfidence(@NonNull final NetworkAttributes o) {
    public float getNetworkGroupSamenessConfidence(@NonNull final NetworkAttributes o) {
        // TODO: Remove the useless comparison for members which are associated with 0 weight.
        final float samenessScore =
        final float samenessScore =
                samenessContribution(WEIGHT_ASSIGNEDV4ADDR, assignedV4Address, o.assignedV4Address)
                samenessContribution(WEIGHT_ASSIGNEDV4ADDR, assignedV4Address, o.assignedV4Address)
                + samenessContribution(WEIGHT_ASSIGNEDV4ADDREXPIRY, assignedV4AddressExpiry,
                + samenessContribution(WEIGHT_ASSIGNEDV4ADDREXPIRY, assignedV4AddressExpiry,
                      o.assignedV4AddressExpiry)
                      o.assignedV4AddressExpiry)
                + samenessContribution(WEIGHT_CLUSTER, cluster, o.cluster)
                + samenessContribution(WEIGHT_CLUSTER, cluster, o.cluster)
                + samenessContribution(WEIGHT_DNSADDRESSES, dnsAddresses, o.dnsAddresses)
                + samenessContribution(WEIGHT_DNSADDRESSES, dnsAddresses, o.dnsAddresses)
                + samenessContribution(WEIGHT_MTU, mtu, o.mtu)
                + samenessContribution(WEIGHT_MTU, mtu, o.mtu);
                + samenessContribution(WEIGHT_V6PROVLOSSQUIRK, ipv6ProvLossQuirk,
                      o.ipv6ProvLossQuirk);
        // The minimum is 0, the max is TOTAL_WEIGHT and should be represented by 1.0, and
        // The minimum is 0, the max is TOTAL_WEIGHT and should be represented by 1.0, and
        // TOTAL_WEIGHT_CUTOFF should represent 0.5, but there is no requirement that
        // TOTAL_WEIGHT_CUTOFF should represent 0.5, but there is no requirement that
        // TOTAL_WEIGHT_CUTOFF would be half of TOTAL_WEIGHT (indeed, it should not be).
        // TOTAL_WEIGHT_CUTOFF would be half of TOTAL_WEIGHT (indeed, it should not be).
@@ -233,8 +216,6 @@ public class NetworkAttributes {
        private List<InetAddress> mDnsAddresses;
        private List<InetAddress> mDnsAddresses;
        @Nullable
        @Nullable
        private Integer mMtu;
        private Integer mMtu;
        @Nullable
        private IPv6ProvisioningLossQuirk mIpv6ProvLossQuirk;


        /**
        /**
         * Constructs a new Builder.
         * Constructs a new Builder.
@@ -250,7 +231,6 @@ public class NetworkAttributes {
            mCluster = attributes.cluster;
            mCluster = attributes.cluster;
            mDnsAddresses = new ArrayList<>(attributes.dnsAddresses);
            mDnsAddresses = new ArrayList<>(attributes.dnsAddresses);
            mMtu = attributes.mtu;
            mMtu = attributes.mtu;
            mIpv6ProvLossQuirk = attributes.ipv6ProvLossQuirk;
        }
        }


        /**
        /**
@@ -317,31 +297,20 @@ public class NetworkAttributes {
            return this;
            return this;
        }
        }


        /**
         * Set the IPv6 Provisioning Loss Quirk information.
         * @param quirk The IPv6 Provisioning Loss Quirk.
         * @return This builder.
         */
        public Builder setIpv6ProvLossQuirk(@Nullable final IPv6ProvisioningLossQuirk quirk) {
            mIpv6ProvLossQuirk = quirk;
            return this;
        }

        /**
        /**
         * Return the built NetworkAttributes object.
         * Return the built NetworkAttributes object.
         * @return The built NetworkAttributes object.
         * @return The built NetworkAttributes object.
         */
         */
        public NetworkAttributes build() {
        public NetworkAttributes build() {
            return new NetworkAttributes(mAssignedAddress, mAssignedAddressExpiry,
            return new NetworkAttributes(mAssignedAddress, mAssignedAddressExpiry,
                    mCluster, mDnsAddresses, mMtu, mIpv6ProvLossQuirk);
                    mCluster, mDnsAddresses, mMtu);
        }
        }
    }
    }


    /** @hide */
    /** @hide */
    public boolean isEmpty() {
    public boolean isEmpty() {
        return (null == assignedV4Address) && (null == assignedV4AddressExpiry)
        return (null == assignedV4Address) && (null == assignedV4AddressExpiry)
                && (null == cluster) && (null == dnsAddresses) && (null == mtu)
                && (null == cluster) && (null == dnsAddresses) && (null == mtu);
                && (null == ipv6ProvLossQuirk);
    }
    }


    @Override
    @Override
@@ -352,14 +321,13 @@ public class NetworkAttributes {
                && Objects.equals(assignedV4AddressExpiry, other.assignedV4AddressExpiry)
                && Objects.equals(assignedV4AddressExpiry, other.assignedV4AddressExpiry)
                && Objects.equals(cluster, other.cluster)
                && Objects.equals(cluster, other.cluster)
                && Objects.equals(dnsAddresses, other.dnsAddresses)
                && Objects.equals(dnsAddresses, other.dnsAddresses)
                && Objects.equals(mtu, other.mtu)
                && Objects.equals(mtu, other.mtu);
                && Objects.equals(ipv6ProvLossQuirk, other.ipv6ProvLossQuirk);
    }
    }


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(assignedV4Address, assignedV4AddressExpiry,
        return Objects.hash(assignedV4Address, assignedV4AddressExpiry,
                cluster, dnsAddresses, mtu, ipv6ProvLossQuirk);
                cluster, dnsAddresses, mtu);
    }
    }


    /** Pretty print */
    /** Pretty print */
@@ -406,14 +374,6 @@ public class NetworkAttributes {
            nullFields.add("mtu");
            nullFields.add("mtu");
        }
        }


        if (null != ipv6ProvLossQuirk) {
            resultJoiner.add("ipv6ProvLossQuirk : [");
            resultJoiner.add(ipv6ProvLossQuirk.toString());
            resultJoiner.add("]");
        } else {
            nullFields.add("ipv6ProvLossQuirk");
        }

        if (!nullFields.isEmpty()) {
        if (!nullFields.isEmpty()) {
            resultJoiner.add("; Null fields : [");
            resultJoiner.add("; Null fields : [");
            for (final String field : nullFields) {
            for (final String field : nullFields) {
+0 −2
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ package android.net.ipmemorystore;
// Blob[] is used to represent an array of byte[], as structured AIDL does not support arrays
// Blob[] is used to represent an array of byte[], as structured AIDL does not support arrays
// of arrays.
// of arrays.
import android.net.ipmemorystore.Blob;
import android.net.ipmemorystore.Blob;
import android.net.quirks.IPv6ProvisioningLossQuirkParcelable;


/**
/**
 * An object to represent attributes of a single L2 network entry.
 * An object to represent attributes of a single L2 network entry.
@@ -35,5 +34,4 @@ parcelable NetworkAttributesParcelable {
    String cluster;
    String cluster;
    Blob[] dnsAddresses;
    Blob[] dnsAddresses;
    int mtu;
    int mtu;
    @nullable IPv6ProvisioningLossQuirkParcelable ipv6ProvLossQuirk;
}
}
Loading