Merge "Add new network capabilities to support automotive head unit via USB" into sc-dev

This commit is contained in:
Lorenzo Colitti
2021-03-30 14:36:56 +00:00
committed by Android (Google) Code Review
5 changed files with 26 additions and 7 deletions

View File

@@ -311,6 +311,7 @@ package android.net {
field public static final int NET_CAPABILITY_ENTERPRISE = 29; // 0x1d field public static final int NET_CAPABILITY_ENTERPRISE = 29; // 0x1d
field public static final int NET_CAPABILITY_FOREGROUND = 19; // 0x13 field public static final int NET_CAPABILITY_FOREGROUND = 19; // 0x13
field public static final int NET_CAPABILITY_FOTA = 3; // 0x3 field public static final int NET_CAPABILITY_FOTA = 3; // 0x3
field public static final int NET_CAPABILITY_HEAD_UNIT = 32; // 0x20
field public static final int NET_CAPABILITY_IA = 7; // 0x7 field public static final int NET_CAPABILITY_IA = 7; // 0x7
field public static final int NET_CAPABILITY_IMS = 4; // 0x4 field public static final int NET_CAPABILITY_IMS = 4; // 0x4
field public static final int NET_CAPABILITY_INTERNET = 12; // 0xc field public static final int NET_CAPABILITY_INTERNET = 12; // 0xc
@@ -334,6 +335,7 @@ package android.net {
field public static final int TRANSPORT_CELLULAR = 0; // 0x0 field public static final int TRANSPORT_CELLULAR = 0; // 0x0
field public static final int TRANSPORT_ETHERNET = 3; // 0x3 field public static final int TRANSPORT_ETHERNET = 3; // 0x3
field public static final int TRANSPORT_LOWPAN = 6; // 0x6 field public static final int TRANSPORT_LOWPAN = 6; // 0x6
field public static final int TRANSPORT_USB = 8; // 0x8
field public static final int TRANSPORT_VPN = 4; // 0x4 field public static final int TRANSPORT_VPN = 4; // 0x4
field public static final int TRANSPORT_WIFI = 1; // 0x1 field public static final int TRANSPORT_WIFI = 1; // 0x1
field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5 field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5

View File

@@ -275,6 +275,7 @@ public final class NetworkCapabilities implements Parcelable {
NET_CAPABILITY_ENTERPRISE, NET_CAPABILITY_ENTERPRISE,
NET_CAPABILITY_VSIM, NET_CAPABILITY_VSIM,
NET_CAPABILITY_BIP, NET_CAPABILITY_BIP,
NET_CAPABILITY_HEAD_UNIT,
}) })
public @interface NetCapability { } public @interface NetCapability { }
@@ -508,8 +509,13 @@ public final class NetworkCapabilities implements Parcelable {
@SystemApi @SystemApi
public static final int NET_CAPABILITY_BIP = 31; public static final int NET_CAPABILITY_BIP = 31;
/**
* Indicates that this network is connected to an automotive head unit.
*/
public static final int NET_CAPABILITY_HEAD_UNIT = 32;
private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS;
private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_BIP; private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_HEAD_UNIT;
/** /**
* Network capabilities that are expected to be mutable, i.e., can change while a particular * Network capabilities that are expected to be mutable, i.e., can change while a particular
@@ -527,7 +533,10 @@ public final class NetworkCapabilities implements Parcelable {
| (1 << NET_CAPABILITY_NOT_SUSPENDED) | (1 << NET_CAPABILITY_NOT_SUSPENDED)
| (1 << NET_CAPABILITY_PARTIAL_CONNECTIVITY) | (1 << NET_CAPABILITY_PARTIAL_CONNECTIVITY)
| (1 << NET_CAPABILITY_TEMPORARILY_NOT_METERED) | (1 << NET_CAPABILITY_TEMPORARILY_NOT_METERED)
| (1 << NET_CAPABILITY_NOT_VCN_MANAGED); | (1 << NET_CAPABILITY_NOT_VCN_MANAGED)
// The value of NET_CAPABILITY_HEAD_UNIT is 32, which cannot use int to do bit shift,
// otherwise there will be an overflow. Use long to do bit shift instead.
| (1L << NET_CAPABILITY_HEAD_UNIT);
/** /**
* Network capabilities that are not allowed in NetworkRequests. This exists because the * Network capabilities that are not allowed in NetworkRequests. This exists because the
@@ -867,6 +876,7 @@ public final class NetworkCapabilities implements Parcelable {
TRANSPORT_WIFI_AWARE, TRANSPORT_WIFI_AWARE,
TRANSPORT_LOWPAN, TRANSPORT_LOWPAN,
TRANSPORT_TEST, TRANSPORT_TEST,
TRANSPORT_USB,
}) })
public @interface Transport { } public @interface Transport { }
@@ -913,10 +923,15 @@ public final class NetworkCapabilities implements Parcelable {
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public static final int TRANSPORT_TEST = 7; public static final int TRANSPORT_TEST = 7;
/**
* Indicates this network uses a USB transport.
*/
public static final int TRANSPORT_USB = 8;
/** @hide */ /** @hide */
public static final int MIN_TRANSPORT = TRANSPORT_CELLULAR; public static final int MIN_TRANSPORT = TRANSPORT_CELLULAR;
/** @hide */ /** @hide */
public static final int MAX_TRANSPORT = TRANSPORT_TEST; public static final int MAX_TRANSPORT = TRANSPORT_USB;
/** @hide */ /** @hide */
public static boolean isValidTransport(@Transport int transportType) { public static boolean isValidTransport(@Transport int transportType) {
@@ -931,7 +946,8 @@ public final class NetworkCapabilities implements Parcelable {
"VPN", "VPN",
"WIFI_AWARE", "WIFI_AWARE",
"LOWPAN", "LOWPAN",
"TEST" "TEST",
"USB"
}; };
/** /**
@@ -2107,6 +2123,7 @@ public final class NetworkCapabilities implements Parcelable {
case NET_CAPABILITY_ENTERPRISE: return "ENTERPRISE"; case NET_CAPABILITY_ENTERPRISE: return "ENTERPRISE";
case NET_CAPABILITY_VSIM: return "VSIM"; case NET_CAPABILITY_VSIM: return "VSIM";
case NET_CAPABILITY_BIP: return "BIP"; case NET_CAPABILITY_BIP: return "BIP";
case NET_CAPABILITY_HEAD_UNIT: return "HEAD_UNIT";
default: return Integer.toString(capability); default: return Integer.toString(capability);
} }
} }

View File

@@ -72,7 +72,7 @@ java_library {
"ServiceConnectivityResources", "ServiceConnectivityResources",
], ],
static_libs: [ static_libs: [
"dnsresolver_aidl_interface-V7-java", "dnsresolver_aidl_interface-V8-java",
"modules-utils-os", "modules-utils-os",
"net-utils-device-common", "net-utils-device-common",
"net-utils-framework-common", "net-utils-framework-common",

View File

@@ -158,7 +158,7 @@ java_library_static {
"android.hardware.power.stats-V1-java", "android.hardware.power.stats-V1-java",
"android.hidl.manager-V1.2-java", "android.hidl.manager-V1.2-java",
"capture_state_listener-aidl-java", "capture_state_listener-aidl-java",
"dnsresolver_aidl_interface-V7-java", "dnsresolver_aidl_interface-V8-java",
"icu4j_calendar_astronomer", "icu4j_calendar_astronomer",
"netd-client", "netd-client",
"overlayable_policy_aidl-java", "overlayable_policy_aidl-java",

View File

@@ -101,7 +101,7 @@ class KeepaliveUtilsTest {
// Check valid customization generates expected array. // Check valid customization generates expected array.
val validRes = arrayOf("0,3", "1,0", "4,4") val validRes = arrayOf("0,3", "1,0", "4,4")
val expectedValidRes = intArrayOf(3, 0, 0, 0, 4, 0, 0, 0) val expectedValidRes = intArrayOf(3, 0, 0, 0, 4, 0, 0, 0, 0)
val mockContext = getMockedContextWithStringArrayRes( val mockContext = getMockedContextWithStringArrayRes(
R.array.config_networkSupportedKeepaliveCount, R.array.config_networkSupportedKeepaliveCount,