Loading core/java/android/net/INetworkManagementEventObserver.aidl +21 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,27 @@ interface INetworkManagementEventObserver { */ void interfaceRemoved(String iface); /** * An interface address has been added or updated * * @param address The address. * @param iface The interface. * @param flags The address flags. * @param scope The address scope. */ void addressUpdated(String address, String iface, int flags, int scope); /** * An interface address has been removed * * @param address The address. * @param iface The interface. * @param flags The address flags. * @param scope The address scope. */ void addressRemoved(String address, String iface, int flags, int scope); /** * A networking quota limit has been reached. The quota might not * be specific to an interface. Loading core/java/com/android/server/net/BaseNetworkObserver.java +10 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,16 @@ public class BaseNetworkObserver extends INetworkManagementEventObserver.Stub { // default no-op } @Override public void addressUpdated(String address, String iface, int flags, int scope) { // default no-op } @Override public void addressRemoved(String address, String iface, int flags, int scope) { // default no-op } @Override public void interfaceLinkStateChanged(String iface, boolean up) { // default no-op Loading services/java/com/android/server/NetworkManagementService.java +57 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final int InterfaceChange = 600; public static final int BandwidthControl = 601; public static final int InterfaceClassActivity = 613; public static final int InterfaceAddressChange = 614; } /** Loading Loading @@ -393,6 +394,36 @@ public class NetworkManagementService extends INetworkManagementService.Stub setFirewallEnabled(mFirewallEnabled || LockdownVpnTracker.isEnabled()); } /** * Notify our observers of a new or updated interface address. */ private void notifyAddressUpdated(String address, String iface, int flags, int scope) { final int length = mObservers.beginBroadcast(); for (int i = 0; i < length; i++) { try { mObservers.getBroadcastItem(i).addressUpdated(address, iface, flags, scope); } catch (RemoteException e) { } catch (RuntimeException e) { } } mObservers.finishBroadcast(); } /** * Notify our observers of a deleted interface address. */ private void notifyAddressRemoved(String address, String iface, int flags, int scope) { final int length = mObservers.beginBroadcast(); for (int i = 0; i < length; i++) { try { mObservers.getBroadcastItem(i).addressRemoved(address, iface, flags, scope); } catch (RemoteException e) { } catch (RuntimeException e) { } } mObservers.finishBroadcast(); } // // Netd Callback handling // Loading Loading @@ -475,6 +506,32 @@ public class NetworkManagementService extends INetworkManagementService.Stub notifyInterfaceClassActivity(cooked[3], isActive); return true; // break; case NetdResponseCode.InterfaceAddressChange: /* * A network address change occurred * Format: "NNN Address updated <addr> <iface> <flags> <scope>" * "NNN Address removed <addr> <iface> <flags> <scope>" */ String msg = String.format("Invalid event from daemon (%s)", raw); if (cooked.length < 6 || !cooked[1].equals("Address")) { throw new IllegalStateException(msg); } int flags, scope; try { flags = Integer.parseInt(cooked[5]); scope = Integer.parseInt(cooked[6]); } catch(NumberFormatException e) { throw new IllegalStateException(msg); } if (cooked[2].equals("updated")) { notifyAddressUpdated(cooked[3], cooked[4], flags, scope); } else { notifyAddressRemoved(cooked[3], cooked[4], flags, scope); } return true; // break; default: break; } return false; Loading services/java/com/android/server/connectivity/Tethering.java +4 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,10 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } public void addressUpdated(String address, String iface, int flags, int scope) {} public void addressRemoved(String address, String iface, int flags, int scope) {} public void limitReached(String limitName, String iface) {} public void interfaceClassDataActivityChanged(String label, boolean active) {} Loading Loading
core/java/android/net/INetworkManagementEventObserver.aidl +21 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,27 @@ interface INetworkManagementEventObserver { */ void interfaceRemoved(String iface); /** * An interface address has been added or updated * * @param address The address. * @param iface The interface. * @param flags The address flags. * @param scope The address scope. */ void addressUpdated(String address, String iface, int flags, int scope); /** * An interface address has been removed * * @param address The address. * @param iface The interface. * @param flags The address flags. * @param scope The address scope. */ void addressRemoved(String address, String iface, int flags, int scope); /** * A networking quota limit has been reached. The quota might not * be specific to an interface. Loading
core/java/com/android/server/net/BaseNetworkObserver.java +10 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,16 @@ public class BaseNetworkObserver extends INetworkManagementEventObserver.Stub { // default no-op } @Override public void addressUpdated(String address, String iface, int flags, int scope) { // default no-op } @Override public void addressRemoved(String address, String iface, int flags, int scope) { // default no-op } @Override public void interfaceLinkStateChanged(String iface, boolean up) { // default no-op Loading
services/java/com/android/server/NetworkManagementService.java +57 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final int InterfaceChange = 600; public static final int BandwidthControl = 601; public static final int InterfaceClassActivity = 613; public static final int InterfaceAddressChange = 614; } /** Loading Loading @@ -393,6 +394,36 @@ public class NetworkManagementService extends INetworkManagementService.Stub setFirewallEnabled(mFirewallEnabled || LockdownVpnTracker.isEnabled()); } /** * Notify our observers of a new or updated interface address. */ private void notifyAddressUpdated(String address, String iface, int flags, int scope) { final int length = mObservers.beginBroadcast(); for (int i = 0; i < length; i++) { try { mObservers.getBroadcastItem(i).addressUpdated(address, iface, flags, scope); } catch (RemoteException e) { } catch (RuntimeException e) { } } mObservers.finishBroadcast(); } /** * Notify our observers of a deleted interface address. */ private void notifyAddressRemoved(String address, String iface, int flags, int scope) { final int length = mObservers.beginBroadcast(); for (int i = 0; i < length; i++) { try { mObservers.getBroadcastItem(i).addressRemoved(address, iface, flags, scope); } catch (RemoteException e) { } catch (RuntimeException e) { } } mObservers.finishBroadcast(); } // // Netd Callback handling // Loading Loading @@ -475,6 +506,32 @@ public class NetworkManagementService extends INetworkManagementService.Stub notifyInterfaceClassActivity(cooked[3], isActive); return true; // break; case NetdResponseCode.InterfaceAddressChange: /* * A network address change occurred * Format: "NNN Address updated <addr> <iface> <flags> <scope>" * "NNN Address removed <addr> <iface> <flags> <scope>" */ String msg = String.format("Invalid event from daemon (%s)", raw); if (cooked.length < 6 || !cooked[1].equals("Address")) { throw new IllegalStateException(msg); } int flags, scope; try { flags = Integer.parseInt(cooked[5]); scope = Integer.parseInt(cooked[6]); } catch(NumberFormatException e) { throw new IllegalStateException(msg); } if (cooked[2].equals("updated")) { notifyAddressUpdated(cooked[3], cooked[4], flags, scope); } else { notifyAddressRemoved(cooked[3], cooked[4], flags, scope); } return true; // break; default: break; } return false; Loading
services/java/com/android/server/connectivity/Tethering.java +4 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,10 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } public void addressUpdated(String address, String iface, int flags, int scope) {} public void addressRemoved(String address, String iface, int flags, int scope) {} public void limitReached(String limitName, String iface) {} public void interfaceClassDataActivityChanged(String label, boolean active) {} Loading