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

Commit a4bc6bae authored by Pavel Grafov's avatar Pavel Grafov Committed by android-build-merger
Browse files

Merge "Use InetAddress instead of String in network events." into oc-dev am: 54e534d6

am: c3ae946f

Change-Id: If08ae7a4eed5d56c02c0d67a3d3fcffe46f982b5
parents 8460abaf c3ae946f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -6205,7 +6205,7 @@ package android.app {
package android.app.admin {
  public final class ConnectEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getIpAddress();
    method public java.net.InetAddress getInetAddress();
    method public int getPort();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.ConnectEvent> CREATOR;
@@ -6550,8 +6550,8 @@ package android.app.admin {
  public final class DnsEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getHostname();
    method public java.lang.String[] getIpAddresses();
    method public int getIpAddressesCount();
    method public java.net.InetAddress[] getInetAddresses();
    method public int getTotalResolvedAddressCount();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.DnsEvent> CREATOR;
  }
+3 −3
Original line number Diff line number Diff line
@@ -6419,7 +6419,7 @@ package android.app {
package android.app.admin {
  public final class ConnectEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getIpAddress();
    method public java.net.InetAddress getInetAddress();
    method public int getPort();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.ConnectEvent> CREATOR;
@@ -6799,8 +6799,8 @@ package android.app.admin {
  public final class DnsEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getHostname();
    method public java.lang.String[] getIpAddresses();
    method public int getIpAddressesCount();
    method public java.net.InetAddress[] getInetAddresses();
    method public int getTotalResolvedAddressCount();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.DnsEvent> CREATOR;
  }
+3 −3
Original line number Diff line number Diff line
@@ -6225,7 +6225,7 @@ package android.app {
package android.app.admin {
  public final class ConnectEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getIpAddress();
    method public java.net.InetAddress getInetAddress();
    method public int getPort();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.ConnectEvent> CREATOR;
@@ -6580,8 +6580,8 @@ package android.app.admin {
  public final class DnsEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
    method public java.lang.String getHostname();
    method public java.lang.String[] getIpAddresses();
    method public int getIpAddressesCount();
    method public java.net.InetAddress[] getInetAddresses();
    method public int getTotalResolvedAddressCount();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.admin.DnsEvent> CREATOR;
  }
+11 −2
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package android.app.admin;
import android.os.Parcel;
import android.os.Parcelable;

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

/**
 * A class that represents a connect library call event.
 */
@@ -44,8 +47,14 @@ public final class ConnectEvent extends NetworkEvent implements Parcelable {
        this.timestamp = in.readLong();
    }

    public String getIpAddress() {
        return ipAddress;
    public InetAddress getInetAddress() {
        try {
            // ipAddress is already an address, not a host name, no DNS resolution will happen.
            return InetAddress.getByName(ipAddress);
        } catch (UnknownHostException e) {
            // Should never happen as we aren't passing a host name.
            return InetAddress.getLoopbackAddress();
        }
    }

    public int getPort() {
+19 −4
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package android.app.admin;
import android.os.Parcel;
import android.os.Parcelable;

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

/**
 * A class that represents a DNS lookup event.
 */
@@ -59,15 +62,27 @@ public final class DnsEvent extends NetworkEvent implements Parcelable {
    }

    /** Returns (possibly a subset of) the IP addresses returned. */
    public String[] getIpAddresses() {
        return ipAddresses;
    public InetAddress[] getInetAddresses() {
        final int length = ipAddresses != null ? ipAddresses.length : 0;
        final InetAddress[] inetAddresses = new InetAddress[length];
        for (int i = 0; i < length; i++) {
            try {
                // ipAddress is already an address, not a host name, no DNS resolution will happen.
                inetAddresses[i] = InetAddress.getByName(ipAddresses[i]);
            } catch (UnknownHostException e) {
                // Should never happen as we aren't passing a host name.
                inetAddresses[i] = InetAddress.getLoopbackAddress();
            }
        }
        return inetAddresses;
    }

    /**
     * Returns the number of IP addresses returned from the DNS lookup event. May be different from
     * the length of ipAddresses if there were too many addresses to log.
     * the length of the array returned by {@link #getInetAddresses()} if there were too many
     * addresses to log.
     */
    public int getIpAddressesCount() {
    public int getTotalResolvedAddressCount() {
        return ipAddressesCount;
    }

Loading