summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-10-12 15:52:13 -0700
committerIrfan Sheriff <isheriff@google.com>2012-10-14 22:41:30 -0700
commit41de2404658c7c6faf6c78e777ba50af11784f5c (patch)
treed19683ae615b59bf24459f4794211246220365d2 /wifi
parent17cf1f2bbc3f7d4f367dbbee935d2939957c0ef6 (diff)
downloadframeworks_base-41de2404658c7c6faf6c78e777ba50af11784f5c.zip
frameworks_base-41de2404658c7c6faf6c78e777ba50af11784f5c.tar.gz
frameworks_base-41de2404658c7c6faf6c78e777ba50af11784f5c.tar.bz2
Fix handling of lost device
We did not update a lost device notice to apps properly. This causes incorrect connection initiation without a discovery which leads to failed invitation requests to supplicant. Bug: 7328758 Change-Id: If4b594c737d639d0f553188309319fba4e3ee7b7
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java9
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pService.java27
2 files changed, 32 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java b/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
index 2093bda..f14c305 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
@@ -114,6 +114,15 @@ public class WifiP2pDeviceList implements Parcelable {
return mDevices.remove(device.deviceAddress) != null;
}
+ /** Returns true if any device the list was removed @hide */
+ public boolean remove(WifiP2pDeviceList list) {
+ boolean ret = false;
+ for (WifiP2pDevice d : list.mDevices.values()) {
+ if (remove(d)) ret = true;
+ }
+ return ret;
+ }
+
/** Get the list of devices */
public Collection<WifiP2pDevice> getDeviceList() {
return Collections.unmodifiableCollection(mDevices.values());
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index ca329e6..70baf13 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -355,6 +355,15 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
private WifiMonitor mWifiMonitor = new WifiMonitor(this, mWifiNative);
private final WifiP2pDeviceList mPeers = new WifiP2pDeviceList();
+ /* During a connection, supplicant can tell us that a device was lost. From a supplicant's
+ * perspective, the discovery stops during connection and it purges device since it does
+ * not get latest updates about the device without being in discovery state.
+ *
+ * From the framework perspective, the device is still there since we are connecting or
+ * connected to it. so we keep these devices in a seperate list, so that they are removed
+ * when connection is cancelled or lost
+ */
+ private final WifiP2pDeviceList mPeersLostDuringConnection = new WifiP2pDeviceList();
private final WifiP2pGroupList mGroups = new WifiP2pGroupList(null,
new GroupDeleteListener() {
@Override
@@ -746,6 +755,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
+ case WifiMonitor.SUP_DISCONNECTION_EVENT:
+ loge("Unexpected loss of p2p socket connection");
+ transitionTo(mP2pDisabledState);
+ break;
case WifiStateMachine.CMD_ENABLE_P2P:
//Nothing to do
break;
@@ -1066,7 +1079,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
break;
}
// Do nothing
- if (DBG) logd("Retain connecting device " + device);
+ if (DBG) logd("Add device to lost list " + device);
+ mPeersLostDuringConnection.update(device);
break;
case WifiP2pManager.DISCOVER_PEERS:
/* Discovery will break negotiation */
@@ -1401,7 +1415,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
device = (WifiP2pDevice) message.obj;
//Device loss for a connected device indicates it is not in discovery any more
if (mGroup.contains(device)) {
- if (DBG) logd("Lost " + device +" , do nothing");
+ if (DBG) logd("Add device to lost list " + device);
+ mPeersLostDuringConnection.update(device);
return HANDLED;
}
// Do the regular device lost handling
@@ -1853,7 +1868,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
private int connect(WifiP2pConfig config, boolean tryInvocation) {
if (config == null) {
- loge("invalid argument.");
+ loge("config is null");
return CONNECT_FAILURE;
}
@@ -1863,7 +1878,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
WifiP2pDevice dev = mPeers.get(config.deviceAddress);
if (dev == null) {
- loge("target device is not found.");
+ loge("target device not found " + config.deviceAddress);
return CONNECT_FAILURE;
}
@@ -2142,6 +2157,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
/* After cancelling group formation, new connections on existing peers can fail
* at supplicant. Flush and restart discovery */
mWifiNative.p2pFlush();
+ if (mPeers.remove(mPeersLostDuringConnection)) sendP2pPeersChangedBroadcast();
+ mPeersLostDuringConnection.clear();
mServiceDiscReqId = null;
sendMessage(WifiP2pManager.DISCOVER_PEERS);
}
@@ -2174,6 +2191,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
mGroup = null;
mWifiNative.p2pFlush();
+ if (mPeers.remove(mPeersLostDuringConnection)) sendP2pPeersChangedBroadcast();
+ mPeersLostDuringConnection.clear();
mServiceDiscReqId = null;
if (changed) sendP2pPeersChangedBroadcast();
}