Add SDK check to decide the callback
This handle the HAL version is higher than the system
Bug: 328820052
Test: atest CtsWifiTestCases
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:523e13c8bdc4aeae11ef8c062adf470af64993f1)
Merged-In: I3b1e24526c9eccd490cc2ec4cdf6d586dc407d55
Change-Id: I3b1e24526c9eccd490cc2ec4cdf6d586dc407d55
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index 0daa8ef..f1d8488 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -16,6 +16,7 @@
#include <android/binder_process.h>
#include <android/binder_manager.h>
#include <aidl/android/hardware/wifi/supplicant/IpVersion.h>
+#include <cutils/properties.h>
extern "C" {
#include "scan.h"
@@ -38,6 +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;
using aidl::android::hardware::wifi::supplicant::GsmRand;
using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
@@ -414,6 +416,11 @@
return expected_version <= aidl_service_version;
}
+int32_t AidlManager::isSdkLevelAtLeast(int32_t expected_version)
+{
+ return expected_version <= sdk_level;
+}
+
int AidlManager::registerAidlService(struct wpa_global *global)
{
// Create the main aidl service object and register it.
@@ -422,7 +429,9 @@
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(),
@@ -1345,7 +1354,7 @@
std::back_inserter(aidl_vendor_elems));
}
- if (isAidlServiceVersionAtLeast(3)) {
+ if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
P2pDeviceFoundEventParams params;
params.srcAddress = macAddrToArray(addr);
params.p2pDeviceAddress = macAddrToArray(info->p2p_device_addr);
@@ -1607,7 +1616,7 @@
}
bool aidl_is_request = (request == 1);
- if (isAidlServiceVersionAtLeast(3)) {
+ if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
P2pProvisionDiscoveryCompletedEventParams params;
params.p2pDeviceAddress = macAddrToArray(dev_addr);
params.isRequest = aidl_is_request;
@@ -1663,7 +1672,7 @@
if (!wpa_s)
return;
- if (isAidlServiceVersionAtLeast(3)) {
+ if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
P2pPeerClientJoinedEventParams params;
params.groupInterfaceName = misc_utils::charBufToString(wpa_group_s->ifname);
params.clientInterfaceAddress = macAddrToArray(sta);
@@ -1699,7 +1708,7 @@
if (!wpa_s)
return;
- if (isAidlServiceVersionAtLeast(3)) {
+ if (isAidlServiceVersionAtLeast(3) && isSdkLevelAtLeast(__ANDROID_API_V__)) {
P2pPeerClientDisconnectedEventParams params;
params.groupInterfaceName = misc_utils::charBufToString(wpa_group_s->ifname);
params.clientInterfaceAddress = macAddrToArray(sta);
diff --git a/wpa_supplicant/aidl/aidl_manager.h b/wpa_supplicant/aidl/aidl_manager.h
index b11a760..103156e 100644
--- a/wpa_supplicant/aidl/aidl_manager.h
+++ b/wpa_supplicant/aidl/aidl_manager.h
@@ -172,6 +172,7 @@
// Methods called from aidl objects.
int32_t isAidlServiceVersionAtLeast(int32_t expected_version);
+ int32_t isSdkLevelAtLeast(int32_t expected_version);
void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id);
void notifyExtRadioWorkTimeout(
struct wpa_supplicant *wpa_s, uint32_t id);