As the goal for my investigations would be to find suitable solutions for the Thali project android issues for the P2P are discussed in Exploring Android to Android P2P page, the Wifi direct does have one annoying feature that potentially makes the API rather unusable.
This is the requirement for showing the acceptance dialog. Basically each group linkage has to be accepted by one side of the connection. The selection of who the accepting party is, is solely determined by the fact that who started the connection process. The dialog is then shown in the device which the connection is made to.
Also note that the dialog is shown in both ends on some point, that is if the device which starts the connection process between these devices changes in some point of time.
To explain this a bit better,Lets assume we have a new app installed in three devices, which have not formed any connections between them beforehand. Then lets assume following steps:
- I’m hanging around in cafe area when Mike comes around, and I start connection to that device and when the connection is established, I’m selected as Group owner.
- In this case Mike had the dialog showing, i.e. the dialog was shown in client side.
- Then Jenny comes around and starts connecting to my device
- Now my device shows the dialog, i.e. the dialog is shown in Group owner side
- I’ll leave the place, and thus both Mike & Jenny are getting disconnected, and then they form a connection between each others device, and Mike gets to be Group owner.
- The Connecting process was started by Jenny, thus it was Mike’s device which showed the dialog this time.
- I’ll come back and find Mike’s device as Group owner, thus my device start creating a connection to Mikes device
- Mike’s device is now showing dialog for accepting my connection request.
So My device had dialogs twice, one for Mike, and one for Jenny. Mike had also the dialog shown twice, once for me and once for Jenny. And Jenny never saw any dialogs.
Thus if I would try connecting to Jenny (or Mike would) , then she would have the dialog shown for both of us. And If we would get these cases covered, we wouldn’t see the dialog in the future.
Or would we ?
One nice feature with the WiFi direct is that the “Known Groups” information is saved, and if you go to settings and dig under the WLAN, you can find the stored groups information in there.
The Information is stored there in a way that I so far only seen them disappear, if I explicitly go and delete them, or if I do factory reset for the device.
Also since I have not seen any documentation suggesting any automated cleaning, I would simply assume that the data stays there, unless they are cleaned by either of the mentioned ways.
All and all, do note that the “Known group” information is stored in both ends and if it is cleared in either end, the connection will be showing the dialogs again.
For example, in the example case, in the end, all devices had 2 items stored under the “Known group”, even Jenny who did not have any acceptance dialogs shown to her. And if Jenny would clear the items from her device, then the dialogs would be shown again, if she would attempt to connect Mike’s or My device in the future.