Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic authentication for Android WiFi Direct

Tags:

android

p2p

In Android ICS, Wireless P2P (WiFi Direct) API is provided.

I tried to develop an Application which can connect 2 phones via Wireless P2P automatically if the MAC address match.

From SDK documentation, I have to following steps:

  1. Turn on WiFi Direct from Setting.
  2. Initialize P2P connection. - initialize()
  3. Discover Peer. - discoverPeers()
  4. See if the MAC address matched.
  5. Connect to the discovered Peer. - connect()

Once, the connect() API is called, Farside phone will Pop Up a connection Authentication Dialog. (Depending on WifiP2pConfig)

Is there anyway to connect automatically, without having Farside to popup the Dialog?

like image 679
Calvin Avatar asked Feb 09 '12 05:02

Calvin


2 Answers

It seems that automation of authentication dialogs is not possible, and this makes p2p routing impossible as well. Right now, the WpsInfo class (which is used in the WifiP2pConfig class that gets passed into the WifiP2pManager's connect() function during peer connection) only displays authentication dialogs in four ways: DISPLAY / KEYPAD / LABEL / PBC. I believe that PBC (push button config ) is the default and is what you refer to. The other three options require the user to input a type of pin, making them even more unusable for automated connections. Maybe if we were to find the type of this authentication dialog class, we could automate the clicking of the 'ok' button?

I wish a new option could be added that would give the application the ability to authenticate a connection, rather than the user. This user based authentication looks like its been carried over from the bluetooth api, and severely limits the usefulness of wifi direct. Maybe the folks at google could help us out?

like image 129
ryanbwork Avatar answered Oct 17 '22 03:10

ryanbwork


In the mean time the situation has changed. You can create a wifi direct connection fully automatic using creategroup() of the WifiP2pManager and the fetch the randomly generated password and SSID with onGroupInfoAvailable(), see this description with example code.

like image 26
hengsti Avatar answered Oct 17 '22 04:10

hengsti