Skip to content

Commit

Permalink
RDKShell: Skip SetFocus to false for Suspended or Hibernated plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 committed Nov 16, 2023
1 parent cc2c93e commit 24405f5
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions RDKShell/RDKShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ std::mutex nativeAppWasResumedMutex;
map<string,bool> nativeAppWasResumed;
#endif

std::mutex suspendedOrHibernatedAppsMutex;
map<string, bool> suspendedOrHibernatedApps;

#define ANY_KEY 65536
#define RDKSHELL_THUNDER_TIMEOUT 20000
#define RDKSHELL_POWER_TIME_WAIT 2.5
Expand Down Expand Up @@ -611,6 +614,10 @@ namespace WPEFramework {
mLaunchEnabled = false;
}

suspendedOrHibernatedAppsMutex.lock();
suspendedOrHibernatedApps[mCallSign] = isSuspended;
suspendedOrHibernatedAppsMutex.unlock();

if (isSuspended)
{
JsonObject params;
Expand Down Expand Up @@ -1054,6 +1061,11 @@ namespace WPEFramework {
nativeAppWasResumed[service->Callsign()] = false;
nativeAppWasResumedMutex.unlock();
#endif
//Reset app suspended/hibernated
suspendedOrHibernatedAppsMutex.lock();
suspendedOrHibernatedApps[service->Callsign()] = false;
suspendedOrHibernatedAppsMutex.unlock();

if(service->Reason() == PluginHost::IShell::FAILURE)
{
gApplicationsExitReason[service->Callsign()] = AppLastExitReason::CRASH;
Expand Down Expand Up @@ -1122,6 +1134,11 @@ namespace WPEFramework {
nativeAppWasResumed[service->Callsign()] = false;
nativeAppWasResumedMutex.unlock();
#endif
//Reset app suspended/hibernated
suspendedOrHibernatedAppsMutex.lock();
suspendedOrHibernatedApps[service->Callsign()] = false;
suspendedOrHibernatedAppsMutex.unlock();

}
if(service->Reason() == PluginHost::IShell::FAILURE)
{
Expand Down Expand Up @@ -3850,6 +3867,12 @@ namespace WPEFramework {
}
}

//Reset app suspended/hibernated for launch
suspendedOrHibernatedAppsMutex.lock();
suspendedOrHibernatedApps[appCallsign] = false;
suspendedOrHibernatedAppsMutex.unlock();


//check to see if plugin already exists
bool newPluginFound = false;
bool originalPluginFound = false;
Expand Down Expand Up @@ -6605,14 +6628,34 @@ namespace WPEFramework {
std::string compositorName = toLower(previousFocusedIterator->first);
if (compositorName == previousFocusedClient)
{
std::cout << "setting the focus of " << compositorName << " to false " << std::endl;
Exchange::IFocus *focusedCallsign = mCurrentService->QueryInterfaceByCallsign<Exchange::IFocus>(previousFocusedIterator->first);
if (focusedCallsign != NULL)
#ifdef HIBERNATE_SUPPORT_ENABLED
// Skip for suspended and hibernated apps, since not needed and may cause unwanted restore from hibernation
bool skipFocus = false;
suspendedOrHibernatedAppsMutex.lock();
if (suspendedOrHibernatedApps.find(previousFocusedIterator->first) != suspendedOrHibernatedApps.end())
{
uint32_t status = focusedCallsign->Focused(false);
std::cout << "result of set focus to false: " << status << std::endl;
focusedCallsign->Release();
skipFocus = suspendedOrHibernatedApps[previousFocusedIterator->first];
}

if (skipFocus == false)
{
#endif
std::cout << "setting the focus of " << compositorName << " to false " << std::endl;
Exchange::IFocus *focusedCallsign = mCurrentService->QueryInterfaceByCallsign<Exchange::IFocus>(previousFocusedIterator->first);
if (focusedCallsign != NULL)
{
uint32_t status = focusedCallsign->Focused(false);
std::cout << "result of set focus to false: " << status << std::endl;
focusedCallsign->Release();
}
#ifdef HIBERNATE_SUPPORT_ENABLED
}
else
{
std::cout << "setting the focus for " << compositorName << " to false skipped, plugin suspended or hibernated " << std::endl;
}
suspendedOrHibernatedAppsMutex.unlock();
#endif
break;
}
}
Expand Down

0 comments on commit 24405f5

Please sign in to comment.