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

Commit 0e3d0923 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Move DhcpServer to NetworkStack app

Test: atest FrameworksNetTests && atest NetworkStackTests
Bug: b/112869080

Change-Id: I96c40e63e9ceb37b67705bdd4d120307e114715b
parent 5dbf0574
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -825,7 +825,10 @@ aidl_interface {
    local_include_dir: "core/java",
    srcs: [
        "core/java/android/net/INetworkStackConnector.aidl",
        "core/java/android/net/INetworkStackStatusCallback.aidl",
        "core/java/android/net/dhcp/DhcpServingParamsParcel.aidl",
        "core/java/android/net/dhcp/IDhcpServer.aidl",
        "core/java/android/net/dhcp/IDhcpServerCallbacks.aidl",
    ],
    api_dir: "aidl/networkstack",
}
+2 −0
Original line number Diff line number Diff line
@@ -2475,6 +2475,8 @@ public class ConnectivityManager {
    public static final int TETHER_ERROR_IFACE_CFG_ERROR      = 10;
    /** {@hide} */
    public static final int TETHER_ERROR_PROVISION_FAILED     = 11;
    /** {@hide} */
    public static final int TETHER_ERROR_DHCPSERVER_ERROR     = 12;

    /**
     * Get a more detailed error code after a Tethering or Untethering
+5 −1
Original line number Diff line number Diff line
@@ -15,7 +15,11 @@
 */
package android.net;

import android.net.dhcp.DhcpServingParamsParcel;
import android.net.dhcp.IDhcpServerCallbacks;

/** @hide */
oneway interface INetworkStackConnector {
    // TODO: requestDhcpServer(), etc. will go here
    void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params,
        in IDhcpServerCallbacks cb);
}
 No newline at end of file
+22 −0
Original line number 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 */
oneway interface INetworkStackStatusCallback {
    void onStatusAvailable(int statusCode);
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -25,9 +25,12 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.dhcp.DhcpServingParamsParcel;
import android.net.dhcp.IDhcpServerCallbacks;
import android.os.Binder;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.Slog;
@@ -58,6 +61,22 @@ public class NetworkStack {

    public NetworkStack() { }

    /**
     * Create a DHCP server according to the specified parameters.
     *
     * <p>The server will be returned asynchronously through the provided callbacks.
     */
    public void makeDhcpServer(final String ifName, final DhcpServingParamsParcel params,
            final IDhcpServerCallbacks cb) {
        requestConnector(connector -> {
            try {
                connector.makeDhcpServer(ifName, params, cb);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }
        });
    }

    private class NetworkStackConnection implements ServiceConnection {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
Loading