Check the client interface version
Bug: 328820052
Test: atest CtsWifiTestCases
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6a98a839a703cd977dea65a763ba81bfaf28cc8c)
Merged-In: Ib334629e72c72727e93261df2cf70eee7065bdcb
Change-Id: Ib334629e72c72727e93261df2cf70eee7065bdcb
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index f1d8488..707299d 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -39,7 +39,7 @@
constexpr size_t kUmtsAutnLenBytes = EAP_AKA_AUTN_LEN;
const std::vector<uint8_t> kZeroBssid = {0, 0, 0, 0, 0, 0};
int32_t aidl_service_version = 0;
-int32_t sdk_level = 0;
+int32_t aidl_client_version = 0;
using aidl::android::hardware::wifi::supplicant::GsmRand;
using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
@@ -87,6 +87,10 @@
return 1;
}
callback_list.push_back(callback);
+ if (aidl_client_version == 0) {
+ callback->getInterfaceVersion(&aidl_client_version);
+ wpa_printf(MSG_INFO, "AIDL client version: %d", aidl_client_version);
+ }
return 0;
}
@@ -416,9 +420,9 @@
return expected_version <= aidl_service_version;
}
-int32_t AidlManager::isSdkLevelAtLeast(int32_t expected_version)
+int32_t AidlManager::isAidlClientVersionAtLeast(int32_t expected_version)
{
- return expected_version <= sdk_level;
+ return expected_version <= aidl_client_version;
}
int AidlManager::registerAidlService(struct wpa_global *global)
@@ -429,9 +433,7 @@
if (!supplicant_object_->getInterfaceVersion(&aidl_service_version).isOk()) {
aidl_service_version = Supplicant::version;
}
- sdk_level = property_get_int32("ro.build.version.sdk", 0);
wpa_printf(MSG_INFO, "AIDL Interface version: %d", aidl_service_version);
- wpa_printf(MSG_INFO, "Sdk version: %d", sdk_level);
wpa_global_ = global;
std::string instance = std::string() + Supplicant::descriptor + "/default";
if (AServiceManager_addService(supplicant_object_->asBinder().get(),
@@ -1354,7 +1356,7 @@
std::back_inserter(aidl_vendor_elems));
}
- if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
+ if (isAidlServiceVersionAtLeast(3) && isAidlClientVersionAtLeast(3)) {
P2pDeviceFoundEventParams params;
params.srcAddress = macAddrToArray(addr);
params.p2pDeviceAddress = macAddrToArray(info->p2p_device_addr);
@@ -1372,6 +1374,7 @@
&ISupplicantP2pIfaceCallback::onDeviceFoundWithParams,
std::placeholders::_1, params));
} else {
+ // Use legacy callback if service or client interface version < 3
const std::function<
ndk::ScopedAStatus(std::shared_ptr<ISupplicantP2pIfaceCallback>)>
func = std::bind(
@@ -1616,7 +1619,7 @@
}
bool aidl_is_request = (request == 1);
- if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
+ if (isAidlServiceVersionAtLeast(3) && isAidlClientVersionAtLeast(3)) {
P2pProvisionDiscoveryCompletedEventParams params;
params.p2pDeviceAddress = macAddrToArray(dev_addr);
params.isRequest = aidl_is_request;
@@ -1632,7 +1635,7 @@
&ISupplicantP2pIfaceCallback::onProvisionDiscoveryCompletedEvent,
std::placeholders::_1, params));
} else {
- // Use legacy callback if interface version < 3
+ // Use legacy callback if service or client interface version < 3
callWithEachP2pIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname),
std::bind(
@@ -1672,7 +1675,7 @@
if (!wpa_s)
return;
- if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
+ if (isAidlServiceVersionAtLeast(3) && isAidlClientVersionAtLeast(3)) {
P2pPeerClientJoinedEventParams params;
params.groupInterfaceName = misc_utils::charBufToString(wpa_group_s->ifname);
params.clientInterfaceAddress = macAddrToArray(sta);
@@ -1689,7 +1692,7 @@
&ISupplicantP2pIfaceCallback::onPeerClientJoined,
std::placeholders::_1, params));
} else {
- // Use legacy callback if interface version < 3
+ // Use legacy callback if service or client interface version < 3
callWithEachP2pIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname),
std::bind(
@@ -1708,7 +1711,7 @@
if (!wpa_s)
return;
- if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
+ if (isAidlServiceVersionAtLeast(3) && isAidlClientVersionAtLeast(3)) {
P2pPeerClientDisconnectedEventParams params;
params.groupInterfaceName = misc_utils::charBufToString(wpa_group_s->ifname);
params.clientInterfaceAddress = macAddrToArray(sta);
@@ -1721,7 +1724,7 @@
&ISupplicantP2pIfaceCallback::onPeerClientDisconnected,
std::placeholders::_1, params));
} else {
- // Use legacy callback if interface version < 3
+ // Use legacy callback if service or client interface version < 3
callWithEachP2pIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname),
std::bind(
diff --git a/wpa_supplicant/aidl/aidl_manager.h b/wpa_supplicant/aidl/aidl_manager.h
index 103156e..b3dfa82 100644
--- a/wpa_supplicant/aidl/aidl_manager.h
+++ b/wpa_supplicant/aidl/aidl_manager.h
@@ -172,7 +172,7 @@
// Methods called from aidl objects.
int32_t isAidlServiceVersionAtLeast(int32_t expected_version);
- int32_t isSdkLevelAtLeast(int32_t expected_version);
+ int32_t isAidlClientVersionAtLeast(int32_t expected_version);
void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id);
void notifyExtRadioWorkTimeout(
struct wpa_supplicant *wpa_s, uint32_t id);