Make BaseNetworkObserver available to core code
Currently BaseNetworkObserver is in frameworks/base/services, but
there is code in frameworks/base/core that could use it. This
code typically extends INetworkManagementEventObserver.stub
because BaseNetworkObserver is not available.
Move BaseNetworkObserver to frameworks/base/core without changing
its package name, and use it to simplify two callers. The third
caller, Tethering, is much larger, and I'm not sure it's
appropriate to change it.
Bug: 10232006
Change-Id: Ifc0f2e619e3424e27e35730c048a1cc523df345e
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 7999c66..d08ba6e 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -27,6 +27,8 @@
import android.os.ServiceManager;
import android.util.Log;
+import com.android.server.net.BaseNetworkObserver;
+
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -62,7 +64,7 @@
private INetworkManagementService mNMService;
- private static class InterfaceObserver extends INetworkManagementEventObserver.Stub {
+ private static class InterfaceObserver extends BaseNetworkObserver {
private EthernetDataTracker mTracker;
InterfaceObserver(EthernetDataTracker tracker) {
@@ -70,10 +72,12 @@
mTracker = tracker;
}
+ @Override
public void interfaceStatusChanged(String iface, boolean up) {
Log.d(TAG, "Interface status changed: " + iface + (up ? "up" : "down"));
}
+ @Override
public void interfaceLinkStateChanged(String iface, boolean up) {
if (mIface.equals(iface)) {
Log.d(TAG, "Interface " + iface + " link " + (up ? "up" : "down"));
@@ -89,21 +93,15 @@
}
}
+ @Override
public void interfaceAdded(String iface) {
mTracker.interfaceAdded(iface);
}
+ @Override
public void interfaceRemoved(String iface) {
mTracker.interfaceRemoved(iface);
}
-
- public void limitReached(String limitName, String iface) {
- // Ignored.
- }
-
- public void interfaceClassDataActivityChanged(String label, boolean active) {
- // Ignored.
- }
}
private EthernetDataTracker() {
diff --git a/services/java/com/android/server/net/BaseNetworkObserver.java b/core/java/com/android/server/net/BaseNetworkObserver.java
similarity index 100%
rename from services/java/com/android/server/net/BaseNetworkObserver.java
rename to core/java/com/android/server/net/BaseNetworkObserver.java
diff --git a/services/java/com/android/server/CommonTimeManagementService.java b/services/java/com/android/server/CommonTimeManagementService.java
index aa2c8b8..710fb9d 100644
--- a/services/java/com/android/server/CommonTimeManagementService.java
+++ b/services/java/com/android/server/CommonTimeManagementService.java
@@ -40,6 +40,8 @@
import android.os.SystemProperties;
import android.util.Log;
+import com.android.server.net.BaseNetworkObserver;
+
/**
* @hide
* <p>CommonTimeManagementService manages the configuration of the native Common Time service,
@@ -104,9 +106,7 @@
/*
* Callback handler implementations.
*/
- private INetworkManagementEventObserver mIfaceObserver =
- new INetworkManagementEventObserver.Stub() {
-
+ private INetworkManagementEventObserver mIfaceObserver = new BaseNetworkObserver() {
public void interfaceStatusChanged(String iface, boolean up) {
reevaluateServiceState();
}
@@ -119,9 +119,6 @@
public void interfaceRemoved(String iface) {
reevaluateServiceState();
}
- public void limitReached(String limitName, String iface) { }
-
- public void interfaceClassDataActivityChanged(String label, boolean active) {}
};
private BroadcastReceiver mConnectivityMangerObserver = new BroadcastReceiver() {