Merge "Move DhcpServer to NetworkStack app"
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
22
core/java/android/net/INetworkStackStatusCallback.aidl
Normal file
22
core/java/android/net/INetworkStackStatusCallback.aidl
Normal 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);
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
33
core/java/android/net/dhcp/DhcpServerCallbacks.java
Normal file
33
core/java/android/net/dhcp/DhcpServerCallbacks.java
Normal 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;
|
||||
}
|
||||
}
|
||||
32
core/java/android/net/dhcp/IDhcpServer.aidl
Normal file
32
core/java/android/net/dhcp/IDhcpServer.aidl
Normal 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);
|
||||
}
|
||||
24
core/java/android/net/dhcp/IDhcpServerCallbacks.aidl
Normal file
24
core/java/android/net/dhcp/IDhcpServerCallbacks.aidl
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user