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

Commit 31ef4c05 authored by Milim Lee's avatar Milim Lee Committed by Remi NGUYEN VAN
Browse files

Local Tethering with ncm interface

Bug: 130840842
Test: build, boot
      atest TetheringTest
      manual test (call startTethering(TETHERING_NCM))

Change-Id: Icc6c4d6be39e787503cecf3a5835b40d4be12a57
parent de933af7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3623,10 +3623,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";
  }
@@ -5231,6 +5233,7 @@ package android.net {
    field public static final String EXTRA_ERRORED_TETHER = "erroredArray";
    field public static final int TETHERING_BLUETOOTH = 2; // 0x2
    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
+1 −0
Original line number Diff line number Diff line
@@ -1656,6 +1656,7 @@ package android.net {
    field public static final String EXTRA_ERRORED_TETHER = "erroredArray";
    field public static final int TETHERING_BLUETOOTH = 2; // 0x2
    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
+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);
        }
+6 −0
Original line number Diff line number Diff line
@@ -130,6 +130,12 @@ public class TetheringManager {
     */
    public static final int TETHERING_WIFI_P2P = 3;

    /**
     * Ncm local tethering type.
     * @see #startTethering(TetheringRequest, Executor, StartTetheringCallback)
     */
    public static final int TETHERING_NCM = 4;

    public static final int TETHER_ERROR_NO_ERROR           = 0;
    public static final int TETHER_ERROR_UNKNOWN_IFACE      = 1;
    public static final int TETHER_ERROR_SERVICE_UNAVAIL    = 2;
+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,12 @@
        <item>"rndis\\d"</item>
    </string-array>

    <!-- List of regexpressions describing the interface (if any) that represent tetherable
         NCM interfaces.  If the device doesn't want to support tethering over NCM this should
         be empty. -->
    <string-array translatable="false" name="config_tether_ncm_regexs">
    </string-array>

    <!-- List of regexpressions describing the interface (if any) that represent tetherable
         Wifi interfaces.  If the device doesn't want to support tethering over Wifi this
         should be empty.  An example would be "softap.*" -->
Loading