#include <package_manager.h>
#include <unistd.h>
+#include "common/extension.h"
#include "common/logger.h"
#include "common/scope_exit.h"
namespace common {
-CurrentApplication& CurrentApplication::GetInstance() {
+namespace {
+
+std::string GetRuntimeVariable(const char* variable_name) {
+ return common::Extension::GetRuntimeVariableString(variable_name);
+}
+
+} // namespace
+
+CurrentApplication &CurrentApplication::GetInstance() {
ScopeLogger();
static CurrentApplication current_application;
return current_application;
std::string CurrentApplication::GetApplicationId() const {
ScopeLogger();
- return app_id_;
+ auto app_id = GetRuntimeVariable("application_id");
+ LoggerI("GetRuntimeVariable: cached application_id: %s, runtime application_id: %s", app_id_.c_str(), app_id.c_str());
+ return app_id.empty() ? app_id_ : app_id;
}
std::string CurrentApplication::GetPackageId() const {
ScopeLogger();
- return package_id_;
+ auto pkg_id = GetRuntimeVariable("package_id");
+ LoggerI("GetRuntimeVariable: cached package_id: %s, runtime package_id: %s", package_id_.c_str(), pkg_id.c_str());
+ return pkg_id.empty() ? package_id_ : pkg_id;
}
std::string CurrentApplication::GetRoot() const {
ScopeLogger();
- return root_;
+ auto app_root = GetRuntimeVariable("app_root");
+ LoggerI("GetRuntimeVariable: cached app_root: %s, runtime app_root: %s", root_.c_str(), app_root.c_str());
+ return app_root.empty() ? root_ : app_root;
}
CurrentApplication::CurrentApplication()