diff options
author | Remi NGUYEN VAN <reminv@google.com> | 2019-01-28 10:24:42 +0900 |
---|---|---|
committer | Remi NGUYEN VAN <reminv@google.com> | 2019-01-28 14:55:50 +0900 |
commit | 9d3f3c7e85f999da93a4cfc9974e06d5dcd60e17 (patch) | |
tree | 81640716f990a93b4d8ee2d3473d3c648367022e /src/com/android/server/NetworkStackService.java | |
parent | e1f80469fad97019bc2bcfa39dc474bd1b2e8373 (diff) |
Add NetworkObserverRegistry to NetworkStack
The NetworkObserverRegistry will replace usage of
NetworkManagementService in the app.
Test: m, booted, WiFi working
Bug: 112869080
Change-Id: Ic7f0114d0c9361dd2408e47bb04a8dd44a908a47
Diffstat (limited to 'src/com/android/server/NetworkStackService.java')
-rw-r--r-- | src/com/android/server/NetworkStackService.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/server/NetworkStackService.java b/src/com/android/server/NetworkStackService.java index 4080ddf..631ee45 100644 --- a/src/com/android/server/NetworkStackService.java +++ b/src/com/android/server/NetworkStackService.java @@ -29,6 +29,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; +import android.net.INetd; import android.net.INetworkMonitor; import android.net.INetworkMonitorCallbacks; import android.net.INetworkStackConnector; @@ -65,6 +66,7 @@ import java.util.Iterator; */ public class NetworkStackService extends Service { private static final String TAG = NetworkStackService.class.getSimpleName(); + private static NetworkStackConnector sConnector; /** * Create a binder connector for the system server to communicate with the network stack. @@ -72,8 +74,11 @@ public class NetworkStackService extends Service { * <p>On platforms where the network stack runs in the system server process, this method may * be called directly instead of obtaining the connector by binding to the service. */ - public static IBinder makeConnector(Context context) { - return new NetworkStackConnector(context); + public static synchronized IBinder makeConnector(Context context) { + if (sConnector == null) { + sConnector = new NetworkStackConnector(context); + } + return sConnector; } @NonNull @@ -85,6 +90,8 @@ public class NetworkStackService extends Service { private static class NetworkStackConnector extends INetworkStackConnector.Stub { private static final int NUM_VALIDATION_LOG_LINES = 20; private final Context mContext; + private final INetd mNetd; + private final NetworkObserverRegistry mObserverRegistry; private final ConnectivityManager mCm; @GuardedBy("mIpClients") private final ArrayList<WeakReference<IpClient>> mIpClients = new ArrayList<>(); @@ -106,7 +113,11 @@ public class NetworkStackService extends Service { NetworkStackConnector(Context context) { mContext = context; + mNetd = (INetd) context.getSystemService(Context.NETD_SERVICE); + mObserverRegistry = new NetworkObserverRegistry(); mCm = context.getSystemService(ConnectivityManager.class); + + // TODO: call mObserverRegistry here after adding sepolicy changes } @NonNull |