Merge "Introduce TETHERING_VIRTUAL type" into main
This commit is contained in:
commit
a05cdee22f
4 changed files with 40 additions and 1 deletions
|
|
@ -47,6 +47,7 @@ package android.net {
|
|||
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 @FlaggedApi("com.android.net.flags.tethering_request_virtual") public static final int TETHERING_VIRTUAL = 7; // 0x7
|
||||
field public static final int TETHERING_WIFI = 0; // 0x0
|
||||
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
|
||||
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ public class TetheringManager {
|
|||
public static class Flags {
|
||||
static final String TETHERING_REQUEST_WITH_SOFT_AP_CONFIG =
|
||||
"com.android.net.flags.tethering_request_with_soft_ap_config";
|
||||
static final String TETHERING_REQUEST_VIRTUAL =
|
||||
"com.android.net.flags.tethering_request_virtual";
|
||||
}
|
||||
|
||||
private static final String TAG = TetheringManager.class.getSimpleName();
|
||||
|
|
@ -194,11 +196,19 @@ public class TetheringManager {
|
|||
*/
|
||||
public static final int TETHERING_WIGIG = 6;
|
||||
|
||||
/**
|
||||
* VIRTUAL tethering type.
|
||||
* @hide
|
||||
*/
|
||||
@FlaggedApi(Flags.TETHERING_REQUEST_VIRTUAL)
|
||||
@SystemApi
|
||||
public static final int TETHERING_VIRTUAL = 7;
|
||||
|
||||
/**
|
||||
* The int value of last tethering type.
|
||||
* @hide
|
||||
*/
|
||||
public static final int MAX_TETHERING_TYPE = TETHERING_WIGIG;
|
||||
public static final int MAX_TETHERING_TYPE = TETHERING_VIRTUAL;
|
||||
|
||||
/** @hide */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import static android.net.TetheringManager.TETHERING_ETHERNET;
|
|||
import static android.net.TetheringManager.TETHERING_INVALID;
|
||||
import static android.net.TetheringManager.TETHERING_NCM;
|
||||
import static android.net.TetheringManager.TETHERING_USB;
|
||||
import static android.net.TetheringManager.TETHERING_VIRTUAL;
|
||||
import static android.net.TetheringManager.TETHERING_WIFI;
|
||||
import static android.net.TetheringManager.TETHERING_WIFI_P2P;
|
||||
import static android.net.TetheringManager.TETHERING_WIGIG;
|
||||
|
|
@ -278,6 +279,7 @@ public class Tethering {
|
|||
private TetheredInterfaceRequestShim mBluetoothIfaceRequest;
|
||||
private String mConfiguredEthernetIface;
|
||||
private String mConfiguredBluetoothIface;
|
||||
private String mConfiguredVirtualIface;
|
||||
private EthernetCallback mEthernetCallback;
|
||||
private TetheredInterfaceCallbackShim mBluetoothCallback;
|
||||
private SettingsObserver mSettingsObserver;
|
||||
|
|
@ -719,6 +721,9 @@ public class Tethering {
|
|||
case TETHERING_ETHERNET:
|
||||
result = setEthernetTethering(enable);
|
||||
break;
|
||||
case TETHERING_VIRTUAL:
|
||||
result = setVirtualMachineTethering(enable);
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG, "Invalid tether type.");
|
||||
result = TETHER_ERROR_UNKNOWN_TYPE;
|
||||
|
|
@ -972,6 +977,21 @@ public class Tethering {
|
|||
}
|
||||
}
|
||||
|
||||
private int setVirtualMachineTethering(final boolean enable) {
|
||||
// TODO(340377643): Use bridge ifname when it's introduced, not fixed TAP ifname.
|
||||
if (enable) {
|
||||
mConfiguredVirtualIface = "avf_tap_fixed";
|
||||
enableIpServing(
|
||||
TETHERING_VIRTUAL,
|
||||
mConfiguredVirtualIface,
|
||||
getRequestedState(TETHERING_VIRTUAL));
|
||||
} else if (mConfiguredVirtualIface != null) {
|
||||
ensureIpServerStopped(mConfiguredVirtualIface);
|
||||
mConfiguredVirtualIface = null;
|
||||
}
|
||||
return TETHER_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
void tether(String iface, int requestedState, final IIntResultListener listener) {
|
||||
mHandler.post(() -> {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -115,3 +115,11 @@ flag {
|
|||
description: "Flag for NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED API"
|
||||
bug: "343823469"
|
||||
}
|
||||
|
||||
flag {
|
||||
name: "tethering_request_virtual"
|
||||
is_exported: true
|
||||
namespace: "android_core_networking"
|
||||
description: "Flag for introducing TETHERING_VIRTUAL type"
|
||||
bug: "340376953"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue