diff options
author | 2025-03-12 21:19:45 +0000 | |
---|---|---|
committer | 2025-03-21 15:53:30 -0700 | |
commit | 8a6b0e8611f837c15b325e61b814745a9422f78a (patch) | |
tree | 6533b57d7dc72e466b33c6fded035f971ddde246 | |
parent | efa2e9c61f9eb2f40a452b95ff28cc7960fc58b7 (diff) |
Don't send BLOCK_DISCOVERY when P2P is in Disabled state
Before triggering the DHCP, clientModeImpl send BLOCK_DISCOVERY
to stop the P2P discovery. And wait for CMD_PRE_DHCP_ACTION_COMPLETE
message back from P2P module. This is done to protect the DHCP exchange.
But if p2p is in a waiting state(Transitioned from Disabled state) for user
response to create the interface, all the messages will be deferred.
So clientModeImpl doesn't get CMD_PRE_DHCP_ACTION_COMPLETE response from P2P module.
This blocks the DHCP when p2p is in waiting state.
A change (Iacf3e35e82c3cf06e9986dba3535a1ac71b4dd88) was added in last year
to prevent BLOCK_DISCOVERY message exchange when P2P is in waiting state.
But that didn't fix the issue. So modified the
logic to, not to send BLOCK_DISCOVER if p2p service is not running.
Bug: 391509308
Test: atest ClientModeImplTest
Flag: EXEMPT bugfix
Change-Id: I65ffa331c5bfeb2c4143c9e21ddc780ee66f36c1
4 files changed, 14 insertions, 18 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 9bcf627f9a..08e93bdf7f 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -3659,7 +3659,7 @@ public class ClientModeImpl extends StateMachine implements ClientMode { // Update link layer stats getWifiLinkLayerStats(); - if (mWifiP2pConnection.isConnected() && !mWifiP2pConnection.isP2pInWaitingState()) { + if (mWifiP2pConnection.isConnected() && !mWifiP2pConnection.isP2pInDisabledState()) { // P2P discovery breaks DHCP, so shut it down in order to get through this. // Once P2P service receives this message and processes it accordingly, it is supposed // to send arg2 (i.e. CMD_PRE_DHCP_ACTION_COMPLETE) in a new Message.what back to diff --git a/service/java/com/android/server/wifi/WifiP2pConnection.java b/service/java/com/android/server/wifi/WifiP2pConnection.java index 907ab0d197..f1c665dd01 100644 --- a/service/java/com/android/server/wifi/WifiP2pConnection.java +++ b/service/java/com/android/server/wifi/WifiP2pConnection.java @@ -45,8 +45,8 @@ public class WifiP2pConnection { private AsyncChannel mWifiP2pChannel; private boolean mTemporarilyDisconnectWifi = false; - /** Used to check if P2P state machine is in waitingState */ - private boolean mWaitingState = false; + /** Used to check if P2P state machine is in DisabledState */ + private boolean mDisabledState = false; public WifiP2pConnection(Context context, Looper looper, ActiveModeWarden activeModeWarden) { mContext = context; @@ -191,12 +191,12 @@ public class WifiP2pConnection { return mTemporarilyDisconnectWifi; } - public void setP2pInWaitingState(boolean inWaitingState) { - mWaitingState = inWaitingState; + public void setP2pInDisabledState(boolean inDisabledState) { + mDisabledState = inDisabledState; } - /** whether the P2P state machine is in waitingState for user response to create interface */ - public boolean isP2pInWaitingState() { - return mWaitingState; + /** whether the P2P state machine is in disabled state */ + public boolean isP2pInDisabledState() { + return mDisabledState; } } diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index 450f3b4ec7..05a21be4a3 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -3026,12 +3026,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { @Override public void enterImpl() { - + mWifiInjector.getWifiP2pConnection().setP2pInDisabledState(true); } @Override public void exitImpl() { - + mWifiInjector.getWifiP2pConnection().setP2pInDisabledState(false); } @Override @@ -3055,14 +3055,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { Log.i(TAG, "No valid package name, ignore ENABLE_P2P"); break; } - mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(true); int proceedWithOperation = mInterfaceConflictManager.manageInterfaceConflictForStateMachine( TAG, message, mP2pStateMachine, mWaitingState, mP2pDisabledState, HalDeviceManager.HDM_CREATE_IFACE_P2P, createRequestorWs(message.sendingUid, packageName), false /* bypassDialog */); - mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(false); if (proceedWithOperation == InterfaceConflictManager.ICM_ABORT_COMMAND) { Log.e(TAG, "User refused to set up P2P"); updateThisDevice(WifiP2pDevice.UNAVAILABLE); @@ -3131,14 +3129,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { Log.i(TAG, "No valid package name, do not set up the P2P interface"); return NOT_HANDLED; } - mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(true); int proceedWithOperation = mInterfaceConflictManager.manageInterfaceConflictForStateMachine( TAG, message, mP2pStateMachine, mWaitingState, mP2pDisabledState, HalDeviceManager.HDM_CREATE_IFACE_P2P, createRequestorWs(message.sendingUid, packageName), false /* bypassDialog */); - mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(false); if (proceedWithOperation == InterfaceConflictManager.ICM_ABORT_COMMAND) { Log.e(TAG, "User refused to set up P2P"); updateThisDevice(WifiP2pDevice.UNAVAILABLE); diff --git a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 19f15a21a7..37ae9aa13e 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -11126,8 +11126,8 @@ public class ClientModeImplTest extends WifiBaseTest { } /** - * Verify that during DHCP process, 1. If P2P is in waiting state, clientModeImpl doesn't send a - * message to block P2P discovery. 2. If P2P is not in waiting state, clientModeImpl sends a + * Verify that during DHCP process, 1. If P2P is in disabled state, clientModeImpl doesn't send + * a message to block P2P discovery. 2. If P2P is not in disabled state, clientModeImpl sends a * message to block P2P discovery. 3. On DHCP completion, clientModeImpl sends a message to * unblock P2P discovery. */ @@ -11162,7 +11162,7 @@ public class ClientModeImplTest extends WifiBaseTest { assertEquals("L3ProvisioningState", getCurrentState().getName()); when(mWifiP2pConnection.isConnected()).thenReturn(true); - when(mWifiP2pConnection.isP2pInWaitingState()).thenReturn(true); + when(mWifiP2pConnection.isP2pInDisabledState()).thenReturn(true); mIpClientCallback.onPreDhcpAction(); mLooper.dispatchAll(); @@ -11170,7 +11170,7 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mIpClient).completedPreDhcpAction(); when(mWifiP2pConnection.isConnected()).thenReturn(true); - when(mWifiP2pConnection.isP2pInWaitingState()).thenReturn(false); + when(mWifiP2pConnection.isP2pInDisabledState()).thenReturn(false); mIpClientCallback.onPreDhcpAction(); mLooper.dispatchAll(); |