summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2013-07-11 17:12:35 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-07-11 17:12:35 -0700
commitd76a6851a896e6708e9d5d8469ec1c0f97b99e79 (patch)
tree60980d100a554e9266c253a7da91975f84caed61 /wifi/java
parentdd893b9db3101eae79c89fb888c8080ed2ba0c66 (diff)
parent6f2b31fcf57e4e7f5cd8af9b66619c8f5825a850 (diff)
downloadframeworks_base-d76a6851a896e6708e9d5d8469ec1c0f97b99e79.zip
frameworks_base-d76a6851a896e6708e9d5d8469ec1c0f97b99e79.tar.gz
frameworks_base-d76a6851a896e6708e9d5d8469ec1c0f97b99e79.tar.bz2
am 6f2b31fc: am 56a7e4ad: am 116d4665: Merge "Block Wifi P2p discovery while doing dhcp." into jb-mr2-dev
* commit '6f2b31fcf57e4e7f5cd8af9b66619c8f5825a850': Block Wifi P2p discovery while doing dhcp.
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java11
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pService.java64
2 files changed, 74 insertions, 1 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index d509b37..8b9fe55 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1773,6 +1773,14 @@ public class WifiStateMachine extends StateMachine {
// TODO: Remove this comment when the driver is fixed.
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false);
mWifiNative.setPowerSave(false);
+
+ /* P2p discovery breaks dhcp, shut it down in order to get through this */
+ Message msg = new Message();
+ msg.what = WifiP2pService.BLOCK_DISCOVERY;
+ msg.arg1 = WifiP2pService.ENABLED;
+ msg.arg2 = DhcpStateMachine.CMD_PRE_DHCP_ACTION_COMPLETE;
+ msg.obj = mDhcpStateMachine;
+ mWifiP2pChannel.sendMessage(msg);
}
@@ -1799,6 +1807,8 @@ public class WifiStateMachine extends StateMachine {
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true);
mWifiNative.setPowerSave(true);
+ mWifiP2pChannel.sendMessage(WifiP2pService.BLOCK_DISCOVERY, WifiP2pService.DISABLED);
+
// Set the coexistence mode back to its default value
mWifiNative.setBluetoothCoexistenceMode(
mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE);
@@ -2995,7 +3005,6 @@ public class WifiStateMachine extends StateMachine {
switch (message.what) {
case DhcpStateMachine.CMD_PRE_DHCP_ACTION:
handlePreDhcpSetup();
- mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_PRE_DHCP_ACTION_COMPLETE);
break;
case DhcpStateMachine.CMD_POST_DHCP_ACTION:
handlePostDhcpSetup();
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 4cfc4ac..68a082a 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -166,6 +166,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
public static final int SET_MIRACAST_MODE = BASE + 14;
+ // During dhcp (and perhaps other times) we can't afford to drop packets
+ // but Discovery will switch our channel enough we will.
+ // msg.arg1 = ENABLED for blocking, DISABLED for resumed.
+ // msg.arg2 = msg to send when blocked
+ // msg.obj = StateMachine to send to when blocked
+ public static final int BLOCK_DISCOVERY = BASE + 15;
+
+ public static final int ENABLED = 1;
+ public static final int DISABLED = 0;
+
private final boolean mP2pSupported;
private WifiP2pDevice mThisDevice = new WifiP2pDevice();
@@ -182,6 +192,15 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
* broadcasts
*/
private boolean mDiscoveryStarted;
+ /* Track whether servcice/peer discovery is blocked in favor of other wifi actions
+ * (notably dhcp)
+ */
+ private boolean mDiscoveryBlocked;
+
+ /*
+ * remember if we were in a scan when it had to be stopped
+ */
+ private boolean mDiscoveryPostponed = false;
private NetworkInfo mNetworkInfo;
@@ -479,6 +498,20 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
AsyncChannel ac = new AsyncChannel();
ac.connect(mContext, getHandler(), message.replyTo);
break;
+ case BLOCK_DISCOVERY:
+ mDiscoveryBlocked = (message.arg1 == ENABLED ? true : false);
+ // always reset this - we went to a state that doesn't support discovery so
+ // it would have stopped regardless
+ mDiscoveryPostponed = false;
+ if (mDiscoveryBlocked) {
+ try {
+ StateMachine m = (StateMachine)message.obj;
+ m.sendMessage(message.arg2);
+ } catch (Exception e) {
+ loge("unable to send BLOCK_DISCOVERY response: " + e);
+ }
+ }
+ break;
case WifiP2pManager.DISCOVER_PEERS:
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
WifiP2pManager.BUSY);
@@ -851,7 +884,33 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
}
break;
}
+ case BLOCK_DISCOVERY:
+ boolean blocked = (message.arg1 == ENABLED ? true : false);
+ if (mDiscoveryBlocked == blocked) break;
+ mDiscoveryBlocked = blocked;
+ if (blocked && mDiscoveryStarted) {
+ mWifiNative.p2pStopFind();
+ mDiscoveryPostponed = true;
+ }
+ if (!blocked && mDiscoveryPostponed) {
+ mDiscoveryPostponed = false;
+ mWifiNative.p2pFind(DISCOVER_TIMEOUT_S);
+ }
+ if (blocked) {
+ try {
+ StateMachine m = (StateMachine)message.obj;
+ m.sendMessage(message.arg2);
+ } catch (Exception e) {
+ loge("unable to send BLOCK_DISCOVERY response: " + e);
+ }
+ }
+ break;
case WifiP2pManager.DISCOVER_PEERS:
+ if (mDiscoveryBlocked) {
+ replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
+ WifiP2pManager.BUSY);
+ break;
+ }
// do not send service discovery request while normal find operation.
clearSupplicantServiceRequest();
if (mWifiNative.p2pFind(DISCOVER_TIMEOUT_S)) {
@@ -874,6 +933,11 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
}
break;
case WifiP2pManager.DISCOVER_SERVICES:
+ if (mDiscoveryBlocked) {
+ replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,
+ WifiP2pManager.BUSY);
+ break;
+ }
if (DBG) logd(getName() + " discover services");
if (!updateSupplicantServiceRequest()) {
replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,