1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server; 18 19 import android.net.LinkAddress; 20 import android.net.RouteInfo; 21 22 /** 23 * Observer for network events, to use with {@link NetworkObserverRegistry}. 24 */ 25 public interface NetworkObserver { 26 27 /** 28 * @see android.net.INetdUnsolicitedEventListener#onInterfaceChanged(java.lang.String, boolean) 29 */ onInterfaceChanged(String ifName, boolean up)30 default void onInterfaceChanged(String ifName, boolean up) {} 31 32 /** 33 * @see android.net.INetdUnsolicitedEventListener#onInterfaceRemoved(String) 34 */ onInterfaceRemoved(String ifName)35 default void onInterfaceRemoved(String ifName) {} 36 37 /** 38 * @see android.net.INetdUnsolicitedEventListener 39 * #onInterfaceAddressUpdated(String, String, int, int) 40 */ onInterfaceAddressUpdated(LinkAddress address, String ifName)41 default void onInterfaceAddressUpdated(LinkAddress address, String ifName) {} 42 43 /** 44 * @see android.net.INetdUnsolicitedEventListener 45 * #onInterfaceAddressRemoved(String, String, int, int) 46 */ onInterfaceAddressRemoved(LinkAddress address, String ifName)47 default void onInterfaceAddressRemoved(LinkAddress address, String ifName) {} 48 49 /** 50 * @see android.net.INetdUnsolicitedEventListener#onInterfaceLinkStateChanged(String, boolean) 51 */ onInterfaceLinkStateChanged(String ifName, boolean up)52 default void onInterfaceLinkStateChanged(String ifName, boolean up) {} 53 54 /** 55 * @see android.net.INetdUnsolicitedEventListener#onInterfaceAdded(String) 56 */ onInterfaceAdded(String ifName)57 default void onInterfaceAdded(String ifName) {} 58 59 /** 60 * @see android.net.INetdUnsolicitedEventListener 61 * #onInterfaceClassActivityChanged(boolean, int, long, int) 62 */ onInterfaceClassActivityChanged( boolean isActive, int label, long timestamp, int uid)63 default void onInterfaceClassActivityChanged( 64 boolean isActive, int label, long timestamp, int uid) {} 65 66 /** 67 * @see android.net.INetdUnsolicitedEventListener#onQuotaLimitReached(String, String) 68 */ onQuotaLimitReached(String alertName, String ifName)69 default void onQuotaLimitReached(String alertName, String ifName) {} 70 71 /** 72 * @see android.net.INetdUnsolicitedEventListener 73 * #onInterfaceDnsServerInfo(String, long, String[]) 74 */ onInterfaceDnsServerInfo(String ifName, long lifetime, String[] servers)75 default void onInterfaceDnsServerInfo(String ifName, long lifetime, String[] servers) {} 76 77 /** 78 * @see android.net.INetdUnsolicitedEventListener 79 * #onRouteChanged(boolean, String, String, String) 80 */ onRouteUpdated(RouteInfo route)81 default void onRouteUpdated(RouteInfo route) {} 82 83 /** 84 * @see android.net.INetdUnsolicitedEventListener 85 * #onRouteChanged(boolean, String, String, String) 86 */ onRouteRemoved(RouteInfo route)87 default void onRouteRemoved(RouteInfo route) {} 88 } 89