From ba7d9dddc76847e834fab513ae7c22086d6c5323 Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Fri, 4 Oct 2024 15:29:50 -0700 Subject: [PATCH] Handle CMD_IPV6_TETHER_UPDATE in UnavailableState Technically, UnavailableState should not handle any messages at all (and shouldn't exist). As the IpServer has already been removed from mTetherStates. However, sendInterfaceState() cleans up IPv6 tethering which eventually triggers a CMD_IPV6_TETHER_UPDATE. Instead of preventing the CMD_IPV6_TETHER_UPDATE, ignore it for now and remove this state entirely once we have rolled out SyncStateMachine. Bug: 368713124 Test: TH Change-Id: I32ae9583aa01411fa1fc299a0fc91138557b7ae2 --- Tethering/src/android/net/ip/IpServer.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java index b4c1b8a227..506fa564d1 100644 --- a/Tethering/src/android/net/ip/IpServer.java +++ b/Tethering/src/android/net/ip/IpServer.java @@ -1394,8 +1394,28 @@ public class IpServer extends StateMachineShim { @Override public void enter() { mLastError = TETHER_ERROR_NO_ERROR; + // TODO: clean this up after the synchronous state machine is fully rolled out. Clean up + // can be directly triggered after calling IpServer.stop() inside Tethering.java. sendInterfaceState(STATE_UNAVAILABLE); } + + @Override + public boolean processMessage(Message message) { + switch (message.what) { + case CMD_IPV6_TETHER_UPDATE: + // sendInterfaceState(STATE_UNAVAILABLE) triggers + // handleInterfaceServingStateInactive which in turn cleans up IPv6 tethering + // (and calls into IpServer one more time). At this point, this is the only + // message we potentially see in this state because this IpServer has already + // been removed from mTetherStates before transitioning to this State; however, + // handleInterfaceServiceStateInactive passes a reference. + // TODO: This can be removed once SyncStateMachine is rolled out and the + // teardown path is cleaned up. + return true; + default: + return false; + } + } } class WaitingForRestartState extends State {