Merge "Move DhcpServer to NetworkStack app"

This commit is contained in:
Remi NGUYEN VAN
2019-01-09 10:42:48 +00:00
committed by Gerrit Code Review
34 changed files with 1027 additions and 163 deletions

View File

@@ -2485,6 +2485,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

View File

@@ -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);
}

View File

@@ -0,0 +1,22 @@
/*
* 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);
}

View File

@@ -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) {

View File

@@ -0,0 +1,33 @@
/*
* 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.dhcp;
/**
* Convenience wrapper around IDhcpServerCallbacks.Stub that implements getInterfaceVersion().
* @hide
*/
public abstract class DhcpServerCallbacks extends IDhcpServerCallbacks.Stub {
// TODO: add @Override here once the API is versioned
/**
* Get the version of the aidl interface implemented by the callbacks.
*/
public int getInterfaceVersion() {
// TODO: return IDhcpServerCallbacks.VERSION;
return 0;
}
}

View File

@@ -0,0 +1,32 @@
/**
* 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 perNmissions and
* limitations under the License.
*/
package android.net.dhcp;
import android.net.INetworkStackStatusCallback;
import android.net.dhcp.DhcpServingParamsParcel;
/** @hide */
oneway interface IDhcpServer {
const int STATUS_UNKNOWN = 0;
const int STATUS_SUCCESS = 1;
const int STATUS_INVALID_ARGUMENT = 2;
const int STATUS_UNKNOWN_ERROR = 3;
void start(in INetworkStackStatusCallback cb);
void updateParams(in DhcpServingParamsParcel params, in INetworkStackStatusCallback cb);
void stop(in INetworkStackStatusCallback cb);
}

View File

@@ -0,0 +1,24 @@
/**
* 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 perNmissions and
* limitations under the License.
*/
package android.net.dhcp;
import android.net.dhcp.IDhcpServer;
/** @hide */
oneway interface IDhcpServerCallbacks {
void onDhcpServerCreated(int statusCode, in IDhcpServer server);
}