Update the p2p device interface name

In some implementations P2P device interface is created under
primary interface(wlan0 by default). In those implementations
p2p device name is predefined in system property wifi.direct.interface.
And the interface is created by supplicant with primary interface as
the parent interface. The naming of p2p device interface is
p2p-dev-<parent interface> ("p2p-dev-wlan0").

With STA+STA feature, wlan0 interface gets deleted in certain scenarios
and wlan1 becomes the active interface. In such scenarios P2P fails to
create the interface as parent interface wlan0 is deleted.

To fix the issue update the p2p device interface from system property
based on the current active wlan interface. ie First get the p2p parent
interface name from p2p device interface name set in property.
Check if the parent interface derived from p2p device interface name is
the current active interface. If not, get the current active interface
and update the name as p2p-dev-<ifname> ("p2p-dev-wlan1").
This helps HIDL/supplicant to get an active wlan interface from p2p
device interface name and succeed in creating the p2p interface under the
active interface.

Bug: 203434193

Test: Manual - Tested STA+STA which ended up deleting wlan0 interface.
      Then ran p2p tests and confirmed that p2p scan and connection
      works.
Change-Id: I522cec02a662c057e21d434f3ed98c7e7a4ca8f0
Merged-In: I522cec02a662c057e21d434f3ed98c7e7a4ca8f0
(cherry picked from commit 7f2822aff735e3c4f727de0759f867791db129ed)
(cherry picked from commit 6adbab13ee2c0a99b03a9dc66bc741b706dc7bf2)
1 file changed