Skip to content

Commit 57e42f4

Browse files
committed
Update group capability before connect
We need to get the latest group capability information before connect now that the supplicant behavior is to do a delayed cleanup. Bug: 6613470 Change-Id: Ie374d750950f3bd4376fd6a767bb253fd7986eb1
1 parent 1ad66b2 commit 57e42f4

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

wifi/java/android/net/wifi/WifiNative.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,27 @@ public String p2pGetDeviceAddress() {
640640
return "";
641641
}
642642

643+
public int getGroupCapability(String deviceAddress) {
644+
int gc = 0;
645+
if (TextUtils.isEmpty(deviceAddress)) return gc;
646+
String peerInfo = p2pPeer(deviceAddress);
647+
if (TextUtils.isEmpty(peerInfo)) return gc;
648+
649+
String[] tokens = peerInfo.split("\n");
650+
for (String token : tokens) {
651+
if (token.startsWith("group_capab=")) {
652+
String[] nameValue = token.split("=");
653+
if (nameValue.length != 2) break;
654+
try {
655+
return Integer.decode(nameValue[1]);
656+
} catch(NumberFormatException e) {
657+
return gc;
658+
}
659+
}
660+
}
661+
return gc;
662+
}
663+
643664
public String p2pPeer(String deviceAddress) {
644665
return doStringCommand("P2P_PEER " + deviceAddress);
645666
}

wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.os.Parcelable;
2020
import android.os.Parcel;
2121
import android.net.wifi.p2p.WifiP2pDevice;
22+
import android.text.TextUtils;
2223
import android.util.Log;
2324

2425
import java.util.ArrayList;
@@ -83,11 +84,22 @@ public void update(WifiP2pDevice device) {
8384
mDevices.put(device.deviceAddress, device);
8485
}
8586

87+
/** @hide */
88+
public void updateGroupCapability(String deviceAddress, int groupCapab) {
89+
if (TextUtils.isEmpty(deviceAddress)) return;
90+
WifiP2pDevice d = mDevices.get(deviceAddress);
91+
if (d != null) {
92+
d.groupCapability = groupCapab;
93+
}
94+
}
95+
8696
/** @hide */
8797
public void updateStatus(String deviceAddress, int status) {
88-
if (deviceAddress == null) return;
98+
if (TextUtils.isEmpty(deviceAddress)) return;
8999
WifiP2pDevice d = mDevices.get(deviceAddress);
90-
d.status = status;
100+
if (d != null) {
101+
d.status = status;
102+
}
91103
}
92104

93105
/** @hide */

wifi/java/android/net/wifi/p2p/WifiP2pService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,10 @@ public boolean processMessage(Message message) {
764764
WifiP2pConfig config = (WifiP2pConfig) message.obj;
765765
mAutonomousGroup = false;
766766

767+
/* Update group capability before connect */
768+
int gc = mWifiNative.getGroupCapability(config.deviceAddress);
769+
mPeers.updateGroupCapability(config.deviceAddress, gc);
770+
767771
if (mSavedPeerConfig != null && config.deviceAddress.equals(
768772
mSavedPeerConfig.deviceAddress)) {
769773
mSavedPeerConfig = config;

0 commit comments

Comments
 (0)