Loading nfc/1.0/default/Nfc.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -14,9 +14,7 @@ namespace implementation { sp<INfcClientCallback> Nfc::mCallback = nullptr; Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), mDeathRecipient(new NfcDeathRecipient(this)) { } Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device) {} // Methods from ::android::hardware::nfc::V1_0::INfc follow. ::android::hardware::Return<NfcStatus> Nfc::open(const sp<INfcClientCallback>& clientCallback) { Loading @@ -25,7 +23,7 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->linkToDeath(mDeathRecipient, 0 /*cookie*/); mCallback->linkToDeath(this, 0 /*cookie*/); int ret = mDevice->open(mDevice, eventCallback, dataCallback); return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED; } Loading Loading @@ -58,7 +56,7 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->unlinkToDeath(mDeathRecipient); mCallback->unlinkToDeath(this); return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } Loading nfc/1.0/default/Nfc.h +33 −38 Original line number Diff line number Diff line Loading @@ -19,19 +19,10 @@ 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 { struct Nfc : public INfc, public hidl_death_recipient { Nfc(nfc_nci_device_t* device); ::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override; ::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; Loading @@ -41,8 +32,7 @@ struct Nfc : public INfc { static void eventCallback(uint8_t event, uint8_t status) { if (mCallback != nullptr) { auto ret = mCallback->sendEvent( (::android::hardware::nfc::V1_0::NfcEvent) event, 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."); Loading @@ -59,10 +49,15 @@ struct Nfc : public INfc { } } } virtual void serviceDied(uint64_t /*cookie*/, const wp<::android::hidl::base::V1_0::IBase>& /*who*/) { close(); } private: static sp<INfcClientCallback> mCallback; const nfc_nci_device_t* mDevice; sp<NfcDeathRecipient> mDeathRecipient; }; extern "C" INfc* HIDL_FETCH_INfc(const char* name); Loading Loading
nfc/1.0/default/Nfc.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -14,9 +14,7 @@ namespace implementation { sp<INfcClientCallback> Nfc::mCallback = nullptr; Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), mDeathRecipient(new NfcDeathRecipient(this)) { } Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device) {} // Methods from ::android::hardware::nfc::V1_0::INfc follow. ::android::hardware::Return<NfcStatus> Nfc::open(const sp<INfcClientCallback>& clientCallback) { Loading @@ -25,7 +23,7 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->linkToDeath(mDeathRecipient, 0 /*cookie*/); mCallback->linkToDeath(this, 0 /*cookie*/); int ret = mDevice->open(mDevice, eventCallback, dataCallback); return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED; } Loading Loading @@ -58,7 +56,7 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device), if (mDevice == nullptr || mCallback == nullptr) { return NfcStatus::FAILED; } mCallback->unlinkToDeath(mDeathRecipient); mCallback->unlinkToDeath(this); return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK; } Loading
nfc/1.0/default/Nfc.h +33 −38 Original line number Diff line number Diff line Loading @@ -19,19 +19,10 @@ 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 { struct Nfc : public INfc, public hidl_death_recipient { Nfc(nfc_nci_device_t* device); ::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override; ::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; Loading @@ -41,8 +32,7 @@ struct Nfc : public INfc { static void eventCallback(uint8_t event, uint8_t status) { if (mCallback != nullptr) { auto ret = mCallback->sendEvent( (::android::hardware::nfc::V1_0::NfcEvent) event, 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."); Loading @@ -59,10 +49,15 @@ struct Nfc : public INfc { } } } virtual void serviceDied(uint64_t /*cookie*/, const wp<::android::hidl::base::V1_0::IBase>& /*who*/) { close(); } private: static sp<INfcClientCallback> mCallback; const nfc_nci_device_t* mDevice; sp<NfcDeathRecipient> mDeathRecipient; }; extern "C" INfc* HIDL_FETCH_INfc(const char* name); Loading