Loading services/core/java/com/android/server/connectivity/tethering/IPv6TetheringInterfaceServices.java +2 −13 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.net.NetworkState; import android.net.RouteInfo; import android.net.ip.RouterAdvertisementDaemon; import android.net.ip.RouterAdvertisementDaemon.RaParams; import android.net.util.NetdService; import android.os.INetworkManagementService; import android.os.ServiceSpecificException; import android.os.RemoteException; Loading Loading @@ -193,7 +194,7 @@ class IPv6TetheringInterfaceServices { private void configureLocalDns( HashSet<Inet6Address> deprecatedDnses, HashSet<Inet6Address> newDnses) { INetd netd = getNetdServiceOrNull(); final INetd netd = NetdService.getInstance(); if (netd == null) { if (newDnses != null) newDnses.clear(); Log.e(TAG, "No netd service instance available; not setting local IPv6 addresses"); Loading Loading @@ -265,18 +266,6 @@ class IPv6TetheringInterfaceServices { return localRoutes; } private INetd getNetdServiceOrNull() { if (mNMService != null) { try { return mNMService.getNetdService(); } catch (RemoteException ignored) { // This blocks until netd can be reached, but it can return // null during a netd crash. } } return null; } // Given a prefix like 2001:db8::/64 return 2001:db8::1. private static Inet6Address getLocalDnsIpFor(IpPrefix localPrefix) { final byte[] dnsBytes = localPrefix.getRawAddress(); Loading services/net/Android.mk +5 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := services.net LOCAL_SRC_FILES += \ $(call all-java-files-under,java) $(call all-java-files-under,java) \ ../../../../system/netd/server/binder/android/net/INetd.aidl LOCAL_AIDL_INCLUDES += \ system/netd/server/binder include $(BUILD_STATIC_JAVA_LIBRARY) services/net/java/android/net/util/NetdService.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.util; import android.net.INetd; import android.os.ServiceManager; import android.util.Log; /** * @hide */ public class NetdService { private static final String TAG = NetdService.class.getSimpleName(); private static final String NETD_SERVICE_NAME = "netd"; /** * It is the caller's responsibility to check for a null return value * and to handle RemoteException errors from invocations on the returned * interface if, for example, netd dies and is restarted. * * @return an INetd instance or null. */ public static INetd getInstance() { final INetd netdInstance = INetd.Stub.asInterface( ServiceManager.getService(NETD_SERVICE_NAME)); if (netdInstance == null) { Log.w(TAG, "WARNING: returning null INetd instance."); } return netdInstance; } } Loading
services/core/java/com/android/server/connectivity/tethering/IPv6TetheringInterfaceServices.java +2 −13 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.net.NetworkState; import android.net.RouteInfo; import android.net.ip.RouterAdvertisementDaemon; import android.net.ip.RouterAdvertisementDaemon.RaParams; import android.net.util.NetdService; import android.os.INetworkManagementService; import android.os.ServiceSpecificException; import android.os.RemoteException; Loading Loading @@ -193,7 +194,7 @@ class IPv6TetheringInterfaceServices { private void configureLocalDns( HashSet<Inet6Address> deprecatedDnses, HashSet<Inet6Address> newDnses) { INetd netd = getNetdServiceOrNull(); final INetd netd = NetdService.getInstance(); if (netd == null) { if (newDnses != null) newDnses.clear(); Log.e(TAG, "No netd service instance available; not setting local IPv6 addresses"); Loading Loading @@ -265,18 +266,6 @@ class IPv6TetheringInterfaceServices { return localRoutes; } private INetd getNetdServiceOrNull() { if (mNMService != null) { try { return mNMService.getNetdService(); } catch (RemoteException ignored) { // This blocks until netd can be reached, but it can return // null during a netd crash. } } return null; } // Given a prefix like 2001:db8::/64 return 2001:db8::1. private static Inet6Address getLocalDnsIpFor(IpPrefix localPrefix) { final byte[] dnsBytes = localPrefix.getRawAddress(); Loading
services/net/Android.mk +5 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := services.net LOCAL_SRC_FILES += \ $(call all-java-files-under,java) $(call all-java-files-under,java) \ ../../../../system/netd/server/binder/android/net/INetd.aidl LOCAL_AIDL_INCLUDES += \ system/netd/server/binder include $(BUILD_STATIC_JAVA_LIBRARY)
services/net/java/android/net/util/NetdService.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.util; import android.net.INetd; import android.os.ServiceManager; import android.util.Log; /** * @hide */ public class NetdService { private static final String TAG = NetdService.class.getSimpleName(); private static final String NETD_SERVICE_NAME = "netd"; /** * It is the caller's responsibility to check for a null return value * and to handle RemoteException errors from invocations on the returned * interface if, for example, netd dies and is restarted. * * @return an INetd instance or null. */ public static INetd getInstance() { final INetd netdInstance = INetd.Stub.asInterface( ServiceManager.getService(NETD_SERVICE_NAME)); if (netdInstance == null) { Log.w(TAG, "WARNING: returning null INetd instance."); } return netdInstance; } }