Merge "hdmi_cec: deal with the framework side went away."

This commit is contained in:
Wally Yau 2017-11-08 21:41:45 +00:00 committed by Android (Google) Code Review
commit c8145123db
2 changed files with 18 additions and 6 deletions

View file

@ -264,8 +264,7 @@ static_assert(HDMI_OPTION_SYSTEM_CEC_CONTROL == static_cast<int>(OptionKey::SYST
sp<IHdmiCecCallback> HdmiCec::mCallback = nullptr;
HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {
}
HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {}
// Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow.
Return<Result> HdmiCec::addLogicalAddress(CecLogicalAddress addr) {
@ -319,8 +318,16 @@ Return<SendMessageResult> HdmiCec::sendMessage(const CecMessage& message) {
}
Return<void> HdmiCec::setCallback(const sp<IHdmiCecCallback>& callback) {
mCallback = callback;
mDevice->register_event_callback(mDevice, eventCallback, nullptr);
if (mCallback != nullptr) {
mCallback->unlinkToDeath(this);
mCallback = nullptr;
}
if (callback != nullptr) {
mCallback = callback;
mCallback->linkToDeath(this, 0 /*cookie*/);
mDevice->register_event_callback(mDevice, eventCallback, nullptr);
}
return Void();
}

View file

@ -47,7 +47,7 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
struct HdmiCec : public IHdmiCec {
struct HdmiCec : public IHdmiCec, public hidl_death_recipient {
HdmiCec(hdmi_cec_device_t* device);
// Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow.
Return<Result> addLogicalAddress(CecLogicalAddress addr) override;
@ -87,7 +87,12 @@ struct HdmiCec : public IHdmiCec {
}
}
private:
virtual void serviceDied(uint64_t /*cookie*/,
const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
setCallback(nullptr);
}
private:
static sp<IHdmiCecCallback> mCallback;
const hdmi_cec_device_t* mDevice;
};