Marking eth network management APIs @SystemApi

Annotating ethernet network management APIs in EthernetManager
with @SystemApi.

Bug: 210485380
Test: atest EthernetServiceTests
atest CtsNetTestCasesLatestSdk

Change-Id: I10429441fd4d7b9bcaa7437b844420a43a415d72
Merged-In: I10429441fd4d7b9bcaa7437b844420a43a415d72
This commit is contained in:
James Mattis
2022-02-02 14:32:40 -08:00
parent 1661c26cf4
commit 28547370d4
3 changed files with 88 additions and 7 deletions

View File

@@ -19,12 +19,14 @@ package android.net;
import android.annotation.CallbackExecutor; import android.annotation.CallbackExecutor;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission; import android.annotation.RequiresPermission;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.annotation.SystemService; import android.annotation.SystemService;
import android.annotation.TestApi; import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.RemoteException; import android.os.RemoteException;
@@ -358,12 +360,43 @@ public class EthernetManager {
return proxy; return proxy;
} }
@RequiresPermission(android.Manifest.permission.MANAGE_ETHERNET_NETWORKS) /**
private void updateConfiguration( * Updates the configuration of an automotive device's ethernet network.
*
* The {@link EthernetNetworkUpdateRequest} {@code request} argument describes how to update the
* configuration for this network.
* Use {@link StaticIpConfiguration.Builder} to build a {@code StaticIpConfiguration} object for
* this network to put inside the {@code request}.
* Similarly, use {@link NetworkCapabilities.Builder} to build a {@code NetworkCapabilities}
* object for this network to put inside the {@code request}.
*
* If non-null, the listener will be called exactly once after this is called, unless
* a synchronous exception was thrown.
*
* @param iface the name of the interface to act upon.
* @param request the {@link EthernetNetworkUpdateRequest} used to set an ethernet network's
* {@link StaticIpConfiguration} and {@link NetworkCapabilities} values.
* @param executor an {@link Executor} to execute the listener on. Optional if listener is null.
* @param listener an optional {@link BiConsumer} to listen for completion of the operation.
* @throws SecurityException if the process doesn't hold
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
* @throws UnsupportedOperationException if called on a non-automotive device or on an
* unsupported interface.
* @hide
*/
@SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK,
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
public void updateConfiguration(
@NonNull String iface, @NonNull String iface,
@NonNull EthernetNetworkUpdateRequest request, @NonNull EthernetNetworkUpdateRequest request,
@Nullable @CallbackExecutor Executor executor, @Nullable @CallbackExecutor Executor executor,
@Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) { @Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) {
Objects.requireNonNull(iface, "iface must be non-null");
Objects.requireNonNull(request, "request must be non-null");
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener( final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
executor, listener); executor, listener);
try { try {
@@ -373,11 +406,34 @@ public class EthernetManager {
} }
} }
@RequiresPermission(android.Manifest.permission.MANAGE_ETHERNET_NETWORKS) /**
private void connectNetwork( * Set an ethernet network's link state up.
*
* When the link is successfully turned up, the listener will be called with the resulting
* network. If any error or unexpected condition happens while the system tries to turn the
* interface up, the listener will be called with an appropriate exception.
* The listener is guaranteed to be called exactly once for each call to this method, but this
* may take an unbounded amount of time depending on the actual network conditions.
*
* @param iface the name of the interface to act upon.
* @param executor an {@link Executor} to execute the listener on. Optional if listener is null.
* @param listener an optional {@link BiConsumer} to listen for completion of the operation.
* @throws SecurityException if the process doesn't hold
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
* @throws UnsupportedOperationException if called on a non-automotive device.
* @hide
*/
@SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK,
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
public void connectNetwork(
@NonNull String iface, @NonNull String iface,
@Nullable @CallbackExecutor Executor executor, @Nullable @CallbackExecutor Executor executor,
@Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) { @Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) {
Objects.requireNonNull(iface, "iface must be non-null");
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener( final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
executor, listener); executor, listener);
try { try {
@@ -387,11 +443,33 @@ public class EthernetManager {
} }
} }
@RequiresPermission(android.Manifest.permission.MANAGE_ETHERNET_NETWORKS) /**
private void disconnectNetwork( * Set an ethernet network's link state down.
*
* When the link is successfully turned down, the listener will be called with the network that
* was torn down, if any. If any error or unexpected condition happens while the system tries to
* turn the interface down, the listener will be called with an appropriate exception.
* The listener is guaranteed to be called exactly once for each call to this method.
*
* @param iface the name of the interface to act upon.
* @param executor an {@link Executor} to execute the listener on. Optional if listener is null.
* @param listener an optional {@link BiConsumer} to listen for completion of the operation.
* @throws SecurityException if the process doesn't hold
* {@link android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}.
* @throws UnsupportedOperationException if called on a non-automotive device.
* @hide
*/
@SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK,
android.Manifest.permission.MANAGE_ETHERNET_NETWORKS})
@RequiresFeature(PackageManager.FEATURE_AUTOMOTIVE)
public void disconnectNetwork(
@NonNull String iface, @NonNull String iface,
@Nullable @CallbackExecutor Executor executor, @Nullable @CallbackExecutor Executor executor,
@Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) { @Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) {
Objects.requireNonNull(iface, "iface must be non-null");
final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener( final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
executor, listener); executor, listener);
try { try {

View File

@@ -17,12 +17,14 @@
package android.net; package android.net;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import java.util.Objects; import java.util.Objects;
/** @hide */ /** @hide */
@SystemApi
public final class EthernetNetworkManagementException public final class EthernetNetworkManagementException
extends RuntimeException implements Parcelable { extends RuntimeException implements Parcelable {

View File

@@ -17,12 +17,14 @@
package android.net; package android.net;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import java.util.Objects; import java.util.Objects;
/** @hide */ /** @hide */
@SystemApi
public final class EthernetNetworkUpdateRequest implements Parcelable { public final class EthernetNetworkUpdateRequest implements Parcelable {
@NonNull @NonNull
private final StaticIpConfiguration mIpConfig; private final StaticIpConfiguration mIpConfig;
@@ -39,7 +41,6 @@ public final class EthernetNetworkUpdateRequest implements Parcelable {
return new NetworkCapabilities(mNetworkCapabilities); return new NetworkCapabilities(mNetworkCapabilities);
} }
/** @hide */
public EthernetNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig, public EthernetNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig,
@NonNull final NetworkCapabilities networkCapabilities) { @NonNull final NetworkCapabilities networkCapabilities) {
Objects.requireNonNull(ipConfig); Objects.requireNonNull(ipConfig);