Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31935985 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Add INetd to SystemServiceRegistry

Includes @SystemApi for Context.NETD_SERVICE so system apps (including
the network stack) can obtain the service.

Test: m
Bug: 112869080
Change-Id: Ida63747cd30abb7b3c19559803353eb0e42e6efa
parent 166c3aa0
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -839,6 +839,7 @@ package android.content {
    field public static final String CONTEXTHUB_SERVICE = "contexthub";
    field public static final String CONTEXTHUB_SERVICE = "contexthub";
    field public static final String EUICC_CARD_SERVICE = "euicc_card";
    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 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 NETWORK_SCORE_SERVICE = "network_score";
    field public static final String OEM_LOCK_SERVICE = "oem_lock";
    field public static final String OEM_LOCK_SERVICE = "oem_lock";
    field public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block";
    field public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block";
+9 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ import android.net.IConnectivityManager;
import android.net.IEthernetManager;
import android.net.IEthernetManager;
import android.net.IIpMemoryStore;
import android.net.IIpMemoryStore;
import android.net.IIpSecService;
import android.net.IIpSecService;
import android.net.INetd;
import android.net.INetworkPolicyManager;
import android.net.INetworkPolicyManager;
import android.net.IpMemoryStore;
import android.net.IpMemoryStore;
import android.net.IpSecManager;
import android.net.IpSecManager;
@@ -288,6 +289,14 @@ final class SystemServiceRegistry {
                return new ConnectivityManager(context, service);
                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,
        registerService(Context.NETWORK_STACK_SERVICE, NetworkStack.class,
                new StaticServiceFetcher<NetworkStack>() {
                new StaticServiceFetcher<NetworkStack>() {
                    @Override
                    @Override
+10 −0
Original line number Original line Diff line number Diff line
@@ -3504,6 +3504,16 @@ public abstract class Context {
     */
     */
    public static final String CONNECTIVITY_SERVICE = "connectivity";
    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
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link NetworkStack} for communicating with the network stack
     * {@link NetworkStack} for communicating with the network stack
+2 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.net.shared;
package android.net.shared;


import android.content.Context;
import android.net.INetd;
import android.net.INetd;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
@@ -28,7 +29,6 @@ import android.util.Log;
 */
 */
public class NetdService {
public class NetdService {
    private static final String TAG = NetdService.class.getSimpleName();
    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 BASE_TIMEOUT_MS = 100;
    private static final long MAX_TIMEOUT_MS = 1000;
    private static final long MAX_TIMEOUT_MS = 1000;


@@ -48,7 +48,7 @@ public class NetdService {
        // NOTE: ServiceManager does no caching for the netd service,
        // NOTE: ServiceManager does no caching for the netd service,
        // because netd is not one of the defined common services.
        // because netd is not one of the defined common services.
        final INetd netdInstance = INetd.Stub.asInterface(
        final INetd netdInstance = INetd.Stub.asInterface(
                ServiceManager.getService(NETD_SERVICE_NAME));
                ServiceManager.getService(Context.NETD_SERVICE));
        if (netdInstance == null) {
        if (netdInstance == null) {
            Log.w(TAG, "WARNING: returning null INetd instance.");
            Log.w(TAG, "WARNING: returning null INetd instance.");
        }
        }