diff --git a/.gitignore b/.gitignore index 56fe945..f22caa2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ src/settings/SettingsConf.h resources screenlog* *ipk +sa8155* diff --git a/src/base/LunaTask.cpp b/src/base/LunaTask.cpp index 8a803a9..bf34475 100644 --- a/src/base/LunaTask.cpp +++ b/src/base/LunaTask.cpp @@ -20,15 +20,17 @@ #include "RunningAppList.h" #include "util/JValueUtil.h" +#define LOG_NAME "LunaTask" + int LunaTask::getDisplayId() { // TODO This is temp solution about displayId // When home app support peropery. Please detete following code block if (getAppId().find("home1") != string::npos) { - Logger::info("LunaTask", __FUNCTION__, "Reserved AppId. DispalyId is 1"); + Logger::info(LOG_NAME, __FUNCTION__, "Reserved AppId. DispalyId is 1"); return 1; } else if (getAppId().find("statusbar1") != string::npos) { - Logger::info("LunaTask", __FUNCTION__, "Reserved AppId. DispalyId is 1"); + Logger::info(LOG_NAME, __FUNCTION__, "Reserved AppId. DispalyId is 1"); return 1; } @@ -40,5 +42,13 @@ int LunaTask::getDisplayId() void LunaTask::setDisplayId(const int displayId) { + int oldDisplayId = getDisplayId(); + if (oldDisplayId != -1 && oldDisplayId != displayId) { + Logger::warning(LOG_NAME, __FUNCTION__, Logger::format("DisplayId is not empty: Old(%d) New(%d)", oldDisplayId, displayId)); + } m_requestPayload.put("displayId", displayId); + if (!m_requestPayload.hasKey("params")) { + m_requestPayload.put("params", pbnjson::Object()); + } + m_requestPayload["params"].put("displayAffinity", displayId); } diff --git a/src/base/RunningAppList.cpp b/src/base/RunningAppList.cpp index 41d907c..978680c 100644 --- a/src/base/RunningAppList.cpp +++ b/src/base/RunningAppList.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019 LG Electronics, Inc. +// Copyright (c) 2019-2020 LG Electronics, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include "base/RunningAppList.h" #include "bus/service/ApplicationManager.h" +#include "conf/RuntimeInfo.h" RunningAppList::RunningAppList() { @@ -102,6 +103,7 @@ RunningAppPtr RunningAppList::getByLunaTask(LunaTaskPtr lunaTask) { if (lunaTask == nullptr) return nullptr; + string appId = lunaTask->getAppId(); string launchPointId = lunaTask->getLaunchPointId(); string instanceId = lunaTask->getInstanceId(); @@ -120,6 +122,13 @@ RunningAppPtr RunningAppList::getByLunaTask(LunaTaskPtr lunaTask) lunaTask->setLaunchPointId(runningApp->getLaunchPointId()); lunaTask->setAppId(runningApp->getAppId()); lunaTask->setDisplayId(runningApp->getDisplayId()); + } else { + // default values + if (RuntimeInfo::getInstance().isInContainer()) { + lunaTask->setDisplayId(RuntimeInfo::getInstance().getDisplayId()); + } else if (lunaTask->getDisplayId() == -1) { + lunaTask->setDisplayId(0); + } } return runningApp; } diff --git a/src/base/RunningAppList.h b/src/base/RunningAppList.h index 62ede80..11085be 100644 --- a/src/base/RunningAppList.h +++ b/src/base/RunningAppList.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019 LG Electronics, Inc. +// Copyright (c) 2019-2020 LG Electronics, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/bus/service/ApplicationManager.cpp b/src/bus/service/ApplicationManager.cpp index 1e89a50..63f7013 100644 --- a/src/bus/service/ApplicationManager.cpp +++ b/src/bus/service/ApplicationManager.cpp @@ -250,15 +250,16 @@ void ApplicationManager::launch(LunaTaskPtr lunaTask) return; } - // If it is launch (not relaunch), assign default displayId - if (lunaTask->getDisplayId() == -1) { - lunaTask->setDisplayId(0); - } PolicyManager::getInstance().launch(lunaTask); } void ApplicationManager::pause(LunaTaskPtr lunaTask) { + RunningAppPtr runningApp = RunningAppList::getInstance().getByLunaTask(lunaTask); + if (runningApp == nullptr) { + LunaTaskList::getInstance().removeAfterReply(lunaTask, ErrCode_GENERAL, lunaTask->getId() + " is not running"); + return; + } PolicyManager::getInstance().pause(lunaTask); return; } diff --git a/src/conf/RuntimeInfo.cpp b/src/conf/RuntimeInfo.cpp index 8ca18e6..1eacf26 100644 --- a/src/conf/RuntimeInfo.cpp +++ b/src/conf/RuntimeInfo.cpp @@ -16,7 +16,11 @@ #include "RuntimeInfo.h" +#include + RuntimeInfo::RuntimeInfo() + : m_displayId(-1), + m_isInContainer(false) { setClassName("RuntimeInfo"); } @@ -27,6 +31,16 @@ RuntimeInfo::~RuntimeInfo() void RuntimeInfo::initialize() { + string displayId = getenv("DISPLAY_ID"); + string container = getenv("container"); + + if (!displayId.empty()) { + m_displayId = stoi(displayId.c_str()); + } + if (!container.empty()) { + m_isInContainer = true; + } + Logger::info(getClassName(), __FUNCTION__, Logger::format("DisplayId(%d) IsInContainer(%s)", m_displayId, Logger::toString(m_isInContainer))); load(); } diff --git a/src/conf/RuntimeInfo.h b/src/conf/RuntimeInfo.h index 36aebfc..aad381e 100644 --- a/src/conf/RuntimeInfo.h +++ b/src/conf/RuntimeInfo.h @@ -17,6 +17,8 @@ #ifndef CONF_RUNTIMEINFO_H_ #define CONF_RUNTIMEINFO_H_ +#include + #include #include "Environment.h" @@ -40,6 +42,17 @@ friend class ISingleton ; bool getValue(const string& key, JValue& value); bool setValue(const string& key, JValue& value); + int getDisplayId() + { + return m_displayId; + } + + bool isInContainer() + { + return m_isInContainer; + } + + private: RuntimeInfo(); @@ -48,6 +61,9 @@ friend class ISingleton ; JValue m_database; + int m_displayId; + bool m_isInContainer; + }; #endif /* CONF_RUNTIMEINFO_H_ */