Loading nfc/Android.bpdeleted 100644 → 0 +0 −18 Original line number Diff line number Diff line 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", ], } nfc/Nfc.cppdeleted 100644 → 0 +0 −107 Original line number Diff line number Diff line #define LOG_TAG "android.hardware.nfc@1.0-impl" #include <log/log.h> #include <hardware/hardware.h> #include <hardware/nfc.h> #include "Nfc.h" namespace android { namespace hardware { namespace nfc { namespace V1_0 { namespace implementation { sp<INfcClientCallback> 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<NfcStatus> Nfc::open(const sp<INfcClientCallback>& 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<uint32_t> Nfc::write(const hidl_vec<uint8_t>& data) { if (mDevice == nullptr) { return -1; } return mDevice->write(mDevice, data.size(), &data[0]); } ::android::hardware::Return<NfcStatus> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) { hidl_vec<uint8_t> 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<NfcStatus> Nfc::prediscover() { if (mDevice == nullptr) { return NfcStatus::FAILED; } return mDevice->pre_discover(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> Nfc::close() { if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->unlinkToDeath(mDeathRecipient); return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> Nfc::controlGranted() { if (mDevice == nullptr) { return NfcStatus::FAILED; } return mDevice->control_granted(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> 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 nfc/Nfc.hdeleted 100644 → 0 +0 −76 Original line number Diff line number Diff line #ifndef ANDROID_HARDWARE_NFC_V1_0_NFC_H #define ANDROID_HARDWARE_NFC_V1_0_NFC_H #include <android/hardware/nfc/1.0/INfc.h> #include <hidl/Status.h> #include <hardware/hardware.h> #include <hardware/nfc.h> 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<INfc> nfc) : mNfc(nfc) { } virtual void serviceDied(uint64_t /*cookie*/, const wp<::android::hidl::base::V1_0::IBase>& /*who*/) { mNfc->close(); } sp<INfc> mNfc; }; struct Nfc : public INfc { Nfc(nfc_nci_device_t* device); ::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override; ::android::hardware::Return<uint32_t> write(const hidl_vec<uint8_t>& data) override; ::android::hardware::Return<NfcStatus> coreInitialized(const hidl_vec<uint8_t>& data) override; ::android::hardware::Return<NfcStatus> prediscover() override; ::android::hardware::Return<NfcStatus> close() override; ::android::hardware::Return<NfcStatus> controlGranted() override; ::android::hardware::Return<NfcStatus> 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<uint8_t> 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<INfcClientCallback> mCallback; const nfc_nci_device_t* mDevice; sp<NfcDeathRecipient> 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 Loading
nfc/Android.bpdeleted 100644 → 0 +0 −18 Original line number Diff line number Diff line 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", ], }
nfc/Nfc.cppdeleted 100644 → 0 +0 −107 Original line number Diff line number Diff line #define LOG_TAG "android.hardware.nfc@1.0-impl" #include <log/log.h> #include <hardware/hardware.h> #include <hardware/nfc.h> #include "Nfc.h" namespace android { namespace hardware { namespace nfc { namespace V1_0 { namespace implementation { sp<INfcClientCallback> 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<NfcStatus> Nfc::open(const sp<INfcClientCallback>& 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<uint32_t> Nfc::write(const hidl_vec<uint8_t>& data) { if (mDevice == nullptr) { return -1; } return mDevice->write(mDevice, data.size(), &data[0]); } ::android::hardware::Return<NfcStatus> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) { hidl_vec<uint8_t> 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<NfcStatus> Nfc::prediscover() { if (mDevice == nullptr) { return NfcStatus::FAILED; } return mDevice->pre_discover(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> Nfc::close() { if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->unlinkToDeath(mDeathRecipient); return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> Nfc::controlGranted() { if (mDevice == nullptr) { return NfcStatus::FAILED; } return mDevice->control_granted(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } ::android::hardware::Return<NfcStatus> 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
nfc/Nfc.hdeleted 100644 → 0 +0 −76 Original line number Diff line number Diff line #ifndef ANDROID_HARDWARE_NFC_V1_0_NFC_H #define ANDROID_HARDWARE_NFC_V1_0_NFC_H #include <android/hardware/nfc/1.0/INfc.h> #include <hidl/Status.h> #include <hardware/hardware.h> #include <hardware/nfc.h> 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<INfc> nfc) : mNfc(nfc) { } virtual void serviceDied(uint64_t /*cookie*/, const wp<::android::hidl::base::V1_0::IBase>& /*who*/) { mNfc->close(); } sp<INfc> mNfc; }; struct Nfc : public INfc { Nfc(nfc_nci_device_t* device); ::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override; ::android::hardware::Return<uint32_t> write(const hidl_vec<uint8_t>& data) override; ::android::hardware::Return<NfcStatus> coreInitialized(const hidl_vec<uint8_t>& data) override; ::android::hardware::Return<NfcStatus> prediscover() override; ::android::hardware::Return<NfcStatus> close() override; ::android::hardware::Return<NfcStatus> controlGranted() override; ::android::hardware::Return<NfcStatus> 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<uint8_t> 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<INfcClientCallback> mCallback; const nfc_nci_device_t* mDevice; sp<NfcDeathRecipient> 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