diff --git a/Tethering/Android.bp b/Tethering/Android.bp index dd60be7c78..414e50a103 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -81,7 +81,10 @@ java_defaults { "framework-tethering.impl", ], manifest: "AndroidManifestBase.xml", - lint: { strict_updatability_linting: true }, + lint: { + strict_updatability_linting: true, + error_checks: ["NewApi"], + }, } // build tethering static library, used to compile both variants of the tethering. @@ -215,7 +218,10 @@ android_app { use_embedded_native_libs: true, privapp_allowlist: ":privapp_allowlist_com.android.tethering", apex_available: ["com.android.tethering"], - lint: { strict_updatability_linting: true }, + lint: { + strict_updatability_linting: true, + error_checks: ["NewApi"], + }, } sdk { diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java index 79d9a23820..c065cd6652 100644 --- a/Tethering/src/android/net/ip/IpServer.java +++ b/Tethering/src/android/net/ip/IpServer.java @@ -838,7 +838,7 @@ public class IpServer extends StateMachineShim { private void addInterfaceToNetwork(final int netId, @NonNull final String ifaceName) { try { - if (null != mRoutingCoordinator.value) { + if (SdkLevel.isAtLeastS() && null != mRoutingCoordinator.value) { // TODO : remove this call in favor of using the LocalNetworkConfiguration // correctly, which will let ConnectivityService do it automatically. mRoutingCoordinator.value.addInterfaceToNetwork(netId, ifaceName); @@ -852,7 +852,7 @@ public class IpServer extends StateMachineShim { private void addInterfaceForward(@NonNull final String fromIface, @NonNull final String toIface) throws ServiceSpecificException, RemoteException { - if (null != mRoutingCoordinator.value) { + if (SdkLevel.isAtLeastS() && null != mRoutingCoordinator.value) { mRoutingCoordinator.value.addInterfaceForward(fromIface, toIface); } else { mNetd.tetherAddForward(fromIface, toIface); @@ -862,7 +862,7 @@ public class IpServer extends StateMachineShim { private void removeInterfaceForward(@NonNull final String fromIface, @NonNull final String toIface) { - if (null != mRoutingCoordinator.value) { + if (SdkLevel.isAtLeastS() && null != mRoutingCoordinator.value) { try { mRoutingCoordinator.value.removeInterfaceForward(fromIface, toIface); } catch (ServiceSpecificException e) { diff --git a/Tethering/src/com/android/networkstack/tethering/OffloadHalAidlImpl.java b/Tethering/src/com/android/networkstack/tethering/OffloadHalAidlImpl.java index e7dc7575af..9ef0f45513 100644 --- a/Tethering/src/com/android/networkstack/tethering/OffloadHalAidlImpl.java +++ b/Tethering/src/com/android/networkstack/tethering/OffloadHalAidlImpl.java @@ -19,18 +19,21 @@ package com.android.networkstack.tethering; import static com.android.networkstack.tethering.OffloadHardwareInterface.OFFLOAD_HAL_VERSION_AIDL; import android.annotation.NonNull; +import android.annotation.TargetApi; import android.hardware.tetheroffload.ForwardedStats; import android.hardware.tetheroffload.IOffload; import android.hardware.tetheroffload.ITetheringOffloadCallback; import android.hardware.tetheroffload.NatTimeoutUpdate; import android.hardware.tetheroffload.NetworkProtocol; import android.hardware.tetheroffload.OffloadCallbackEvent; +import android.os.Build; import android.os.Handler; import android.os.NativeHandle; import android.os.ParcelFileDescriptor; import android.os.ServiceManager; import android.system.OsConstants; +import com.android.internal.annotations.VisibleForTesting; import com.android.modules.utils.build.SdkLevel; import com.android.net.module.util.SharedLog; import com.android.networkstack.tethering.OffloadHardwareInterface.OffloadHalCallback; @@ -40,6 +43,7 @@ import java.util.ArrayList; /** * The implementation of IOffloadHal which based on Stable AIDL interface */ +@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class OffloadHalAidlImpl implements IOffloadHal { private static final String TAG = OffloadHalAidlImpl.class.getSimpleName(); private static final String HAL_INSTANCE_NAME = IOffload.DESCRIPTOR + "/default"; @@ -52,6 +56,7 @@ public class OffloadHalAidlImpl implements IOffloadHal { private TetheringOffloadCallback mTetheringOffloadCallback; + @VisibleForTesting public OffloadHalAidlImpl(int version, @NonNull IOffload offload, @NonNull Handler handler, @NonNull SharedLog log) { mOffloadVersion = version;