/* * Copyright (C) 2016 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.app.admin; import android.os.Parcel; import android.os.Parcelable; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * A class that represents a DNS lookup event initiated through the standard network stack. * *
It contains information about the originating app as well as the DNS hostname and resolved
* IP addresses.
*/
public final class DnsEvent extends NetworkEvent implements Parcelable {
/** The hostname that was looked up. */
private final String mHostname;
/** Contains (possibly a subset of) the IP addresses returned. */
private final String[] mIpAddresses;
/**
* 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.
*/
private final int mIpAddressesCount;
/** @hide */
public DnsEvent(String hostname, String[] ipAddresses, int ipAddressesCount,
String packageName, long timestamp) {
super(packageName, timestamp);
this.mHostname = hostname;
this.mIpAddresses = ipAddresses;
this.mIpAddressesCount = ipAddressesCount;
}
private DnsEvent(Parcel in) {
this.mHostname = in.readString();
this.mIpAddresses = in.createStringArray();
this.mIpAddressesCount = in.readInt();
this.mPackageName = in.readString();
this.mTimestamp = in.readLong();
this.mId = in.readLong();
}
/** Returns the hostname that was looked up. */
public String getHostname() {
return mHostname;
}
/** Returns (possibly a subset of) the IP addresses returned. */
public List