Skip to content

Commit

Permalink
Merge branch 'sprint/24Q3' into sprint/24Q3
Browse files Browse the repository at this point in the history
  • Loading branch information
goruklu authored Sep 25, 2024
2 parents 2da0f60 + e9c97d4 commit 8863132
Show file tree
Hide file tree
Showing 23 changed files with 1,643 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/workflows/L2-tests-R4-4-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-RDK-45037-Secure-Storage-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDK-51362-System-Mode-Thunder-Plugin.patch
cd ..
- name: Build ThunderInterfaces
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ if(PLUGIN_CONTROLSERVICE)
add_subdirectory(ControlService)
endif()

if(PLUGIN_SYSTEMMODE)
add_subdirectory(SystemMode)
endif()

if(PLUGIN_USERSETTINGS)
add_subdirectory(UserSettings)
endif()
Expand Down
230 changes: 191 additions & 39 deletions DisplaySettings/DisplaySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,34 @@ namespace WPEFramework {

DisplaySettings::DisplaySettings()
: PluginHost::JSONRPC()
, _engine(Core::ProxyType<RPC::InvokeServerType<1, 0, 4>>::Create())
, _communicatorClient(Core::ProxyType<RPC::CommunicatorClient>::Create(Core::NodeId("/tmp/communicator"), Core::ProxyType<Core::IIPCServer>(_engine)))
, _controller(nullptr)
, _remotStoreObject(nullptr)
{
LOGINFO("ctor");
DisplaySettings::_instance = this;
m_client = nullptr;

CreateHandler({ 2 });

if (!_communicatorClient.IsValid())
{
LOGWARN("Invalid _communicatorClient \n");
}
else
{

#if ((THUNDER_VERSION == 2) || ((THUNDER_VERSION == 4) && (THUNDER_VERSION_MINOR == 2)))
_engine->Announcements(_communicatorClient->Announcement());
#endif

LOGINFO("Connect the COM-RPC socket\n");
_controller = _communicatorClient->Open<PluginHost::IShell>(_T("org.rdk.SystemMode"), ~0, 3000);


}

registerMethodLockedApi("getConnectedVideoDisplays", &DisplaySettings::getConnectedVideoDisplays, this);
registerMethodLockedApi("getConnectedAudioPorts", &DisplaySettings::getConnectedAudioPorts, this);
registerMethodLockedApi("setEnableAudioPort", &DisplaySettings::setEnableAudioPort, this);
Expand Down Expand Up @@ -368,12 +389,36 @@ namespace WPEFramework {
}

DisplaySettings::~DisplaySettings()
{
LOGINFO ("dtor");
isResCacheUpdated = false;
isDisplayConnectedCacheUpdated = false;
isStbHDRcapabilitiesCache = false;
}
{
if (_controller)
{
_controller->Release();
_controller = nullptr;
}

LOGINFO("Disconnect from the COM-RPC socket\n");
// Disconnect from the COM-RPC socket
_communicatorClient->Close(RPC::CommunicationTimeOut);
if (_communicatorClient.IsValid())
{
_communicatorClient.Release();
}

if(_engine.IsValid())
{
_engine.Release();
}

if(_remotStoreObject)
{
_remotStoreObject->Release();
}

LOGINFO ("dtor");
isResCacheUpdated = false;
isDisplayConnectedCacheUpdated = false;
isStbHDRcapabilitiesCache = false;
}

void DisplaySettings::AudioPortsReInitialize()
{
Expand Down Expand Up @@ -557,48 +602,116 @@ namespace WPEFramework {
LOGWARN("Current power state %d", m_powerState);
}
LOGWARN ("DisplaySettings::Initialize completes line:%d", __LINE__);

if (_controller)
{
_remotStoreObject = _controller->QueryInterface<Exchange::ISystemMode>();

if(_remotStoreObject)
{
_remotStoreObject->AddRef();
}
else
{
LOGERR("Failed to create SystemMode _controller\n");
}
}
else
{
LOGERR("Failed to create SystemMode Controller\n");
}
ASSERT (nullptr != _remotStoreObject);


if(_remotStoreObject)
{
const string& callsign = "org.rdk.DisplaySettings";
const string& systemMode = "DEVICE_OPTIMIZE";
_remotStoreObject->ClientActivated(callsign,systemMode);
}
else
{
Utils::String::updateSystemModeFile( "DEVICE_OPTIMIZE", "callsign", "org.rdk.DisplaySettings","add") ;
}

// On success return empty, to indicate there is no error text.
return (string());
}

void DisplaySettings::Deinitialize(PluginHost::IShell* service)
{
LOGINFO("Enetering DisplaySettings::Deinitialize");
{
std::unique_lock<std::mutex> lock(DisplaySettings::_instance->m_sendMsgMutex);
DisplaySettings::_instance->m_sendMsgThreadExit = true;
DisplaySettings::_instance->m_sendMsgThreadRun = true;
DisplaySettings::_instance->m_sendMsgCV.notify_one();
}
int count = 0;
while(audioPortInitActive && count < 20){
sleep(100);
count++;
}
try
{
if (m_sendMsgThread.joinable())
m_sendMsgThread.join();
}
catch(const std::system_error& e)
{
LOGERR("system_error exception in thread join %s", e.what());
}
catch(const std::exception& e)
{
LOGERR("exception in thread join %s", e.what());
}
{
LOGINFO("Enetering DisplaySettings::Deinitialize");

stopCecTimeAndUnsubscribeEvent();
//During DisplaySettings plugin activation the SystemMode may not be added .But it will be added /tmp/SystemMode.txt . If after 5 min SystemMode got activated then SystemMode fill the client map from /tmp/SystemMode.txt. In this case if we deactivate DisplaySettings then _remotStoreObject will be null here . So we try to QueryInterface the ISystemMode one more time
if(_remotStoreObject == nullptr)
{
if (_controller)
{
_remotStoreObject = _controller->QueryInterface<Exchange::ISystemMode>();

DeinitializeIARM();
DisplaySettings::_instance = nullptr;
if(_remotStoreObject)
{
_remotStoreObject->AddRef();
}
else
{
LOGERR("Failed to create SystemMode _controller\n");
}
}
else
{
LOGERR("Failed to create SystemMode Controller\n");
}
}

ASSERT(service == m_service);
ASSERT (nullptr != _remotStoreObject);

m_service->Release();
m_service = nullptr;
}
if(_remotStoreObject)
{
const string& callsign = "org.rdk.DisplaySettings";
const string& systemMode = "DEVICE_OPTIMIZE";
_remotStoreObject->ClientDeactivated(callsign,systemMode);
}
else
{
Utils::String::updateSystemModeFile( "DEVICE_OPTIMIZE", "callsign", "org.rdk.DisplaySettings","delete") ;
}

{
std::unique_lock<std::mutex> lock(DisplaySettings::_instance->m_sendMsgMutex);
DisplaySettings::_instance->m_sendMsgThreadExit = true;
DisplaySettings::_instance->m_sendMsgThreadRun = true;
DisplaySettings::_instance->m_sendMsgCV.notify_one();
}
int count = 0;
while(audioPortInitActive && count < 20){
sleep(100);
count++;
}
try
{
if (m_sendMsgThread.joinable())
m_sendMsgThread.join();
}
catch(const std::system_error& e)
{
LOGERR("system_error exception in thread join %s", e.what());
}
catch(const std::exception& e)
{
LOGERR("exception in thread join %s", e.what());
}

stopCecTimeAndUnsubscribeEvent();

DeinitializeIARM();
DisplaySettings::_instance = nullptr;

ASSERT(service == m_service);

m_service->Release();
m_service = nullptr;
}

void DisplaySettings::InitializeIARM()
{
Expand Down Expand Up @@ -5880,6 +5993,14 @@ void DisplaySettings::sendMsgThread()
sendNotify("connectedVideoDisplaysUpdated", params);
}
previousStatus = hdmiHotPlugEvent;

//If HDMI hotplug event occurs, DisplaySettings re-evaluate whether it should be signalling ALLM output of the HDMI port
std::string currentAllmState = "";
Utils::String::getSystemModePropertyValue("DEVICE_OPTIMIZE" ,"currentstate" , currentAllmState);
if(currentAllmState == "VIDEO" || currentAllmState == "GAME")
{
Request(currentAllmState);
}
}

void DisplaySettings::connectedAudioPortUpdated (int iAudioPortType, bool isPortConnected)
Expand Down Expand Up @@ -6164,5 +6285,36 @@ void DisplaySettings::sendMsgThread()

return mode;
}

