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

Commit d61b6b89 authored by Rashmi Ramanna's avatar Rashmi Ramanna Committed by Steve Kondik
Browse files

Show PIN on Peer device on receiving PIN display request.

P2P provision discovery would request the peer to display a PIN.
The PIN is displayed handling the request, the PIN need to be
entered on keypad of requested peer device to achieve the
connection.

Change-Id: I8b6487681d78eb10c558983a08dec1ac8a8eee65
CRs-fixed: 382608
parent 433f4374
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -1207,12 +1207,23 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                    break;
                case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
                case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
                case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
                    //We let the supplicant handle the provision discovery response
                    //and wait instead for the GO_NEGOTIATION_REQUEST_EVENT.
                    //Handling provision discovery and issuing a p2p_connect before
                    //group negotiation comes through causes issues
                    break;
                case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
                    WifiP2pProvDiscEvent provDisc = (WifiP2pProvDiscEvent) message.obj;
                    WifiP2pDevice device = provDisc.device;
                    if (device == null) {
                        Slog.d(TAG, "Device entry is null");
                        break;
                    }
                    notifyP2pProvDiscShowPinRequest(provDisc.pin, device.deviceAddress);
                    mPeers.updateStatus(device.deviceAddress, WifiP2pDevice.INVITED);
                    sendPeersChangedBroadcast();
                    transitionTo(mGroupNegotiationState);
                    break;
                case WifiP2pManager.CREATE_GROUP:
                    mAutonomousGroup = true;
                    int netId = message.arg1;
@@ -2123,6 +2134,36 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        dialog.show();
    }

    private void notifyP2pProvDiscShowPinRequest(String pin, String peerAddress) {
        Resources r = Resources.getSystem();
        final String tempDevAddress = peerAddress;
        final String tempPin = pin;

        final View textEntryView = LayoutInflater.from(mContext)
                .inflate(R.layout.wifi_p2p_dialog, null);

        ViewGroup group = (ViewGroup) textEntryView.findViewById(R.id.info);
        addRowToDialog(group, R.string.wifi_p2p_to_message, getDeviceName(peerAddress));
        addRowToDialog(group, R.string.wifi_p2p_show_pin_message, pin);

        AlertDialog dialog = new AlertDialog.Builder(mContext)
            .setTitle(r.getString(R.string.wifi_p2p_invitation_sent_title))
            .setView(textEntryView)
            .setPositiveButton(r.getString(R.string.accept), new OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            mSavedPeerConfig = new WifiP2pConfig();
                            mSavedPeerConfig.deviceAddress = tempDevAddress;
                            mSavedPeerConfig.wps.setup = WpsInfo.DISPLAY;
                            mSavedPeerConfig.wps.pin = tempPin;
                            mWifiNative.p2pConnect(mSavedPeerConfig, FORM_GROUP);
                        }
                    })
            .setCancelable(false)
            .create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        dialog.show();
    }

    private void notifyInvitationReceived() {
        Resources r = Resources.getSystem();
        final WpsInfo wps = mSavedPeerConfig.wps;