diff options
| author | Sunil Ravi <sunilravi@google.com> | 2021-10-20 01:34:48 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-20 01:34:48 +0000 |
| commit | b828beb0469d300e265de1fa2da2fc3b90152fcd (patch) | |
| tree | 008930f424c002d16914d509a2917c301051c535 | |
| parent | c69d81e5f374a5b25830e66e9fe24111ac73b603 (diff) | |
| parent | 6adbab13ee2c0a99b03a9dc66bc741b706dc7bf2 (diff) | |
Update the p2p device interface name am: 6adbab13ee
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/16087108
Change-Id: I29de6a4bf01101cb32d2aafd8a4dce8fa5f398c0
| -rw-r--r-- | wifi/1.5/default/wifi_chip.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp index 82d794ca1..6bdff4214 100644 --- a/wifi/1.5/default/wifi_chip.cpp +++ b/wifi/1.5/default/wifi_chip.cpp @@ -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(); } |
