diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-09-25 15:54:45 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-25 15:54:47 -0700 |
commit | e79275a9f6d5215fd9b833f8921939c0993389f2 (patch) | |
tree | 6921e67decd4383299147b1ee60155bb0b9dd75f /wifi | |
parent | be47828fbce3c647211b6948df4b61a27275cdff (diff) | |
parent | c41096e1b4bf453c195c8c46c5d296f2125d31f6 (diff) | |
download | frameworks_base-e79275a9f6d5215fd9b833f8921939c0993389f2.zip frameworks_base-e79275a9f6d5215fd9b833f8921939c0993389f2.tar.gz frameworks_base-e79275a9f6d5215fd9b833f8921939c0993389f2.tar.bz2 |
Merge "P2p fixes" into jb-mr1-dev
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiMonitor.java | 5 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pDevice.java | 12 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 52 |
3 files changed, 61 insertions, 8 deletions
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java index ab54a15..93ab4a4 100644 --- a/wifi/java/android/net/wifi/WifiMonitor.java +++ b/wifi/java/android/net/wifi/WifiMonitor.java @@ -217,6 +217,8 @@ public class WifiMonitor { pri_dev_type=1-0050F204-1 name='p2p-TEST2' config_methods=0x188 dev_capab=0x27 group_capab=0x0 */ private static final String P2P_PROV_DISC_SHOW_PIN_STR = "P2P-PROV-DISC-SHOW-PIN"; + /* P2P-PROV-DISC-FAILURE p2p_dev_addr=42:fc:89:e1:e2:27 */ + private static final String P2P_PROV_DISC_FAILURE_STR = "P2P-PROV-DISC-FAILURE"; /* * Protocol format is as follows.<br> @@ -319,6 +321,7 @@ public class WifiMonitor { public static final int P2P_PROV_DISC_SHOW_PIN_EVENT = BASE + 36; public static final int P2P_FIND_STOPPED_EVENT = BASE + 37; public static final int P2P_SERV_DISC_RESP_EVENT = BASE + 38; + public static final int P2P_PROV_DISC_FAILURE_EVENT = BASE + 39; /* hostap events */ public static final int AP_STA_DISCONNECTED_EVENT = BASE + 41; @@ -615,6 +618,8 @@ public class WifiMonitor { } else if (dataString.startsWith(P2P_PROV_DISC_SHOW_PIN_STR)) { mStateMachine.sendMessage(P2P_PROV_DISC_SHOW_PIN_EVENT, new WifiP2pProvDiscEvent(dataString)); + } else if (dataString.startsWith(P2P_PROV_DISC_FAILURE_STR)) { + mStateMachine.sendMessage(P2P_PROV_DISC_FAILURE_EVENT); } else if (dataString.startsWith(P2P_SERV_DISC_RESP_STR)) { List<WifiP2pServiceResponse> list = WifiP2pServiceResponse.newInstance(dataString); if (list != null) { diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java index 863a055..7d71539 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java @@ -260,6 +260,18 @@ public class WifiP2pDevice implements Parcelable { return (groupCapability & GROUP_CAPAB_GROUP_LIMIT) != 0; } + /** @hide */ + public void update(WifiP2pDevice device) { + if (device == null || device.deviceAddress == null) return; + deviceName = device.deviceName; + primaryDeviceType = device.primaryDeviceType; + secondaryDeviceType = device.secondaryDeviceType; + wpsConfigMethodsSupported = device.wpsConfigMethodsSupported; + deviceCapability = device.deviceCapability; + groupCapability = device.groupCapability; + wfdInfo = device.wfdInfo; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index b317f3f..8f0d8f0 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -346,6 +346,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { private GroupCreatedState mGroupCreatedState = new GroupCreatedState(); private UserAuthorizingJoinState mUserAuthorizingJoinState = new UserAuthorizingJoinState(); + private OngoingGroupRemovalState mOngoingGroupRemovalState = new OngoingGroupRemovalState(); private WifiNative mWifiNative = new WifiNative(mInterface); private WifiMonitor mWifiMonitor = new WifiMonitor(this, mWifiNative); @@ -389,6 +390,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { addState(mGroupNegotiationState, mGroupCreatingState); addState(mGroupCreatedState, mP2pEnabledState); addState(mUserAuthorizingJoinState, mGroupCreatedState); + addState(mOngoingGroupRemovalState, mGroupCreatedState); if (p2pSupported) { setInitialState(mP2pDisabledState); @@ -545,6 +547,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { case DhcpStateMachine.CMD_PRE_DHCP_ACTION: case DhcpStateMachine.CMD_POST_DHCP_ACTION: case DhcpStateMachine.CMD_ON_QUIT: + case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT: break; /* unexpected group created, remove */ case WifiMonitor.P2P_GROUP_STARTED_EVENT: @@ -1183,6 +1186,11 @@ public class WifiP2pService extends IWifiP2pManager.Stub { transitionTo(mGroupNegotiationState); } break; + case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT: + loge("provision discovery failed"); + handleGroupCreationFailure(); + transitionTo(mInactiveState); + break; default: return NOT_HANDLED; } @@ -1228,6 +1236,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { P2pStateMachine.this, mGroup.getInterface()); mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP); WifiP2pDevice groupOwner = mGroup.getOwner(); + /* update group owner details with the ones found at discovery */ + groupOwner.update(mPeers.get(groupOwner.deviceAddress)); mPeers.updateStatus(groupOwner.deviceAddress, WifiP2pDevice.CONNECTED); sendP2pPeersChangedBroadcast(); } @@ -1303,7 +1313,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { deviceAddress.equals(mSavedProvDiscDevice.deviceAddress)) { mSavedProvDiscDevice = null; } - mGroup.addClient(deviceAddress); + mGroup.addClient(mPeers.get(deviceAddress)); mPeers.updateStatus(deviceAddress, WifiP2pDevice.CONNECTED); if (DBG) logd(getName() + " ap sta connected"); sendP2pPeersChangedBroadcast(); @@ -1357,6 +1367,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { case WifiP2pManager.REMOVE_GROUP: if (DBG) logd(getName() + " remove group"); if (mWifiNative.p2pGroupRemove(mGroup.getInterface())) { + transitionTo(mOngoingGroupRemovalState); replyToMessage(message, WifiP2pManager.REMOVE_GROUP_SUCCEEDED); } else { handleGroupRemoved(); @@ -1534,6 +1545,30 @@ public class WifiP2pService extends IWifiP2pManager.Stub { } } + class OngoingGroupRemovalState extends State { + @Override + public void enter() { + if (DBG) logd(getName()); + } + + @Override + public boolean processMessage(Message message) { + if (DBG) logd(getName() + message.toString()); + switch (message.what) { + // Group removal ongoing. Multiple calls + // end up removing persisted network. Do nothing. + case WifiP2pManager.REMOVE_GROUP: + replyToMessage(message, WifiP2pManager.REMOVE_GROUP_SUCCEEDED); + break; + // Parent state will transition out of this state + // when removal is complete + default: + return NOT_HANDLED; + } + return HANDLED; + } + } + private void sendP2pStateChangedBroadcast(boolean enabled) { final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); @@ -1858,15 +1893,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub { } if (DBG) logd("netId related with " + dev.deviceAddress + " = " + netId); if (netId >= 0) { - // Invoke the persistent group. - if (!mWifiNative.p2pReinvoke(netId, dev.deviceAddress)) { - loge("p2pReinvoke() failed"); - return CONNECT_FAILURE; + if (mWifiNative.p2pReinvoke(netId, dev.deviceAddress)) { + // Save network id. It'll be used when an invitation result event is received. + mSavedPeerConfig.netId = netId; + return CONNECT_SUCCESS; + } else { + loge("p2pReinvoke() failed, update networks"); + updatePersistentNetworks(); + // continue with negotiation } - // Save network id. It'll be used when an invitation result event is received. - mSavedPeerConfig.netId = netId; - return CONNECT_SUCCESS; } } |