Loading services/core/java/com/android/server/connectivity/Tethering.java +2 −3 Original line number Diff line number Diff line Loading @@ -90,9 +90,8 @@ import java.util.concurrent.atomic.AtomicInteger; /** * @hide * * Timeout * * TODO - look for parent classes and code sharing * This class holds much of the business logic to allow Android devices * to act as IP gateways via USB, BT, and WiFi interfaces. */ public class Tethering extends BaseNetworkObserver implements IControlsTethering { Loading services/core/java/com/android/server/connectivity/tethering/TetherInterfaceSM.java +2 −51 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ public class TetherInterfaceSM extends StateMachine { public static final int CMD_TETHER_CONNECTION_CHANGED = BASE_IFACE + 12; private final State mInitialState; private final State mStartingState; private final State mTetheredState; private final State mUnavailableState; Loading Loading @@ -111,8 +110,6 @@ public class TetherInterfaceSM extends StateMachine { mInitialState = new InitialState(); addState(mInitialState); mStartingState = new StartingState(); addState(mStartingState); mTetheredState = new TetheredState(); addState(mTetheredState); mUnavailableState = new UnavailableState(); Loading @@ -127,7 +124,6 @@ public class TetherInterfaceSM extends StateMachine { res += mIfaceName + " - "; IState current = getCurrentState(); if (current == mInitialState) res += "InitialState"; if (current == mStartingState) res += "StartingState"; if (current == mTetheredState) res += "TetheredState"; if (current == mUnavailableState) res += "UnavailableState"; if (isAvailable()) res += " - Available"; Loading Loading @@ -235,7 +231,7 @@ public class TetherInterfaceSM extends StateMachine { case CMD_TETHER_REQUESTED: setLastError(ConnectivityManager.TETHER_ERROR_NO_ERROR); mTetherController.notifyInterfaceTetheringReadiness(true, TetherInterfaceSM.this); transitionTo(mStartingState); transitionTo(mTetheredState); break; case CMD_INTERFACE_DOWN: transitionTo(mUnavailableState); Loading @@ -248,7 +244,7 @@ public class TetherInterfaceSM extends StateMachine { } } class StartingState extends State { class TetheredState extends State { @Override public void enter() { setAvailable(false); Loading @@ -261,51 +257,7 @@ public class TetherInterfaceSM extends StateMachine { return; } } mTetherController.sendTetherStateChangedBroadcast(); // Skipping StartingState transitionTo(mTetheredState); } @Override public boolean processMessage(Message message) { maybeLogMessage(this, message.what); boolean retValue = true; switch (message.what) { // maybe a parent class? case CMD_TETHER_UNREQUESTED: mTetherController.notifyInterfaceTetheringReadiness(false, TetherInterfaceSM.this); if (mUsb) { if (!configureUsbIface(false, mIfaceName)) { setLastErrorAndTransitionToInitialState( ConnectivityManager.TETHER_ERROR_IFACE_CFG_ERROR); break; } } transitionTo(mInitialState); 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: setLastErrorAndTransitionToInitialState( ConnectivityManager.TETHER_ERROR_MASTER_ERROR); break; case CMD_INTERFACE_DOWN: mTetherController.notifyInterfaceTetheringReadiness(false, TetherInterfaceSM.this); transitionTo(mUnavailableState); break; default: retValue = false; } return retValue; } } class TetheredState extends State { @Override public void enter() { try { mNMService.tetherInterface(mIfaceName); } catch (Exception e) { Loading @@ -321,7 +273,6 @@ public class TetherInterfaceSM extends StateMachine { return; } if (DBG) Log.d(TAG, "Tethered " + mIfaceName); setAvailable(false); setTethered(true); mTetherController.sendTetherStateChangedBroadcast(); } Loading services/tests/servicestests/src/com/android/server/connectivity/tethering/TetherInterfaceSMTest.java +0 −8 Original line number Diff line number Diff line Loading @@ -129,10 +129,6 @@ public class TetherInterfaceSMTest { dispatchCommand(TetherInterfaceSM.CMD_TETHER_REQUESTED); InOrder inOrder = inOrder(mTetherHelper, mNMService); inOrder.verify(mTetherHelper).notifyInterfaceTetheringReadiness(true, mTestedSm); // TODO: This broadcast should be removed. When we send this, we are neither // available nor tethered, which is misleading, since we're transitioning // from one to the other. inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); inOrder.verify(mNMService).tetherInterface(IFACE_NAME); inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); Loading Loading @@ -168,10 +164,6 @@ public class TetherInterfaceSMTest { inOrder.verify(mTetherHelper).notifyInterfaceTetheringReadiness(true, mTestedSm); inOrder.verify(mNMService).getInterfaceConfig(IFACE_NAME); inOrder.verify(mNMService).setInterfaceConfig(IFACE_NAME, mInterfaceConfiguration); // TODO: This broadcast should be removed. When we send this, we are neither // available nor tethered, which is misleading, since we're transitioning // from one to the other. inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); inOrder.verify(mNMService).tetherInterface(IFACE_NAME); inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); Loading Loading
services/core/java/com/android/server/connectivity/Tethering.java +2 −3 Original line number Diff line number Diff line Loading @@ -90,9 +90,8 @@ import java.util.concurrent.atomic.AtomicInteger; /** * @hide * * Timeout * * TODO - look for parent classes and code sharing * This class holds much of the business logic to allow Android devices * to act as IP gateways via USB, BT, and WiFi interfaces. */ public class Tethering extends BaseNetworkObserver implements IControlsTethering { Loading
services/core/java/com/android/server/connectivity/tethering/TetherInterfaceSM.java +2 −51 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ public class TetherInterfaceSM extends StateMachine { public static final int CMD_TETHER_CONNECTION_CHANGED = BASE_IFACE + 12; private final State mInitialState; private final State mStartingState; private final State mTetheredState; private final State mUnavailableState; Loading Loading @@ -111,8 +110,6 @@ public class TetherInterfaceSM extends StateMachine { mInitialState = new InitialState(); addState(mInitialState); mStartingState = new StartingState(); addState(mStartingState); mTetheredState = new TetheredState(); addState(mTetheredState); mUnavailableState = new UnavailableState(); Loading @@ -127,7 +124,6 @@ public class TetherInterfaceSM extends StateMachine { res += mIfaceName + " - "; IState current = getCurrentState(); if (current == mInitialState) res += "InitialState"; if (current == mStartingState) res += "StartingState"; if (current == mTetheredState) res += "TetheredState"; if (current == mUnavailableState) res += "UnavailableState"; if (isAvailable()) res += " - Available"; Loading Loading @@ -235,7 +231,7 @@ public class TetherInterfaceSM extends StateMachine { case CMD_TETHER_REQUESTED: setLastError(ConnectivityManager.TETHER_ERROR_NO_ERROR); mTetherController.notifyInterfaceTetheringReadiness(true, TetherInterfaceSM.this); transitionTo(mStartingState); transitionTo(mTetheredState); break; case CMD_INTERFACE_DOWN: transitionTo(mUnavailableState); Loading @@ -248,7 +244,7 @@ public class TetherInterfaceSM extends StateMachine { } } class StartingState extends State { class TetheredState extends State { @Override public void enter() { setAvailable(false); Loading @@ -261,51 +257,7 @@ public class TetherInterfaceSM extends StateMachine { return; } } mTetherController.sendTetherStateChangedBroadcast(); // Skipping StartingState transitionTo(mTetheredState); } @Override public boolean processMessage(Message message) { maybeLogMessage(this, message.what); boolean retValue = true; switch (message.what) { // maybe a parent class? case CMD_TETHER_UNREQUESTED: mTetherController.notifyInterfaceTetheringReadiness(false, TetherInterfaceSM.this); if (mUsb) { if (!configureUsbIface(false, mIfaceName)) { setLastErrorAndTransitionToInitialState( ConnectivityManager.TETHER_ERROR_IFACE_CFG_ERROR); break; } } transitionTo(mInitialState); 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: setLastErrorAndTransitionToInitialState( ConnectivityManager.TETHER_ERROR_MASTER_ERROR); break; case CMD_INTERFACE_DOWN: mTetherController.notifyInterfaceTetheringReadiness(false, TetherInterfaceSM.this); transitionTo(mUnavailableState); break; default: retValue = false; } return retValue; } } class TetheredState extends State { @Override public void enter() { try { mNMService.tetherInterface(mIfaceName); } catch (Exception e) { Loading @@ -321,7 +273,6 @@ public class TetherInterfaceSM extends StateMachine { return; } if (DBG) Log.d(TAG, "Tethered " + mIfaceName); setAvailable(false); setTethered(true); mTetherController.sendTetherStateChangedBroadcast(); } Loading
services/tests/servicestests/src/com/android/server/connectivity/tethering/TetherInterfaceSMTest.java +0 −8 Original line number Diff line number Diff line Loading @@ -129,10 +129,6 @@ public class TetherInterfaceSMTest { dispatchCommand(TetherInterfaceSM.CMD_TETHER_REQUESTED); InOrder inOrder = inOrder(mTetherHelper, mNMService); inOrder.verify(mTetherHelper).notifyInterfaceTetheringReadiness(true, mTestedSm); // TODO: This broadcast should be removed. When we send this, we are neither // available nor tethered, which is misleading, since we're transitioning // from one to the other. inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); inOrder.verify(mNMService).tetherInterface(IFACE_NAME); inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); Loading Loading @@ -168,10 +164,6 @@ public class TetherInterfaceSMTest { inOrder.verify(mTetherHelper).notifyInterfaceTetheringReadiness(true, mTestedSm); inOrder.verify(mNMService).getInterfaceConfig(IFACE_NAME); inOrder.verify(mNMService).setInterfaceConfig(IFACE_NAME, mInterfaceConfiguration); // TODO: This broadcast should be removed. When we send this, we are neither // available nor tethered, which is misleading, since we're transitioning // from one to the other. inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); inOrder.verify(mNMService).tetherInterface(IFACE_NAME); inOrder.verify(mTetherHelper).sendTetherStateChangedBroadcast(); Loading