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

Commit fb3dccd9 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Gerrit Code Review
Browse files

Merge changes I34842acd,Icc6c4d6b

* changes:
  Add support for Ethernet tethering
  Local Tethering with ncm interface
parents e7e38501 f2f3f3e3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -1577,6 +1577,7 @@ package android.content {
    field public static final String BUGREPORT_SERVICE = "bugreport";
    field public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
    field public static final String CONTEXTHUB_SERVICE = "contexthub";
    field public static final String ETHERNET_SERVICE = "ethernet";
    field public static final String EUICC_CARD_SERVICE = "euicc_card";
    field public static final String HDMI_CONTROL_SERVICE = "hdmi_control";
    field public static final String NETD_SERVICE = "netd";
@@ -3285,10 +3286,12 @@ package android.hardware.usb {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public void setCurrentFunctions(long);
    field @RequiresPermission(android.Manifest.permission.MANAGE_USB) public static final String ACTION_USB_PORT_CHANGED = "android.hardware.usb.action.USB_PORT_CHANGED";
    field public static final String ACTION_USB_STATE = "android.hardware.usb.action.USB_STATE";
    field public static final long FUNCTION_NCM = 1024L; // 0x400L
    field public static final long FUNCTION_NONE = 0L; // 0x0L
    field public static final long FUNCTION_RNDIS = 32L; // 0x20L
    field public static final String USB_CONFIGURED = "configured";
    field public static final String USB_CONNECTED = "connected";
    field public static final String USB_FUNCTION_NCM = "ncm";
    field public static final String USB_FUNCTION_RNDIS = "rndis";
  }
@@ -4380,6 +4383,19 @@ package android.net {
    method @Deprecated public void onUpstreamChanged(@Nullable android.net.Network);
  }
  public class EthernetManager {
    method @NonNull public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull android.net.EthernetManager.TetheredInterfaceCallback);
  }
  public static interface EthernetManager.TetheredInterfaceCallback {
    method public void onAvailable(@NonNull String);
    method public void onUnavailable();
  }
  public static class EthernetManager.TetheredInterfaceRequest {
    method public void release();
  }
  public class InvalidPacketException extends java.lang.Exception {
    ctor public InvalidPacketException(int);
    field public static final int ERROR_INVALID_IP_ADDRESS = -21; // 0xffffffeb
@@ -4753,7 +4769,9 @@ package android.net {
    field public static final String EXTRA_AVAILABLE_TETHER = "availableArray";
    field public static final String EXTRA_ERRORED_TETHER = "erroredArray";
    field public static final int TETHERING_BLUETOOTH = 2; // 0x2
    field public static final int TETHERING_ETHERNET = 5; // 0x5
    field public static final int TETHERING_INVALID = -1; // 0xffffffff
    field public static final int TETHERING_NCM = 4; // 0x4
    field public static final int TETHERING_USB = 1; // 0x1
    field public static final int TETHERING_WIFI = 0; // 0x0
    field public static final int TETHERING_WIFI_P2P = 3; // 0x3
+16 −0
Original line number Diff line number Diff line
@@ -653,6 +653,7 @@ package android.content {
    method public void setContentCaptureOptions(@Nullable android.content.ContentCaptureOptions);
    field public static final String BUGREPORT_SERVICE = "bugreport";
    field public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture";
    field public static final String ETHERNET_SERVICE = "ethernet";
    field public static final String NETWORK_STACK_SERVICE = "network_stack";
    field public static final String PERMISSION_SERVICE = "permission";
    field public static final String ROLLBACK_SERVICE = "rollback";
@@ -1392,6 +1393,19 @@ package android.net {
    field public static final String EXTRA_CAPTIVE_PORTAL_USER_AGENT = "android.net.extra.CAPTIVE_PORTAL_USER_AGENT";
  }

  public class EthernetManager {
    method @NonNull public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull android.net.EthernetManager.TetheredInterfaceCallback);
  }

  public static interface EthernetManager.TetheredInterfaceCallback {
    method public void onAvailable(@NonNull String);
    method public void onUnavailable();
  }

  public static class EthernetManager.TetheredInterfaceRequest {
    method public void release();
  }

  public final class IpPrefix implements android.os.Parcelable {
    ctor public IpPrefix(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
    ctor public IpPrefix(@NonNull String);
@@ -1540,7 +1554,9 @@ package android.net {
    field public static final String EXTRA_AVAILABLE_TETHER = "availableArray";
    field public static final String EXTRA_ERRORED_TETHER = "erroredArray";
    field public static final int TETHERING_BLUETOOTH = 2; // 0x2
    field public static final int TETHERING_ETHERNET = 5; // 0x5
    field public static final int TETHERING_INVALID = -1; // 0xffffffff
    field public static final int TETHERING_NCM = 4; // 0x4
    field public static final int TETHERING_USB = 1; // 0x1
    field public static final int TETHERING_WIFI = 0; // 0x0
    field public static final int TETHERING_WIFI_P2P = 3; // 0x3
+4 −4
Original line number Diff line number Diff line
@@ -4022,16 +4022,16 @@ public abstract class Context {
    public static final String LOWPAN_SERVICE = "lowpan";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a {@link
     * android.net.EthernetManager} for handling management of
     * Ethernet access.
     * Use with {@link #getSystemService(String)} to retrieve a {@link android.net.EthernetManager}
     * for handling management of Ethernet access.
     *
     * @see #getSystemService(String)
     * @see android.net.EthernetManager
     *
     * @hide
     */
    @UnsupportedAppUsage
    @SystemApi
    @TestApi
    public static final String ETHERNET_SERVICE = "ethernet";

    /**
+21 −1
Original line number Diff line number Diff line
@@ -261,6 +261,15 @@ public class UsbManager {
     */
    public static final String USB_FUNCTION_ACCESSORY = "accessory";

    /**
     * Name of the NCM USB function.
     * Used in extras for the {@link #ACTION_USB_STATE} broadcast
     *
     * {@hide}
     */
    @SystemApi
    public static final String USB_FUNCTION_NCM = "ncm";

    /**
     * Name of extra for {@link #ACTION_USB_PORT_CHANGED}
     * containing the {@link UsbPort} object for the port.
@@ -367,8 +376,15 @@ public class UsbManager {
     */
    public static final long FUNCTION_ADB = GadgetFunction.ADB;

    /**
     * Code for the ncm source usb function.
     * {@hide}
     */
    @SystemApi
    public static final long FUNCTION_NCM = 1 << 10;

    private static final long SETTABLE_FUNCTIONS = FUNCTION_MTP | FUNCTION_PTP | FUNCTION_RNDIS
            | FUNCTION_MIDI;
            | FUNCTION_MIDI | FUNCTION_NCM;

    private static final Map<String, Long> FUNCTION_NAME_TO_CODE = new HashMap<>();

@@ -380,6 +396,7 @@ public class UsbManager {
        FUNCTION_NAME_TO_CODE.put(UsbManager.USB_FUNCTION_ACCESSORY, FUNCTION_ACCESSORY);
        FUNCTION_NAME_TO_CODE.put(UsbManager.USB_FUNCTION_AUDIO_SOURCE, FUNCTION_AUDIO_SOURCE);
        FUNCTION_NAME_TO_CODE.put(UsbManager.USB_FUNCTION_ADB, FUNCTION_ADB);
        FUNCTION_NAME_TO_CODE.put(UsbManager.USB_FUNCTION_NCM, FUNCTION_NCM);
    }

    private final Context mContext;
@@ -935,6 +952,9 @@ public class UsbManager {
        if ((functions & FUNCTION_AUDIO_SOURCE) != 0) {
            joiner.add(UsbManager.USB_FUNCTION_AUDIO_SOURCE);
        }
        if ((functions & FUNCTION_NCM) != 0) {
            joiner.add(UsbManager.USB_FUNCTION_NCM);
        }
        if ((functions & FUNCTION_ADB) != 0) {
            joiner.add(UsbManager.USB_FUNCTION_ADB);
        }
+14 −0
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
package android.net;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.Handler;
@@ -32,6 +34,8 @@ import java.util.Objects;
 *
 * @hide
 */
@SystemApi
@TestApi
@SystemService(Context.ETHERNET_SERVICE)
public class EthernetManager {
    private static final String TAG = "EthernetManager";
@@ -62,12 +66,14 @@ public class EthernetManager {

    /**
     * A listener interface to receive notification on changes in Ethernet.
     * @hide
     */
    public interface Listener {
        /**
         * Called when Ethernet port's availability is changed.
         * @param iface Ethernet interface name
         * @param isAvailable {@code true} if Ethernet port exists.
         * @hide
         */
        @UnsupportedAppUsage
        void onAvailabilityChanged(String iface, boolean isAvailable);
@@ -78,6 +84,7 @@ public class EthernetManager {
     * Applications will almost always want to use
     * {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve
     * the standard {@link android.content.Context#ETHERNET_SERVICE Context.ETHERNET_SERVICE}.
     * @hide
     */
    public EthernetManager(Context context, IEthernetManager service) {
        mContext = context;
@@ -87,6 +94,7 @@ public class EthernetManager {
    /**
     * Get Ethernet configuration.
     * @return the Ethernet Configuration, contained in {@link IpConfiguration}.
     * @hide
     */
    @UnsupportedAppUsage
    public IpConfiguration getConfiguration(String iface) {
@@ -99,6 +107,7 @@ public class EthernetManager {

    /**
     * Set Ethernet configuration.
     * @hide
     */
    @UnsupportedAppUsage
    public void setConfiguration(String iface, IpConfiguration config) {
@@ -111,6 +120,7 @@ public class EthernetManager {

    /**
     * Indicates whether the system currently has one or more Ethernet interfaces.
     * @hide
     */
    @UnsupportedAppUsage
    public boolean isAvailable() {
@@ -121,6 +131,7 @@ public class EthernetManager {
     * Indicates whether the system has given interface.
     *
     * @param iface Ethernet interface name
     * @hide
     */
    @UnsupportedAppUsage
    public boolean isAvailable(String iface) {
@@ -135,6 +146,7 @@ public class EthernetManager {
     * Adds a listener.
     * @param listener A {@link Listener} to add.
     * @throws IllegalArgumentException If the listener is null.
     * @hide
     */
    @UnsupportedAppUsage
    public void addListener(Listener listener) {
@@ -153,6 +165,7 @@ public class EthernetManager {

    /**
     * Returns an array of available Ethernet interface names.
     * @hide
     */
    @UnsupportedAppUsage
    public String[] getAvailableInterfaces() {
@@ -167,6 +180,7 @@ public class EthernetManager {
     * Removes a listener.
     * @param listener A {@link Listener} to remove.
     * @throws IllegalArgumentException If the listener is null.
     * @hide
     */
    @UnsupportedAppUsage
    public void removeListener(Listener listener) {
Loading