import android.os.Parcelable;
/**
- * An event recorded by DnsEventListenerService.
+ * A DNS event recorded by NetdEventListenerService.
* {@hide}
*/
@SystemApi
java/com/android/server/EventLogTags.logtags \
java/com/android/server/am/EventLogTags.logtags \
../../../../system/netd/server/binder/android/net/INetd.aidl \
- ../../../../system/netd/server/binder/android/net/metrics/IDnsEventListener.aidl \
+ ../../../../system/netd/server/binder/android/net/metrics/INetdEventListener.aidl \
LOCAL_AIDL_INCLUDES += \
system/netd/server/binder
@VisibleForTesting
public final Impl impl = new Impl();
- private DnsEventListenerService mDnsListener;
+ private NetdEventListenerService mNetdListener;
@GuardedBy("mLock")
private ArrayList<ConnectivityMetricsEvent> mBuffer;
public void onBootPhase(int phase) {
if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
if (DBG) Log.d(TAG, "onBootPhase");
- mDnsListener = new DnsEventListenerService(getContext());
+ mNetdListener = new NetdEventListenerService(getContext());
publishBinderService(SERVICE_NAME, impl);
- publishBinderService(mDnsListener.SERVICE_NAME, mDnsListener);
+ publishBinderService(mNetdListener.SERVICE_NAME, mNetdListener);
}
}
pw.println("Buffer capacity: " + mCapacity);
pw.println("Dropped events: " + mDropped);
}
- if (mDnsListener != null) {
- mDnsListener.dump(pw);
+ if (mNetdListener != null) {
+ mNetdListener.dump(pw);
}
}
import android.net.Network;
import android.net.NetworkRequest;
import android.net.metrics.DnsEvent;
-import android.net.metrics.IDnsEventListener;
+import android.net.metrics.INetdEventListener;
import android.net.metrics.IpConnectivityLog;
import android.util.Log;
/**
- * Implementation of the IDnsEventListener interface.
+ * Implementation of the INetdEventListener interface.
*/
-public class DnsEventListenerService extends IDnsEventListener.Stub {
+public class NetdEventListenerService extends INetdEventListener.Stub {
- public static final String SERVICE_NAME = "dns_listener";
+ public static final String SERVICE_NAME = "netd_listener";
- private static final String TAG = DnsEventListenerService.class.getSimpleName();
+ private static final String TAG = NetdEventListenerService.class.getSimpleName();
private static final boolean DBG = true;
private static final boolean VDBG = false;
private final NetworkCallback mNetworkCallback = new NetworkCallback() {
@Override
public void onLost(Network network) {
- synchronized (DnsEventListenerService.this) {
+ synchronized (NetdEventListenerService.this) {
DnsEventBatch batch = mEventBatches.remove(network.netId);
if (batch != null) {
batch.logAndClear();
}
};
- public DnsEventListenerService(Context context) {
+ public NetdEventListenerService(Context context) {
this(context.getSystemService(ConnectivityManager.class), new IpConnectivityLog());
}
@VisibleForTesting
- public DnsEventListenerService(ConnectivityManager cm, IpConnectivityLog log) {
+ public NetdEventListenerService(ConnectivityManager cm, IpConnectivityLog log) {
// We are started when boot is complete, so ConnectivityService should already be running.
mCm = cm;
mMetricsLog = log;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.metrics.DnsEvent;
-import android.net.metrics.IDnsEventListener;
+import android.net.metrics.INetdEventListener;
import android.net.metrics.IpConnectivityLog;
import junit.framework.TestCase;
import java.util.OptionalInt;
import java.util.stream.IntStream;
-public class DnsEventListenerServiceTest extends TestCase {
+public class NetdEventListenerServiceTest extends TestCase {
- // TODO: read from DnsEventListenerService after this constant is read from system property
+ // TODO: read from NetdEventListenerService after this constant is read from system property
static final int BATCH_SIZE = 100;
- static final int EVENT_TYPE = IDnsEventListener.EVENT_GETADDRINFO;
- // TODO: read from IDnsEventListener
+ static final int EVENT_TYPE = INetdEventListener.EVENT_GETADDRINFO;
+ // TODO: read from INetdEventListener
static final int RETURN_CODE = 1;
static final byte[] EVENT_TYPES = new byte[BATCH_SIZE];
}
}
- DnsEventListenerService mDnsService;
+ NetdEventListenerService mNetdEventListenerService;
@Mock ConnectivityManager mCm;
@Mock IpConnectivityLog mLog;
MockitoAnnotations.initMocks(this);
mCallbackCaptor = ArgumentCaptor.forClass(NetworkCallback.class);
mEvCaptor = ArgumentCaptor.forClass(DnsEvent.class);
- mDnsService = new DnsEventListenerService(mCm, mLog);
+ mNetdEventListenerService = new NetdEventListenerService(mCm, mLog);
verify(mCm, times(1)).registerNetworkCallback(any(), mCallbackCaptor.capture());
}
new Thread() {
public void run() {
while (System.currentTimeMillis() < stop) {
- mDnsService.dump(pw);
+ mNetdEventListenerService.dump(pw);
}
}
}.start();
void log(int netId, int[] latencies) {
for (int l : latencies) {
- mDnsService.onDnsEvent(netId, EVENT_TYPE, RETURN_CODE, l);
+ mNetdEventListenerService.onDnsEvent(netId, EVENT_TYPE, RETURN_CODE, l);
}
}