Merge "Support losing the upstream in IpServerTest."
diff --git a/Tethering/Android.bp b/Tethering/Android.bp
index 3111ab7..6589c84 100644
--- a/Tethering/Android.bp
+++ b/Tethering/Android.bp
@@ -98,7 +98,6 @@
// Build system doesn't track transitive dependeicies for jni_libs, list all the dependencies
// explicitly.
jni_libs: [
- "liblog",
"libnativehelper_compat_libc++",
"libtetherutilsjni",
],
diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp
index cb0de7a..1a3d5b6 100644
--- a/Tethering/common/TetheringLib/Android.bp
+++ b/Tethering/common/TetheringLib/Android.bp
@@ -83,7 +83,6 @@
name: "framework-tethering-stubs",
srcs: [":framework-tethering-stubs-sources"],
libs: ["framework-all"],
- static_libs: ["tethering-aidl-interfaces-java"],
sdk_version: "core_platform",
}
diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java b/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java
index df87ac9..a18f5da 100644
--- a/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java
+++ b/Tethering/common/TetheringLib/src/android/net/TetheringConstants.java
@@ -33,6 +33,9 @@
*/
@SystemApi(client = MODULE_LIBRARIES)
public class TetheringConstants {
+ /** An explicit private class to avoid exposing constructor.*/
+ private TetheringConstants() { }
+
/**
* Extra used for communicating with the TetherService. Includes the type of tethering to
* enable if any.
diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java
index 0d369dc..3acc766 100644
--- a/Tethering/src/android/net/ip/IpServer.java
+++ b/Tethering/src/android/net/ip/IpServer.java
@@ -675,7 +675,12 @@
final String upstreamIface = v6only.getInterfaceName();
params = new RaParams();
- params.mtu = v6only.getMtu();
+ // We advertise an mtu lower by 16, which is the closest multiple of 8 >= 14,
+ // the ethernet header size. This makes kernel ebpf tethering offload happy.
+ // This hack should be reverted once we have the kernel fixed up.
+ // Note: this will automatically clamp to at least 1280 (ipv6 minimum mtu)
+ // see RouterAdvertisementDaemon.java putMtu()
+ params.mtu = v6only.getMtu() - 16;
params.hasDefaultRoute = v6only.hasIpv6DefaultRoute();
if (params.hasDefaultRoute) params.hopLimit = getHopLimit(upstreamIface);
diff --git a/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
index e462d36..84ca656 100644
--- a/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
+++ b/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
@@ -16,6 +16,8 @@
package com.android.server.connectivity.tethering;
+import static android.Manifest.permission.NETWORK_SETTINGS;
+import static android.Manifest.permission.NETWORK_STACK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.hardware.usb.UsbManager.USB_CONFIGURED;
import static android.hardware.usb.UsbManager.USB_CONNECTED;
@@ -150,10 +152,6 @@
private static final boolean DBG = false;
private static final boolean VDBG = false;
- // TODO: add the below permissions to @SystemApi
- private static final String PERMISSION_NETWORK_SETTINGS = "android.permission.NETWORK_SETTINGS";
- private static final String PERMISSION_NETWORK_STACK = "android.permission.NETWORK_STACK";
-
private static final Class[] sMessageClasses = {
Tethering.class, TetherMasterSM.class, IpServer.class
};
@@ -314,9 +312,13 @@
startStateMachineUpdaters(mHandler);
startTrackDefaultNetwork();
- getWifiManager().registerSoftApCallback(
- mHandler::post /* executor */,
- new TetheringSoftApCallback());
+
+ final WifiManager wifiManager = getWifiManager();
+ if (wifiManager != null) {
+ wifiManager.registerSoftApCallback(
+ mHandler::post /* executor */,
+ new TetheringSoftApCallback());
+ }
}
private void startStateMachineUpdaters(Handler handler) {
@@ -1983,9 +1985,9 @@
/** Register tethering event callback */
void registerTetheringEventCallback(ITetheringEventCallback callback) {
final boolean hasListPermission =
- hasCallingPermission(PERMISSION_NETWORK_SETTINGS)
+ hasCallingPermission(NETWORK_SETTINGS)
|| hasCallingPermission(PERMISSION_MAINLINE_NETWORK_STACK)
- || hasCallingPermission(PERMISSION_NETWORK_STACK);
+ || hasCallingPermission(NETWORK_STACK);
mHandler.post(() -> {
mTetheringEventCallbacks.register(callback, new CallbackCookie(hasListPermission));
final TetheringCallbackStartedParcel parcel = new TetheringCallbackStartedParcel();