summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-10-15 10:23:22 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-15 10:23:23 -0700
commitd86a532c5271dfbfe7378ddeb6700fafd92ecbcc (patch)
tree5e1b6f5de9ef427d1e1853d987b3177e7c22d624 /wifi/java/android
parent48df14919602a7aac9ea9d0f0a2a3afe04eb6e0b (diff)
parent41de2404658c7c6faf6c78e777ba50af11784f5c (diff)
downloadframeworks_base-d86a532c5271dfbfe7378ddeb6700fafd92ecbcc.zip
frameworks_base-d86a532c5271dfbfe7378ddeb6700fafd92ecbcc.tar.gz
frameworks_base-d86a532c5271dfbfe7378ddeb6700fafd92ecbcc.tar.bz2
Merge "Fix handling of lost device" into jb-mr1-dev
Diffstat (limited to 'wifi/java/android')
-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();
}