Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57e42f41 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

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
parent 1ad66b2f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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);
    }
+14 −2
Original line number Diff line number Diff line
@@ -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;
@@ -83,12 +84,23 @@ public class WifiP2pDeviceList implements Parcelable {
        mDevices.put(device.deviceAddress, device);
    }

    /** @hide */
    public void updateGroupCapability(String deviceAddress, int groupCapab) {
        if (TextUtils.isEmpty(deviceAddress)) return;
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
            d.groupCapability = groupCapab;
        }
    }

    /** @hide */
    public void updateStatus(String deviceAddress, int status) {
        if (deviceAddress == null) return;
        if (TextUtils.isEmpty(deviceAddress)) return;
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
            d.status = status;
        }
    }

    /** @hide */
    public WifiP2pDevice get(String deviceAddress) {
+4 −0
Original line number Diff line number Diff line
@@ -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;