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

Commit 75bba8c7 authored by Xiao Ma's avatar Xiao Ma
Browse files

Rename package name of IPv6ProvisioningLossQuirkParcelable.

Move new added IPv6ProvisioningLossQuirkParcelable.aidl to new
directory android/net/networkstack/aidl, also change the package
name to clearly identify AIDL classes.

Also lengthen the variable name inside NetworkAttributesParcelable
to ipv6ProvisioningLossQuirk.

Bug: 157534516
Test: atest NetworkStackTests
Change-Id: Ie2e0eb8078244a469a95ddeab6a933290ae1bcb3
parent 130d40d9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ aidl_interface {
        "src/android/net/IIpMemoryStore.aidl",
        "src/android/net/IIpMemoryStoreCallbacks.aidl",
        "src/android/net/ipmemorystore/**/*.aidl",
        "src/android/net/quirks/IPv6ProvisioningLossQuirkParcelable.aidl",
        // New AIDL classes should go into android.net.networkstack.aidl so they can be clearly
        // identified
        "src/android/net/networkstack/aidl/quirks/IPv6ProvisioningLossQuirkParcelable.aidl",
    ],
    backend: {
        java: {
@@ -138,7 +140,7 @@ java_library {
        "src/android/net/IpMemoryStoreClient.java",
        "src/android/net/ipmemorystore/**/*.java",
        "src/android/net/networkstack/**/*.java",
        "src/android/net/quirks/**/*.java",
        "src/android/net/networkstack/aidl/quirks/**/*.java",
        "src/android/net/shared/**/*.java",
    ],
    static_libs: [
+1 −1
Original line number Diff line number Diff line
@@ -23,5 +23,5 @@ parcelable NetworkAttributesParcelable {
  String cluster;
  android.net.ipmemorystore.Blob[] dnsAddresses;
  int mtu;
  @nullable android.net.quirks.IPv6ProvisioningLossQuirkParcelable ipv6ProvLossQuirk;
  @nullable android.net.networkstack.aidl.quirks.IPv6ProvisioningLossQuirkParcelable ipv6ProvisioningLossQuirk;
}
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
// 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;
package android.net.networkstack.aidl.quirks;
parcelable IPv6ProvisioningLossQuirkParcelable {
  int detectionCount;
  long quirkExpiry;
+18 −17
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.net.ipmemorystore;

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

import com.android.internal.annotations.VisibleForTesting;

@@ -86,7 +86,7 @@ public class NetworkAttributes {

    // IPv6 provisioning quirk info about this network, if applicable.
    @Nullable
    public final IPv6ProvisioningLossQuirk ipv6ProvLossQuirk;
    public final IPv6ProvisioningLossQuirk ipv6ProvisioningLossQuirk;
    // 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;
@@ -110,7 +110,7 @@ public class NetworkAttributes {
            @Nullable final String cluster,
            @Nullable final List<InetAddress> dnsAddresses,
            @Nullable final Integer mtu,
            @Nullable final IPv6ProvisioningLossQuirk ipv6ProvLossQuirk) {
            @Nullable final IPv6ProvisioningLossQuirk ipv6ProvisioningLossQuirk) {
        if (mtu != null && mtu < 0) throw new IllegalArgumentException("MTU can't be negative");
        if (assignedV4AddressExpiry != null && assignedV4AddressExpiry <= 0) {
            throw new IllegalArgumentException("lease expiry can't be negative or zero");
@@ -121,7 +121,7 @@ public class NetworkAttributes {
        this.dnsAddresses = null == dnsAddresses ? null :
                Collections.unmodifiableList(new ArrayList<>(dnsAddresses));
        this.mtu = mtu;
        this.ipv6ProvLossQuirk = ipv6ProvLossQuirk;
        this.ipv6ProvisioningLossQuirk = ipv6ProvisioningLossQuirk;
    }

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

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

@@ -206,8 +207,8 @@ public class NetworkAttributes {
                + samenessContribution(WEIGHT_CLUSTER, cluster, o.cluster)
                + samenessContribution(WEIGHT_DNSADDRESSES, dnsAddresses, o.dnsAddresses)
                + samenessContribution(WEIGHT_MTU, mtu, o.mtu)
                + samenessContribution(WEIGHT_V6PROVLOSSQUIRK, ipv6ProvLossQuirk,
                      o.ipv6ProvLossQuirk);
                + samenessContribution(WEIGHT_V6PROVLOSSQUIRK, ipv6ProvisioningLossQuirk,
                      o.ipv6ProvisioningLossQuirk);
        // 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 would be half of TOTAL_WEIGHT (indeed, it should not be).
@@ -250,7 +251,7 @@ public class NetworkAttributes {
            mCluster = attributes.cluster;
            mDnsAddresses = new ArrayList<>(attributes.dnsAddresses);
            mMtu = attributes.mtu;
            mIpv6ProvLossQuirk = attributes.ipv6ProvLossQuirk;
            mIpv6ProvLossQuirk = attributes.ipv6ProvisioningLossQuirk;
        }

        /**
@@ -341,7 +342,7 @@ public class NetworkAttributes {
    public boolean isEmpty() {
        return (null == assignedV4Address) && (null == assignedV4AddressExpiry)
                && (null == cluster) && (null == dnsAddresses) && (null == mtu)
                && (null == ipv6ProvLossQuirk);
                && (null == ipv6ProvisioningLossQuirk);
    }

    @Override
@@ -353,13 +354,13 @@ public class NetworkAttributes {
                && Objects.equals(cluster, other.cluster)
                && Objects.equals(dnsAddresses, other.dnsAddresses)
                && Objects.equals(mtu, other.mtu)
                && Objects.equals(ipv6ProvLossQuirk, other.ipv6ProvLossQuirk);
                && Objects.equals(ipv6ProvisioningLossQuirk, other.ipv6ProvisioningLossQuirk);
    }

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

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

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

        if (!nullFields.isEmpty()) {
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package android.net.ipmemorystore;
// Blob[] is used to represent an array of byte[], as structured AIDL does not support arrays
// of arrays.
import android.net.ipmemorystore.Blob;
import android.net.quirks.IPv6ProvisioningLossQuirkParcelable;
import android.net.networkstack.aidl.quirks.IPv6ProvisioningLossQuirkParcelable;

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