Merge "Block Wifi P2p discovery while doing dhcp." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
116d466598
@@ -1771,6 +1771,14 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
// TODO: Remove this comment when the driver is fixed.
|
// TODO: Remove this comment when the driver is fixed.
|
||||||
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false);
|
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false);
|
||||||
mWifiNative.setPowerSave(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1797,6 +1805,8 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true);
|
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true);
|
||||||
mWifiNative.setPowerSave(true);
|
mWifiNative.setPowerSave(true);
|
||||||
|
|
||||||
|
mWifiP2pChannel.sendMessage(WifiP2pService.BLOCK_DISCOVERY, WifiP2pService.DISABLED);
|
||||||
|
|
||||||
// Set the coexistence mode back to its default value
|
// Set the coexistence mode back to its default value
|
||||||
mWifiNative.setBluetoothCoexistenceMode(
|
mWifiNative.setBluetoothCoexistenceMode(
|
||||||
mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE);
|
mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE);
|
||||||
@@ -2986,7 +2996,6 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case DhcpStateMachine.CMD_PRE_DHCP_ACTION:
|
case DhcpStateMachine.CMD_PRE_DHCP_ACTION:
|
||||||
handlePreDhcpSetup();
|
handlePreDhcpSetup();
|
||||||
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_PRE_DHCP_ACTION_COMPLETE);
|
|
||||||
break;
|
break;
|
||||||
case DhcpStateMachine.CMD_POST_DHCP_ACTION:
|
case DhcpStateMachine.CMD_POST_DHCP_ACTION:
|
||||||
handlePostDhcpSetup();
|
handlePostDhcpSetup();
|
||||||
|
|||||||
@@ -166,6 +166,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
|
|
||||||
public static final int SET_MIRACAST_MODE = BASE + 14;
|
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 final boolean mP2pSupported;
|
||||||
|
|
||||||
private WifiP2pDevice mThisDevice = new WifiP2pDevice();
|
private WifiP2pDevice mThisDevice = new WifiP2pDevice();
|
||||||
@@ -182,6 +192,15 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
* broadcasts
|
* broadcasts
|
||||||
*/
|
*/
|
||||||
private boolean mDiscoveryStarted;
|
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;
|
private NetworkInfo mNetworkInfo;
|
||||||
|
|
||||||
@@ -479,6 +498,20 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
AsyncChannel ac = new AsyncChannel();
|
AsyncChannel ac = new AsyncChannel();
|
||||||
ac.connect(mContext, getHandler(), message.replyTo);
|
ac.connect(mContext, getHandler(), message.replyTo);
|
||||||
break;
|
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:
|
case WifiP2pManager.DISCOVER_PEERS:
|
||||||
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
|
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
|
||||||
WifiP2pManager.BUSY);
|
WifiP2pManager.BUSY);
|
||||||
@@ -851,7 +884,33 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
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.
|
// do not send service discovery request while normal find operation.
|
||||||
clearSupplicantServiceRequest();
|
clearSupplicantServiceRequest();
|
||||||
if (mWifiNative.p2pFind(DISCOVER_TIMEOUT_S)) {
|
if (mWifiNative.p2pFind(DISCOVER_TIMEOUT_S)) {
|
||||||
@@ -874,6 +933,11 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WifiP2pManager.DISCOVER_SERVICES:
|
case WifiP2pManager.DISCOVER_SERVICES:
|
||||||
|
if (mDiscoveryBlocked) {
|
||||||
|
replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,
|
||||||
|
WifiP2pManager.BUSY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (DBG) logd(getName() + " discover services");
|
if (DBG) logd(getName() + " discover services");
|
||||||
if (!updateSupplicantServiceRequest()) {
|
if (!updateSupplicantServiceRequest()) {
|
||||||
replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,
|
replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,
|
||||||
|
|||||||
Reference in New Issue
Block a user