void DisplaySettings::Request(const string& newState)
{
vector<string> connectedDisplays;
getConnectedVideoDisplaysHelper(connectedDisplays);
for (int i = 0; i < (int)connectedDisplays.size(); i++)
{
try
{
std::string strVideoPort = connectedDisplays.at(i);;
device::VideoOutputPort vPort = device::Host::getInstance().getVideoOutputPort(strVideoPort.c_str());
if (isDisplayConnected(strVideoPort))
{
bool enable = (newState == "GAME") ? true : false;
vPort.setAllmEnabled(enable);
}
else
{
LOGWARN("failure: %s is not connected!",strVideoPort.c_str());
}
}
catch (const device::Exception& err)
{
LOG_DEVICE_EXCEPTION0();
}
}
if( 0 == (int)connectedDisplays.size())
{
LOGWARN("No display connected to device (or)device's powerstate is not ON");
}
}
} // namespace Plugin
} // namespace WPEFramework
16 changes: 15 additions & 1 deletion DisplaySettings/DisplaySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "irMgr.h"
#include "pwrMgr.h"
#include "rfcapi.h"
#include <interfaces/ISystemMode.h>
#include <interfaces/IDeviceOptimizeStateActivator.h>
#include <iostream>
#include <fstream>

namespace WPEFramework {

Expand All @@ -45,7 +49,7 @@ namespace WPEFramework {
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
class DisplaySettings : public PluginHost::IPlugin, public PluginHost::JSONRPC {
class DisplaySettings : public PluginHost::IPlugin, public PluginHost::JSONRPC ,Exchange::IDeviceOptimizeStateActivator {
private:
typedef Core::JSON::String JString;
typedef Core::JSON::ArrayType<JString> JStringArray;
Expand Down Expand Up @@ -192,8 +196,11 @@ namespace WPEFramework {
BEGIN_INTERFACE_MAP(DisplaySettings)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
INTERFACE_ENTRY(Exchange::IDeviceOptimizeStateActivator)
END_INTERFACE_MAP

void Request(const string& newState);

private:
void InitializeIARM();
void DeinitializeIARM();
Expand Down Expand Up @@ -316,6 +323,13 @@ namespace WPEFramework {
public:
static DisplaySettings* _instance;

private:
mutable Core::CriticalSection _adminLock;
Core::ProxyType<RPC::InvokeServerType<1, 0, 4>> _engine;
Core::ProxyType<RPC::CommunicatorClient> _communicatorClient;
PluginHost::IShell *_controller;
Exchange::ISystemMode* _remotStoreObject;

};
} // namespace Plugin
} // namespace WPEFramework
24 changes: 24 additions & 0 deletions SystemMode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog

All notable changes to this RDK Service will be documented in this file.

* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG.

* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels:
* **Added** for new features.
* **Changed** for changes in existing functionality.
* **Deprecated** for soon-to-be removed features.
* **Removed** for now removed features.
* **Fixed** for any bug fixes.
* **Security** in case of vulnerabilities.

* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
## [1.0.0] - 16-08-2024
### Added
- Add CHANGELOG

### Change
- Reset API version to 1.0.0
- Change README to inform how to update changelog and API version
Loading

0 comments on commit 8863132

Please sign in to comment.