Merge "bpf_connectivity_headers - remove visibility from //system/netd/tests"
diff --git a/Cronet/TEST_MAPPING b/Cronet/TEST_MAPPING
index 815d496..b1f3088 100644
--- a/Cronet/TEST_MAPPING
+++ b/Cronet/TEST_MAPPING
@@ -1,7 +1,7 @@
{
- "postsubmit": [
+ "presubmit": [
{
- "name": "CronetApiTest"
+ "name": "CtsCronetTestCases"
}
]
}
diff --git a/Cronet/tests/cts/Android.bp b/Cronet/tests/cts/Android.bp
index e71c707..56f3ddb 100644
--- a/Cronet/tests/cts/Android.bp
+++ b/Cronet/tests/cts/Android.bp
@@ -18,12 +18,16 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-java_library {
- name: "CronetApiCommonTests",
+android_test {
+ name: "CtsCronetTestCases",
+ compile_multilib: "both", // Include both the 32 and 64 bit versions
+ defaults: ["cts_defaults"],
+ sdk_version: "test_current",
srcs: ["src/**/*.java"],
static_libs: [
"androidx.test.rules",
"androidx.core_core",
+ "ctstestrunner-axt",
"junit",
],
libs: [
@@ -33,14 +37,11 @@
"androidx.annotation_annotation",
"framework-cronet",
],
-}
-android_test {
- name: "CronetApiTest",
- sdk_version: "test_current",
- test_suites: ["device-tests"],
- certificate: "platform",
- static_libs: [
- "CronetApiCommonTests",
+ // Tag this as a cts test artifact
+ test_suites: [
+ "cts",
+ "general-tests",
+ "mts-tethering"
],
}
diff --git a/Cronet/tests/cts/AndroidManifest.xml b/Cronet/tests/cts/AndroidManifest.xml
index db0f0b3..6797586 100644
--- a/Cronet/tests/cts/AndroidManifest.xml
+++ b/Cronet/tests/cts/AndroidManifest.xml
@@ -18,18 +18,21 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.chromium.net.test">
+ package="android.cronet.cts">
<uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <application>
- <uses-library android:name="android.test.runner" />
- <uses-library android:name="framework-cronet" />
+ <application android:usesCleartextTraffic="true">
+ <uses-library android:name="android.test.runner"/>
+ <uses-library android:name="framework-cronet"/>
</application>
<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="org.chromium.net.test"
- android:label="Cronet API Networking Tests" />
-</manifest>
\ No newline at end of file
+ android:targetPackage="android.cronet.cts"
+ android:label="CTS tests of android.cronet">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener"/>
+ </instrumentation>
+</manifest>
diff --git a/Cronet/tests/cts/AndroidTest.xml b/Cronet/tests/cts/AndroidTest.xml
new file mode 100644
index 0000000..3ab60e4
--- /dev/null
+++ b/Cronet/tests/cts/AndroidTest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Config for CTS Cronet test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="networking" />
+ <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
+ <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+ <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsCronetTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.cronet.cts" />
+ <option name="runtime-hint" value="10s" />
+ </test>
+
+ <!-- Only run CtsCronetTestcasess in MTS if the Tethering Mainline module is installed. -->
+ <object type="module_controller"
+ class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+ <option name="mainline-module-package-name" value="com.google.android.tethering" />
+ </object>
+</configuration>
diff --git a/Cronet/tests/cts/OWNERS b/Cronet/tests/cts/OWNERS
new file mode 100644
index 0000000..acb6ee6
--- /dev/null
+++ b/Cronet/tests/cts/OWNERS
@@ -0,0 +1,8 @@
+# Bug component: 31808
+
+set noparent
+file:platform/packages/modules/Connectivity:master:/OWNERS_core_networking_xts
+
+# TODO: Temp ownership to develop cronet CTS
+colibie@google.com #{LAST_RESORT_SUGGESTION}
+prohr@google.com #{LAST_RESORT_SUGGESTION}
diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java
index f0dd030..b3ec805 100644
--- a/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -146,6 +146,7 @@
import com.android.networkstack.tethering.util.PrefixUtils;
import com.android.networkstack.tethering.util.TetheringUtils;
import com.android.networkstack.tethering.util.VersionedBroadcastListener;
+import com.android.networkstack.tethering.wear.WearableConnectionManager;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -257,6 +258,7 @@
private final BpfCoordinator mBpfCoordinator;
private final PrivateAddressCoordinator mPrivateAddressCoordinator;
private final TetheringMetrics mTetheringMetrics;
+ private final WearableConnectionManager mWearableConnectionManager;
private int mActiveDataSubId = INVALID_SUBSCRIPTION_ID;
private volatile TetheringConfiguration mConfig;
@@ -393,6 +395,12 @@
}
});
+ if (SdkLevel.isAtLeastT() && mConfig.isWearTetheringEnabled()) {
+ mWearableConnectionManager = mDeps.getWearableConnectionManager(mContext);
+ } else {
+ mWearableConnectionManager = null;
+ }
+
startStateMachineUpdaters();
}
@@ -2638,6 +2646,13 @@
mPrivateAddressCoordinator.dump(pw);
pw.decreaseIndent();
+ if (mWearableConnectionManager != null) {
+ pw.println("WearableConnectionManager:");
+ pw.increaseIndent();
+ mWearableConnectionManager.dump(pw);
+ pw.decreaseIndent();
+ }
+
pw.println("Log:");
pw.increaseIndent();
if (CollectionUtils.contains(args, "--short")) {
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
index 903de9d..b6591a9 100644
--- a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
+++ b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
@@ -123,6 +123,13 @@
*/
public static final String TETHER_FORCE_USB_FUNCTIONS =
"tether_force_usb_functions";
+
+ /**
+ * Experiment flag to enable TETHERING_WEAR.
+ */
+ public static final String TETHER_ENABLE_WEAR_TETHERING =
+ "tether_enable_wear_tethering";
+
/**
* Default value that used to periodic polls tether offload stats from tethering offload HAL
* to make the data warnings work.
@@ -158,6 +165,8 @@
private final boolean mEnableWifiP2pDedicatedIp;
private final int mP2pLeasesSubnetPrefixLength;
+ private final boolean mEnableWearTethering;
+
private final int mUsbTetheringFunction;
protected final ContentResolver mContentResolver;
@@ -234,6 +243,8 @@
mP2pLeasesSubnetPrefixLength = getP2pLeasesSubnetPrefixLengthFromRes(res, configLog);
+ mEnableWearTethering = shouldEnableWearTethering(ctx);
+
configLog.log(toString());
}
@@ -317,6 +328,11 @@
return mP2pLeasesSubnetPrefixLength;
}
+ /** Returns true if wearable device tethering is enabled. */
+ public boolean isWearTetheringEnabled() {
+ return mEnableWearTethering;
+ }
+
/** Does the dumping.*/
public void dump(PrintWriter pw) {
pw.print("activeDataSubId: ");
@@ -362,6 +378,9 @@
pw.print("p2pLeasesSubnetPrefixLength: ");
pw.println(mP2pLeasesSubnetPrefixLength);
+ pw.print("enableWearTethering: ");
+ pw.println(mEnableWearTethering);
+
pw.print("mUsbTetheringFunction: ");
pw.println(isUsingNcm() ? "NCM" : "RNDIS");
}
@@ -387,6 +406,7 @@
isCarrierConfigAffirmsEntitlementCheckRequired));
sj.add(String.format("enableBpfOffload:%s", mEnableBpfOffload));
sj.add(String.format("enableLegacyDhcpServer:%s", mEnableLegacyDhcpServer));
+ sj.add(String.format("enableWearTethering:%s", mEnableWearTethering));
return String.format("TetheringConfiguration{%s}", sj.toString());
}
@@ -557,6 +577,11 @@
TETHER_ENABLE_LEGACY_DHCP_SERVER, false /** defaultValue */);
}
+ private boolean shouldEnableWearTethering(Context context) {
+ return SdkLevel.isAtLeastT()
+ && isTetheringFeatureEnabled(context, TETHER_ENABLE_WEAR_TETHERING);
+ }
+
private boolean getDeviceConfigBoolean(final String name, final boolean defaultValue) {
// Due to the limitation of static mock for testing, using #getDeviceConfigProperty instead
// of DeviceConfig#getBoolean. If using #getBoolean here, the test can't know that the
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
index 611d1cf..741a5c5 100644
--- a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
+++ b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.net.INetd;
import android.net.ip.IpServer;
+import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -29,12 +30,14 @@
import android.text.TextUtils;
import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
import com.android.internal.util.StateMachine;
import com.android.net.module.util.SharedLog;
import com.android.networkstack.apishim.BluetoothPanShimImpl;
import com.android.networkstack.apishim.common.BluetoothPanShim;
import com.android.networkstack.tethering.metrics.TetheringMetrics;
+import com.android.networkstack.tethering.wear.WearableConnectionManager;
import java.util.ArrayList;
@@ -171,4 +174,12 @@
public TetheringMetrics getTetheringMetrics() {
return new TetheringMetrics();
}
+
+ /**
+ * Returns the implementation of WearableConnectionManager.
+ */
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ public WearableConnectionManager getWearableConnectionManager(Context ctx) {
+ return new WearableConnectionManager(ctx);
+ }
}
diff --git a/Tethering/src/com/android/networkstack/tethering/wear/WearableConnectionManager.java b/Tethering/src/com/android/networkstack/tethering/wear/WearableConnectionManager.java
new file mode 100644
index 0000000..a1b535a
--- /dev/null
+++ b/Tethering/src/com/android/networkstack/tethering/wear/WearableConnectionManager.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.networkstack.tethering.wear;
+
+import android.content.Context;
+import android.os.Build;
+
+import androidx.annotation.RequiresApi;
+
+import com.android.internal.util.IndentingPrintWriter;
+
+/**
+ * Manages Bluetooth connections from Wearable devices.
+ */
+public class WearableConnectionManager {
+ @RequiresApi(Build.VERSION_CODES.TIRAMISU)
+ public WearableConnectionManager(Context context) {
+ }
+
+ public void dump(IndentingPrintWriter pw) {
+ }
+}