Merge "p2p enhancements"

This commit is contained in:
Irfan Sheriff
2011-12-05 14:07:06 -08:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 9 deletions

View File

@@ -239,6 +239,10 @@ public class WifiNative {
return WifiNative.doBooleanCommand("SET config_methods " + cfg);
}
public static boolean setP2pSsidPostfix(String postfix) {
return WifiNative.doBooleanCommand("SET p2p_ssid_postfix " + postfix);
}
public static boolean p2pFind() {
return doBooleanCommand("P2P_FIND");
}

View File

@@ -172,6 +172,12 @@ public class WifiP2pGroup implements Parcelable {
return mClients.size() == 0;
}
/** @hide Returns {@code true} if the device is part of the group */
public boolean contains(WifiP2pDevice device) {
if (mOwner.equals(device) || mClients.contains(device)) return true;
return false;
}
/** Get the list of clients currently part of the p2p group */
public Collection<WifiP2pDevice> getClientList() {
return Collections.unmodifiableCollection(mClients);

View File

@@ -1088,16 +1088,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
break;
case WifiMonitor.P2P_DEVICE_LOST_EVENT:
WifiP2pDevice device = (WifiP2pDevice) message.obj;
if (device.equals(mGroup.getOwner())) {
logd("Lost the group owner, killing p2p connection");
WifiNative.p2pGroupRemove(mGroup.getInterface());
} else if (mGroup.removeClient(device)) {
if (!mPersistGroup && mGroup.isClientListEmpty()) {
Slog.d(TAG, "Client list empty, removing a non-persistent p2p group");
WifiNative.p2pGroupRemove(mGroup.getInterface());
}
//Device loss for a connected device indicates it is not in discovery any more
if (mGroup.contains(device)) {
if (DBG) logd("Lost " + device +" , do nothing");
return HANDLED;
}
return NOT_HANDLED; // Do the regular device lost handling
// Do the regular device lost handling
return NOT_HANDLED;
case WifiP2pManager.DISABLE_P2P:
sendMessage(WifiP2pManager.REMOVE_GROUP);
deferMessage(message);
@@ -1401,6 +1398,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
private void initializeP2pSettings() {
WifiNative.setPersistentReconnect(true);
WifiNative.setDeviceName(mThisDevice.deviceName);
//DIRECT-XY-DEVICENAME (XY is randomly generated)
WifiNative.setP2pSsidPostfix("-" + mThisDevice.deviceName);
WifiNative.setDeviceType(mThisDevice.primaryDeviceType);
//The supplicant default is to support everything, but a bug necessitates
//the framework to specify this explicitly