Skip to content

Commit b613ccc

Browse files
hgfell683aishwariya15
authored andcommitted
XIONE-14703, ES1-1645 - WPEFramework crash
Reason for change: Handling unhandled exceptions Test Procedure: None Risks: Low Priority: P1 Signed-off-by:Hayden Gfeller <[email protected]>
1 parent 37e2891 commit b613ccc

File tree

1 file changed

+67
-25
lines changed

1 file changed

+67
-25
lines changed

HdmiCecSink/HdmiCecSink.cpp

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,29 +2719,53 @@ namespace WPEFramework
27192719
_instance->allocateLogicalAddress(DeviceType::TV);
27202720
if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED)
27212721
{
2722-
logicalAddress = LogicalAddress(_instance->m_logicalAddressAllocated);
2723-
LibCCEC::getInstance().addLogicalAddress(logicalAddress);
2724-
_instance->smConnection->setSource(logicalAddress);
2725-
_instance->m_numberOfDevices = 0;
2726-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType = DeviceType::TV;
2727-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_isDevicePresent = true;
2728-
_instance->deviceList[_instance->m_logicalAddressAllocated].update(physical_addr);
2729-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_1_4;
2730-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_vendorID = appVendorId;
2731-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState);
2732-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage = defaultLanguage;
2733-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_osdName = osdName.toString().c_str();
2734-
if(cecVersion == 2.0) {
2735-
_instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_2_0;
2736-
_instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST),
2737-
MessageEncoder().encode(ReportFeatures(Version::V_2_0,allDevicetype,rcProfile,deviceFeatures)), 500);
2738-
}
2739-
_instance->smConnection->addFrameListener(_instance->msgFrameListener);
2740-
_instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST),
2741-
MessageEncoder().encode(ReportPhysicalAddress(physical_addr, _instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType)), 100);
2742-
2743-
_instance->m_sleepTime = 0;
2744-
_instance->m_pollThreadState = POLL_THREAD_STATE_PING;
2722+
try(){
2723+
2724+
logicalAddress = LogicalAddress(_instance->m_logicalAddressAllocated);
2725+
LibCCEC::getInstance().addLogicalAddress(logicalAddress);
2726+
_instance->smConnection->setSource(logicalAddress);
2727+
_instance->m_numberOfDevices = 0;
2728+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType = DeviceType::TV;
2729+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_isDevicePresent = true;
2730+
_instance->deviceList[_instance->m_logicalAddressAllocated].update(physical_addr);
2731+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_1_4;
2732+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_vendorID = appVendorId;
2733+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState);
2734+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage = defaultLanguage;
2735+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_osdName = osdName.toString().c_str();
2736+
if(cecVersion == 2.0) {
2737+
_instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_2_0;
2738+
_instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST),
2739+
MessageEncoder().encode(ReportFeatures(Version::V_2_0,allDevicetype,rcProfile,deviceFeatures)), 500);
2740+
}
2741+
_instance->smConnection->addFrameListener(_instance->msgFrameListener);
2742+
_instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST),
2743+
MessageEncoder().encode(ReportPhysicalAddress(physical_addr, _instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType)), 100);
2744+
2745+
_instance->m_sleepTime = 0;
2746+
_instance->m_pollThreadState = POLL_THREAD_STATE_PING;
2747+
}
2748+
catch(InvalidStateException &e){
2749+
LOGWARN("InvalidStateException caught in LibCCEC::getInstance().addLogicalAddress() %s", e.what());
2750+
LOGINFO("Not able allocate Logical Address for TV");
2751+
_instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2752+
}
2753+
catch(IOException &e){
2754+
LOGWARN("IOException caught in LibCCEC::getInstance().addLogicalAddress() %s", e.what());
2755+
LOGINFO("Not able allocate Logical Address for TV");
2756+
_instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2757+
}
2758+
catch (const std::exception& e)
2759+
{
2760+
LOGWARN("CEC exception caught from LibCCEC::getInstance().addLogicalAddress() ");
2761+
LOGINFO("Not able allocate Logical Address for TV");
2762+
_instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2763+
}
2764+
catch(...){
2765+
LOGWARN("Exception caught in LibCCEC::getInstance().addLogicalAddress()");
2766+
LOGINFO("Not able allocate Logical Address for TV");
2767+
_instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2768+
}
27452769
}
27462770
else
27472771
{
@@ -2977,9 +3001,18 @@ namespace WPEFramework
29773001
{
29783002
LibCCEC::getInstance().init("HdmiCecSink");
29793003
}
3004+
catch(InvalidStateException &e){
3005+
LOGWARN("InvalidStateException caught in LibCCEC::init %s", e.what());
3006+
}
3007+
catch(IOException &e){
3008+
LOGWARN("IOException caught in LibCCEC::init %s", e.what());
3009+
}
29803010
catch (const std::exception& e)
29813011
{
2982-
LOGWARN("CEC exception caught from LibCCEC::getInstance().init()");
3012+
LOGWARN("CEC exception caught from CECEnable");
3013+
}
3014+
catch(...){
3015+
LOGWARN("Exception caught in LibCCEC::init");
29833016
}
29843017
}
29853018
libcecInitStatus++;
@@ -3088,9 +3121,18 @@ namespace WPEFramework
30883121
{
30893122
LibCCEC::getInstance().term();
30903123
}
3124+
catch(InvalidStateException &e){
3125+
LOGWARN("InvalidStateException caught in LibCCEC::term %s", e.what());
3126+
}
3127+
catch(IOException &e){
3128+
LOGWARN("IOException caught in LibCCEC::term %s", e.what());
3129+
}
30913130
catch (const std::exception& e)
30923131
{
3093-
LOGWARN("CEC exception caught from LibCCEC::getInstance().term() ");
3132+
LOGWARN("CEC exception caught from CECEnable");
3133+
}
3134+
catch(...){
3135+
LOGWARN("Exception caught in LibCCEC::term");
30943136
}
30953137
}
30963138

0 commit comments

Comments
 (0)