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

Commit 2e61ad1f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "P2P: Fix for GO inviting a p2p device."

parents 087238d4 b644157d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -194,6 +194,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
     */
@@ -1159,6 +1161,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");
@@ -2353,15 +2356,23 @@ 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;
    }

    /**