Reputation: 221
While connecting to a peer using WiFi Direct, user's permission is required. I know that connection can't be made without user never giving the permission and there's a feature request for this kind of functionality: https://code.google.com/p/android/issues/detail?id=30880
But I don't need this feature, asking for permission on the first connection is OK (also, more secure). Is there any method such that the permission is asked for the first time only? And when trying to connect to same peer later, the permission is not required.
Upvotes: 22
Views: 5740
Reputation: 2886
The closest thing to have Wi-Fi Direct features without prompt I've managed is to use Service Discovery combined with legacy mode, i.e. when the connection is supposed to happen, you don't use WifiP2pManager.connect() but WifiManager.enableNetwork() instead.
I'm the author of a very simple P2P stack which automates all the magic, you can check out an example on https://github.com/croconaut/wifon-mini to see how well/bad it works (plus some documentation).
Upvotes: 1
Reputation: 213
From the P2P specification we can find something called "persistent P2P group" which is intended to re-establish a group without user-intervention.
In a persitent P2P group the Group Owner stores the credentials of the group so that the group can be re-established in the future by the request of any group member without the need of user intervention.
Such a group can be formed by specifying persistent while connecting using command line (see the P2P of wpa_supplicant
and search for p2p_connect
command https://android.googlesource.com/platform/external/wpa_supplicant_8/+/ics-plus-aosp/wpa_supplicant/README-P2P). But I don't know if the option is available with the current devices.
Edit: See the answer to the question Can I change the group owner in a persistent group in Wi-Fi Direct?
Since I worked with Wi-Fi Direct on Ubuntu, I used wpa_cli
(which comes along with wpa_supplicant
) to create a persistent group as specified in the p2p_readme
file.
Upvotes: 5
Reputation: 1791
I am using two HTC One V's as well as an HTC One X+. I've been running the WifiDirectDemo given by Android. Apart from switching Wifi Direct on, no other setup is required. I simply press a search button in the application and peers are listed.
I did at first think I needed another devices permission as you've described, needing to reenable it every time I installed the application on my devices. But this was before I noticed the search button in the application, and realised this was not required.
Could you have made the same mistake as me?
Upvotes: 0
Reputation: 2890
Unfortunately, not at this time. Perhaps in the future, or if you write your own ROM.
Upvotes: 0