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

Commit 2ea4166c authored by Christopher Wiley's avatar Christopher Wiley
Browse files

Remove dead code from TetherInterfaceSM

Because no code outside of unittests ever issued these commands
to TetherInterfaceSM, we never executed any of the removed codepaths.

Change-Id: Id54f6e4eaeff8b3486cd78ddcc8c2a31011e6436
Test: Compiles.  Unittests continue to pass.
Bug: 28798823
parent 79e7fde0
Loading
Loading
Loading
Loading
+9 −37
Original line number Diff line number Diff line
@@ -54,18 +54,12 @@ public class TetherInterfaceSM extends StateMachine {
            MessageUtils.findMessageNames(messageClasses);

    private static final int BASE_IFACE              = Protocol.BASE_TETHERING + 100;
    // notification from the master SM that it's not in tether mode
    public static final int CMD_TETHER_MODE_DEAD            = BASE_IFACE + 1;
    // request from the user that it wants to tether
    public static final int CMD_TETHER_REQUESTED            = BASE_IFACE + 2;
    // request from the user that it wants to untether
    public static final int CMD_TETHER_UNREQUESTED          = BASE_IFACE + 3;
    // notification that this interface is down
    public static final int CMD_INTERFACE_DOWN              = BASE_IFACE + 4;
    // notification that this interface is up
    public static final int CMD_INTERFACE_UP                = BASE_IFACE + 5;
    // notification from the master SM that it had an error turning on cellular dun
    public static final int CMD_CELL_DUN_ERROR              = BASE_IFACE + 6;
    // notification from the master SM that it had trouble enabling IP Forwarding
    public static final int CMD_IP_FORWARDING_ENABLE_ERROR  = BASE_IFACE + 7;
    // notification from the master SM that it had trouble disabling IP Forwarding
@@ -309,7 +303,6 @@ public class TetherInterfaceSM extends StateMachine {
        public boolean processMessage(Message message) {
            maybeLogMessage(this, message.what);
            boolean retValue = true;
            boolean error = false;
            switch (message.what) {
                case CMD_TETHER_UNREQUESTED:
                case CMD_INTERFACE_DOWN:
@@ -365,15 +358,11 @@ public class TetherInterfaceSM extends StateMachine {
                    }
                    mMyUpstreamIfaceName = newUpstreamIfaceName;
                    break;
                case CMD_CELL_DUN_ERROR:
                case CMD_IP_FORWARDING_ENABLE_ERROR:
                case CMD_IP_FORWARDING_DISABLE_ERROR:
                case CMD_START_TETHERING_ERROR:
                case CMD_STOP_TETHERING_ERROR:
                case CMD_SET_DNS_FORWARDERS_ERROR:
                    error = true;
                    // fall through
                case CMD_TETHER_MODE_DEAD:
                    cleanupUpstream();
                    try {
                        mNMService.untetherInterface(mIfaceName);
@@ -382,20 +371,9 @@ public class TetherInterfaceSM extends StateMachine {
                                ConnectivityManager.TETHER_ERROR_UNTETHER_IFACE_ERROR);
                        break;
                    }
                    if (error) {
                    setLastErrorAndTransitionToInitialState(
                            ConnectivityManager.TETHER_ERROR_MASTER_ERROR);
                    break;
                    }
                    if (DBG) Log.d(TAG, "Tether lost upstream connection " + mIfaceName);
                    mTetherController.sendTetherStateChangedBroadcast();
                    if (mUsb) {
                        if (!configureUsbIface(false, mIfaceName)) {
                            setLastError(ConnectivityManager.TETHER_ERROR_IFACE_CFG_ERROR);
                        }
                    }
                    transitionTo(mInitialState);
                    break;
                default:
                    retValue = false;
                    break;
@@ -404,6 +382,13 @@ public class TetherInterfaceSM extends StateMachine {
        }
    }

    /**
     * This state is terminal for the per interface state machine.  At this
     * point, the master state machine should have removed this interface
     * specific state machine from its list of possible recipients of
     * tethering requests.  The state machine itself will hang around until
     * the garbage collector finds it.
     */
    class UnavailableState extends State {
        @Override
        public void enter() {
@@ -412,19 +397,6 @@ public class TetherInterfaceSM extends StateMachine {
            setTethered(false);
            mTetherController.sendTetherStateChangedBroadcast();
        }
        @Override
        public boolean processMessage(Message message) {
            boolean retValue = true;
            switch (message.what) {
                case CMD_INTERFACE_UP:
                    transitionTo(mInitialState);
                    break;
                default:
                    retValue = false;
                    break;
            }
            return retValue;
        }
    }

    void setLastErrorAndTransitionToInitialState(int error) {
+0 −3
Original line number Diff line number Diff line
@@ -92,10 +92,7 @@ public class TetherInterfaceSMTest {
    public void shouldDoNothingUntilRequested() {
        initStateMachine(false);
        final int [] NOOP_COMMANDS = {
            TetherInterfaceSM.CMD_TETHER_MODE_DEAD,
            TetherInterfaceSM.CMD_TETHER_UNREQUESTED,
            TetherInterfaceSM.CMD_INTERFACE_UP,
            TetherInterfaceSM.CMD_CELL_DUN_ERROR,
            TetherInterfaceSM.CMD_IP_FORWARDING_ENABLE_ERROR,
            TetherInterfaceSM.CMD_IP_FORWARDING_DISABLE_ERROR,
            TetherInterfaceSM.CMD_START_TETHERING_ERROR,