summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-05-11 14:46:46 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-11 14:46:46 -0700
commitba1db8a5912c989e493269b8751c7e9d312e0eae (patch)
tree84f2df678ef02b7856d253031b9fcf67ab086741 /wifi
parentdcc1996b768ef36ed82f09dfd682914db1e9a2e9 (diff)
parent10ca870d3b58ec6fd62b85466ec1211fca77d33e (diff)
downloadframeworks_base-ba1db8a5912c989e493269b8751c7e9d312e0eae.zip
frameworks_base-ba1db8a5912c989e493269b8751c7e9d312e0eae.tar.gz
frameworks_base-ba1db8a5912c989e493269b8751c7e9d312e0eae.tar.bz2
Merge "Fix wifi direct issues" into jb-dev
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java11
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java9
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pService.java32
3 files changed, 33 insertions, 19 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 73618f6..0a87a53 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -442,8 +442,8 @@ public class WifiNative {
return doBooleanCommand("SET p2p_ssid_postfix " + postfix);
}
- public boolean setP2pGroupIdle(int time) {
- return doBooleanCommand("SET p2p_group_idle " + time);
+ public boolean setP2pGroupIdle(String iface, int time) {
+ return doBooleanCommand("SET interface=" + iface + " p2p_group_idle " + time);
}
public void setPowerSave(boolean enabled) {
@@ -624,13 +624,6 @@ public class WifiNative {
return "";
}
- public boolean isGroupOwner(String deviceAddress) {
- /* BSS returns details only for a GO */
- String bssInfo = doStringCommand("BSS p2p_dev_addr=" + deviceAddress);
- if (TextUtils.isEmpty(bssInfo)) return false;
- return true;
- }
-
public String p2pPeer(String deviceAddress) {
return doStringCommand("P2P_PEER " + deviceAddress);
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java b/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
index 8942ff1..b2347c8 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
@@ -108,6 +108,15 @@ public class WifiP2pDeviceList implements Parcelable {
return Collections.unmodifiableCollection(mDevices.values());
}
+ /** @hide */
+ public boolean isGroupOwner(String deviceAddress) {
+ if (deviceAddress != null) {
+ WifiP2pDevice device = mDevices.get(deviceAddress);
+ if (device != null) return device.isGroupOwner();
+ }
+ return false;
+ }
+
public String toString() {
StringBuffer sbuf = new StringBuffer();
for (WifiP2pDevice device : mDevices.values()) {
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index b4a879a..cc49cae 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -159,6 +159,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
* is invoked */
private boolean mAutonomousGroup;
+ /* Invitation to join an existing p2p group */
+ private boolean mJoinExistingGroup;
+
/* Track whether we are in p2p discovery. This is used to avoid sending duplicate
* broadcasts
*/
@@ -761,7 +764,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
//Stop discovery before issuing connect
mWifiNative.p2pStopFind();
- if (mWifiNative.isGroupOwner(mSavedPeerConfig.deviceAddress)) {
+ if (mPeers.isGroupOwner(mSavedPeerConfig.deviceAddress)) {
p2pConnectWithPinDisplay(mSavedPeerConfig, JOIN_GROUP);
} else {
p2pConnectWithPinDisplay(mSavedPeerConfig, FORM_GROUP);
@@ -778,7 +781,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
mWifiNative.p2pStopFind();
//If peer is a GO, we do not need to send provisional discovery,
//the supplicant takes care of it.
- if (mWifiNative.isGroupOwner(mSavedPeerConfig.deviceAddress)) {
+ if (mPeers.isGroupOwner(mSavedPeerConfig.deviceAddress)) {
if (DBG) logd("Sending join to GO");
p2pConnectWithPinDisplay(mSavedPeerConfig, JOIN_GROUP);
transitionTo(mGroupNegotiationState);
@@ -795,6 +798,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
mSavedPeerConfig = (WifiP2pConfig) message.obj;
+ mAutonomousGroup = false;
+ mJoinExistingGroup = false;
if (!sendConnectNoticeToApp(mPeers.get(mSavedPeerConfig.deviceAddress),
mSavedPeerConfig)) {
transitionTo(mUserAuthorizingInvitationState);
@@ -824,6 +829,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
}
}
+ mAutonomousGroup = false;
+ mJoinExistingGroup = true;
//TODO In the p2p client case, we should set source address correctly.
if (!sendConnectNoticeToApp(mPeers.get(mSavedPeerConfig.deviceAddress),
mSavedPeerConfig)) {
@@ -840,8 +847,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
break;
case WifiP2pManager.CREATE_GROUP:
mAutonomousGroup = true;
- // An autonomous GO requires group idle settings to be reset
- mWifiNative.setP2pGroupIdle(0);
if (mWifiNative.p2pGroupAdd()) {
replyToMessage(message, WifiP2pManager.CREATE_GROUP_SUCCEEDED);
} else {
@@ -863,11 +868,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
if (DBG) logd(getName());
sendMessageDelayed(obtainMessage(GROUP_CREATING_TIMED_OUT,
++mGroupCreatingTimeoutIndex, 0), GROUP_CREATING_WAIT_TIME_MS);
-
- // Set default group idle settings
- if (!mAutonomousGroup) {
- mWifiNative.setP2pGroupIdle(GROUP_IDLE_TIME_S);
- }
}
@Override
@@ -921,7 +921,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
switch (message.what) {
case PEER_CONNECTION_USER_ACCEPT:
//TODO: handle persistence
- if (mWifiNative.isGroupOwner(mSavedPeerConfig.deviceAddress)) {
+ if (mJoinExistingGroup) {
p2pConnectWithPinDisplay(mSavedPeerConfig, JOIN_GROUP);
} else {
p2pConnectWithPinDisplay(mSavedPeerConfig, FORM_GROUP);
@@ -983,6 +983,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
mWifiNative.p2pConnect(mSavedPeerConfig, FORM_GROUP);
transitionTo(mGroupNegotiationState);
} else {
+ mJoinExistingGroup = false;
transitionTo(mUserAuthorizingInvitationState);
}
}
@@ -1031,6 +1032,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
if (mGroup.isGroupOwner()) {
startDhcpServer(mGroup.getInterface());
} else {
+ // Set group idle only for a client on the group interface to speed up
+ // disconnect when GO is gone. Setting group idle time for a group owner
+ // causes connectivity issues for new clients
+ mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(mContext,
P2pStateMachine.this, mGroup.getInterface());
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
@@ -1455,6 +1460,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
sendMessage(PEER_CONNECTION_USER_REJECT);
}
})
+ .setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface arg0) {
+ if (DBG) logd(getName() + " ignore connect");
+ sendMessage(PEER_CONNECTION_USER_REJECT);
+ }
+ })
.create();
//make the enter pin area or the display pin area visible