Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dfbd68f authored by Jean Chalard's avatar Jean Chalard Committed by Gerrit Code Review
Browse files

Merge "Remove deprecated NMS methods from V" into main

parents 7d558a42 a8200f9d
Loading
Loading
Loading
Loading
+29 −10
Original line number Diff line number Diff line
@@ -125,50 +125,65 @@ interface INetworkManagementService
    /**
     * Returns true if IP forwarding is enabled
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Use {@code android.net.INetd#ipfwdEnabled}")
    boolean getIpForwardingEnabled();

    /**
     * Enables/Disables IP Forwarding
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
            + "{@code android.net.TetheringManager#startTethering}. See also "
            + "{@code INetd#ipfwdEnableForwarding(String)}.")
    void setIpForwardingEnabled(boolean enabled);

    /**
     * Start tethering services with the specified dhcp server range
     * arg is a set of start end pairs defining the ranges.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "{@code android.net.TetheringManager#startTethering}")
    void startTethering(in String[] dhcpRanges);

    /**
     * Stop currently running tethering services
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "{@code android.net.TetheringManager#stopTethering(int)}")
    void stopTethering();

    /**
     * Returns true if tethering services are started
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Generally track your own tethering requests. "
            + "See also {@code android.net.INetd#tetherIsEnabled()}")
    boolean isTetheringStarted();

    /**
     * Tethers the specified interface
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
            + "{@code android.net.TetheringManager#startTethering}. See also "
            + "{@code com.android.net.module.util.NetdUtils#tetherInterface}.")
    void tetherInterface(String iface);

    /**
     * Untethers the specified interface
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Avoid using this directly. Instead, disable "
            + "tethering with {@code android.net.TetheringManager#stopTethering(int)}. "
            + "See also {@code NetdUtils#untetherInterface}.")
    void untetherInterface(String iface);

    /**
     * Returns a list of currently tethered interfaces
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "{@code android.net.TetheringManager#getTetheredIfaces()}")
    String[] listTetheredInterfaces();

    /**
@@ -176,13 +191,17 @@ interface INetworkManagementService
     *  The address and netmask of the external interface is used for
     *  the NAT'ed network.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
            + "{@code android.net.TetheringManager#startTethering}.")
    void enableNat(String internalInterface, String externalInterface);

    /**
     *  Disables Network Address Translation between two interfaces.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
            publicAlternatives = "Avoid using this directly. Instead, disable tethering with "
            + "{@code android.net.TetheringManager#stopTethering(int)}.")
    void disableNat(String internalInterface, String externalInterface);

    /**
+34 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IBatteryStats;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.HexDump;
import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.NetdUtils;
import com.android.net.module.util.NetdUtils.ModifyOperation;
import com.android.net.module.util.PermissionUtils;
@@ -779,7 +780,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public boolean getIpForwardingEnabled() throws IllegalStateException{
        PermissionUtils.enforceNetworkStackPermission(mContext);

        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException(
                    "NMS#getIpForwardingEnabled not supported in V+");
        }
        try {
            return mNetdService.ipfwdEnabled();
        } catch (RemoteException | ServiceSpecificException e) {
@@ -790,6 +794,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void setIpForwardingEnabled(boolean enable) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException(
                    "NMS#setIpForwardingEnabled not supported in V+");
        }
        try {
            if (enable) {
                mNetdService.ipfwdEnableForwarding("tethering");
@@ -804,6 +812,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void startTethering(String[] dhcpRange) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#startTethering not supported in V+");
        }
        try {
            NetdUtils.tetherStart(mNetdService, true /* usingLegacyDnsProxy */, dhcpRange);
        } catch (RemoteException | ServiceSpecificException e) {
@@ -814,6 +825,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void stopTethering() {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#stopTethering not supported in V+");
        }
        try {
            mNetdService.tetherStop();
        } catch (RemoteException | ServiceSpecificException e) {
@@ -824,6 +838,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public boolean isTetheringStarted() {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#isTetheringStarted not supported in V+");
        }
        try {
            return mNetdService.tetherIsEnabled();
        } catch (RemoteException | ServiceSpecificException e) {
@@ -834,6 +851,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void tetherInterface(String iface) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#tetherInterface not supported in V+");
        }
        try {
            final LinkAddress addr = getInterfaceConfig(iface).getLinkAddress();
            final IpPrefix dest = new IpPrefix(addr.getAddress(), addr.getPrefixLength());
@@ -846,6 +866,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void untetherInterface(String iface) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#untetherInterface not supported in V+");
        }
        try {
            NetdUtils.untetherInterface(mNetdService, iface);
        } catch (RemoteException | ServiceSpecificException e) {
@@ -856,6 +879,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public String[] listTetheredInterfaces() {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException(
                    "NMS#listTetheredInterfaces not supported in V+");
        }
        try {
            return mNetdService.tetherInterfaceList();
        } catch (RemoteException | ServiceSpecificException e) {
@@ -866,6 +893,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void enableNat(String internalInterface, String externalInterface) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#enableNat not supported in V+");
        }
        try {
            mNetdService.tetherAddForward(internalInterface, externalInterface);
        } catch (RemoteException | ServiceSpecificException e) {
@@ -876,6 +906,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
    @Override
    public void disableNat(String internalInterface, String externalInterface) {
        PermissionUtils.enforceNetworkStackPermission(mContext);
        if (SdkLevel.isAtLeastV()) {
            throw new UnsupportedOperationException("NMS#disableNat not supported in V+");
        }
        try {
            mNetdService.tetherRemoveForward(internalInterface, externalInterface);
        } catch (RemoteException | ServiceSpecificException e) {