Merge "hdmi_cec: deal with the framework side went away."
This commit is contained in:
commit
c8145123db
2 changed files with 18 additions and 6 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue