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

Commit 74469274 authored by Deepthi Gowri's avatar Deepthi Gowri Committed by Steve Kondik
Browse files

P2P: Fix for GO inviting a p2p device.

A p2p device on an invitation request from the peer invokes
p2p_peer command to know if the peer is a p2p device / GO.
Due to the cached entries there would be a possibility of
not getting the updated information, ending up in the wrong
negotiation with the invited peer. Thus do not rely on
p2p_peer command, rather assume that the peer is a GO on an
invitation request, provided there is no persistent network
configured.

Change-Id: Ic70c4147d8b34bcddf4bf70811a5aeb4ea0650bc
CRs-Fixed: 486437

Conflicts:

	wifi/java/android/net/wifi/p2p/WifiP2pService.java
parent d61b6b89
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -197,6 +197,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    /* Invitation to join an existing p2p group */
    private boolean mJoinExistingGroup;

    private boolean mIsInvite = false;

    /* Track whether we are in p2p discovery. This is used to avoid sending duplicate
     * broadcasts
     */
@@ -1174,6 +1176,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
                    WifiP2pGroup group = (WifiP2pGroup) message.obj;
                    WifiP2pDevice owner = group.getOwner();
                    mIsInvite = true;

                    if (owner == null) {
                        loge("Ignored invitation from null owner");
@@ -2344,15 +2347,24 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
     * @param config for the peer
     */
    private void p2pConnectWithPinDisplay(WifiP2pConfig config) {
        boolean join = false;
        WifiP2pDevice dev = fetchCurrentDeviceDetails(config);

        String pin = mWifiNative.p2pConnect(config, dev.isGroupOwner());
        if (mIsInvite) {
            join = true;
        }
        else {
            join = dev.isGroupOwner();
        }

        String pin = mWifiNative.p2pConnect(config, join);
        try {
            Integer.parseInt(pin);
            notifyInvitationSent(pin, config.deviceAddress);
        } catch (NumberFormatException ignore) {
            // do nothing if p2pConnect did not return a pin
        }
        mIsInvite = false;
    }

    /**