Loading wifi/java/android/net/wifi/WifiNative.java +2 −9 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); } Loading wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java +9 −0 Original line number Diff line number Diff line Loading @@ -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()) { Loading wifi/java/android/net/wifi/p2p/WifiP2pService.java +22 −10 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading Loading @@ -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)) { Loading @@ -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 { Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -983,6 +983,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { mWifiNative.p2pConnect(mSavedPeerConfig, FORM_GROUP); transitionTo(mGroupNegotiationState); } else { mJoinExistingGroup = false; transitionTo(mUserAuthorizingInvitationState); } } Loading Loading @@ -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); Loading Loading @@ -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 Loading Loading
wifi/java/android/net/wifi/WifiNative.java +2 −9 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); } Loading
wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java +9 −0 Original line number Diff line number Diff line Loading @@ -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()) { Loading
wifi/java/android/net/wifi/p2p/WifiP2pService.java +22 −10 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading Loading @@ -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)) { Loading @@ -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 { Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -983,6 +983,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { mWifiNative.p2pConnect(mSavedPeerConfig, FORM_GROUP); transitionTo(mGroupNegotiationState); } else { mJoinExistingGroup = false; transitionTo(mUserAuthorizingInvitationState); } } Loading Loading @@ -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); Loading Loading @@ -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 Loading