am ca96a322: Merge "Update group capability before connect" into jb-dev
* commit 'ca96a322f0485db9f0beed243e10a607c909729f': Update group capability before connect
This commit is contained in:
@@ -640,6 +640,27 @@ public class WifiNative {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getGroupCapability(String deviceAddress) {
|
||||
int gc = 0;
|
||||
if (TextUtils.isEmpty(deviceAddress)) return gc;
|
||||
String peerInfo = p2pPeer(deviceAddress);
|
||||
if (TextUtils.isEmpty(peerInfo)) return gc;
|
||||
|
||||
String[] tokens = peerInfo.split("\n");
|
||||
for (String token : tokens) {
|
||||
if (token.startsWith("group_capab=")) {
|
||||
String[] nameValue = token.split("=");
|
||||
if (nameValue.length != 2) break;
|
||||
try {
|
||||
return Integer.decode(nameValue[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
return gc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
public String p2pPeer(String deviceAddress) {
|
||||
return doStringCommand("P2P_PEER " + deviceAddress);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.net.wifi.p2p;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Parcel;
|
||||
import android.net.wifi.p2p.WifiP2pDevice;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -84,10 +85,21 @@ public class WifiP2pDeviceList implements Parcelable {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void updateStatus(String deviceAddress, int status) {
|
||||
if (deviceAddress == null) return;
|
||||
public void updateGroupCapability(String deviceAddress, int groupCapab) {
|
||||
if (TextUtils.isEmpty(deviceAddress)) return;
|
||||
WifiP2pDevice d = mDevices.get(deviceAddress);
|
||||
d.status = status;
|
||||
if (d != null) {
|
||||
d.groupCapability = groupCapab;
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void updateStatus(String deviceAddress, int status) {
|
||||
if (TextUtils.isEmpty(deviceAddress)) return;
|
||||
WifiP2pDevice d = mDevices.get(deviceAddress);
|
||||
if (d != null) {
|
||||
d.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
|
||||
@@ -764,6 +764,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
WifiP2pConfig config = (WifiP2pConfig) message.obj;
|
||||
mAutonomousGroup = false;
|
||||
|
||||
/* Update group capability before connect */
|
||||
int gc = mWifiNative.getGroupCapability(config.deviceAddress);
|
||||
mPeers.updateGroupCapability(config.deviceAddress, gc);
|
||||
|
||||
if (mSavedPeerConfig != null && config.deviceAddress.equals(
|
||||
mSavedPeerConfig.deviceAddress)) {
|
||||
mSavedPeerConfig = config;
|
||||
|
||||
Reference in New Issue
Block a user