mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
Update the p2p device interface name am: 6adbab13ee
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/16087108 Change-Id: I29de6a4bf01101cb32d2aafd8a4dce8fa5f398c0
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "wifi_chip.h"
|
||||
#include "wifi_status_util.h"
|
||||
|
||||
#define P2P_MGMT_DEVICE_PREFIX "p2p-dev-"
|
||||
|
||||
namespace {
|
||||
using android::sp;
|
||||
using android::base::unique_fd;
|
||||
@@ -126,8 +128,37 @@ std::vector<std::string> getPredefinedApIfaceNames(bool is_bridged) {
|
||||
}
|
||||
|
||||
std::string getPredefinedP2pIfaceName() {
|
||||
std::array<char, PROPERTY_VALUE_MAX> primaryIfaceName;
|
||||
char p2pParentIfname[100];
|
||||
std::string p2pDevIfName = "";
|
||||
std::array<char, PROPERTY_VALUE_MAX> buffer;
|
||||
property_get("wifi.direct.interface", buffer.data(), "p2p0");
|
||||
if (strncmp(buffer.data(), P2P_MGMT_DEVICE_PREFIX,
|
||||
strlen(P2P_MGMT_DEVICE_PREFIX)) == 0) {
|
||||
/* Get the p2p parent interface name from p2p device interface name set
|
||||
* in property */
|
||||
strncpy(p2pParentIfname, buffer.data() + strlen(P2P_MGMT_DEVICE_PREFIX),
|
||||
strlen(buffer.data()) - strlen(P2P_MGMT_DEVICE_PREFIX));
|
||||
if (property_get(kActiveWlanIfaceNameProperty, primaryIfaceName.data(),
|
||||
nullptr) == 0) {
|
||||
return buffer.data();
|
||||
}
|
||||
/* Check if the parent interface derived from p2p device interface name
|
||||
* is active */
|
||||
if (strncmp(p2pParentIfname, primaryIfaceName.data(),
|
||||
strlen(buffer.data()) - strlen(P2P_MGMT_DEVICE_PREFIX)) !=
|
||||
0) {
|
||||
/*
|
||||
* Update the predefined p2p device interface parent interface name
|
||||
* with current active wlan interface
|
||||
*/
|
||||
p2pDevIfName += P2P_MGMT_DEVICE_PREFIX;
|
||||
p2pDevIfName += primaryIfaceName.data();
|
||||
LOG(INFO) << "update the p2p device interface name to "
|
||||
<< p2pDevIfName.c_str();
|
||||
return p2pDevIfName;
|
||||
}
|
||||
}
|
||||
return buffer.data();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user