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

Commit 6db38c75 authored by James Mattis's avatar James Mattis Committed by Gerrit Code Review
Browse files

Merge "Marking eth network management APIs @SystemApi"

parents 9d805c35 51f72b15
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -7023,7 +7023,10 @@ package android.metrics {
package android.net {
  public class EthernetManager {
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void connectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void disconnectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.TetheredInterfaceCallback);
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void updateConfiguration(@NonNull String, @NonNull android.net.EthernetNetworkUpdateRequest, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
  }
  public static interface EthernetManager.TetheredInterfaceCallback {
@@ -7035,6 +7038,22 @@ package android.net {
    method public void release();
  }
  public final class EthernetNetworkManagementException extends java.lang.RuntimeException implements android.os.Parcelable {
    ctor public EthernetNetworkManagementException(@NonNull String);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkManagementException> CREATOR;
  }
  public final class EthernetNetworkUpdateRequest implements android.os.Parcelable {
    ctor public EthernetNetworkUpdateRequest(@NonNull android.net.StaticIpConfiguration, @NonNull android.net.NetworkCapabilities);
    method public int describeContents();
    method @NonNull public android.net.StaticIpConfiguration getIpConfig();
    method @NonNull public android.net.NetworkCapabilities getNetworkCapabilities();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkUpdateRequest> CREATOR;
  }
  public final class IpSecManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void applyTunnelModeTransform(@NonNull android.net.IpSecManager.IpSecTunnelInterface, int, @NonNull android.net.IpSecTransform) throws java.io.IOException;
    method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public android.net.IpSecManager.IpSecTunnelInterface createIpSecTunnelInterface(@NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull android.net.Network) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException;
+84 −6
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@ package android.net;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.RemoteException;

@@ -358,12 +360,43 @@ public class EthernetManager {
        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 EthernetNetworkUpdateRequest request,
            @Nullable @CallbackExecutor Executor executor,
            @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(
                executor, listener);
        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,
            @Nullable @CallbackExecutor Executor executor,
            @Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) {
        Objects.requireNonNull(iface, "iface must be non-null");
        final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
                executor, listener);
        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,
            @Nullable @CallbackExecutor Executor executor,
            @Nullable BiConsumer<Network, EthernetNetworkManagementException> listener) {
        Objects.requireNonNull(iface, "iface must be non-null");
        final InternalNetworkManagementListener proxy = getInternalNetworkManagementListener(
                executor, listener);
        try {
+2 −0
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@
package android.net;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/** @hide */
@SystemApi
public final class EthernetNetworkManagementException
        extends RuntimeException implements Parcelable {

+2 −1
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@
package android.net;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/** @hide */
@SystemApi
public final class EthernetNetworkUpdateRequest implements Parcelable {
    @NonNull
    private final StaticIpConfiguration mIpConfig;
@@ -39,7 +41,6 @@ public final class EthernetNetworkUpdateRequest implements Parcelable {
        return new NetworkCapabilities(mNetworkCapabilities);
    }

    /** @hide */
    public EthernetNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig,
            @NonNull final NetworkCapabilities networkCapabilities) {
        Objects.requireNonNull(ipConfig);