summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author James Mattis <jmattis@google.com> 2021-12-23 00:59:06 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-12-23 00:59:06 +0000
commit9ff27e580216adbb528f5ff1779e204cd29f9a60 (patch)
treec2ebaca477084003cbd8a23600f9df6221e8f00f
parent1d6f1c9d04b9804a81f582643926cbb391761aef (diff)
parent3dd562abab66136f3e725d456f02df777159edf8 (diff)
Merge changes from topic "railway_stub"
* changes: eth manager updates for network management APIs aidl and Parcelable defintions for eth management
-rw-r--r--core/java/android/net/IInternalNetworkManagementListener.aidl25
-rw-r--r--core/java/android/net/InternalNetworkManagementException.aidl19
-rw-r--r--core/java/android/net/InternalNetworkManagementException.java59
-rw-r--r--core/java/android/net/InternalNetworkUpdateRequest.aidl19
-rw-r--r--core/java/android/net/InternalNetworkUpdateRequest.java108
-rw-r--r--packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java82
-rw-r--r--packages/ConnectivityT/framework-t/src/android/net/IEthernetManager.aidl6
7 files changed, 318 insertions, 0 deletions
diff --git a/core/java/android/net/IInternalNetworkManagementListener.aidl b/core/java/android/net/IInternalNetworkManagementListener.aidl
new file mode 100644
index 000000000000..69cde3bd14e8
--- /dev/null
+++ b/core/java/android/net/IInternalNetworkManagementListener.aidl
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2021, 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.net.InternalNetworkManagementException;
+import android.net.Network;
+
+/** @hide */
+oneway interface IInternalNetworkManagementListener {
+ void onComplete(in Network network, in InternalNetworkManagementException exception);
+} \ No newline at end of file
diff --git a/core/java/android/net/InternalNetworkManagementException.aidl b/core/java/android/net/InternalNetworkManagementException.aidl
new file mode 100644
index 000000000000..dcce706989f6
--- /dev/null
+++ b/core/java/android/net/InternalNetworkManagementException.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2021 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;
+
+ parcelable InternalNetworkManagementException; \ No newline at end of file
diff --git a/core/java/android/net/InternalNetworkManagementException.java b/core/java/android/net/InternalNetworkManagementException.java
new file mode 100644
index 000000000000..7f4e403f2259
--- /dev/null
+++ b/core/java/android/net/InternalNetworkManagementException.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 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.os.Parcel;
+import android.os.Parcelable;
+
+/** @hide */
+public final class InternalNetworkManagementException
+ extends RuntimeException implements Parcelable {
+
+ /* @hide */
+ public InternalNetworkManagementException(@NonNull final Throwable t) {
+ super(t);
+ }
+
+ private InternalNetworkManagementException(@NonNull final Parcel source) {
+ super(source.readString());
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeString(getCause().getMessage());
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Parcelable.Creator<InternalNetworkManagementException> CREATOR =
+ new Parcelable.Creator<InternalNetworkManagementException>() {
+ @Override
+ public InternalNetworkManagementException[] newArray(int size) {
+ return new InternalNetworkManagementException[size];
+ }
+
+ @Override
+ public InternalNetworkManagementException createFromParcel(@NonNull Parcel source) {
+ return new InternalNetworkManagementException(source);
+ }
+ };
+}
diff --git a/core/java/android/net/InternalNetworkUpdateRequest.aidl b/core/java/android/net/InternalNetworkUpdateRequest.aidl
new file mode 100644
index 000000000000..da00cb97afb4
--- /dev/null
+++ b/core/java/android/net/InternalNetworkUpdateRequest.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2021 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;
+
+ parcelable InternalNetworkUpdateRequest; \ No newline at end of file
diff --git a/core/java/android/net/InternalNetworkUpdateRequest.java b/core/java/android/net/InternalNetworkUpdateRequest.java
new file mode 100644
index 000000000000..6f093835fb08
--- /dev/null
+++ b/core/java/android/net/InternalNetworkUpdateRequest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2021 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.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/** @hide */
+public final class InternalNetworkUpdateRequest implements Parcelable {
+ @NonNull
+ private final StaticIpConfiguration mIpConfig;
+ @Nullable
+ private final NetworkCapabilities mNetworkCapabilities;
+
+ @NonNull
+ public StaticIpConfiguration getIpConfig() {
+ return new StaticIpConfiguration(mIpConfig);
+ }
+
+ @NonNull
+ public NetworkCapabilities getNetworkCapabilities() {
+ return mNetworkCapabilities == null
+ ? null : new NetworkCapabilities(mNetworkCapabilities);
+ }
+
+ /** @hide */
+ public InternalNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig,
+ @Nullable final NetworkCapabilities networkCapabilities) {
+ Objects.requireNonNull(ipConfig);
+ mIpConfig = new StaticIpConfiguration(ipConfig);
+ if (null == networkCapabilities) {
+ mNetworkCapabilities = null;
+ } else {
+ mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
+ }
+ }
+
+ private InternalNetworkUpdateRequest(@NonNull final Parcel source) {
+ Objects.requireNonNull(source);
+ mIpConfig = StaticIpConfiguration.CREATOR.createFromParcel(source);
+ mNetworkCapabilities = NetworkCapabilities.CREATOR.createFromParcel(source);
+ }
+
+ @Override
+ public String toString() {
+ return "InternalNetworkUpdateRequest{"
+ + "mIpConfig=" + mIpConfig
+ + ", mNetworkCapabilities=" + mNetworkCapabilities + '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ InternalNetworkUpdateRequest that = (InternalNetworkUpdateRequest) o;
+
+ return Objects.equals(that.getIpConfig(), mIpConfig)
+ && Objects.equals(that.getNetworkCapabilities(), mNetworkCapabilities);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mIpConfig, mNetworkCapabilities);
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ mIpConfig.writeToParcel(dest, flags);
+ mNetworkCapabilities.writeToParcel(dest, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Parcelable.Creator<InternalNetworkUpdateRequest> CREATOR =
+ new Parcelable.Creator<InternalNetworkUpdateRequest>() {
+ @Override
+ public InternalNetworkUpdateRequest[] newArray(int size) {
+ return new InternalNetworkUpdateRequest[size];
+ }
+
+ @Override
+ public InternalNetworkUpdateRequest createFromParcel(@NonNull Parcel source) {
+ return new InternalNetworkUpdateRequest(source);
+ }
+ };
+}
diff --git a/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java b/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java
index 7cd63ef9cc5a..ece54df96665 100644
--- a/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java
+++ b/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java
@@ -16,7 +16,9 @@
package android.net;
+import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
@@ -32,6 +34,7 @@ import com.android.internal.os.BackgroundThread;
import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.Executor;
+import java.util.function.BiConsumer;
/**
* A class representing the IP configuration of the Ethernet network.
@@ -315,4 +318,83 @@ public class EthernetManager {
}
return new TetheredInterfaceRequest(mService, cbInternal);
}
+
+ private static final class InternalNetworkManagementListener
+ extends IInternalNetworkManagementListener.Stub {
+ @NonNull
+ private final Executor mExecutor;
+ @NonNull
+ private final BiConsumer<Network, InternalNetworkManagementException> mListener;
+
+ InternalNetworkManagementListener(
+ @NonNull final Executor executor,
+ @NonNull final BiConsumer<Network, InternalNetworkManagementException> listener) {
+ Objects.requireNonNull(executor, "Pass a non-null executor");
+ Objects.requireNonNull(listener, "Pass a non-null listener");
+ mExecutor = executor;
+ mListener = listener;
+ }
+
+ @Override
+ public void onComplete(
+ @Nullable final Network network,
+ @Nullable final InternalNetworkManagementException e) {
+ mExecutor.execute(() -> mListener.accept(network, e));
+ }
+ }
+
+ private InternalNetworkManagementListener getInternalNetworkManagementListener(
+ @Nullable final Executor executor,
+ @Nullable final BiConsumer<Network, InternalNetworkManagementException> listener) {
+ if (null != listener) {
+ Objects.requireNonNull(executor, "Pass a non-null executor, or a null listener");
+ }
+ final InternalNetworkManagementListener proxy;
+ if (null == listener) {
+ proxy = null;
+ } else {
+ proxy = new InternalNetworkManagementListener(executor, listener);
+ }
+ return proxy;
+ }
+
+ private void updateConfiguration(
+ @NonNull String iface,
+ @NonNull InternalNetworkUpdateRequest request,
+ @Nullable @CallbackExecutor Executor executor,
+ @Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
+ final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
+ executor, listener);
+ try {
+ mService.updateConfiguration(iface, request, proxy);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ private void connectNetwork(
+ @NonNull String iface,
+ @Nullable @CallbackExecutor Executor executor,
+ @Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
+ final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
+ executor, listener);
+ try {
+ mService.connectNetwork(iface, proxy);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ private void disconnectNetwork(
+ @NonNull String iface,
+ @Nullable @CallbackExecutor Executor executor,
+ @Nullable BiConsumer<Network, InternalNetworkManagementException> listener) {
+ final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
+ executor, listener);
+ try {
+ mService.disconnectNetwork(iface, proxy);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
diff --git a/packages/ConnectivityT/framework-t/src/android/net/IEthernetManager.aidl b/packages/ConnectivityT/framework-t/src/android/net/IEthernetManager.aidl
index e058e5a70c71..e688bea1cfac 100644
--- a/packages/ConnectivityT/framework-t/src/android/net/IEthernetManager.aidl
+++ b/packages/ConnectivityT/framework-t/src/android/net/IEthernetManager.aidl
@@ -18,6 +18,8 @@ package android.net;
import android.net.IpConfiguration;
import android.net.IEthernetServiceListener;
+import android.net.IInternalNetworkManagementListener;
+import android.net.InternalNetworkUpdateRequest;
import android.net.ITetheredInterfaceCallback;
/**
@@ -36,4 +38,8 @@ interface IEthernetManager
void setIncludeTestInterfaces(boolean include);
void requestTetheredInterface(in ITetheredInterfaceCallback callback);
void releaseTetheredInterface(in ITetheredInterfaceCallback callback);
+ void updateConfiguration(String iface, in InternalNetworkUpdateRequest request,
+ in IInternalNetworkManagementListener listener);
+ void connectNetwork(String iface, in IInternalNetworkManagementListener listener);
+ void disconnectNetwork(String iface, in IInternalNetworkManagementListener listener);
}