Skip to content

Commit ca1269f

Browse files
committed
Fail fast on persistent failure
Other fixes - 20s idle time out was added a work around for an earlier cavium issue. Reduce to 10s - Reload network fix when supplicant issues an error for a persistent network Bug: 7248890 Change-Id: I6cea7c88c75aaca40ddcb973404e93ec0f66cbc4
1 parent d973039 commit ca1269f

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
123123
private static final Boolean TRY_REINVOCATION = true;;
124124
private static final Boolean NO_REINVOCATION = false;
125125

126+
private static final Boolean RELOAD = true;
127+
private static final Boolean NO_RELOAD = false;
128+
126129
private static final int CONNECT_FAILURE = -1;
127130
private static final int CONNECT_SUCCESS = 0;
128131
private static final int NEEDS_PROVISION_REQ = 1;
@@ -135,7 +138,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
135138
private static final int DISCOVER_TIMEOUT_S = 120;
136139

137140
/* Idle time after a peer is gone when the group is torn down */
138-
private static final int GROUP_IDLE_TIME_S = 20;
141+
private static final int GROUP_IDLE_TIME_S = 10;
139142

140143
private static final int BASE = Protocol.BASE_WIFI_P2P_SERVICE;
141144

@@ -1222,7 +1225,7 @@ public boolean processMessage(Message message) {
12221225
/*
12231226
* update cache information and set network id to mGroup.
12241227
*/
1225-
updatePersistentNetworks();
1228+
updatePersistentNetworks(NO_RELOAD);
12261229
String devAddr = mGroup.getOwner().deviceAddress;
12271230
mGroup.setNetworkId(mGroups.getNetworkId(devAddr,
12281231
mGroup.getNetworkName()));
@@ -1269,11 +1272,14 @@ public boolean processMessage(Message message) {
12691272
if (DBG) logd("Remove unknown client from the list");
12701273
removeClientFromList(netId, mSavedPeerConfig.deviceAddress, true);
12711274
}
1272-
}
12731275

1274-
// invocation is failed or deferred. Try another way to connect.
1275-
mSavedPeerConfig.netId = WifiP2pGroup.PERSISTENT_NET_ID;
1276-
if (connect(mSavedPeerConfig, NO_REINVOCATION) == CONNECT_FAILURE) {
1276+
// invocation is failed or deferred. Try another way to connect.
1277+
mSavedPeerConfig.netId = WifiP2pGroup.PERSISTENT_NET_ID;
1278+
if (connect(mSavedPeerConfig, NO_REINVOCATION) == CONNECT_FAILURE) {
1279+
handleGroupCreationFailure();
1280+
transitionTo(mInactiveState);
1281+
}
1282+
} else {
12771283
handleGroupCreationFailure();
12781284
transitionTo(mInactiveState);
12791285
}
@@ -1759,14 +1765,16 @@ public void onCancel(DialogInterface arg0) {
17591765
* Synchronize the persistent group list between
17601766
* wpa_supplicant and mGroups.
17611767
*/
1762-
private void updatePersistentNetworks() {
1768+
private void updatePersistentNetworks(boolean reload) {
17631769
String listStr = mWifiNative.listNetworks();
17641770
if (listStr == null) return;
17651771

17661772
boolean isSaveRequired = false;
17671773
String[] lines = listStr.split("\n");
17681774
if (lines == null) return;
17691775

1776+
if (reload) mGroups.clear();
1777+
17701778
// Skip the first line, which is a header
17711779
for (int i = 1; i < lines.length; i++) {
17721780
String[] result = lines[i].split("\t");
@@ -1821,9 +1829,9 @@ private void updatePersistentNetworks() {
18211829
isSaveRequired = true;
18221830
}
18231831

1824-
if (isSaveRequired) {
1825-
sendP2pPersistentGroupsChangedBroadcast();
1832+
if (reload || isSaveRequired) {
18261833
mWifiNative.saveConfig();
1834+
sendP2pPersistentGroupsChangedBroadcast();
18271835
}
18281836
}
18291837

@@ -1900,7 +1908,7 @@ private int connect(WifiP2pConfig config, boolean tryInvocation) {
19001908
return CONNECT_SUCCESS;
19011909
} else {
19021910
loge("p2pReinvoke() failed, update networks");
1903-
updatePersistentNetworks();
1911+
updatePersistentNetworks(RELOAD);
19041912
// continue with negotiation
19051913
}
19061914
}
@@ -2112,7 +2120,7 @@ private void initializeP2pSettings() {
21122120
mServiceTransactionId = 0;
21132121
mServiceDiscReqId = null;
21142122

2115-
updatePersistentNetworks();
2123+
updatePersistentNetworks(RELOAD);
21162124
}
21172125

21182126
private void updateThisDevice(int status) {

0 commit comments

Comments
 (0)