Skip to content

Commit 9cb9804

Browse files
committed
Retain device during connecting state
With join taking much longer, sometimes device can be lost from supplicant. Retain device to complete connection. Also, clear up stale peer data after find stops during inactive state. Bug: 6557725 Change-Id: I15b92e50a837481f974034b1ea7b32c8abee969e
1 parent 4dd5a25 commit 9cb9804

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

wifi/java/android/net/wifi/p2p/WifiP2pService.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ public boolean processMessage(Message message) {
425425
case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
426426
case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
427427
case WifiMonitor.P2P_GROUP_REMOVED_EVENT:
428+
case WifiMonitor.P2P_DEVICE_FOUND_EVENT:
429+
case WifiMonitor.P2P_DEVICE_LOST_EVENT:
430+
case WifiMonitor.P2P_FIND_STOPPED_EVENT:
431+
case WifiMonitor.P2P_SERV_DISC_RESP_EVENT:
432+
case WifiStateMachine.CMD_ENABLE_P2P:
433+
case WifiStateMachine.CMD_DISABLE_P2P:
428434
case PEER_CONNECTION_USER_ACCEPT:
429435
case PEER_CONNECTION_USER_REJECT:
430436
case GROUP_CREATING_TIMED_OUT:
@@ -837,6 +843,13 @@ public boolean processMessage(Message message) {
837843
transitionTo(mUserAuthorizingInvitationState);
838844
}
839845
break;
846+
case WifiMonitor.P2P_FIND_STOPPED_EVENT:
847+
// When discovery stops in inactive state, flush to clear
848+
// state peer data
849+
mWifiNative.p2pFlush();
850+
mServiceDiscReqId = null;
851+
sendP2pDiscoveryChangedBroadcast(false);
852+
break;
840853
case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
841854
case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
842855
case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
@@ -873,6 +886,7 @@ public void enter() {
873886
@Override
874887
public boolean processMessage(Message message) {
875888
if (DBG) logd(getName() + message.toString());
889+
boolean ret = HANDLED;
876890
switch (message.what) {
877891
case GROUP_CREATING_TIMED_OUT:
878892
if (mGroupCreatingTimeoutIndex == message.arg1) {
@@ -881,6 +895,16 @@ public boolean processMessage(Message message) {
881895
transitionTo(mInactiveState);
882896
}
883897
break;
898+
case WifiMonitor.P2P_DEVICE_LOST_EVENT:
899+
WifiP2pDevice device = (WifiP2pDevice) message.obj;
900+
if (!mSavedPeerConfig.deviceAddress.equals(device.deviceAddress)) {
901+
// Do the regular device lost handling
902+
ret = NOT_HANDLED;
903+
break;
904+
}
905+
// Do nothing
906+
if (DBG) logd("Retain connecting device " + device);
907+
break;
884908
case WifiP2pManager.DISCOVER_PEERS:
885909
/* Discovery will break negotiation */
886910
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
@@ -898,9 +922,9 @@ public boolean processMessage(Message message) {
898922
replyToMessage(message, WifiP2pManager.CANCEL_CONNECT_SUCCEEDED);
899923
break;
900924
default:
901-
return NOT_HANDLED;
925+
ret = NOT_HANDLED;
902926
}
903-
return HANDLED;
927+
return ret;
904928
}
905929
}
906930

0 commit comments

Comments
 (0)