From 8342358c42850725d53bdd3951508e2a322d9406 Mon Sep 17 00:00:00 2001 From: DidntRead Date: Tue, 1 May 2018 19:19:45 +0300 Subject: [PATCH] remove nfc files --- nfc/Android.bp | 18 --------- nfc/Nfc.cpp | 107 ------------------------------------------------- nfc/Nfc.h | 76 ----------------------------------- 3 files changed, 201 deletions(-) delete mode 100644 nfc/Android.bp delete mode 100644 nfc/Nfc.cpp delete mode 100644 nfc/Nfc.h diff --git a/nfc/Android.bp b/nfc/Android.bp deleted file mode 100644 index 10ff9d3..0000000 --- a/nfc/Android.bp +++ /dev/null @@ -1,18 +0,0 @@ -cc_library_shared { - name: "android.hardware.nfc@1.0-impl-mtk", - defaults: ["hidl_defaults"], - relative_install_path: "hw", - proprietary: true, - srcs: ["Nfc.cpp"], - shared_libs: [ - "liblog", - "libcutils", - "libhardware", - "libbase", - "libcutils", - "libutils", - "libhidlbase", - "libhidltransport", - "android.hardware.nfc@1.0", - ], -} diff --git a/nfc/Nfc.cpp b/nfc/Nfc.cpp deleted file mode 100644 index 535e751..0000000 --- a/nfc/Nfc.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#define LOG_TAG "android.hardware.nfc@1.0-impl" - -#include - -#include -#include -#include "Nfc.h" - -namespace android { -namespace hardware { -namespace nfc { -namespace V1_0 { -namespace implementation { - -sp Nfc::mCallback = nullptr; - -Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), - mDeathRecipient(new NfcDeathRecipient(this)) { -} - -// Methods from ::android::hardware::nfc::V1_0::INfc follow. -::android::hardware::Return Nfc::open(const sp& clientCallback) { - mCallback = clientCallback; - - if (mDevice == nullptr || mCallback == nullptr) { - return NfcStatus::FAILED; - } - mCallback->linkToDeath(mDeathRecipient, 0 /*cookie*/); - int ret = mDevice->open(mDevice, eventCallback, dataCallback); - return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED; -} - -::android::hardware::Return Nfc::write(const hidl_vec& data) { - if (mDevice == nullptr) { - return -1; - } - return mDevice->write(mDevice, data.size(), &data[0]); -} - -::android::hardware::Return Nfc::coreInitialized(const hidl_vec& data) { - hidl_vec copy = data; - - if (mDevice == nullptr) { - return NfcStatus::FAILED; - } - int ret = mDevice->core_initialized(mDevice, ©[0]); - return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED; -} - -::android::hardware::Return Nfc::prediscover() { - if (mDevice == nullptr) { - return NfcStatus::FAILED; - } - return mDevice->pre_discover(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; -} - -::android::hardware::Return Nfc::close() { - if (mDevice == nullptr || mCallback == nullptr) { - return NfcStatus::FAILED; - } - mCallback->unlinkToDeath(mDeathRecipient); - return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; -} - -::android::hardware::Return Nfc::controlGranted() { - if (mDevice == nullptr) { - return NfcStatus::FAILED; - } - return mDevice->control_granted(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; -} - -::android::hardware::Return Nfc::powerCycle() { - if (mDevice == nullptr) { - return NfcStatus::FAILED; - } - return mDevice->power_cycle(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; -} - - -INfc* HIDL_FETCH_INfc(const char * /*name*/) { - nfc_nci_device_t* nfc_device; - int ret = 0; - const hw_module_t* hw_module = nullptr; - - ret = hw_get_module (NFC_NCI_MT6605_HARDWARE_MODULE_ID, &hw_module); - if (ret == 0) { - ret = nfc_nci_open (hw_module, &nfc_device); - if (ret != 0) { - ALOGE ("nfc_nci_open failed: %d", ret); - } - } - else - ALOGE ("hw_get_module %s failed: %d", NFC_NCI_MT6605_HARDWARE_MODULE_ID, ret); - - if (ret == 0) { - return new Nfc(nfc_device); - } else { - ALOGE("Passthrough failed to load legacy HAL."); - return nullptr; - } -} - -} // namespace implementation -} // namespace V1_0 -} // namespace nfc -} // namespace hardware -} // namespace android diff --git a/nfc/Nfc.h b/nfc/Nfc.h deleted file mode 100644 index 84f2149..0000000 --- a/nfc/Nfc.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef ANDROID_HARDWARE_NFC_V1_0_NFC_H -#define ANDROID_HARDWARE_NFC_V1_0_NFC_H - -#include -#include -#include -#include -namespace android { -namespace hardware { -namespace nfc { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::nfc::V1_0::INfc; -using ::android::hardware::nfc::V1_0::INfcClientCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct NfcDeathRecipient : hidl_death_recipient { - NfcDeathRecipient(const sp nfc) : mNfc(nfc) { - } - - virtual void serviceDied(uint64_t /*cookie*/, const wp<::android::hidl::base::V1_0::IBase>& /*who*/) { - mNfc->close(); - } - sp mNfc; -}; - -struct Nfc : public INfc { - Nfc(nfc_nci_device_t* device); - ::android::hardware::Return open(const sp& clientCallback) override; - ::android::hardware::Return write(const hidl_vec& data) override; - ::android::hardware::Return coreInitialized(const hidl_vec& data) override; - ::android::hardware::Return prediscover() override; - ::android::hardware::Return close() override; - ::android::hardware::Return controlGranted() override; - ::android::hardware::Return powerCycle() override; - - static void eventCallback(uint8_t event, uint8_t status) { - if (mCallback != nullptr) { - auto ret = mCallback->sendEvent( - (::android::hardware::nfc::V1_0::NfcEvent) event, - (::android::hardware::nfc::V1_0::NfcStatus) status); - if (!ret.isOk()) { - ALOGW("Failed to call back into NFC process."); - } - } - } - static void dataCallback(uint16_t data_len, uint8_t* p_data) { - hidl_vec data; - data.setToExternal(p_data, data_len); - if (mCallback != nullptr) { - auto ret = mCallback->sendData(data); - if (!ret.isOk()) { - ALOGW("Failed to call back into NFC process."); - } - } - } - private: - static sp mCallback; - const nfc_nci_device_t* mDevice; - sp mDeathRecipient; -}; -#define NFC_NCI_MT6605_HARDWARE_MODULE_ID "nfc_nci.mt6605" -extern "C" INfc* HIDL_FETCH_INfc(const char* name); - -} // namespace implementation -} // namespace V1_0 -} // namespace nfc -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_NFC_V1_0_NFC_H -- GitLab