diff options
author | Jong Wook Kim <jongwook@google.com> | 2018-05-04 19:25:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-04 19:25:56 +0000 |
commit | d8b9357f72fc7b719b4297dd5a8d1be315ecd219 (patch) | |
tree | 4db69cad495cd85d10784d9b13349dabe6626c0d /service | |
parent | 295a9401b82a849a2449b3853bfcbd1fddcd04f6 (diff) | |
parent | e62a75f3884ecaf38451e3af631b2c173ea511c1 (diff) |
Merge "Sink device not displaying PIN when connect using WPS_KEYPAD option" into pi-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index fdad6574e..c089c9c09 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -1553,12 +1553,27 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { break; case WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT: case WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT: - case WifiP2pMonitor.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 WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT: + if (message.obj == null) { + Log.e(TAG, "Illegal argument(s)"); + break; + } + WifiP2pProvDiscEvent provDisc = (WifiP2pProvDiscEvent) message.obj; + WifiP2pDevice device = provDisc.device; + if (device == null) { + loge("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; @@ -2648,6 +2663,39 @@ public class WifiP2pServiceImpl 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); + } + }) + .create(); + dialog.setCanceledOnTouchOutside(false); + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + WindowManager.LayoutParams attrs = dialog.getWindow().getAttributes(); + attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; + dialog.getWindow().setAttributes(attrs); + dialog.show(); + } + private void notifyInvitationReceived() { Resources r = Resources.getSystem(); final WpsInfo wps = mSavedPeerConfig.wps; |