Update Client code for NFC 1.1 HAL NfcClientCallback
Test: Nfc Enable/disable with NFC 1.0 & NFC 1.1 HAL
Bug: 72746517
Change-Id: I337896a9ca46c85bb2465d3478dddf56fb51f2ab
diff --git a/src/adaptation/NfcAdaptation.cc b/src/adaptation/NfcAdaptation.cc
index e6403f5..1431c55 100644
--- a/src/adaptation/NfcAdaptation.cc
+++ b/src/adaptation/NfcAdaptation.cc
@@ -41,7 +41,7 @@
using android::hardware::Void;
using android::hardware::nfc::V1_0::INfc;
using INfcV1_1 = android::hardware::nfc::V1_1::INfc;
-using android::hardware::nfc::V1_0::INfcClientCallback;
+using android::hardware::nfc::V1_1::INfcClientCallback;
using android::hardware::hidl_vec;
extern bool nfc_debug_enabled;
@@ -105,6 +105,12 @@
mDataCallback = dataCallback;
};
virtual ~NfcClientCallback() = default;
+ Return<void> sendEvent_1_1(
+ ::android::hardware::nfc::V1_1::NfcEvent event,
+ ::android::hardware::nfc::V1_0::NfcStatus event_status) override {
+ mEventCallback((uint8_t)event, (tHAL_NFC_STATUS)event_status);
+ return Void();
+ };
Return<void> sendEvent(
::android::hardware::nfc::V1_0::NfcEvent event,
::android::hardware::nfc::V1_0::NfcStatus event_status) override {
@@ -462,7 +468,11 @@
const char* func = "NfcAdaptation::HalOpen";
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", func);
mCallback = new NfcClientCallback(p_hal_cback, p_data_cback);
- mHal->open(mCallback);
+ if (mHal_1_1 != nullptr) {
+ mHal_1_1->open_1_1(mCallback);
+ } else {
+ mHal->open(mCallback);
+ }
}
/*******************************************************************************
diff --git a/src/include/NfcAdaptation.h b/src/include/NfcAdaptation.h
index 48d0894..81ecfca 100644
--- a/src/include/NfcAdaptation.h
+++ b/src/include/NfcAdaptation.h
@@ -32,6 +32,7 @@
}
namespace V1_1 {
struct INfc;
+struct INfcClientCallback;
}
}
}
@@ -96,7 +97,7 @@
tHAL_NFC_ENTRY mHalEntryFuncs; // function pointers for HAL entry points
static android::sp<android::hardware::nfc::V1_0::INfc> mHal;
static android::sp<android::hardware::nfc::V1_1::INfc> mHal_1_1;
- static android::hardware::nfc::V1_0::INfcClientCallback* mCallback;
+ static android::hardware::nfc::V1_1::INfcClientCallback* mCallback;
static tHAL_NFC_CBACK* mHalCallback;
static tHAL_NFC_DATA_CBACK* mHalDataCallback;
static ThreadCondVar mHalOpenCompletedEvent;