Merge "Add INetd to SystemServiceRegistry" am: e3f18bd77c

am: 9268c0be32

Change-Id: I92cd23a587ab0f7df2db92918011a9a488c31668
This commit is contained in:
Remi NGUYEN VAN
2019-01-28 00:47:45 -08:00
committed by android-build-merger
4 changed files with 22 additions and 2 deletions

View File

@@ -839,6 +839,7 @@ package android.content {
field public static final String CONTEXTHUB_SERVICE = "contexthub";
field public static final String EUICC_CARD_SERVICE = "euicc_card";
field public static final String HDMI_CONTROL_SERVICE = "hdmi_control";
field public static final String NETD_SERVICE = "netd";
field public static final String NETWORK_SCORE_SERVICE = "network_score";
field public static final String OEM_LOCK_SERVICE = "oem_lock";
field public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block";

View File

@@ -84,6 +84,7 @@ import android.net.IConnectivityManager;
import android.net.IEthernetManager;
import android.net.IIpMemoryStore;
import android.net.IIpSecService;
import android.net.INetd;
import android.net.INetworkPolicyManager;
import android.net.IpMemoryStore;
import android.net.IpSecManager;
@@ -288,6 +289,14 @@ final class SystemServiceRegistry {
return new ConnectivityManager(context, service);
}});
registerService(Context.NETD_SERVICE, INetd.class, new StaticServiceFetcher<INetd>() {
@Override
public INetd createService() throws ServiceNotFoundException {
return INetd.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.NETD_SERVICE));
}
});
registerService(Context.NETWORK_STACK_SERVICE, NetworkStack.class,
new StaticServiceFetcher<NetworkStack>() {
@Override

View File

@@ -3504,6 +3504,16 @@ public abstract class Context {
*/
public static final String CONNECTIVITY_SERVICE = "connectivity";
/**
* Use with {@link #getSystemService(String)} to retrieve a
* {@link android.net.INetd} for communicating with the network stack
* @hide
* @see #getSystemService(String)
* @hide
*/
@SystemApi
public static final String NETD_SERVICE = "netd";
/**
* Use with {@link #getSystemService(String)} to retrieve a
* {@link NetworkStack} for communicating with the network stack

View File

@@ -16,6 +16,7 @@
package android.net.shared;
import android.content.Context;
import android.net.INetd;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -28,7 +29,6 @@ import android.util.Log;
*/
public class NetdService {
private static final String TAG = NetdService.class.getSimpleName();
private static final String NETD_SERVICE_NAME = "netd";
private static final long BASE_TIMEOUT_MS = 100;
private static final long MAX_TIMEOUT_MS = 1000;
@@ -48,7 +48,7 @@ public class NetdService {
// NOTE: ServiceManager does no caching for the netd service,
// because netd is not one of the defined common services.
final INetd netdInstance = INetd.Stub.asInterface(
ServiceManager.getService(NETD_SERVICE_NAME));
ServiceManager.getService(Context.NETD_SERVICE));
if (netdInstance == null) {
Log.w(TAG, "WARNING: returning null INetd instance.");
}