Merge "Update group capability before connect" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ca96a322f0
@@ -640,6 +640,27 @@ public class WifiNative {
|
|||||||
return "";
|
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) {
|
public String p2pPeer(String deviceAddress) {
|
||||||
return doStringCommand("P2P_PEER " + deviceAddress);
|
return doStringCommand("P2P_PEER " + deviceAddress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package android.net.wifi.p2p;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.net.wifi.p2p.WifiP2pDevice;
|
import android.net.wifi.p2p.WifiP2pDevice;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -84,10 +85,21 @@ public class WifiP2pDeviceList implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void updateStatus(String deviceAddress, int status) {
|
public void updateGroupCapability(String deviceAddress, int groupCapab) {
|
||||||
if (deviceAddress == null) return;
|
if (TextUtils.isEmpty(deviceAddress)) return;
|
||||||
WifiP2pDevice d = mDevices.get(deviceAddress);
|
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 */
|
/** @hide */
|
||||||
|
|||||||
@@ -764,6 +764,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
WifiP2pConfig config = (WifiP2pConfig) message.obj;
|
WifiP2pConfig config = (WifiP2pConfig) message.obj;
|
||||||
mAutonomousGroup = false;
|
mAutonomousGroup = false;
|
||||||
|
|
||||||
|
/* Update group capability before connect */
|
||||||
|
int gc = mWifiNative.getGroupCapability(config.deviceAddress);
|
||||||
|
mPeers.updateGroupCapability(config.deviceAddress, gc);
|
||||||
|
|
||||||
if (mSavedPeerConfig != null && config.deviceAddress.equals(
|
if (mSavedPeerConfig != null && config.deviceAddress.equals(
|
||||||
mSavedPeerConfig.deviceAddress)) {
|
mSavedPeerConfig.deviceAddress)) {
|
||||||
mSavedPeerConfig = config;
|
mSavedPeerConfig = config;
|
||||||
|
|||||||
Reference in New Issue
Block a user