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

Commit 8c141bdb authored by Chalard Jean's avatar Chalard Jean
Browse files

[MS01] Add the IP memory store service.

Bug: 116512211
Test: Added initial tests
Change-Id: I9d9af4097e3e2d7afd9956b9cbfa29a9f9558ae0
parent 81552d61
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -697,6 +697,7 @@ java_defaults {
        "android.hardware.radio-V1.3-java",
        "android.hardware.radio-V1.3-java",
        "android.hardware.radio-V1.4-java",
        "android.hardware.radio-V1.4-java",
        "android.hardware.usb.gadget-V1.0-java",
        "android.hardware.usb.gadget-V1.0-java",
        "networkstack-aidl-interfaces-java",
        "netd_aidl_interface-java",
        "netd_aidl_interface-java",
    ],
    ],


@@ -715,6 +716,16 @@ java_defaults {


}
}


// AIDL interfaces between the core system and the networking mainline module.
aidl_interface {
    name: "networkstack-aidl-interfaces",
    local_include_dir: "core/java",
    srcs: [
        "core/java/android/net/IIpMemoryStore.aidl",
    ],
    api_dir: "aidl/networkstack",
}

filegroup {
filegroup {
    name: "libincident_aidl",
    name: "libincident_aidl",
    srcs: [
    srcs: [
+17 −4
Original line number Original line Diff line number Diff line
@@ -82,8 +82,10 @@ import android.net.ConnectivityThread;
import android.net.EthernetManager;
import android.net.EthernetManager;
import android.net.IConnectivityManager;
import android.net.IConnectivityManager;
import android.net.IEthernetManager;
import android.net.IEthernetManager;
import android.net.IIpMemoryStore;
import android.net.IIpSecService;
import android.net.IIpSecService;
import android.net.INetworkPolicyManager;
import android.net.INetworkPolicyManager;
import android.net.IpMemoryStore;
import android.net.IpSecManager;
import android.net.IpSecManager;
import android.net.NetworkPolicyManager;
import android.net.NetworkPolicyManager;
import android.net.NetworkScoreManager;
import android.net.NetworkScoreManager;
@@ -291,6 +293,17 @@ final class SystemServiceRegistry {
                        return new NetworkStack();
                        return new NetworkStack();
                    }});
                    }});


        registerService(Context.IP_MEMORY_STORE_SERVICE, IpMemoryStore.class,
                new CachedServiceFetcher<IpMemoryStore>() {
                    @Override
                    public IpMemoryStore createService(final ContextImpl ctx)
                            throws ServiceNotFoundException {
                        IBinder b = ServiceManager.getServiceOrThrow(
                                Context.IP_MEMORY_STORE_SERVICE);
                        IIpMemoryStore service = IIpMemoryStore.Stub.asInterface(b);
                        return new IpMemoryStore(ctx, service);
                    }});

        registerService(Context.IPSEC_SERVICE, IpSecManager.class,
        registerService(Context.IPSEC_SERVICE, IpSecManager.class,
                new CachedServiceFetcher<IpSecManager>() {
                new CachedServiceFetcher<IpSecManager>() {
            @Override
            @Override
+9 −0
Original line number Original line Diff line number Diff line
@@ -3015,6 +3015,7 @@ public abstract class Context {
            VIBRATOR_SERVICE,
            VIBRATOR_SERVICE,
            //@hide: STATUS_BAR_SERVICE,
            //@hide: STATUS_BAR_SERVICE,
            CONNECTIVITY_SERVICE,
            CONNECTIVITY_SERVICE,
            //@hide: IP_MEMORY_STORE_SERVICE,
            IPSEC_SERVICE,
            IPSEC_SERVICE,
            //@hide: UPDATE_LOCK_SERVICE,
            //@hide: UPDATE_LOCK_SERVICE,
            //@hide: NETWORKMANAGEMENT_SERVICE,
            //@hide: NETWORKMANAGEMENT_SERVICE,
@@ -3512,6 +3513,14 @@ public abstract class Context {
     */
     */
    public static final String NETWORK_STACK_SERVICE = "network_stack";
    public static final String NETWORK_STACK_SERVICE = "network_stack";


    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.net.IpMemoryStore} to store and read information about
     * known networks.
     * @hide
     */
    public static final String IP_MEMORY_STORE_SERVICE = "ipmemorystore";

    /**
    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.net.IpSecManager} for encrypting Sockets or Networks with
     * {@link android.net.IpSecManager} for encrypting Sockets or Networks with
+27 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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;

/** {@hide} */
interface IIpMemoryStore {
    /**
     * Returns the version of the memory store.
     * This is just a fake method returning 1 to have some method in there
     * without adding any actual complexity to review.
     */
    int version();
}
+53 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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;

import android.annotation.NonNull;
import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;

import com.android.internal.util.Preconditions;

/**
 * The interface for system components to access the IP memory store.
 * @see com.android.server.net.ipmemorystore.IpMemoryStoreService
 * @hide
 */
@SystemService(Context.IP_MEMORY_STORE_SERVICE)
public class IpMemoryStore {
    @NonNull final Context mContext;
    @NonNull final IIpMemoryStore mService;

    public IpMemoryStore(@NonNull final Context context, @NonNull final IIpMemoryStore service) {
        mContext = Preconditions.checkNotNull(context, "missing context");
        mService = Preconditions.checkNotNull(service, "missing IIpMemoryStore");
    }

    /**
     * Returns the version of the memory store
     * @hide
     **/
    // TODO : remove this
    public int version() {
        try {
            return mService.version();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
Loading