Merge "cronet: Copy configuration for CTS from //cts/tests/test"
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) {
+ }
+}