Remove strong pointer in contructor to "this"
Bug: 69110631
Test: NFC on/off
Change-Id: I6c0173df6b6f49e7c07e9670c827b2944c6fe23f
diff --git a/nfc/1.0/default/Nfc.cpp b/nfc/1.0/default/Nfc.cpp
index d337a36..fcdcbbc 100644
--- a/nfc/1.0/default/Nfc.cpp
+++ b/nfc/1.0/default/Nfc.cpp
@@ -14,9 +14,7 @@
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) {
@@ -25,7 +23,7 @@
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;
}
@@ -58,7 +56,7 @@
if (mDevice == nullptr || mCallback == nullptr) {
return NfcStatus::FAILED;
}
- mCallback->unlinkToDeath(mDeathRecipient);
+ mCallback->unlinkToDeath(this);
return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
}