Skip to content

Commit

Permalink
Merge branch 'profiles' into develop
Browse files Browse the repository at this point in the history
Change-Id: Ie405ae35bdd7dfad121943026aac4f376c711f34
  • Loading branch information
sangwoo-kang committed Mar 16, 2020
2 parents 016dd3a + 6f73194 commit 9968a27
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/settings/SettingsConf.h
resources
screenlog*
*ipk
sa8155*
14 changes: 12 additions & 2 deletions src/base/LunaTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
11 changes: 10 additions & 1 deletion src/base/RunningAppList.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -17,6 +17,7 @@
#include "base/RunningAppList.h"

#include "bus/service/ApplicationManager.h"
#include "conf/RuntimeInfo.h"

RunningAppList::RunningAppList()
{
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/base/RunningAppList.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 5 additions & 4 deletions src/bus/service/ApplicationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 14 additions & 0 deletions src/conf/RuntimeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

#include "RuntimeInfo.h"

#include <stdlib.h>

RuntimeInfo::RuntimeInfo()
: m_displayId(-1),
m_isInContainer(false)
{
setClassName("RuntimeInfo");
}
Expand All @@ -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();
}

Expand Down
16 changes: 16 additions & 0 deletions src/conf/RuntimeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef CONF_RUNTIMEINFO_H_
#define CONF_RUNTIMEINFO_H_

#include <iostream>

#include <pbnjson.hpp>

#include "Environment.h"
Expand All @@ -40,6 +42,17 @@ friend class ISingleton<RuntimeInfo> ;
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();

Expand All @@ -48,6 +61,9 @@ friend class ISingleton<RuntimeInfo> ;

JValue m_database;

int m_displayId;
bool m_isInContainer;

};

#endif /* CONF_RUNTIMEINFO_H_ */

0 comments on commit 9968a27

Please sign in to comment.